babylon.max.js 6.8 MB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259226022612262226322642265226622672268226922702271227222732274227522762277227822792280228122822283228422852286228722882289229022912292229322942295229622972298229923002301230223032304230523062307230823092310231123122313231423152316231723182319232023212322232323242325232623272328232923302331233223332334233523362337233823392340234123422343234423452346234723482349235023512352235323542355235623572358235923602361236223632364236523662367236823692370237123722373237423752376237723782379238023812382238323842385238623872388238923902391239223932394239523962397239823992400240124022403240424052406240724082409241024112412241324142415241624172418241924202421242224232424242524262427242824292430243124322433243424352436243724382439244024412442244324442445244624472448244924502451245224532454245524562457245824592460246124622463246424652466246724682469247024712472247324742475247624772478247924802481248224832484248524862487248824892490249124922493249424952496249724982499250025012502250325042505250625072508250925102511251225132514251525162517251825192520252125222523252425252526252725282529253025312532253325342535253625372538253925402541254225432544254525462547254825492550255125522553255425552556255725582559256025612562256325642565256625672568256925702571257225732574257525762577257825792580258125822583258425852586258725882589259025912592259325942595259625972598259926002601260226032604260526062607260826092610261126122613261426152616261726182619262026212622262326242625262626272628262926302631263226332634263526362637263826392640264126422643264426452646264726482649265026512652265326542655265626572658265926602661266226632664266526662667266826692670267126722673267426752676267726782679268026812682268326842685268626872688268926902691269226932694269526962697269826992700270127022703270427052706270727082709271027112712271327142715271627172718271927202721272227232724272527262727272827292730273127322733273427352736273727382739274027412742274327442745274627472748274927502751275227532754275527562757275827592760276127622763276427652766276727682769277027712772277327742775277627772778277927802781278227832784278527862787278827892790279127922793279427952796279727982799280028012802280328042805280628072808280928102811281228132814281528162817281828192820282128222823282428252826282728282829283028312832283328342835283628372838283928402841284228432844284528462847284828492850285128522853285428552856285728582859286028612862286328642865286628672868286928702871287228732874287528762877287828792880288128822883288428852886288728882889289028912892289328942895289628972898289929002901290229032904290529062907290829092910291129122913291429152916291729182919292029212922292329242925292629272928292929302931293229332934293529362937293829392940294129422943294429452946294729482949295029512952295329542955295629572958295929602961296229632964296529662967296829692970297129722973297429752976297729782979298029812982298329842985298629872988298929902991299229932994299529962997299829993000300130023003300430053006300730083009301030113012301330143015301630173018301930203021302230233024302530263027302830293030303130323033303430353036303730383039304030413042304330443045304630473048304930503051305230533054305530563057305830593060306130623063306430653066306730683069307030713072307330743075307630773078307930803081308230833084308530863087308830893090309130923093309430953096309730983099310031013102310331043105310631073108310931103111311231133114311531163117311831193120312131223123312431253126312731283129313031313132313331343135313631373138313931403141314231433144314531463147314831493150315131523153315431553156315731583159316031613162316331643165316631673168316931703171317231733174317531763177317831793180318131823183318431853186318731883189319031913192319331943195319631973198319932003201320232033204320532063207320832093210321132123213321432153216321732183219322032213222322332243225322632273228322932303231323232333234323532363237323832393240324132423243324432453246324732483249325032513252325332543255325632573258325932603261326232633264326532663267326832693270327132723273327432753276327732783279328032813282328332843285328632873288328932903291329232933294329532963297329832993300330133023303330433053306330733083309331033113312331333143315331633173318331933203321332233233324332533263327332833293330333133323333333433353336333733383339334033413342334333443345334633473348334933503351335233533354335533563357335833593360336133623363336433653366336733683369337033713372337333743375337633773378337933803381338233833384338533863387338833893390339133923393339433953396339733983399340034013402340334043405340634073408340934103411341234133414341534163417341834193420342134223423342434253426342734283429343034313432343334343435343634373438343934403441344234433444344534463447344834493450345134523453345434553456345734583459346034613462346334643465346634673468346934703471347234733474347534763477347834793480348134823483348434853486348734883489349034913492349334943495349634973498349935003501350235033504350535063507350835093510351135123513351435153516351735183519352035213522352335243525352635273528352935303531353235333534353535363537353835393540354135423543354435453546354735483549355035513552355335543555355635573558355935603561356235633564356535663567356835693570357135723573357435753576357735783579358035813582358335843585358635873588358935903591359235933594359535963597359835993600360136023603360436053606360736083609361036113612361336143615361636173618361936203621362236233624362536263627362836293630363136323633363436353636363736383639364036413642364336443645364636473648364936503651365236533654365536563657365836593660366136623663366436653666366736683669367036713672367336743675367636773678367936803681368236833684368536863687368836893690369136923693369436953696369736983699370037013702370337043705370637073708370937103711371237133714371537163717371837193720372137223723372437253726372737283729373037313732373337343735373637373738373937403741374237433744374537463747374837493750375137523753375437553756375737583759376037613762376337643765376637673768376937703771377237733774377537763777377837793780378137823783378437853786378737883789379037913792379337943795379637973798379938003801380238033804380538063807380838093810381138123813381438153816381738183819382038213822382338243825382638273828382938303831383238333834383538363837383838393840384138423843384438453846384738483849385038513852385338543855385638573858385938603861386238633864386538663867386838693870387138723873387438753876387738783879388038813882388338843885388638873888388938903891389238933894389538963897389838993900390139023903390439053906390739083909391039113912391339143915391639173918391939203921392239233924392539263927392839293930393139323933393439353936393739383939394039413942394339443945394639473948394939503951395239533954395539563957395839593960396139623963396439653966396739683969397039713972397339743975397639773978397939803981398239833984398539863987398839893990399139923993399439953996399739983999400040014002400340044005400640074008400940104011401240134014401540164017401840194020402140224023402440254026402740284029403040314032403340344035403640374038403940404041404240434044404540464047404840494050405140524053405440554056405740584059406040614062406340644065406640674068406940704071407240734074407540764077407840794080408140824083408440854086408740884089409040914092409340944095409640974098409941004101410241034104410541064107410841094110411141124113411441154116411741184119412041214122412341244125412641274128412941304131413241334134413541364137413841394140414141424143414441454146414741484149415041514152415341544155415641574158415941604161416241634164416541664167416841694170417141724173417441754176417741784179418041814182418341844185418641874188418941904191419241934194419541964197419841994200420142024203420442054206420742084209421042114212421342144215421642174218421942204221422242234224422542264227422842294230423142324233423442354236423742384239424042414242424342444245424642474248424942504251425242534254425542564257425842594260426142624263426442654266426742684269427042714272427342744275427642774278427942804281428242834284428542864287428842894290429142924293429442954296429742984299430043014302430343044305430643074308430943104311431243134314431543164317431843194320432143224323432443254326432743284329433043314332433343344335433643374338433943404341434243434344434543464347434843494350435143524353435443554356435743584359436043614362436343644365436643674368436943704371437243734374437543764377437843794380438143824383438443854386438743884389439043914392439343944395439643974398439944004401440244034404440544064407440844094410441144124413441444154416441744184419442044214422442344244425442644274428442944304431443244334434443544364437443844394440444144424443444444454446444744484449445044514452445344544455445644574458445944604461446244634464446544664467446844694470447144724473447444754476447744784479448044814482448344844485448644874488448944904491449244934494449544964497449844994500450145024503450445054506450745084509451045114512451345144515451645174518451945204521452245234524452545264527452845294530453145324533453445354536453745384539454045414542454345444545454645474548454945504551455245534554455545564557455845594560456145624563456445654566456745684569457045714572457345744575457645774578457945804581458245834584458545864587458845894590459145924593459445954596459745984599460046014602460346044605460646074608460946104611461246134614461546164617461846194620462146224623462446254626462746284629463046314632463346344635463646374638463946404641464246434644464546464647464846494650465146524653465446554656465746584659466046614662466346644665466646674668466946704671467246734674467546764677467846794680468146824683468446854686468746884689469046914692469346944695469646974698469947004701470247034704470547064707470847094710471147124713471447154716471747184719472047214722472347244725472647274728472947304731473247334734473547364737473847394740474147424743474447454746474747484749475047514752475347544755475647574758475947604761476247634764476547664767476847694770477147724773477447754776477747784779478047814782478347844785478647874788478947904791479247934794479547964797479847994800480148024803480448054806480748084809481048114812481348144815481648174818481948204821482248234824482548264827482848294830483148324833483448354836483748384839484048414842484348444845484648474848484948504851485248534854485548564857485848594860486148624863486448654866486748684869487048714872487348744875487648774878487948804881488248834884488548864887488848894890489148924893489448954896489748984899490049014902490349044905490649074908490949104911491249134914491549164917491849194920492149224923492449254926492749284929493049314932493349344935493649374938493949404941494249434944494549464947494849494950495149524953495449554956495749584959496049614962496349644965496649674968496949704971497249734974497549764977497849794980498149824983498449854986498749884989499049914992499349944995499649974998499950005001500250035004500550065007500850095010501150125013501450155016501750185019502050215022502350245025502650275028502950305031503250335034503550365037503850395040504150425043504450455046504750485049505050515052505350545055505650575058505950605061506250635064506550665067506850695070507150725073507450755076507750785079508050815082508350845085508650875088508950905091509250935094509550965097509850995100510151025103510451055106510751085109511051115112511351145115511651175118511951205121512251235124512551265127512851295130513151325133513451355136513751385139514051415142514351445145514651475148514951505151515251535154515551565157515851595160516151625163516451655166516751685169517051715172517351745175517651775178517951805181518251835184518551865187518851895190519151925193519451955196519751985199520052015202520352045205520652075208520952105211521252135214521552165217521852195220522152225223522452255226522752285229523052315232523352345235523652375238523952405241524252435244524552465247524852495250525152525253525452555256525752585259526052615262526352645265526652675268526952705271527252735274527552765277527852795280528152825283528452855286528752885289529052915292529352945295529652975298529953005301530253035304530553065307530853095310531153125313531453155316531753185319532053215322532353245325532653275328532953305331533253335334533553365337533853395340534153425343534453455346534753485349535053515352535353545355535653575358535953605361536253635364536553665367536853695370537153725373537453755376537753785379538053815382538353845385538653875388538953905391539253935394539553965397539853995400540154025403540454055406540754085409541054115412541354145415541654175418541954205421542254235424542554265427542854295430543154325433543454355436543754385439544054415442544354445445544654475448544954505451545254535454545554565457545854595460546154625463546454655466546754685469547054715472547354745475547654775478547954805481548254835484548554865487548854895490549154925493549454955496549754985499550055015502550355045505550655075508550955105511551255135514551555165517551855195520552155225523552455255526552755285529553055315532553355345535553655375538553955405541554255435544554555465547554855495550555155525553555455555556555755585559556055615562556355645565556655675568556955705571557255735574557555765577557855795580558155825583558455855586558755885589559055915592559355945595559655975598559956005601560256035604560556065607560856095610561156125613561456155616561756185619562056215622562356245625562656275628562956305631563256335634563556365637563856395640564156425643564456455646564756485649565056515652565356545655565656575658565956605661566256635664566556665667566856695670567156725673567456755676567756785679568056815682568356845685568656875688568956905691569256935694569556965697569856995700570157025703570457055706570757085709571057115712571357145715571657175718571957205721572257235724572557265727572857295730573157325733573457355736573757385739574057415742574357445745574657475748574957505751575257535754575557565757575857595760576157625763576457655766576757685769577057715772577357745775577657775778577957805781578257835784578557865787578857895790579157925793579457955796579757985799580058015802580358045805580658075808580958105811581258135814581558165817581858195820582158225823582458255826582758285829583058315832583358345835583658375838583958405841584258435844584558465847584858495850585158525853585458555856585758585859586058615862586358645865586658675868586958705871587258735874587558765877587858795880588158825883588458855886588758885889589058915892589358945895589658975898589959005901590259035904590559065907590859095910591159125913591459155916591759185919592059215922592359245925592659275928592959305931593259335934593559365937593859395940594159425943594459455946594759485949595059515952595359545955595659575958595959605961596259635964596559665967596859695970597159725973597459755976597759785979598059815982598359845985598659875988598959905991599259935994599559965997599859996000600160026003600460056006600760086009601060116012601360146015601660176018601960206021602260236024602560266027602860296030603160326033603460356036603760386039604060416042604360446045604660476048604960506051605260536054605560566057605860596060606160626063606460656066606760686069607060716072607360746075607660776078607960806081608260836084608560866087608860896090609160926093609460956096609760986099610061016102610361046105610661076108610961106111611261136114611561166117611861196120612161226123612461256126612761286129613061316132613361346135613661376138613961406141614261436144614561466147614861496150615161526153615461556156615761586159616061616162616361646165616661676168616961706171617261736174617561766177617861796180618161826183618461856186618761886189619061916192619361946195619661976198619962006201620262036204620562066207620862096210621162126213621462156216621762186219622062216222622362246225622662276228622962306231623262336234623562366237623862396240624162426243624462456246624762486249625062516252625362546255625662576258625962606261626262636264626562666267626862696270627162726273627462756276627762786279628062816282628362846285628662876288628962906291629262936294629562966297629862996300630163026303630463056306630763086309631063116312631363146315631663176318631963206321632263236324632563266327632863296330633163326333633463356336633763386339634063416342634363446345634663476348634963506351635263536354635563566357635863596360636163626363636463656366636763686369637063716372637363746375637663776378637963806381638263836384638563866387638863896390639163926393639463956396639763986399640064016402640364046405640664076408640964106411641264136414641564166417641864196420642164226423642464256426642764286429643064316432643364346435643664376438643964406441644264436444644564466447644864496450645164526453645464556456645764586459646064616462646364646465646664676468646964706471647264736474647564766477647864796480648164826483648464856486648764886489649064916492649364946495649664976498649965006501650265036504650565066507650865096510651165126513651465156516651765186519652065216522652365246525652665276528652965306531653265336534653565366537653865396540654165426543654465456546654765486549655065516552655365546555655665576558655965606561656265636564656565666567656865696570657165726573657465756576657765786579658065816582658365846585658665876588658965906591659265936594659565966597659865996600660166026603660466056606660766086609661066116612661366146615661666176618661966206621662266236624662566266627662866296630663166326633663466356636663766386639664066416642664366446645664666476648664966506651665266536654665566566657665866596660666166626663666466656666666766686669667066716672667366746675667666776678667966806681668266836684668566866687668866896690669166926693669466956696669766986699670067016702670367046705670667076708670967106711671267136714671567166717671867196720672167226723672467256726672767286729673067316732673367346735673667376738673967406741674267436744674567466747674867496750675167526753675467556756675767586759676067616762676367646765676667676768676967706771677267736774677567766777677867796780678167826783678467856786678767886789679067916792679367946795679667976798679968006801680268036804680568066807680868096810681168126813681468156816681768186819682068216822682368246825682668276828682968306831683268336834683568366837683868396840684168426843684468456846684768486849685068516852685368546855685668576858685968606861686268636864686568666867686868696870687168726873687468756876687768786879688068816882688368846885688668876888688968906891689268936894689568966897689868996900690169026903690469056906690769086909691069116912691369146915691669176918691969206921692269236924692569266927692869296930693169326933693469356936693769386939694069416942694369446945694669476948694969506951695269536954695569566957695869596960696169626963696469656966696769686969697069716972697369746975697669776978697969806981698269836984698569866987698869896990699169926993699469956996699769986999700070017002700370047005700670077008700970107011701270137014701570167017701870197020702170227023702470257026702770287029703070317032703370347035703670377038703970407041704270437044704570467047704870497050705170527053705470557056705770587059706070617062706370647065706670677068706970707071707270737074707570767077707870797080708170827083708470857086708770887089709070917092709370947095709670977098709971007101710271037104710571067107710871097110711171127113711471157116711771187119712071217122712371247125712671277128712971307131713271337134713571367137713871397140714171427143714471457146714771487149715071517152715371547155715671577158715971607161716271637164716571667167716871697170717171727173717471757176717771787179718071817182718371847185718671877188718971907191719271937194719571967197719871997200720172027203720472057206720772087209721072117212721372147215721672177218721972207221722272237224722572267227722872297230723172327233723472357236723772387239724072417242724372447245724672477248724972507251725272537254725572567257725872597260726172627263726472657266726772687269727072717272727372747275727672777278727972807281728272837284728572867287728872897290729172927293729472957296729772987299730073017302730373047305730673077308730973107311731273137314731573167317731873197320732173227323732473257326732773287329733073317332733373347335733673377338733973407341734273437344734573467347734873497350735173527353735473557356735773587359736073617362736373647365736673677368736973707371737273737374737573767377737873797380738173827383738473857386738773887389739073917392739373947395739673977398739974007401740274037404740574067407740874097410741174127413741474157416741774187419742074217422742374247425742674277428742974307431743274337434743574367437743874397440744174427443744474457446744774487449745074517452745374547455745674577458745974607461746274637464746574667467746874697470747174727473747474757476747774787479748074817482748374847485748674877488748974907491749274937494749574967497749874997500750175027503750475057506750775087509751075117512751375147515751675177518751975207521752275237524752575267527752875297530753175327533753475357536753775387539754075417542754375447545754675477548754975507551755275537554755575567557755875597560756175627563756475657566756775687569757075717572757375747575757675777578757975807581758275837584758575867587758875897590759175927593759475957596759775987599760076017602760376047605760676077608760976107611761276137614761576167617761876197620762176227623762476257626762776287629763076317632763376347635763676377638763976407641764276437644764576467647764876497650765176527653765476557656765776587659766076617662766376647665766676677668766976707671767276737674767576767677767876797680768176827683768476857686768776887689769076917692769376947695769676977698769977007701770277037704770577067707770877097710771177127713771477157716771777187719772077217722772377247725772677277728772977307731773277337734773577367737773877397740774177427743774477457746774777487749775077517752775377547755775677577758775977607761776277637764776577667767776877697770777177727773777477757776777777787779778077817782778377847785778677877788778977907791779277937794779577967797779877997800780178027803780478057806780778087809781078117812781378147815781678177818781978207821782278237824782578267827782878297830783178327833783478357836783778387839784078417842784378447845784678477848784978507851785278537854785578567857785878597860786178627863786478657866786778687869787078717872787378747875787678777878787978807881788278837884788578867887788878897890789178927893789478957896789778987899790079017902790379047905790679077908790979107911791279137914791579167917791879197920792179227923792479257926792779287929793079317932793379347935793679377938793979407941794279437944794579467947794879497950795179527953795479557956795779587959796079617962796379647965796679677968796979707971797279737974797579767977797879797980798179827983798479857986798779887989799079917992799379947995799679977998799980008001800280038004800580068007800880098010801180128013801480158016801780188019802080218022802380248025802680278028802980308031803280338034803580368037803880398040804180428043804480458046804780488049805080518052805380548055805680578058805980608061806280638064806580668067806880698070807180728073807480758076807780788079808080818082808380848085808680878088808980908091809280938094809580968097809880998100810181028103810481058106810781088109811081118112811381148115811681178118811981208121812281238124812581268127812881298130813181328133813481358136813781388139814081418142814381448145814681478148814981508151815281538154815581568157815881598160816181628163816481658166816781688169817081718172817381748175817681778178817981808181818281838184818581868187818881898190819181928193819481958196819781988199820082018202820382048205820682078208820982108211821282138214821582168217821882198220822182228223822482258226822782288229823082318232823382348235823682378238823982408241824282438244824582468247824882498250825182528253825482558256825782588259826082618262826382648265826682678268826982708271827282738274827582768277827882798280828182828283828482858286828782888289829082918292829382948295829682978298829983008301830283038304830583068307830883098310831183128313831483158316831783188319832083218322832383248325832683278328832983308331833283338334833583368337833883398340834183428343834483458346834783488349835083518352835383548355835683578358835983608361836283638364836583668367836883698370837183728373837483758376837783788379838083818382838383848385838683878388838983908391839283938394839583968397839883998400840184028403840484058406840784088409841084118412841384148415841684178418841984208421842284238424842584268427842884298430843184328433843484358436843784388439844084418442844384448445844684478448844984508451845284538454845584568457845884598460846184628463846484658466846784688469847084718472847384748475847684778478847984808481848284838484848584868487848884898490849184928493849484958496849784988499850085018502850385048505850685078508850985108511851285138514851585168517851885198520852185228523852485258526852785288529853085318532853385348535853685378538853985408541854285438544854585468547854885498550855185528553855485558556855785588559856085618562856385648565856685678568856985708571857285738574857585768577857885798580858185828583858485858586858785888589859085918592859385948595859685978598859986008601860286038604860586068607860886098610861186128613861486158616861786188619862086218622862386248625862686278628862986308631863286338634863586368637863886398640864186428643864486458646864786488649865086518652865386548655865686578658865986608661866286638664866586668667866886698670867186728673867486758676867786788679868086818682868386848685868686878688868986908691869286938694869586968697869886998700870187028703870487058706870787088709871087118712871387148715871687178718871987208721872287238724872587268727872887298730873187328733873487358736873787388739874087418742874387448745874687478748874987508751875287538754875587568757875887598760876187628763876487658766876787688769877087718772877387748775877687778778877987808781878287838784878587868787878887898790879187928793879487958796879787988799880088018802880388048805880688078808880988108811881288138814881588168817881888198820882188228823882488258826882788288829883088318832883388348835883688378838883988408841884288438844884588468847884888498850885188528853885488558856885788588859886088618862886388648865886688678868886988708871887288738874887588768877887888798880888188828883888488858886888788888889889088918892889388948895889688978898889989008901890289038904890589068907890889098910891189128913891489158916891789188919892089218922892389248925892689278928892989308931893289338934893589368937893889398940894189428943894489458946894789488949895089518952895389548955895689578958895989608961896289638964896589668967896889698970897189728973897489758976897789788979898089818982898389848985898689878988898989908991899289938994899589968997899889999000900190029003900490059006900790089009901090119012901390149015901690179018901990209021902290239024902590269027902890299030903190329033903490359036903790389039904090419042904390449045904690479048904990509051905290539054905590569057905890599060906190629063906490659066906790689069907090719072907390749075907690779078907990809081908290839084908590869087908890899090909190929093909490959096909790989099910091019102910391049105910691079108910991109111911291139114911591169117911891199120912191229123912491259126912791289129913091319132913391349135913691379138913991409141914291439144914591469147914891499150915191529153915491559156915791589159916091619162916391649165916691679168916991709171917291739174917591769177917891799180918191829183918491859186918791889189919091919192919391949195919691979198919992009201920292039204920592069207920892099210921192129213921492159216921792189219922092219222922392249225922692279228922992309231923292339234923592369237923892399240924192429243924492459246924792489249925092519252925392549255925692579258925992609261926292639264926592669267926892699270927192729273927492759276927792789279928092819282928392849285928692879288928992909291929292939294929592969297929892999300930193029303930493059306930793089309931093119312931393149315931693179318931993209321932293239324932593269327932893299330933193329333933493359336933793389339934093419342934393449345934693479348934993509351935293539354935593569357935893599360936193629363936493659366936793689369937093719372937393749375937693779378937993809381938293839384938593869387938893899390939193929393939493959396939793989399940094019402940394049405940694079408940994109411941294139414941594169417941894199420942194229423942494259426942794289429943094319432943394349435943694379438943994409441944294439444944594469447944894499450945194529453945494559456945794589459946094619462946394649465946694679468946994709471947294739474947594769477947894799480948194829483948494859486948794889489949094919492949394949495949694979498949995009501950295039504950595069507950895099510951195129513951495159516951795189519952095219522952395249525952695279528952995309531953295339534953595369537953895399540954195429543954495459546954795489549955095519552955395549555955695579558955995609561956295639564956595669567956895699570957195729573957495759576957795789579958095819582958395849585958695879588958995909591959295939594959595969597959895999600960196029603960496059606960796089609961096119612961396149615961696179618961996209621962296239624962596269627962896299630963196329633963496359636963796389639964096419642964396449645964696479648964996509651965296539654965596569657965896599660966196629663966496659666966796689669967096719672967396749675967696779678967996809681968296839684968596869687968896899690969196929693969496959696969796989699970097019702970397049705970697079708970997109711971297139714971597169717971897199720972197229723972497259726972797289729973097319732973397349735973697379738973997409741974297439744974597469747974897499750975197529753975497559756975797589759976097619762976397649765976697679768976997709771977297739774977597769777977897799780978197829783978497859786978797889789979097919792979397949795979697979798979998009801980298039804980598069807980898099810981198129813981498159816981798189819982098219822982398249825982698279828982998309831983298339834983598369837983898399840984198429843984498459846984798489849985098519852985398549855985698579858985998609861986298639864986598669867986898699870987198729873987498759876987798789879988098819882988398849885988698879888988998909891989298939894989598969897989898999900990199029903990499059906990799089909991099119912991399149915991699179918991999209921992299239924992599269927992899299930993199329933993499359936993799389939994099419942994399449945994699479948994999509951995299539954995599569957995899599960996199629963996499659966996799689969997099719972997399749975997699779978997999809981998299839984998599869987998899899990999199929993999499959996999799989999100001000110002100031000410005100061000710008100091001010011100121001310014100151001610017100181001910020100211002210023100241002510026100271002810029100301003110032100331003410035100361003710038100391004010041100421004310044100451004610047100481004910050100511005210053100541005510056100571005810059100601006110062100631006410065100661006710068100691007010071100721007310074100751007610077100781007910080100811008210083100841008510086100871008810089100901009110092100931009410095100961009710098100991010010101101021010310104101051010610107101081010910110101111011210113101141011510116101171011810119101201012110122101231012410125101261012710128101291013010131101321013310134101351013610137101381013910140101411014210143101441014510146101471014810149101501015110152101531015410155101561015710158101591016010161101621016310164101651016610167101681016910170101711017210173101741017510176101771017810179101801018110182101831018410185101861018710188101891019010191101921019310194101951019610197101981019910200102011020210203102041020510206102071020810209102101021110212102131021410215102161021710218102191022010221102221022310224102251022610227102281022910230102311023210233102341023510236102371023810239102401024110242102431024410245102461024710248102491025010251102521025310254102551025610257102581025910260102611026210263102641026510266102671026810269102701027110272102731027410275102761027710278102791028010281102821028310284102851028610287102881028910290102911029210293102941029510296102971029810299103001030110302103031030410305103061030710308103091031010311103121031310314103151031610317103181031910320103211032210323103241032510326103271032810329103301033110332103331033410335103361033710338103391034010341103421034310344103451034610347103481034910350103511035210353103541035510356103571035810359103601036110362103631036410365103661036710368103691037010371103721037310374103751037610377103781037910380103811038210383103841038510386103871038810389103901039110392103931039410395103961039710398103991040010401104021040310404104051040610407104081040910410104111041210413104141041510416104171041810419104201042110422104231042410425104261042710428104291043010431104321043310434104351043610437104381043910440104411044210443104441044510446104471044810449104501045110452104531045410455104561045710458104591046010461104621046310464104651046610467104681046910470104711047210473104741047510476104771047810479104801048110482104831048410485104861048710488104891049010491104921049310494104951049610497104981049910500105011050210503105041050510506105071050810509105101051110512105131051410515105161051710518105191052010521105221052310524105251052610527105281052910530105311053210533105341053510536105371053810539105401054110542105431054410545105461054710548105491055010551105521055310554105551055610557105581055910560105611056210563105641056510566105671056810569105701057110572105731057410575105761057710578105791058010581105821058310584105851058610587105881058910590105911059210593105941059510596105971059810599106001060110602106031060410605106061060710608106091061010611106121061310614106151061610617106181061910620106211062210623106241062510626106271062810629106301063110632106331063410635106361063710638106391064010641106421064310644106451064610647106481064910650106511065210653106541065510656106571065810659106601066110662106631066410665106661066710668106691067010671106721067310674106751067610677106781067910680106811068210683106841068510686106871068810689106901069110692106931069410695106961069710698106991070010701107021070310704107051070610707107081070910710107111071210713107141071510716107171071810719107201072110722107231072410725107261072710728107291073010731107321073310734107351073610737107381073910740107411074210743107441074510746107471074810749107501075110752107531075410755107561075710758107591076010761107621076310764107651076610767107681076910770107711077210773107741077510776107771077810779107801078110782107831078410785107861078710788107891079010791107921079310794107951079610797107981079910800108011080210803108041080510806108071080810809108101081110812108131081410815108161081710818108191082010821108221082310824108251082610827108281082910830108311083210833108341083510836108371083810839108401084110842108431084410845108461084710848108491085010851108521085310854108551085610857108581085910860108611086210863108641086510866108671086810869108701087110872108731087410875108761087710878108791088010881108821088310884108851088610887108881088910890108911089210893108941089510896108971089810899109001090110902109031090410905109061090710908109091091010911109121091310914109151091610917109181091910920109211092210923109241092510926109271092810929109301093110932109331093410935109361093710938109391094010941109421094310944109451094610947109481094910950109511095210953109541095510956109571095810959109601096110962109631096410965109661096710968109691097010971109721097310974109751097610977109781097910980109811098210983109841098510986109871098810989109901099110992109931099410995109961099710998109991100011001110021100311004110051100611007110081100911010110111101211013110141101511016110171101811019110201102111022110231102411025110261102711028110291103011031110321103311034110351103611037110381103911040110411104211043110441104511046110471104811049110501105111052110531105411055110561105711058110591106011061110621106311064110651106611067110681106911070110711107211073110741107511076110771107811079110801108111082110831108411085110861108711088110891109011091110921109311094110951109611097110981109911100111011110211103111041110511106111071110811109111101111111112111131111411115111161111711118111191112011121111221112311124111251112611127111281112911130111311113211133111341113511136111371113811139111401114111142111431114411145111461114711148111491115011151111521115311154111551115611157111581115911160111611116211163111641116511166111671116811169111701117111172111731117411175111761117711178111791118011181111821118311184111851118611187111881118911190111911119211193111941119511196111971119811199112001120111202112031120411205112061120711208112091121011211112121121311214112151121611217112181121911220112211122211223112241122511226112271122811229112301123111232112331123411235112361123711238112391124011241112421124311244112451124611247112481124911250112511125211253112541125511256112571125811259112601126111262112631126411265112661126711268112691127011271112721127311274112751127611277112781127911280112811128211283112841128511286112871128811289112901129111292112931129411295112961129711298112991130011301113021130311304113051130611307113081130911310113111131211313113141131511316113171131811319113201132111322113231132411325113261132711328113291133011331113321133311334113351133611337113381133911340113411134211343113441134511346113471134811349113501135111352113531135411355113561135711358113591136011361113621136311364113651136611367113681136911370113711137211373113741137511376113771137811379113801138111382113831138411385113861138711388113891139011391113921139311394113951139611397113981139911400114011140211403114041140511406114071140811409114101141111412114131141411415114161141711418114191142011421114221142311424114251142611427114281142911430114311143211433114341143511436114371143811439114401144111442114431144411445114461144711448114491145011451114521145311454114551145611457114581145911460114611146211463114641146511466114671146811469114701147111472114731147411475114761147711478114791148011481114821148311484114851148611487114881148911490114911149211493114941149511496114971149811499115001150111502115031150411505115061150711508115091151011511115121151311514115151151611517115181151911520115211152211523115241152511526115271152811529115301153111532115331153411535115361153711538115391154011541115421154311544115451154611547115481154911550115511155211553115541155511556115571155811559115601156111562115631156411565115661156711568115691157011571115721157311574115751157611577115781157911580115811158211583115841158511586115871158811589115901159111592115931159411595115961159711598115991160011601116021160311604116051160611607116081160911610116111161211613116141161511616116171161811619116201162111622116231162411625116261162711628116291163011631116321163311634116351163611637116381163911640116411164211643116441164511646116471164811649116501165111652116531165411655116561165711658116591166011661116621166311664116651166611667116681166911670116711167211673116741167511676116771167811679116801168111682116831168411685116861168711688116891169011691116921169311694116951169611697116981169911700117011170211703117041170511706117071170811709117101171111712117131171411715117161171711718117191172011721117221172311724117251172611727117281172911730117311173211733117341173511736117371173811739117401174111742117431174411745117461174711748117491175011751117521175311754117551175611757117581175911760117611176211763117641176511766117671176811769117701177111772117731177411775117761177711778117791178011781117821178311784117851178611787117881178911790117911179211793117941179511796117971179811799118001180111802118031180411805118061180711808118091181011811118121181311814118151181611817118181181911820118211182211823118241182511826118271182811829118301183111832118331183411835118361183711838118391184011841118421184311844118451184611847118481184911850118511185211853118541185511856118571185811859118601186111862118631186411865118661186711868118691187011871118721187311874118751187611877118781187911880118811188211883118841188511886118871188811889118901189111892118931189411895118961189711898118991190011901119021190311904119051190611907119081190911910119111191211913119141191511916119171191811919119201192111922119231192411925119261192711928119291193011931119321193311934119351193611937119381193911940119411194211943119441194511946119471194811949119501195111952119531195411955119561195711958119591196011961119621196311964119651196611967119681196911970119711197211973119741197511976119771197811979119801198111982119831198411985119861198711988119891199011991119921199311994119951199611997119981199912000120011200212003120041200512006120071200812009120101201112012120131201412015120161201712018120191202012021120221202312024120251202612027120281202912030120311203212033120341203512036120371203812039120401204112042120431204412045120461204712048120491205012051120521205312054120551205612057120581205912060120611206212063120641206512066120671206812069120701207112072120731207412075120761207712078120791208012081120821208312084120851208612087120881208912090120911209212093120941209512096120971209812099121001210112102121031210412105121061210712108121091211012111121121211312114121151211612117121181211912120121211212212123121241212512126121271212812129121301213112132121331213412135121361213712138121391214012141121421214312144121451214612147121481214912150121511215212153121541215512156121571215812159121601216112162121631216412165121661216712168121691217012171121721217312174121751217612177121781217912180121811218212183121841218512186121871218812189121901219112192121931219412195121961219712198121991220012201122021220312204122051220612207122081220912210122111221212213122141221512216122171221812219122201222112222122231222412225122261222712228122291223012231122321223312234122351223612237122381223912240122411224212243122441224512246122471224812249122501225112252122531225412255122561225712258122591226012261122621226312264122651226612267122681226912270122711227212273122741227512276122771227812279122801228112282122831228412285122861228712288122891229012291122921229312294122951229612297122981229912300123011230212303123041230512306123071230812309123101231112312123131231412315123161231712318123191232012321123221232312324123251232612327123281232912330123311233212333123341233512336123371233812339123401234112342123431234412345123461234712348123491235012351123521235312354123551235612357123581235912360123611236212363123641236512366123671236812369123701237112372123731237412375123761237712378123791238012381123821238312384123851238612387123881238912390123911239212393123941239512396123971239812399124001240112402124031240412405124061240712408124091241012411124121241312414124151241612417124181241912420124211242212423124241242512426124271242812429124301243112432124331243412435124361243712438124391244012441124421244312444124451244612447124481244912450124511245212453124541245512456124571245812459124601246112462124631246412465124661246712468124691247012471124721247312474124751247612477124781247912480124811248212483124841248512486124871248812489124901249112492124931249412495124961249712498124991250012501125021250312504125051250612507125081250912510125111251212513125141251512516125171251812519125201252112522125231252412525125261252712528125291253012531125321253312534125351253612537125381253912540125411254212543125441254512546125471254812549125501255112552125531255412555125561255712558125591256012561125621256312564125651256612567125681256912570125711257212573125741257512576125771257812579125801258112582125831258412585125861258712588125891259012591125921259312594125951259612597125981259912600126011260212603126041260512606126071260812609126101261112612126131261412615126161261712618126191262012621126221262312624126251262612627126281262912630126311263212633126341263512636126371263812639126401264112642126431264412645126461264712648126491265012651126521265312654126551265612657126581265912660126611266212663126641266512666126671266812669126701267112672126731267412675126761267712678126791268012681126821268312684126851268612687126881268912690126911269212693126941269512696126971269812699127001270112702127031270412705127061270712708127091271012711127121271312714127151271612717127181271912720127211272212723127241272512726127271272812729127301273112732127331273412735127361273712738127391274012741127421274312744127451274612747127481274912750127511275212753127541275512756127571275812759127601276112762127631276412765127661276712768127691277012771127721277312774127751277612777127781277912780127811278212783127841278512786127871278812789127901279112792127931279412795127961279712798127991280012801128021280312804128051280612807128081280912810128111281212813128141281512816128171281812819128201282112822128231282412825128261282712828128291283012831128321283312834128351283612837128381283912840128411284212843128441284512846128471284812849128501285112852128531285412855128561285712858128591286012861128621286312864128651286612867128681286912870128711287212873128741287512876128771287812879128801288112882128831288412885128861288712888128891289012891128921289312894128951289612897128981289912900129011290212903129041290512906129071290812909129101291112912129131291412915129161291712918129191292012921129221292312924129251292612927129281292912930129311293212933129341293512936129371293812939129401294112942129431294412945129461294712948129491295012951129521295312954129551295612957129581295912960129611296212963129641296512966129671296812969129701297112972129731297412975129761297712978129791298012981129821298312984129851298612987129881298912990129911299212993129941299512996129971299812999130001300113002130031300413005130061300713008130091301013011130121301313014130151301613017130181301913020130211302213023130241302513026130271302813029130301303113032130331303413035130361303713038130391304013041130421304313044130451304613047130481304913050130511305213053130541305513056130571305813059130601306113062130631306413065130661306713068130691307013071130721307313074130751307613077130781307913080130811308213083130841308513086130871308813089130901309113092130931309413095130961309713098130991310013101131021310313104131051310613107131081310913110131111311213113131141311513116131171311813119131201312113122131231312413125131261312713128131291313013131131321313313134131351313613137131381313913140131411314213143131441314513146131471314813149131501315113152131531315413155131561315713158131591316013161131621316313164131651316613167131681316913170131711317213173131741317513176131771317813179131801318113182131831318413185131861318713188131891319013191131921319313194131951319613197131981319913200132011320213203132041320513206132071320813209132101321113212132131321413215132161321713218132191322013221132221322313224132251322613227132281322913230132311323213233132341323513236132371323813239132401324113242132431324413245132461324713248132491325013251132521325313254132551325613257132581325913260132611326213263132641326513266132671326813269132701327113272132731327413275132761327713278132791328013281132821328313284132851328613287132881328913290132911329213293132941329513296132971329813299133001330113302133031330413305133061330713308133091331013311133121331313314133151331613317133181331913320133211332213323133241332513326133271332813329133301333113332133331333413335133361333713338133391334013341133421334313344133451334613347133481334913350133511335213353133541335513356133571335813359133601336113362133631336413365133661336713368133691337013371133721337313374133751337613377133781337913380133811338213383133841338513386133871338813389133901339113392133931339413395133961339713398133991340013401134021340313404134051340613407134081340913410134111341213413134141341513416134171341813419134201342113422134231342413425134261342713428134291343013431134321343313434134351343613437134381343913440134411344213443134441344513446134471344813449134501345113452134531345413455134561345713458134591346013461134621346313464134651346613467134681346913470134711347213473134741347513476134771347813479134801348113482134831348413485134861348713488134891349013491134921349313494134951349613497134981349913500135011350213503135041350513506135071350813509135101351113512135131351413515135161351713518135191352013521135221352313524135251352613527135281352913530135311353213533135341353513536135371353813539135401354113542135431354413545135461354713548135491355013551135521355313554135551355613557135581355913560135611356213563135641356513566135671356813569135701357113572135731357413575135761357713578135791358013581135821358313584135851358613587135881358913590135911359213593135941359513596135971359813599136001360113602136031360413605136061360713608136091361013611136121361313614136151361613617136181361913620136211362213623136241362513626136271362813629136301363113632136331363413635136361363713638136391364013641136421364313644136451364613647136481364913650136511365213653136541365513656136571365813659136601366113662136631366413665136661366713668136691367013671136721367313674136751367613677136781367913680136811368213683136841368513686136871368813689136901369113692136931369413695136961369713698136991370013701137021370313704137051370613707137081370913710137111371213713137141371513716137171371813719137201372113722137231372413725137261372713728137291373013731137321373313734137351373613737137381373913740137411374213743137441374513746137471374813749137501375113752137531375413755137561375713758137591376013761137621376313764137651376613767137681376913770137711377213773137741377513776137771377813779137801378113782137831378413785137861378713788137891379013791137921379313794137951379613797137981379913800138011380213803138041380513806138071380813809138101381113812138131381413815138161381713818138191382013821138221382313824138251382613827138281382913830138311383213833138341383513836138371383813839138401384113842138431384413845138461384713848138491385013851138521385313854138551385613857138581385913860138611386213863138641386513866138671386813869138701387113872138731387413875138761387713878138791388013881138821388313884138851388613887138881388913890138911389213893138941389513896138971389813899139001390113902139031390413905139061390713908139091391013911139121391313914139151391613917139181391913920139211392213923139241392513926139271392813929139301393113932139331393413935139361393713938139391394013941139421394313944139451394613947139481394913950139511395213953139541395513956139571395813959139601396113962139631396413965139661396713968139691397013971139721397313974139751397613977139781397913980139811398213983139841398513986139871398813989139901399113992139931399413995139961399713998139991400014001140021400314004140051400614007140081400914010140111401214013140141401514016140171401814019140201402114022140231402414025140261402714028140291403014031140321403314034140351403614037140381403914040140411404214043140441404514046140471404814049140501405114052140531405414055140561405714058140591406014061140621406314064140651406614067140681406914070140711407214073140741407514076140771407814079140801408114082140831408414085140861408714088140891409014091140921409314094140951409614097140981409914100141011410214103141041410514106141071410814109141101411114112141131411414115141161411714118141191412014121141221412314124141251412614127141281412914130141311413214133141341413514136141371413814139141401414114142141431414414145141461414714148141491415014151141521415314154141551415614157141581415914160141611416214163141641416514166141671416814169141701417114172141731417414175141761417714178141791418014181141821418314184141851418614187141881418914190141911419214193141941419514196141971419814199142001420114202142031420414205142061420714208142091421014211142121421314214142151421614217142181421914220142211422214223142241422514226142271422814229142301423114232142331423414235142361423714238142391424014241142421424314244142451424614247142481424914250142511425214253142541425514256142571425814259142601426114262142631426414265142661426714268142691427014271142721427314274142751427614277142781427914280142811428214283142841428514286142871428814289142901429114292142931429414295142961429714298142991430014301143021430314304143051430614307143081430914310143111431214313143141431514316143171431814319143201432114322143231432414325143261432714328143291433014331143321433314334143351433614337143381433914340143411434214343143441434514346143471434814349143501435114352143531435414355143561435714358143591436014361143621436314364143651436614367143681436914370143711437214373143741437514376143771437814379143801438114382143831438414385143861438714388143891439014391143921439314394143951439614397143981439914400144011440214403144041440514406144071440814409144101441114412144131441414415144161441714418144191442014421144221442314424144251442614427144281442914430144311443214433144341443514436144371443814439144401444114442144431444414445144461444714448144491445014451144521445314454144551445614457144581445914460144611446214463144641446514466144671446814469144701447114472144731447414475144761447714478144791448014481144821448314484144851448614487144881448914490144911449214493144941449514496144971449814499145001450114502145031450414505145061450714508145091451014511145121451314514145151451614517145181451914520145211452214523145241452514526145271452814529145301453114532145331453414535145361453714538145391454014541145421454314544145451454614547145481454914550145511455214553145541455514556145571455814559145601456114562145631456414565145661456714568145691457014571145721457314574145751457614577145781457914580145811458214583145841458514586145871458814589145901459114592145931459414595145961459714598145991460014601146021460314604146051460614607146081460914610146111461214613146141461514616146171461814619146201462114622146231462414625146261462714628146291463014631146321463314634146351463614637146381463914640146411464214643146441464514646146471464814649146501465114652146531465414655146561465714658146591466014661146621466314664146651466614667146681466914670146711467214673146741467514676146771467814679146801468114682146831468414685146861468714688146891469014691146921469314694146951469614697146981469914700147011470214703147041470514706147071470814709147101471114712147131471414715147161471714718147191472014721147221472314724147251472614727147281472914730147311473214733147341473514736147371473814739147401474114742147431474414745147461474714748147491475014751147521475314754147551475614757147581475914760147611476214763147641476514766147671476814769147701477114772147731477414775147761477714778147791478014781147821478314784147851478614787147881478914790147911479214793147941479514796147971479814799148001480114802148031480414805148061480714808148091481014811148121481314814148151481614817148181481914820148211482214823148241482514826148271482814829148301483114832148331483414835148361483714838148391484014841148421484314844148451484614847148481484914850148511485214853148541485514856148571485814859148601486114862148631486414865148661486714868148691487014871148721487314874148751487614877148781487914880148811488214883148841488514886148871488814889148901489114892148931489414895148961489714898148991490014901149021490314904149051490614907149081490914910149111491214913149141491514916149171491814919149201492114922149231492414925149261492714928149291493014931149321493314934149351493614937149381493914940149411494214943149441494514946149471494814949149501495114952149531495414955149561495714958149591496014961149621496314964149651496614967149681496914970149711497214973149741497514976149771497814979149801498114982149831498414985149861498714988149891499014991149921499314994149951499614997149981499915000150011500215003150041500515006150071500815009150101501115012150131501415015150161501715018150191502015021150221502315024150251502615027150281502915030150311503215033150341503515036150371503815039150401504115042150431504415045150461504715048150491505015051150521505315054150551505615057150581505915060150611506215063150641506515066150671506815069150701507115072150731507415075150761507715078150791508015081150821508315084150851508615087150881508915090150911509215093150941509515096150971509815099151001510115102151031510415105151061510715108151091511015111151121511315114151151511615117151181511915120151211512215123151241512515126151271512815129151301513115132151331513415135151361513715138151391514015141151421514315144151451514615147151481514915150151511515215153151541515515156151571515815159151601516115162151631516415165151661516715168151691517015171151721517315174151751517615177151781517915180151811518215183151841518515186151871518815189151901519115192151931519415195151961519715198151991520015201152021520315204152051520615207152081520915210152111521215213152141521515216152171521815219152201522115222152231522415225152261522715228152291523015231152321523315234152351523615237152381523915240152411524215243152441524515246152471524815249152501525115252152531525415255152561525715258152591526015261152621526315264152651526615267152681526915270152711527215273152741527515276152771527815279152801528115282152831528415285152861528715288152891529015291152921529315294152951529615297152981529915300153011530215303153041530515306153071530815309153101531115312153131531415315153161531715318153191532015321153221532315324153251532615327153281532915330153311533215333153341533515336153371533815339153401534115342153431534415345153461534715348153491535015351153521535315354153551535615357153581535915360153611536215363153641536515366153671536815369153701537115372153731537415375153761537715378153791538015381153821538315384153851538615387153881538915390153911539215393153941539515396153971539815399154001540115402154031540415405154061540715408154091541015411154121541315414154151541615417154181541915420154211542215423154241542515426154271542815429154301543115432154331543415435154361543715438154391544015441154421544315444154451544615447154481544915450154511545215453154541545515456154571545815459154601546115462154631546415465154661546715468154691547015471154721547315474154751547615477154781547915480154811548215483154841548515486154871548815489154901549115492154931549415495154961549715498154991550015501155021550315504155051550615507155081550915510155111551215513155141551515516155171551815519155201552115522155231552415525155261552715528155291553015531155321553315534155351553615537155381553915540155411554215543155441554515546155471554815549155501555115552155531555415555155561555715558155591556015561155621556315564155651556615567155681556915570155711557215573155741557515576155771557815579155801558115582155831558415585155861558715588155891559015591155921559315594155951559615597155981559915600156011560215603156041560515606156071560815609156101561115612156131561415615156161561715618156191562015621156221562315624156251562615627156281562915630156311563215633156341563515636156371563815639156401564115642156431564415645156461564715648156491565015651156521565315654156551565615657156581565915660156611566215663156641566515666156671566815669156701567115672156731567415675156761567715678156791568015681156821568315684156851568615687156881568915690156911569215693156941569515696156971569815699157001570115702157031570415705157061570715708157091571015711157121571315714157151571615717157181571915720157211572215723157241572515726157271572815729157301573115732157331573415735157361573715738157391574015741157421574315744157451574615747157481574915750157511575215753157541575515756157571575815759157601576115762157631576415765157661576715768157691577015771157721577315774157751577615777157781577915780157811578215783157841578515786157871578815789157901579115792157931579415795157961579715798157991580015801158021580315804158051580615807158081580915810158111581215813158141581515816158171581815819158201582115822158231582415825158261582715828158291583015831158321583315834158351583615837158381583915840158411584215843158441584515846158471584815849158501585115852158531585415855158561585715858158591586015861158621586315864158651586615867158681586915870158711587215873158741587515876158771587815879158801588115882158831588415885158861588715888158891589015891158921589315894158951589615897158981589915900159011590215903159041590515906159071590815909159101591115912159131591415915159161591715918159191592015921159221592315924159251592615927159281592915930159311593215933159341593515936159371593815939159401594115942159431594415945159461594715948159491595015951159521595315954159551595615957159581595915960159611596215963159641596515966159671596815969159701597115972159731597415975159761597715978159791598015981159821598315984159851598615987159881598915990159911599215993159941599515996159971599815999160001600116002160031600416005160061600716008160091601016011160121601316014160151601616017160181601916020160211602216023160241602516026160271602816029160301603116032160331603416035160361603716038160391604016041160421604316044160451604616047160481604916050160511605216053160541605516056160571605816059160601606116062160631606416065160661606716068160691607016071160721607316074160751607616077160781607916080160811608216083160841608516086160871608816089160901609116092160931609416095160961609716098160991610016101161021610316104161051610616107161081610916110161111611216113161141611516116161171611816119161201612116122161231612416125161261612716128161291613016131161321613316134161351613616137161381613916140161411614216143161441614516146161471614816149161501615116152161531615416155161561615716158161591616016161161621616316164161651616616167161681616916170161711617216173161741617516176161771617816179161801618116182161831618416185161861618716188161891619016191161921619316194161951619616197161981619916200162011620216203162041620516206162071620816209162101621116212162131621416215162161621716218162191622016221162221622316224162251622616227162281622916230162311623216233162341623516236162371623816239162401624116242162431624416245162461624716248162491625016251162521625316254162551625616257162581625916260162611626216263162641626516266162671626816269162701627116272162731627416275162761627716278162791628016281162821628316284162851628616287162881628916290162911629216293162941629516296162971629816299163001630116302163031630416305163061630716308163091631016311163121631316314163151631616317163181631916320163211632216323163241632516326163271632816329163301633116332163331633416335163361633716338163391634016341163421634316344163451634616347163481634916350163511635216353163541635516356163571635816359163601636116362163631636416365163661636716368163691637016371163721637316374163751637616377163781637916380163811638216383163841638516386163871638816389163901639116392163931639416395163961639716398163991640016401164021640316404164051640616407164081640916410164111641216413164141641516416164171641816419164201642116422164231642416425164261642716428164291643016431164321643316434164351643616437164381643916440164411644216443164441644516446164471644816449164501645116452164531645416455164561645716458164591646016461164621646316464164651646616467164681646916470164711647216473164741647516476164771647816479164801648116482164831648416485164861648716488164891649016491164921649316494164951649616497164981649916500165011650216503165041650516506165071650816509165101651116512165131651416515165161651716518165191652016521165221652316524165251652616527165281652916530165311653216533165341653516536165371653816539165401654116542165431654416545165461654716548165491655016551165521655316554165551655616557165581655916560165611656216563165641656516566165671656816569165701657116572165731657416575165761657716578165791658016581165821658316584165851658616587165881658916590165911659216593165941659516596165971659816599166001660116602166031660416605166061660716608166091661016611166121661316614166151661616617166181661916620166211662216623166241662516626166271662816629166301663116632166331663416635166361663716638166391664016641166421664316644166451664616647166481664916650166511665216653166541665516656166571665816659166601666116662166631666416665166661666716668166691667016671166721667316674166751667616677166781667916680166811668216683166841668516686166871668816689166901669116692166931669416695166961669716698166991670016701167021670316704167051670616707167081670916710167111671216713167141671516716167171671816719167201672116722167231672416725167261672716728167291673016731167321673316734167351673616737167381673916740167411674216743167441674516746167471674816749167501675116752167531675416755167561675716758167591676016761167621676316764167651676616767167681676916770167711677216773167741677516776167771677816779167801678116782167831678416785167861678716788167891679016791167921679316794167951679616797167981679916800168011680216803168041680516806168071680816809168101681116812168131681416815168161681716818168191682016821168221682316824168251682616827168281682916830168311683216833168341683516836168371683816839168401684116842168431684416845168461684716848168491685016851168521685316854168551685616857168581685916860168611686216863168641686516866168671686816869168701687116872168731687416875168761687716878168791688016881168821688316884168851688616887168881688916890168911689216893168941689516896168971689816899169001690116902169031690416905169061690716908169091691016911169121691316914169151691616917169181691916920169211692216923169241692516926169271692816929169301693116932169331693416935169361693716938169391694016941169421694316944169451694616947169481694916950169511695216953169541695516956169571695816959169601696116962169631696416965169661696716968169691697016971169721697316974169751697616977169781697916980169811698216983169841698516986169871698816989169901699116992169931699416995169961699716998169991700017001170021700317004170051700617007170081700917010170111701217013170141701517016170171701817019170201702117022170231702417025170261702717028170291703017031170321703317034170351703617037170381703917040170411704217043170441704517046170471704817049170501705117052170531705417055170561705717058170591706017061170621706317064170651706617067170681706917070170711707217073170741707517076170771707817079170801708117082170831708417085170861708717088170891709017091170921709317094170951709617097170981709917100171011710217103171041710517106171071710817109171101711117112171131711417115171161711717118171191712017121171221712317124171251712617127171281712917130171311713217133171341713517136171371713817139171401714117142171431714417145171461714717148171491715017151171521715317154171551715617157171581715917160171611716217163171641716517166171671716817169171701717117172171731717417175171761717717178171791718017181171821718317184171851718617187171881718917190171911719217193171941719517196171971719817199172001720117202172031720417205172061720717208172091721017211172121721317214172151721617217172181721917220172211722217223172241722517226172271722817229172301723117232172331723417235172361723717238172391724017241172421724317244172451724617247172481724917250172511725217253172541725517256172571725817259172601726117262172631726417265172661726717268172691727017271172721727317274172751727617277172781727917280172811728217283172841728517286172871728817289172901729117292172931729417295172961729717298172991730017301173021730317304173051730617307173081730917310173111731217313173141731517316173171731817319173201732117322173231732417325173261732717328173291733017331173321733317334173351733617337173381733917340173411734217343173441734517346173471734817349173501735117352173531735417355173561735717358173591736017361173621736317364173651736617367173681736917370173711737217373173741737517376173771737817379173801738117382173831738417385173861738717388173891739017391173921739317394173951739617397173981739917400174011740217403174041740517406174071740817409174101741117412174131741417415174161741717418174191742017421174221742317424174251742617427174281742917430174311743217433174341743517436174371743817439174401744117442174431744417445174461744717448174491745017451174521745317454174551745617457174581745917460174611746217463174641746517466174671746817469174701747117472174731747417475174761747717478174791748017481174821748317484174851748617487174881748917490174911749217493174941749517496174971749817499175001750117502175031750417505175061750717508175091751017511175121751317514175151751617517175181751917520175211752217523175241752517526175271752817529175301753117532175331753417535175361753717538175391754017541175421754317544175451754617547175481754917550175511755217553175541755517556175571755817559175601756117562175631756417565175661756717568175691757017571175721757317574175751757617577175781757917580175811758217583175841758517586175871758817589175901759117592175931759417595175961759717598175991760017601176021760317604176051760617607176081760917610176111761217613176141761517616176171761817619176201762117622176231762417625176261762717628176291763017631176321763317634176351763617637176381763917640176411764217643176441764517646176471764817649176501765117652176531765417655176561765717658176591766017661176621766317664176651766617667176681766917670176711767217673176741767517676176771767817679176801768117682176831768417685176861768717688176891769017691176921769317694176951769617697176981769917700177011770217703177041770517706177071770817709177101771117712177131771417715177161771717718177191772017721177221772317724177251772617727177281772917730177311773217733177341773517736177371773817739177401774117742177431774417745177461774717748177491775017751177521775317754177551775617757177581775917760177611776217763177641776517766177671776817769177701777117772177731777417775177761777717778177791778017781177821778317784177851778617787177881778917790177911779217793177941779517796177971779817799178001780117802178031780417805178061780717808178091781017811178121781317814178151781617817178181781917820178211782217823178241782517826178271782817829178301783117832178331783417835178361783717838178391784017841178421784317844178451784617847178481784917850178511785217853178541785517856178571785817859178601786117862178631786417865178661786717868178691787017871178721787317874178751787617877178781787917880178811788217883178841788517886178871788817889178901789117892178931789417895178961789717898178991790017901179021790317904179051790617907179081790917910179111791217913179141791517916179171791817919179201792117922179231792417925179261792717928179291793017931179321793317934179351793617937179381793917940179411794217943179441794517946179471794817949179501795117952179531795417955179561795717958179591796017961179621796317964179651796617967179681796917970179711797217973179741797517976179771797817979179801798117982179831798417985179861798717988179891799017991179921799317994179951799617997179981799918000180011800218003180041800518006180071800818009180101801118012180131801418015180161801718018180191802018021180221802318024180251802618027180281802918030180311803218033180341803518036180371803818039180401804118042180431804418045180461804718048180491805018051180521805318054180551805618057180581805918060180611806218063180641806518066180671806818069180701807118072180731807418075180761807718078180791808018081180821808318084180851808618087180881808918090180911809218093180941809518096180971809818099181001810118102181031810418105181061810718108181091811018111181121811318114181151811618117181181811918120181211812218123181241812518126181271812818129181301813118132181331813418135181361813718138181391814018141181421814318144181451814618147181481814918150181511815218153181541815518156181571815818159181601816118162181631816418165181661816718168181691817018171181721817318174181751817618177181781817918180181811818218183181841818518186181871818818189181901819118192181931819418195181961819718198181991820018201182021820318204182051820618207182081820918210182111821218213182141821518216182171821818219182201822118222182231822418225182261822718228182291823018231182321823318234182351823618237182381823918240182411824218243182441824518246182471824818249182501825118252182531825418255182561825718258182591826018261182621826318264182651826618267182681826918270182711827218273182741827518276182771827818279182801828118282182831828418285182861828718288182891829018291182921829318294182951829618297182981829918300183011830218303183041830518306183071830818309183101831118312183131831418315183161831718318183191832018321183221832318324183251832618327183281832918330183311833218333183341833518336183371833818339183401834118342183431834418345183461834718348183491835018351183521835318354183551835618357183581835918360183611836218363183641836518366183671836818369183701837118372183731837418375183761837718378183791838018381183821838318384183851838618387183881838918390183911839218393183941839518396183971839818399184001840118402184031840418405184061840718408184091841018411184121841318414184151841618417184181841918420184211842218423184241842518426184271842818429184301843118432184331843418435184361843718438184391844018441184421844318444184451844618447184481844918450184511845218453184541845518456184571845818459184601846118462184631846418465184661846718468184691847018471184721847318474184751847618477184781847918480184811848218483184841848518486184871848818489184901849118492184931849418495184961849718498184991850018501185021850318504185051850618507185081850918510185111851218513185141851518516185171851818519185201852118522185231852418525185261852718528185291853018531185321853318534185351853618537185381853918540185411854218543185441854518546185471854818549185501855118552185531855418555185561855718558185591856018561185621856318564185651856618567185681856918570185711857218573185741857518576185771857818579185801858118582185831858418585185861858718588185891859018591185921859318594185951859618597185981859918600186011860218603186041860518606186071860818609186101861118612186131861418615186161861718618186191862018621186221862318624186251862618627186281862918630186311863218633186341863518636186371863818639186401864118642186431864418645186461864718648186491865018651186521865318654186551865618657186581865918660186611866218663186641866518666186671866818669186701867118672186731867418675186761867718678186791868018681186821868318684186851868618687186881868918690186911869218693186941869518696186971869818699187001870118702187031870418705187061870718708187091871018711187121871318714187151871618717187181871918720187211872218723187241872518726187271872818729187301873118732187331873418735187361873718738187391874018741187421874318744187451874618747187481874918750187511875218753187541875518756187571875818759187601876118762187631876418765187661876718768187691877018771187721877318774187751877618777187781877918780187811878218783187841878518786187871878818789187901879118792187931879418795187961879718798187991880018801188021880318804188051880618807188081880918810188111881218813188141881518816188171881818819188201882118822188231882418825188261882718828188291883018831188321883318834188351883618837188381883918840188411884218843188441884518846188471884818849188501885118852188531885418855188561885718858188591886018861188621886318864188651886618867188681886918870188711887218873188741887518876188771887818879188801888118882188831888418885188861888718888188891889018891188921889318894188951889618897188981889918900189011890218903189041890518906189071890818909189101891118912189131891418915189161891718918189191892018921189221892318924189251892618927189281892918930189311893218933189341893518936189371893818939189401894118942189431894418945189461894718948189491895018951189521895318954189551895618957189581895918960189611896218963189641896518966189671896818969189701897118972189731897418975189761897718978189791898018981189821898318984189851898618987189881898918990189911899218993189941899518996189971899818999190001900119002190031900419005190061900719008190091901019011190121901319014190151901619017190181901919020190211902219023190241902519026190271902819029190301903119032190331903419035190361903719038190391904019041190421904319044190451904619047190481904919050190511905219053190541905519056190571905819059190601906119062190631906419065190661906719068190691907019071190721907319074190751907619077190781907919080190811908219083190841908519086190871908819089190901909119092190931909419095190961909719098190991910019101191021910319104191051910619107191081910919110191111911219113191141911519116191171911819119191201912119122191231912419125191261912719128191291913019131191321913319134191351913619137191381913919140191411914219143191441914519146191471914819149191501915119152191531915419155191561915719158191591916019161191621916319164191651916619167191681916919170191711917219173191741917519176191771917819179191801918119182191831918419185191861918719188191891919019191191921919319194191951919619197191981919919200192011920219203192041920519206192071920819209192101921119212192131921419215192161921719218192191922019221192221922319224192251922619227192281922919230192311923219233192341923519236192371923819239192401924119242192431924419245192461924719248192491925019251192521925319254192551925619257192581925919260192611926219263192641926519266192671926819269192701927119272192731927419275192761927719278192791928019281192821928319284192851928619287192881928919290192911929219293192941929519296192971929819299193001930119302193031930419305193061930719308193091931019311193121931319314193151931619317193181931919320193211932219323193241932519326193271932819329193301933119332193331933419335193361933719338193391934019341193421934319344193451934619347193481934919350193511935219353193541935519356193571935819359193601936119362193631936419365193661936719368193691937019371193721937319374193751937619377193781937919380193811938219383193841938519386193871938819389193901939119392193931939419395193961939719398193991940019401194021940319404194051940619407194081940919410194111941219413194141941519416194171941819419194201942119422194231942419425194261942719428194291943019431194321943319434194351943619437194381943919440194411944219443194441944519446194471944819449194501945119452194531945419455194561945719458194591946019461194621946319464194651946619467194681946919470194711947219473194741947519476194771947819479194801948119482194831948419485194861948719488194891949019491194921949319494194951949619497194981949919500195011950219503195041950519506195071950819509195101951119512195131951419515195161951719518195191952019521195221952319524195251952619527195281952919530195311953219533195341953519536195371953819539195401954119542195431954419545195461954719548195491955019551195521955319554195551955619557195581955919560195611956219563195641956519566195671956819569195701957119572195731957419575195761957719578195791958019581195821958319584195851958619587195881958919590195911959219593195941959519596195971959819599196001960119602196031960419605196061960719608196091961019611196121961319614196151961619617196181961919620196211962219623196241962519626196271962819629196301963119632196331963419635196361963719638196391964019641196421964319644196451964619647196481964919650196511965219653196541965519656196571965819659196601966119662196631966419665196661966719668196691967019671196721967319674196751967619677196781967919680196811968219683196841968519686196871968819689196901969119692196931969419695196961969719698196991970019701197021970319704197051970619707197081970919710197111971219713197141971519716197171971819719197201972119722197231972419725197261972719728197291973019731197321973319734197351973619737197381973919740197411974219743197441974519746197471974819749197501975119752197531975419755197561975719758197591976019761197621976319764197651976619767197681976919770197711977219773197741977519776197771977819779197801978119782197831978419785197861978719788197891979019791197921979319794197951979619797197981979919800198011980219803198041980519806198071980819809198101981119812198131981419815198161981719818198191982019821198221982319824198251982619827198281982919830198311983219833198341983519836198371983819839198401984119842198431984419845198461984719848198491985019851198521985319854198551985619857198581985919860198611986219863198641986519866198671986819869198701987119872198731987419875198761987719878198791988019881198821988319884198851988619887198881988919890198911989219893198941989519896198971989819899199001990119902199031990419905199061990719908199091991019911199121991319914199151991619917199181991919920199211992219923199241992519926199271992819929199301993119932199331993419935199361993719938199391994019941199421994319944199451994619947199481994919950199511995219953199541995519956199571995819959199601996119962199631996419965199661996719968199691997019971199721997319974199751997619977199781997919980199811998219983199841998519986199871998819989199901999119992199931999419995199961999719998199992000020001200022000320004200052000620007200082000920010200112001220013200142001520016200172001820019200202002120022200232002420025200262002720028200292003020031200322003320034200352003620037200382003920040200412004220043200442004520046200472004820049200502005120052200532005420055200562005720058200592006020061200622006320064200652006620067200682006920070200712007220073200742007520076200772007820079200802008120082200832008420085200862008720088200892009020091200922009320094200952009620097200982009920100201012010220103201042010520106201072010820109201102011120112201132011420115201162011720118201192012020121201222012320124201252012620127201282012920130201312013220133201342013520136201372013820139201402014120142201432014420145201462014720148201492015020151201522015320154201552015620157201582015920160201612016220163201642016520166201672016820169201702017120172201732017420175201762017720178201792018020181201822018320184201852018620187201882018920190201912019220193201942019520196201972019820199202002020120202202032020420205202062020720208202092021020211202122021320214202152021620217202182021920220202212022220223202242022520226202272022820229202302023120232202332023420235202362023720238202392024020241202422024320244202452024620247202482024920250202512025220253202542025520256202572025820259202602026120262202632026420265202662026720268202692027020271202722027320274202752027620277202782027920280202812028220283202842028520286202872028820289202902029120292202932029420295202962029720298202992030020301203022030320304203052030620307203082030920310203112031220313203142031520316203172031820319203202032120322203232032420325203262032720328203292033020331203322033320334203352033620337203382033920340203412034220343203442034520346203472034820349203502035120352203532035420355203562035720358203592036020361203622036320364203652036620367203682036920370203712037220373203742037520376203772037820379203802038120382203832038420385203862038720388203892039020391203922039320394203952039620397203982039920400204012040220403204042040520406204072040820409204102041120412204132041420415204162041720418204192042020421204222042320424204252042620427204282042920430204312043220433204342043520436204372043820439204402044120442204432044420445204462044720448204492045020451204522045320454204552045620457204582045920460204612046220463204642046520466204672046820469204702047120472204732047420475204762047720478204792048020481204822048320484204852048620487204882048920490204912049220493204942049520496204972049820499205002050120502205032050420505205062050720508205092051020511205122051320514205152051620517205182051920520205212052220523205242052520526205272052820529205302053120532205332053420535205362053720538205392054020541205422054320544205452054620547205482054920550205512055220553205542055520556205572055820559205602056120562205632056420565205662056720568205692057020571205722057320574205752057620577205782057920580205812058220583205842058520586205872058820589205902059120592205932059420595205962059720598205992060020601206022060320604206052060620607206082060920610206112061220613206142061520616206172061820619206202062120622206232062420625206262062720628206292063020631206322063320634206352063620637206382063920640206412064220643206442064520646206472064820649206502065120652206532065420655206562065720658206592066020661206622066320664206652066620667206682066920670206712067220673206742067520676206772067820679206802068120682206832068420685206862068720688206892069020691206922069320694206952069620697206982069920700207012070220703207042070520706207072070820709207102071120712207132071420715207162071720718207192072020721207222072320724207252072620727207282072920730207312073220733207342073520736207372073820739207402074120742207432074420745207462074720748207492075020751207522075320754207552075620757207582075920760207612076220763207642076520766207672076820769207702077120772207732077420775207762077720778207792078020781207822078320784207852078620787207882078920790207912079220793207942079520796207972079820799208002080120802208032080420805208062080720808208092081020811208122081320814208152081620817208182081920820208212082220823208242082520826208272082820829208302083120832208332083420835208362083720838208392084020841208422084320844208452084620847208482084920850208512085220853208542085520856208572085820859208602086120862208632086420865208662086720868208692087020871208722087320874208752087620877208782087920880208812088220883208842088520886208872088820889208902089120892208932089420895208962089720898208992090020901209022090320904209052090620907209082090920910209112091220913209142091520916209172091820919209202092120922209232092420925209262092720928209292093020931209322093320934209352093620937209382093920940209412094220943209442094520946209472094820949209502095120952209532095420955209562095720958209592096020961209622096320964209652096620967209682096920970209712097220973209742097520976209772097820979209802098120982209832098420985209862098720988209892099020991209922099320994209952099620997209982099921000210012100221003210042100521006210072100821009210102101121012210132101421015210162101721018210192102021021210222102321024210252102621027210282102921030210312103221033210342103521036210372103821039210402104121042210432104421045210462104721048210492105021051210522105321054210552105621057210582105921060210612106221063210642106521066210672106821069210702107121072210732107421075210762107721078210792108021081210822108321084210852108621087210882108921090210912109221093210942109521096210972109821099211002110121102211032110421105211062110721108211092111021111211122111321114211152111621117211182111921120211212112221123211242112521126211272112821129211302113121132211332113421135211362113721138211392114021141211422114321144211452114621147211482114921150211512115221153211542115521156211572115821159211602116121162211632116421165211662116721168211692117021171211722117321174211752117621177211782117921180211812118221183211842118521186211872118821189211902119121192211932119421195211962119721198211992120021201212022120321204212052120621207212082120921210212112121221213212142121521216212172121821219212202122121222212232122421225212262122721228212292123021231212322123321234212352123621237212382123921240212412124221243212442124521246212472124821249212502125121252212532125421255212562125721258212592126021261212622126321264212652126621267212682126921270212712127221273212742127521276212772127821279212802128121282212832128421285212862128721288212892129021291212922129321294212952129621297212982129921300213012130221303213042130521306213072130821309213102131121312213132131421315213162131721318213192132021321213222132321324213252132621327213282132921330213312133221333213342133521336213372133821339213402134121342213432134421345213462134721348213492135021351213522135321354213552135621357213582135921360213612136221363213642136521366213672136821369213702137121372213732137421375213762137721378213792138021381213822138321384213852138621387213882138921390213912139221393213942139521396213972139821399214002140121402214032140421405214062140721408214092141021411214122141321414214152141621417214182141921420214212142221423214242142521426214272142821429214302143121432214332143421435214362143721438214392144021441214422144321444214452144621447214482144921450214512145221453214542145521456214572145821459214602146121462214632146421465214662146721468214692147021471214722147321474214752147621477214782147921480214812148221483214842148521486214872148821489214902149121492214932149421495214962149721498214992150021501215022150321504215052150621507215082150921510215112151221513215142151521516215172151821519215202152121522215232152421525215262152721528215292153021531215322153321534215352153621537215382153921540215412154221543215442154521546215472154821549215502155121552215532155421555215562155721558215592156021561215622156321564215652156621567215682156921570215712157221573215742157521576215772157821579215802158121582215832158421585215862158721588215892159021591215922159321594215952159621597215982159921600216012160221603216042160521606216072160821609216102161121612216132161421615216162161721618216192162021621216222162321624216252162621627216282162921630216312163221633216342163521636216372163821639216402164121642216432164421645216462164721648216492165021651216522165321654216552165621657216582165921660216612166221663216642166521666216672166821669216702167121672216732167421675216762167721678216792168021681216822168321684216852168621687216882168921690216912169221693216942169521696216972169821699217002170121702217032170421705217062170721708217092171021711217122171321714217152171621717217182171921720217212172221723217242172521726217272172821729217302173121732217332173421735217362173721738217392174021741217422174321744217452174621747217482174921750217512175221753217542175521756217572175821759217602176121762217632176421765217662176721768217692177021771217722177321774217752177621777217782177921780217812178221783217842178521786217872178821789217902179121792217932179421795217962179721798217992180021801218022180321804218052180621807218082180921810218112181221813218142181521816218172181821819218202182121822218232182421825218262182721828218292183021831218322183321834218352183621837218382183921840218412184221843218442184521846218472184821849218502185121852218532185421855218562185721858218592186021861218622186321864218652186621867218682186921870218712187221873218742187521876218772187821879218802188121882218832188421885218862188721888218892189021891218922189321894218952189621897218982189921900219012190221903219042190521906219072190821909219102191121912219132191421915219162191721918219192192021921219222192321924219252192621927219282192921930219312193221933219342193521936219372193821939219402194121942219432194421945219462194721948219492195021951219522195321954219552195621957219582195921960219612196221963219642196521966219672196821969219702197121972219732197421975219762197721978219792198021981219822198321984219852198621987219882198921990219912199221993219942199521996219972199821999220002200122002220032200422005220062200722008220092201022011220122201322014220152201622017220182201922020220212202222023220242202522026220272202822029220302203122032220332203422035220362203722038220392204022041220422204322044220452204622047220482204922050220512205222053220542205522056220572205822059220602206122062220632206422065220662206722068220692207022071220722207322074220752207622077220782207922080220812208222083220842208522086220872208822089220902209122092220932209422095220962209722098220992210022101221022210322104221052210622107221082210922110221112211222113221142211522116221172211822119221202212122122221232212422125221262212722128221292213022131221322213322134221352213622137221382213922140221412214222143221442214522146221472214822149221502215122152221532215422155221562215722158221592216022161221622216322164221652216622167221682216922170221712217222173221742217522176221772217822179221802218122182221832218422185221862218722188221892219022191221922219322194221952219622197221982219922200222012220222203222042220522206222072220822209222102221122212222132221422215222162221722218222192222022221222222222322224222252222622227222282222922230222312223222233222342223522236222372223822239222402224122242222432224422245222462224722248222492225022251222522225322254222552225622257222582225922260222612226222263222642226522266222672226822269222702227122272222732227422275222762227722278222792228022281222822228322284222852228622287222882228922290222912229222293222942229522296222972229822299223002230122302223032230422305223062230722308223092231022311223122231322314223152231622317223182231922320223212232222323223242232522326223272232822329223302233122332223332233422335223362233722338223392234022341223422234322344223452234622347223482234922350223512235222353223542235522356223572235822359223602236122362223632236422365223662236722368223692237022371223722237322374223752237622377223782237922380223812238222383223842238522386223872238822389223902239122392223932239422395223962239722398223992240022401224022240322404224052240622407224082240922410224112241222413224142241522416224172241822419224202242122422224232242422425224262242722428224292243022431224322243322434224352243622437224382243922440224412244222443224442244522446224472244822449224502245122452224532245422455224562245722458224592246022461224622246322464224652246622467224682246922470224712247222473224742247522476224772247822479224802248122482224832248422485224862248722488224892249022491224922249322494224952249622497224982249922500225012250222503225042250522506225072250822509225102251122512225132251422515225162251722518225192252022521225222252322524225252252622527225282252922530225312253222533225342253522536225372253822539225402254122542225432254422545225462254722548225492255022551225522255322554225552255622557225582255922560225612256222563225642256522566225672256822569225702257122572225732257422575225762257722578225792258022581225822258322584225852258622587225882258922590225912259222593225942259522596225972259822599226002260122602226032260422605226062260722608226092261022611226122261322614226152261622617226182261922620226212262222623226242262522626226272262822629226302263122632226332263422635226362263722638226392264022641226422264322644226452264622647226482264922650226512265222653226542265522656226572265822659226602266122662226632266422665226662266722668226692267022671226722267322674226752267622677226782267922680226812268222683226842268522686226872268822689226902269122692226932269422695226962269722698226992270022701227022270322704227052270622707227082270922710227112271222713227142271522716227172271822719227202272122722227232272422725227262272722728227292273022731227322273322734227352273622737227382273922740227412274222743227442274522746227472274822749227502275122752227532275422755227562275722758227592276022761227622276322764227652276622767227682276922770227712277222773227742277522776227772277822779227802278122782227832278422785227862278722788227892279022791227922279322794227952279622797227982279922800228012280222803228042280522806228072280822809228102281122812228132281422815228162281722818228192282022821228222282322824228252282622827228282282922830228312283222833228342283522836228372283822839228402284122842228432284422845228462284722848228492285022851228522285322854228552285622857228582285922860228612286222863228642286522866228672286822869228702287122872228732287422875228762287722878228792288022881228822288322884228852288622887228882288922890228912289222893228942289522896228972289822899229002290122902229032290422905229062290722908229092291022911229122291322914229152291622917229182291922920229212292222923229242292522926229272292822929229302293122932229332293422935229362293722938229392294022941229422294322944229452294622947229482294922950229512295222953229542295522956229572295822959229602296122962229632296422965229662296722968229692297022971229722297322974229752297622977229782297922980229812298222983229842298522986229872298822989229902299122992229932299422995229962299722998229992300023001230022300323004230052300623007230082300923010230112301223013230142301523016230172301823019230202302123022230232302423025230262302723028230292303023031230322303323034230352303623037230382303923040230412304223043230442304523046230472304823049230502305123052230532305423055230562305723058230592306023061230622306323064230652306623067230682306923070230712307223073230742307523076230772307823079230802308123082230832308423085230862308723088230892309023091230922309323094230952309623097230982309923100231012310223103231042310523106231072310823109231102311123112231132311423115231162311723118231192312023121231222312323124231252312623127231282312923130231312313223133231342313523136231372313823139231402314123142231432314423145231462314723148231492315023151231522315323154231552315623157231582315923160231612316223163231642316523166231672316823169231702317123172231732317423175231762317723178231792318023181231822318323184231852318623187231882318923190231912319223193231942319523196231972319823199232002320123202232032320423205232062320723208232092321023211232122321323214232152321623217232182321923220232212322223223232242322523226232272322823229232302323123232232332323423235232362323723238232392324023241232422324323244232452324623247232482324923250232512325223253232542325523256232572325823259232602326123262232632326423265232662326723268232692327023271232722327323274232752327623277232782327923280232812328223283232842328523286232872328823289232902329123292232932329423295232962329723298232992330023301233022330323304233052330623307233082330923310233112331223313233142331523316233172331823319233202332123322233232332423325233262332723328233292333023331233322333323334233352333623337233382333923340233412334223343233442334523346233472334823349233502335123352233532335423355233562335723358233592336023361233622336323364233652336623367233682336923370233712337223373233742337523376233772337823379233802338123382233832338423385233862338723388233892339023391233922339323394233952339623397233982339923400234012340223403234042340523406234072340823409234102341123412234132341423415234162341723418234192342023421234222342323424234252342623427234282342923430234312343223433234342343523436234372343823439234402344123442234432344423445234462344723448234492345023451234522345323454234552345623457234582345923460234612346223463234642346523466234672346823469234702347123472234732347423475234762347723478234792348023481234822348323484234852348623487234882348923490234912349223493234942349523496234972349823499235002350123502235032350423505235062350723508235092351023511235122351323514235152351623517235182351923520235212352223523235242352523526235272352823529235302353123532235332353423535235362353723538235392354023541235422354323544235452354623547235482354923550235512355223553235542355523556235572355823559235602356123562235632356423565235662356723568235692357023571235722357323574235752357623577235782357923580235812358223583235842358523586235872358823589235902359123592235932359423595235962359723598235992360023601236022360323604236052360623607236082360923610236112361223613236142361523616236172361823619236202362123622236232362423625236262362723628236292363023631236322363323634236352363623637236382363923640236412364223643236442364523646236472364823649236502365123652236532365423655236562365723658236592366023661236622366323664236652366623667236682366923670236712367223673236742367523676236772367823679236802368123682236832368423685236862368723688236892369023691236922369323694236952369623697236982369923700237012370223703237042370523706237072370823709237102371123712237132371423715237162371723718237192372023721237222372323724237252372623727237282372923730237312373223733237342373523736237372373823739237402374123742237432374423745237462374723748237492375023751237522375323754237552375623757237582375923760237612376223763237642376523766237672376823769237702377123772237732377423775237762377723778237792378023781237822378323784237852378623787237882378923790237912379223793237942379523796237972379823799238002380123802238032380423805238062380723808238092381023811238122381323814238152381623817238182381923820238212382223823238242382523826238272382823829238302383123832238332383423835238362383723838238392384023841238422384323844238452384623847238482384923850238512385223853238542385523856238572385823859238602386123862238632386423865238662386723868238692387023871238722387323874238752387623877238782387923880238812388223883238842388523886238872388823889238902389123892238932389423895238962389723898238992390023901239022390323904239052390623907239082390923910239112391223913239142391523916239172391823919239202392123922239232392423925239262392723928239292393023931239322393323934239352393623937239382393923940239412394223943239442394523946239472394823949239502395123952239532395423955239562395723958239592396023961239622396323964239652396623967239682396923970239712397223973239742397523976239772397823979239802398123982239832398423985239862398723988239892399023991239922399323994239952399623997239982399924000240012400224003240042400524006240072400824009240102401124012240132401424015240162401724018240192402024021240222402324024240252402624027240282402924030240312403224033240342403524036240372403824039240402404124042240432404424045240462404724048240492405024051240522405324054240552405624057240582405924060240612406224063240642406524066240672406824069240702407124072240732407424075240762407724078240792408024081240822408324084240852408624087240882408924090240912409224093240942409524096240972409824099241002410124102241032410424105241062410724108241092411024111241122411324114241152411624117241182411924120241212412224123241242412524126241272412824129241302413124132241332413424135241362413724138241392414024141241422414324144241452414624147241482414924150241512415224153241542415524156241572415824159241602416124162241632416424165241662416724168241692417024171241722417324174241752417624177241782417924180241812418224183241842418524186241872418824189241902419124192241932419424195241962419724198241992420024201242022420324204242052420624207242082420924210242112421224213242142421524216242172421824219242202422124222242232422424225242262422724228242292423024231242322423324234242352423624237242382423924240242412424224243242442424524246242472424824249242502425124252242532425424255242562425724258242592426024261242622426324264242652426624267242682426924270242712427224273242742427524276242772427824279242802428124282242832428424285242862428724288242892429024291242922429324294242952429624297242982429924300243012430224303243042430524306243072430824309243102431124312243132431424315243162431724318243192432024321243222432324324243252432624327243282432924330243312433224333243342433524336243372433824339243402434124342243432434424345243462434724348243492435024351243522435324354243552435624357243582435924360243612436224363243642436524366243672436824369243702437124372243732437424375243762437724378243792438024381243822438324384243852438624387243882438924390243912439224393243942439524396243972439824399244002440124402244032440424405244062440724408244092441024411244122441324414244152441624417244182441924420244212442224423244242442524426244272442824429244302443124432244332443424435244362443724438244392444024441244422444324444244452444624447244482444924450244512445224453244542445524456244572445824459244602446124462244632446424465244662446724468244692447024471244722447324474244752447624477244782447924480244812448224483244842448524486244872448824489244902449124492244932449424495244962449724498244992450024501245022450324504245052450624507245082450924510245112451224513245142451524516245172451824519245202452124522245232452424525245262452724528245292453024531245322453324534245352453624537245382453924540245412454224543245442454524546245472454824549245502455124552245532455424555245562455724558245592456024561245622456324564245652456624567245682456924570245712457224573245742457524576245772457824579245802458124582245832458424585245862458724588245892459024591245922459324594245952459624597245982459924600246012460224603246042460524606246072460824609246102461124612246132461424615246162461724618246192462024621246222462324624246252462624627246282462924630246312463224633246342463524636246372463824639246402464124642246432464424645246462464724648246492465024651246522465324654246552465624657246582465924660246612466224663246642466524666246672466824669246702467124672246732467424675246762467724678246792468024681246822468324684246852468624687246882468924690246912469224693246942469524696246972469824699247002470124702247032470424705247062470724708247092471024711247122471324714247152471624717247182471924720247212472224723247242472524726247272472824729247302473124732247332473424735247362473724738247392474024741247422474324744247452474624747247482474924750247512475224753247542475524756247572475824759247602476124762247632476424765247662476724768247692477024771247722477324774247752477624777247782477924780247812478224783247842478524786247872478824789247902479124792247932479424795247962479724798247992480024801248022480324804248052480624807248082480924810248112481224813248142481524816248172481824819248202482124822248232482424825248262482724828248292483024831248322483324834248352483624837248382483924840248412484224843248442484524846248472484824849248502485124852248532485424855248562485724858248592486024861248622486324864248652486624867248682486924870248712487224873248742487524876248772487824879248802488124882248832488424885248862488724888248892489024891248922489324894248952489624897248982489924900249012490224903249042490524906249072490824909249102491124912249132491424915249162491724918249192492024921249222492324924249252492624927249282492924930249312493224933249342493524936249372493824939249402494124942249432494424945249462494724948249492495024951249522495324954249552495624957249582495924960249612496224963249642496524966249672496824969249702497124972249732497424975249762497724978249792498024981249822498324984249852498624987249882498924990249912499224993249942499524996249972499824999250002500125002250032500425005250062500725008250092501025011250122501325014250152501625017250182501925020250212502225023250242502525026250272502825029250302503125032250332503425035250362503725038250392504025041250422504325044250452504625047250482504925050250512505225053250542505525056250572505825059250602506125062250632506425065250662506725068250692507025071250722507325074250752507625077250782507925080250812508225083250842508525086250872508825089250902509125092250932509425095250962509725098250992510025101251022510325104251052510625107251082510925110251112511225113251142511525116251172511825119251202512125122251232512425125251262512725128251292513025131251322513325134251352513625137251382513925140251412514225143251442514525146251472514825149251502515125152251532515425155251562515725158251592516025161251622516325164251652516625167251682516925170251712517225173251742517525176251772517825179251802518125182251832518425185251862518725188251892519025191251922519325194251952519625197251982519925200252012520225203252042520525206252072520825209252102521125212252132521425215252162521725218252192522025221252222522325224252252522625227252282522925230252312523225233252342523525236252372523825239252402524125242252432524425245252462524725248252492525025251252522525325254252552525625257252582525925260252612526225263252642526525266252672526825269252702527125272252732527425275252762527725278252792528025281252822528325284252852528625287252882528925290252912529225293252942529525296252972529825299253002530125302253032530425305253062530725308253092531025311253122531325314253152531625317253182531925320253212532225323253242532525326253272532825329253302533125332253332533425335253362533725338253392534025341253422534325344253452534625347253482534925350253512535225353253542535525356253572535825359253602536125362253632536425365253662536725368253692537025371253722537325374253752537625377253782537925380253812538225383253842538525386253872538825389253902539125392253932539425395253962539725398253992540025401254022540325404254052540625407254082540925410254112541225413254142541525416254172541825419254202542125422254232542425425254262542725428254292543025431254322543325434254352543625437254382543925440254412544225443254442544525446254472544825449254502545125452254532545425455254562545725458254592546025461254622546325464254652546625467254682546925470254712547225473254742547525476254772547825479254802548125482254832548425485254862548725488254892549025491254922549325494254952549625497254982549925500255012550225503255042550525506255072550825509255102551125512255132551425515255162551725518255192552025521255222552325524255252552625527255282552925530255312553225533255342553525536255372553825539255402554125542255432554425545255462554725548255492555025551255522555325554255552555625557255582555925560255612556225563255642556525566255672556825569255702557125572255732557425575255762557725578255792558025581255822558325584255852558625587255882558925590255912559225593255942559525596255972559825599256002560125602256032560425605256062560725608256092561025611256122561325614256152561625617256182561925620256212562225623256242562525626256272562825629256302563125632256332563425635256362563725638256392564025641256422564325644256452564625647256482564925650256512565225653256542565525656256572565825659256602566125662256632566425665256662566725668256692567025671256722567325674256752567625677256782567925680256812568225683256842568525686256872568825689256902569125692256932569425695256962569725698256992570025701257022570325704257052570625707257082570925710257112571225713257142571525716257172571825719257202572125722257232572425725257262572725728257292573025731257322573325734257352573625737257382573925740257412574225743257442574525746257472574825749257502575125752257532575425755257562575725758257592576025761257622576325764257652576625767257682576925770257712577225773257742577525776257772577825779257802578125782257832578425785257862578725788257892579025791257922579325794257952579625797257982579925800258012580225803258042580525806258072580825809258102581125812258132581425815258162581725818258192582025821258222582325824258252582625827258282582925830258312583225833258342583525836258372583825839258402584125842258432584425845258462584725848258492585025851258522585325854258552585625857258582585925860258612586225863258642586525866258672586825869258702587125872258732587425875258762587725878258792588025881258822588325884258852588625887258882588925890258912589225893258942589525896258972589825899259002590125902259032590425905259062590725908259092591025911259122591325914259152591625917259182591925920259212592225923259242592525926259272592825929259302593125932259332593425935259362593725938259392594025941259422594325944259452594625947259482594925950259512595225953259542595525956259572595825959259602596125962259632596425965259662596725968259692597025971259722597325974259752597625977259782597925980259812598225983259842598525986259872598825989259902599125992259932599425995259962599725998259992600026001260022600326004260052600626007260082600926010260112601226013260142601526016260172601826019260202602126022260232602426025260262602726028260292603026031260322603326034260352603626037260382603926040260412604226043260442604526046260472604826049260502605126052260532605426055260562605726058260592606026061260622606326064260652606626067260682606926070260712607226073260742607526076260772607826079260802608126082260832608426085260862608726088260892609026091260922609326094260952609626097260982609926100261012610226103261042610526106261072610826109261102611126112261132611426115261162611726118261192612026121261222612326124261252612626127261282612926130261312613226133261342613526136261372613826139261402614126142261432614426145261462614726148261492615026151261522615326154261552615626157261582615926160261612616226163261642616526166261672616826169261702617126172261732617426175261762617726178261792618026181261822618326184261852618626187261882618926190261912619226193261942619526196261972619826199262002620126202262032620426205262062620726208262092621026211262122621326214262152621626217262182621926220262212622226223262242622526226262272622826229262302623126232262332623426235262362623726238262392624026241262422624326244262452624626247262482624926250262512625226253262542625526256262572625826259262602626126262262632626426265262662626726268262692627026271262722627326274262752627626277262782627926280262812628226283262842628526286262872628826289262902629126292262932629426295262962629726298262992630026301263022630326304263052630626307263082630926310263112631226313263142631526316263172631826319263202632126322263232632426325263262632726328263292633026331263322633326334263352633626337263382633926340263412634226343263442634526346263472634826349263502635126352263532635426355263562635726358263592636026361263622636326364263652636626367263682636926370263712637226373263742637526376263772637826379263802638126382263832638426385263862638726388263892639026391263922639326394263952639626397263982639926400264012640226403264042640526406264072640826409264102641126412264132641426415264162641726418264192642026421264222642326424264252642626427264282642926430264312643226433264342643526436264372643826439264402644126442264432644426445264462644726448264492645026451264522645326454264552645626457264582645926460264612646226463264642646526466264672646826469264702647126472264732647426475264762647726478264792648026481264822648326484264852648626487264882648926490264912649226493264942649526496264972649826499265002650126502265032650426505265062650726508265092651026511265122651326514265152651626517265182651926520265212652226523265242652526526265272652826529265302653126532265332653426535265362653726538265392654026541265422654326544265452654626547265482654926550265512655226553265542655526556265572655826559265602656126562265632656426565265662656726568265692657026571265722657326574265752657626577265782657926580265812658226583265842658526586265872658826589265902659126592265932659426595265962659726598265992660026601266022660326604266052660626607266082660926610266112661226613266142661526616266172661826619266202662126622266232662426625266262662726628266292663026631266322663326634266352663626637266382663926640266412664226643266442664526646266472664826649266502665126652266532665426655266562665726658266592666026661266622666326664266652666626667266682666926670266712667226673266742667526676266772667826679266802668126682266832668426685266862668726688266892669026691266922669326694266952669626697266982669926700267012670226703267042670526706267072670826709267102671126712267132671426715267162671726718267192672026721267222672326724267252672626727267282672926730267312673226733267342673526736267372673826739267402674126742267432674426745267462674726748267492675026751267522675326754267552675626757267582675926760267612676226763267642676526766267672676826769267702677126772267732677426775267762677726778267792678026781267822678326784267852678626787267882678926790267912679226793267942679526796267972679826799268002680126802268032680426805268062680726808268092681026811268122681326814268152681626817268182681926820268212682226823268242682526826268272682826829268302683126832268332683426835268362683726838268392684026841268422684326844268452684626847268482684926850268512685226853268542685526856268572685826859268602686126862268632686426865268662686726868268692687026871268722687326874268752687626877268782687926880268812688226883268842688526886268872688826889268902689126892268932689426895268962689726898268992690026901269022690326904269052690626907269082690926910269112691226913269142691526916269172691826919269202692126922269232692426925269262692726928269292693026931269322693326934269352693626937269382693926940269412694226943269442694526946269472694826949269502695126952269532695426955269562695726958269592696026961269622696326964269652696626967269682696926970269712697226973269742697526976269772697826979269802698126982269832698426985269862698726988269892699026991269922699326994269952699626997269982699927000270012700227003270042700527006270072700827009270102701127012270132701427015270162701727018270192702027021270222702327024270252702627027270282702927030270312703227033270342703527036270372703827039270402704127042270432704427045270462704727048270492705027051270522705327054270552705627057270582705927060270612706227063270642706527066270672706827069270702707127072270732707427075270762707727078270792708027081270822708327084270852708627087270882708927090270912709227093270942709527096270972709827099271002710127102271032710427105271062710727108271092711027111271122711327114271152711627117271182711927120271212712227123271242712527126271272712827129271302713127132271332713427135271362713727138271392714027141271422714327144271452714627147271482714927150271512715227153271542715527156271572715827159271602716127162271632716427165271662716727168271692717027171271722717327174271752717627177271782717927180271812718227183271842718527186271872718827189271902719127192271932719427195271962719727198271992720027201272022720327204272052720627207272082720927210272112721227213272142721527216272172721827219272202722127222272232722427225272262722727228272292723027231272322723327234272352723627237272382723927240272412724227243272442724527246272472724827249272502725127252272532725427255272562725727258272592726027261272622726327264272652726627267272682726927270272712727227273272742727527276272772727827279272802728127282272832728427285272862728727288272892729027291272922729327294272952729627297272982729927300273012730227303273042730527306273072730827309273102731127312273132731427315273162731727318273192732027321273222732327324273252732627327273282732927330273312733227333273342733527336273372733827339273402734127342273432734427345273462734727348273492735027351273522735327354273552735627357273582735927360273612736227363273642736527366273672736827369273702737127372273732737427375273762737727378273792738027381273822738327384273852738627387273882738927390273912739227393273942739527396273972739827399274002740127402274032740427405274062740727408274092741027411274122741327414274152741627417274182741927420274212742227423274242742527426274272742827429274302743127432274332743427435274362743727438274392744027441274422744327444274452744627447274482744927450274512745227453274542745527456274572745827459274602746127462274632746427465274662746727468274692747027471274722747327474274752747627477274782747927480274812748227483274842748527486274872748827489274902749127492274932749427495274962749727498274992750027501275022750327504275052750627507275082750927510275112751227513275142751527516275172751827519275202752127522275232752427525275262752727528275292753027531275322753327534275352753627537275382753927540275412754227543275442754527546275472754827549275502755127552275532755427555275562755727558275592756027561275622756327564275652756627567275682756927570275712757227573275742757527576275772757827579275802758127582275832758427585275862758727588275892759027591275922759327594275952759627597275982759927600276012760227603276042760527606276072760827609276102761127612276132761427615276162761727618276192762027621276222762327624276252762627627276282762927630276312763227633276342763527636276372763827639276402764127642276432764427645276462764727648276492765027651276522765327654276552765627657276582765927660276612766227663276642766527666276672766827669276702767127672276732767427675276762767727678276792768027681276822768327684276852768627687276882768927690276912769227693276942769527696276972769827699277002770127702277032770427705277062770727708277092771027711277122771327714277152771627717277182771927720277212772227723277242772527726277272772827729277302773127732277332773427735277362773727738277392774027741277422774327744277452774627747277482774927750277512775227753277542775527756277572775827759277602776127762277632776427765277662776727768277692777027771277722777327774277752777627777277782777927780277812778227783277842778527786277872778827789277902779127792277932779427795277962779727798277992780027801278022780327804278052780627807278082780927810278112781227813278142781527816278172781827819278202782127822278232782427825278262782727828278292783027831278322783327834278352783627837278382783927840278412784227843278442784527846278472784827849278502785127852278532785427855278562785727858278592786027861278622786327864278652786627867278682786927870278712787227873278742787527876278772787827879278802788127882278832788427885278862788727888278892789027891278922789327894278952789627897278982789927900279012790227903279042790527906279072790827909279102791127912279132791427915279162791727918279192792027921279222792327924279252792627927279282792927930279312793227933279342793527936279372793827939279402794127942279432794427945279462794727948279492795027951279522795327954279552795627957279582795927960279612796227963279642796527966279672796827969279702797127972279732797427975279762797727978279792798027981279822798327984279852798627987279882798927990279912799227993279942799527996279972799827999280002800128002280032800428005280062800728008280092801028011280122801328014280152801628017280182801928020280212802228023280242802528026280272802828029280302803128032280332803428035280362803728038280392804028041280422804328044280452804628047280482804928050280512805228053280542805528056280572805828059280602806128062280632806428065280662806728068280692807028071280722807328074280752807628077280782807928080280812808228083280842808528086280872808828089280902809128092280932809428095280962809728098280992810028101281022810328104281052810628107281082810928110281112811228113281142811528116281172811828119281202812128122281232812428125281262812728128281292813028131281322813328134281352813628137281382813928140281412814228143281442814528146281472814828149281502815128152281532815428155281562815728158281592816028161281622816328164281652816628167281682816928170281712817228173281742817528176281772817828179281802818128182281832818428185281862818728188281892819028191281922819328194281952819628197281982819928200282012820228203282042820528206282072820828209282102821128212282132821428215282162821728218282192822028221282222822328224282252822628227282282822928230282312823228233282342823528236282372823828239282402824128242282432824428245282462824728248282492825028251282522825328254282552825628257282582825928260282612826228263282642826528266282672826828269282702827128272282732827428275282762827728278282792828028281282822828328284282852828628287282882828928290282912829228293282942829528296282972829828299283002830128302283032830428305283062830728308283092831028311283122831328314283152831628317283182831928320283212832228323283242832528326283272832828329283302833128332283332833428335283362833728338283392834028341283422834328344283452834628347283482834928350283512835228353283542835528356283572835828359283602836128362283632836428365283662836728368283692837028371283722837328374283752837628377283782837928380283812838228383283842838528386283872838828389283902839128392283932839428395283962839728398283992840028401284022840328404284052840628407284082840928410284112841228413284142841528416284172841828419284202842128422284232842428425284262842728428284292843028431284322843328434284352843628437284382843928440284412844228443284442844528446284472844828449284502845128452284532845428455284562845728458284592846028461284622846328464284652846628467284682846928470284712847228473284742847528476284772847828479284802848128482284832848428485284862848728488284892849028491284922849328494284952849628497284982849928500285012850228503285042850528506285072850828509285102851128512285132851428515285162851728518285192852028521285222852328524285252852628527285282852928530285312853228533285342853528536285372853828539285402854128542285432854428545285462854728548285492855028551285522855328554285552855628557285582855928560285612856228563285642856528566285672856828569285702857128572285732857428575285762857728578285792858028581285822858328584285852858628587285882858928590285912859228593285942859528596285972859828599286002860128602286032860428605286062860728608286092861028611286122861328614286152861628617286182861928620286212862228623286242862528626286272862828629286302863128632286332863428635286362863728638286392864028641286422864328644286452864628647286482864928650286512865228653286542865528656286572865828659286602866128662286632866428665286662866728668286692867028671286722867328674286752867628677286782867928680286812868228683286842868528686286872868828689286902869128692286932869428695286962869728698286992870028701287022870328704287052870628707287082870928710287112871228713287142871528716287172871828719287202872128722287232872428725287262872728728287292873028731287322873328734287352873628737287382873928740287412874228743287442874528746287472874828749287502875128752287532875428755287562875728758287592876028761287622876328764287652876628767287682876928770287712877228773287742877528776287772877828779287802878128782287832878428785287862878728788287892879028791287922879328794287952879628797287982879928800288012880228803288042880528806288072880828809288102881128812288132881428815288162881728818288192882028821288222882328824288252882628827288282882928830288312883228833288342883528836288372883828839288402884128842288432884428845288462884728848288492885028851288522885328854288552885628857288582885928860288612886228863288642886528866288672886828869288702887128872288732887428875288762887728878288792888028881288822888328884288852888628887288882888928890288912889228893288942889528896288972889828899289002890128902289032890428905289062890728908289092891028911289122891328914289152891628917289182891928920289212892228923289242892528926289272892828929289302893128932289332893428935289362893728938289392894028941289422894328944289452894628947289482894928950289512895228953289542895528956289572895828959289602896128962289632896428965289662896728968289692897028971289722897328974289752897628977289782897928980289812898228983289842898528986289872898828989289902899128992289932899428995289962899728998289992900029001290022900329004290052900629007290082900929010290112901229013290142901529016290172901829019290202902129022290232902429025290262902729028290292903029031290322903329034290352903629037290382903929040290412904229043290442904529046290472904829049290502905129052290532905429055290562905729058290592906029061290622906329064290652906629067290682906929070290712907229073290742907529076290772907829079290802908129082290832908429085290862908729088290892909029091290922909329094290952909629097290982909929100291012910229103291042910529106291072910829109291102911129112291132911429115291162911729118291192912029121291222912329124291252912629127291282912929130291312913229133291342913529136291372913829139291402914129142291432914429145291462914729148291492915029151291522915329154291552915629157291582915929160291612916229163291642916529166291672916829169291702917129172291732917429175291762917729178291792918029181291822918329184291852918629187291882918929190291912919229193291942919529196291972919829199292002920129202292032920429205292062920729208292092921029211292122921329214292152921629217292182921929220292212922229223292242922529226292272922829229292302923129232292332923429235292362923729238292392924029241292422924329244292452924629247292482924929250292512925229253292542925529256292572925829259292602926129262292632926429265292662926729268292692927029271292722927329274292752927629277292782927929280292812928229283292842928529286292872928829289292902929129292292932929429295292962929729298292992930029301293022930329304293052930629307293082930929310293112931229313293142931529316293172931829319293202932129322293232932429325293262932729328293292933029331293322933329334293352933629337293382933929340293412934229343293442934529346293472934829349293502935129352293532935429355293562935729358293592936029361293622936329364293652936629367293682936929370293712937229373293742937529376293772937829379293802938129382293832938429385293862938729388293892939029391293922939329394293952939629397293982939929400294012940229403294042940529406294072940829409294102941129412294132941429415294162941729418294192942029421294222942329424294252942629427294282942929430294312943229433294342943529436294372943829439294402944129442294432944429445294462944729448294492945029451294522945329454294552945629457294582945929460294612946229463294642946529466294672946829469294702947129472294732947429475294762947729478294792948029481294822948329484294852948629487294882948929490294912949229493294942949529496294972949829499295002950129502295032950429505295062950729508295092951029511295122951329514295152951629517295182951929520295212952229523295242952529526295272952829529295302953129532295332953429535295362953729538295392954029541295422954329544295452954629547295482954929550295512955229553295542955529556295572955829559295602956129562295632956429565295662956729568295692957029571295722957329574295752957629577295782957929580295812958229583295842958529586295872958829589295902959129592295932959429595295962959729598295992960029601296022960329604296052960629607296082960929610296112961229613296142961529616296172961829619296202962129622296232962429625296262962729628296292963029631296322963329634296352963629637296382963929640296412964229643296442964529646296472964829649296502965129652296532965429655296562965729658296592966029661296622966329664296652966629667296682966929670296712967229673296742967529676296772967829679296802968129682296832968429685296862968729688296892969029691296922969329694296952969629697296982969929700297012970229703297042970529706297072970829709297102971129712297132971429715297162971729718297192972029721297222972329724297252972629727297282972929730297312973229733297342973529736297372973829739297402974129742297432974429745297462974729748297492975029751297522975329754297552975629757297582975929760297612976229763297642976529766297672976829769297702977129772297732977429775297762977729778297792978029781297822978329784297852978629787297882978929790297912979229793297942979529796297972979829799298002980129802298032980429805298062980729808298092981029811298122981329814298152981629817298182981929820298212982229823298242982529826298272982829829298302983129832298332983429835298362983729838298392984029841298422984329844298452984629847298482984929850298512985229853298542985529856298572985829859298602986129862298632986429865298662986729868298692987029871298722987329874298752987629877298782987929880298812988229883298842988529886298872988829889298902989129892298932989429895298962989729898298992990029901299022990329904299052990629907299082990929910299112991229913299142991529916299172991829919299202992129922299232992429925299262992729928299292993029931299322993329934299352993629937299382993929940299412994229943299442994529946299472994829949299502995129952299532995429955299562995729958299592996029961299622996329964299652996629967299682996929970299712997229973299742997529976299772997829979299802998129982299832998429985299862998729988299892999029991299922999329994299952999629997299982999930000300013000230003300043000530006300073000830009300103001130012300133001430015300163001730018300193002030021300223002330024300253002630027300283002930030300313003230033300343003530036300373003830039300403004130042300433004430045300463004730048300493005030051300523005330054300553005630057300583005930060300613006230063300643006530066300673006830069300703007130072300733007430075300763007730078300793008030081300823008330084300853008630087300883008930090300913009230093300943009530096300973009830099301003010130102301033010430105301063010730108301093011030111301123011330114301153011630117301183011930120301213012230123301243012530126301273012830129301303013130132301333013430135301363013730138301393014030141301423014330144301453014630147301483014930150301513015230153301543015530156301573015830159301603016130162301633016430165301663016730168301693017030171301723017330174301753017630177301783017930180301813018230183301843018530186301873018830189301903019130192301933019430195301963019730198301993020030201302023020330204302053020630207302083020930210302113021230213302143021530216302173021830219302203022130222302233022430225302263022730228302293023030231302323023330234302353023630237302383023930240302413024230243302443024530246302473024830249302503025130252302533025430255302563025730258302593026030261302623026330264302653026630267302683026930270302713027230273302743027530276302773027830279302803028130282302833028430285302863028730288302893029030291302923029330294302953029630297302983029930300303013030230303303043030530306303073030830309303103031130312303133031430315303163031730318303193032030321303223032330324303253032630327303283032930330303313033230333303343033530336303373033830339303403034130342303433034430345303463034730348303493035030351303523035330354303553035630357303583035930360303613036230363303643036530366303673036830369303703037130372303733037430375303763037730378303793038030381303823038330384303853038630387303883038930390303913039230393303943039530396303973039830399304003040130402304033040430405304063040730408304093041030411304123041330414304153041630417304183041930420304213042230423304243042530426304273042830429304303043130432304333043430435304363043730438304393044030441304423044330444304453044630447304483044930450304513045230453304543045530456304573045830459304603046130462304633046430465304663046730468304693047030471304723047330474304753047630477304783047930480304813048230483304843048530486304873048830489304903049130492304933049430495304963049730498304993050030501305023050330504305053050630507305083050930510305113051230513305143051530516305173051830519305203052130522305233052430525305263052730528305293053030531305323053330534305353053630537305383053930540305413054230543305443054530546305473054830549305503055130552305533055430555305563055730558305593056030561305623056330564305653056630567305683056930570305713057230573305743057530576305773057830579305803058130582305833058430585305863058730588305893059030591305923059330594305953059630597305983059930600306013060230603306043060530606306073060830609306103061130612306133061430615306163061730618306193062030621306223062330624306253062630627306283062930630306313063230633306343063530636306373063830639306403064130642306433064430645306463064730648306493065030651306523065330654306553065630657306583065930660306613066230663306643066530666306673066830669306703067130672306733067430675306763067730678306793068030681306823068330684306853068630687306883068930690306913069230693306943069530696306973069830699307003070130702307033070430705307063070730708307093071030711307123071330714307153071630717307183071930720307213072230723307243072530726307273072830729307303073130732307333073430735307363073730738307393074030741307423074330744307453074630747307483074930750307513075230753307543075530756307573075830759307603076130762307633076430765307663076730768307693077030771307723077330774307753077630777307783077930780307813078230783307843078530786307873078830789307903079130792307933079430795307963079730798307993080030801308023080330804308053080630807308083080930810308113081230813308143081530816308173081830819308203082130822308233082430825308263082730828308293083030831308323083330834308353083630837308383083930840308413084230843308443084530846308473084830849308503085130852308533085430855308563085730858308593086030861308623086330864308653086630867308683086930870308713087230873308743087530876308773087830879308803088130882308833088430885308863088730888308893089030891308923089330894308953089630897308983089930900309013090230903309043090530906309073090830909309103091130912309133091430915309163091730918309193092030921309223092330924309253092630927309283092930930309313093230933309343093530936309373093830939309403094130942309433094430945309463094730948309493095030951309523095330954309553095630957309583095930960309613096230963309643096530966309673096830969309703097130972309733097430975309763097730978309793098030981309823098330984309853098630987309883098930990309913099230993309943099530996309973099830999310003100131002310033100431005310063100731008310093101031011310123101331014310153101631017310183101931020310213102231023310243102531026310273102831029310303103131032310333103431035310363103731038310393104031041310423104331044310453104631047310483104931050310513105231053310543105531056310573105831059310603106131062310633106431065310663106731068310693107031071310723107331074310753107631077310783107931080310813108231083310843108531086310873108831089310903109131092310933109431095310963109731098310993110031101311023110331104311053110631107311083110931110311113111231113311143111531116311173111831119311203112131122311233112431125311263112731128311293113031131311323113331134311353113631137311383113931140311413114231143311443114531146311473114831149311503115131152311533115431155311563115731158311593116031161311623116331164311653116631167311683116931170311713117231173311743117531176311773117831179311803118131182311833118431185311863118731188311893119031191311923119331194311953119631197311983119931200312013120231203312043120531206312073120831209312103121131212312133121431215312163121731218312193122031221312223122331224312253122631227312283122931230312313123231233312343123531236312373123831239312403124131242312433124431245312463124731248312493125031251312523125331254312553125631257312583125931260312613126231263312643126531266312673126831269312703127131272312733127431275312763127731278312793128031281312823128331284312853128631287312883128931290312913129231293312943129531296312973129831299313003130131302313033130431305313063130731308313093131031311313123131331314313153131631317313183131931320313213132231323313243132531326313273132831329313303133131332313333133431335313363133731338313393134031341313423134331344313453134631347313483134931350313513135231353313543135531356313573135831359313603136131362313633136431365313663136731368313693137031371313723137331374313753137631377313783137931380313813138231383313843138531386313873138831389313903139131392313933139431395313963139731398313993140031401314023140331404314053140631407314083140931410314113141231413314143141531416314173141831419314203142131422314233142431425314263142731428314293143031431314323143331434314353143631437314383143931440314413144231443314443144531446314473144831449314503145131452314533145431455314563145731458314593146031461314623146331464314653146631467314683146931470314713147231473314743147531476314773147831479314803148131482314833148431485314863148731488314893149031491314923149331494314953149631497314983149931500315013150231503315043150531506315073150831509315103151131512315133151431515315163151731518315193152031521315223152331524315253152631527315283152931530315313153231533315343153531536315373153831539315403154131542315433154431545315463154731548315493155031551315523155331554315553155631557315583155931560315613156231563315643156531566315673156831569315703157131572315733157431575315763157731578315793158031581315823158331584315853158631587315883158931590315913159231593315943159531596315973159831599316003160131602316033160431605316063160731608316093161031611316123161331614316153161631617316183161931620316213162231623316243162531626316273162831629316303163131632316333163431635316363163731638316393164031641316423164331644316453164631647316483164931650316513165231653316543165531656316573165831659316603166131662316633166431665316663166731668316693167031671316723167331674316753167631677316783167931680316813168231683316843168531686316873168831689316903169131692316933169431695316963169731698316993170031701317023170331704317053170631707317083170931710317113171231713317143171531716317173171831719317203172131722317233172431725317263172731728317293173031731317323173331734317353173631737317383173931740317413174231743317443174531746317473174831749317503175131752317533175431755317563175731758317593176031761317623176331764317653176631767317683176931770317713177231773317743177531776317773177831779317803178131782317833178431785317863178731788317893179031791317923179331794317953179631797317983179931800318013180231803318043180531806318073180831809318103181131812318133181431815318163181731818318193182031821318223182331824318253182631827318283182931830318313183231833318343183531836318373183831839318403184131842318433184431845318463184731848318493185031851318523185331854318553185631857318583185931860318613186231863318643186531866318673186831869318703187131872318733187431875318763187731878318793188031881318823188331884318853188631887318883188931890318913189231893318943189531896318973189831899319003190131902319033190431905319063190731908319093191031911319123191331914319153191631917319183191931920319213192231923319243192531926319273192831929319303193131932319333193431935319363193731938319393194031941319423194331944319453194631947319483194931950319513195231953319543195531956319573195831959319603196131962319633196431965319663196731968319693197031971319723197331974319753197631977319783197931980319813198231983319843198531986319873198831989319903199131992319933199431995319963199731998319993200032001320023200332004320053200632007320083200932010320113201232013320143201532016320173201832019320203202132022320233202432025320263202732028320293203032031320323203332034320353203632037320383203932040320413204232043320443204532046320473204832049320503205132052320533205432055320563205732058320593206032061320623206332064320653206632067320683206932070320713207232073320743207532076320773207832079320803208132082320833208432085320863208732088320893209032091320923209332094320953209632097320983209932100321013210232103321043210532106321073210832109321103211132112321133211432115321163211732118321193212032121321223212332124321253212632127321283212932130321313213232133321343213532136321373213832139321403214132142321433214432145321463214732148321493215032151321523215332154321553215632157321583215932160321613216232163321643216532166321673216832169321703217132172321733217432175321763217732178321793218032181321823218332184321853218632187321883218932190321913219232193321943219532196321973219832199322003220132202322033220432205322063220732208322093221032211322123221332214322153221632217322183221932220322213222232223322243222532226322273222832229322303223132232322333223432235322363223732238322393224032241322423224332244322453224632247322483224932250322513225232253322543225532256322573225832259322603226132262322633226432265322663226732268322693227032271322723227332274322753227632277322783227932280322813228232283322843228532286322873228832289322903229132292322933229432295322963229732298322993230032301323023230332304323053230632307323083230932310323113231232313323143231532316323173231832319323203232132322323233232432325323263232732328323293233032331323323233332334323353233632337323383233932340323413234232343323443234532346323473234832349323503235132352323533235432355323563235732358323593236032361323623236332364323653236632367323683236932370323713237232373323743237532376323773237832379323803238132382323833238432385323863238732388323893239032391323923239332394323953239632397323983239932400324013240232403324043240532406324073240832409324103241132412324133241432415324163241732418324193242032421324223242332424324253242632427324283242932430324313243232433324343243532436324373243832439324403244132442324433244432445324463244732448324493245032451324523245332454324553245632457324583245932460324613246232463324643246532466324673246832469324703247132472324733247432475324763247732478324793248032481324823248332484324853248632487324883248932490324913249232493324943249532496324973249832499325003250132502325033250432505325063250732508325093251032511325123251332514325153251632517325183251932520325213252232523325243252532526325273252832529325303253132532325333253432535325363253732538325393254032541325423254332544325453254632547325483254932550325513255232553325543255532556325573255832559325603256132562325633256432565325663256732568325693257032571325723257332574325753257632577325783257932580325813258232583325843258532586325873258832589325903259132592325933259432595325963259732598325993260032601326023260332604326053260632607326083260932610326113261232613326143261532616326173261832619326203262132622326233262432625326263262732628326293263032631326323263332634326353263632637326383263932640326413264232643326443264532646326473264832649326503265132652326533265432655326563265732658326593266032661326623266332664326653266632667326683266932670326713267232673326743267532676326773267832679326803268132682326833268432685326863268732688326893269032691326923269332694326953269632697326983269932700327013270232703327043270532706327073270832709327103271132712327133271432715327163271732718327193272032721327223272332724327253272632727327283272932730327313273232733327343273532736327373273832739327403274132742327433274432745327463274732748327493275032751327523275332754327553275632757327583275932760327613276232763327643276532766327673276832769327703277132772327733277432775327763277732778327793278032781327823278332784327853278632787327883278932790327913279232793327943279532796327973279832799328003280132802328033280432805328063280732808328093281032811328123281332814328153281632817328183281932820328213282232823328243282532826328273282832829328303283132832328333283432835328363283732838328393284032841328423284332844328453284632847328483284932850328513285232853328543285532856328573285832859328603286132862328633286432865328663286732868328693287032871328723287332874328753287632877328783287932880328813288232883328843288532886328873288832889328903289132892328933289432895328963289732898328993290032901329023290332904329053290632907329083290932910329113291232913329143291532916329173291832919329203292132922329233292432925329263292732928329293293032931329323293332934329353293632937329383293932940329413294232943329443294532946329473294832949329503295132952329533295432955329563295732958329593296032961329623296332964329653296632967329683296932970329713297232973329743297532976329773297832979329803298132982329833298432985329863298732988329893299032991329923299332994329953299632997329983299933000330013300233003330043300533006330073300833009330103301133012330133301433015330163301733018330193302033021330223302333024330253302633027330283302933030330313303233033330343303533036330373303833039330403304133042330433304433045330463304733048330493305033051330523305333054330553305633057330583305933060330613306233063330643306533066330673306833069330703307133072330733307433075330763307733078330793308033081330823308333084330853308633087330883308933090330913309233093330943309533096330973309833099331003310133102331033310433105331063310733108331093311033111331123311333114331153311633117331183311933120331213312233123331243312533126331273312833129331303313133132331333313433135331363313733138331393314033141331423314333144331453314633147331483314933150331513315233153331543315533156331573315833159331603316133162331633316433165331663316733168331693317033171331723317333174331753317633177331783317933180331813318233183331843318533186331873318833189331903319133192331933319433195331963319733198331993320033201332023320333204332053320633207332083320933210332113321233213332143321533216332173321833219332203322133222332233322433225332263322733228332293323033231332323323333234332353323633237332383323933240332413324233243332443324533246332473324833249332503325133252332533325433255332563325733258332593326033261332623326333264332653326633267332683326933270332713327233273332743327533276332773327833279332803328133282332833328433285332863328733288332893329033291332923329333294332953329633297332983329933300333013330233303333043330533306333073330833309333103331133312333133331433315333163331733318333193332033321333223332333324333253332633327333283332933330333313333233333333343333533336333373333833339333403334133342333433334433345333463334733348333493335033351333523335333354333553335633357333583335933360333613336233363333643336533366333673336833369333703337133372333733337433375333763337733378333793338033381333823338333384333853338633387333883338933390333913339233393333943339533396333973339833399334003340133402334033340433405334063340733408334093341033411334123341333414334153341633417334183341933420334213342233423334243342533426334273342833429334303343133432334333343433435334363343733438334393344033441334423344333444334453344633447334483344933450334513345233453334543345533456334573345833459334603346133462334633346433465334663346733468334693347033471334723347333474334753347633477334783347933480334813348233483334843348533486334873348833489334903349133492334933349433495334963349733498334993350033501335023350333504335053350633507335083350933510335113351233513335143351533516335173351833519335203352133522335233352433525335263352733528335293353033531335323353333534335353353633537335383353933540335413354233543335443354533546335473354833549335503355133552335533355433555335563355733558335593356033561335623356333564335653356633567335683356933570335713357233573335743357533576335773357833579335803358133582335833358433585335863358733588335893359033591335923359333594335953359633597335983359933600336013360233603336043360533606336073360833609336103361133612336133361433615336163361733618336193362033621336223362333624336253362633627336283362933630336313363233633336343363533636336373363833639336403364133642336433364433645336463364733648336493365033651336523365333654336553365633657336583365933660336613366233663336643366533666336673366833669336703367133672336733367433675336763367733678336793368033681336823368333684336853368633687336883368933690336913369233693336943369533696336973369833699337003370133702337033370433705337063370733708337093371033711337123371333714337153371633717337183371933720337213372233723337243372533726337273372833729337303373133732337333373433735337363373733738337393374033741337423374333744337453374633747337483374933750337513375233753337543375533756337573375833759337603376133762337633376433765337663376733768337693377033771337723377333774337753377633777337783377933780337813378233783337843378533786337873378833789337903379133792337933379433795337963379733798337993380033801338023380333804338053380633807338083380933810338113381233813338143381533816338173381833819338203382133822338233382433825338263382733828338293383033831338323383333834338353383633837338383383933840338413384233843338443384533846338473384833849338503385133852338533385433855338563385733858338593386033861338623386333864338653386633867338683386933870338713387233873338743387533876338773387833879338803388133882338833388433885338863388733888338893389033891338923389333894338953389633897338983389933900339013390233903339043390533906339073390833909339103391133912339133391433915339163391733918339193392033921339223392333924339253392633927339283392933930339313393233933339343393533936339373393833939339403394133942339433394433945339463394733948339493395033951339523395333954339553395633957339583395933960339613396233963339643396533966339673396833969339703397133972339733397433975339763397733978339793398033981339823398333984339853398633987339883398933990339913399233993339943399533996339973399833999340003400134002340033400434005340063400734008340093401034011340123401334014340153401634017340183401934020340213402234023340243402534026340273402834029340303403134032340333403434035340363403734038340393404034041340423404334044340453404634047340483404934050340513405234053340543405534056340573405834059340603406134062340633406434065340663406734068340693407034071340723407334074340753407634077340783407934080340813408234083340843408534086340873408834089340903409134092340933409434095340963409734098340993410034101341023410334104341053410634107341083410934110341113411234113341143411534116341173411834119341203412134122341233412434125341263412734128341293413034131341323413334134341353413634137341383413934140341413414234143341443414534146341473414834149341503415134152341533415434155341563415734158341593416034161341623416334164341653416634167341683416934170341713417234173341743417534176341773417834179341803418134182341833418434185341863418734188341893419034191341923419334194341953419634197341983419934200342013420234203342043420534206342073420834209342103421134212342133421434215342163421734218342193422034221342223422334224342253422634227342283422934230342313423234233342343423534236342373423834239342403424134242342433424434245342463424734248342493425034251342523425334254342553425634257342583425934260342613426234263342643426534266342673426834269342703427134272342733427434275342763427734278342793428034281342823428334284342853428634287342883428934290342913429234293342943429534296342973429834299343003430134302343033430434305343063430734308343093431034311343123431334314343153431634317343183431934320343213432234323343243432534326343273432834329343303433134332343333433434335343363433734338343393434034341343423434334344343453434634347343483434934350343513435234353343543435534356343573435834359343603436134362343633436434365343663436734368343693437034371343723437334374343753437634377343783437934380343813438234383343843438534386343873438834389343903439134392343933439434395343963439734398343993440034401344023440334404344053440634407344083440934410344113441234413344143441534416344173441834419344203442134422344233442434425344263442734428344293443034431344323443334434344353443634437344383443934440344413444234443344443444534446344473444834449344503445134452344533445434455344563445734458344593446034461344623446334464344653446634467344683446934470344713447234473344743447534476344773447834479344803448134482344833448434485344863448734488344893449034491344923449334494344953449634497344983449934500345013450234503345043450534506345073450834509345103451134512345133451434515345163451734518345193452034521345223452334524345253452634527345283452934530345313453234533345343453534536345373453834539345403454134542345433454434545345463454734548345493455034551345523455334554345553455634557345583455934560345613456234563345643456534566345673456834569345703457134572345733457434575345763457734578345793458034581345823458334584345853458634587345883458934590345913459234593345943459534596345973459834599346003460134602346033460434605346063460734608346093461034611346123461334614346153461634617346183461934620346213462234623346243462534626346273462834629346303463134632346333463434635346363463734638346393464034641346423464334644346453464634647346483464934650346513465234653346543465534656346573465834659346603466134662346633466434665346663466734668346693467034671346723467334674346753467634677346783467934680346813468234683346843468534686346873468834689346903469134692346933469434695346963469734698346993470034701347023470334704347053470634707347083470934710347113471234713347143471534716347173471834719347203472134722347233472434725347263472734728347293473034731347323473334734347353473634737347383473934740347413474234743347443474534746347473474834749347503475134752347533475434755347563475734758347593476034761347623476334764347653476634767347683476934770347713477234773347743477534776347773477834779347803478134782347833478434785347863478734788347893479034791347923479334794347953479634797347983479934800348013480234803348043480534806348073480834809348103481134812348133481434815348163481734818348193482034821348223482334824348253482634827348283482934830348313483234833348343483534836348373483834839348403484134842348433484434845348463484734848348493485034851348523485334854348553485634857348583485934860348613486234863348643486534866348673486834869348703487134872348733487434875348763487734878348793488034881348823488334884348853488634887348883488934890348913489234893348943489534896348973489834899349003490134902349033490434905349063490734908349093491034911349123491334914349153491634917349183491934920349213492234923349243492534926349273492834929349303493134932349333493434935349363493734938349393494034941349423494334944349453494634947349483494934950349513495234953349543495534956349573495834959349603496134962349633496434965349663496734968349693497034971349723497334974349753497634977349783497934980349813498234983349843498534986349873498834989349903499134992349933499434995349963499734998349993500035001350023500335004350053500635007350083500935010350113501235013350143501535016350173501835019350203502135022350233502435025350263502735028350293503035031350323503335034350353503635037350383503935040350413504235043350443504535046350473504835049350503505135052350533505435055350563505735058350593506035061350623506335064350653506635067350683506935070350713507235073350743507535076350773507835079350803508135082350833508435085350863508735088350893509035091350923509335094350953509635097350983509935100351013510235103351043510535106351073510835109351103511135112351133511435115351163511735118351193512035121351223512335124351253512635127351283512935130351313513235133351343513535136351373513835139351403514135142351433514435145351463514735148351493515035151351523515335154351553515635157351583515935160351613516235163351643516535166351673516835169351703517135172351733517435175351763517735178351793518035181351823518335184351853518635187351883518935190351913519235193351943519535196351973519835199352003520135202352033520435205352063520735208352093521035211352123521335214352153521635217352183521935220352213522235223352243522535226352273522835229352303523135232352333523435235352363523735238352393524035241352423524335244352453524635247352483524935250352513525235253352543525535256352573525835259352603526135262352633526435265352663526735268352693527035271352723527335274352753527635277352783527935280352813528235283352843528535286352873528835289352903529135292352933529435295352963529735298352993530035301353023530335304353053530635307353083530935310353113531235313353143531535316353173531835319353203532135322353233532435325353263532735328353293533035331353323533335334353353533635337353383533935340353413534235343353443534535346353473534835349353503535135352353533535435355353563535735358353593536035361353623536335364353653536635367353683536935370353713537235373353743537535376353773537835379353803538135382353833538435385353863538735388353893539035391353923539335394353953539635397353983539935400354013540235403354043540535406354073540835409354103541135412354133541435415354163541735418354193542035421354223542335424354253542635427354283542935430354313543235433354343543535436354373543835439354403544135442354433544435445354463544735448354493545035451354523545335454354553545635457354583545935460354613546235463354643546535466354673546835469354703547135472354733547435475354763547735478354793548035481354823548335484354853548635487354883548935490354913549235493354943549535496354973549835499355003550135502355033550435505355063550735508355093551035511355123551335514355153551635517355183551935520355213552235523355243552535526355273552835529355303553135532355333553435535355363553735538355393554035541355423554335544355453554635547355483554935550355513555235553355543555535556355573555835559355603556135562355633556435565355663556735568355693557035571355723557335574355753557635577355783557935580355813558235583355843558535586355873558835589355903559135592355933559435595355963559735598355993560035601356023560335604356053560635607356083560935610356113561235613356143561535616356173561835619356203562135622356233562435625356263562735628356293563035631356323563335634356353563635637356383563935640356413564235643356443564535646356473564835649356503565135652356533565435655356563565735658356593566035661356623566335664356653566635667356683566935670356713567235673356743567535676356773567835679356803568135682356833568435685356863568735688356893569035691356923569335694356953569635697356983569935700357013570235703357043570535706357073570835709357103571135712357133571435715357163571735718357193572035721357223572335724357253572635727357283572935730357313573235733357343573535736357373573835739357403574135742357433574435745357463574735748357493575035751357523575335754357553575635757357583575935760357613576235763357643576535766357673576835769357703577135772357733577435775357763577735778357793578035781357823578335784357853578635787357883578935790357913579235793357943579535796357973579835799358003580135802358033580435805358063580735808358093581035811358123581335814358153581635817358183581935820358213582235823358243582535826358273582835829358303583135832358333583435835358363583735838358393584035841358423584335844358453584635847358483584935850358513585235853358543585535856358573585835859358603586135862358633586435865358663586735868358693587035871358723587335874358753587635877358783587935880358813588235883358843588535886358873588835889358903589135892358933589435895358963589735898358993590035901359023590335904359053590635907359083590935910359113591235913359143591535916359173591835919359203592135922359233592435925359263592735928359293593035931359323593335934359353593635937359383593935940359413594235943359443594535946359473594835949359503595135952359533595435955359563595735958359593596035961359623596335964359653596635967359683596935970359713597235973359743597535976359773597835979359803598135982359833598435985359863598735988359893599035991359923599335994359953599635997359983599936000360013600236003360043600536006360073600836009360103601136012360133601436015360163601736018360193602036021360223602336024360253602636027360283602936030360313603236033360343603536036360373603836039360403604136042360433604436045360463604736048360493605036051360523605336054360553605636057360583605936060360613606236063360643606536066360673606836069360703607136072360733607436075360763607736078360793608036081360823608336084360853608636087360883608936090360913609236093360943609536096360973609836099361003610136102361033610436105361063610736108361093611036111361123611336114361153611636117361183611936120361213612236123361243612536126361273612836129361303613136132361333613436135361363613736138361393614036141361423614336144361453614636147361483614936150361513615236153361543615536156361573615836159361603616136162361633616436165361663616736168361693617036171361723617336174361753617636177361783617936180361813618236183361843618536186361873618836189361903619136192361933619436195361963619736198361993620036201362023620336204362053620636207362083620936210362113621236213362143621536216362173621836219362203622136222362233622436225362263622736228362293623036231362323623336234362353623636237362383623936240362413624236243362443624536246362473624836249362503625136252362533625436255362563625736258362593626036261362623626336264362653626636267362683626936270362713627236273362743627536276362773627836279362803628136282362833628436285362863628736288362893629036291362923629336294362953629636297362983629936300363013630236303363043630536306363073630836309363103631136312363133631436315363163631736318363193632036321363223632336324363253632636327363283632936330363313633236333363343633536336363373633836339363403634136342363433634436345363463634736348363493635036351363523635336354363553635636357363583635936360363613636236363363643636536366363673636836369363703637136372363733637436375363763637736378363793638036381363823638336384363853638636387363883638936390363913639236393363943639536396363973639836399364003640136402364033640436405364063640736408364093641036411364123641336414364153641636417364183641936420364213642236423364243642536426364273642836429364303643136432364333643436435364363643736438364393644036441364423644336444364453644636447364483644936450364513645236453364543645536456364573645836459364603646136462364633646436465364663646736468364693647036471364723647336474364753647636477364783647936480364813648236483364843648536486364873648836489364903649136492364933649436495364963649736498364993650036501365023650336504365053650636507365083650936510365113651236513365143651536516365173651836519365203652136522365233652436525365263652736528365293653036531365323653336534365353653636537365383653936540365413654236543365443654536546365473654836549365503655136552365533655436555365563655736558365593656036561365623656336564365653656636567365683656936570365713657236573365743657536576365773657836579365803658136582365833658436585365863658736588365893659036591365923659336594365953659636597365983659936600366013660236603366043660536606366073660836609366103661136612366133661436615366163661736618366193662036621366223662336624366253662636627366283662936630366313663236633366343663536636366373663836639366403664136642366433664436645366463664736648366493665036651366523665336654366553665636657366583665936660366613666236663366643666536666366673666836669366703667136672366733667436675366763667736678366793668036681366823668336684366853668636687366883668936690366913669236693366943669536696366973669836699367003670136702367033670436705367063670736708367093671036711367123671336714367153671636717367183671936720367213672236723367243672536726367273672836729367303673136732367333673436735367363673736738367393674036741367423674336744367453674636747367483674936750367513675236753367543675536756367573675836759367603676136762367633676436765367663676736768367693677036771367723677336774367753677636777367783677936780367813678236783367843678536786367873678836789367903679136792367933679436795367963679736798367993680036801368023680336804368053680636807368083680936810368113681236813368143681536816368173681836819368203682136822368233682436825368263682736828368293683036831368323683336834368353683636837368383683936840368413684236843368443684536846368473684836849368503685136852368533685436855368563685736858368593686036861368623686336864368653686636867368683686936870368713687236873368743687536876368773687836879368803688136882368833688436885368863688736888368893689036891368923689336894368953689636897368983689936900369013690236903369043690536906369073690836909369103691136912369133691436915369163691736918369193692036921369223692336924369253692636927369283692936930369313693236933369343693536936369373693836939369403694136942369433694436945369463694736948369493695036951369523695336954369553695636957369583695936960369613696236963369643696536966369673696836969369703697136972369733697436975369763697736978369793698036981369823698336984369853698636987369883698936990369913699236993369943699536996369973699836999370003700137002370033700437005370063700737008370093701037011370123701337014370153701637017370183701937020370213702237023370243702537026370273702837029370303703137032370333703437035370363703737038370393704037041370423704337044370453704637047370483704937050370513705237053370543705537056370573705837059370603706137062370633706437065370663706737068370693707037071370723707337074370753707637077370783707937080370813708237083370843708537086370873708837089370903709137092370933709437095370963709737098370993710037101371023710337104371053710637107371083710937110371113711237113371143711537116371173711837119371203712137122371233712437125371263712737128371293713037131371323713337134371353713637137371383713937140371413714237143371443714537146371473714837149371503715137152371533715437155371563715737158371593716037161371623716337164371653716637167371683716937170371713717237173371743717537176371773717837179371803718137182371833718437185371863718737188371893719037191371923719337194371953719637197371983719937200372013720237203372043720537206372073720837209372103721137212372133721437215372163721737218372193722037221372223722337224372253722637227372283722937230372313723237233372343723537236372373723837239372403724137242372433724437245372463724737248372493725037251372523725337254372553725637257372583725937260372613726237263372643726537266372673726837269372703727137272372733727437275372763727737278372793728037281372823728337284372853728637287372883728937290372913729237293372943729537296372973729837299373003730137302373033730437305373063730737308373093731037311373123731337314373153731637317373183731937320373213732237323373243732537326373273732837329373303733137332373333733437335373363733737338373393734037341373423734337344373453734637347373483734937350373513735237353373543735537356373573735837359373603736137362373633736437365373663736737368373693737037371373723737337374373753737637377373783737937380373813738237383373843738537386373873738837389373903739137392373933739437395373963739737398373993740037401374023740337404374053740637407374083740937410374113741237413374143741537416374173741837419374203742137422374233742437425374263742737428374293743037431374323743337434374353743637437374383743937440374413744237443374443744537446374473744837449374503745137452374533745437455374563745737458374593746037461374623746337464374653746637467374683746937470374713747237473374743747537476374773747837479374803748137482374833748437485374863748737488374893749037491374923749337494374953749637497374983749937500375013750237503375043750537506375073750837509375103751137512375133751437515375163751737518375193752037521375223752337524375253752637527375283752937530375313753237533375343753537536375373753837539375403754137542375433754437545375463754737548375493755037551375523755337554375553755637557375583755937560375613756237563375643756537566375673756837569375703757137572375733757437575375763757737578375793758037581375823758337584375853758637587375883758937590375913759237593375943759537596375973759837599376003760137602376033760437605376063760737608376093761037611376123761337614376153761637617376183761937620376213762237623376243762537626376273762837629376303763137632376333763437635376363763737638376393764037641376423764337644376453764637647376483764937650376513765237653376543765537656376573765837659376603766137662376633766437665376663766737668376693767037671376723767337674376753767637677376783767937680376813768237683376843768537686376873768837689376903769137692376933769437695376963769737698376993770037701377023770337704377053770637707377083770937710377113771237713377143771537716377173771837719377203772137722377233772437725377263772737728377293773037731377323773337734377353773637737377383773937740377413774237743377443774537746377473774837749377503775137752377533775437755377563775737758377593776037761377623776337764377653776637767377683776937770377713777237773377743777537776377773777837779377803778137782377833778437785377863778737788377893779037791377923779337794377953779637797377983779937800378013780237803378043780537806378073780837809378103781137812378133781437815378163781737818378193782037821378223782337824378253782637827378283782937830378313783237833378343783537836378373783837839378403784137842378433784437845378463784737848378493785037851378523785337854378553785637857378583785937860378613786237863378643786537866378673786837869378703787137872378733787437875378763787737878378793788037881378823788337884378853788637887378883788937890378913789237893378943789537896378973789837899379003790137902379033790437905379063790737908379093791037911379123791337914379153791637917379183791937920379213792237923379243792537926379273792837929379303793137932379333793437935379363793737938379393794037941379423794337944379453794637947379483794937950379513795237953379543795537956379573795837959379603796137962379633796437965379663796737968379693797037971379723797337974379753797637977379783797937980379813798237983379843798537986379873798837989379903799137992379933799437995379963799737998379993800038001380023800338004380053800638007380083800938010380113801238013380143801538016380173801838019380203802138022380233802438025380263802738028380293803038031380323803338034380353803638037380383803938040380413804238043380443804538046380473804838049380503805138052380533805438055380563805738058380593806038061380623806338064380653806638067380683806938070380713807238073380743807538076380773807838079380803808138082380833808438085380863808738088380893809038091380923809338094380953809638097380983809938100381013810238103381043810538106381073810838109381103811138112381133811438115381163811738118381193812038121381223812338124381253812638127381283812938130381313813238133381343813538136381373813838139381403814138142381433814438145381463814738148381493815038151381523815338154381553815638157381583815938160381613816238163381643816538166381673816838169381703817138172381733817438175381763817738178381793818038181381823818338184381853818638187381883818938190381913819238193381943819538196381973819838199382003820138202382033820438205382063820738208382093821038211382123821338214382153821638217382183821938220382213822238223382243822538226382273822838229382303823138232382333823438235382363823738238382393824038241382423824338244382453824638247382483824938250382513825238253382543825538256382573825838259382603826138262382633826438265382663826738268382693827038271382723827338274382753827638277382783827938280382813828238283382843828538286382873828838289382903829138292382933829438295382963829738298382993830038301383023830338304383053830638307383083830938310383113831238313383143831538316383173831838319383203832138322383233832438325383263832738328383293833038331383323833338334383353833638337383383833938340383413834238343383443834538346383473834838349383503835138352383533835438355383563835738358383593836038361383623836338364383653836638367383683836938370383713837238373383743837538376383773837838379383803838138382383833838438385383863838738388383893839038391383923839338394383953839638397383983839938400384013840238403384043840538406384073840838409384103841138412384133841438415384163841738418384193842038421384223842338424384253842638427384283842938430384313843238433384343843538436384373843838439384403844138442384433844438445384463844738448384493845038451384523845338454384553845638457384583845938460384613846238463384643846538466384673846838469384703847138472384733847438475384763847738478384793848038481384823848338484384853848638487384883848938490384913849238493384943849538496384973849838499385003850138502385033850438505385063850738508385093851038511385123851338514385153851638517385183851938520385213852238523385243852538526385273852838529385303853138532385333853438535385363853738538385393854038541385423854338544385453854638547385483854938550385513855238553385543855538556385573855838559385603856138562385633856438565385663856738568385693857038571385723857338574385753857638577385783857938580385813858238583385843858538586385873858838589385903859138592385933859438595385963859738598385993860038601386023860338604386053860638607386083860938610386113861238613386143861538616386173861838619386203862138622386233862438625386263862738628386293863038631386323863338634386353863638637386383863938640386413864238643386443864538646386473864838649386503865138652386533865438655386563865738658386593866038661386623866338664386653866638667386683866938670386713867238673386743867538676386773867838679386803868138682386833868438685386863868738688386893869038691386923869338694386953869638697386983869938700387013870238703387043870538706387073870838709387103871138712387133871438715387163871738718387193872038721387223872338724387253872638727387283872938730387313873238733387343873538736387373873838739387403874138742387433874438745387463874738748387493875038751387523875338754387553875638757387583875938760387613876238763387643876538766387673876838769387703877138772387733877438775387763877738778387793878038781387823878338784387853878638787387883878938790387913879238793387943879538796387973879838799388003880138802388033880438805388063880738808388093881038811388123881338814388153881638817388183881938820388213882238823388243882538826388273882838829388303883138832388333883438835388363883738838388393884038841388423884338844388453884638847388483884938850388513885238853388543885538856388573885838859388603886138862388633886438865388663886738868388693887038871388723887338874388753887638877388783887938880388813888238883388843888538886388873888838889388903889138892388933889438895388963889738898388993890038901389023890338904389053890638907389083890938910389113891238913389143891538916389173891838919389203892138922389233892438925389263892738928389293893038931389323893338934389353893638937389383893938940389413894238943389443894538946389473894838949389503895138952389533895438955389563895738958389593896038961389623896338964389653896638967389683896938970389713897238973389743897538976389773897838979389803898138982389833898438985389863898738988389893899038991389923899338994389953899638997389983899939000390013900239003390043900539006390073900839009390103901139012390133901439015390163901739018390193902039021390223902339024390253902639027390283902939030390313903239033390343903539036390373903839039390403904139042390433904439045390463904739048390493905039051390523905339054390553905639057390583905939060390613906239063390643906539066390673906839069390703907139072390733907439075390763907739078390793908039081390823908339084390853908639087390883908939090390913909239093390943909539096390973909839099391003910139102391033910439105391063910739108391093911039111391123911339114391153911639117391183911939120391213912239123391243912539126391273912839129391303913139132391333913439135391363913739138391393914039141391423914339144391453914639147391483914939150391513915239153391543915539156391573915839159391603916139162391633916439165391663916739168391693917039171391723917339174391753917639177391783917939180391813918239183391843918539186391873918839189391903919139192391933919439195391963919739198391993920039201392023920339204392053920639207392083920939210392113921239213392143921539216392173921839219392203922139222392233922439225392263922739228392293923039231392323923339234392353923639237392383923939240392413924239243392443924539246392473924839249392503925139252392533925439255392563925739258392593926039261392623926339264392653926639267392683926939270392713927239273392743927539276392773927839279392803928139282392833928439285392863928739288392893929039291392923929339294392953929639297392983929939300393013930239303393043930539306393073930839309393103931139312393133931439315393163931739318393193932039321393223932339324393253932639327393283932939330393313933239333393343933539336393373933839339393403934139342393433934439345393463934739348393493935039351393523935339354393553935639357393583935939360393613936239363393643936539366393673936839369393703937139372393733937439375393763937739378393793938039381393823938339384393853938639387393883938939390393913939239393393943939539396393973939839399394003940139402394033940439405394063940739408394093941039411394123941339414394153941639417394183941939420394213942239423394243942539426394273942839429394303943139432394333943439435394363943739438394393944039441394423944339444394453944639447394483944939450394513945239453394543945539456394573945839459394603946139462394633946439465394663946739468394693947039471394723947339474394753947639477394783947939480394813948239483394843948539486394873948839489394903949139492394933949439495394963949739498394993950039501395023950339504395053950639507395083950939510395113951239513395143951539516395173951839519395203952139522395233952439525395263952739528395293953039531395323953339534395353953639537395383953939540395413954239543395443954539546395473954839549395503955139552395533955439555395563955739558395593956039561395623956339564395653956639567395683956939570395713957239573395743957539576395773957839579395803958139582395833958439585395863958739588395893959039591395923959339594395953959639597395983959939600396013960239603396043960539606396073960839609396103961139612396133961439615396163961739618396193962039621396223962339624396253962639627396283962939630396313963239633396343963539636396373963839639396403964139642396433964439645396463964739648396493965039651396523965339654396553965639657396583965939660396613966239663396643966539666396673966839669396703967139672396733967439675396763967739678396793968039681396823968339684396853968639687396883968939690396913969239693396943969539696396973969839699397003970139702397033970439705397063970739708397093971039711397123971339714397153971639717397183971939720397213972239723397243972539726397273972839729397303973139732397333973439735397363973739738397393974039741397423974339744397453974639747397483974939750397513975239753397543975539756397573975839759397603976139762397633976439765397663976739768397693977039771397723977339774397753977639777397783977939780397813978239783397843978539786397873978839789397903979139792397933979439795397963979739798397993980039801398023980339804398053980639807398083980939810398113981239813398143981539816398173981839819398203982139822398233982439825398263982739828398293983039831398323983339834398353983639837398383983939840398413984239843398443984539846398473984839849398503985139852398533985439855398563985739858398593986039861398623986339864398653986639867398683986939870398713987239873398743987539876398773987839879398803988139882398833988439885398863988739888398893989039891398923989339894398953989639897398983989939900399013990239903399043990539906399073990839909399103991139912399133991439915399163991739918399193992039921399223992339924399253992639927399283992939930399313993239933399343993539936399373993839939399403994139942399433994439945399463994739948399493995039951399523995339954399553995639957399583995939960399613996239963399643996539966399673996839969399703997139972399733997439975399763997739978399793998039981399823998339984399853998639987399883998939990399913999239993399943999539996399973999839999400004000140002400034000440005400064000740008400094001040011400124001340014400154001640017400184001940020400214002240023400244002540026400274002840029400304003140032400334003440035400364003740038400394004040041400424004340044400454004640047400484004940050400514005240053400544005540056400574005840059400604006140062400634006440065400664006740068400694007040071400724007340074400754007640077400784007940080400814008240083400844008540086400874008840089400904009140092400934009440095400964009740098400994010040101401024010340104401054010640107401084010940110401114011240113401144011540116401174011840119401204012140122401234012440125401264012740128401294013040131401324013340134401354013640137401384013940140401414014240143401444014540146401474014840149401504015140152401534015440155401564015740158401594016040161401624016340164401654016640167401684016940170401714017240173401744017540176401774017840179401804018140182401834018440185401864018740188401894019040191401924019340194401954019640197401984019940200402014020240203402044020540206402074020840209402104021140212402134021440215402164021740218402194022040221402224022340224402254022640227402284022940230402314023240233402344023540236402374023840239402404024140242402434024440245402464024740248402494025040251402524025340254402554025640257402584025940260402614026240263402644026540266402674026840269402704027140272402734027440275402764027740278402794028040281402824028340284402854028640287402884028940290402914029240293402944029540296402974029840299403004030140302403034030440305403064030740308403094031040311403124031340314403154031640317403184031940320403214032240323403244032540326403274032840329403304033140332403334033440335403364033740338403394034040341403424034340344403454034640347403484034940350403514035240353403544035540356403574035840359403604036140362403634036440365403664036740368403694037040371403724037340374403754037640377403784037940380403814038240383403844038540386403874038840389403904039140392403934039440395403964039740398403994040040401404024040340404404054040640407404084040940410404114041240413404144041540416404174041840419404204042140422404234042440425404264042740428404294043040431404324043340434404354043640437404384043940440404414044240443404444044540446404474044840449404504045140452404534045440455404564045740458404594046040461404624046340464404654046640467404684046940470404714047240473404744047540476404774047840479404804048140482404834048440485404864048740488404894049040491404924049340494404954049640497404984049940500405014050240503405044050540506405074050840509405104051140512405134051440515405164051740518405194052040521405224052340524405254052640527405284052940530405314053240533405344053540536405374053840539405404054140542405434054440545405464054740548405494055040551405524055340554405554055640557405584055940560405614056240563405644056540566405674056840569405704057140572405734057440575405764057740578405794058040581405824058340584405854058640587405884058940590405914059240593405944059540596405974059840599406004060140602406034060440605406064060740608406094061040611406124061340614406154061640617406184061940620406214062240623406244062540626406274062840629406304063140632406334063440635406364063740638406394064040641406424064340644406454064640647406484064940650406514065240653406544065540656406574065840659406604066140662406634066440665406664066740668406694067040671406724067340674406754067640677406784067940680406814068240683406844068540686406874068840689406904069140692406934069440695406964069740698406994070040701407024070340704407054070640707407084070940710407114071240713407144071540716407174071840719407204072140722407234072440725407264072740728407294073040731407324073340734407354073640737407384073940740407414074240743407444074540746407474074840749407504075140752407534075440755407564075740758407594076040761407624076340764407654076640767407684076940770407714077240773407744077540776407774077840779407804078140782407834078440785407864078740788407894079040791407924079340794407954079640797407984079940800408014080240803408044080540806408074080840809408104081140812408134081440815408164081740818408194082040821408224082340824408254082640827408284082940830408314083240833408344083540836408374083840839408404084140842408434084440845408464084740848408494085040851408524085340854408554085640857408584085940860408614086240863408644086540866408674086840869408704087140872408734087440875408764087740878408794088040881408824088340884408854088640887408884088940890408914089240893408944089540896408974089840899409004090140902409034090440905409064090740908409094091040911409124091340914409154091640917409184091940920409214092240923409244092540926409274092840929409304093140932409334093440935409364093740938409394094040941409424094340944409454094640947409484094940950409514095240953409544095540956409574095840959409604096140962409634096440965409664096740968409694097040971409724097340974409754097640977409784097940980409814098240983409844098540986409874098840989409904099140992409934099440995409964099740998409994100041001410024100341004410054100641007410084100941010410114101241013410144101541016410174101841019410204102141022410234102441025410264102741028410294103041031410324103341034410354103641037410384103941040410414104241043410444104541046410474104841049410504105141052410534105441055410564105741058410594106041061410624106341064410654106641067410684106941070410714107241073410744107541076410774107841079410804108141082410834108441085410864108741088410894109041091410924109341094410954109641097410984109941100411014110241103411044110541106411074110841109411104111141112411134111441115411164111741118411194112041121411224112341124411254112641127411284112941130411314113241133411344113541136411374113841139411404114141142411434114441145411464114741148411494115041151411524115341154411554115641157411584115941160411614116241163411644116541166411674116841169411704117141172411734117441175411764117741178411794118041181411824118341184411854118641187411884118941190411914119241193411944119541196411974119841199412004120141202412034120441205412064120741208412094121041211412124121341214412154121641217412184121941220412214122241223412244122541226412274122841229412304123141232412334123441235412364123741238412394124041241412424124341244412454124641247412484124941250412514125241253412544125541256412574125841259412604126141262412634126441265412664126741268412694127041271412724127341274412754127641277412784127941280412814128241283412844128541286412874128841289412904129141292412934129441295412964129741298412994130041301413024130341304413054130641307413084130941310413114131241313413144131541316413174131841319413204132141322413234132441325413264132741328413294133041331413324133341334413354133641337413384133941340413414134241343413444134541346413474134841349413504135141352413534135441355413564135741358413594136041361413624136341364413654136641367413684136941370413714137241373413744137541376413774137841379413804138141382413834138441385413864138741388413894139041391413924139341394413954139641397413984139941400414014140241403414044140541406414074140841409414104141141412414134141441415414164141741418414194142041421414224142341424414254142641427414284142941430414314143241433414344143541436414374143841439414404144141442414434144441445414464144741448414494145041451414524145341454414554145641457414584145941460414614146241463414644146541466414674146841469414704147141472414734147441475414764147741478414794148041481414824148341484414854148641487414884148941490414914149241493414944149541496414974149841499415004150141502415034150441505415064150741508415094151041511415124151341514415154151641517415184151941520415214152241523415244152541526415274152841529415304153141532415334153441535415364153741538415394154041541415424154341544415454154641547415484154941550415514155241553415544155541556415574155841559415604156141562415634156441565415664156741568415694157041571415724157341574415754157641577415784157941580415814158241583415844158541586415874158841589415904159141592415934159441595415964159741598415994160041601416024160341604416054160641607416084160941610416114161241613416144161541616416174161841619416204162141622416234162441625416264162741628416294163041631416324163341634416354163641637416384163941640416414164241643416444164541646416474164841649416504165141652416534165441655416564165741658416594166041661416624166341664416654166641667416684166941670416714167241673416744167541676416774167841679416804168141682416834168441685416864168741688416894169041691416924169341694416954169641697416984169941700417014170241703417044170541706417074170841709417104171141712417134171441715417164171741718417194172041721417224172341724417254172641727417284172941730417314173241733417344173541736417374173841739417404174141742417434174441745417464174741748417494175041751417524175341754417554175641757417584175941760417614176241763417644176541766417674176841769417704177141772417734177441775417764177741778417794178041781417824178341784417854178641787417884178941790417914179241793417944179541796417974179841799418004180141802418034180441805418064180741808418094181041811418124181341814418154181641817418184181941820418214182241823418244182541826418274182841829418304183141832418334183441835418364183741838418394184041841418424184341844418454184641847418484184941850418514185241853418544185541856418574185841859418604186141862418634186441865418664186741868418694187041871418724187341874418754187641877418784187941880418814188241883418844188541886418874188841889418904189141892418934189441895418964189741898418994190041901419024190341904419054190641907419084190941910419114191241913419144191541916419174191841919419204192141922419234192441925419264192741928419294193041931419324193341934419354193641937419384193941940419414194241943419444194541946419474194841949419504195141952419534195441955419564195741958419594196041961419624196341964419654196641967419684196941970419714197241973419744197541976419774197841979419804198141982419834198441985419864198741988419894199041991419924199341994419954199641997419984199942000420014200242003420044200542006420074200842009420104201142012420134201442015420164201742018420194202042021420224202342024420254202642027420284202942030420314203242033420344203542036420374203842039420404204142042420434204442045420464204742048420494205042051420524205342054420554205642057420584205942060420614206242063420644206542066420674206842069420704207142072420734207442075420764207742078420794208042081420824208342084420854208642087420884208942090420914209242093420944209542096420974209842099421004210142102421034210442105421064210742108421094211042111421124211342114421154211642117421184211942120421214212242123421244212542126421274212842129421304213142132421334213442135421364213742138421394214042141421424214342144421454214642147421484214942150421514215242153421544215542156421574215842159421604216142162421634216442165421664216742168421694217042171421724217342174421754217642177421784217942180421814218242183421844218542186421874218842189421904219142192421934219442195421964219742198421994220042201422024220342204422054220642207422084220942210422114221242213422144221542216422174221842219422204222142222422234222442225422264222742228422294223042231422324223342234422354223642237422384223942240422414224242243422444224542246422474224842249422504225142252422534225442255422564225742258422594226042261422624226342264422654226642267422684226942270422714227242273422744227542276422774227842279422804228142282422834228442285422864228742288422894229042291422924229342294422954229642297422984229942300423014230242303423044230542306423074230842309423104231142312423134231442315423164231742318423194232042321423224232342324423254232642327423284232942330423314233242333423344233542336423374233842339423404234142342423434234442345423464234742348423494235042351423524235342354423554235642357423584235942360423614236242363423644236542366423674236842369423704237142372423734237442375423764237742378423794238042381423824238342384423854238642387423884238942390423914239242393423944239542396423974239842399424004240142402424034240442405424064240742408424094241042411424124241342414424154241642417424184241942420424214242242423424244242542426424274242842429424304243142432424334243442435424364243742438424394244042441424424244342444424454244642447424484244942450424514245242453424544245542456424574245842459424604246142462424634246442465424664246742468424694247042471424724247342474424754247642477424784247942480424814248242483424844248542486424874248842489424904249142492424934249442495424964249742498424994250042501425024250342504425054250642507425084250942510425114251242513425144251542516425174251842519425204252142522425234252442525425264252742528425294253042531425324253342534425354253642537425384253942540425414254242543425444254542546425474254842549425504255142552425534255442555425564255742558425594256042561425624256342564425654256642567425684256942570425714257242573425744257542576425774257842579425804258142582425834258442585425864258742588425894259042591425924259342594425954259642597425984259942600426014260242603426044260542606426074260842609426104261142612426134261442615426164261742618426194262042621426224262342624426254262642627426284262942630426314263242633426344263542636426374263842639426404264142642426434264442645426464264742648426494265042651426524265342654426554265642657426584265942660426614266242663426644266542666426674266842669426704267142672426734267442675426764267742678426794268042681426824268342684426854268642687426884268942690426914269242693426944269542696426974269842699427004270142702427034270442705427064270742708427094271042711427124271342714427154271642717427184271942720427214272242723427244272542726427274272842729427304273142732427334273442735427364273742738427394274042741427424274342744427454274642747427484274942750427514275242753427544275542756427574275842759427604276142762427634276442765427664276742768427694277042771427724277342774427754277642777427784277942780427814278242783427844278542786427874278842789427904279142792427934279442795427964279742798427994280042801428024280342804428054280642807428084280942810428114281242813428144281542816428174281842819428204282142822428234282442825428264282742828428294283042831428324283342834428354283642837428384283942840428414284242843428444284542846428474284842849428504285142852428534285442855428564285742858428594286042861428624286342864428654286642867428684286942870428714287242873428744287542876428774287842879428804288142882428834288442885428864288742888428894289042891428924289342894428954289642897428984289942900429014290242903429044290542906429074290842909429104291142912429134291442915429164291742918429194292042921429224292342924429254292642927429284292942930429314293242933429344293542936429374293842939429404294142942429434294442945429464294742948429494295042951429524295342954429554295642957429584295942960429614296242963429644296542966429674296842969429704297142972429734297442975429764297742978429794298042981429824298342984429854298642987429884298942990429914299242993429944299542996429974299842999430004300143002430034300443005430064300743008430094301043011430124301343014430154301643017430184301943020430214302243023430244302543026430274302843029430304303143032430334303443035430364303743038430394304043041430424304343044430454304643047430484304943050430514305243053430544305543056430574305843059430604306143062430634306443065430664306743068430694307043071430724307343074430754307643077430784307943080430814308243083430844308543086430874308843089430904309143092430934309443095430964309743098430994310043101431024310343104431054310643107431084310943110431114311243113431144311543116431174311843119431204312143122431234312443125431264312743128431294313043131431324313343134431354313643137431384313943140431414314243143431444314543146431474314843149431504315143152431534315443155431564315743158431594316043161431624316343164431654316643167431684316943170431714317243173431744317543176431774317843179431804318143182431834318443185431864318743188431894319043191431924319343194431954319643197431984319943200432014320243203432044320543206432074320843209432104321143212432134321443215432164321743218432194322043221432224322343224432254322643227432284322943230432314323243233432344323543236432374323843239432404324143242432434324443245432464324743248432494325043251432524325343254432554325643257432584325943260432614326243263432644326543266432674326843269432704327143272432734327443275432764327743278432794328043281432824328343284432854328643287432884328943290432914329243293432944329543296432974329843299433004330143302433034330443305433064330743308433094331043311433124331343314433154331643317433184331943320433214332243323433244332543326433274332843329433304333143332433334333443335433364333743338433394334043341433424334343344433454334643347433484334943350433514335243353433544335543356433574335843359433604336143362433634336443365433664336743368433694337043371433724337343374433754337643377433784337943380433814338243383433844338543386433874338843389433904339143392433934339443395433964339743398433994340043401434024340343404434054340643407434084340943410434114341243413434144341543416434174341843419434204342143422434234342443425434264342743428434294343043431434324343343434434354343643437434384343943440434414344243443434444344543446434474344843449434504345143452434534345443455434564345743458434594346043461434624346343464434654346643467434684346943470434714347243473434744347543476434774347843479434804348143482434834348443485434864348743488434894349043491434924349343494434954349643497434984349943500435014350243503435044350543506435074350843509435104351143512435134351443515435164351743518435194352043521435224352343524435254352643527435284352943530435314353243533435344353543536435374353843539435404354143542435434354443545435464354743548435494355043551435524355343554435554355643557435584355943560435614356243563435644356543566435674356843569435704357143572435734357443575435764357743578435794358043581435824358343584435854358643587435884358943590435914359243593435944359543596435974359843599436004360143602436034360443605436064360743608436094361043611436124361343614436154361643617436184361943620436214362243623436244362543626436274362843629436304363143632436334363443635436364363743638436394364043641436424364343644436454364643647436484364943650436514365243653436544365543656436574365843659436604366143662436634366443665436664366743668436694367043671436724367343674436754367643677436784367943680436814368243683436844368543686436874368843689436904369143692436934369443695436964369743698436994370043701437024370343704437054370643707437084370943710437114371243713437144371543716437174371843719437204372143722437234372443725437264372743728437294373043731437324373343734437354373643737437384373943740437414374243743437444374543746437474374843749437504375143752437534375443755437564375743758437594376043761437624376343764437654376643767437684376943770437714377243773437744377543776437774377843779437804378143782437834378443785437864378743788437894379043791437924379343794437954379643797437984379943800438014380243803438044380543806438074380843809438104381143812438134381443815438164381743818438194382043821438224382343824438254382643827438284382943830438314383243833438344383543836438374383843839438404384143842438434384443845438464384743848438494385043851438524385343854438554385643857438584385943860438614386243863438644386543866438674386843869438704387143872438734387443875438764387743878438794388043881438824388343884438854388643887438884388943890438914389243893438944389543896438974389843899439004390143902439034390443905439064390743908439094391043911439124391343914439154391643917439184391943920439214392243923439244392543926439274392843929439304393143932439334393443935439364393743938439394394043941439424394343944439454394643947439484394943950439514395243953439544395543956439574395843959439604396143962439634396443965439664396743968439694397043971439724397343974439754397643977439784397943980439814398243983439844398543986439874398843989439904399143992439934399443995439964399743998439994400044001440024400344004440054400644007440084400944010440114401244013440144401544016440174401844019440204402144022440234402444025440264402744028440294403044031440324403344034440354403644037440384403944040440414404244043440444404544046440474404844049440504405144052440534405444055440564405744058440594406044061440624406344064440654406644067440684406944070440714407244073440744407544076440774407844079440804408144082440834408444085440864408744088440894409044091440924409344094440954409644097440984409944100441014410244103441044410544106441074410844109441104411144112441134411444115441164411744118441194412044121441224412344124441254412644127441284412944130441314413244133441344413544136441374413844139441404414144142441434414444145441464414744148441494415044151441524415344154441554415644157441584415944160441614416244163441644416544166441674416844169441704417144172441734417444175441764417744178441794418044181441824418344184441854418644187441884418944190441914419244193441944419544196441974419844199442004420144202442034420444205442064420744208442094421044211442124421344214442154421644217442184421944220442214422244223442244422544226442274422844229442304423144232442334423444235442364423744238442394424044241442424424344244442454424644247442484424944250442514425244253442544425544256442574425844259442604426144262442634426444265442664426744268442694427044271442724427344274442754427644277442784427944280442814428244283442844428544286442874428844289442904429144292442934429444295442964429744298442994430044301443024430344304443054430644307443084430944310443114431244313443144431544316443174431844319443204432144322443234432444325443264432744328443294433044331443324433344334443354433644337443384433944340443414434244343443444434544346443474434844349443504435144352443534435444355443564435744358443594436044361443624436344364443654436644367443684436944370443714437244373443744437544376443774437844379443804438144382443834438444385443864438744388443894439044391443924439344394443954439644397443984439944400444014440244403444044440544406444074440844409444104441144412444134441444415444164441744418444194442044421444224442344424444254442644427444284442944430444314443244433444344443544436444374443844439444404444144442444434444444445444464444744448444494445044451444524445344454444554445644457444584445944460444614446244463444644446544466444674446844469444704447144472444734447444475444764447744478444794448044481444824448344484444854448644487444884448944490444914449244493444944449544496444974449844499445004450144502445034450444505445064450744508445094451044511445124451344514445154451644517445184451944520445214452244523445244452544526445274452844529445304453144532445334453444535445364453744538445394454044541445424454344544445454454644547445484454944550445514455244553445544455544556445574455844559445604456144562445634456444565445664456744568445694457044571445724457344574445754457644577445784457944580445814458244583445844458544586445874458844589445904459144592445934459444595445964459744598445994460044601446024460344604446054460644607446084460944610446114461244613446144461544616446174461844619446204462144622446234462444625446264462744628446294463044631446324463344634446354463644637446384463944640446414464244643446444464544646446474464844649446504465144652446534465444655446564465744658446594466044661446624466344664446654466644667446684466944670446714467244673446744467544676446774467844679446804468144682446834468444685446864468744688446894469044691446924469344694446954469644697446984469944700447014470244703447044470544706447074470844709447104471144712447134471444715447164471744718447194472044721447224472344724447254472644727447284472944730447314473244733447344473544736447374473844739447404474144742447434474444745447464474744748447494475044751447524475344754447554475644757447584475944760447614476244763447644476544766447674476844769447704477144772447734477444775447764477744778447794478044781447824478344784447854478644787447884478944790447914479244793447944479544796447974479844799448004480144802448034480444805448064480744808448094481044811448124481344814448154481644817448184481944820448214482244823448244482544826448274482844829448304483144832448334483444835448364483744838448394484044841448424484344844448454484644847448484484944850448514485244853448544485544856448574485844859448604486144862448634486444865448664486744868448694487044871448724487344874448754487644877448784487944880448814488244883448844488544886448874488844889448904489144892448934489444895448964489744898448994490044901449024490344904449054490644907449084490944910449114491244913449144491544916449174491844919449204492144922449234492444925449264492744928449294493044931449324493344934449354493644937449384493944940449414494244943449444494544946449474494844949449504495144952449534495444955449564495744958449594496044961449624496344964449654496644967449684496944970449714497244973449744497544976449774497844979449804498144982449834498444985449864498744988449894499044991449924499344994449954499644997449984499945000450014500245003450044500545006450074500845009450104501145012450134501445015450164501745018450194502045021450224502345024450254502645027450284502945030450314503245033450344503545036450374503845039450404504145042450434504445045450464504745048450494505045051450524505345054450554505645057450584505945060450614506245063450644506545066450674506845069450704507145072450734507445075450764507745078450794508045081450824508345084450854508645087450884508945090450914509245093450944509545096450974509845099451004510145102451034510445105451064510745108451094511045111451124511345114451154511645117451184511945120451214512245123451244512545126451274512845129451304513145132451334513445135451364513745138451394514045141451424514345144451454514645147451484514945150451514515245153451544515545156451574515845159451604516145162451634516445165451664516745168451694517045171451724517345174451754517645177451784517945180451814518245183451844518545186451874518845189451904519145192451934519445195451964519745198451994520045201452024520345204452054520645207452084520945210452114521245213452144521545216452174521845219452204522145222452234522445225452264522745228452294523045231452324523345234452354523645237452384523945240452414524245243452444524545246452474524845249452504525145252452534525445255452564525745258452594526045261452624526345264452654526645267452684526945270452714527245273452744527545276452774527845279452804528145282452834528445285452864528745288452894529045291452924529345294452954529645297452984529945300453014530245303453044530545306453074530845309453104531145312453134531445315453164531745318453194532045321453224532345324453254532645327453284532945330453314533245333453344533545336453374533845339453404534145342453434534445345453464534745348453494535045351453524535345354453554535645357453584535945360453614536245363453644536545366453674536845369453704537145372453734537445375453764537745378453794538045381453824538345384453854538645387453884538945390453914539245393453944539545396453974539845399454004540145402454034540445405454064540745408454094541045411454124541345414454154541645417454184541945420454214542245423454244542545426454274542845429454304543145432454334543445435454364543745438454394544045441454424544345444454454544645447454484544945450454514545245453454544545545456454574545845459454604546145462454634546445465454664546745468454694547045471454724547345474454754547645477454784547945480454814548245483454844548545486454874548845489454904549145492454934549445495454964549745498454994550045501455024550345504455054550645507455084550945510455114551245513455144551545516455174551845519455204552145522455234552445525455264552745528455294553045531455324553345534455354553645537455384553945540455414554245543455444554545546455474554845549455504555145552455534555445555455564555745558455594556045561455624556345564455654556645567455684556945570455714557245573455744557545576455774557845579455804558145582455834558445585455864558745588455894559045591455924559345594455954559645597455984559945600456014560245603456044560545606456074560845609456104561145612456134561445615456164561745618456194562045621456224562345624456254562645627456284562945630456314563245633456344563545636456374563845639456404564145642456434564445645456464564745648456494565045651456524565345654456554565645657456584565945660456614566245663456644566545666456674566845669456704567145672456734567445675456764567745678456794568045681456824568345684456854568645687456884568945690456914569245693456944569545696456974569845699457004570145702457034570445705457064570745708457094571045711457124571345714457154571645717457184571945720457214572245723457244572545726457274572845729457304573145732457334573445735457364573745738457394574045741457424574345744457454574645747457484574945750457514575245753457544575545756457574575845759457604576145762457634576445765457664576745768457694577045771457724577345774457754577645777457784577945780457814578245783457844578545786457874578845789457904579145792457934579445795457964579745798457994580045801458024580345804458054580645807458084580945810458114581245813458144581545816458174581845819458204582145822458234582445825458264582745828458294583045831458324583345834458354583645837458384583945840458414584245843458444584545846458474584845849458504585145852458534585445855458564585745858458594586045861458624586345864458654586645867458684586945870458714587245873458744587545876458774587845879458804588145882458834588445885458864588745888458894589045891458924589345894458954589645897458984589945900459014590245903459044590545906459074590845909459104591145912459134591445915459164591745918459194592045921459224592345924459254592645927459284592945930459314593245933459344593545936459374593845939459404594145942459434594445945459464594745948459494595045951459524595345954459554595645957459584595945960459614596245963459644596545966459674596845969459704597145972459734597445975459764597745978459794598045981459824598345984459854598645987459884598945990459914599245993459944599545996459974599845999460004600146002460034600446005460064600746008460094601046011460124601346014460154601646017460184601946020460214602246023460244602546026460274602846029460304603146032460334603446035460364603746038460394604046041460424604346044460454604646047460484604946050460514605246053460544605546056460574605846059460604606146062460634606446065460664606746068460694607046071460724607346074460754607646077460784607946080460814608246083460844608546086460874608846089460904609146092460934609446095460964609746098460994610046101461024610346104461054610646107461084610946110461114611246113461144611546116461174611846119461204612146122461234612446125461264612746128461294613046131461324613346134461354613646137461384613946140461414614246143461444614546146461474614846149461504615146152461534615446155461564615746158461594616046161461624616346164461654616646167461684616946170461714617246173461744617546176461774617846179461804618146182461834618446185461864618746188461894619046191461924619346194461954619646197461984619946200462014620246203462044620546206462074620846209462104621146212462134621446215462164621746218462194622046221462224622346224462254622646227462284622946230462314623246233462344623546236462374623846239462404624146242462434624446245462464624746248462494625046251462524625346254462554625646257462584625946260462614626246263462644626546266462674626846269462704627146272462734627446275462764627746278462794628046281462824628346284462854628646287462884628946290462914629246293462944629546296462974629846299463004630146302463034630446305463064630746308463094631046311463124631346314463154631646317463184631946320463214632246323463244632546326463274632846329463304633146332463334633446335463364633746338463394634046341463424634346344463454634646347463484634946350463514635246353463544635546356463574635846359463604636146362463634636446365463664636746368463694637046371463724637346374463754637646377463784637946380463814638246383463844638546386463874638846389463904639146392463934639446395463964639746398463994640046401464024640346404464054640646407464084640946410464114641246413464144641546416464174641846419464204642146422464234642446425464264642746428464294643046431464324643346434464354643646437464384643946440464414644246443464444644546446464474644846449464504645146452464534645446455464564645746458464594646046461464624646346464464654646646467464684646946470464714647246473464744647546476464774647846479464804648146482464834648446485464864648746488464894649046491464924649346494464954649646497464984649946500465014650246503465044650546506465074650846509465104651146512465134651446515465164651746518465194652046521465224652346524465254652646527465284652946530465314653246533465344653546536465374653846539465404654146542465434654446545465464654746548465494655046551465524655346554465554655646557465584655946560465614656246563465644656546566465674656846569465704657146572465734657446575465764657746578465794658046581465824658346584465854658646587465884658946590465914659246593465944659546596465974659846599466004660146602466034660446605466064660746608466094661046611466124661346614466154661646617466184661946620466214662246623466244662546626466274662846629466304663146632466334663446635466364663746638466394664046641466424664346644466454664646647466484664946650466514665246653466544665546656466574665846659466604666146662466634666446665466664666746668466694667046671466724667346674466754667646677466784667946680466814668246683466844668546686466874668846689466904669146692466934669446695466964669746698466994670046701467024670346704467054670646707467084670946710467114671246713467144671546716467174671846719467204672146722467234672446725467264672746728467294673046731467324673346734467354673646737467384673946740467414674246743467444674546746467474674846749467504675146752467534675446755467564675746758467594676046761467624676346764467654676646767467684676946770467714677246773467744677546776467774677846779467804678146782467834678446785467864678746788467894679046791467924679346794467954679646797467984679946800468014680246803468044680546806468074680846809468104681146812468134681446815468164681746818468194682046821468224682346824468254682646827468284682946830468314683246833468344683546836468374683846839468404684146842468434684446845468464684746848468494685046851468524685346854468554685646857468584685946860468614686246863468644686546866468674686846869468704687146872468734687446875468764687746878468794688046881468824688346884468854688646887468884688946890468914689246893468944689546896468974689846899469004690146902469034690446905469064690746908469094691046911469124691346914469154691646917469184691946920469214692246923469244692546926469274692846929469304693146932469334693446935469364693746938469394694046941469424694346944469454694646947469484694946950469514695246953469544695546956469574695846959469604696146962469634696446965469664696746968469694697046971469724697346974469754697646977469784697946980469814698246983469844698546986469874698846989469904699146992469934699446995469964699746998469994700047001470024700347004470054700647007470084700947010470114701247013470144701547016470174701847019470204702147022470234702447025470264702747028470294703047031470324703347034470354703647037470384703947040470414704247043470444704547046470474704847049470504705147052470534705447055470564705747058470594706047061470624706347064470654706647067470684706947070470714707247073470744707547076470774707847079470804708147082470834708447085470864708747088470894709047091470924709347094470954709647097470984709947100471014710247103471044710547106471074710847109471104711147112471134711447115471164711747118471194712047121471224712347124471254712647127471284712947130471314713247133471344713547136471374713847139471404714147142471434714447145471464714747148471494715047151471524715347154471554715647157471584715947160471614716247163471644716547166471674716847169471704717147172471734717447175471764717747178471794718047181471824718347184471854718647187471884718947190471914719247193471944719547196471974719847199472004720147202472034720447205472064720747208472094721047211472124721347214472154721647217472184721947220472214722247223472244722547226472274722847229472304723147232472334723447235472364723747238472394724047241472424724347244472454724647247472484724947250472514725247253472544725547256472574725847259472604726147262472634726447265472664726747268472694727047271472724727347274472754727647277472784727947280472814728247283472844728547286472874728847289472904729147292472934729447295472964729747298472994730047301473024730347304473054730647307473084730947310473114731247313473144731547316473174731847319473204732147322473234732447325473264732747328473294733047331473324733347334473354733647337473384733947340473414734247343473444734547346473474734847349473504735147352473534735447355473564735747358473594736047361473624736347364473654736647367473684736947370473714737247373473744737547376473774737847379473804738147382473834738447385473864738747388473894739047391473924739347394473954739647397473984739947400474014740247403474044740547406474074740847409474104741147412474134741447415474164741747418474194742047421474224742347424474254742647427474284742947430474314743247433474344743547436474374743847439474404744147442474434744447445474464744747448474494745047451474524745347454474554745647457474584745947460474614746247463474644746547466474674746847469474704747147472474734747447475474764747747478474794748047481474824748347484474854748647487474884748947490474914749247493474944749547496474974749847499475004750147502475034750447505475064750747508475094751047511475124751347514475154751647517475184751947520475214752247523475244752547526475274752847529475304753147532475334753447535475364753747538475394754047541475424754347544475454754647547475484754947550475514755247553475544755547556475574755847559475604756147562475634756447565475664756747568475694757047571475724757347574475754757647577475784757947580475814758247583475844758547586475874758847589475904759147592475934759447595475964759747598475994760047601476024760347604476054760647607476084760947610476114761247613476144761547616476174761847619476204762147622476234762447625476264762747628476294763047631476324763347634476354763647637476384763947640476414764247643476444764547646476474764847649476504765147652476534765447655476564765747658476594766047661476624766347664476654766647667476684766947670476714767247673476744767547676476774767847679476804768147682476834768447685476864768747688476894769047691476924769347694476954769647697476984769947700477014770247703477044770547706477074770847709477104771147712477134771447715477164771747718477194772047721477224772347724477254772647727477284772947730477314773247733477344773547736477374773847739477404774147742477434774447745477464774747748477494775047751477524775347754477554775647757477584775947760477614776247763477644776547766477674776847769477704777147772477734777447775477764777747778477794778047781477824778347784477854778647787477884778947790477914779247793477944779547796477974779847799478004780147802478034780447805478064780747808478094781047811478124781347814478154781647817478184781947820478214782247823478244782547826478274782847829478304783147832478334783447835478364783747838478394784047841478424784347844478454784647847478484784947850478514785247853478544785547856478574785847859478604786147862478634786447865478664786747868478694787047871478724787347874478754787647877478784787947880478814788247883478844788547886478874788847889478904789147892478934789447895478964789747898478994790047901479024790347904479054790647907479084790947910479114791247913479144791547916479174791847919479204792147922479234792447925479264792747928479294793047931479324793347934479354793647937479384793947940479414794247943479444794547946479474794847949479504795147952479534795447955479564795747958479594796047961479624796347964479654796647967479684796947970479714797247973479744797547976479774797847979479804798147982479834798447985479864798747988479894799047991479924799347994479954799647997479984799948000480014800248003480044800548006480074800848009480104801148012480134801448015480164801748018480194802048021480224802348024480254802648027480284802948030480314803248033480344803548036480374803848039480404804148042480434804448045480464804748048480494805048051480524805348054480554805648057480584805948060480614806248063480644806548066480674806848069480704807148072480734807448075480764807748078480794808048081480824808348084480854808648087480884808948090480914809248093480944809548096480974809848099481004810148102481034810448105481064810748108481094811048111481124811348114481154811648117481184811948120481214812248123481244812548126481274812848129481304813148132481334813448135481364813748138481394814048141481424814348144481454814648147481484814948150481514815248153481544815548156481574815848159481604816148162481634816448165481664816748168481694817048171481724817348174481754817648177481784817948180481814818248183481844818548186481874818848189481904819148192481934819448195481964819748198481994820048201482024820348204482054820648207482084820948210482114821248213482144821548216482174821848219482204822148222482234822448225482264822748228482294823048231482324823348234482354823648237482384823948240482414824248243482444824548246482474824848249482504825148252482534825448255482564825748258482594826048261482624826348264482654826648267482684826948270482714827248273482744827548276482774827848279482804828148282482834828448285482864828748288482894829048291482924829348294482954829648297482984829948300483014830248303483044830548306483074830848309483104831148312483134831448315483164831748318483194832048321483224832348324483254832648327483284832948330483314833248333483344833548336483374833848339483404834148342483434834448345483464834748348483494835048351483524835348354483554835648357483584835948360483614836248363483644836548366483674836848369483704837148372483734837448375483764837748378483794838048381483824838348384483854838648387483884838948390483914839248393483944839548396483974839848399484004840148402484034840448405484064840748408484094841048411484124841348414484154841648417484184841948420484214842248423484244842548426484274842848429484304843148432484334843448435484364843748438484394844048441484424844348444484454844648447484484844948450484514845248453484544845548456484574845848459484604846148462484634846448465484664846748468484694847048471484724847348474484754847648477484784847948480484814848248483484844848548486484874848848489484904849148492484934849448495484964849748498484994850048501485024850348504485054850648507485084850948510485114851248513485144851548516485174851848519485204852148522485234852448525485264852748528485294853048531485324853348534485354853648537485384853948540485414854248543485444854548546485474854848549485504855148552485534855448555485564855748558485594856048561485624856348564485654856648567485684856948570485714857248573485744857548576485774857848579485804858148582485834858448585485864858748588485894859048591485924859348594485954859648597485984859948600486014860248603486044860548606486074860848609486104861148612486134861448615486164861748618486194862048621486224862348624486254862648627486284862948630486314863248633486344863548636486374863848639486404864148642486434864448645486464864748648486494865048651486524865348654486554865648657486584865948660486614866248663486644866548666486674866848669486704867148672486734867448675486764867748678486794868048681486824868348684486854868648687486884868948690486914869248693486944869548696486974869848699487004870148702487034870448705487064870748708487094871048711487124871348714487154871648717487184871948720487214872248723487244872548726487274872848729487304873148732487334873448735487364873748738487394874048741487424874348744487454874648747487484874948750487514875248753487544875548756487574875848759487604876148762487634876448765487664876748768487694877048771487724877348774487754877648777487784877948780487814878248783487844878548786487874878848789487904879148792487934879448795487964879748798487994880048801488024880348804488054880648807488084880948810488114881248813488144881548816488174881848819488204882148822488234882448825488264882748828488294883048831488324883348834488354883648837488384883948840488414884248843488444884548846488474884848849488504885148852488534885448855488564885748858488594886048861488624886348864488654886648867488684886948870488714887248873488744887548876488774887848879488804888148882488834888448885488864888748888488894889048891488924889348894488954889648897488984889948900489014890248903489044890548906489074890848909489104891148912489134891448915489164891748918489194892048921489224892348924489254892648927489284892948930489314893248933489344893548936489374893848939489404894148942489434894448945489464894748948489494895048951489524895348954489554895648957489584895948960489614896248963489644896548966489674896848969489704897148972489734897448975489764897748978489794898048981489824898348984489854898648987489884898948990489914899248993489944899548996489974899848999490004900149002490034900449005490064900749008490094901049011490124901349014490154901649017490184901949020490214902249023490244902549026490274902849029490304903149032490334903449035490364903749038490394904049041490424904349044490454904649047490484904949050490514905249053490544905549056490574905849059490604906149062490634906449065490664906749068490694907049071490724907349074490754907649077490784907949080490814908249083490844908549086490874908849089490904909149092490934909449095490964909749098490994910049101491024910349104491054910649107491084910949110491114911249113491144911549116491174911849119491204912149122491234912449125491264912749128491294913049131491324913349134491354913649137491384913949140491414914249143491444914549146491474914849149491504915149152491534915449155491564915749158491594916049161491624916349164491654916649167491684916949170491714917249173491744917549176491774917849179491804918149182491834918449185491864918749188491894919049191491924919349194491954919649197491984919949200492014920249203492044920549206492074920849209492104921149212492134921449215492164921749218492194922049221492224922349224492254922649227492284922949230492314923249233492344923549236492374923849239492404924149242492434924449245492464924749248492494925049251492524925349254492554925649257492584925949260492614926249263492644926549266492674926849269492704927149272492734927449275492764927749278492794928049281492824928349284492854928649287492884928949290492914929249293492944929549296492974929849299493004930149302493034930449305493064930749308493094931049311493124931349314493154931649317493184931949320493214932249323493244932549326493274932849329493304933149332493334933449335493364933749338493394934049341493424934349344493454934649347493484934949350493514935249353493544935549356493574935849359493604936149362493634936449365493664936749368493694937049371493724937349374493754937649377493784937949380493814938249383493844938549386493874938849389493904939149392493934939449395493964939749398493994940049401494024940349404494054940649407494084940949410494114941249413494144941549416494174941849419494204942149422494234942449425494264942749428494294943049431494324943349434494354943649437494384943949440494414944249443494444944549446494474944849449494504945149452494534945449455494564945749458494594946049461494624946349464494654946649467494684946949470494714947249473494744947549476494774947849479494804948149482494834948449485494864948749488494894949049491494924949349494494954949649497494984949949500495014950249503495044950549506495074950849509495104951149512495134951449515495164951749518495194952049521495224952349524495254952649527495284952949530495314953249533495344953549536495374953849539495404954149542495434954449545495464954749548495494955049551495524955349554495554955649557495584955949560495614956249563495644956549566495674956849569495704957149572495734957449575495764957749578495794958049581495824958349584495854958649587495884958949590495914959249593495944959549596495974959849599496004960149602496034960449605496064960749608496094961049611496124961349614496154961649617496184961949620496214962249623496244962549626496274962849629496304963149632496334963449635496364963749638496394964049641496424964349644496454964649647496484964949650496514965249653496544965549656496574965849659496604966149662496634966449665496664966749668496694967049671496724967349674496754967649677496784967949680496814968249683496844968549686496874968849689496904969149692496934969449695496964969749698496994970049701497024970349704497054970649707497084970949710497114971249713497144971549716497174971849719497204972149722497234972449725497264972749728497294973049731497324973349734497354973649737497384973949740497414974249743497444974549746497474974849749497504975149752497534975449755497564975749758497594976049761497624976349764497654976649767497684976949770497714977249773497744977549776497774977849779497804978149782497834978449785497864978749788497894979049791497924979349794497954979649797497984979949800498014980249803498044980549806498074980849809498104981149812498134981449815498164981749818498194982049821498224982349824498254982649827498284982949830498314983249833498344983549836498374983849839498404984149842498434984449845498464984749848498494985049851498524985349854498554985649857498584985949860498614986249863498644986549866498674986849869498704987149872498734987449875498764987749878498794988049881498824988349884498854988649887498884988949890498914989249893498944989549896498974989849899499004990149902499034990449905499064990749908499094991049911499124991349914499154991649917499184991949920499214992249923499244992549926499274992849929499304993149932499334993449935499364993749938499394994049941499424994349944499454994649947499484994949950499514995249953499544995549956499574995849959499604996149962499634996449965499664996749968499694997049971499724997349974499754997649977499784997949980499814998249983499844998549986499874998849989499904999149992499934999449995499964999749998499995000050001500025000350004500055000650007500085000950010500115001250013500145001550016500175001850019500205002150022500235002450025500265002750028500295003050031500325003350034500355003650037500385003950040500415004250043500445004550046500475004850049500505005150052500535005450055500565005750058500595006050061500625006350064500655006650067500685006950070500715007250073500745007550076500775007850079500805008150082500835008450085500865008750088500895009050091500925009350094500955009650097500985009950100501015010250103501045010550106501075010850109501105011150112501135011450115501165011750118501195012050121501225012350124501255012650127501285012950130501315013250133501345013550136501375013850139501405014150142501435014450145501465014750148501495015050151501525015350154501555015650157501585015950160501615016250163501645016550166501675016850169501705017150172501735017450175501765017750178501795018050181501825018350184501855018650187501885018950190501915019250193501945019550196501975019850199502005020150202502035020450205502065020750208502095021050211502125021350214502155021650217502185021950220502215022250223502245022550226502275022850229502305023150232502335023450235502365023750238502395024050241502425024350244502455024650247502485024950250502515025250253502545025550256502575025850259502605026150262502635026450265502665026750268502695027050271502725027350274502755027650277502785027950280502815028250283502845028550286502875028850289502905029150292502935029450295502965029750298502995030050301503025030350304503055030650307503085030950310503115031250313503145031550316503175031850319503205032150322503235032450325503265032750328503295033050331503325033350334503355033650337503385033950340503415034250343503445034550346503475034850349503505035150352503535035450355503565035750358503595036050361503625036350364503655036650367503685036950370503715037250373503745037550376503775037850379503805038150382503835038450385503865038750388503895039050391503925039350394503955039650397503985039950400504015040250403504045040550406504075040850409504105041150412504135041450415504165041750418504195042050421504225042350424504255042650427504285042950430504315043250433504345043550436504375043850439504405044150442504435044450445504465044750448504495045050451504525045350454504555045650457504585045950460504615046250463504645046550466504675046850469504705047150472504735047450475504765047750478504795048050481504825048350484504855048650487504885048950490504915049250493504945049550496504975049850499505005050150502505035050450505505065050750508505095051050511505125051350514505155051650517505185051950520505215052250523505245052550526505275052850529505305053150532505335053450535505365053750538505395054050541505425054350544505455054650547505485054950550505515055250553505545055550556505575055850559505605056150562505635056450565505665056750568505695057050571505725057350574505755057650577505785057950580505815058250583505845058550586505875058850589505905059150592505935059450595505965059750598505995060050601506025060350604506055060650607506085060950610506115061250613506145061550616506175061850619506205062150622506235062450625506265062750628506295063050631506325063350634506355063650637506385063950640506415064250643506445064550646506475064850649506505065150652506535065450655506565065750658506595066050661506625066350664506655066650667506685066950670506715067250673506745067550676506775067850679506805068150682506835068450685506865068750688506895069050691506925069350694506955069650697506985069950700507015070250703507045070550706507075070850709507105071150712507135071450715507165071750718507195072050721507225072350724507255072650727507285072950730507315073250733507345073550736507375073850739507405074150742507435074450745507465074750748507495075050751507525075350754507555075650757507585075950760507615076250763507645076550766507675076850769507705077150772507735077450775507765077750778507795078050781507825078350784507855078650787507885078950790507915079250793507945079550796507975079850799508005080150802508035080450805508065080750808508095081050811508125081350814508155081650817508185081950820508215082250823508245082550826508275082850829508305083150832508335083450835508365083750838508395084050841508425084350844508455084650847508485084950850508515085250853508545085550856508575085850859508605086150862508635086450865508665086750868508695087050871508725087350874508755087650877508785087950880508815088250883508845088550886508875088850889508905089150892508935089450895508965089750898508995090050901509025090350904509055090650907509085090950910509115091250913509145091550916509175091850919509205092150922509235092450925509265092750928509295093050931509325093350934509355093650937509385093950940509415094250943509445094550946509475094850949509505095150952509535095450955509565095750958509595096050961509625096350964509655096650967509685096950970509715097250973509745097550976509775097850979509805098150982509835098450985509865098750988509895099050991509925099350994509955099650997509985099951000510015100251003510045100551006510075100851009510105101151012510135101451015510165101751018510195102051021510225102351024510255102651027510285102951030510315103251033510345103551036510375103851039510405104151042510435104451045510465104751048510495105051051510525105351054510555105651057510585105951060510615106251063510645106551066510675106851069510705107151072510735107451075510765107751078510795108051081510825108351084510855108651087510885108951090510915109251093510945109551096510975109851099511005110151102511035110451105511065110751108511095111051111511125111351114511155111651117511185111951120511215112251123511245112551126511275112851129511305113151132511335113451135511365113751138511395114051141511425114351144511455114651147511485114951150511515115251153511545115551156511575115851159511605116151162511635116451165511665116751168511695117051171511725117351174511755117651177511785117951180511815118251183511845118551186511875118851189511905119151192511935119451195511965119751198511995120051201512025120351204512055120651207512085120951210512115121251213512145121551216512175121851219512205122151222512235122451225512265122751228512295123051231512325123351234512355123651237512385123951240512415124251243512445124551246512475124851249512505125151252512535125451255512565125751258512595126051261512625126351264512655126651267512685126951270512715127251273512745127551276512775127851279512805128151282512835128451285512865128751288512895129051291512925129351294512955129651297512985129951300513015130251303513045130551306513075130851309513105131151312513135131451315513165131751318513195132051321513225132351324513255132651327513285132951330513315133251333513345133551336513375133851339513405134151342513435134451345513465134751348513495135051351513525135351354513555135651357513585135951360513615136251363513645136551366513675136851369513705137151372513735137451375513765137751378513795138051381513825138351384513855138651387513885138951390513915139251393513945139551396513975139851399514005140151402514035140451405514065140751408514095141051411514125141351414514155141651417514185141951420514215142251423514245142551426514275142851429514305143151432514335143451435514365143751438514395144051441514425144351444514455144651447514485144951450514515145251453514545145551456514575145851459514605146151462514635146451465514665146751468514695147051471514725147351474514755147651477514785147951480514815148251483514845148551486514875148851489514905149151492514935149451495514965149751498514995150051501515025150351504515055150651507515085150951510515115151251513515145151551516515175151851519515205152151522515235152451525515265152751528515295153051531515325153351534515355153651537515385153951540515415154251543515445154551546515475154851549515505155151552515535155451555515565155751558515595156051561515625156351564515655156651567515685156951570515715157251573515745157551576515775157851579515805158151582515835158451585515865158751588515895159051591515925159351594515955159651597515985159951600516015160251603516045160551606516075160851609516105161151612516135161451615516165161751618516195162051621516225162351624516255162651627516285162951630516315163251633516345163551636516375163851639516405164151642516435164451645516465164751648516495165051651516525165351654516555165651657516585165951660516615166251663516645166551666516675166851669516705167151672516735167451675516765167751678516795168051681516825168351684516855168651687516885168951690516915169251693516945169551696516975169851699517005170151702517035170451705517065170751708517095171051711517125171351714517155171651717517185171951720517215172251723517245172551726517275172851729517305173151732517335173451735517365173751738517395174051741517425174351744517455174651747517485174951750517515175251753517545175551756517575175851759517605176151762517635176451765517665176751768517695177051771517725177351774517755177651777517785177951780517815178251783517845178551786517875178851789517905179151792517935179451795517965179751798517995180051801518025180351804518055180651807518085180951810518115181251813518145181551816518175181851819518205182151822518235182451825518265182751828518295183051831518325183351834518355183651837518385183951840518415184251843518445184551846518475184851849518505185151852518535185451855518565185751858518595186051861518625186351864518655186651867518685186951870518715187251873518745187551876518775187851879518805188151882518835188451885518865188751888518895189051891518925189351894518955189651897518985189951900519015190251903519045190551906519075190851909519105191151912519135191451915519165191751918519195192051921519225192351924519255192651927519285192951930519315193251933519345193551936519375193851939519405194151942519435194451945519465194751948519495195051951519525195351954519555195651957519585195951960519615196251963519645196551966519675196851969519705197151972519735197451975519765197751978519795198051981519825198351984519855198651987519885198951990519915199251993519945199551996519975199851999520005200152002520035200452005520065200752008520095201052011520125201352014520155201652017520185201952020520215202252023520245202552026520275202852029520305203152032520335203452035520365203752038520395204052041520425204352044520455204652047520485204952050520515205252053520545205552056520575205852059520605206152062520635206452065520665206752068520695207052071520725207352074520755207652077520785207952080520815208252083520845208552086520875208852089520905209152092520935209452095520965209752098520995210052101521025210352104521055210652107521085210952110521115211252113521145211552116521175211852119521205212152122521235212452125521265212752128521295213052131521325213352134521355213652137521385213952140521415214252143521445214552146521475214852149521505215152152521535215452155521565215752158521595216052161521625216352164521655216652167521685216952170521715217252173521745217552176521775217852179521805218152182521835218452185521865218752188521895219052191521925219352194521955219652197521985219952200522015220252203522045220552206522075220852209522105221152212522135221452215522165221752218522195222052221522225222352224522255222652227522285222952230522315223252233522345223552236522375223852239522405224152242522435224452245522465224752248522495225052251522525225352254522555225652257522585225952260522615226252263522645226552266522675226852269522705227152272522735227452275522765227752278522795228052281522825228352284522855228652287522885228952290522915229252293522945229552296522975229852299523005230152302523035230452305523065230752308523095231052311523125231352314523155231652317523185231952320523215232252323523245232552326523275232852329523305233152332523335233452335523365233752338523395234052341523425234352344523455234652347523485234952350523515235252353523545235552356523575235852359523605236152362523635236452365523665236752368523695237052371523725237352374523755237652377523785237952380523815238252383523845238552386523875238852389523905239152392523935239452395523965239752398523995240052401524025240352404524055240652407524085240952410524115241252413524145241552416524175241852419524205242152422524235242452425524265242752428524295243052431524325243352434524355243652437524385243952440524415244252443524445244552446524475244852449524505245152452524535245452455524565245752458524595246052461524625246352464524655246652467524685246952470524715247252473524745247552476524775247852479524805248152482524835248452485524865248752488524895249052491524925249352494524955249652497524985249952500525015250252503525045250552506525075250852509525105251152512525135251452515525165251752518525195252052521525225252352524525255252652527525285252952530525315253252533525345253552536525375253852539525405254152542525435254452545525465254752548525495255052551525525255352554525555255652557525585255952560525615256252563525645256552566525675256852569525705257152572525735257452575525765257752578525795258052581525825258352584525855258652587525885258952590525915259252593525945259552596525975259852599526005260152602526035260452605526065260752608526095261052611526125261352614526155261652617526185261952620526215262252623526245262552626526275262852629526305263152632526335263452635526365263752638526395264052641526425264352644526455264652647526485264952650526515265252653526545265552656526575265852659526605266152662526635266452665526665266752668526695267052671526725267352674526755267652677526785267952680526815268252683526845268552686526875268852689526905269152692526935269452695526965269752698526995270052701527025270352704527055270652707527085270952710527115271252713527145271552716527175271852719527205272152722527235272452725527265272752728527295273052731527325273352734527355273652737527385273952740527415274252743527445274552746527475274852749527505275152752527535275452755527565275752758527595276052761527625276352764527655276652767527685276952770527715277252773527745277552776527775277852779527805278152782527835278452785527865278752788527895279052791527925279352794527955279652797527985279952800528015280252803528045280552806528075280852809528105281152812528135281452815528165281752818528195282052821528225282352824528255282652827528285282952830528315283252833528345283552836528375283852839528405284152842528435284452845528465284752848528495285052851528525285352854528555285652857528585285952860528615286252863528645286552866528675286852869528705287152872528735287452875528765287752878528795288052881528825288352884528855288652887528885288952890528915289252893528945289552896528975289852899529005290152902529035290452905529065290752908529095291052911529125291352914529155291652917529185291952920529215292252923529245292552926529275292852929529305293152932529335293452935529365293752938529395294052941529425294352944529455294652947529485294952950529515295252953529545295552956529575295852959529605296152962529635296452965529665296752968529695297052971529725297352974529755297652977529785297952980529815298252983529845298552986529875298852989529905299152992529935299452995529965299752998529995300053001530025300353004530055300653007530085300953010530115301253013530145301553016530175301853019530205302153022530235302453025530265302753028530295303053031530325303353034530355303653037530385303953040530415304253043530445304553046530475304853049530505305153052530535305453055530565305753058530595306053061530625306353064530655306653067530685306953070530715307253073530745307553076530775307853079530805308153082530835308453085530865308753088530895309053091530925309353094530955309653097530985309953100531015310253103531045310553106531075310853109531105311153112531135311453115531165311753118531195312053121531225312353124531255312653127531285312953130531315313253133531345313553136531375313853139531405314153142531435314453145531465314753148531495315053151531525315353154531555315653157531585315953160531615316253163531645316553166531675316853169531705317153172531735317453175531765317753178531795318053181531825318353184531855318653187531885318953190531915319253193531945319553196531975319853199532005320153202532035320453205532065320753208532095321053211532125321353214532155321653217532185321953220532215322253223532245322553226532275322853229532305323153232532335323453235532365323753238532395324053241532425324353244532455324653247532485324953250532515325253253532545325553256532575325853259532605326153262532635326453265532665326753268532695327053271532725327353274532755327653277532785327953280532815328253283532845328553286532875328853289532905329153292532935329453295532965329753298532995330053301533025330353304533055330653307533085330953310533115331253313533145331553316533175331853319533205332153322533235332453325533265332753328533295333053331533325333353334533355333653337533385333953340533415334253343533445334553346533475334853349533505335153352533535335453355533565335753358533595336053361533625336353364533655336653367533685336953370533715337253373533745337553376533775337853379533805338153382533835338453385533865338753388533895339053391533925339353394533955339653397533985339953400534015340253403534045340553406534075340853409534105341153412534135341453415534165341753418534195342053421534225342353424534255342653427534285342953430534315343253433534345343553436534375343853439534405344153442534435344453445534465344753448534495345053451534525345353454534555345653457534585345953460534615346253463534645346553466534675346853469534705347153472534735347453475534765347753478534795348053481534825348353484534855348653487534885348953490534915349253493534945349553496534975349853499535005350153502535035350453505535065350753508535095351053511535125351353514535155351653517535185351953520535215352253523535245352553526535275352853529535305353153532535335353453535535365353753538535395354053541535425354353544535455354653547535485354953550535515355253553535545355553556535575355853559535605356153562535635356453565535665356753568535695357053571535725357353574535755357653577535785357953580535815358253583535845358553586535875358853589535905359153592535935359453595535965359753598535995360053601536025360353604536055360653607536085360953610536115361253613536145361553616536175361853619536205362153622536235362453625536265362753628536295363053631536325363353634536355363653637536385363953640536415364253643536445364553646536475364853649536505365153652536535365453655536565365753658536595366053661536625366353664536655366653667536685366953670536715367253673536745367553676536775367853679536805368153682536835368453685536865368753688536895369053691536925369353694536955369653697536985369953700537015370253703537045370553706537075370853709537105371153712537135371453715537165371753718537195372053721537225372353724537255372653727537285372953730537315373253733537345373553736537375373853739537405374153742537435374453745537465374753748537495375053751537525375353754537555375653757537585375953760537615376253763537645376553766537675376853769537705377153772537735377453775537765377753778537795378053781537825378353784537855378653787537885378953790537915379253793537945379553796537975379853799538005380153802538035380453805538065380753808538095381053811538125381353814538155381653817538185381953820538215382253823538245382553826538275382853829538305383153832538335383453835538365383753838538395384053841538425384353844538455384653847538485384953850538515385253853538545385553856538575385853859538605386153862538635386453865538665386753868538695387053871538725387353874538755387653877538785387953880538815388253883538845388553886538875388853889538905389153892538935389453895538965389753898538995390053901539025390353904539055390653907539085390953910539115391253913539145391553916539175391853919539205392153922539235392453925539265392753928539295393053931539325393353934539355393653937539385393953940539415394253943539445394553946539475394853949539505395153952539535395453955539565395753958539595396053961539625396353964539655396653967539685396953970539715397253973539745397553976539775397853979539805398153982539835398453985539865398753988539895399053991539925399353994539955399653997539985399954000540015400254003540045400554006540075400854009540105401154012540135401454015540165401754018540195402054021540225402354024540255402654027540285402954030540315403254033540345403554036540375403854039540405404154042540435404454045540465404754048540495405054051540525405354054540555405654057540585405954060540615406254063540645406554066540675406854069540705407154072540735407454075540765407754078540795408054081540825408354084540855408654087540885408954090540915409254093540945409554096540975409854099541005410154102541035410454105541065410754108541095411054111541125411354114541155411654117541185411954120541215412254123541245412554126541275412854129541305413154132541335413454135541365413754138541395414054141541425414354144541455414654147541485414954150541515415254153541545415554156541575415854159541605416154162541635416454165541665416754168541695417054171541725417354174541755417654177541785417954180541815418254183541845418554186541875418854189541905419154192541935419454195541965419754198541995420054201542025420354204542055420654207542085420954210542115421254213542145421554216542175421854219542205422154222542235422454225542265422754228542295423054231542325423354234542355423654237542385423954240542415424254243542445424554246542475424854249542505425154252542535425454255542565425754258542595426054261542625426354264542655426654267542685426954270542715427254273542745427554276542775427854279542805428154282542835428454285542865428754288542895429054291542925429354294542955429654297542985429954300543015430254303543045430554306543075430854309543105431154312543135431454315543165431754318543195432054321543225432354324543255432654327543285432954330543315433254333543345433554336543375433854339543405434154342543435434454345543465434754348543495435054351543525435354354543555435654357543585435954360543615436254363543645436554366543675436854369543705437154372543735437454375543765437754378543795438054381543825438354384543855438654387543885438954390543915439254393543945439554396543975439854399544005440154402544035440454405544065440754408544095441054411544125441354414544155441654417544185441954420544215442254423544245442554426544275442854429544305443154432544335443454435544365443754438544395444054441544425444354444544455444654447544485444954450544515445254453544545445554456544575445854459544605446154462544635446454465544665446754468544695447054471544725447354474544755447654477544785447954480544815448254483544845448554486544875448854489544905449154492544935449454495544965449754498544995450054501545025450354504545055450654507545085450954510545115451254513545145451554516545175451854519545205452154522545235452454525545265452754528545295453054531545325453354534545355453654537545385453954540545415454254543545445454554546545475454854549545505455154552545535455454555545565455754558545595456054561545625456354564545655456654567545685456954570545715457254573545745457554576545775457854579545805458154582545835458454585545865458754588545895459054591545925459354594545955459654597545985459954600546015460254603546045460554606546075460854609546105461154612546135461454615546165461754618546195462054621546225462354624546255462654627546285462954630546315463254633546345463554636546375463854639546405464154642546435464454645546465464754648546495465054651546525465354654546555465654657546585465954660546615466254663546645466554666546675466854669546705467154672546735467454675546765467754678546795468054681546825468354684546855468654687546885468954690546915469254693546945469554696546975469854699547005470154702547035470454705547065470754708547095471054711547125471354714547155471654717547185471954720547215472254723547245472554726547275472854729547305473154732547335473454735547365473754738547395474054741547425474354744547455474654747547485474954750547515475254753547545475554756547575475854759547605476154762547635476454765547665476754768547695477054771547725477354774547755477654777547785477954780547815478254783547845478554786547875478854789547905479154792547935479454795547965479754798547995480054801548025480354804548055480654807548085480954810548115481254813548145481554816548175481854819548205482154822548235482454825548265482754828548295483054831548325483354834548355483654837548385483954840548415484254843548445484554846548475484854849548505485154852548535485454855548565485754858548595486054861548625486354864548655486654867548685486954870548715487254873548745487554876548775487854879548805488154882548835488454885548865488754888548895489054891548925489354894548955489654897548985489954900549015490254903549045490554906549075490854909549105491154912549135491454915549165491754918549195492054921549225492354924549255492654927549285492954930549315493254933549345493554936549375493854939549405494154942549435494454945549465494754948549495495054951549525495354954549555495654957549585495954960549615496254963549645496554966549675496854969549705497154972549735497454975549765497754978549795498054981549825498354984549855498654987549885498954990549915499254993549945499554996549975499854999550005500155002550035500455005550065500755008550095501055011550125501355014550155501655017550185501955020550215502255023550245502555026550275502855029550305503155032550335503455035550365503755038550395504055041550425504355044550455504655047550485504955050550515505255053550545505555056550575505855059550605506155062550635506455065550665506755068550695507055071550725507355074550755507655077550785507955080550815508255083550845508555086550875508855089550905509155092550935509455095550965509755098550995510055101551025510355104551055510655107551085510955110551115511255113551145511555116551175511855119551205512155122551235512455125551265512755128551295513055131551325513355134551355513655137551385513955140551415514255143551445514555146551475514855149551505515155152551535515455155551565515755158551595516055161551625516355164551655516655167551685516955170551715517255173551745517555176551775517855179551805518155182551835518455185551865518755188551895519055191551925519355194551955519655197551985519955200552015520255203552045520555206552075520855209552105521155212552135521455215552165521755218552195522055221552225522355224552255522655227552285522955230552315523255233552345523555236552375523855239552405524155242552435524455245552465524755248552495525055251552525525355254552555525655257552585525955260552615526255263552645526555266552675526855269552705527155272552735527455275552765527755278552795528055281552825528355284552855528655287552885528955290552915529255293552945529555296552975529855299553005530155302553035530455305553065530755308553095531055311553125531355314553155531655317553185531955320553215532255323553245532555326553275532855329553305533155332553335533455335553365533755338553395534055341553425534355344553455534655347553485534955350553515535255353553545535555356553575535855359553605536155362553635536455365553665536755368553695537055371553725537355374553755537655377553785537955380553815538255383553845538555386553875538855389553905539155392553935539455395553965539755398553995540055401554025540355404554055540655407554085540955410554115541255413554145541555416554175541855419554205542155422554235542455425554265542755428554295543055431554325543355434554355543655437554385543955440554415544255443554445544555446554475544855449554505545155452554535545455455554565545755458554595546055461554625546355464554655546655467554685546955470554715547255473554745547555476554775547855479554805548155482554835548455485554865548755488554895549055491554925549355494554955549655497554985549955500555015550255503555045550555506555075550855509555105551155512555135551455515555165551755518555195552055521555225552355524555255552655527555285552955530555315553255533555345553555536555375553855539555405554155542555435554455545555465554755548555495555055551555525555355554555555555655557555585555955560555615556255563555645556555566555675556855569555705557155572555735557455575555765557755578555795558055581555825558355584555855558655587555885558955590555915559255593555945559555596555975559855599556005560155602556035560455605556065560755608556095561055611556125561355614556155561655617556185561955620556215562255623556245562555626556275562855629556305563155632556335563455635556365563755638556395564055641556425564355644556455564655647556485564955650556515565255653556545565555656556575565855659556605566155662556635566455665556665566755668556695567055671556725567355674556755567655677556785567955680556815568255683556845568555686556875568855689556905569155692556935569455695556965569755698556995570055701557025570355704557055570655707557085570955710557115571255713557145571555716557175571855719557205572155722557235572455725557265572755728557295573055731557325573355734557355573655737557385573955740557415574255743557445574555746557475574855749557505575155752557535575455755557565575755758557595576055761557625576355764557655576655767557685576955770557715577255773557745577555776557775577855779557805578155782557835578455785557865578755788557895579055791557925579355794557955579655797557985579955800558015580255803558045580555806558075580855809558105581155812558135581455815558165581755818558195582055821558225582355824558255582655827558285582955830558315583255833558345583555836558375583855839558405584155842558435584455845558465584755848558495585055851558525585355854558555585655857558585585955860558615586255863558645586555866558675586855869558705587155872558735587455875558765587755878558795588055881558825588355884558855588655887558885588955890558915589255893558945589555896558975589855899559005590155902559035590455905559065590755908559095591055911559125591355914559155591655917559185591955920559215592255923559245592555926559275592855929559305593155932559335593455935559365593755938559395594055941559425594355944559455594655947559485594955950559515595255953559545595555956559575595855959559605596155962559635596455965559665596755968559695597055971559725597355974559755597655977559785597955980559815598255983559845598555986559875598855989559905599155992559935599455995559965599755998559995600056001560025600356004560055600656007560085600956010560115601256013560145601556016560175601856019560205602156022560235602456025560265602756028560295603056031560325603356034560355603656037560385603956040560415604256043560445604556046560475604856049560505605156052560535605456055560565605756058560595606056061560625606356064560655606656067560685606956070560715607256073560745607556076560775607856079560805608156082560835608456085560865608756088560895609056091560925609356094560955609656097560985609956100561015610256103561045610556106561075610856109561105611156112561135611456115561165611756118561195612056121561225612356124561255612656127561285612956130561315613256133561345613556136561375613856139561405614156142561435614456145561465614756148561495615056151561525615356154561555615656157561585615956160561615616256163561645616556166561675616856169561705617156172561735617456175561765617756178561795618056181561825618356184561855618656187561885618956190561915619256193561945619556196561975619856199562005620156202562035620456205562065620756208562095621056211562125621356214562155621656217562185621956220562215622256223562245622556226562275622856229562305623156232562335623456235562365623756238562395624056241562425624356244562455624656247562485624956250562515625256253562545625556256562575625856259562605626156262562635626456265562665626756268562695627056271562725627356274562755627656277562785627956280562815628256283562845628556286562875628856289562905629156292562935629456295562965629756298562995630056301563025630356304563055630656307563085630956310563115631256313563145631556316563175631856319563205632156322563235632456325563265632756328563295633056331563325633356334563355633656337563385633956340563415634256343563445634556346563475634856349563505635156352563535635456355563565635756358563595636056361563625636356364563655636656367563685636956370563715637256373563745637556376563775637856379563805638156382563835638456385563865638756388563895639056391563925639356394563955639656397563985639956400564015640256403564045640556406564075640856409564105641156412564135641456415564165641756418564195642056421564225642356424564255642656427564285642956430564315643256433564345643556436564375643856439564405644156442564435644456445564465644756448564495645056451564525645356454564555645656457564585645956460564615646256463564645646556466564675646856469564705647156472564735647456475564765647756478564795648056481564825648356484564855648656487564885648956490564915649256493564945649556496564975649856499565005650156502565035650456505565065650756508565095651056511565125651356514565155651656517565185651956520565215652256523565245652556526565275652856529565305653156532565335653456535565365653756538565395654056541565425654356544565455654656547565485654956550565515655256553565545655556556565575655856559565605656156562565635656456565565665656756568565695657056571565725657356574565755657656577565785657956580565815658256583565845658556586565875658856589565905659156592565935659456595565965659756598565995660056601566025660356604566055660656607566085660956610566115661256613566145661556616566175661856619566205662156622566235662456625566265662756628566295663056631566325663356634566355663656637566385663956640566415664256643566445664556646566475664856649566505665156652566535665456655566565665756658566595666056661566625666356664566655666656667566685666956670566715667256673566745667556676566775667856679566805668156682566835668456685566865668756688566895669056691566925669356694566955669656697566985669956700567015670256703567045670556706567075670856709567105671156712567135671456715567165671756718567195672056721567225672356724567255672656727567285672956730567315673256733567345673556736567375673856739567405674156742567435674456745567465674756748567495675056751567525675356754567555675656757567585675956760567615676256763567645676556766567675676856769567705677156772567735677456775567765677756778567795678056781567825678356784567855678656787567885678956790567915679256793567945679556796567975679856799568005680156802568035680456805568065680756808568095681056811568125681356814568155681656817568185681956820568215682256823568245682556826568275682856829568305683156832568335683456835568365683756838568395684056841568425684356844568455684656847568485684956850568515685256853568545685556856568575685856859568605686156862568635686456865568665686756868568695687056871568725687356874568755687656877568785687956880568815688256883568845688556886568875688856889568905689156892568935689456895568965689756898568995690056901569025690356904569055690656907569085690956910569115691256913569145691556916569175691856919569205692156922569235692456925569265692756928569295693056931569325693356934569355693656937569385693956940569415694256943569445694556946569475694856949569505695156952569535695456955569565695756958569595696056961569625696356964569655696656967569685696956970569715697256973569745697556976569775697856979569805698156982569835698456985569865698756988569895699056991569925699356994569955699656997569985699957000570015700257003570045700557006570075700857009570105701157012570135701457015570165701757018570195702057021570225702357024570255702657027570285702957030570315703257033570345703557036570375703857039570405704157042570435704457045570465704757048570495705057051570525705357054570555705657057570585705957060570615706257063570645706557066570675706857069570705707157072570735707457075570765707757078570795708057081570825708357084570855708657087570885708957090570915709257093570945709557096570975709857099571005710157102571035710457105571065710757108571095711057111571125711357114571155711657117571185711957120571215712257123571245712557126571275712857129571305713157132571335713457135571365713757138571395714057141571425714357144571455714657147571485714957150571515715257153571545715557156571575715857159571605716157162571635716457165571665716757168571695717057171571725717357174571755717657177571785717957180571815718257183571845718557186571875718857189571905719157192571935719457195571965719757198571995720057201572025720357204572055720657207572085720957210572115721257213572145721557216572175721857219572205722157222572235722457225572265722757228572295723057231572325723357234572355723657237572385723957240572415724257243572445724557246572475724857249572505725157252572535725457255572565725757258572595726057261572625726357264572655726657267572685726957270572715727257273572745727557276572775727857279572805728157282572835728457285572865728757288572895729057291572925729357294572955729657297572985729957300573015730257303573045730557306573075730857309573105731157312573135731457315573165731757318573195732057321573225732357324573255732657327573285732957330573315733257333573345733557336573375733857339573405734157342573435734457345573465734757348573495735057351573525735357354573555735657357573585735957360573615736257363573645736557366573675736857369573705737157372573735737457375573765737757378573795738057381573825738357384573855738657387573885738957390573915739257393573945739557396573975739857399574005740157402574035740457405574065740757408574095741057411574125741357414574155741657417574185741957420574215742257423574245742557426574275742857429574305743157432574335743457435574365743757438574395744057441574425744357444574455744657447574485744957450574515745257453574545745557456574575745857459574605746157462574635746457465574665746757468574695747057471574725747357474574755747657477574785747957480574815748257483574845748557486574875748857489574905749157492574935749457495574965749757498574995750057501575025750357504575055750657507575085750957510575115751257513575145751557516575175751857519575205752157522575235752457525575265752757528575295753057531575325753357534575355753657537575385753957540575415754257543575445754557546575475754857549575505755157552575535755457555575565755757558575595756057561575625756357564575655756657567575685756957570575715757257573575745757557576575775757857579575805758157582575835758457585575865758757588575895759057591575925759357594575955759657597575985759957600576015760257603576045760557606576075760857609576105761157612576135761457615576165761757618576195762057621576225762357624576255762657627576285762957630576315763257633576345763557636576375763857639576405764157642576435764457645576465764757648576495765057651576525765357654576555765657657576585765957660576615766257663576645766557666576675766857669576705767157672576735767457675576765767757678576795768057681576825768357684576855768657687576885768957690576915769257693576945769557696576975769857699577005770157702577035770457705577065770757708577095771057711577125771357714577155771657717577185771957720577215772257723577245772557726577275772857729577305773157732577335773457735577365773757738577395774057741577425774357744577455774657747577485774957750577515775257753577545775557756577575775857759577605776157762577635776457765577665776757768577695777057771577725777357774577755777657777577785777957780577815778257783577845778557786577875778857789577905779157792577935779457795577965779757798577995780057801578025780357804578055780657807578085780957810578115781257813578145781557816578175781857819578205782157822578235782457825578265782757828578295783057831578325783357834578355783657837578385783957840578415784257843578445784557846578475784857849578505785157852578535785457855578565785757858578595786057861578625786357864578655786657867578685786957870578715787257873578745787557876578775787857879578805788157882578835788457885578865788757888578895789057891578925789357894578955789657897578985789957900579015790257903579045790557906579075790857909579105791157912579135791457915579165791757918579195792057921579225792357924579255792657927579285792957930579315793257933579345793557936579375793857939579405794157942579435794457945579465794757948579495795057951579525795357954579555795657957579585795957960579615796257963579645796557966579675796857969579705797157972579735797457975579765797757978579795798057981579825798357984579855798657987579885798957990579915799257993579945799557996579975799857999580005800158002580035800458005580065800758008580095801058011580125801358014580155801658017580185801958020580215802258023580245802558026580275802858029580305803158032580335803458035580365803758038580395804058041580425804358044580455804658047580485804958050580515805258053580545805558056580575805858059580605806158062580635806458065580665806758068580695807058071580725807358074580755807658077580785807958080580815808258083580845808558086580875808858089580905809158092580935809458095580965809758098580995810058101581025810358104581055810658107581085810958110581115811258113581145811558116581175811858119581205812158122581235812458125581265812758128581295813058131581325813358134581355813658137581385813958140581415814258143581445814558146581475814858149581505815158152581535815458155581565815758158581595816058161581625816358164581655816658167581685816958170581715817258173581745817558176581775817858179581805818158182581835818458185581865818758188581895819058191581925819358194581955819658197581985819958200582015820258203582045820558206582075820858209582105821158212582135821458215582165821758218582195822058221582225822358224582255822658227582285822958230582315823258233582345823558236582375823858239582405824158242582435824458245582465824758248582495825058251582525825358254582555825658257582585825958260582615826258263582645826558266582675826858269582705827158272582735827458275582765827758278582795828058281582825828358284582855828658287582885828958290582915829258293582945829558296582975829858299583005830158302583035830458305583065830758308583095831058311583125831358314583155831658317583185831958320583215832258323583245832558326583275832858329583305833158332583335833458335583365833758338583395834058341583425834358344583455834658347583485834958350583515835258353583545835558356583575835858359583605836158362583635836458365583665836758368583695837058371583725837358374583755837658377583785837958380583815838258383583845838558386583875838858389583905839158392583935839458395583965839758398583995840058401584025840358404584055840658407584085840958410584115841258413584145841558416584175841858419584205842158422584235842458425584265842758428584295843058431584325843358434584355843658437584385843958440584415844258443584445844558446584475844858449584505845158452584535845458455584565845758458584595846058461584625846358464584655846658467584685846958470584715847258473584745847558476584775847858479584805848158482584835848458485584865848758488584895849058491584925849358494584955849658497584985849958500585015850258503585045850558506585075850858509585105851158512585135851458515585165851758518585195852058521585225852358524585255852658527585285852958530585315853258533585345853558536585375853858539585405854158542585435854458545585465854758548585495855058551585525855358554585555855658557585585855958560585615856258563585645856558566585675856858569585705857158572585735857458575585765857758578585795858058581585825858358584585855858658587585885858958590585915859258593585945859558596585975859858599586005860158602586035860458605586065860758608586095861058611586125861358614586155861658617586185861958620586215862258623586245862558626586275862858629586305863158632586335863458635586365863758638586395864058641586425864358644586455864658647586485864958650586515865258653586545865558656586575865858659586605866158662586635866458665586665866758668586695867058671586725867358674586755867658677586785867958680586815868258683586845868558686586875868858689586905869158692586935869458695586965869758698586995870058701587025870358704587055870658707587085870958710587115871258713587145871558716587175871858719587205872158722587235872458725587265872758728587295873058731587325873358734587355873658737587385873958740587415874258743587445874558746587475874858749587505875158752587535875458755587565875758758587595876058761587625876358764587655876658767587685876958770587715877258773587745877558776587775877858779587805878158782587835878458785587865878758788587895879058791587925879358794587955879658797587985879958800588015880258803588045880558806588075880858809588105881158812588135881458815588165881758818588195882058821588225882358824588255882658827588285882958830588315883258833588345883558836588375883858839588405884158842588435884458845588465884758848588495885058851588525885358854588555885658857588585885958860588615886258863588645886558866588675886858869588705887158872588735887458875588765887758878588795888058881588825888358884588855888658887588885888958890588915889258893588945889558896588975889858899589005890158902589035890458905589065890758908589095891058911589125891358914589155891658917589185891958920589215892258923589245892558926589275892858929589305893158932589335893458935589365893758938589395894058941589425894358944589455894658947589485894958950589515895258953589545895558956589575895858959589605896158962589635896458965589665896758968589695897058971589725897358974589755897658977589785897958980589815898258983589845898558986589875898858989589905899158992589935899458995589965899758998589995900059001590025900359004590055900659007590085900959010590115901259013590145901559016590175901859019590205902159022590235902459025590265902759028590295903059031590325903359034590355903659037590385903959040590415904259043590445904559046590475904859049590505905159052590535905459055590565905759058590595906059061590625906359064590655906659067590685906959070590715907259073590745907559076590775907859079590805908159082590835908459085590865908759088590895909059091590925909359094590955909659097590985909959100591015910259103591045910559106591075910859109591105911159112591135911459115591165911759118591195912059121591225912359124591255912659127591285912959130591315913259133591345913559136591375913859139591405914159142591435914459145591465914759148591495915059151591525915359154591555915659157591585915959160591615916259163591645916559166591675916859169591705917159172591735917459175591765917759178591795918059181591825918359184591855918659187591885918959190591915919259193591945919559196591975919859199592005920159202592035920459205592065920759208592095921059211592125921359214592155921659217592185921959220592215922259223592245922559226592275922859229592305923159232592335923459235592365923759238592395924059241592425924359244592455924659247592485924959250592515925259253592545925559256592575925859259592605926159262592635926459265592665926759268592695927059271592725927359274592755927659277592785927959280592815928259283592845928559286592875928859289592905929159292592935929459295592965929759298592995930059301593025930359304593055930659307593085930959310593115931259313593145931559316593175931859319593205932159322593235932459325593265932759328593295933059331593325933359334593355933659337593385933959340593415934259343593445934559346593475934859349593505935159352593535935459355593565935759358593595936059361593625936359364593655936659367593685936959370593715937259373593745937559376593775937859379593805938159382593835938459385593865938759388593895939059391593925939359394593955939659397593985939959400594015940259403594045940559406594075940859409594105941159412594135941459415594165941759418594195942059421594225942359424594255942659427594285942959430594315943259433594345943559436594375943859439594405944159442594435944459445594465944759448594495945059451594525945359454594555945659457594585945959460594615946259463594645946559466594675946859469594705947159472594735947459475594765947759478594795948059481594825948359484594855948659487594885948959490594915949259493594945949559496594975949859499595005950159502595035950459505595065950759508595095951059511595125951359514595155951659517595185951959520595215952259523595245952559526595275952859529595305953159532595335953459535595365953759538595395954059541595425954359544595455954659547595485954959550595515955259553595545955559556595575955859559595605956159562595635956459565595665956759568595695957059571595725957359574595755957659577595785957959580595815958259583595845958559586595875958859589595905959159592595935959459595595965959759598595995960059601596025960359604596055960659607596085960959610596115961259613596145961559616596175961859619596205962159622596235962459625596265962759628596295963059631596325963359634596355963659637596385963959640596415964259643596445964559646596475964859649596505965159652596535965459655596565965759658596595966059661596625966359664596655966659667596685966959670596715967259673596745967559676596775967859679596805968159682596835968459685596865968759688596895969059691596925969359694596955969659697596985969959700597015970259703597045970559706597075970859709597105971159712597135971459715597165971759718597195972059721597225972359724597255972659727597285972959730597315973259733597345973559736597375973859739597405974159742597435974459745597465974759748597495975059751597525975359754597555975659757597585975959760597615976259763597645976559766597675976859769597705977159772597735977459775597765977759778597795978059781597825978359784597855978659787597885978959790597915979259793597945979559796597975979859799598005980159802598035980459805598065980759808598095981059811598125981359814598155981659817598185981959820598215982259823598245982559826598275982859829598305983159832598335983459835598365983759838598395984059841598425984359844598455984659847598485984959850598515985259853598545985559856598575985859859598605986159862598635986459865598665986759868598695987059871598725987359874598755987659877598785987959880598815988259883598845988559886598875988859889598905989159892598935989459895598965989759898598995990059901599025990359904599055990659907599085990959910599115991259913599145991559916599175991859919599205992159922599235992459925599265992759928599295993059931599325993359934599355993659937599385993959940599415994259943599445994559946599475994859949599505995159952599535995459955599565995759958599595996059961599625996359964599655996659967599685996959970599715997259973599745997559976599775997859979599805998159982599835998459985599865998759988599895999059991599925999359994599955999659997599985999960000600016000260003600046000560006600076000860009600106001160012600136001460015600166001760018600196002060021600226002360024600256002660027600286002960030600316003260033600346003560036600376003860039600406004160042600436004460045600466004760048600496005060051600526005360054600556005660057600586005960060600616006260063600646006560066600676006860069600706007160072600736007460075600766007760078600796008060081600826008360084600856008660087600886008960090600916009260093600946009560096600976009860099601006010160102601036010460105601066010760108601096011060111601126011360114601156011660117601186011960120601216012260123601246012560126601276012860129601306013160132601336013460135601366013760138601396014060141601426014360144601456014660147601486014960150601516015260153601546015560156601576015860159601606016160162601636016460165601666016760168601696017060171601726017360174601756017660177601786017960180601816018260183601846018560186601876018860189601906019160192601936019460195601966019760198601996020060201602026020360204602056020660207602086020960210602116021260213602146021560216602176021860219602206022160222602236022460225602266022760228602296023060231602326023360234602356023660237602386023960240602416024260243602446024560246602476024860249602506025160252602536025460255602566025760258602596026060261602626026360264602656026660267602686026960270602716027260273602746027560276602776027860279602806028160282602836028460285602866028760288602896029060291602926029360294602956029660297602986029960300603016030260303603046030560306603076030860309603106031160312603136031460315603166031760318603196032060321603226032360324603256032660327603286032960330603316033260333603346033560336603376033860339603406034160342603436034460345603466034760348603496035060351603526035360354603556035660357603586035960360603616036260363603646036560366603676036860369603706037160372603736037460375603766037760378603796038060381603826038360384603856038660387603886038960390603916039260393603946039560396603976039860399604006040160402604036040460405604066040760408604096041060411604126041360414604156041660417604186041960420604216042260423604246042560426604276042860429604306043160432604336043460435604366043760438604396044060441604426044360444604456044660447604486044960450604516045260453604546045560456604576045860459604606046160462604636046460465604666046760468604696047060471604726047360474604756047660477604786047960480604816048260483604846048560486604876048860489604906049160492604936049460495604966049760498604996050060501605026050360504605056050660507605086050960510605116051260513605146051560516605176051860519605206052160522605236052460525605266052760528605296053060531605326053360534605356053660537605386053960540605416054260543605446054560546605476054860549605506055160552605536055460555605566055760558605596056060561605626056360564605656056660567605686056960570605716057260573605746057560576605776057860579605806058160582605836058460585605866058760588605896059060591605926059360594605956059660597605986059960600606016060260603606046060560606606076060860609606106061160612606136061460615606166061760618606196062060621606226062360624606256062660627606286062960630606316063260633606346063560636606376063860639606406064160642606436064460645606466064760648606496065060651606526065360654606556065660657606586065960660606616066260663606646066560666606676066860669606706067160672606736067460675606766067760678606796068060681606826068360684606856068660687606886068960690606916069260693606946069560696606976069860699607006070160702607036070460705607066070760708607096071060711607126071360714607156071660717607186071960720607216072260723607246072560726607276072860729607306073160732607336073460735607366073760738607396074060741607426074360744607456074660747607486074960750607516075260753607546075560756607576075860759607606076160762607636076460765607666076760768607696077060771607726077360774607756077660777607786077960780607816078260783607846078560786607876078860789607906079160792607936079460795607966079760798607996080060801608026080360804608056080660807608086080960810608116081260813608146081560816608176081860819608206082160822608236082460825608266082760828608296083060831608326083360834608356083660837608386083960840608416084260843608446084560846608476084860849608506085160852608536085460855608566085760858608596086060861608626086360864608656086660867608686086960870608716087260873608746087560876608776087860879608806088160882608836088460885608866088760888608896089060891608926089360894608956089660897608986089960900609016090260903609046090560906609076090860909609106091160912609136091460915609166091760918609196092060921609226092360924609256092660927609286092960930609316093260933609346093560936609376093860939609406094160942609436094460945609466094760948609496095060951609526095360954609556095660957609586095960960609616096260963609646096560966609676096860969609706097160972609736097460975609766097760978609796098060981609826098360984609856098660987609886098960990609916099260993609946099560996609976099860999610006100161002610036100461005610066100761008610096101061011610126101361014610156101661017610186101961020610216102261023610246102561026610276102861029610306103161032610336103461035610366103761038610396104061041610426104361044610456104661047610486104961050610516105261053610546105561056610576105861059610606106161062610636106461065610666106761068610696107061071610726107361074610756107661077610786107961080610816108261083610846108561086610876108861089610906109161092610936109461095610966109761098610996110061101611026110361104611056110661107611086110961110611116111261113611146111561116611176111861119611206112161122611236112461125611266112761128611296113061131611326113361134611356113661137611386113961140611416114261143611446114561146611476114861149611506115161152611536115461155611566115761158611596116061161611626116361164611656116661167611686116961170611716117261173611746117561176611776117861179611806118161182611836118461185611866118761188611896119061191611926119361194611956119661197611986119961200612016120261203612046120561206612076120861209612106121161212612136121461215612166121761218612196122061221612226122361224612256122661227612286122961230612316123261233612346123561236612376123861239612406124161242612436124461245612466124761248612496125061251612526125361254612556125661257612586125961260612616126261263612646126561266612676126861269612706127161272612736127461275612766127761278612796128061281612826128361284612856128661287612886128961290612916129261293612946129561296612976129861299613006130161302613036130461305613066130761308613096131061311613126131361314613156131661317613186131961320613216132261323613246132561326613276132861329613306133161332613336133461335613366133761338613396134061341613426134361344613456134661347613486134961350613516135261353613546135561356613576135861359613606136161362613636136461365613666136761368613696137061371613726137361374613756137661377613786137961380613816138261383613846138561386613876138861389613906139161392613936139461395613966139761398613996140061401614026140361404614056140661407614086140961410614116141261413614146141561416614176141861419614206142161422614236142461425614266142761428614296143061431614326143361434614356143661437614386143961440614416144261443614446144561446614476144861449614506145161452614536145461455614566145761458614596146061461614626146361464614656146661467614686146961470614716147261473614746147561476614776147861479614806148161482614836148461485614866148761488614896149061491614926149361494614956149661497614986149961500615016150261503615046150561506615076150861509615106151161512615136151461515615166151761518615196152061521615226152361524615256152661527615286152961530615316153261533615346153561536615376153861539615406154161542615436154461545615466154761548615496155061551615526155361554615556155661557615586155961560615616156261563615646156561566615676156861569615706157161572615736157461575615766157761578615796158061581615826158361584615856158661587615886158961590615916159261593615946159561596615976159861599616006160161602616036160461605616066160761608616096161061611616126161361614616156161661617616186161961620616216162261623616246162561626616276162861629616306163161632616336163461635616366163761638616396164061641616426164361644616456164661647616486164961650616516165261653616546165561656616576165861659616606166161662616636166461665616666166761668616696167061671616726167361674616756167661677616786167961680616816168261683616846168561686616876168861689616906169161692616936169461695616966169761698616996170061701617026170361704617056170661707617086170961710617116171261713617146171561716617176171861719617206172161722617236172461725617266172761728617296173061731617326173361734617356173661737617386173961740617416174261743617446174561746617476174861749617506175161752617536175461755617566175761758617596176061761617626176361764617656176661767617686176961770617716177261773617746177561776617776177861779617806178161782617836178461785617866178761788617896179061791617926179361794617956179661797617986179961800618016180261803618046180561806618076180861809618106181161812618136181461815618166181761818618196182061821618226182361824618256182661827618286182961830618316183261833618346183561836618376183861839618406184161842618436184461845618466184761848618496185061851618526185361854618556185661857618586185961860618616186261863618646186561866618676186861869618706187161872618736187461875618766187761878618796188061881618826188361884618856188661887618886188961890618916189261893618946189561896618976189861899619006190161902619036190461905619066190761908619096191061911619126191361914619156191661917619186191961920619216192261923619246192561926619276192861929619306193161932619336193461935619366193761938619396194061941619426194361944619456194661947619486194961950619516195261953619546195561956619576195861959619606196161962619636196461965619666196761968619696197061971619726197361974619756197661977619786197961980619816198261983619846198561986619876198861989619906199161992619936199461995619966199761998619996200062001620026200362004620056200662007620086200962010620116201262013620146201562016620176201862019620206202162022620236202462025620266202762028620296203062031620326203362034620356203662037620386203962040620416204262043620446204562046620476204862049620506205162052620536205462055620566205762058620596206062061620626206362064620656206662067620686206962070620716207262073620746207562076620776207862079620806208162082620836208462085620866208762088620896209062091620926209362094620956209662097620986209962100621016210262103621046210562106621076210862109621106211162112621136211462115621166211762118621196212062121621226212362124621256212662127621286212962130621316213262133621346213562136621376213862139621406214162142621436214462145621466214762148621496215062151621526215362154621556215662157621586215962160621616216262163621646216562166621676216862169621706217162172621736217462175621766217762178621796218062181621826218362184621856218662187621886218962190621916219262193621946219562196621976219862199622006220162202622036220462205622066220762208622096221062211622126221362214622156221662217622186221962220622216222262223622246222562226622276222862229622306223162232622336223462235622366223762238622396224062241622426224362244622456224662247622486224962250622516225262253622546225562256622576225862259622606226162262622636226462265622666226762268622696227062271622726227362274622756227662277622786227962280622816228262283622846228562286622876228862289622906229162292622936229462295622966229762298622996230062301623026230362304623056230662307623086230962310623116231262313623146231562316623176231862319623206232162322623236232462325623266232762328623296233062331623326233362334623356233662337623386233962340623416234262343623446234562346623476234862349623506235162352623536235462355623566235762358623596236062361623626236362364623656236662367623686236962370623716237262373623746237562376623776237862379623806238162382623836238462385623866238762388623896239062391623926239362394623956239662397623986239962400624016240262403624046240562406624076240862409624106241162412624136241462415624166241762418624196242062421624226242362424624256242662427624286242962430624316243262433624346243562436624376243862439624406244162442624436244462445624466244762448624496245062451624526245362454624556245662457624586245962460624616246262463624646246562466624676246862469624706247162472624736247462475624766247762478624796248062481624826248362484624856248662487624886248962490624916249262493624946249562496624976249862499625006250162502625036250462505625066250762508625096251062511625126251362514625156251662517625186251962520625216252262523625246252562526625276252862529625306253162532625336253462535625366253762538625396254062541625426254362544625456254662547625486254962550625516255262553625546255562556625576255862559625606256162562625636256462565625666256762568625696257062571625726257362574625756257662577625786257962580625816258262583625846258562586625876258862589625906259162592625936259462595625966259762598625996260062601626026260362604626056260662607626086260962610626116261262613626146261562616626176261862619626206262162622626236262462625626266262762628626296263062631626326263362634626356263662637626386263962640626416264262643626446264562646626476264862649626506265162652626536265462655626566265762658626596266062661626626266362664626656266662667626686266962670626716267262673626746267562676626776267862679626806268162682626836268462685626866268762688626896269062691626926269362694626956269662697626986269962700627016270262703627046270562706627076270862709627106271162712627136271462715627166271762718627196272062721627226272362724627256272662727627286272962730627316273262733627346273562736627376273862739627406274162742627436274462745627466274762748627496275062751627526275362754627556275662757627586275962760627616276262763627646276562766627676276862769627706277162772627736277462775627766277762778627796278062781627826278362784627856278662787627886278962790627916279262793627946279562796627976279862799628006280162802628036280462805628066280762808628096281062811628126281362814628156281662817628186281962820628216282262823628246282562826628276282862829628306283162832628336283462835628366283762838628396284062841628426284362844628456284662847628486284962850628516285262853628546285562856628576285862859628606286162862628636286462865628666286762868628696287062871628726287362874628756287662877628786287962880628816288262883628846288562886628876288862889628906289162892628936289462895628966289762898628996290062901629026290362904629056290662907629086290962910629116291262913629146291562916629176291862919629206292162922629236292462925629266292762928629296293062931629326293362934629356293662937629386293962940629416294262943629446294562946629476294862949629506295162952629536295462955629566295762958629596296062961629626296362964629656296662967629686296962970629716297262973629746297562976629776297862979629806298162982629836298462985629866298762988629896299062991629926299362994629956299662997629986299963000630016300263003630046300563006630076300863009630106301163012630136301463015630166301763018630196302063021630226302363024630256302663027630286302963030630316303263033630346303563036630376303863039630406304163042630436304463045630466304763048630496305063051630526305363054630556305663057630586305963060630616306263063630646306563066630676306863069630706307163072630736307463075630766307763078630796308063081630826308363084630856308663087630886308963090630916309263093630946309563096630976309863099631006310163102631036310463105631066310763108631096311063111631126311363114631156311663117631186311963120631216312263123631246312563126631276312863129631306313163132631336313463135631366313763138631396314063141631426314363144631456314663147631486314963150631516315263153631546315563156631576315863159631606316163162631636316463165631666316763168631696317063171631726317363174631756317663177631786317963180631816318263183631846318563186631876318863189631906319163192631936319463195631966319763198631996320063201632026320363204632056320663207632086320963210632116321263213632146321563216632176321863219632206322163222632236322463225632266322763228632296323063231632326323363234632356323663237632386323963240632416324263243632446324563246632476324863249632506325163252632536325463255632566325763258632596326063261632626326363264632656326663267632686326963270632716327263273632746327563276632776327863279632806328163282632836328463285632866328763288632896329063291632926329363294632956329663297632986329963300633016330263303633046330563306633076330863309633106331163312633136331463315633166331763318633196332063321633226332363324633256332663327633286332963330633316333263333633346333563336633376333863339633406334163342633436334463345633466334763348633496335063351633526335363354633556335663357633586335963360633616336263363633646336563366633676336863369633706337163372633736337463375633766337763378633796338063381633826338363384633856338663387633886338963390633916339263393633946339563396633976339863399634006340163402634036340463405634066340763408634096341063411634126341363414634156341663417634186341963420634216342263423634246342563426634276342863429634306343163432634336343463435634366343763438634396344063441634426344363444634456344663447634486344963450634516345263453634546345563456634576345863459634606346163462634636346463465634666346763468634696347063471634726347363474634756347663477634786347963480634816348263483634846348563486634876348863489634906349163492634936349463495634966349763498634996350063501635026350363504635056350663507635086350963510635116351263513635146351563516635176351863519635206352163522635236352463525635266352763528635296353063531635326353363534635356353663537635386353963540635416354263543635446354563546635476354863549635506355163552635536355463555635566355763558635596356063561635626356363564635656356663567635686356963570635716357263573635746357563576635776357863579635806358163582635836358463585635866358763588635896359063591635926359363594635956359663597635986359963600636016360263603636046360563606636076360863609636106361163612636136361463615636166361763618636196362063621636226362363624636256362663627636286362963630636316363263633636346363563636636376363863639636406364163642636436364463645636466364763648636496365063651636526365363654636556365663657636586365963660636616366263663636646366563666636676366863669636706367163672636736367463675636766367763678636796368063681636826368363684636856368663687636886368963690636916369263693636946369563696636976369863699637006370163702637036370463705637066370763708637096371063711637126371363714637156371663717637186371963720637216372263723637246372563726637276372863729637306373163732637336373463735637366373763738637396374063741637426374363744637456374663747637486374963750637516375263753637546375563756637576375863759637606376163762637636376463765637666376763768637696377063771637726377363774637756377663777637786377963780637816378263783637846378563786637876378863789637906379163792637936379463795637966379763798637996380063801638026380363804638056380663807638086380963810638116381263813638146381563816638176381863819638206382163822638236382463825638266382763828638296383063831638326383363834638356383663837638386383963840638416384263843638446384563846638476384863849638506385163852638536385463855638566385763858638596386063861638626386363864638656386663867638686386963870638716387263873638746387563876638776387863879638806388163882638836388463885638866388763888638896389063891638926389363894638956389663897638986389963900639016390263903639046390563906639076390863909639106391163912639136391463915639166391763918639196392063921639226392363924639256392663927639286392963930639316393263933639346393563936639376393863939639406394163942639436394463945639466394763948639496395063951639526395363954639556395663957639586395963960639616396263963639646396563966639676396863969639706397163972639736397463975639766397763978639796398063981639826398363984639856398663987639886398963990639916399263993639946399563996639976399863999640006400164002640036400464005640066400764008640096401064011640126401364014640156401664017640186401964020640216402264023640246402564026640276402864029640306403164032640336403464035640366403764038640396404064041640426404364044640456404664047640486404964050640516405264053640546405564056640576405864059640606406164062640636406464065640666406764068640696407064071640726407364074640756407664077640786407964080640816408264083640846408564086640876408864089640906409164092640936409464095640966409764098640996410064101641026410364104641056410664107641086410964110641116411264113641146411564116641176411864119641206412164122641236412464125641266412764128641296413064131641326413364134641356413664137641386413964140641416414264143641446414564146641476414864149641506415164152641536415464155641566415764158641596416064161641626416364164641656416664167641686416964170641716417264173641746417564176641776417864179641806418164182641836418464185641866418764188641896419064191641926419364194641956419664197641986419964200642016420264203642046420564206642076420864209642106421164212642136421464215642166421764218642196422064221642226422364224642256422664227642286422964230642316423264233642346423564236642376423864239642406424164242642436424464245642466424764248642496425064251642526425364254642556425664257642586425964260642616426264263642646426564266642676426864269642706427164272642736427464275642766427764278642796428064281642826428364284642856428664287642886428964290642916429264293642946429564296642976429864299643006430164302643036430464305643066430764308643096431064311643126431364314643156431664317643186431964320643216432264323643246432564326643276432864329643306433164332643336433464335643366433764338643396434064341643426434364344643456434664347643486434964350643516435264353643546435564356643576435864359643606436164362643636436464365643666436764368643696437064371643726437364374643756437664377643786437964380643816438264383643846438564386643876438864389643906439164392643936439464395643966439764398643996440064401644026440364404644056440664407644086440964410644116441264413644146441564416644176441864419644206442164422644236442464425644266442764428644296443064431644326443364434644356443664437644386443964440644416444264443644446444564446644476444864449644506445164452644536445464455644566445764458644596446064461644626446364464644656446664467644686446964470644716447264473644746447564476644776447864479644806448164482644836448464485644866448764488644896449064491644926449364494644956449664497644986449964500645016450264503645046450564506645076450864509645106451164512645136451464515645166451764518645196452064521645226452364524645256452664527645286452964530645316453264533645346453564536645376453864539645406454164542645436454464545645466454764548645496455064551645526455364554645556455664557645586455964560645616456264563645646456564566645676456864569645706457164572645736457464575645766457764578645796458064581645826458364584645856458664587645886458964590645916459264593645946459564596645976459864599646006460164602646036460464605646066460764608646096461064611646126461364614646156461664617646186461964620646216462264623646246462564626646276462864629646306463164632646336463464635646366463764638646396464064641646426464364644646456464664647646486464964650646516465264653646546465564656646576465864659646606466164662646636466464665646666466764668646696467064671646726467364674646756467664677646786467964680646816468264683646846468564686646876468864689646906469164692646936469464695646966469764698646996470064701647026470364704647056470664707647086470964710647116471264713647146471564716647176471864719647206472164722647236472464725647266472764728647296473064731647326473364734647356473664737647386473964740647416474264743647446474564746647476474864749647506475164752647536475464755647566475764758647596476064761647626476364764647656476664767647686476964770647716477264773647746477564776647776477864779647806478164782647836478464785647866478764788647896479064791647926479364794647956479664797647986479964800648016480264803648046480564806648076480864809648106481164812648136481464815648166481764818648196482064821648226482364824648256482664827648286482964830648316483264833648346483564836648376483864839648406484164842648436484464845648466484764848648496485064851648526485364854648556485664857648586485964860648616486264863648646486564866648676486864869648706487164872648736487464875648766487764878648796488064881648826488364884648856488664887648886488964890648916489264893648946489564896648976489864899649006490164902649036490464905649066490764908649096491064911649126491364914649156491664917649186491964920649216492264923649246492564926649276492864929649306493164932649336493464935649366493764938649396494064941649426494364944649456494664947649486494964950649516495264953649546495564956649576495864959649606496164962649636496464965649666496764968649696497064971649726497364974649756497664977649786497964980649816498264983649846498564986649876498864989649906499164992649936499464995649966499764998649996500065001650026500365004650056500665007650086500965010650116501265013650146501565016650176501865019650206502165022650236502465025650266502765028650296503065031650326503365034650356503665037650386503965040650416504265043650446504565046650476504865049650506505165052650536505465055650566505765058650596506065061650626506365064650656506665067650686506965070650716507265073650746507565076650776507865079650806508165082650836508465085650866508765088650896509065091650926509365094650956509665097650986509965100651016510265103651046510565106651076510865109651106511165112651136511465115651166511765118651196512065121651226512365124651256512665127651286512965130651316513265133651346513565136651376513865139651406514165142651436514465145651466514765148651496515065151651526515365154651556515665157651586515965160651616516265163651646516565166651676516865169651706517165172651736517465175651766517765178651796518065181651826518365184651856518665187651886518965190651916519265193651946519565196651976519865199652006520165202652036520465205652066520765208652096521065211652126521365214652156521665217652186521965220652216522265223652246522565226652276522865229652306523165232652336523465235652366523765238652396524065241652426524365244652456524665247652486524965250652516525265253652546525565256652576525865259652606526165262652636526465265652666526765268652696527065271652726527365274652756527665277652786527965280652816528265283652846528565286652876528865289652906529165292652936529465295652966529765298652996530065301653026530365304653056530665307653086530965310653116531265313653146531565316653176531865319653206532165322653236532465325653266532765328653296533065331653326533365334653356533665337653386533965340653416534265343653446534565346653476534865349653506535165352653536535465355653566535765358653596536065361653626536365364653656536665367653686536965370653716537265373653746537565376653776537865379653806538165382653836538465385653866538765388653896539065391653926539365394653956539665397653986539965400654016540265403654046540565406654076540865409654106541165412654136541465415654166541765418654196542065421654226542365424654256542665427654286542965430654316543265433654346543565436654376543865439654406544165442654436544465445654466544765448654496545065451654526545365454654556545665457654586545965460654616546265463654646546565466654676546865469654706547165472654736547465475654766547765478654796548065481654826548365484654856548665487654886548965490654916549265493654946549565496654976549865499655006550165502655036550465505655066550765508655096551065511655126551365514655156551665517655186551965520655216552265523655246552565526655276552865529655306553165532655336553465535655366553765538655396554065541655426554365544655456554665547655486554965550655516555265553655546555565556655576555865559655606556165562655636556465565655666556765568655696557065571655726557365574655756557665577655786557965580655816558265583655846558565586655876558865589655906559165592655936559465595655966559765598655996560065601656026560365604656056560665607656086560965610656116561265613656146561565616656176561865619656206562165622656236562465625656266562765628656296563065631656326563365634656356563665637656386563965640656416564265643656446564565646656476564865649656506565165652656536565465655656566565765658656596566065661656626566365664656656566665667656686566965670656716567265673656746567565676656776567865679656806568165682656836568465685656866568765688656896569065691656926569365694656956569665697656986569965700657016570265703657046570565706657076570865709657106571165712657136571465715657166571765718657196572065721657226572365724657256572665727657286572965730657316573265733657346573565736657376573865739657406574165742657436574465745657466574765748657496575065751657526575365754657556575665757657586575965760657616576265763657646576565766657676576865769657706577165772657736577465775657766577765778657796578065781657826578365784657856578665787657886578965790657916579265793657946579565796657976579865799658006580165802658036580465805658066580765808658096581065811658126581365814658156581665817658186581965820658216582265823658246582565826658276582865829658306583165832658336583465835658366583765838658396584065841658426584365844658456584665847658486584965850658516585265853658546585565856658576585865859658606586165862658636586465865658666586765868658696587065871658726587365874658756587665877658786587965880658816588265883658846588565886658876588865889658906589165892658936589465895658966589765898658996590065901659026590365904659056590665907659086590965910659116591265913659146591565916659176591865919659206592165922659236592465925659266592765928659296593065931659326593365934659356593665937659386593965940659416594265943659446594565946659476594865949659506595165952659536595465955659566595765958659596596065961659626596365964659656596665967659686596965970659716597265973659746597565976659776597865979659806598165982659836598465985659866598765988659896599065991659926599365994659956599665997659986599966000660016600266003660046600566006660076600866009660106601166012660136601466015660166601766018660196602066021660226602366024660256602666027660286602966030660316603266033660346603566036660376603866039660406604166042660436604466045660466604766048660496605066051660526605366054660556605666057660586605966060660616606266063660646606566066660676606866069660706607166072660736607466075660766607766078660796608066081660826608366084660856608666087660886608966090660916609266093660946609566096660976609866099661006610166102661036610466105661066610766108661096611066111661126611366114661156611666117661186611966120661216612266123661246612566126661276612866129661306613166132661336613466135661366613766138661396614066141661426614366144661456614666147661486614966150661516615266153661546615566156661576615866159661606616166162661636616466165661666616766168661696617066171661726617366174661756617666177661786617966180661816618266183661846618566186661876618866189661906619166192661936619466195661966619766198661996620066201662026620366204662056620666207662086620966210662116621266213662146621566216662176621866219662206622166222662236622466225662266622766228662296623066231662326623366234662356623666237662386623966240662416624266243662446624566246662476624866249662506625166252662536625466255662566625766258662596626066261662626626366264662656626666267662686626966270662716627266273662746627566276662776627866279662806628166282662836628466285662866628766288662896629066291662926629366294662956629666297662986629966300663016630266303663046630566306663076630866309663106631166312663136631466315663166631766318663196632066321663226632366324663256632666327663286632966330663316633266333663346633566336663376633866339663406634166342663436634466345663466634766348663496635066351663526635366354663556635666357663586635966360663616636266363663646636566366663676636866369663706637166372663736637466375663766637766378663796638066381663826638366384663856638666387663886638966390663916639266393663946639566396663976639866399664006640166402664036640466405664066640766408664096641066411664126641366414664156641666417664186641966420664216642266423664246642566426664276642866429664306643166432664336643466435664366643766438664396644066441664426644366444664456644666447664486644966450664516645266453664546645566456664576645866459664606646166462664636646466465664666646766468664696647066471664726647366474664756647666477664786647966480664816648266483664846648566486664876648866489664906649166492664936649466495664966649766498664996650066501665026650366504665056650666507665086650966510665116651266513665146651566516665176651866519665206652166522665236652466525665266652766528665296653066531665326653366534665356653666537665386653966540665416654266543665446654566546665476654866549665506655166552665536655466555665566655766558665596656066561665626656366564665656656666567665686656966570665716657266573665746657566576665776657866579665806658166582665836658466585665866658766588665896659066591665926659366594665956659666597665986659966600666016660266603666046660566606666076660866609666106661166612666136661466615666166661766618666196662066621666226662366624666256662666627666286662966630666316663266633666346663566636666376663866639666406664166642666436664466645666466664766648666496665066651666526665366654666556665666657666586665966660666616666266663666646666566666666676666866669666706667166672666736667466675666766667766678666796668066681666826668366684666856668666687666886668966690666916669266693666946669566696666976669866699667006670166702667036670466705667066670766708667096671066711667126671366714667156671666717667186671966720667216672266723667246672566726667276672866729667306673166732667336673466735667366673766738667396674066741667426674366744667456674666747667486674966750667516675266753667546675566756667576675866759667606676166762667636676466765667666676766768667696677066771667726677366774667756677666777667786677966780667816678266783667846678566786667876678866789667906679166792667936679466795667966679766798667996680066801668026680366804668056680666807668086680966810668116681266813668146681566816668176681866819668206682166822668236682466825668266682766828668296683066831668326683366834668356683666837668386683966840668416684266843668446684566846668476684866849668506685166852668536685466855668566685766858668596686066861668626686366864668656686666867668686686966870668716687266873668746687566876668776687866879668806688166882668836688466885668866688766888668896689066891668926689366894668956689666897668986689966900669016690266903669046690566906669076690866909669106691166912669136691466915669166691766918669196692066921669226692366924669256692666927669286692966930669316693266933669346693566936669376693866939669406694166942669436694466945669466694766948669496695066951669526695366954669556695666957669586695966960669616696266963669646696566966669676696866969669706697166972669736697466975669766697766978669796698066981669826698366984669856698666987669886698966990669916699266993669946699566996669976699866999670006700167002670036700467005670066700767008670096701067011670126701367014670156701667017670186701967020670216702267023670246702567026670276702867029670306703167032670336703467035670366703767038670396704067041670426704367044670456704667047670486704967050670516705267053670546705567056670576705867059670606706167062670636706467065670666706767068670696707067071670726707367074670756707667077670786707967080670816708267083670846708567086670876708867089670906709167092670936709467095670966709767098670996710067101671026710367104671056710667107671086710967110671116711267113671146711567116671176711867119671206712167122671236712467125671266712767128671296713067131671326713367134671356713667137671386713967140671416714267143671446714567146671476714867149671506715167152671536715467155671566715767158671596716067161671626716367164671656716667167671686716967170671716717267173671746717567176671776717867179671806718167182671836718467185671866718767188671896719067191671926719367194671956719667197671986719967200672016720267203672046720567206672076720867209672106721167212672136721467215672166721767218672196722067221672226722367224672256722667227672286722967230672316723267233672346723567236672376723867239672406724167242672436724467245672466724767248672496725067251672526725367254672556725667257672586725967260672616726267263672646726567266672676726867269672706727167272672736727467275672766727767278672796728067281672826728367284672856728667287672886728967290672916729267293672946729567296672976729867299673006730167302673036730467305673066730767308673096731067311673126731367314673156731667317673186731967320673216732267323673246732567326673276732867329673306733167332673336733467335673366733767338673396734067341673426734367344673456734667347673486734967350673516735267353673546735567356673576735867359673606736167362673636736467365673666736767368673696737067371673726737367374673756737667377673786737967380673816738267383673846738567386673876738867389673906739167392673936739467395673966739767398673996740067401674026740367404674056740667407674086740967410674116741267413674146741567416674176741867419674206742167422674236742467425674266742767428674296743067431674326743367434674356743667437674386743967440674416744267443674446744567446674476744867449674506745167452674536745467455674566745767458674596746067461674626746367464674656746667467674686746967470674716747267473674746747567476674776747867479674806748167482674836748467485674866748767488674896749067491674926749367494674956749667497674986749967500675016750267503675046750567506675076750867509675106751167512675136751467515675166751767518675196752067521675226752367524675256752667527675286752967530675316753267533675346753567536675376753867539675406754167542675436754467545675466754767548675496755067551675526755367554675556755667557675586755967560675616756267563675646756567566675676756867569675706757167572675736757467575675766757767578675796758067581675826758367584675856758667587675886758967590675916759267593675946759567596675976759867599676006760167602676036760467605676066760767608676096761067611676126761367614676156761667617676186761967620676216762267623676246762567626676276762867629676306763167632676336763467635676366763767638676396764067641676426764367644676456764667647676486764967650676516765267653676546765567656676576765867659676606766167662676636766467665676666766767668676696767067671676726767367674676756767667677676786767967680676816768267683676846768567686676876768867689676906769167692676936769467695676966769767698676996770067701677026770367704677056770667707677086770967710677116771267713677146771567716677176771867719677206772167722677236772467725677266772767728677296773067731677326773367734677356773667737677386773967740677416774267743677446774567746677476774867749677506775167752677536775467755677566775767758677596776067761677626776367764677656776667767677686776967770677716777267773677746777567776677776777867779677806778167782677836778467785677866778767788677896779067791677926779367794677956779667797677986779967800678016780267803678046780567806678076780867809678106781167812678136781467815678166781767818678196782067821678226782367824678256782667827678286782967830678316783267833678346783567836678376783867839678406784167842678436784467845678466784767848678496785067851678526785367854678556785667857678586785967860678616786267863678646786567866678676786867869678706787167872678736787467875678766787767878678796788067881678826788367884678856788667887678886788967890678916789267893678946789567896678976789867899679006790167902679036790467905679066790767908679096791067911679126791367914679156791667917679186791967920679216792267923679246792567926679276792867929679306793167932679336793467935679366793767938679396794067941679426794367944679456794667947679486794967950679516795267953679546795567956679576795867959679606796167962679636796467965679666796767968679696797067971679726797367974679756797667977679786797967980679816798267983679846798567986679876798867989679906799167992679936799467995679966799767998679996800068001680026800368004680056800668007680086800968010680116801268013680146801568016680176801868019680206802168022680236802468025680266802768028680296803068031680326803368034680356803668037680386803968040680416804268043680446804568046680476804868049680506805168052680536805468055680566805768058680596806068061680626806368064680656806668067680686806968070680716807268073680746807568076680776807868079680806808168082680836808468085680866808768088680896809068091680926809368094680956809668097680986809968100681016810268103681046810568106681076810868109681106811168112681136811468115681166811768118681196812068121681226812368124681256812668127681286812968130681316813268133681346813568136681376813868139681406814168142681436814468145681466814768148681496815068151681526815368154681556815668157681586815968160681616816268163681646816568166681676816868169681706817168172681736817468175681766817768178681796818068181681826818368184681856818668187681886818968190681916819268193681946819568196681976819868199682006820168202682036820468205682066820768208682096821068211682126821368214682156821668217682186821968220682216822268223682246822568226682276822868229682306823168232682336823468235682366823768238682396824068241682426824368244682456824668247682486824968250682516825268253682546825568256682576825868259682606826168262682636826468265682666826768268682696827068271682726827368274682756827668277682786827968280682816828268283682846828568286682876828868289682906829168292682936829468295682966829768298682996830068301683026830368304683056830668307683086830968310683116831268313683146831568316683176831868319683206832168322683236832468325683266832768328683296833068331683326833368334683356833668337683386833968340683416834268343683446834568346683476834868349683506835168352683536835468355683566835768358683596836068361683626836368364683656836668367683686836968370683716837268373683746837568376683776837868379683806838168382683836838468385683866838768388683896839068391683926839368394683956839668397683986839968400684016840268403684046840568406684076840868409684106841168412684136841468415684166841768418684196842068421684226842368424684256842668427684286842968430684316843268433684346843568436684376843868439684406844168442684436844468445684466844768448684496845068451684526845368454684556845668457684586845968460684616846268463684646846568466684676846868469684706847168472684736847468475684766847768478684796848068481684826848368484684856848668487684886848968490684916849268493684946849568496684976849868499685006850168502685036850468505685066850768508685096851068511685126851368514685156851668517685186851968520685216852268523685246852568526685276852868529685306853168532685336853468535685366853768538685396854068541685426854368544685456854668547685486854968550685516855268553685546855568556685576855868559685606856168562685636856468565685666856768568685696857068571685726857368574685756857668577685786857968580685816858268583685846858568586685876858868589685906859168592685936859468595685966859768598685996860068601686026860368604686056860668607686086860968610686116861268613686146861568616686176861868619686206862168622686236862468625686266862768628686296863068631686326863368634686356863668637686386863968640686416864268643686446864568646686476864868649686506865168652686536865468655686566865768658686596866068661686626866368664686656866668667686686866968670686716867268673686746867568676686776867868679686806868168682686836868468685686866868768688686896869068691686926869368694686956869668697686986869968700687016870268703687046870568706687076870868709687106871168712687136871468715687166871768718687196872068721687226872368724687256872668727687286872968730687316873268733687346873568736687376873868739687406874168742687436874468745687466874768748687496875068751687526875368754687556875668757687586875968760687616876268763687646876568766687676876868769687706877168772687736877468775687766877768778687796878068781687826878368784687856878668787687886878968790687916879268793687946879568796687976879868799688006880168802688036880468805688066880768808688096881068811688126881368814688156881668817688186881968820688216882268823688246882568826688276882868829688306883168832688336883468835688366883768838688396884068841688426884368844688456884668847688486884968850688516885268853688546885568856688576885868859688606886168862688636886468865688666886768868688696887068871688726887368874688756887668877688786887968880688816888268883688846888568886688876888868889688906889168892688936889468895688966889768898688996890068901689026890368904689056890668907689086890968910689116891268913689146891568916689176891868919689206892168922689236892468925689266892768928689296893068931689326893368934689356893668937689386893968940689416894268943689446894568946689476894868949689506895168952689536895468955689566895768958689596896068961689626896368964689656896668967689686896968970689716897268973689746897568976689776897868979689806898168982689836898468985689866898768988689896899068991689926899368994689956899668997689986899969000690016900269003690046900569006690076900869009690106901169012690136901469015690166901769018690196902069021690226902369024690256902669027690286902969030690316903269033690346903569036690376903869039690406904169042690436904469045690466904769048690496905069051690526905369054690556905669057690586905969060690616906269063690646906569066690676906869069690706907169072690736907469075690766907769078690796908069081690826908369084690856908669087690886908969090690916909269093690946909569096690976909869099691006910169102691036910469105691066910769108691096911069111691126911369114691156911669117691186911969120691216912269123691246912569126691276912869129691306913169132691336913469135691366913769138691396914069141691426914369144691456914669147691486914969150691516915269153691546915569156691576915869159691606916169162691636916469165691666916769168691696917069171691726917369174691756917669177691786917969180691816918269183691846918569186691876918869189691906919169192691936919469195691966919769198691996920069201692026920369204692056920669207692086920969210692116921269213692146921569216692176921869219692206922169222692236922469225692266922769228692296923069231692326923369234692356923669237692386923969240692416924269243692446924569246692476924869249692506925169252692536925469255692566925769258692596926069261692626926369264692656926669267692686926969270692716927269273692746927569276692776927869279692806928169282692836928469285692866928769288692896929069291692926929369294692956929669297692986929969300693016930269303693046930569306693076930869309693106931169312693136931469315693166931769318693196932069321693226932369324693256932669327693286932969330693316933269333693346933569336693376933869339693406934169342693436934469345693466934769348693496935069351693526935369354693556935669357693586935969360693616936269363693646936569366693676936869369693706937169372693736937469375693766937769378693796938069381693826938369384693856938669387693886938969390693916939269393693946939569396693976939869399694006940169402694036940469405694066940769408694096941069411694126941369414694156941669417694186941969420694216942269423694246942569426694276942869429694306943169432694336943469435694366943769438694396944069441694426944369444694456944669447694486944969450694516945269453694546945569456694576945869459694606946169462694636946469465694666946769468694696947069471694726947369474694756947669477694786947969480694816948269483694846948569486694876948869489694906949169492694936949469495694966949769498694996950069501695026950369504695056950669507695086950969510695116951269513695146951569516695176951869519695206952169522695236952469525695266952769528695296953069531695326953369534695356953669537695386953969540695416954269543695446954569546695476954869549695506955169552695536955469555695566955769558695596956069561695626956369564695656956669567695686956969570695716957269573695746957569576695776957869579695806958169582695836958469585695866958769588695896959069591695926959369594695956959669597695986959969600696016960269603696046960569606696076960869609696106961169612696136961469615696166961769618696196962069621696226962369624696256962669627696286962969630696316963269633696346963569636696376963869639696406964169642696436964469645696466964769648696496965069651696526965369654696556965669657696586965969660696616966269663696646966569666696676966869669696706967169672696736967469675696766967769678696796968069681696826968369684696856968669687696886968969690696916969269693696946969569696696976969869699697006970169702697036970469705697066970769708697096971069711697126971369714697156971669717697186971969720697216972269723697246972569726697276972869729697306973169732697336973469735697366973769738697396974069741697426974369744697456974669747697486974969750697516975269753697546975569756697576975869759697606976169762697636976469765697666976769768697696977069771697726977369774697756977669777697786977969780697816978269783697846978569786697876978869789697906979169792697936979469795697966979769798697996980069801698026980369804698056980669807698086980969810698116981269813698146981569816698176981869819698206982169822698236982469825698266982769828698296983069831698326983369834698356983669837698386983969840698416984269843698446984569846698476984869849698506985169852698536985469855698566985769858698596986069861698626986369864698656986669867698686986969870698716987269873698746987569876698776987869879698806988169882698836988469885698866988769888698896989069891698926989369894698956989669897698986989969900699016990269903699046990569906699076990869909699106991169912699136991469915699166991769918699196992069921699226992369924699256992669927699286992969930699316993269933699346993569936699376993869939699406994169942699436994469945699466994769948699496995069951699526995369954699556995669957699586995969960699616996269963699646996569966699676996869969699706997169972699736997469975699766997769978699796998069981699826998369984699856998669987699886998969990699916999269993699946999569996699976999869999700007000170002700037000470005700067000770008700097001070011700127001370014700157001670017700187001970020700217002270023700247002570026700277002870029700307003170032700337003470035700367003770038700397004070041700427004370044700457004670047700487004970050700517005270053700547005570056700577005870059700607006170062700637006470065700667006770068700697007070071700727007370074700757007670077700787007970080700817008270083700847008570086700877008870089700907009170092700937009470095700967009770098700997010070101701027010370104701057010670107701087010970110701117011270113701147011570116701177011870119701207012170122701237012470125701267012770128701297013070131701327013370134701357013670137701387013970140701417014270143701447014570146701477014870149701507015170152701537015470155701567015770158701597016070161701627016370164701657016670167701687016970170701717017270173701747017570176701777017870179701807018170182701837018470185701867018770188701897019070191701927019370194701957019670197701987019970200702017020270203702047020570206702077020870209702107021170212702137021470215702167021770218702197022070221702227022370224702257022670227702287022970230702317023270233702347023570236702377023870239702407024170242702437024470245702467024770248702497025070251702527025370254702557025670257702587025970260702617026270263702647026570266702677026870269702707027170272702737027470275702767027770278702797028070281702827028370284702857028670287702887028970290702917029270293702947029570296702977029870299703007030170302703037030470305703067030770308703097031070311703127031370314703157031670317703187031970320703217032270323703247032570326703277032870329703307033170332703337033470335703367033770338703397034070341703427034370344703457034670347703487034970350703517035270353703547035570356703577035870359703607036170362703637036470365703667036770368703697037070371703727037370374703757037670377703787037970380703817038270383703847038570386703877038870389703907039170392703937039470395703967039770398703997040070401704027040370404704057040670407704087040970410704117041270413704147041570416704177041870419704207042170422704237042470425704267042770428704297043070431704327043370434704357043670437704387043970440704417044270443704447044570446704477044870449704507045170452704537045470455704567045770458704597046070461704627046370464704657046670467704687046970470704717047270473704747047570476704777047870479704807048170482704837048470485704867048770488704897049070491704927049370494704957049670497704987049970500705017050270503705047050570506705077050870509705107051170512705137051470515705167051770518705197052070521705227052370524705257052670527705287052970530705317053270533705347053570536705377053870539705407054170542705437054470545705467054770548705497055070551705527055370554705557055670557705587055970560705617056270563705647056570566705677056870569705707057170572705737057470575705767057770578705797058070581705827058370584705857058670587705887058970590705917059270593705947059570596705977059870599706007060170602706037060470605706067060770608706097061070611706127061370614706157061670617706187061970620706217062270623706247062570626706277062870629706307063170632706337063470635706367063770638706397064070641706427064370644706457064670647706487064970650706517065270653706547065570656706577065870659706607066170662706637066470665706667066770668706697067070671706727067370674706757067670677706787067970680706817068270683706847068570686706877068870689706907069170692706937069470695706967069770698706997070070701707027070370704707057070670707707087070970710707117071270713707147071570716707177071870719707207072170722707237072470725707267072770728707297073070731707327073370734707357073670737707387073970740707417074270743707447074570746707477074870749707507075170752707537075470755707567075770758707597076070761707627076370764707657076670767707687076970770707717077270773707747077570776707777077870779707807078170782707837078470785707867078770788707897079070791707927079370794707957079670797707987079970800708017080270803708047080570806708077080870809708107081170812708137081470815708167081770818708197082070821708227082370824708257082670827708287082970830708317083270833708347083570836708377083870839708407084170842708437084470845708467084770848708497085070851708527085370854708557085670857708587085970860708617086270863708647086570866708677086870869708707087170872708737087470875708767087770878708797088070881708827088370884708857088670887708887088970890708917089270893708947089570896708977089870899709007090170902709037090470905709067090770908709097091070911709127091370914709157091670917709187091970920709217092270923709247092570926709277092870929709307093170932709337093470935709367093770938709397094070941709427094370944709457094670947709487094970950709517095270953709547095570956709577095870959709607096170962709637096470965709667096770968709697097070971709727097370974709757097670977709787097970980709817098270983709847098570986709877098870989709907099170992709937099470995709967099770998709997100071001710027100371004710057100671007710087100971010710117101271013710147101571016710177101871019710207102171022710237102471025710267102771028710297103071031710327103371034710357103671037710387103971040710417104271043710447104571046710477104871049710507105171052710537105471055710567105771058710597106071061710627106371064710657106671067710687106971070710717107271073710747107571076710777107871079710807108171082710837108471085710867108771088710897109071091710927109371094710957109671097710987109971100711017110271103711047110571106711077110871109711107111171112711137111471115711167111771118711197112071121711227112371124711257112671127711287112971130711317113271133711347113571136711377113871139711407114171142711437114471145711467114771148711497115071151711527115371154711557115671157711587115971160711617116271163711647116571166711677116871169711707117171172711737117471175711767117771178711797118071181711827118371184711857118671187711887118971190711917119271193711947119571196711977119871199712007120171202712037120471205712067120771208712097121071211712127121371214712157121671217712187121971220712217122271223712247122571226712277122871229712307123171232712337123471235712367123771238712397124071241712427124371244712457124671247712487124971250712517125271253712547125571256712577125871259712607126171262712637126471265712667126771268712697127071271712727127371274712757127671277712787127971280712817128271283712847128571286712877128871289712907129171292712937129471295712967129771298712997130071301713027130371304713057130671307713087130971310713117131271313713147131571316713177131871319713207132171322713237132471325713267132771328713297133071331713327133371334713357133671337713387133971340713417134271343713447134571346713477134871349713507135171352713537135471355713567135771358713597136071361713627136371364713657136671367713687136971370713717137271373713747137571376713777137871379713807138171382713837138471385713867138771388713897139071391713927139371394713957139671397713987139971400714017140271403714047140571406714077140871409714107141171412714137141471415714167141771418714197142071421714227142371424714257142671427714287142971430714317143271433714347143571436714377143871439714407144171442714437144471445714467144771448714497145071451714527145371454714557145671457714587145971460714617146271463714647146571466714677146871469714707147171472714737147471475714767147771478714797148071481714827148371484714857148671487714887148971490714917149271493714947149571496714977149871499715007150171502715037150471505715067150771508715097151071511715127151371514715157151671517715187151971520715217152271523715247152571526715277152871529715307153171532715337153471535715367153771538715397154071541715427154371544715457154671547715487154971550715517155271553715547155571556715577155871559715607156171562715637156471565715667156771568715697157071571715727157371574715757157671577715787157971580715817158271583715847158571586715877158871589715907159171592715937159471595715967159771598715997160071601716027160371604716057160671607716087160971610716117161271613716147161571616716177161871619716207162171622716237162471625716267162771628716297163071631716327163371634716357163671637716387163971640716417164271643716447164571646716477164871649716507165171652716537165471655716567165771658716597166071661716627166371664716657166671667716687166971670716717167271673716747167571676716777167871679716807168171682716837168471685716867168771688716897169071691716927169371694716957169671697716987169971700717017170271703717047170571706717077170871709717107171171712717137171471715717167171771718717197172071721717227172371724717257172671727717287172971730717317173271733717347173571736717377173871739717407174171742717437174471745717467174771748717497175071751717527175371754717557175671757717587175971760717617176271763717647176571766717677176871769717707177171772717737177471775717767177771778717797178071781717827178371784717857178671787717887178971790717917179271793717947179571796717977179871799718007180171802718037180471805718067180771808718097181071811718127181371814718157181671817718187181971820718217182271823718247182571826718277182871829718307183171832718337183471835718367183771838718397184071841718427184371844718457184671847718487184971850718517185271853718547185571856718577185871859718607186171862718637186471865718667186771868718697187071871718727187371874718757187671877718787187971880718817188271883718847188571886718877188871889718907189171892718937189471895718967189771898718997190071901719027190371904719057190671907719087190971910719117191271913719147191571916719177191871919719207192171922719237192471925719267192771928719297193071931719327193371934719357193671937719387193971940719417194271943719447194571946719477194871949719507195171952719537195471955719567195771958719597196071961719627196371964719657196671967719687196971970719717197271973719747197571976719777197871979719807198171982719837198471985719867198771988719897199071991719927199371994719957199671997719987199972000720017200272003720047200572006720077200872009720107201172012720137201472015720167201772018720197202072021720227202372024720257202672027720287202972030720317203272033720347203572036720377203872039720407204172042720437204472045720467204772048720497205072051720527205372054720557205672057720587205972060720617206272063720647206572066720677206872069720707207172072720737207472075720767207772078720797208072081720827208372084720857208672087720887208972090720917209272093720947209572096720977209872099721007210172102721037210472105721067210772108721097211072111721127211372114721157211672117721187211972120721217212272123721247212572126721277212872129721307213172132721337213472135721367213772138721397214072141721427214372144721457214672147721487214972150721517215272153721547215572156721577215872159721607216172162721637216472165721667216772168721697217072171721727217372174721757217672177721787217972180721817218272183721847218572186721877218872189721907219172192721937219472195721967219772198721997220072201722027220372204722057220672207722087220972210722117221272213722147221572216722177221872219722207222172222722237222472225722267222772228722297223072231722327223372234722357223672237722387223972240722417224272243722447224572246722477224872249722507225172252722537225472255722567225772258722597226072261722627226372264722657226672267722687226972270722717227272273722747227572276722777227872279722807228172282722837228472285722867228772288722897229072291722927229372294722957229672297722987229972300723017230272303723047230572306723077230872309723107231172312723137231472315723167231772318723197232072321723227232372324723257232672327723287232972330723317233272333723347233572336723377233872339723407234172342723437234472345723467234772348723497235072351723527235372354723557235672357723587235972360723617236272363723647236572366723677236872369723707237172372723737237472375723767237772378723797238072381723827238372384723857238672387723887238972390723917239272393723947239572396723977239872399724007240172402724037240472405724067240772408724097241072411724127241372414724157241672417724187241972420724217242272423724247242572426724277242872429724307243172432724337243472435724367243772438724397244072441724427244372444724457244672447724487244972450724517245272453724547245572456724577245872459724607246172462724637246472465724667246772468724697247072471724727247372474724757247672477724787247972480724817248272483724847248572486724877248872489724907249172492724937249472495724967249772498724997250072501725027250372504725057250672507725087250972510725117251272513725147251572516725177251872519725207252172522725237252472525725267252772528725297253072531725327253372534725357253672537725387253972540725417254272543725447254572546725477254872549725507255172552725537255472555725567255772558725597256072561725627256372564725657256672567725687256972570725717257272573725747257572576725777257872579725807258172582725837258472585725867258772588725897259072591725927259372594725957259672597725987259972600726017260272603726047260572606726077260872609726107261172612726137261472615726167261772618726197262072621726227262372624726257262672627726287262972630726317263272633726347263572636726377263872639726407264172642726437264472645726467264772648726497265072651726527265372654726557265672657726587265972660726617266272663726647266572666726677266872669726707267172672726737267472675726767267772678726797268072681726827268372684726857268672687726887268972690726917269272693726947269572696726977269872699727007270172702727037270472705727067270772708727097271072711727127271372714727157271672717727187271972720727217272272723727247272572726727277272872729727307273172732727337273472735727367273772738727397274072741727427274372744727457274672747727487274972750727517275272753727547275572756727577275872759727607276172762727637276472765727667276772768727697277072771727727277372774727757277672777727787277972780727817278272783727847278572786727877278872789727907279172792727937279472795727967279772798727997280072801728027280372804728057280672807728087280972810728117281272813728147281572816728177281872819728207282172822728237282472825728267282772828728297283072831728327283372834728357283672837728387283972840728417284272843728447284572846728477284872849728507285172852728537285472855728567285772858728597286072861728627286372864728657286672867728687286972870728717287272873728747287572876728777287872879728807288172882728837288472885728867288772888728897289072891728927289372894728957289672897728987289972900729017290272903729047290572906729077290872909729107291172912729137291472915729167291772918729197292072921729227292372924729257292672927729287292972930729317293272933729347293572936729377293872939729407294172942729437294472945729467294772948729497295072951729527295372954729557295672957729587295972960729617296272963729647296572966729677296872969729707297172972729737297472975729767297772978729797298072981729827298372984729857298672987729887298972990729917299272993729947299572996729977299872999730007300173002730037300473005730067300773008730097301073011730127301373014730157301673017730187301973020730217302273023730247302573026730277302873029730307303173032730337303473035730367303773038730397304073041730427304373044730457304673047730487304973050730517305273053730547305573056730577305873059730607306173062730637306473065730667306773068730697307073071730727307373074730757307673077730787307973080730817308273083730847308573086730877308873089730907309173092730937309473095730967309773098730997310073101731027310373104731057310673107731087310973110731117311273113731147311573116731177311873119731207312173122731237312473125731267312773128731297313073131731327313373134731357313673137731387313973140731417314273143731447314573146731477314873149731507315173152731537315473155731567315773158731597316073161731627316373164731657316673167731687316973170731717317273173731747317573176731777317873179731807318173182731837318473185731867318773188731897319073191731927319373194731957319673197731987319973200732017320273203732047320573206732077320873209732107321173212732137321473215732167321773218732197322073221732227322373224732257322673227732287322973230732317323273233732347323573236732377323873239732407324173242732437324473245732467324773248732497325073251732527325373254732557325673257732587325973260732617326273263732647326573266732677326873269732707327173272732737327473275732767327773278732797328073281732827328373284732857328673287732887328973290732917329273293732947329573296732977329873299733007330173302733037330473305733067330773308733097331073311733127331373314733157331673317733187331973320733217332273323733247332573326733277332873329733307333173332733337333473335733367333773338733397334073341733427334373344733457334673347733487334973350733517335273353733547335573356733577335873359733607336173362733637336473365733667336773368733697337073371733727337373374733757337673377733787337973380733817338273383733847338573386733877338873389733907339173392733937339473395733967339773398733997340073401734027340373404734057340673407734087340973410734117341273413734147341573416734177341873419734207342173422734237342473425734267342773428734297343073431734327343373434734357343673437734387343973440734417344273443734447344573446734477344873449734507345173452734537345473455734567345773458734597346073461734627346373464734657346673467734687346973470734717347273473734747347573476734777347873479734807348173482734837348473485734867348773488734897349073491734927349373494734957349673497734987349973500735017350273503735047350573506735077350873509735107351173512735137351473515735167351773518735197352073521735227352373524735257352673527735287352973530735317353273533735347353573536735377353873539735407354173542735437354473545735467354773548735497355073551735527355373554735557355673557735587355973560735617356273563735647356573566735677356873569735707357173572735737357473575735767357773578735797358073581735827358373584735857358673587735887358973590735917359273593735947359573596735977359873599736007360173602736037360473605736067360773608736097361073611736127361373614736157361673617736187361973620736217362273623736247362573626736277362873629736307363173632736337363473635736367363773638736397364073641736427364373644736457364673647736487364973650736517365273653736547365573656736577365873659736607366173662736637366473665736667366773668736697367073671736727367373674736757367673677736787367973680736817368273683736847368573686736877368873689736907369173692736937369473695736967369773698736997370073701737027370373704737057370673707737087370973710737117371273713737147371573716737177371873719737207372173722737237372473725737267372773728737297373073731737327373373734737357373673737737387373973740737417374273743737447374573746737477374873749737507375173752737537375473755737567375773758737597376073761737627376373764737657376673767737687376973770737717377273773737747377573776737777377873779737807378173782737837378473785737867378773788737897379073791737927379373794737957379673797737987379973800738017380273803738047380573806738077380873809738107381173812738137381473815738167381773818738197382073821738227382373824738257382673827738287382973830738317383273833738347383573836738377383873839738407384173842738437384473845738467384773848738497385073851738527385373854738557385673857738587385973860738617386273863738647386573866738677386873869738707387173872738737387473875738767387773878738797388073881738827388373884738857388673887738887388973890738917389273893738947389573896738977389873899739007390173902739037390473905739067390773908739097391073911739127391373914739157391673917739187391973920739217392273923739247392573926739277392873929739307393173932739337393473935739367393773938739397394073941739427394373944739457394673947739487394973950739517395273953739547395573956739577395873959739607396173962739637396473965739667396773968739697397073971739727397373974739757397673977739787397973980739817398273983739847398573986739877398873989739907399173992739937399473995739967399773998739997400074001740027400374004740057400674007740087400974010740117401274013740147401574016740177401874019740207402174022740237402474025740267402774028740297403074031740327403374034740357403674037740387403974040740417404274043740447404574046740477404874049740507405174052740537405474055740567405774058740597406074061740627406374064740657406674067740687406974070740717407274073740747407574076740777407874079740807408174082740837408474085740867408774088740897409074091740927409374094740957409674097740987409974100741017410274103741047410574106741077410874109741107411174112741137411474115741167411774118741197412074121741227412374124741257412674127741287412974130741317413274133741347413574136741377413874139741407414174142741437414474145741467414774148741497415074151741527415374154741557415674157741587415974160741617416274163741647416574166741677416874169741707417174172741737417474175741767417774178741797418074181741827418374184741857418674187741887418974190741917419274193741947419574196741977419874199742007420174202742037420474205742067420774208742097421074211742127421374214742157421674217742187421974220742217422274223742247422574226742277422874229742307423174232742337423474235742367423774238742397424074241742427424374244742457424674247742487424974250742517425274253742547425574256742577425874259742607426174262742637426474265742667426774268742697427074271742727427374274742757427674277742787427974280742817428274283742847428574286742877428874289742907429174292742937429474295742967429774298742997430074301743027430374304743057430674307743087430974310743117431274313743147431574316743177431874319743207432174322743237432474325743267432774328743297433074331743327433374334743357433674337743387433974340743417434274343743447434574346743477434874349743507435174352743537435474355743567435774358743597436074361743627436374364743657436674367743687436974370743717437274373743747437574376743777437874379743807438174382743837438474385743867438774388743897439074391743927439374394743957439674397743987439974400744017440274403744047440574406744077440874409744107441174412744137441474415744167441774418744197442074421744227442374424744257442674427744287442974430744317443274433744347443574436744377443874439744407444174442744437444474445744467444774448744497445074451744527445374454744557445674457744587445974460744617446274463744647446574466744677446874469744707447174472744737447474475744767447774478744797448074481744827448374484744857448674487744887448974490744917449274493744947449574496744977449874499745007450174502745037450474505745067450774508745097451074511745127451374514745157451674517745187451974520745217452274523745247452574526745277452874529745307453174532745337453474535745367453774538745397454074541745427454374544745457454674547745487454974550745517455274553745547455574556745577455874559745607456174562745637456474565745667456774568745697457074571745727457374574745757457674577745787457974580745817458274583745847458574586745877458874589745907459174592745937459474595745967459774598745997460074601746027460374604746057460674607746087460974610746117461274613746147461574616746177461874619746207462174622746237462474625746267462774628746297463074631746327463374634746357463674637746387463974640746417464274643746447464574646746477464874649746507465174652746537465474655746567465774658746597466074661746627466374664746657466674667746687466974670746717467274673746747467574676746777467874679746807468174682746837468474685746867468774688746897469074691746927469374694746957469674697746987469974700747017470274703747047470574706747077470874709747107471174712747137471474715747167471774718747197472074721747227472374724747257472674727747287472974730747317473274733747347473574736747377473874739747407474174742747437474474745747467474774748747497475074751747527475374754747557475674757747587475974760747617476274763747647476574766747677476874769747707477174772747737477474775747767477774778747797478074781747827478374784747857478674787747887478974790747917479274793747947479574796747977479874799748007480174802748037480474805748067480774808748097481074811748127481374814748157481674817748187481974820748217482274823748247482574826748277482874829748307483174832748337483474835748367483774838748397484074841748427484374844748457484674847748487484974850748517485274853748547485574856748577485874859748607486174862748637486474865748667486774868748697487074871748727487374874748757487674877748787487974880748817488274883748847488574886748877488874889748907489174892748937489474895748967489774898748997490074901749027490374904749057490674907749087490974910749117491274913749147491574916749177491874919749207492174922749237492474925749267492774928749297493074931749327493374934749357493674937749387493974940749417494274943749447494574946749477494874949749507495174952749537495474955749567495774958749597496074961749627496374964749657496674967749687496974970749717497274973749747497574976749777497874979749807498174982749837498474985749867498774988749897499074991749927499374994749957499674997749987499975000750017500275003750047500575006750077500875009750107501175012750137501475015750167501775018750197502075021750227502375024750257502675027750287502975030750317503275033750347503575036750377503875039750407504175042750437504475045750467504775048750497505075051750527505375054750557505675057750587505975060750617506275063750647506575066750677506875069750707507175072750737507475075750767507775078750797508075081750827508375084750857508675087750887508975090750917509275093750947509575096750977509875099751007510175102751037510475105751067510775108751097511075111751127511375114751157511675117751187511975120751217512275123751247512575126751277512875129751307513175132751337513475135751367513775138751397514075141751427514375144751457514675147751487514975150751517515275153751547515575156751577515875159751607516175162751637516475165751667516775168751697517075171751727517375174751757517675177751787517975180751817518275183751847518575186751877518875189751907519175192751937519475195751967519775198751997520075201752027520375204752057520675207752087520975210752117521275213752147521575216752177521875219752207522175222752237522475225752267522775228752297523075231752327523375234752357523675237752387523975240752417524275243752447524575246752477524875249752507525175252752537525475255752567525775258752597526075261752627526375264752657526675267752687526975270752717527275273752747527575276752777527875279752807528175282752837528475285752867528775288752897529075291752927529375294752957529675297752987529975300753017530275303753047530575306753077530875309753107531175312753137531475315753167531775318753197532075321753227532375324753257532675327753287532975330753317533275333753347533575336753377533875339753407534175342753437534475345753467534775348753497535075351753527535375354753557535675357753587535975360753617536275363753647536575366753677536875369753707537175372753737537475375753767537775378753797538075381753827538375384753857538675387753887538975390753917539275393753947539575396753977539875399754007540175402754037540475405754067540775408754097541075411754127541375414754157541675417754187541975420754217542275423754247542575426754277542875429754307543175432754337543475435754367543775438754397544075441754427544375444754457544675447754487544975450754517545275453754547545575456754577545875459754607546175462754637546475465754667546775468754697547075471754727547375474754757547675477754787547975480754817548275483754847548575486754877548875489754907549175492754937549475495754967549775498754997550075501755027550375504755057550675507755087550975510755117551275513755147551575516755177551875519755207552175522755237552475525755267552775528755297553075531755327553375534755357553675537755387553975540755417554275543755447554575546755477554875549755507555175552755537555475555755567555775558755597556075561755627556375564755657556675567755687556975570755717557275573755747557575576755777557875579755807558175582755837558475585755867558775588755897559075591755927559375594755957559675597755987559975600756017560275603756047560575606756077560875609756107561175612756137561475615756167561775618756197562075621756227562375624756257562675627756287562975630756317563275633756347563575636756377563875639756407564175642756437564475645756467564775648756497565075651756527565375654756557565675657756587565975660756617566275663756647566575666756677566875669756707567175672756737567475675756767567775678756797568075681756827568375684756857568675687756887568975690756917569275693756947569575696756977569875699757007570175702757037570475705757067570775708757097571075711757127571375714757157571675717757187571975720757217572275723757247572575726757277572875729757307573175732757337573475735757367573775738757397574075741757427574375744757457574675747757487574975750757517575275753757547575575756757577575875759757607576175762757637576475765757667576775768757697577075771757727577375774757757577675777757787577975780757817578275783757847578575786757877578875789757907579175792757937579475795757967579775798757997580075801758027580375804758057580675807758087580975810758117581275813758147581575816758177581875819758207582175822758237582475825758267582775828758297583075831758327583375834758357583675837758387583975840758417584275843758447584575846758477584875849758507585175852758537585475855758567585775858758597586075861758627586375864758657586675867758687586975870758717587275873758747587575876758777587875879758807588175882758837588475885758867588775888758897589075891758927589375894758957589675897758987589975900759017590275903759047590575906759077590875909759107591175912759137591475915759167591775918759197592075921759227592375924759257592675927759287592975930759317593275933759347593575936759377593875939759407594175942759437594475945759467594775948759497595075951759527595375954759557595675957759587595975960759617596275963759647596575966759677596875969759707597175972759737597475975759767597775978759797598075981759827598375984759857598675987759887598975990759917599275993759947599575996759977599875999760007600176002760037600476005760067600776008760097601076011760127601376014760157601676017760187601976020760217602276023760247602576026760277602876029760307603176032760337603476035760367603776038760397604076041760427604376044760457604676047760487604976050760517605276053760547605576056760577605876059760607606176062760637606476065760667606776068760697607076071760727607376074760757607676077760787607976080760817608276083760847608576086760877608876089760907609176092760937609476095760967609776098760997610076101761027610376104761057610676107761087610976110761117611276113761147611576116761177611876119761207612176122761237612476125761267612776128761297613076131761327613376134761357613676137761387613976140761417614276143761447614576146761477614876149761507615176152761537615476155761567615776158761597616076161761627616376164761657616676167761687616976170761717617276173761747617576176761777617876179761807618176182761837618476185761867618776188761897619076191761927619376194761957619676197761987619976200762017620276203762047620576206762077620876209762107621176212762137621476215762167621776218762197622076221762227622376224762257622676227762287622976230762317623276233762347623576236762377623876239762407624176242762437624476245762467624776248762497625076251762527625376254762557625676257762587625976260762617626276263762647626576266762677626876269762707627176272762737627476275762767627776278762797628076281762827628376284762857628676287762887628976290762917629276293762947629576296762977629876299763007630176302763037630476305763067630776308763097631076311763127631376314763157631676317763187631976320763217632276323763247632576326763277632876329763307633176332763337633476335763367633776338763397634076341763427634376344763457634676347763487634976350763517635276353763547635576356763577635876359763607636176362763637636476365763667636776368763697637076371763727637376374763757637676377763787637976380763817638276383763847638576386763877638876389763907639176392763937639476395763967639776398763997640076401764027640376404764057640676407764087640976410764117641276413764147641576416764177641876419764207642176422764237642476425764267642776428764297643076431764327643376434764357643676437764387643976440764417644276443764447644576446764477644876449764507645176452764537645476455764567645776458764597646076461764627646376464764657646676467764687646976470764717647276473764747647576476764777647876479764807648176482764837648476485764867648776488764897649076491764927649376494764957649676497764987649976500765017650276503765047650576506765077650876509765107651176512765137651476515765167651776518765197652076521765227652376524765257652676527765287652976530765317653276533765347653576536765377653876539765407654176542765437654476545765467654776548765497655076551765527655376554765557655676557765587655976560765617656276563765647656576566765677656876569765707657176572765737657476575765767657776578765797658076581765827658376584765857658676587765887658976590765917659276593765947659576596765977659876599766007660176602766037660476605766067660776608766097661076611766127661376614766157661676617766187661976620766217662276623766247662576626766277662876629766307663176632766337663476635766367663776638766397664076641766427664376644766457664676647766487664976650766517665276653766547665576656766577665876659766607666176662766637666476665766667666776668766697667076671766727667376674766757667676677766787667976680766817668276683766847668576686766877668876689766907669176692766937669476695766967669776698766997670076701767027670376704767057670676707767087670976710767117671276713767147671576716767177671876719767207672176722767237672476725767267672776728767297673076731767327673376734767357673676737767387673976740767417674276743767447674576746767477674876749767507675176752767537675476755767567675776758767597676076761767627676376764767657676676767767687676976770767717677276773767747677576776767777677876779767807678176782767837678476785767867678776788767897679076791767927679376794767957679676797767987679976800768017680276803768047680576806768077680876809768107681176812768137681476815768167681776818768197682076821768227682376824768257682676827768287682976830768317683276833768347683576836768377683876839768407684176842768437684476845768467684776848768497685076851768527685376854768557685676857768587685976860768617686276863768647686576866768677686876869768707687176872768737687476875768767687776878768797688076881768827688376884768857688676887768887688976890768917689276893768947689576896768977689876899769007690176902769037690476905769067690776908769097691076911769127691376914769157691676917769187691976920769217692276923769247692576926769277692876929769307693176932769337693476935769367693776938769397694076941769427694376944769457694676947769487694976950769517695276953769547695576956769577695876959769607696176962769637696476965769667696776968769697697076971769727697376974769757697676977769787697976980769817698276983769847698576986769877698876989769907699176992769937699476995769967699776998769997700077001770027700377004770057700677007770087700977010770117701277013770147701577016770177701877019770207702177022770237702477025770267702777028770297703077031770327703377034770357703677037770387703977040770417704277043770447704577046770477704877049770507705177052770537705477055770567705777058770597706077061770627706377064770657706677067770687706977070770717707277073770747707577076770777707877079770807708177082770837708477085770867708777088770897709077091770927709377094770957709677097770987709977100771017710277103771047710577106771077710877109771107711177112771137711477115771167711777118771197712077121771227712377124771257712677127771287712977130771317713277133771347713577136771377713877139771407714177142771437714477145771467714777148771497715077151771527715377154771557715677157771587715977160771617716277163771647716577166771677716877169771707717177172771737717477175771767717777178771797718077181771827718377184771857718677187771887718977190771917719277193771947719577196771977719877199772007720177202772037720477205772067720777208772097721077211772127721377214772157721677217772187721977220772217722277223772247722577226772277722877229772307723177232772337723477235772367723777238772397724077241772427724377244772457724677247772487724977250772517725277253772547725577256772577725877259772607726177262772637726477265772667726777268772697727077271772727727377274772757727677277772787727977280772817728277283772847728577286772877728877289772907729177292772937729477295772967729777298772997730077301773027730377304773057730677307773087730977310773117731277313773147731577316773177731877319773207732177322773237732477325773267732777328773297733077331773327733377334773357733677337773387733977340773417734277343773447734577346773477734877349773507735177352773537735477355773567735777358773597736077361773627736377364773657736677367773687736977370773717737277373773747737577376773777737877379773807738177382773837738477385773867738777388773897739077391773927739377394773957739677397773987739977400774017740277403774047740577406774077740877409774107741177412774137741477415774167741777418774197742077421774227742377424774257742677427774287742977430774317743277433774347743577436774377743877439774407744177442774437744477445774467744777448774497745077451774527745377454774557745677457774587745977460774617746277463774647746577466774677746877469774707747177472774737747477475774767747777478774797748077481774827748377484774857748677487774887748977490774917749277493774947749577496774977749877499775007750177502775037750477505775067750777508775097751077511775127751377514775157751677517775187751977520775217752277523775247752577526775277752877529775307753177532775337753477535775367753777538775397754077541775427754377544775457754677547775487754977550775517755277553775547755577556775577755877559775607756177562775637756477565775667756777568775697757077571775727757377574775757757677577775787757977580775817758277583775847758577586775877758877589775907759177592775937759477595775967759777598775997760077601776027760377604776057760677607776087760977610776117761277613776147761577616776177761877619776207762177622776237762477625776267762777628776297763077631776327763377634776357763677637776387763977640776417764277643776447764577646776477764877649776507765177652776537765477655776567765777658776597766077661776627766377664776657766677667776687766977670776717767277673776747767577676776777767877679776807768177682776837768477685776867768777688776897769077691776927769377694776957769677697776987769977700777017770277703777047770577706777077770877709777107771177712777137771477715777167771777718777197772077721777227772377724777257772677727777287772977730777317773277733777347773577736777377773877739777407774177742777437774477745777467774777748777497775077751777527775377754777557775677757777587775977760777617776277763777647776577766777677776877769777707777177772777737777477775777767777777778777797778077781777827778377784777857778677787777887778977790777917779277793777947779577796777977779877799778007780177802778037780477805778067780777808778097781077811778127781377814778157781677817778187781977820778217782277823778247782577826778277782877829778307783177832778337783477835778367783777838778397784077841778427784377844778457784677847778487784977850778517785277853778547785577856778577785877859778607786177862778637786477865778667786777868778697787077871778727787377874778757787677877778787787977880778817788277883778847788577886778877788877889778907789177892778937789477895778967789777898778997790077901779027790377904779057790677907779087790977910779117791277913779147791577916779177791877919779207792177922779237792477925779267792777928779297793077931779327793377934779357793677937779387793977940779417794277943779447794577946779477794877949779507795177952779537795477955779567795777958779597796077961779627796377964779657796677967779687796977970779717797277973779747797577976779777797877979779807798177982779837798477985779867798777988779897799077991779927799377994779957799677997779987799978000780017800278003780047800578006780077800878009780107801178012780137801478015780167801778018780197802078021780227802378024780257802678027780287802978030780317803278033780347803578036780377803878039780407804178042780437804478045780467804778048780497805078051780527805378054780557805678057780587805978060780617806278063780647806578066780677806878069780707807178072780737807478075780767807778078780797808078081780827808378084780857808678087780887808978090780917809278093780947809578096780977809878099781007810178102781037810478105781067810778108781097811078111781127811378114781157811678117781187811978120781217812278123781247812578126781277812878129781307813178132781337813478135781367813778138781397814078141781427814378144781457814678147781487814978150781517815278153781547815578156781577815878159781607816178162781637816478165781667816778168781697817078171781727817378174781757817678177781787817978180781817818278183781847818578186781877818878189781907819178192781937819478195781967819778198781997820078201782027820378204782057820678207782087820978210782117821278213782147821578216782177821878219782207822178222782237822478225782267822778228782297823078231782327823378234782357823678237782387823978240782417824278243782447824578246782477824878249782507825178252782537825478255782567825778258782597826078261782627826378264782657826678267782687826978270782717827278273782747827578276782777827878279782807828178282782837828478285782867828778288782897829078291782927829378294782957829678297782987829978300783017830278303783047830578306783077830878309783107831178312783137831478315783167831778318783197832078321783227832378324783257832678327783287832978330783317833278333783347833578336783377833878339783407834178342783437834478345783467834778348783497835078351783527835378354783557835678357783587835978360783617836278363783647836578366783677836878369783707837178372783737837478375783767837778378783797838078381783827838378384783857838678387783887838978390783917839278393783947839578396783977839878399784007840178402784037840478405784067840778408784097841078411784127841378414784157841678417784187841978420784217842278423784247842578426784277842878429784307843178432784337843478435784367843778438784397844078441784427844378444784457844678447784487844978450784517845278453784547845578456784577845878459784607846178462784637846478465784667846778468784697847078471784727847378474784757847678477784787847978480784817848278483784847848578486784877848878489784907849178492784937849478495784967849778498784997850078501785027850378504785057850678507785087850978510785117851278513785147851578516785177851878519785207852178522785237852478525785267852778528785297853078531785327853378534785357853678537785387853978540785417854278543785447854578546785477854878549785507855178552785537855478555785567855778558785597856078561785627856378564785657856678567785687856978570785717857278573785747857578576785777857878579785807858178582785837858478585785867858778588785897859078591785927859378594785957859678597785987859978600786017860278603786047860578606786077860878609786107861178612786137861478615786167861778618786197862078621786227862378624786257862678627786287862978630786317863278633786347863578636786377863878639786407864178642786437864478645786467864778648786497865078651786527865378654786557865678657786587865978660786617866278663786647866578666786677866878669786707867178672786737867478675786767867778678786797868078681786827868378684786857868678687786887868978690786917869278693786947869578696786977869878699787007870178702787037870478705787067870778708787097871078711787127871378714787157871678717787187871978720787217872278723787247872578726787277872878729787307873178732787337873478735787367873778738787397874078741787427874378744787457874678747787487874978750787517875278753787547875578756787577875878759787607876178762787637876478765787667876778768787697877078771787727877378774787757877678777787787877978780787817878278783787847878578786787877878878789787907879178792787937879478795787967879778798787997880078801788027880378804788057880678807788087880978810788117881278813788147881578816788177881878819788207882178822788237882478825788267882778828788297883078831788327883378834788357883678837788387883978840788417884278843788447884578846788477884878849788507885178852788537885478855788567885778858788597886078861788627886378864788657886678867788687886978870788717887278873788747887578876788777887878879788807888178882788837888478885788867888778888788897889078891788927889378894788957889678897788987889978900789017890278903789047890578906789077890878909789107891178912789137891478915789167891778918789197892078921789227892378924789257892678927789287892978930789317893278933789347893578936789377893878939789407894178942789437894478945789467894778948789497895078951789527895378954789557895678957789587895978960789617896278963789647896578966789677896878969789707897178972789737897478975789767897778978789797898078981789827898378984789857898678987789887898978990789917899278993789947899578996789977899878999790007900179002790037900479005790067900779008790097901079011790127901379014790157901679017790187901979020790217902279023790247902579026790277902879029790307903179032790337903479035790367903779038790397904079041790427904379044790457904679047790487904979050790517905279053790547905579056790577905879059790607906179062790637906479065790667906779068790697907079071790727907379074790757907679077790787907979080790817908279083790847908579086790877908879089790907909179092790937909479095790967909779098790997910079101791027910379104791057910679107791087910979110791117911279113791147911579116791177911879119791207912179122791237912479125791267912779128791297913079131791327913379134791357913679137791387913979140791417914279143791447914579146791477914879149791507915179152791537915479155791567915779158791597916079161791627916379164791657916679167791687916979170791717917279173791747917579176791777917879179791807918179182791837918479185791867918779188791897919079191791927919379194791957919679197791987919979200792017920279203792047920579206792077920879209792107921179212792137921479215792167921779218792197922079221792227922379224792257922679227792287922979230792317923279233792347923579236792377923879239792407924179242792437924479245792467924779248792497925079251792527925379254792557925679257792587925979260792617926279263792647926579266792677926879269792707927179272792737927479275792767927779278792797928079281792827928379284792857928679287792887928979290792917929279293792947929579296792977929879299793007930179302793037930479305793067930779308793097931079311793127931379314793157931679317793187931979320793217932279323793247932579326793277932879329793307933179332793337933479335793367933779338793397934079341793427934379344793457934679347793487934979350793517935279353793547935579356793577935879359793607936179362793637936479365793667936779368793697937079371793727937379374793757937679377793787937979380793817938279383793847938579386793877938879389793907939179392793937939479395793967939779398793997940079401794027940379404794057940679407794087940979410794117941279413794147941579416794177941879419794207942179422794237942479425794267942779428794297943079431794327943379434794357943679437794387943979440794417944279443794447944579446794477944879449794507945179452794537945479455794567945779458794597946079461794627946379464794657946679467794687946979470794717947279473794747947579476794777947879479794807948179482794837948479485794867948779488794897949079491794927949379494794957949679497794987949979500795017950279503795047950579506795077950879509795107951179512795137951479515795167951779518795197952079521795227952379524795257952679527795287952979530795317953279533795347953579536795377953879539795407954179542795437954479545795467954779548795497955079551795527955379554795557955679557795587955979560795617956279563795647956579566795677956879569795707957179572795737957479575795767957779578795797958079581795827958379584795857958679587795887958979590795917959279593795947959579596795977959879599796007960179602796037960479605796067960779608796097961079611796127961379614796157961679617796187961979620796217962279623796247962579626796277962879629796307963179632796337963479635796367963779638796397964079641796427964379644796457964679647796487964979650796517965279653796547965579656796577965879659796607966179662796637966479665796667966779668796697967079671796727967379674796757967679677796787967979680796817968279683796847968579686796877968879689796907969179692796937969479695796967969779698796997970079701797027970379704797057970679707797087970979710797117971279713797147971579716797177971879719797207972179722797237972479725797267972779728797297973079731797327973379734797357973679737797387973979740797417974279743797447974579746797477974879749797507975179752797537975479755797567975779758797597976079761797627976379764797657976679767797687976979770797717977279773797747977579776797777977879779797807978179782797837978479785797867978779788797897979079791797927979379794797957979679797797987979979800798017980279803798047980579806798077980879809798107981179812798137981479815798167981779818798197982079821798227982379824798257982679827798287982979830798317983279833798347983579836798377983879839798407984179842798437984479845798467984779848798497985079851798527985379854798557985679857798587985979860798617986279863798647986579866798677986879869798707987179872798737987479875798767987779878798797988079881798827988379884798857988679887798887988979890798917989279893798947989579896798977989879899799007990179902799037990479905799067990779908799097991079911799127991379914799157991679917799187991979920799217992279923799247992579926799277992879929799307993179932799337993479935799367993779938799397994079941799427994379944799457994679947799487994979950799517995279953799547995579956799577995879959799607996179962799637996479965799667996779968799697997079971799727997379974799757997679977799787997979980799817998279983799847998579986799877998879989799907999179992799937999479995799967999779998799998000080001800028000380004800058000680007800088000980010800118001280013800148001580016800178001880019800208002180022800238002480025800268002780028800298003080031800328003380034800358003680037800388003980040800418004280043800448004580046800478004880049800508005180052800538005480055800568005780058800598006080061800628006380064800658006680067800688006980070800718007280073800748007580076800778007880079800808008180082800838008480085800868008780088800898009080091800928009380094800958009680097800988009980100801018010280103801048010580106801078010880109801108011180112801138011480115801168011780118801198012080121801228012380124801258012680127801288012980130801318013280133801348013580136801378013880139801408014180142801438014480145801468014780148801498015080151801528015380154801558015680157801588015980160801618016280163801648016580166801678016880169801708017180172801738017480175801768017780178801798018080181801828018380184801858018680187801888018980190801918019280193801948019580196801978019880199802008020180202802038020480205802068020780208802098021080211802128021380214802158021680217802188021980220802218022280223802248022580226802278022880229802308023180232802338023480235802368023780238802398024080241802428024380244802458024680247802488024980250802518025280253802548025580256802578025880259802608026180262802638026480265802668026780268802698027080271802728027380274802758027680277802788027980280802818028280283802848028580286802878028880289802908029180292802938029480295802968029780298802998030080301803028030380304803058030680307803088030980310803118031280313803148031580316803178031880319803208032180322803238032480325803268032780328803298033080331803328033380334803358033680337803388033980340803418034280343803448034580346803478034880349803508035180352803538035480355803568035780358803598036080361803628036380364803658036680367803688036980370803718037280373803748037580376803778037880379803808038180382803838038480385803868038780388803898039080391803928039380394803958039680397803988039980400804018040280403804048040580406804078040880409804108041180412804138041480415804168041780418804198042080421804228042380424804258042680427804288042980430804318043280433804348043580436804378043880439804408044180442804438044480445804468044780448804498045080451804528045380454804558045680457804588045980460804618046280463804648046580466804678046880469804708047180472804738047480475804768047780478804798048080481804828048380484804858048680487804888048980490804918049280493804948049580496804978049880499805008050180502805038050480505805068050780508805098051080511805128051380514805158051680517805188051980520805218052280523805248052580526805278052880529805308053180532805338053480535805368053780538805398054080541805428054380544805458054680547805488054980550805518055280553805548055580556805578055880559805608056180562805638056480565805668056780568805698057080571805728057380574805758057680577805788057980580805818058280583805848058580586805878058880589805908059180592805938059480595805968059780598805998060080601806028060380604806058060680607806088060980610806118061280613806148061580616806178061880619806208062180622806238062480625806268062780628806298063080631806328063380634806358063680637806388063980640806418064280643806448064580646806478064880649806508065180652806538065480655806568065780658806598066080661806628066380664806658066680667806688066980670806718067280673806748067580676806778067880679806808068180682806838068480685806868068780688806898069080691806928069380694806958069680697806988069980700807018070280703807048070580706807078070880709807108071180712807138071480715807168071780718807198072080721807228072380724807258072680727807288072980730807318073280733807348073580736807378073880739807408074180742807438074480745807468074780748807498075080751807528075380754807558075680757807588075980760807618076280763807648076580766807678076880769807708077180772807738077480775807768077780778807798078080781807828078380784807858078680787807888078980790807918079280793807948079580796807978079880799808008080180802808038080480805808068080780808808098081080811808128081380814808158081680817808188081980820808218082280823808248082580826808278082880829808308083180832808338083480835808368083780838808398084080841808428084380844808458084680847808488084980850808518085280853808548085580856808578085880859808608086180862808638086480865808668086780868808698087080871808728087380874808758087680877808788087980880808818088280883808848088580886808878088880889808908089180892808938089480895808968089780898808998090080901809028090380904809058090680907809088090980910809118091280913809148091580916809178091880919809208092180922809238092480925809268092780928809298093080931809328093380934809358093680937809388093980940809418094280943809448094580946809478094880949809508095180952809538095480955809568095780958809598096080961809628096380964809658096680967809688096980970809718097280973809748097580976809778097880979809808098180982809838098480985809868098780988809898099080991809928099380994809958099680997809988099981000810018100281003810048100581006810078100881009810108101181012810138101481015810168101781018810198102081021810228102381024810258102681027810288102981030810318103281033810348103581036810378103881039810408104181042810438104481045810468104781048810498105081051810528105381054810558105681057810588105981060810618106281063810648106581066810678106881069810708107181072810738107481075810768107781078810798108081081810828108381084810858108681087810888108981090810918109281093810948109581096810978109881099811008110181102811038110481105811068110781108811098111081111811128111381114811158111681117811188111981120811218112281123811248112581126811278112881129811308113181132811338113481135811368113781138811398114081141811428114381144811458114681147811488114981150811518115281153811548115581156811578115881159811608116181162811638116481165811668116781168811698117081171811728117381174811758117681177811788117981180811818118281183811848118581186811878118881189811908119181192811938119481195811968119781198811998120081201812028120381204812058120681207812088120981210812118121281213812148121581216812178121881219812208122181222812238122481225812268122781228812298123081231812328123381234812358123681237812388123981240812418124281243812448124581246812478124881249812508125181252812538125481255812568125781258812598126081261812628126381264812658126681267812688126981270812718127281273812748127581276812778127881279812808128181282812838128481285812868128781288812898129081291812928129381294812958129681297812988129981300813018130281303813048130581306813078130881309813108131181312813138131481315813168131781318813198132081321813228132381324813258132681327813288132981330813318133281333813348133581336813378133881339813408134181342813438134481345813468134781348813498135081351813528135381354813558135681357813588135981360813618136281363813648136581366813678136881369813708137181372813738137481375813768137781378813798138081381813828138381384813858138681387813888138981390813918139281393813948139581396813978139881399814008140181402814038140481405814068140781408814098141081411814128141381414814158141681417814188141981420814218142281423814248142581426814278142881429814308143181432814338143481435814368143781438814398144081441814428144381444814458144681447814488144981450814518145281453814548145581456814578145881459814608146181462814638146481465814668146781468814698147081471814728147381474814758147681477814788147981480814818148281483814848148581486814878148881489814908149181492814938149481495814968149781498814998150081501815028150381504815058150681507815088150981510815118151281513815148151581516815178151881519815208152181522815238152481525815268152781528815298153081531815328153381534815358153681537815388153981540815418154281543815448154581546815478154881549815508155181552815538155481555815568155781558815598156081561815628156381564815658156681567815688156981570815718157281573815748157581576815778157881579815808158181582815838158481585815868158781588815898159081591815928159381594815958159681597815988159981600816018160281603816048160581606816078160881609816108161181612816138161481615816168161781618816198162081621816228162381624816258162681627816288162981630816318163281633816348163581636816378163881639816408164181642816438164481645816468164781648816498165081651816528165381654816558165681657816588165981660816618166281663816648166581666816678166881669816708167181672816738167481675816768167781678816798168081681816828168381684816858168681687816888168981690816918169281693816948169581696816978169881699817008170181702817038170481705817068170781708817098171081711817128171381714817158171681717817188171981720817218172281723817248172581726817278172881729817308173181732817338173481735817368173781738817398174081741817428174381744817458174681747817488174981750817518175281753817548175581756817578175881759817608176181762817638176481765817668176781768817698177081771817728177381774817758177681777817788177981780817818178281783817848178581786817878178881789817908179181792817938179481795817968179781798817998180081801818028180381804818058180681807818088180981810818118181281813818148181581816818178181881819818208182181822818238182481825818268182781828818298183081831818328183381834818358183681837818388183981840818418184281843818448184581846818478184881849818508185181852818538185481855818568185781858818598186081861818628186381864818658186681867818688186981870818718187281873818748187581876818778187881879818808188181882818838188481885818868188781888818898189081891818928189381894818958189681897818988189981900819018190281903819048190581906819078190881909819108191181912819138191481915819168191781918819198192081921819228192381924819258192681927819288192981930819318193281933819348193581936819378193881939819408194181942819438194481945819468194781948819498195081951819528195381954819558195681957819588195981960819618196281963819648196581966819678196881969819708197181972819738197481975819768197781978819798198081981819828198381984819858198681987819888198981990819918199281993819948199581996819978199881999820008200182002820038200482005820068200782008820098201082011820128201382014820158201682017820188201982020820218202282023820248202582026820278202882029820308203182032820338203482035820368203782038820398204082041820428204382044820458204682047820488204982050820518205282053820548205582056820578205882059820608206182062820638206482065820668206782068820698207082071820728207382074820758207682077820788207982080820818208282083820848208582086820878208882089820908209182092820938209482095820968209782098820998210082101821028210382104821058210682107821088210982110821118211282113821148211582116821178211882119821208212182122821238212482125821268212782128821298213082131821328213382134821358213682137821388213982140821418214282143821448214582146821478214882149821508215182152821538215482155821568215782158821598216082161821628216382164821658216682167821688216982170821718217282173821748217582176821778217882179821808218182182821838218482185821868218782188821898219082191821928219382194821958219682197821988219982200822018220282203822048220582206822078220882209822108221182212822138221482215822168221782218822198222082221822228222382224822258222682227822288222982230822318223282233822348223582236822378223882239822408224182242822438224482245822468224782248822498225082251822528225382254822558225682257822588225982260822618226282263822648226582266822678226882269822708227182272822738227482275822768227782278822798228082281822828228382284822858228682287822888228982290822918229282293822948229582296822978229882299823008230182302823038230482305823068230782308823098231082311823128231382314823158231682317823188231982320823218232282323823248232582326823278232882329823308233182332823338233482335823368233782338823398234082341823428234382344823458234682347823488234982350823518235282353823548235582356823578235882359823608236182362823638236482365823668236782368823698237082371823728237382374823758237682377823788237982380823818238282383823848238582386823878238882389823908239182392823938239482395823968239782398823998240082401824028240382404824058240682407824088240982410824118241282413824148241582416824178241882419824208242182422824238242482425824268242782428824298243082431824328243382434824358243682437824388243982440824418244282443824448244582446824478244882449824508245182452824538245482455824568245782458824598246082461824628246382464824658246682467824688246982470824718247282473824748247582476824778247882479824808248182482824838248482485824868248782488824898249082491824928249382494824958249682497824988249982500825018250282503825048250582506825078250882509825108251182512825138251482515825168251782518825198252082521825228252382524825258252682527825288252982530825318253282533825348253582536825378253882539825408254182542825438254482545825468254782548825498255082551825528255382554825558255682557825588255982560825618256282563825648256582566825678256882569825708257182572825738257482575825768257782578825798258082581825828258382584825858258682587825888258982590825918259282593825948259582596825978259882599826008260182602826038260482605826068260782608826098261082611826128261382614826158261682617826188261982620826218262282623826248262582626826278262882629826308263182632826338263482635826368263782638826398264082641826428264382644826458264682647826488264982650826518265282653826548265582656826578265882659826608266182662826638266482665826668266782668826698267082671826728267382674826758267682677826788267982680826818268282683826848268582686826878268882689826908269182692826938269482695826968269782698826998270082701827028270382704827058270682707827088270982710827118271282713827148271582716827178271882719827208272182722827238272482725827268272782728827298273082731827328273382734827358273682737827388273982740827418274282743827448274582746827478274882749827508275182752827538275482755827568275782758827598276082761827628276382764827658276682767827688276982770827718277282773827748277582776827778277882779827808278182782827838278482785827868278782788827898279082791827928279382794827958279682797827988279982800828018280282803828048280582806828078280882809828108281182812828138281482815828168281782818828198282082821828228282382824828258282682827828288282982830828318283282833828348283582836828378283882839828408284182842828438284482845828468284782848828498285082851828528285382854828558285682857828588285982860828618286282863828648286582866828678286882869828708287182872828738287482875828768287782878828798288082881828828288382884828858288682887828888288982890828918289282893828948289582896828978289882899829008290182902829038290482905829068290782908829098291082911829128291382914829158291682917829188291982920829218292282923829248292582926829278292882929829308293182932829338293482935829368293782938829398294082941829428294382944829458294682947829488294982950829518295282953829548295582956829578295882959829608296182962829638296482965829668296782968829698297082971829728297382974829758297682977829788297982980829818298282983829848298582986829878298882989829908299182992829938299482995829968299782998829998300083001830028300383004830058300683007830088300983010830118301283013830148301583016830178301883019830208302183022830238302483025830268302783028830298303083031830328303383034830358303683037830388303983040830418304283043830448304583046830478304883049830508305183052830538305483055830568305783058830598306083061830628306383064830658306683067830688306983070830718307283073830748307583076830778307883079830808308183082830838308483085830868308783088830898309083091830928309383094830958309683097830988309983100831018310283103831048310583106831078310883109831108311183112831138311483115831168311783118831198312083121831228312383124831258312683127831288312983130831318313283133831348313583136831378313883139831408314183142831438314483145831468314783148831498315083151831528315383154831558315683157831588315983160831618316283163831648316583166831678316883169831708317183172831738317483175831768317783178831798318083181831828318383184831858318683187831888318983190831918319283193831948319583196831978319883199832008320183202832038320483205832068320783208832098321083211832128321383214832158321683217832188321983220832218322283223832248322583226832278322883229832308323183232832338323483235832368323783238832398324083241832428324383244832458324683247832488324983250832518325283253832548325583256832578325883259832608326183262832638326483265832668326783268832698327083271832728327383274832758327683277832788327983280832818328283283832848328583286832878328883289832908329183292832938329483295832968329783298832998330083301833028330383304833058330683307833088330983310833118331283313833148331583316833178331883319833208332183322833238332483325833268332783328833298333083331833328333383334833358333683337833388333983340833418334283343833448334583346833478334883349833508335183352833538335483355833568335783358833598336083361833628336383364833658336683367833688336983370833718337283373833748337583376833778337883379833808338183382833838338483385833868338783388833898339083391833928339383394833958339683397833988339983400834018340283403834048340583406834078340883409834108341183412834138341483415834168341783418834198342083421834228342383424834258342683427834288342983430834318343283433834348343583436834378343883439834408344183442834438344483445834468344783448834498345083451834528345383454834558345683457834588345983460834618346283463834648346583466834678346883469834708347183472834738347483475834768347783478834798348083481834828348383484834858348683487834888348983490834918349283493834948349583496834978349883499835008350183502835038350483505835068350783508835098351083511835128351383514835158351683517835188351983520835218352283523835248352583526835278352883529835308353183532835338353483535835368353783538835398354083541835428354383544835458354683547835488354983550835518355283553835548355583556835578355883559835608356183562835638356483565835668356783568835698357083571835728357383574835758357683577835788357983580835818358283583835848358583586835878358883589835908359183592835938359483595835968359783598835998360083601836028360383604836058360683607836088360983610836118361283613836148361583616836178361883619836208362183622836238362483625836268362783628836298363083631836328363383634836358363683637836388363983640836418364283643836448364583646836478364883649836508365183652836538365483655836568365783658836598366083661836628366383664836658366683667836688366983670836718367283673836748367583676836778367883679836808368183682836838368483685836868368783688836898369083691836928369383694836958369683697836988369983700837018370283703837048370583706837078370883709837108371183712837138371483715837168371783718837198372083721837228372383724837258372683727837288372983730837318373283733837348373583736837378373883739837408374183742837438374483745837468374783748837498375083751837528375383754837558375683757837588375983760837618376283763837648376583766837678376883769837708377183772837738377483775837768377783778837798378083781837828378383784837858378683787837888378983790837918379283793837948379583796837978379883799838008380183802838038380483805838068380783808838098381083811838128381383814838158381683817838188381983820838218382283823838248382583826838278382883829838308383183832838338383483835838368383783838838398384083841838428384383844838458384683847838488384983850838518385283853838548385583856838578385883859838608386183862838638386483865838668386783868838698387083871838728387383874838758387683877838788387983880838818388283883838848388583886838878388883889838908389183892838938389483895838968389783898838998390083901839028390383904839058390683907839088390983910839118391283913839148391583916839178391883919839208392183922839238392483925839268392783928839298393083931839328393383934839358393683937839388393983940839418394283943839448394583946839478394883949839508395183952839538395483955839568395783958839598396083961839628396383964839658396683967839688396983970839718397283973839748397583976839778397883979839808398183982839838398483985839868398783988839898399083991839928399383994839958399683997839988399984000840018400284003840048400584006840078400884009840108401184012840138401484015840168401784018840198402084021840228402384024840258402684027840288402984030840318403284033840348403584036840378403884039840408404184042840438404484045840468404784048840498405084051840528405384054840558405684057840588405984060840618406284063840648406584066840678406884069840708407184072840738407484075840768407784078840798408084081840828408384084840858408684087840888408984090840918409284093840948409584096840978409884099841008410184102841038410484105841068410784108841098411084111841128411384114841158411684117841188411984120841218412284123841248412584126841278412884129841308413184132841338413484135841368413784138841398414084141841428414384144841458414684147841488414984150841518415284153841548415584156841578415884159841608416184162841638416484165841668416784168841698417084171841728417384174841758417684177841788417984180841818418284183841848418584186841878418884189841908419184192841938419484195841968419784198841998420084201842028420384204842058420684207842088420984210842118421284213842148421584216842178421884219842208422184222842238422484225842268422784228842298423084231842328423384234842358423684237842388423984240842418424284243842448424584246842478424884249842508425184252842538425484255842568425784258842598426084261842628426384264842658426684267842688426984270842718427284273842748427584276842778427884279842808428184282842838428484285842868428784288842898429084291842928429384294842958429684297842988429984300843018430284303843048430584306843078430884309843108431184312843138431484315843168431784318843198432084321843228432384324843258432684327843288432984330843318433284333843348433584336843378433884339843408434184342843438434484345843468434784348843498435084351843528435384354843558435684357843588435984360843618436284363843648436584366843678436884369843708437184372843738437484375843768437784378843798438084381843828438384384843858438684387843888438984390843918439284393843948439584396843978439884399844008440184402844038440484405844068440784408844098441084411844128441384414844158441684417844188441984420844218442284423844248442584426844278442884429844308443184432844338443484435844368443784438844398444084441844428444384444844458444684447844488444984450844518445284453844548445584456844578445884459844608446184462844638446484465844668446784468844698447084471844728447384474844758447684477844788447984480844818448284483844848448584486844878448884489844908449184492844938449484495844968449784498844998450084501845028450384504845058450684507845088450984510845118451284513845148451584516845178451884519845208452184522845238452484525845268452784528845298453084531845328453384534845358453684537845388453984540845418454284543845448454584546845478454884549845508455184552845538455484555845568455784558845598456084561845628456384564845658456684567845688456984570845718457284573845748457584576845778457884579845808458184582845838458484585845868458784588845898459084591845928459384594845958459684597845988459984600846018460284603846048460584606846078460884609846108461184612846138461484615846168461784618846198462084621846228462384624846258462684627846288462984630846318463284633846348463584636846378463884639846408464184642846438464484645846468464784648846498465084651846528465384654846558465684657846588465984660846618466284663846648466584666846678466884669846708467184672846738467484675846768467784678846798468084681846828468384684846858468684687846888468984690846918469284693846948469584696846978469884699847008470184702847038470484705847068470784708847098471084711847128471384714847158471684717847188471984720847218472284723847248472584726847278472884729847308473184732847338473484735847368473784738847398474084741847428474384744847458474684747847488474984750847518475284753847548475584756847578475884759847608476184762847638476484765847668476784768847698477084771847728477384774847758477684777847788477984780847818478284783847848478584786847878478884789847908479184792847938479484795847968479784798847998480084801848028480384804848058480684807848088480984810848118481284813848148481584816848178481884819848208482184822848238482484825848268482784828848298483084831848328483384834848358483684837848388483984840848418484284843848448484584846848478484884849848508485184852848538485484855848568485784858848598486084861848628486384864848658486684867848688486984870848718487284873848748487584876848778487884879848808488184882848838488484885848868488784888848898489084891848928489384894848958489684897848988489984900849018490284903849048490584906849078490884909849108491184912849138491484915849168491784918849198492084921849228492384924849258492684927849288492984930849318493284933849348493584936849378493884939849408494184942849438494484945849468494784948849498495084951849528495384954849558495684957849588495984960849618496284963849648496584966849678496884969849708497184972849738497484975849768497784978849798498084981849828498384984849858498684987849888498984990849918499284993849948499584996849978499884999850008500185002850038500485005850068500785008850098501085011850128501385014850158501685017850188501985020850218502285023850248502585026850278502885029850308503185032850338503485035850368503785038850398504085041850428504385044850458504685047850488504985050850518505285053850548505585056850578505885059850608506185062850638506485065850668506785068850698507085071850728507385074850758507685077850788507985080850818508285083850848508585086850878508885089850908509185092850938509485095850968509785098850998510085101851028510385104851058510685107851088510985110851118511285113851148511585116851178511885119851208512185122851238512485125851268512785128851298513085131851328513385134851358513685137851388513985140851418514285143851448514585146851478514885149851508515185152851538515485155851568515785158851598516085161851628516385164851658516685167851688516985170851718517285173851748517585176851778517885179851808518185182851838518485185851868518785188851898519085191851928519385194851958519685197851988519985200852018520285203852048520585206852078520885209852108521185212852138521485215852168521785218852198522085221852228522385224852258522685227852288522985230852318523285233852348523585236852378523885239852408524185242852438524485245852468524785248852498525085251852528525385254852558525685257852588525985260852618526285263852648526585266852678526885269852708527185272852738527485275852768527785278852798528085281852828528385284852858528685287852888528985290852918529285293852948529585296852978529885299853008530185302853038530485305853068530785308853098531085311853128531385314853158531685317853188531985320853218532285323853248532585326853278532885329853308533185332853338533485335853368533785338853398534085341853428534385344853458534685347853488534985350853518535285353853548535585356853578535885359853608536185362853638536485365853668536785368853698537085371853728537385374853758537685377853788537985380853818538285383853848538585386853878538885389853908539185392853938539485395853968539785398853998540085401854028540385404854058540685407854088540985410854118541285413854148541585416854178541885419854208542185422854238542485425854268542785428854298543085431854328543385434854358543685437854388543985440854418544285443854448544585446854478544885449854508545185452854538545485455854568545785458854598546085461854628546385464854658546685467854688546985470854718547285473854748547585476854778547885479854808548185482854838548485485854868548785488854898549085491854928549385494854958549685497854988549985500855018550285503855048550585506855078550885509855108551185512855138551485515855168551785518855198552085521855228552385524855258552685527855288552985530855318553285533855348553585536855378553885539855408554185542855438554485545855468554785548855498555085551855528555385554855558555685557855588555985560855618556285563855648556585566855678556885569855708557185572855738557485575855768557785578855798558085581855828558385584855858558685587855888558985590855918559285593855948559585596855978559885599856008560185602856038560485605856068560785608856098561085611856128561385614856158561685617856188561985620856218562285623856248562585626856278562885629856308563185632856338563485635856368563785638856398564085641856428564385644856458564685647856488564985650856518565285653856548565585656856578565885659856608566185662856638566485665856668566785668856698567085671856728567385674856758567685677856788567985680856818568285683856848568585686856878568885689856908569185692856938569485695856968569785698856998570085701857028570385704857058570685707857088570985710857118571285713857148571585716857178571885719857208572185722857238572485725857268572785728857298573085731857328573385734857358573685737857388573985740857418574285743857448574585746857478574885749857508575185752857538575485755857568575785758857598576085761857628576385764857658576685767857688576985770857718577285773857748577585776857778577885779857808578185782857838578485785857868578785788857898579085791857928579385794857958579685797857988579985800858018580285803858048580585806858078580885809858108581185812858138581485815858168581785818858198582085821858228582385824858258582685827858288582985830858318583285833858348583585836858378583885839858408584185842858438584485845858468584785848858498585085851858528585385854858558585685857858588585985860858618586285863858648586585866858678586885869858708587185872858738587485875858768587785878858798588085881858828588385884858858588685887858888588985890858918589285893858948589585896858978589885899859008590185902859038590485905859068590785908859098591085911859128591385914859158591685917859188591985920859218592285923859248592585926859278592885929859308593185932859338593485935859368593785938859398594085941859428594385944859458594685947859488594985950859518595285953859548595585956859578595885959859608596185962859638596485965859668596785968859698597085971859728597385974859758597685977859788597985980859818598285983859848598585986859878598885989859908599185992859938599485995859968599785998859998600086001860028600386004860058600686007860088600986010860118601286013860148601586016860178601886019860208602186022860238602486025860268602786028860298603086031860328603386034860358603686037860388603986040860418604286043860448604586046860478604886049860508605186052860538605486055860568605786058860598606086061860628606386064860658606686067860688606986070860718607286073860748607586076860778607886079860808608186082860838608486085860868608786088860898609086091860928609386094860958609686097860988609986100861018610286103861048610586106861078610886109861108611186112861138611486115861168611786118861198612086121861228612386124861258612686127861288612986130861318613286133861348613586136861378613886139861408614186142861438614486145861468614786148861498615086151861528615386154861558615686157861588615986160861618616286163861648616586166861678616886169861708617186172861738617486175861768617786178861798618086181861828618386184861858618686187861888618986190861918619286193861948619586196861978619886199862008620186202862038620486205862068620786208862098621086211862128621386214862158621686217862188621986220862218622286223862248622586226862278622886229862308623186232862338623486235862368623786238862398624086241862428624386244862458624686247862488624986250862518625286253862548625586256862578625886259862608626186262862638626486265862668626786268862698627086271862728627386274862758627686277862788627986280862818628286283862848628586286862878628886289862908629186292862938629486295862968629786298862998630086301863028630386304863058630686307863088630986310863118631286313863148631586316863178631886319863208632186322863238632486325863268632786328863298633086331863328633386334863358633686337863388633986340863418634286343863448634586346863478634886349863508635186352863538635486355863568635786358863598636086361863628636386364863658636686367863688636986370863718637286373863748637586376863778637886379863808638186382863838638486385863868638786388863898639086391863928639386394863958639686397863988639986400864018640286403864048640586406864078640886409864108641186412864138641486415864168641786418864198642086421864228642386424864258642686427864288642986430864318643286433864348643586436864378643886439864408644186442864438644486445864468644786448864498645086451864528645386454864558645686457864588645986460864618646286463864648646586466864678646886469864708647186472864738647486475864768647786478864798648086481864828648386484864858648686487864888648986490864918649286493864948649586496864978649886499865008650186502865038650486505865068650786508865098651086511865128651386514865158651686517865188651986520865218652286523865248652586526865278652886529865308653186532865338653486535865368653786538865398654086541865428654386544865458654686547865488654986550865518655286553865548655586556865578655886559865608656186562865638656486565865668656786568865698657086571865728657386574865758657686577865788657986580865818658286583865848658586586865878658886589865908659186592865938659486595865968659786598865998660086601866028660386604866058660686607866088660986610866118661286613866148661586616866178661886619866208662186622866238662486625866268662786628866298663086631866328663386634866358663686637866388663986640866418664286643866448664586646866478664886649866508665186652866538665486655866568665786658866598666086661866628666386664866658666686667866688666986670866718667286673866748667586676866778667886679866808668186682866838668486685866868668786688866898669086691866928669386694866958669686697866988669986700867018670286703867048670586706867078670886709867108671186712867138671486715867168671786718867198672086721867228672386724867258672686727867288672986730867318673286733867348673586736867378673886739867408674186742867438674486745867468674786748867498675086751867528675386754867558675686757867588675986760867618676286763867648676586766867678676886769867708677186772867738677486775867768677786778867798678086781867828678386784867858678686787867888678986790867918679286793867948679586796867978679886799868008680186802868038680486805868068680786808868098681086811868128681386814868158681686817868188681986820868218682286823868248682586826868278682886829868308683186832868338683486835868368683786838868398684086841868428684386844868458684686847868488684986850868518685286853868548685586856868578685886859868608686186862868638686486865868668686786868868698687086871868728687386874868758687686877868788687986880868818688286883868848688586886868878688886889868908689186892868938689486895868968689786898868998690086901869028690386904869058690686907869088690986910869118691286913869148691586916869178691886919869208692186922869238692486925869268692786928869298693086931869328693386934869358693686937869388693986940869418694286943869448694586946869478694886949869508695186952869538695486955869568695786958869598696086961869628696386964869658696686967869688696986970869718697286973869748697586976869778697886979869808698186982869838698486985869868698786988869898699086991869928699386994869958699686997869988699987000870018700287003870048700587006870078700887009870108701187012870138701487015870168701787018870198702087021870228702387024870258702687027870288702987030870318703287033870348703587036870378703887039870408704187042870438704487045870468704787048870498705087051870528705387054870558705687057870588705987060870618706287063870648706587066870678706887069870708707187072870738707487075870768707787078870798708087081870828708387084870858708687087870888708987090870918709287093870948709587096870978709887099871008710187102871038710487105871068710787108871098711087111871128711387114871158711687117871188711987120871218712287123871248712587126871278712887129871308713187132871338713487135871368713787138871398714087141871428714387144871458714687147871488714987150871518715287153871548715587156871578715887159871608716187162871638716487165871668716787168871698717087171871728717387174871758717687177871788717987180871818718287183871848718587186871878718887189871908719187192871938719487195871968719787198871998720087201872028720387204872058720687207872088720987210872118721287213872148721587216872178721887219872208722187222872238722487225872268722787228872298723087231872328723387234872358723687237872388723987240872418724287243872448724587246872478724887249872508725187252872538725487255872568725787258872598726087261872628726387264872658726687267872688726987270872718727287273872748727587276872778727887279872808728187282872838728487285872868728787288872898729087291872928729387294872958729687297872988729987300873018730287303873048730587306873078730887309873108731187312873138731487315873168731787318873198732087321873228732387324873258732687327873288732987330873318733287333873348733587336873378733887339873408734187342873438734487345873468734787348873498735087351873528735387354873558735687357873588735987360873618736287363873648736587366873678736887369873708737187372873738737487375873768737787378873798738087381873828738387384873858738687387873888738987390873918739287393873948739587396873978739887399874008740187402874038740487405874068740787408874098741087411874128741387414874158741687417874188741987420874218742287423874248742587426874278742887429874308743187432874338743487435874368743787438874398744087441874428744387444874458744687447874488744987450874518745287453874548745587456874578745887459874608746187462874638746487465874668746787468874698747087471874728747387474874758747687477874788747987480874818748287483874848748587486874878748887489874908749187492874938749487495874968749787498874998750087501875028750387504875058750687507875088750987510875118751287513875148751587516875178751887519875208752187522875238752487525875268752787528875298753087531875328753387534875358753687537875388753987540875418754287543875448754587546875478754887549875508755187552875538755487555875568755787558875598756087561875628756387564875658756687567875688756987570875718757287573875748757587576875778757887579875808758187582875838758487585875868758787588875898759087591875928759387594875958759687597875988759987600876018760287603876048760587606876078760887609876108761187612876138761487615876168761787618876198762087621876228762387624876258762687627876288762987630876318763287633876348763587636876378763887639876408764187642876438764487645876468764787648876498765087651876528765387654876558765687657876588765987660876618766287663876648766587666876678766887669876708767187672876738767487675876768767787678876798768087681876828768387684876858768687687876888768987690876918769287693876948769587696876978769887699877008770187702877038770487705877068770787708877098771087711877128771387714877158771687717877188771987720877218772287723877248772587726877278772887729877308773187732877338773487735877368773787738877398774087741877428774387744877458774687747877488774987750877518775287753877548775587756877578775887759877608776187762877638776487765877668776787768877698777087771877728777387774877758777687777877788777987780877818778287783877848778587786877878778887789877908779187792877938779487795877968779787798877998780087801878028780387804878058780687807878088780987810878118781287813878148781587816878178781887819878208782187822878238782487825878268782787828878298783087831878328783387834878358783687837878388783987840878418784287843878448784587846878478784887849878508785187852878538785487855878568785787858878598786087861878628786387864878658786687867878688786987870878718787287873878748787587876878778787887879878808788187882878838788487885878868788787888878898789087891878928789387894878958789687897878988789987900879018790287903879048790587906879078790887909879108791187912879138791487915879168791787918879198792087921879228792387924879258792687927879288792987930879318793287933879348793587936879378793887939879408794187942879438794487945879468794787948879498795087951879528795387954879558795687957879588795987960879618796287963879648796587966879678796887969879708797187972879738797487975879768797787978879798798087981879828798387984879858798687987879888798987990879918799287993879948799587996879978799887999880008800188002880038800488005880068800788008880098801088011880128801388014880158801688017880188801988020880218802288023880248802588026880278802888029880308803188032880338803488035880368803788038880398804088041880428804388044880458804688047880488804988050880518805288053880548805588056880578805888059880608806188062880638806488065880668806788068880698807088071880728807388074880758807688077880788807988080880818808288083880848808588086880878808888089880908809188092880938809488095880968809788098880998810088101881028810388104881058810688107881088810988110881118811288113881148811588116881178811888119881208812188122881238812488125881268812788128881298813088131881328813388134881358813688137881388813988140881418814288143881448814588146881478814888149881508815188152881538815488155881568815788158881598816088161881628816388164881658816688167881688816988170881718817288173881748817588176881778817888179881808818188182881838818488185881868818788188881898819088191881928819388194881958819688197881988819988200882018820288203882048820588206882078820888209882108821188212882138821488215882168821788218882198822088221882228822388224882258822688227882288822988230882318823288233882348823588236882378823888239882408824188242882438824488245882468824788248882498825088251882528825388254882558825688257882588825988260882618826288263882648826588266882678826888269882708827188272882738827488275882768827788278882798828088281882828828388284882858828688287882888828988290882918829288293882948829588296882978829888299883008830188302883038830488305883068830788308883098831088311883128831388314883158831688317883188831988320883218832288323883248832588326883278832888329883308833188332883338833488335883368833788338883398834088341883428834388344883458834688347883488834988350883518835288353883548835588356883578835888359883608836188362883638836488365883668836788368883698837088371883728837388374883758837688377883788837988380883818838288383883848838588386883878838888389883908839188392883938839488395883968839788398883998840088401884028840388404884058840688407884088840988410884118841288413884148841588416884178841888419884208842188422884238842488425884268842788428884298843088431884328843388434884358843688437884388843988440884418844288443884448844588446884478844888449884508845188452884538845488455884568845788458884598846088461884628846388464884658846688467884688846988470884718847288473884748847588476884778847888479884808848188482884838848488485884868848788488884898849088491884928849388494884958849688497884988849988500885018850288503885048850588506885078850888509885108851188512885138851488515885168851788518885198852088521885228852388524885258852688527885288852988530885318853288533885348853588536885378853888539885408854188542885438854488545885468854788548885498855088551885528855388554885558855688557885588855988560885618856288563885648856588566885678856888569885708857188572885738857488575885768857788578885798858088581885828858388584885858858688587885888858988590885918859288593885948859588596885978859888599886008860188602886038860488605886068860788608886098861088611886128861388614886158861688617886188861988620886218862288623886248862588626886278862888629886308863188632886338863488635886368863788638886398864088641886428864388644886458864688647886488864988650886518865288653886548865588656886578865888659886608866188662886638866488665886668866788668886698867088671886728867388674886758867688677886788867988680886818868288683886848868588686886878868888689886908869188692886938869488695886968869788698886998870088701887028870388704887058870688707887088870988710887118871288713887148871588716887178871888719887208872188722887238872488725887268872788728887298873088731887328873388734887358873688737887388873988740887418874288743887448874588746887478874888749887508875188752887538875488755887568875788758887598876088761887628876388764887658876688767887688876988770887718877288773887748877588776887778877888779887808878188782887838878488785887868878788788887898879088791887928879388794887958879688797887988879988800888018880288803888048880588806888078880888809888108881188812888138881488815888168881788818888198882088821888228882388824888258882688827888288882988830888318883288833888348883588836888378883888839888408884188842888438884488845888468884788848888498885088851888528885388854888558885688857888588885988860888618886288863888648886588866888678886888869888708887188872888738887488875888768887788878888798888088881888828888388884888858888688887888888888988890888918889288893888948889588896888978889888899889008890188902889038890488905889068890788908889098891088911889128891388914889158891688917889188891988920889218892288923889248892588926889278892888929889308893188932889338893488935889368893788938889398894088941889428894388944889458894688947889488894988950889518895288953889548895588956889578895888959889608896188962889638896488965889668896788968889698897088971889728897388974889758897688977889788897988980889818898288983889848898588986889878898888989889908899188992889938899488995889968899788998889998900089001890028900389004890058900689007890088900989010890118901289013890148901589016890178901889019890208902189022890238902489025890268902789028890298903089031890328903389034890358903689037890388903989040890418904289043890448904589046890478904889049890508905189052890538905489055890568905789058890598906089061890628906389064890658906689067890688906989070890718907289073890748907589076890778907889079890808908189082890838908489085890868908789088890898909089091890928909389094890958909689097890988909989100891018910289103891048910589106891078910889109891108911189112891138911489115891168911789118891198912089121891228912389124891258912689127891288912989130891318913289133891348913589136891378913889139891408914189142891438914489145891468914789148891498915089151891528915389154891558915689157891588915989160891618916289163891648916589166891678916889169891708917189172891738917489175891768917789178891798918089181891828918389184891858918689187891888918989190891918919289193891948919589196891978919889199892008920189202892038920489205892068920789208892098921089211892128921389214892158921689217892188921989220892218922289223892248922589226892278922889229892308923189232892338923489235892368923789238892398924089241892428924389244892458924689247892488924989250892518925289253892548925589256892578925889259892608926189262892638926489265892668926789268892698927089271892728927389274892758927689277892788927989280892818928289283892848928589286892878928889289892908929189292892938929489295892968929789298892998930089301893028930389304893058930689307893088930989310893118931289313893148931589316893178931889319893208932189322893238932489325893268932789328893298933089331893328933389334893358933689337893388933989340893418934289343893448934589346893478934889349893508935189352893538935489355893568935789358893598936089361893628936389364893658936689367893688936989370893718937289373893748937589376893778937889379893808938189382893838938489385893868938789388893898939089391893928939389394893958939689397893988939989400894018940289403894048940589406894078940889409894108941189412894138941489415894168941789418894198942089421894228942389424894258942689427894288942989430894318943289433894348943589436894378943889439894408944189442894438944489445894468944789448894498945089451894528945389454894558945689457894588945989460894618946289463894648946589466894678946889469894708947189472894738947489475894768947789478894798948089481894828948389484894858948689487894888948989490894918949289493894948949589496894978949889499895008950189502895038950489505895068950789508895098951089511895128951389514895158951689517895188951989520895218952289523895248952589526895278952889529895308953189532895338953489535895368953789538895398954089541895428954389544895458954689547895488954989550895518955289553895548955589556895578955889559895608956189562895638956489565895668956789568895698957089571895728957389574895758957689577895788957989580895818958289583895848958589586895878958889589895908959189592895938959489595895968959789598895998960089601896028960389604896058960689607896088960989610896118961289613896148961589616896178961889619896208962189622896238962489625896268962789628896298963089631896328963389634896358963689637896388963989640896418964289643896448964589646896478964889649896508965189652896538965489655896568965789658896598966089661896628966389664896658966689667896688966989670896718967289673896748967589676896778967889679896808968189682896838968489685896868968789688896898969089691896928969389694896958969689697896988969989700897018970289703897048970589706897078970889709897108971189712897138971489715897168971789718897198972089721897228972389724897258972689727897288972989730897318973289733897348973589736897378973889739897408974189742897438974489745897468974789748897498975089751897528975389754897558975689757897588975989760897618976289763897648976589766897678976889769897708977189772897738977489775897768977789778897798978089781897828978389784897858978689787897888978989790897918979289793897948979589796897978979889799898008980189802898038980489805898068980789808898098981089811898128981389814898158981689817898188981989820898218982289823898248982589826898278982889829898308983189832898338983489835898368983789838898398984089841898428984389844898458984689847898488984989850898518985289853898548985589856898578985889859898608986189862898638986489865898668986789868898698987089871898728987389874898758987689877898788987989880898818988289883898848988589886898878988889889898908989189892898938989489895898968989789898898998990089901899028990389904899058990689907899088990989910899118991289913899148991589916899178991889919899208992189922899238992489925899268992789928899298993089931899328993389934899358993689937899388993989940899418994289943899448994589946899478994889949899508995189952899538995489955899568995789958899598996089961899628996389964899658996689967899688996989970899718997289973899748997589976899778997889979899808998189982899838998489985899868998789988899898999089991899928999389994899958999689997899988999990000900019000290003900049000590006900079000890009900109001190012900139001490015900169001790018900199002090021900229002390024900259002690027900289002990030900319003290033900349003590036900379003890039900409004190042900439004490045900469004790048900499005090051900529005390054900559005690057900589005990060900619006290063900649006590066900679006890069900709007190072900739007490075900769007790078900799008090081900829008390084900859008690087900889008990090900919009290093900949009590096900979009890099901009010190102901039010490105901069010790108901099011090111901129011390114901159011690117901189011990120901219012290123901249012590126901279012890129901309013190132901339013490135901369013790138901399014090141901429014390144901459014690147901489014990150901519015290153901549015590156901579015890159901609016190162901639016490165901669016790168901699017090171901729017390174901759017690177901789017990180901819018290183901849018590186901879018890189901909019190192901939019490195901969019790198901999020090201902029020390204902059020690207902089020990210902119021290213902149021590216902179021890219902209022190222902239022490225902269022790228902299023090231902329023390234902359023690237902389023990240902419024290243902449024590246902479024890249902509025190252902539025490255902569025790258902599026090261902629026390264902659026690267902689026990270902719027290273902749027590276902779027890279902809028190282902839028490285902869028790288902899029090291902929029390294902959029690297902989029990300903019030290303903049030590306903079030890309903109031190312903139031490315903169031790318903199032090321903229032390324903259032690327903289032990330903319033290333903349033590336903379033890339903409034190342903439034490345903469034790348903499035090351903529035390354903559035690357903589035990360903619036290363903649036590366903679036890369903709037190372903739037490375903769037790378903799038090381903829038390384903859038690387903889038990390903919039290393903949039590396903979039890399904009040190402904039040490405904069040790408904099041090411904129041390414904159041690417904189041990420904219042290423904249042590426904279042890429904309043190432904339043490435904369043790438904399044090441904429044390444904459044690447904489044990450904519045290453904549045590456904579045890459904609046190462904639046490465904669046790468904699047090471904729047390474904759047690477904789047990480904819048290483904849048590486904879048890489904909049190492904939049490495904969049790498904999050090501905029050390504905059050690507905089050990510905119051290513905149051590516905179051890519905209052190522905239052490525905269052790528905299053090531905329053390534905359053690537905389053990540905419054290543905449054590546905479054890549905509055190552905539055490555905569055790558905599056090561905629056390564905659056690567905689056990570905719057290573905749057590576905779057890579905809058190582905839058490585905869058790588905899059090591905929059390594905959059690597905989059990600906019060290603906049060590606906079060890609906109061190612906139061490615906169061790618906199062090621906229062390624906259062690627906289062990630906319063290633906349063590636906379063890639906409064190642906439064490645906469064790648906499065090651906529065390654906559065690657906589065990660906619066290663906649066590666906679066890669906709067190672906739067490675906769067790678906799068090681906829068390684906859068690687906889068990690906919069290693906949069590696906979069890699907009070190702907039070490705907069070790708907099071090711907129071390714907159071690717907189071990720907219072290723907249072590726907279072890729907309073190732907339073490735907369073790738907399074090741907429074390744907459074690747907489074990750907519075290753907549075590756907579075890759907609076190762907639076490765907669076790768907699077090771907729077390774907759077690777907789077990780907819078290783907849078590786907879078890789907909079190792907939079490795907969079790798907999080090801908029080390804908059080690807908089080990810908119081290813908149081590816908179081890819908209082190822908239082490825908269082790828908299083090831908329083390834908359083690837908389083990840908419084290843908449084590846908479084890849908509085190852908539085490855908569085790858908599086090861908629086390864908659086690867908689086990870908719087290873908749087590876908779087890879908809088190882908839088490885908869088790888908899089090891908929089390894908959089690897908989089990900909019090290903909049090590906909079090890909909109091190912909139091490915909169091790918909199092090921909229092390924909259092690927909289092990930909319093290933909349093590936909379093890939909409094190942909439094490945909469094790948909499095090951909529095390954909559095690957909589095990960909619096290963909649096590966909679096890969909709097190972909739097490975909769097790978909799098090981909829098390984909859098690987909889098990990909919099290993909949099590996909979099890999910009100191002910039100491005910069100791008910099101091011910129101391014910159101691017910189101991020910219102291023910249102591026910279102891029910309103191032910339103491035910369103791038910399104091041910429104391044910459104691047910489104991050910519105291053910549105591056910579105891059910609106191062910639106491065910669106791068910699107091071910729107391074910759107691077910789107991080910819108291083910849108591086910879108891089910909109191092910939109491095910969109791098910999110091101911029110391104911059110691107911089110991110911119111291113911149111591116911179111891119911209112191122911239112491125911269112791128911299113091131911329113391134911359113691137911389113991140911419114291143911449114591146911479114891149911509115191152911539115491155911569115791158911599116091161911629116391164911659116691167911689116991170911719117291173911749117591176911779117891179911809118191182911839118491185911869118791188911899119091191911929119391194911959119691197911989119991200912019120291203912049120591206912079120891209912109121191212912139121491215912169121791218912199122091221912229122391224912259122691227912289122991230912319123291233912349123591236912379123891239912409124191242912439124491245912469124791248912499125091251912529125391254912559125691257912589125991260912619126291263912649126591266912679126891269912709127191272912739127491275912769127791278912799128091281912829128391284912859128691287912889128991290912919129291293912949129591296912979129891299913009130191302913039130491305913069130791308913099131091311913129131391314913159131691317913189131991320913219132291323913249132591326913279132891329913309133191332913339133491335913369133791338913399134091341913429134391344913459134691347913489134991350913519135291353913549135591356913579135891359913609136191362913639136491365913669136791368913699137091371913729137391374913759137691377913789137991380913819138291383913849138591386913879138891389913909139191392913939139491395913969139791398913999140091401914029140391404914059140691407914089140991410914119141291413914149141591416914179141891419914209142191422914239142491425914269142791428914299143091431914329143391434914359143691437914389143991440914419144291443914449144591446914479144891449914509145191452914539145491455914569145791458914599146091461914629146391464914659146691467914689146991470914719147291473914749147591476914779147891479914809148191482914839148491485914869148791488914899149091491914929149391494914959149691497914989149991500915019150291503915049150591506915079150891509915109151191512915139151491515915169151791518915199152091521915229152391524915259152691527915289152991530915319153291533915349153591536915379153891539915409154191542915439154491545915469154791548915499155091551915529155391554915559155691557915589155991560915619156291563915649156591566915679156891569915709157191572915739157491575915769157791578915799158091581915829158391584915859158691587915889158991590915919159291593915949159591596915979159891599916009160191602916039160491605916069160791608916099161091611916129161391614916159161691617916189161991620916219162291623916249162591626916279162891629916309163191632916339163491635916369163791638916399164091641916429164391644916459164691647916489164991650916519165291653916549165591656916579165891659916609166191662916639166491665916669166791668916699167091671916729167391674916759167691677916789167991680916819168291683916849168591686916879168891689916909169191692916939169491695916969169791698916999170091701917029170391704917059170691707917089170991710917119171291713917149171591716917179171891719917209172191722917239172491725917269172791728917299173091731917329173391734917359173691737917389173991740917419174291743917449174591746917479174891749917509175191752917539175491755917569175791758917599176091761917629176391764917659176691767917689176991770917719177291773917749177591776917779177891779917809178191782917839178491785917869178791788917899179091791917929179391794917959179691797917989179991800918019180291803918049180591806918079180891809918109181191812918139181491815918169181791818918199182091821918229182391824918259182691827918289182991830918319183291833918349183591836918379183891839918409184191842918439184491845918469184791848918499185091851918529185391854918559185691857918589185991860918619186291863918649186591866918679186891869918709187191872918739187491875918769187791878918799188091881918829188391884918859188691887918889188991890918919189291893918949189591896918979189891899919009190191902919039190491905919069190791908919099191091911919129191391914919159191691917919189191991920919219192291923919249192591926919279192891929919309193191932919339193491935919369193791938919399194091941919429194391944919459194691947919489194991950919519195291953919549195591956919579195891959919609196191962919639196491965919669196791968919699197091971919729197391974919759197691977919789197991980919819198291983919849198591986919879198891989919909199191992919939199491995919969199791998919999200092001920029200392004920059200692007920089200992010920119201292013920149201592016920179201892019920209202192022920239202492025920269202792028920299203092031920329203392034920359203692037920389203992040920419204292043920449204592046920479204892049920509205192052920539205492055920569205792058920599206092061920629206392064920659206692067920689206992070920719207292073920749207592076920779207892079920809208192082920839208492085920869208792088920899209092091920929209392094920959209692097920989209992100921019210292103921049210592106921079210892109921109211192112921139211492115921169211792118921199212092121921229212392124921259212692127921289212992130921319213292133921349213592136921379213892139921409214192142921439214492145921469214792148921499215092151921529215392154921559215692157921589215992160921619216292163921649216592166921679216892169921709217192172921739217492175921769217792178921799218092181921829218392184921859218692187921889218992190921919219292193921949219592196921979219892199922009220192202922039220492205922069220792208922099221092211922129221392214922159221692217922189221992220922219222292223922249222592226922279222892229922309223192232922339223492235922369223792238922399224092241922429224392244922459224692247922489224992250922519225292253922549225592256922579225892259922609226192262922639226492265922669226792268922699227092271922729227392274922759227692277922789227992280922819228292283922849228592286922879228892289922909229192292922939229492295922969229792298922999230092301923029230392304923059230692307923089230992310923119231292313923149231592316923179231892319923209232192322923239232492325923269232792328923299233092331923329233392334923359233692337923389233992340923419234292343923449234592346923479234892349923509235192352923539235492355923569235792358923599236092361923629236392364923659236692367923689236992370923719237292373923749237592376923779237892379923809238192382923839238492385923869238792388923899239092391923929239392394923959239692397923989239992400924019240292403924049240592406924079240892409924109241192412924139241492415924169241792418924199242092421924229242392424924259242692427924289242992430924319243292433924349243592436924379243892439924409244192442924439244492445924469244792448924499245092451924529245392454924559245692457924589245992460924619246292463924649246592466924679246892469924709247192472924739247492475924769247792478924799248092481924829248392484924859248692487924889248992490924919249292493924949249592496924979249892499925009250192502925039250492505925069250792508925099251092511925129251392514925159251692517925189251992520925219252292523925249252592526925279252892529925309253192532925339253492535925369253792538925399254092541925429254392544925459254692547925489254992550925519255292553925549255592556925579255892559925609256192562925639256492565925669256792568925699257092571925729257392574925759257692577925789257992580925819258292583925849258592586925879258892589925909259192592925939259492595925969259792598925999260092601926029260392604926059260692607926089260992610926119261292613926149261592616926179261892619926209262192622926239262492625926269262792628926299263092631926329263392634926359263692637926389263992640926419264292643926449264592646926479264892649926509265192652926539265492655926569265792658926599266092661926629266392664926659266692667926689266992670926719267292673926749267592676926779267892679926809268192682926839268492685926869268792688926899269092691926929269392694926959269692697926989269992700927019270292703927049270592706927079270892709927109271192712927139271492715927169271792718927199272092721927229272392724927259272692727927289272992730927319273292733927349273592736927379273892739927409274192742927439274492745927469274792748927499275092751927529275392754927559275692757927589275992760927619276292763927649276592766927679276892769927709277192772927739277492775927769277792778927799278092781927829278392784927859278692787927889278992790927919279292793927949279592796927979279892799928009280192802928039280492805928069280792808928099281092811928129281392814928159281692817928189281992820928219282292823928249282592826928279282892829928309283192832928339283492835928369283792838928399284092841928429284392844928459284692847928489284992850928519285292853928549285592856928579285892859928609286192862928639286492865928669286792868928699287092871928729287392874928759287692877928789287992880928819288292883928849288592886928879288892889928909289192892928939289492895928969289792898928999290092901929029290392904929059290692907929089290992910929119291292913929149291592916929179291892919929209292192922929239292492925929269292792928929299293092931929329293392934929359293692937929389293992940929419294292943929449294592946929479294892949929509295192952929539295492955929569295792958929599296092961929629296392964929659296692967929689296992970929719297292973929749297592976929779297892979929809298192982929839298492985929869298792988929899299092991929929299392994929959299692997929989299993000930019300293003930049300593006930079300893009930109301193012930139301493015930169301793018930199302093021930229302393024930259302693027930289302993030930319303293033930349303593036930379303893039930409304193042930439304493045930469304793048930499305093051930529305393054930559305693057930589305993060930619306293063930649306593066930679306893069930709307193072930739307493075930769307793078930799308093081930829308393084930859308693087930889308993090930919309293093930949309593096930979309893099931009310193102931039310493105931069310793108931099311093111931129311393114931159311693117931189311993120931219312293123931249312593126931279312893129931309313193132931339313493135931369313793138931399314093141931429314393144931459314693147931489314993150931519315293153931549315593156931579315893159931609316193162931639316493165931669316793168931699317093171931729317393174931759317693177931789317993180931819318293183931849318593186931879318893189931909319193192931939319493195931969319793198931999320093201932029320393204932059320693207932089320993210932119321293213932149321593216932179321893219932209322193222932239322493225932269322793228932299323093231932329323393234932359323693237932389323993240932419324293243932449324593246932479324893249932509325193252932539325493255932569325793258932599326093261932629326393264932659326693267932689326993270932719327293273932749327593276932779327893279932809328193282932839328493285932869328793288932899329093291932929329393294932959329693297932989329993300933019330293303933049330593306933079330893309933109331193312933139331493315933169331793318933199332093321933229332393324933259332693327933289332993330933319333293333933349333593336933379333893339933409334193342933439334493345933469334793348933499335093351933529335393354933559335693357933589335993360933619336293363933649336593366933679336893369933709337193372933739337493375933769337793378933799338093381933829338393384933859338693387933889338993390933919339293393933949339593396933979339893399934009340193402934039340493405934069340793408934099341093411934129341393414934159341693417934189341993420934219342293423934249342593426934279342893429934309343193432934339343493435934369343793438934399344093441934429344393444934459344693447934489344993450934519345293453934549345593456934579345893459934609346193462934639346493465934669346793468934699347093471934729347393474934759347693477934789347993480934819348293483934849348593486934879348893489934909349193492934939349493495934969349793498934999350093501935029350393504935059350693507935089350993510935119351293513935149351593516935179351893519935209352193522935239352493525935269352793528935299353093531935329353393534935359353693537935389353993540935419354293543935449354593546935479354893549935509355193552935539355493555935569355793558935599356093561935629356393564935659356693567935689356993570935719357293573935749357593576935779357893579935809358193582935839358493585935869358793588935899359093591935929359393594935959359693597935989359993600936019360293603936049360593606936079360893609936109361193612936139361493615936169361793618936199362093621936229362393624936259362693627936289362993630936319363293633936349363593636936379363893639936409364193642936439364493645936469364793648936499365093651936529365393654936559365693657936589365993660936619366293663936649366593666936679366893669936709367193672936739367493675936769367793678936799368093681936829368393684936859368693687936889368993690936919369293693936949369593696936979369893699937009370193702937039370493705937069370793708937099371093711937129371393714937159371693717937189371993720937219372293723937249372593726937279372893729937309373193732937339373493735937369373793738937399374093741937429374393744937459374693747937489374993750937519375293753937549375593756937579375893759937609376193762937639376493765937669376793768937699377093771937729377393774937759377693777937789377993780937819378293783937849378593786937879378893789937909379193792937939379493795937969379793798937999380093801938029380393804938059380693807938089380993810938119381293813938149381593816938179381893819938209382193822938239382493825938269382793828938299383093831938329383393834938359383693837938389383993840938419384293843938449384593846938479384893849938509385193852938539385493855938569385793858938599386093861938629386393864938659386693867938689386993870938719387293873938749387593876938779387893879938809388193882938839388493885938869388793888938899389093891938929389393894938959389693897938989389993900939019390293903939049390593906939079390893909939109391193912939139391493915939169391793918939199392093921939229392393924939259392693927939289392993930939319393293933939349393593936939379393893939939409394193942939439394493945939469394793948939499395093951939529395393954939559395693957939589395993960939619396293963939649396593966939679396893969939709397193972939739397493975939769397793978939799398093981939829398393984939859398693987939889398993990939919399293993939949399593996939979399893999940009400194002940039400494005940069400794008940099401094011940129401394014940159401694017940189401994020940219402294023940249402594026940279402894029940309403194032940339403494035940369403794038940399404094041940429404394044940459404694047940489404994050940519405294053940549405594056940579405894059940609406194062940639406494065940669406794068940699407094071940729407394074940759407694077940789407994080940819408294083940849408594086940879408894089940909409194092940939409494095940969409794098940999410094101941029410394104941059410694107941089410994110941119411294113941149411594116941179411894119941209412194122941239412494125941269412794128941299413094131941329413394134941359413694137941389413994140941419414294143941449414594146941479414894149941509415194152941539415494155941569415794158941599416094161941629416394164941659416694167941689416994170941719417294173941749417594176941779417894179941809418194182941839418494185941869418794188941899419094191941929419394194941959419694197941989419994200942019420294203942049420594206942079420894209942109421194212942139421494215942169421794218942199422094221942229422394224942259422694227942289422994230942319423294233942349423594236942379423894239942409424194242942439424494245942469424794248942499425094251942529425394254942559425694257942589425994260942619426294263942649426594266942679426894269942709427194272942739427494275942769427794278942799428094281942829428394284942859428694287942889428994290942919429294293942949429594296942979429894299943009430194302943039430494305943069430794308943099431094311943129431394314943159431694317943189431994320943219432294323943249432594326943279432894329943309433194332943339433494335943369433794338943399434094341943429434394344943459434694347943489434994350943519435294353943549435594356943579435894359943609436194362943639436494365943669436794368943699437094371943729437394374943759437694377943789437994380943819438294383943849438594386943879438894389943909439194392943939439494395943969439794398943999440094401944029440394404944059440694407944089440994410944119441294413944149441594416944179441894419944209442194422944239442494425944269442794428944299443094431944329443394434944359443694437944389443994440944419444294443944449444594446944479444894449944509445194452944539445494455944569445794458944599446094461944629446394464944659446694467944689446994470944719447294473944749447594476944779447894479944809448194482944839448494485944869448794488944899449094491944929449394494944959449694497944989449994500945019450294503945049450594506945079450894509945109451194512945139451494515945169451794518945199452094521945229452394524945259452694527945289452994530945319453294533945349453594536945379453894539945409454194542945439454494545945469454794548945499455094551945529455394554945559455694557945589455994560945619456294563945649456594566945679456894569945709457194572945739457494575945769457794578945799458094581945829458394584945859458694587945889458994590945919459294593945949459594596945979459894599946009460194602946039460494605946069460794608946099461094611946129461394614946159461694617946189461994620946219462294623946249462594626946279462894629946309463194632946339463494635946369463794638946399464094641946429464394644946459464694647946489464994650946519465294653946549465594656946579465894659946609466194662946639466494665946669466794668946699467094671946729467394674946759467694677946789467994680946819468294683946849468594686946879468894689946909469194692946939469494695946969469794698946999470094701947029470394704947059470694707947089470994710947119471294713947149471594716947179471894719947209472194722947239472494725947269472794728947299473094731947329473394734947359473694737947389473994740947419474294743947449474594746947479474894749947509475194752947539475494755947569475794758947599476094761947629476394764947659476694767947689476994770947719477294773947749477594776947779477894779947809478194782947839478494785947869478794788947899479094791947929479394794947959479694797947989479994800948019480294803948049480594806948079480894809948109481194812948139481494815948169481794818948199482094821948229482394824948259482694827948289482994830948319483294833948349483594836948379483894839948409484194842948439484494845948469484794848948499485094851948529485394854948559485694857948589485994860948619486294863948649486594866948679486894869948709487194872948739487494875948769487794878948799488094881948829488394884948859488694887948889488994890948919489294893948949489594896948979489894899949009490194902949039490494905949069490794908949099491094911949129491394914949159491694917949189491994920949219492294923949249492594926949279492894929949309493194932949339493494935949369493794938949399494094941949429494394944949459494694947949489494994950949519495294953949549495594956949579495894959949609496194962949639496494965949669496794968949699497094971949729497394974949759497694977949789497994980949819498294983949849498594986949879498894989949909499194992949939499494995949969499794998949999500095001950029500395004950059500695007950089500995010950119501295013950149501595016950179501895019950209502195022950239502495025950269502795028950299503095031950329503395034950359503695037950389503995040950419504295043950449504595046950479504895049950509505195052950539505495055950569505795058950599506095061950629506395064950659506695067950689506995070950719507295073950749507595076950779507895079950809508195082950839508495085950869508795088950899509095091950929509395094950959509695097950989509995100951019510295103951049510595106951079510895109951109511195112951139511495115951169511795118951199512095121951229512395124951259512695127951289512995130951319513295133951349513595136951379513895139951409514195142951439514495145951469514795148951499515095151951529515395154951559515695157951589515995160951619516295163951649516595166951679516895169951709517195172951739517495175951769517795178951799518095181951829518395184951859518695187951889518995190951919519295193951949519595196951979519895199952009520195202952039520495205952069520795208952099521095211952129521395214952159521695217952189521995220952219522295223952249522595226952279522895229952309523195232952339523495235952369523795238952399524095241952429524395244952459524695247952489524995250952519525295253952549525595256952579525895259952609526195262952639526495265952669526795268952699527095271952729527395274952759527695277952789527995280952819528295283952849528595286952879528895289952909529195292952939529495295952969529795298952999530095301953029530395304953059530695307953089530995310953119531295313953149531595316953179531895319953209532195322953239532495325953269532795328953299533095331953329533395334953359533695337953389533995340953419534295343953449534595346953479534895349953509535195352953539535495355953569535795358953599536095361953629536395364953659536695367953689536995370953719537295373953749537595376953779537895379953809538195382953839538495385953869538795388953899539095391953929539395394953959539695397953989539995400954019540295403954049540595406954079540895409954109541195412954139541495415954169541795418954199542095421954229542395424954259542695427954289542995430954319543295433954349543595436954379543895439954409544195442954439544495445954469544795448954499545095451954529545395454954559545695457954589545995460954619546295463954649546595466954679546895469954709547195472954739547495475954769547795478954799548095481954829548395484954859548695487954889548995490954919549295493954949549595496954979549895499955009550195502955039550495505955069550795508955099551095511955129551395514955159551695517955189551995520955219552295523955249552595526955279552895529955309553195532955339553495535955369553795538955399554095541955429554395544955459554695547955489554995550955519555295553955549555595556955579555895559955609556195562955639556495565955669556795568955699557095571955729557395574955759557695577955789557995580955819558295583955849558595586955879558895589955909559195592955939559495595955969559795598955999560095601956029560395604956059560695607956089560995610956119561295613956149561595616956179561895619956209562195622956239562495625956269562795628956299563095631956329563395634956359563695637956389563995640956419564295643956449564595646956479564895649956509565195652956539565495655956569565795658956599566095661956629566395664956659566695667956689566995670956719567295673956749567595676956779567895679956809568195682956839568495685956869568795688956899569095691956929569395694956959569695697956989569995700957019570295703957049570595706957079570895709957109571195712957139571495715957169571795718957199572095721957229572395724957259572695727957289572995730957319573295733957349573595736957379573895739957409574195742957439574495745957469574795748957499575095751957529575395754957559575695757957589575995760957619576295763957649576595766957679576895769957709577195772957739577495775957769577795778957799578095781957829578395784957859578695787957889578995790957919579295793957949579595796957979579895799958009580195802958039580495805958069580795808958099581095811958129581395814958159581695817958189581995820958219582295823958249582595826958279582895829958309583195832958339583495835958369583795838958399584095841958429584395844958459584695847958489584995850958519585295853958549585595856958579585895859958609586195862958639586495865958669586795868958699587095871958729587395874958759587695877958789587995880958819588295883958849588595886958879588895889958909589195892958939589495895958969589795898958999590095901959029590395904959059590695907959089590995910959119591295913959149591595916959179591895919959209592195922959239592495925959269592795928959299593095931959329593395934959359593695937959389593995940959419594295943959449594595946959479594895949959509595195952959539595495955959569595795958959599596095961959629596395964959659596695967959689596995970959719597295973959749597595976959779597895979959809598195982959839598495985959869598795988959899599095991959929599395994959959599695997959989599996000960019600296003960049600596006960079600896009960109601196012960139601496015960169601796018960199602096021960229602396024960259602696027960289602996030960319603296033960349603596036960379603896039960409604196042960439604496045960469604796048960499605096051960529605396054960559605696057960589605996060960619606296063960649606596066960679606896069960709607196072960739607496075960769607796078960799608096081960829608396084960859608696087960889608996090960919609296093960949609596096960979609896099961009610196102961039610496105961069610796108961099611096111961129611396114961159611696117961189611996120961219612296123961249612596126961279612896129961309613196132961339613496135961369613796138961399614096141961429614396144961459614696147961489614996150961519615296153961549615596156961579615896159961609616196162961639616496165961669616796168961699617096171961729617396174961759617696177961789617996180961819618296183961849618596186961879618896189961909619196192961939619496195961969619796198961999620096201962029620396204962059620696207962089620996210962119621296213962149621596216962179621896219962209622196222962239622496225962269622796228962299623096231962329623396234962359623696237962389623996240962419624296243962449624596246962479624896249962509625196252962539625496255962569625796258962599626096261962629626396264962659626696267962689626996270962719627296273962749627596276962779627896279962809628196282962839628496285962869628796288962899629096291962929629396294962959629696297962989629996300963019630296303963049630596306963079630896309963109631196312963139631496315963169631796318963199632096321963229632396324963259632696327963289632996330963319633296333963349633596336963379633896339963409634196342963439634496345963469634796348963499635096351963529635396354963559635696357963589635996360963619636296363963649636596366963679636896369963709637196372963739637496375963769637796378963799638096381963829638396384963859638696387963889638996390963919639296393963949639596396963979639896399964009640196402964039640496405964069640796408964099641096411964129641396414964159641696417964189641996420964219642296423964249642596426964279642896429964309643196432964339643496435964369643796438964399644096441964429644396444964459644696447964489644996450964519645296453964549645596456964579645896459964609646196462964639646496465964669646796468964699647096471964729647396474964759647696477964789647996480964819648296483964849648596486964879648896489964909649196492964939649496495964969649796498964999650096501965029650396504965059650696507965089650996510965119651296513965149651596516965179651896519965209652196522965239652496525965269652796528965299653096531965329653396534965359653696537965389653996540965419654296543965449654596546965479654896549965509655196552965539655496555965569655796558965599656096561965629656396564965659656696567965689656996570965719657296573965749657596576965779657896579965809658196582965839658496585965869658796588965899659096591965929659396594965959659696597965989659996600966019660296603966049660596606966079660896609966109661196612966139661496615966169661796618966199662096621966229662396624966259662696627966289662996630966319663296633966349663596636966379663896639966409664196642966439664496645966469664796648966499665096651966529665396654966559665696657966589665996660966619666296663966649666596666966679666896669966709667196672966739667496675966769667796678966799668096681966829668396684966859668696687966889668996690966919669296693966949669596696966979669896699967009670196702967039670496705967069670796708967099671096711967129671396714967159671696717967189671996720967219672296723967249672596726967279672896729967309673196732967339673496735967369673796738967399674096741967429674396744967459674696747967489674996750967519675296753967549675596756967579675896759967609676196762967639676496765967669676796768967699677096771967729677396774967759677696777967789677996780967819678296783967849678596786967879678896789967909679196792967939679496795967969679796798967999680096801968029680396804968059680696807968089680996810968119681296813968149681596816968179681896819968209682196822968239682496825968269682796828968299683096831968329683396834968359683696837968389683996840968419684296843968449684596846968479684896849968509685196852968539685496855968569685796858968599686096861968629686396864968659686696867968689686996870968719687296873968749687596876968779687896879968809688196882968839688496885968869688796888968899689096891968929689396894968959689696897968989689996900969019690296903969049690596906969079690896909969109691196912969139691496915969169691796918969199692096921969229692396924969259692696927969289692996930969319693296933969349693596936969379693896939969409694196942969439694496945969469694796948969499695096951969529695396954969559695696957969589695996960969619696296963969649696596966969679696896969969709697196972969739697496975969769697796978969799698096981969829698396984969859698696987969889698996990969919699296993969949699596996969979699896999970009700197002970039700497005970069700797008970099701097011970129701397014970159701697017970189701997020970219702297023970249702597026970279702897029970309703197032970339703497035970369703797038970399704097041970429704397044970459704697047970489704997050970519705297053970549705597056970579705897059970609706197062970639706497065970669706797068970699707097071970729707397074970759707697077970789707997080970819708297083970849708597086970879708897089970909709197092970939709497095970969709797098970999710097101971029710397104971059710697107971089710997110971119711297113971149711597116971179711897119971209712197122971239712497125971269712797128971299713097131971329713397134971359713697137971389713997140971419714297143971449714597146971479714897149971509715197152971539715497155971569715797158971599716097161971629716397164971659716697167971689716997170971719717297173971749717597176971779717897179971809718197182971839718497185971869718797188971899719097191971929719397194971959719697197971989719997200972019720297203972049720597206972079720897209972109721197212972139721497215972169721797218972199722097221972229722397224972259722697227972289722997230972319723297233972349723597236972379723897239972409724197242972439724497245972469724797248972499725097251972529725397254972559725697257972589725997260972619726297263972649726597266972679726897269972709727197272972739727497275972769727797278972799728097281972829728397284972859728697287972889728997290972919729297293972949729597296972979729897299973009730197302973039730497305973069730797308973099731097311973129731397314973159731697317973189731997320973219732297323973249732597326973279732897329973309733197332973339733497335973369733797338973399734097341973429734397344973459734697347973489734997350973519735297353973549735597356973579735897359973609736197362973639736497365973669736797368973699737097371973729737397374973759737697377973789737997380973819738297383973849738597386973879738897389973909739197392973939739497395973969739797398973999740097401974029740397404974059740697407974089740997410974119741297413974149741597416974179741897419974209742197422974239742497425974269742797428974299743097431974329743397434974359743697437974389743997440974419744297443974449744597446974479744897449974509745197452974539745497455974569745797458974599746097461974629746397464974659746697467974689746997470974719747297473974749747597476974779747897479974809748197482974839748497485974869748797488974899749097491974929749397494974959749697497974989749997500975019750297503975049750597506975079750897509975109751197512975139751497515975169751797518975199752097521975229752397524975259752697527975289752997530975319753297533975349753597536975379753897539975409754197542975439754497545975469754797548975499755097551975529755397554975559755697557975589755997560975619756297563975649756597566975679756897569975709757197572975739757497575975769757797578975799758097581975829758397584975859758697587975889758997590975919759297593975949759597596975979759897599976009760197602976039760497605976069760797608976099761097611976129761397614976159761697617976189761997620976219762297623976249762597626976279762897629976309763197632976339763497635976369763797638976399764097641976429764397644976459764697647976489764997650976519765297653976549765597656976579765897659976609766197662976639766497665976669766797668976699767097671976729767397674976759767697677976789767997680976819768297683976849768597686976879768897689976909769197692976939769497695976969769797698976999770097701977029770397704977059770697707977089770997710977119771297713977149771597716977179771897719977209772197722977239772497725977269772797728977299773097731977329773397734977359773697737977389773997740977419774297743977449774597746977479774897749977509775197752977539775497755977569775797758977599776097761977629776397764977659776697767977689776997770977719777297773977749777597776977779777897779977809778197782977839778497785977869778797788977899779097791977929779397794977959779697797977989779997800978019780297803978049780597806978079780897809978109781197812978139781497815978169781797818978199782097821978229782397824978259782697827978289782997830978319783297833978349783597836978379783897839978409784197842978439784497845978469784797848978499785097851978529785397854978559785697857978589785997860978619786297863978649786597866978679786897869978709787197872978739787497875978769787797878978799788097881978829788397884978859788697887978889788997890978919789297893978949789597896978979789897899979009790197902979039790497905979069790797908979099791097911979129791397914979159791697917979189791997920979219792297923979249792597926979279792897929979309793197932979339793497935979369793797938979399794097941979429794397944979459794697947979489794997950979519795297953979549795597956979579795897959979609796197962979639796497965979669796797968979699797097971979729797397974979759797697977979789797997980979819798297983979849798597986979879798897989979909799197992979939799497995979969799797998979999800098001980029800398004980059800698007980089800998010980119801298013980149801598016980179801898019980209802198022980239802498025980269802798028980299803098031980329803398034980359803698037980389803998040980419804298043980449804598046980479804898049980509805198052980539805498055980569805798058980599806098061980629806398064980659806698067980689806998070980719807298073980749807598076980779807898079980809808198082980839808498085980869808798088980899809098091980929809398094980959809698097980989809998100981019810298103981049810598106981079810898109981109811198112981139811498115981169811798118981199812098121981229812398124981259812698127981289812998130981319813298133981349813598136981379813898139981409814198142981439814498145981469814798148981499815098151981529815398154981559815698157981589815998160981619816298163981649816598166981679816898169981709817198172981739817498175981769817798178981799818098181981829818398184981859818698187981889818998190981919819298193981949819598196981979819898199982009820198202982039820498205982069820798208982099821098211982129821398214982159821698217982189821998220982219822298223982249822598226982279822898229982309823198232982339823498235982369823798238982399824098241982429824398244982459824698247982489824998250982519825298253982549825598256982579825898259982609826198262982639826498265982669826798268982699827098271982729827398274982759827698277982789827998280982819828298283982849828598286982879828898289982909829198292982939829498295982969829798298982999830098301983029830398304983059830698307983089830998310983119831298313983149831598316983179831898319983209832198322983239832498325983269832798328983299833098331983329833398334983359833698337983389833998340983419834298343983449834598346983479834898349983509835198352983539835498355983569835798358983599836098361983629836398364983659836698367983689836998370983719837298373983749837598376983779837898379983809838198382983839838498385983869838798388983899839098391983929839398394983959839698397983989839998400984019840298403984049840598406984079840898409984109841198412984139841498415984169841798418984199842098421984229842398424984259842698427984289842998430984319843298433984349843598436984379843898439984409844198442984439844498445984469844798448984499845098451984529845398454984559845698457984589845998460984619846298463984649846598466984679846898469984709847198472984739847498475984769847798478984799848098481984829848398484984859848698487984889848998490984919849298493984949849598496984979849898499985009850198502985039850498505985069850798508985099851098511985129851398514985159851698517985189851998520985219852298523985249852598526985279852898529985309853198532985339853498535985369853798538985399854098541985429854398544985459854698547985489854998550985519855298553985549855598556985579855898559985609856198562985639856498565985669856798568985699857098571985729857398574985759857698577985789857998580985819858298583985849858598586985879858898589985909859198592985939859498595985969859798598985999860098601986029860398604986059860698607986089860998610986119861298613986149861598616986179861898619986209862198622986239862498625986269862798628986299863098631986329863398634986359863698637986389863998640986419864298643986449864598646986479864898649986509865198652986539865498655986569865798658986599866098661986629866398664986659866698667986689866998670986719867298673986749867598676986779867898679986809868198682986839868498685986869868798688986899869098691986929869398694986959869698697986989869998700987019870298703987049870598706987079870898709987109871198712987139871498715987169871798718987199872098721987229872398724987259872698727987289872998730987319873298733987349873598736987379873898739987409874198742987439874498745987469874798748987499875098751987529875398754987559875698757987589875998760987619876298763987649876598766987679876898769987709877198772987739877498775987769877798778987799878098781987829878398784987859878698787987889878998790987919879298793987949879598796987979879898799988009880198802988039880498805988069880798808988099881098811988129881398814988159881698817988189881998820988219882298823988249882598826988279882898829988309883198832988339883498835988369883798838988399884098841988429884398844988459884698847988489884998850988519885298853988549885598856988579885898859988609886198862988639886498865988669886798868988699887098871988729887398874988759887698877988789887998880988819888298883988849888598886988879888898889988909889198892988939889498895988969889798898988999890098901989029890398904989059890698907989089890998910989119891298913989149891598916989179891898919989209892198922989239892498925989269892798928989299893098931989329893398934989359893698937989389893998940989419894298943989449894598946989479894898949989509895198952989539895498955989569895798958989599896098961989629896398964989659896698967989689896998970989719897298973989749897598976989779897898979989809898198982989839898498985989869898798988989899899098991989929899398994989959899698997989989899999000990019900299003990049900599006990079900899009990109901199012990139901499015990169901799018990199902099021990229902399024990259902699027990289902999030990319903299033990349903599036990379903899039990409904199042990439904499045990469904799048990499905099051990529905399054990559905699057990589905999060990619906299063990649906599066990679906899069990709907199072990739907499075990769907799078990799908099081990829908399084990859908699087990889908999090990919909299093990949909599096990979909899099991009910199102991039910499105991069910799108991099911099111991129911399114991159911699117991189911999120991219912299123991249912599126991279912899129991309913199132991339913499135991369913799138991399914099141991429914399144991459914699147991489914999150991519915299153991549915599156991579915899159991609916199162991639916499165991669916799168991699917099171991729917399174991759917699177991789917999180991819918299183991849918599186991879918899189991909919199192991939919499195991969919799198991999920099201992029920399204992059920699207992089920999210992119921299213992149921599216992179921899219992209922199222992239922499225992269922799228992299923099231992329923399234992359923699237992389923999240992419924299243992449924599246992479924899249992509925199252992539925499255992569925799258992599926099261992629926399264992659926699267992689926999270992719927299273992749927599276992779927899279992809928199282992839928499285992869928799288992899929099291992929929399294992959929699297992989929999300993019930299303993049930599306993079930899309993109931199312993139931499315993169931799318993199932099321993229932399324993259932699327993289932999330993319933299333993349933599336993379933899339993409934199342993439934499345993469934799348993499935099351993529935399354993559935699357993589935999360993619936299363993649936599366993679936899369993709937199372993739937499375993769937799378993799938099381993829938399384993859938699387993889938999390993919939299393993949939599396993979939899399994009940199402994039940499405994069940799408994099941099411994129941399414994159941699417994189941999420994219942299423994249942599426994279942899429994309943199432994339943499435994369943799438994399944099441994429944399444994459944699447994489944999450994519945299453994549945599456994579945899459994609946199462994639946499465994669946799468994699947099471994729947399474994759947699477994789947999480994819948299483994849948599486994879948899489994909949199492994939949499495994969949799498994999950099501995029950399504995059950699507995089950999510995119951299513995149951599516995179951899519995209952199522995239952499525995269952799528995299953099531995329953399534995359953699537995389953999540995419954299543995449954599546995479954899549995509955199552995539955499555995569955799558995599956099561995629956399564995659956699567995689956999570995719957299573995749957599576995779957899579995809958199582995839958499585995869958799588995899959099591995929959399594995959959699597995989959999600996019960299603996049960599606996079960899609996109961199612996139961499615996169961799618996199962099621996229962399624996259962699627996289962999630996319963299633996349963599636996379963899639996409964199642996439964499645996469964799648996499965099651996529965399654996559965699657996589965999660996619966299663996649966599666996679966899669996709967199672996739967499675996769967799678996799968099681996829968399684996859968699687996889968999690996919969299693996949969599696996979969899699997009970199702997039970499705997069970799708997099971099711997129971399714997159971699717997189971999720997219972299723997249972599726997279972899729997309973199732997339973499735997369973799738997399974099741997429974399744997459974699747997489974999750997519975299753997549975599756997579975899759997609976199762997639976499765997669976799768997699977099771997729977399774997759977699777997789977999780997819978299783997849978599786997879978899789997909979199792997939979499795997969979799798997999980099801998029980399804998059980699807998089980999810998119981299813998149981599816998179981899819998209982199822998239982499825998269982799828998299983099831998329983399834998359983699837998389983999840998419984299843998449984599846998479984899849998509985199852998539985499855998569985799858998599986099861998629986399864998659986699867998689986999870998719987299873998749987599876998779987899879998809988199882998839988499885998869988799888998899989099891998929989399894998959989699897998989989999900999019990299903999049990599906999079990899909999109991199912999139991499915999169991799918999199992099921999229992399924999259992699927999289992999930999319993299933999349993599936999379993899939999409994199942999439994499945999469994799948999499995099951999529995399954999559995699957999589995999960999619996299963999649996599966999679996899969999709997199972999739997499975999769997799978999799998099981999829998399984999859998699987999889998999990999919999299993999949999599996999979999899999100000100001100002100003100004100005100006100007100008100009100010100011100012100013100014100015100016100017100018100019100020100021100022100023100024100025100026100027100028100029100030100031100032100033100034100035100036100037100038100039100040100041100042100043100044100045100046100047100048100049100050100051100052100053100054100055100056100057100058100059100060100061100062100063100064100065100066100067100068100069100070100071100072100073100074100075100076100077100078100079100080100081100082100083100084100085100086100087100088100089100090100091100092100093100094100095100096100097100098100099100100100101100102100103100104100105100106100107100108100109100110100111100112100113100114100115100116100117100118100119100120100121100122100123100124100125100126100127100128100129100130100131100132100133100134100135100136100137100138100139100140100141100142100143100144100145100146100147100148100149100150100151100152100153100154100155100156100157100158100159100160100161100162100163100164100165100166100167100168100169100170100171100172100173100174100175100176100177100178100179100180100181100182100183100184100185100186100187100188100189100190100191100192100193100194100195100196100197100198100199100200100201100202100203100204100205100206100207100208100209100210100211100212100213100214100215100216100217100218100219100220100221100222100223100224100225100226100227100228100229100230100231100232100233100234100235100236100237100238100239100240100241100242100243100244100245100246100247100248100249100250100251100252100253100254100255100256100257100258100259100260100261100262100263100264100265100266100267100268100269100270100271100272100273100274100275100276100277100278100279100280100281100282100283100284100285100286100287100288100289100290100291100292100293100294100295100296100297100298100299100300100301100302100303100304100305100306100307100308100309100310100311100312100313100314100315100316100317100318100319100320100321100322100323100324100325100326100327100328100329100330100331100332100333100334100335100336100337100338100339100340100341100342100343100344100345100346100347100348100349100350100351100352100353100354100355100356100357100358100359100360100361100362100363100364100365100366100367100368100369100370100371100372100373100374100375100376100377100378100379100380100381100382100383100384100385100386100387100388100389100390100391100392100393100394100395100396100397100398100399100400100401100402100403100404100405100406100407100408100409100410100411100412100413100414100415100416100417100418100419100420100421100422100423100424100425100426100427100428100429100430100431100432100433100434100435100436100437100438100439100440100441100442100443100444100445100446100447100448100449100450100451100452100453100454100455100456100457100458100459100460100461100462100463100464100465100466100467100468100469100470100471100472100473100474100475100476100477100478100479100480100481100482100483100484100485100486100487100488100489100490100491100492100493100494100495100496100497100498100499100500100501100502100503100504100505100506100507100508100509100510100511100512100513100514100515100516100517100518100519100520100521100522100523100524100525100526100527100528100529100530100531100532100533100534100535100536100537100538100539100540100541100542100543100544100545100546100547100548100549100550100551100552100553100554100555100556100557100558100559100560100561100562100563100564100565100566100567100568100569100570100571100572100573100574100575100576100577100578100579100580100581100582100583100584100585100586100587100588100589100590100591100592100593100594100595100596100597100598100599100600100601100602100603100604100605100606100607100608100609100610100611100612100613100614100615100616100617100618100619100620100621100622100623100624100625100626100627100628100629100630100631100632100633100634100635100636100637100638100639100640100641100642100643100644100645100646100647100648100649100650100651100652100653100654100655100656100657100658100659100660100661100662100663100664100665100666100667100668100669100670100671100672100673100674100675100676100677100678100679100680100681100682100683100684100685100686100687100688100689100690100691100692100693100694100695100696100697100698100699100700100701100702100703100704100705100706100707100708100709100710100711100712100713100714100715100716100717100718100719100720100721100722100723100724100725100726100727100728100729100730100731100732100733100734100735100736100737100738100739100740100741100742100743100744100745100746100747100748100749100750100751100752100753100754100755100756100757100758100759100760100761100762100763100764100765100766100767100768100769100770100771100772100773100774100775100776100777100778100779100780100781100782100783100784100785100786100787100788100789100790100791100792100793100794100795100796100797100798100799100800100801100802100803100804100805100806100807100808100809100810100811100812100813100814100815100816100817100818100819100820100821100822100823100824100825100826100827100828100829100830100831100832100833100834100835100836100837100838100839100840100841100842100843100844100845100846100847100848100849100850100851100852100853100854100855100856100857100858100859100860100861100862100863100864100865100866100867100868100869100870100871100872100873100874100875100876100877100878100879100880100881100882100883100884100885100886100887100888100889100890100891100892100893100894100895100896100897100898100899100900100901100902100903100904100905100906100907100908100909100910100911100912100913100914100915100916100917100918100919100920100921100922100923100924100925100926100927100928100929100930100931100932100933100934100935100936100937100938100939100940100941100942100943100944100945100946100947100948100949100950100951100952100953100954100955100956100957100958100959100960100961100962100963100964100965100966100967100968100969100970100971100972100973100974100975100976100977100978100979100980100981100982100983100984100985100986100987100988100989100990100991100992100993100994100995100996100997100998100999101000101001101002101003101004101005101006101007101008101009101010101011101012101013101014101015101016101017101018101019101020101021101022101023101024101025101026101027101028101029101030101031101032101033101034101035101036101037101038101039101040101041101042101043101044101045101046101047101048101049101050101051101052101053101054101055101056101057101058101059101060101061101062101063101064101065101066101067101068101069101070101071101072101073101074101075101076101077101078101079101080101081101082101083101084101085101086101087101088101089101090101091101092101093101094101095101096101097101098101099101100101101101102101103101104101105101106101107101108101109101110101111101112101113101114101115101116101117101118101119101120101121101122101123101124101125101126101127101128101129101130101131101132101133101134101135101136101137101138101139101140101141101142101143101144101145101146101147101148101149101150101151101152101153101154101155101156101157101158101159101160101161101162101163101164101165101166101167101168101169101170101171101172101173101174101175101176101177101178101179101180101181101182101183101184101185101186101187101188101189101190101191101192101193101194101195101196101197101198101199101200101201101202101203101204101205101206101207101208101209101210101211101212101213101214101215101216101217101218101219101220101221101222101223101224101225101226101227101228101229101230101231101232101233101234101235101236101237101238101239101240101241101242101243101244101245101246101247101248101249101250101251101252101253101254101255101256101257101258101259101260101261101262101263101264101265101266101267101268101269101270101271101272101273101274101275101276101277101278101279101280101281101282101283101284101285101286101287101288101289101290101291101292101293101294101295101296101297101298101299101300101301101302101303101304101305101306101307101308101309101310101311101312101313101314101315101316101317101318101319101320101321101322101323101324101325101326101327101328101329101330101331101332101333101334101335101336101337101338101339101340101341101342101343101344101345101346101347101348101349101350101351101352101353101354101355101356101357101358101359101360101361101362101363101364101365101366101367101368101369101370101371101372101373101374101375101376101377101378101379101380101381101382101383101384101385101386101387101388101389101390101391101392101393101394101395101396101397101398101399101400101401101402101403101404101405101406101407101408101409101410101411101412101413101414101415101416101417101418101419101420101421101422101423101424101425101426101427101428101429101430101431101432101433101434101435101436101437101438101439101440101441101442101443101444101445101446101447101448101449101450101451101452101453101454101455101456101457101458101459101460101461101462101463101464101465101466101467101468101469101470101471101472101473101474101475101476101477101478101479101480101481101482101483101484101485101486101487101488101489101490101491101492101493101494101495101496101497101498101499101500101501101502101503101504101505101506101507101508101509101510101511101512101513101514101515101516101517101518101519101520101521101522101523101524101525101526101527101528101529101530101531101532101533101534101535101536101537101538101539101540101541101542101543101544101545101546101547101548101549101550101551101552101553101554101555101556101557101558101559101560101561101562101563101564101565101566101567101568101569101570101571101572101573101574101575101576101577101578101579101580101581101582101583101584101585101586101587101588101589101590101591101592101593101594101595101596101597101598101599101600101601101602101603101604101605101606101607101608101609101610101611101612101613101614101615101616101617101618101619101620101621101622101623101624101625101626101627101628101629101630101631101632101633101634101635101636101637101638101639101640101641101642101643101644101645101646101647101648101649101650101651101652101653101654101655101656101657101658101659101660101661101662101663101664101665101666101667101668101669101670101671101672101673101674101675101676101677101678101679101680101681101682101683101684101685101686101687101688101689101690101691101692101693101694101695101696101697101698101699101700101701101702101703101704101705101706101707101708101709101710101711101712101713101714101715101716101717101718101719101720101721101722101723101724101725101726101727101728101729101730101731101732101733101734101735101736101737101738101739101740101741101742101743101744101745101746101747101748101749101750101751101752101753101754101755101756101757101758101759101760101761101762101763101764101765101766101767101768101769101770101771101772101773101774101775101776101777101778101779101780101781101782101783101784101785101786101787101788101789101790101791101792101793101794101795101796101797101798101799101800101801101802101803101804101805101806101807101808101809101810101811101812101813101814101815101816101817101818101819101820101821101822101823101824101825101826101827101828101829101830101831101832101833101834101835101836101837101838101839101840101841101842101843101844101845101846101847101848101849101850101851101852101853101854101855101856101857101858101859101860101861101862101863101864101865101866101867101868101869101870101871101872101873101874101875101876101877101878101879101880101881101882101883101884101885101886101887101888101889101890101891101892101893101894101895101896101897101898101899101900101901101902101903101904101905101906101907101908101909101910101911101912101913101914101915101916101917101918101919101920101921101922101923101924101925101926101927101928101929101930101931101932101933101934101935101936101937101938101939101940101941101942101943101944101945101946101947101948101949101950101951101952101953101954101955101956101957101958101959101960101961101962101963101964101965101966101967101968101969101970101971101972101973101974101975101976101977101978101979101980101981101982101983101984101985101986101987101988101989101990101991101992101993101994101995101996101997101998101999102000102001102002102003102004102005102006102007102008102009102010102011102012102013102014102015102016102017102018102019102020102021102022102023102024102025102026102027102028102029102030102031102032102033102034102035102036102037102038102039102040102041102042102043102044102045102046102047102048102049102050102051102052102053102054102055102056102057102058102059102060102061102062102063102064102065102066102067102068102069102070102071102072102073102074102075102076102077102078102079102080102081102082102083102084102085102086102087102088102089102090102091102092102093102094102095102096102097102098102099102100102101102102102103102104102105102106102107102108102109102110102111102112102113102114102115102116102117102118102119102120102121102122102123102124102125102126102127102128102129102130102131102132102133102134102135102136102137102138102139102140102141102142102143102144102145102146102147102148102149102150102151102152102153102154102155102156102157102158102159102160102161102162102163102164102165102166102167102168102169102170102171102172102173102174102175102176102177102178102179102180102181102182102183102184102185102186102187102188102189102190102191102192102193102194102195102196102197102198102199102200102201102202102203102204102205102206102207102208102209102210102211102212102213102214102215102216102217102218102219102220102221102222102223102224102225102226102227102228102229102230102231102232102233102234102235102236102237102238102239102240102241102242102243102244102245102246102247102248102249102250102251102252102253102254102255102256102257102258102259102260102261102262102263102264102265102266102267102268102269102270102271102272102273102274102275102276102277102278102279102280102281102282102283102284102285102286102287102288102289102290102291102292102293102294102295102296102297102298102299102300102301102302102303102304102305102306102307102308102309102310102311102312102313102314102315102316102317102318102319102320102321102322102323102324102325102326102327102328102329102330102331102332102333102334102335102336102337102338102339102340102341102342102343102344102345102346102347102348102349102350102351102352102353102354102355102356102357102358102359102360102361102362102363102364102365102366102367102368102369102370102371102372102373102374102375102376102377102378102379102380102381102382102383102384102385102386102387102388102389102390102391102392102393102394102395102396102397102398102399102400102401102402102403102404102405102406102407102408102409102410102411102412102413102414102415102416102417102418102419102420102421102422102423102424102425102426102427102428102429102430102431102432102433102434102435102436102437102438102439102440102441102442102443102444102445102446102447102448102449102450102451102452102453102454102455102456102457102458102459102460102461102462102463102464102465102466102467102468102469102470102471102472102473102474102475102476102477102478102479102480102481102482102483102484102485102486102487102488102489102490102491102492102493102494102495102496102497102498102499102500102501102502102503102504102505102506102507102508102509102510102511102512102513102514102515102516102517102518102519102520102521102522102523102524102525102526102527102528102529102530102531102532102533102534102535102536102537102538102539102540102541102542102543102544102545102546102547102548102549102550102551102552102553102554102555102556102557102558102559102560102561102562102563102564102565102566102567102568102569102570102571102572102573102574102575102576102577102578102579102580102581102582102583102584102585102586102587102588102589102590102591102592102593102594102595102596102597102598102599102600102601102602102603102604102605102606102607102608102609102610102611102612102613102614102615102616102617102618102619102620102621102622102623102624102625102626102627102628102629102630102631102632102633102634102635102636102637102638102639102640102641102642102643102644102645102646102647102648102649102650102651102652102653102654102655102656102657102658102659102660102661102662102663102664102665102666102667102668102669102670102671102672102673102674102675102676102677102678102679102680102681102682102683102684102685102686102687102688102689102690102691102692102693102694102695102696102697102698102699102700102701102702102703102704102705102706102707102708102709102710102711102712102713102714102715102716102717102718102719102720102721102722102723102724102725102726102727102728102729102730102731102732102733102734102735102736102737102738102739102740102741102742102743102744102745102746102747102748102749102750102751102752102753102754102755102756102757102758102759102760102761102762102763102764102765102766102767102768102769102770102771102772102773102774102775102776102777102778102779102780102781102782102783102784102785102786102787102788102789102790102791102792102793102794102795102796102797102798102799102800102801102802102803102804102805102806102807102808102809102810102811102812102813102814102815102816102817102818102819102820102821102822102823102824102825102826102827102828102829102830102831102832102833102834102835102836102837102838102839102840102841102842102843102844102845102846102847102848102849102850102851102852102853102854102855102856102857102858102859102860102861102862102863102864102865102866102867102868102869102870102871102872102873102874102875102876102877102878102879102880102881102882102883102884102885102886102887102888102889102890102891102892102893102894102895102896102897102898102899102900102901102902102903102904102905102906102907102908102909102910102911102912102913102914102915102916102917102918102919102920102921102922102923102924102925102926102927102928102929102930102931102932102933102934102935102936102937102938102939102940102941102942102943102944102945102946102947102948102949102950102951102952102953102954102955102956102957102958102959102960102961102962102963102964102965102966102967102968102969102970102971102972102973102974102975102976102977102978102979102980102981102982102983102984102985102986102987102988102989102990102991102992102993102994102995102996102997102998102999103000103001103002103003103004103005103006103007103008103009103010103011103012103013103014103015103016103017103018103019103020103021103022103023103024103025103026103027103028103029103030103031103032103033103034103035103036103037103038103039103040103041103042103043103044103045103046103047103048103049103050103051103052103053103054103055103056103057103058103059103060103061103062103063103064103065103066103067103068103069103070103071103072103073103074103075103076103077103078103079103080103081103082103083103084103085103086103087103088103089103090103091103092103093103094103095103096103097103098103099103100103101103102103103103104103105103106103107103108103109103110103111103112103113103114103115103116103117103118103119103120103121103122103123103124103125103126103127103128103129103130103131103132103133103134103135103136103137103138103139103140103141103142103143103144103145103146103147103148103149103150103151103152103153103154103155103156103157103158103159103160103161103162103163103164103165103166103167103168103169103170103171103172103173103174103175103176103177103178103179103180103181103182103183103184103185103186103187103188103189103190103191103192103193103194103195103196103197103198103199103200103201103202103203103204103205103206103207103208103209103210103211103212103213103214103215103216103217103218103219103220103221103222103223103224103225103226103227103228103229103230103231103232103233103234103235103236103237103238103239103240103241103242103243103244103245103246103247103248103249103250103251103252103253103254103255103256103257103258103259103260103261103262103263103264103265103266103267103268103269103270103271103272103273103274103275103276103277103278103279103280103281103282103283103284103285103286103287103288103289103290103291103292103293103294103295103296103297103298103299103300103301103302103303103304103305103306103307103308103309103310103311103312103313103314103315103316103317103318103319103320103321103322103323103324103325103326103327103328103329103330103331103332103333103334103335103336103337103338103339103340103341103342103343103344103345103346103347103348103349103350103351103352103353103354103355103356103357103358103359103360103361103362103363103364103365103366103367103368103369103370103371103372103373103374103375103376103377103378103379103380103381103382103383103384103385103386103387103388103389103390103391103392103393103394103395103396103397103398103399103400103401103402103403103404103405103406103407103408103409103410103411103412103413103414103415103416103417103418103419103420103421103422103423103424103425103426103427103428103429103430103431103432103433103434103435103436103437103438103439103440103441103442103443103444103445103446103447103448103449103450103451103452103453103454103455103456103457103458103459103460103461103462103463103464103465103466103467103468103469103470103471103472103473103474103475103476103477103478103479103480103481103482103483103484103485103486103487103488103489103490103491103492103493103494103495103496103497103498103499103500103501103502103503103504103505103506103507103508103509103510103511103512103513103514103515103516103517103518103519103520103521103522103523103524103525103526103527103528103529103530103531103532103533103534103535103536103537103538103539103540103541103542103543103544103545103546103547103548103549103550103551103552103553103554103555103556103557103558103559103560103561103562103563103564103565103566103567103568103569103570103571103572103573103574103575103576103577103578103579103580103581103582103583103584103585103586103587103588103589103590103591103592103593103594103595103596103597103598103599103600103601103602103603103604103605103606103607103608103609103610103611103612103613103614103615103616103617103618103619103620103621103622103623103624103625103626103627103628103629103630103631103632103633103634103635103636103637103638103639103640103641103642103643103644103645103646103647103648103649103650103651103652103653103654103655103656103657103658103659103660103661103662103663103664103665103666103667103668103669103670103671103672103673103674103675103676103677103678103679103680103681103682103683103684103685103686103687103688103689103690103691103692103693103694103695103696103697103698103699103700103701103702103703103704103705103706103707103708103709103710103711103712103713103714103715103716103717103718103719103720103721103722103723103724103725103726103727103728103729103730103731103732103733103734103735103736103737103738103739103740103741103742103743103744103745103746103747103748103749103750103751103752103753103754103755103756103757103758103759103760103761103762103763103764103765103766103767103768103769103770103771103772103773103774103775103776103777103778103779103780103781103782103783103784103785103786103787103788103789103790103791103792103793103794103795103796103797103798103799103800103801103802103803103804103805103806103807103808103809103810103811103812103813103814103815103816103817103818103819103820103821103822103823103824103825103826103827103828103829103830103831103832103833103834103835103836103837103838103839103840103841103842103843103844103845103846103847103848103849103850103851103852103853103854103855103856103857103858103859103860103861103862103863103864103865103866103867103868103869103870103871103872103873103874103875103876103877103878103879103880103881103882103883103884103885103886103887103888103889103890103891103892103893103894103895103896103897103898103899103900103901103902103903103904103905103906103907103908103909103910103911103912103913103914103915103916103917103918103919103920103921103922103923103924103925103926103927103928103929103930103931103932103933103934103935103936103937103938103939103940103941103942103943103944103945103946103947103948103949103950103951103952103953103954103955103956103957103958103959103960103961103962103963103964103965103966103967103968103969103970103971103972103973103974103975103976103977103978103979103980103981103982103983103984103985103986103987103988103989103990103991103992103993103994103995103996103997103998103999104000104001104002104003104004104005104006104007104008104009104010104011104012104013104014104015104016104017104018104019104020104021104022104023104024104025104026104027104028104029104030104031104032104033104034104035104036104037104038104039104040104041104042104043104044104045104046104047104048104049104050104051104052104053104054104055104056104057104058104059104060104061104062104063104064104065104066104067104068104069104070104071104072104073104074104075104076104077104078104079104080104081104082104083104084104085104086104087104088104089104090104091104092104093104094104095104096104097104098104099104100104101104102104103104104104105104106104107104108104109104110104111104112104113104114104115104116104117104118104119104120104121104122104123104124104125104126104127104128104129104130104131104132104133104134104135104136104137104138104139104140104141104142104143104144104145104146104147104148104149104150104151104152104153104154104155104156104157104158104159104160104161104162104163104164104165104166104167104168104169104170104171104172104173104174104175104176104177104178104179104180104181104182104183104184104185104186104187104188104189104190104191104192104193104194104195104196104197104198104199104200104201104202104203104204104205104206104207104208104209104210104211104212104213104214104215104216104217104218104219104220104221104222104223104224104225104226104227104228104229104230104231104232104233104234104235104236104237104238104239104240104241104242104243104244104245104246104247104248104249104250104251104252104253104254104255104256104257104258104259104260104261104262104263104264104265104266104267104268104269104270104271104272104273104274104275104276104277104278104279104280104281104282104283104284104285104286104287104288104289104290104291104292104293104294104295104296104297104298104299104300104301104302104303104304104305104306104307104308104309104310104311104312104313104314104315104316104317104318104319104320104321104322104323104324104325104326104327104328104329104330104331104332104333104334104335104336104337104338104339104340104341104342104343104344104345104346104347104348104349104350104351104352104353104354104355104356104357104358104359104360104361104362104363104364104365104366104367104368104369104370104371104372104373104374104375104376104377104378104379104380104381104382104383104384104385104386104387104388104389104390104391104392104393104394104395104396104397104398104399104400104401104402104403104404104405104406104407104408104409104410104411104412104413104414104415104416104417104418104419104420104421104422104423104424104425104426104427104428104429104430104431104432104433104434104435104436104437104438104439104440104441104442104443104444104445104446104447104448104449104450104451104452104453104454104455104456104457104458104459104460104461104462104463104464104465104466104467104468104469104470104471104472104473104474104475104476104477104478104479104480104481104482104483104484104485104486104487104488104489104490104491104492104493104494104495104496104497104498104499104500104501104502104503104504104505104506104507104508104509104510104511104512104513104514104515104516104517104518104519104520104521104522104523104524104525104526104527104528104529104530104531104532104533104534104535104536104537104538104539104540104541104542104543104544104545104546104547104548104549104550104551104552104553104554104555104556104557104558104559104560104561104562104563104564104565104566104567104568104569104570104571104572104573104574104575104576104577104578104579104580104581104582104583104584104585104586104587104588104589104590104591104592104593104594104595104596104597104598104599104600104601104602104603104604104605104606104607104608104609104610104611104612104613104614104615104616104617104618104619104620104621104622104623104624104625104626104627104628104629104630104631104632104633104634104635104636104637104638104639104640104641104642104643104644104645104646104647104648104649104650104651104652104653104654104655104656104657104658104659104660104661104662104663104664104665104666104667104668104669104670104671104672104673104674104675104676104677104678104679104680104681104682104683104684104685104686104687104688104689104690104691104692104693104694104695104696104697104698104699104700104701104702104703104704104705104706104707104708104709104710104711104712104713104714104715104716104717104718104719104720104721104722104723104724104725104726104727104728104729104730104731104732104733104734104735104736104737104738104739104740104741104742104743104744104745104746104747104748104749104750104751104752104753104754104755104756104757104758104759104760104761104762104763104764104765104766104767104768104769104770104771104772104773104774104775104776104777104778104779104780104781104782104783104784104785104786104787104788104789104790104791104792104793104794104795104796104797104798104799104800104801104802104803104804104805104806104807104808104809104810104811104812104813104814104815104816104817104818104819104820104821104822104823104824104825104826104827104828104829104830104831104832104833104834104835104836104837104838104839104840104841104842104843104844104845104846104847104848104849104850104851104852104853104854104855104856104857104858104859104860104861104862104863104864104865104866104867104868104869104870104871104872104873104874104875104876104877104878104879104880104881104882104883104884104885104886104887104888104889104890104891104892104893104894104895104896104897104898104899104900104901104902104903104904104905104906104907104908104909104910104911104912104913104914104915104916104917104918104919104920104921104922104923104924104925104926104927104928104929104930104931104932104933104934104935104936104937104938104939104940104941104942104943104944104945104946104947104948104949104950104951104952104953104954104955104956104957104958104959104960104961104962104963104964104965104966104967104968104969104970104971104972104973104974104975104976104977104978104979104980104981104982104983104984104985104986104987104988104989104990104991104992104993104994104995104996104997104998104999105000105001105002105003105004105005105006105007105008105009105010105011105012105013105014105015105016105017105018105019105020105021105022105023105024105025105026105027105028105029105030105031105032105033105034105035105036105037105038105039105040105041105042105043105044105045105046105047105048105049105050105051105052105053105054105055105056105057105058105059105060105061105062105063105064105065105066105067105068105069105070105071105072105073105074105075105076105077105078105079105080105081105082105083105084105085105086105087105088105089105090105091105092105093105094105095105096105097105098105099105100105101105102105103105104105105105106105107105108105109105110105111105112105113105114105115105116105117105118105119105120105121105122105123105124105125105126105127105128105129105130105131105132105133105134105135105136105137105138105139105140105141105142105143105144105145105146105147105148105149105150105151105152105153105154105155105156105157105158105159105160105161105162105163105164105165105166105167105168105169105170105171105172105173105174105175105176105177105178105179105180105181105182105183105184105185105186105187105188105189105190105191105192105193105194105195105196105197105198105199105200105201105202105203105204105205105206105207105208105209105210105211105212105213105214105215105216105217105218105219105220105221105222105223105224105225105226105227105228105229105230105231105232105233105234105235105236105237105238105239105240105241105242105243105244105245105246105247105248105249105250105251105252105253105254105255105256105257105258105259105260105261105262105263105264105265105266105267105268105269105270105271105272105273105274105275105276105277105278105279105280105281105282105283105284105285105286105287105288105289105290105291105292105293105294105295105296105297105298105299105300105301105302105303105304105305105306105307105308105309105310105311105312105313105314105315105316105317105318105319105320105321105322105323105324105325105326105327105328105329105330105331105332105333105334105335105336105337105338105339105340105341105342105343105344105345105346105347105348105349105350105351105352105353105354105355105356105357105358105359105360105361105362105363105364105365105366105367105368105369105370105371105372105373105374105375105376105377105378105379105380105381105382105383105384105385105386105387105388105389105390105391105392105393105394105395105396105397105398105399105400105401105402105403105404105405105406105407105408105409105410105411105412105413105414105415105416105417105418105419105420105421105422105423105424105425105426105427105428105429105430105431105432105433105434105435105436105437105438105439105440105441105442105443105444105445105446105447105448105449105450105451105452105453105454105455105456105457105458105459105460105461105462105463105464105465105466105467105468105469105470105471105472105473105474105475105476105477105478105479105480105481105482105483105484105485105486105487105488105489105490105491105492105493105494105495105496105497105498105499105500105501105502105503105504105505105506105507105508105509105510105511105512105513105514105515105516105517105518105519105520105521105522105523105524105525105526105527105528105529105530105531105532105533105534105535105536105537105538105539105540105541105542105543105544105545105546105547105548105549105550105551105552105553105554105555105556105557105558105559105560105561105562105563105564105565105566105567105568105569105570105571105572105573105574105575105576105577105578105579105580105581105582105583105584105585105586105587105588105589105590105591105592105593105594105595105596105597105598105599105600105601105602105603105604105605105606105607105608105609105610105611105612105613105614105615105616105617105618105619105620105621105622105623105624105625105626105627105628105629105630105631105632105633105634105635105636105637105638105639105640105641105642105643105644105645105646105647105648105649105650105651105652105653105654105655105656105657105658105659105660105661105662105663105664105665105666105667105668105669105670105671105672105673105674105675105676105677105678105679105680105681105682105683105684105685105686105687105688105689105690105691105692105693105694105695105696105697105698105699105700105701105702105703105704105705105706105707105708105709105710105711105712105713105714105715105716105717105718105719105720105721105722105723105724105725105726105727105728105729105730105731105732105733105734105735105736105737105738105739105740105741105742105743105744105745105746105747105748105749105750105751105752105753105754105755105756105757105758105759105760105761105762105763105764105765105766105767105768105769105770105771105772105773105774105775105776105777105778105779105780105781105782105783105784105785105786105787105788105789105790105791105792105793105794105795105796105797105798105799105800105801105802105803105804105805105806105807105808105809105810105811105812105813105814105815105816105817105818105819105820105821105822105823105824105825105826105827105828105829105830105831105832105833105834105835105836105837105838105839105840105841105842105843105844105845105846105847105848105849105850105851105852105853105854105855105856105857105858105859105860105861105862105863105864105865105866105867105868105869105870105871105872105873105874105875105876105877105878105879105880105881105882105883105884105885105886105887105888105889105890105891105892105893105894105895105896105897105898105899105900105901105902105903105904105905105906105907105908105909105910105911105912105913105914105915105916105917105918105919105920105921105922105923105924105925105926105927105928105929105930105931105932105933105934105935105936105937105938105939105940105941105942105943105944105945105946105947105948105949105950105951105952105953105954105955105956105957105958105959105960105961105962105963105964105965105966105967105968105969105970105971105972105973105974105975105976105977105978105979105980105981105982105983105984105985105986105987105988105989105990105991105992105993105994105995105996105997105998105999106000106001106002106003106004106005106006106007106008106009106010106011106012106013106014106015106016106017106018106019106020106021106022106023106024106025106026106027106028106029106030106031106032106033106034106035106036106037106038106039106040106041106042106043106044106045106046106047106048106049106050106051106052106053106054106055106056106057106058106059106060106061106062106063106064106065106066106067106068106069106070106071106072106073106074106075106076106077106078106079106080106081106082106083106084106085106086106087106088106089106090106091106092106093106094106095106096106097106098106099106100106101106102106103106104106105106106106107106108106109106110106111106112106113106114106115106116106117106118106119106120106121106122106123106124106125106126106127106128106129106130106131106132106133106134106135106136106137106138106139106140106141106142106143106144106145106146106147106148106149106150106151106152106153106154106155106156106157106158106159106160106161106162106163106164106165106166106167106168106169106170106171106172106173106174106175106176106177106178106179106180106181106182106183106184106185106186106187106188106189106190106191106192106193106194106195106196106197106198106199106200106201106202106203106204106205106206106207106208106209106210106211106212106213106214106215106216106217106218106219106220106221106222106223106224106225106226106227106228106229106230106231106232106233106234106235106236106237106238106239106240106241106242106243106244106245106246106247106248106249106250106251106252106253106254106255106256106257106258106259106260106261106262106263106264106265106266106267106268106269106270106271106272106273106274106275106276106277106278106279106280106281106282106283106284106285106286106287106288106289106290106291106292106293106294106295106296106297106298106299106300106301106302106303106304106305106306106307106308106309106310106311106312106313106314106315106316106317106318106319106320106321106322106323106324106325106326106327106328106329106330106331106332106333106334106335106336106337106338106339106340106341106342106343106344106345106346106347106348106349106350106351106352106353106354106355106356106357106358106359106360106361106362106363106364106365106366106367106368106369106370106371106372106373106374106375106376106377106378106379106380106381106382106383106384106385106386106387106388106389106390106391106392106393106394106395106396106397106398106399106400106401106402106403106404106405106406106407106408106409106410106411106412106413106414106415106416106417106418106419106420106421106422106423106424106425106426106427106428106429106430106431106432106433106434106435106436106437106438106439106440106441106442106443106444106445106446106447106448106449106450106451106452106453106454106455106456106457106458106459106460106461106462106463106464106465106466106467106468106469106470106471106472106473106474106475106476106477106478106479106480106481106482106483106484106485106486106487106488106489106490106491106492106493106494106495106496106497106498106499106500106501106502106503106504106505106506106507106508106509106510106511106512106513106514106515106516106517106518106519106520106521106522106523106524106525106526106527106528106529106530106531106532106533106534106535106536106537106538106539106540106541106542106543106544106545106546106547106548106549106550106551106552106553106554106555106556106557106558106559106560106561106562106563106564106565106566106567106568106569106570106571106572106573106574106575106576106577106578106579106580106581106582106583106584106585106586106587106588106589106590106591106592106593106594106595106596106597106598106599106600106601106602106603106604106605106606106607106608106609106610106611106612106613106614106615106616106617106618106619106620106621106622106623106624106625106626106627106628106629106630106631106632106633106634106635106636106637106638106639106640106641106642106643106644106645106646106647106648106649106650106651106652106653106654106655106656106657106658106659106660106661106662106663106664106665106666106667106668106669106670106671106672106673106674106675106676106677106678106679106680106681106682106683106684106685106686106687106688106689106690106691106692106693106694106695106696106697106698106699106700106701106702106703106704106705106706106707106708106709106710106711106712106713106714106715106716106717106718106719106720106721106722106723106724106725106726106727106728106729106730106731106732106733106734106735106736106737106738106739106740106741106742106743106744106745106746106747106748106749106750106751106752106753106754106755106756106757106758106759106760106761106762106763106764106765106766106767106768106769106770106771106772106773106774106775106776106777106778106779106780106781106782106783106784106785106786106787106788106789106790106791106792106793106794106795106796106797106798106799106800106801106802106803106804106805106806106807106808106809106810106811106812106813106814106815106816106817106818106819106820106821106822106823106824106825106826106827106828106829106830106831106832106833106834106835106836106837106838106839106840106841106842106843106844106845106846106847106848106849106850106851106852106853106854106855106856106857106858106859106860106861106862106863106864106865106866106867106868106869106870106871106872106873106874106875106876106877106878106879106880106881106882106883106884106885106886106887106888106889106890106891106892106893106894106895106896106897106898106899106900106901106902106903106904106905106906106907106908106909106910106911106912106913106914106915106916106917106918106919106920106921106922106923106924106925106926106927106928106929106930106931106932106933106934106935106936106937106938106939106940106941106942106943106944106945106946106947106948106949106950106951106952106953106954106955106956106957106958106959106960106961106962106963106964106965106966106967106968106969106970106971106972106973106974106975106976106977106978106979106980106981106982106983106984106985106986106987106988106989106990106991106992106993106994106995106996106997106998106999107000107001107002107003107004107005107006107007107008107009107010107011107012107013107014107015107016107017107018107019107020107021107022107023107024107025107026107027107028107029107030107031107032107033107034107035107036107037107038107039107040107041107042107043107044107045107046107047107048107049107050107051107052107053107054107055107056107057107058107059107060107061107062107063107064107065107066107067107068107069107070107071107072107073107074107075107076107077107078107079107080107081107082107083107084107085107086107087107088107089107090107091107092107093107094107095107096107097107098107099107100107101107102107103107104107105107106107107107108107109107110107111107112107113107114107115107116107117107118107119107120107121107122107123107124107125107126107127107128107129107130107131107132107133107134107135107136107137107138107139107140107141107142107143107144107145107146107147107148107149107150107151107152107153107154107155107156107157107158107159107160107161107162107163107164107165107166107167107168107169107170107171107172107173107174107175107176107177107178107179107180107181107182107183107184107185107186107187107188107189107190107191107192107193107194107195107196107197107198107199107200107201107202107203107204107205107206107207107208107209107210107211107212107213107214107215107216107217107218107219107220107221107222107223107224107225107226107227107228107229107230107231107232107233107234107235107236107237107238107239107240107241107242107243107244107245107246107247107248107249107250107251107252107253107254107255107256107257107258107259107260107261107262107263107264107265107266107267107268107269107270107271107272107273107274107275107276107277107278107279107280107281107282107283107284107285107286107287107288107289107290107291107292107293107294107295107296107297107298107299107300107301107302107303107304107305107306107307107308107309107310107311107312107313107314107315107316107317107318107319107320107321107322107323107324107325107326107327107328107329107330107331107332107333107334107335107336107337107338107339107340107341107342107343107344107345107346107347107348107349107350107351107352107353107354107355107356107357107358107359107360107361107362107363107364107365107366107367107368107369107370107371107372107373107374107375107376107377107378107379107380107381107382107383107384107385107386107387107388107389107390107391107392107393107394107395107396107397107398107399107400107401107402107403107404107405107406107407107408107409107410107411107412107413107414107415107416107417107418107419107420107421107422107423107424107425107426107427107428107429107430107431107432107433107434107435107436107437107438107439107440107441107442107443107444107445107446107447107448107449107450107451107452107453107454107455107456107457107458107459107460107461107462107463107464107465107466107467107468107469107470107471107472107473107474107475107476107477107478107479107480107481107482107483107484107485107486107487107488107489107490107491107492107493107494107495107496107497107498107499107500107501107502107503107504107505107506107507107508107509107510107511107512107513107514107515107516107517107518107519107520107521107522107523107524107525107526107527107528107529107530107531107532107533107534107535107536107537107538107539107540107541107542107543107544107545107546107547107548107549107550107551107552107553107554107555107556107557107558107559107560107561107562107563107564107565107566107567107568107569107570107571107572107573107574107575107576107577107578107579107580107581107582107583107584107585107586107587107588107589107590107591107592107593107594107595107596107597107598107599107600107601107602107603107604107605107606107607107608107609107610107611107612107613107614107615107616107617107618107619107620107621107622107623107624107625107626107627107628107629107630107631107632107633107634107635107636107637107638107639107640107641107642107643107644107645107646107647107648107649107650107651107652107653107654107655107656107657107658107659107660107661107662107663107664107665107666107667107668107669107670107671107672107673107674107675107676107677107678107679107680107681107682107683107684107685107686107687107688107689107690107691107692107693107694107695107696107697107698107699107700107701107702107703107704107705107706107707107708107709107710107711107712107713107714107715107716107717107718107719107720107721107722107723107724107725107726107727107728107729107730107731107732107733107734107735107736107737107738107739107740107741107742107743107744107745107746107747107748107749107750107751107752107753107754107755107756107757107758107759107760107761107762107763107764107765107766107767107768107769107770107771107772107773107774107775107776107777107778107779107780107781107782107783107784107785107786107787107788107789107790107791107792107793107794107795107796107797107798107799107800107801107802107803107804107805107806107807107808107809107810107811107812107813107814107815107816107817107818107819107820107821107822107823107824107825107826107827107828107829107830107831107832107833107834107835107836107837107838107839107840107841107842107843107844107845107846107847107848107849107850107851107852107853107854107855107856107857107858107859107860107861107862107863107864107865107866107867107868107869107870107871107872107873107874107875107876107877107878107879107880107881107882107883107884107885107886107887107888107889107890107891107892107893107894107895107896107897107898107899107900107901107902107903107904107905107906107907107908107909107910107911107912107913107914107915107916107917107918107919107920107921107922107923107924107925107926107927107928107929107930107931107932107933107934107935107936107937107938107939107940107941107942107943107944107945107946107947107948107949107950107951107952107953107954107955107956107957107958107959107960107961107962107963107964107965107966107967107968107969107970107971107972107973107974107975107976107977107978107979107980107981107982107983107984107985107986107987107988107989107990107991107992107993107994107995107996107997107998107999108000108001108002108003108004108005108006108007108008108009108010108011108012108013108014108015108016108017108018108019108020108021108022108023108024108025108026108027108028108029108030108031108032108033108034108035108036108037108038108039108040108041108042108043108044108045108046108047108048108049108050108051108052108053108054108055108056108057108058108059108060108061108062108063108064108065108066108067108068108069108070108071108072108073108074108075108076108077108078108079108080108081108082108083108084108085108086108087108088108089108090108091108092108093108094108095108096108097108098108099108100108101108102108103108104108105108106108107108108108109108110108111108112108113108114108115108116108117108118108119108120108121108122108123108124108125108126108127108128108129108130108131108132108133108134108135108136108137108138108139108140108141108142108143108144108145108146108147108148108149108150108151108152108153108154108155108156108157108158108159108160108161108162108163108164108165108166108167108168108169108170108171108172108173108174108175108176108177108178108179108180108181108182108183108184108185108186108187108188108189108190108191108192108193108194108195108196108197108198108199108200108201108202108203108204108205108206108207108208108209108210108211108212108213108214108215108216108217108218108219108220108221108222108223108224108225108226108227108228108229108230108231108232108233108234108235108236108237108238108239108240108241108242108243108244108245108246108247108248108249108250108251108252108253108254108255108256108257108258108259108260108261108262108263108264108265108266108267108268108269108270108271108272108273108274108275108276108277108278108279108280108281108282108283108284108285108286108287108288108289108290108291108292108293108294108295108296108297108298108299108300108301108302108303108304108305108306108307108308108309108310108311108312108313108314108315108316108317108318108319108320108321108322108323108324108325108326108327108328108329108330108331108332108333108334108335108336108337108338108339108340108341108342108343108344108345108346108347108348108349108350108351108352108353108354108355108356108357108358108359108360108361108362108363108364108365108366108367108368108369108370108371108372108373108374108375108376108377108378108379108380108381108382108383108384108385108386108387108388108389108390108391108392108393108394108395108396108397108398108399108400108401108402108403108404108405108406108407108408108409108410108411108412108413108414108415108416108417108418108419108420108421108422108423108424108425108426108427108428108429108430108431108432108433108434108435108436108437108438108439108440108441108442108443108444108445108446108447108448108449108450108451108452108453108454108455108456108457108458108459108460108461108462108463108464108465108466108467108468108469108470108471108472108473108474108475108476108477108478108479108480108481108482108483108484108485108486108487108488108489108490108491108492108493108494108495108496108497108498108499108500108501108502108503108504108505108506108507108508108509108510108511108512108513108514108515108516108517108518108519108520108521108522108523108524108525108526108527108528108529108530108531108532108533108534108535108536108537108538108539108540108541108542108543108544108545108546108547108548108549108550108551108552108553108554108555108556108557108558108559108560108561108562108563108564108565108566108567108568108569108570108571108572108573108574108575108576108577108578108579108580108581108582108583108584108585108586108587108588108589108590108591108592108593108594108595108596108597108598108599108600108601108602108603108604108605108606108607108608108609108610108611108612108613108614108615108616108617108618108619108620108621108622108623108624108625108626108627108628108629108630108631108632108633108634108635108636108637108638108639108640108641108642108643108644108645108646108647108648108649108650108651108652108653108654108655108656108657108658108659108660108661108662108663108664108665108666108667108668108669108670108671108672108673108674108675108676108677108678108679108680108681108682108683108684108685108686108687108688108689108690108691108692108693108694108695108696108697108698108699108700108701108702108703108704108705108706108707108708108709108710108711108712108713108714108715108716108717108718108719108720108721108722108723108724108725108726108727108728108729108730108731108732108733108734108735108736108737108738108739108740108741108742108743108744108745108746108747108748108749108750108751108752108753108754108755108756108757108758108759108760108761108762108763108764108765108766108767108768108769108770108771108772108773108774108775108776108777108778108779108780108781108782108783108784108785108786108787108788108789108790108791108792108793108794108795108796108797108798108799108800108801108802108803108804108805108806108807108808108809108810108811108812108813108814108815108816108817108818108819108820108821108822108823108824108825108826108827108828108829108830108831108832108833108834108835108836108837108838108839108840108841108842108843108844108845108846108847108848108849108850108851108852108853108854108855108856108857108858108859108860108861108862108863108864108865108866108867108868108869108870108871108872108873108874108875108876108877108878108879108880108881108882108883108884108885108886108887108888108889108890108891108892108893108894108895108896108897108898108899108900108901108902108903108904108905108906108907108908108909108910108911108912108913108914108915108916108917108918108919108920108921108922108923108924108925108926108927108928108929108930108931108932108933108934108935108936108937108938108939108940108941108942108943108944108945108946108947108948108949108950108951108952108953108954108955108956108957108958108959108960108961108962108963108964108965108966108967108968108969108970108971108972108973108974108975108976108977108978108979108980108981108982108983108984108985108986108987108988108989108990108991108992108993108994108995108996108997108998108999109000109001109002109003109004109005109006109007109008109009109010109011109012109013109014109015109016109017109018109019109020109021109022109023109024109025109026109027109028109029109030109031109032109033109034109035109036109037109038109039109040109041109042109043109044109045109046109047109048109049109050109051109052109053109054109055109056109057109058109059109060109061109062109063109064109065109066109067109068109069109070109071109072109073109074109075109076109077109078109079109080109081109082109083109084109085109086109087109088109089109090109091109092109093109094109095109096109097109098109099109100109101109102109103109104109105109106109107109108109109109110109111109112109113109114109115109116109117109118109119109120109121109122109123109124109125109126109127109128109129109130109131109132109133109134109135109136109137109138109139109140109141109142109143109144109145109146109147109148109149109150109151109152109153109154109155109156109157109158109159109160109161109162109163109164109165109166109167109168109169109170109171109172109173109174109175109176109177109178109179109180109181109182109183109184109185109186109187109188109189109190109191109192109193109194109195109196109197109198109199109200109201109202109203109204109205109206109207109208109209109210109211109212109213109214109215109216109217109218109219109220109221109222109223109224109225109226109227109228109229109230109231109232109233109234109235109236109237109238109239109240109241109242109243109244109245109246109247109248109249109250109251109252109253109254109255109256109257109258109259109260109261109262109263109264109265109266109267109268109269109270109271109272109273109274109275109276109277109278109279109280109281109282109283109284109285109286109287109288109289109290109291109292109293109294109295109296109297109298109299109300109301109302109303109304109305109306109307109308109309109310109311109312109313109314109315109316109317109318109319109320109321109322109323109324109325109326109327109328109329109330109331109332109333109334109335109336109337109338109339109340109341109342109343109344109345109346109347109348109349109350109351109352109353109354109355109356109357109358109359109360109361109362109363109364109365109366109367109368109369109370109371109372109373109374109375109376109377109378109379109380109381109382109383109384109385109386109387109388109389109390109391109392109393109394109395109396109397109398109399109400109401109402109403109404109405109406109407109408109409109410109411109412109413109414109415109416109417109418109419109420109421109422109423109424109425109426109427109428109429109430109431109432109433109434109435109436109437109438109439109440109441109442109443109444109445109446109447109448109449109450109451109452109453109454109455109456109457109458109459109460109461109462109463109464109465109466109467109468109469109470109471109472109473109474109475109476109477109478109479109480109481109482109483109484109485109486109487109488109489109490109491109492109493109494109495109496109497109498109499109500109501109502109503109504109505109506109507109508109509109510109511109512109513109514109515109516109517109518109519109520109521109522109523109524109525109526109527109528109529109530109531109532109533109534109535109536109537109538109539109540109541109542109543109544109545109546109547109548109549109550109551109552109553109554109555109556109557109558109559109560109561109562109563109564109565109566109567109568109569109570109571109572109573109574109575109576109577109578109579109580109581109582109583109584109585109586109587109588109589109590109591109592109593109594109595109596109597109598109599109600109601109602109603109604109605109606109607109608109609109610109611109612109613109614109615109616109617109618109619109620109621109622109623109624109625109626109627109628109629109630109631109632109633109634109635109636109637109638109639109640109641109642109643109644109645109646109647109648109649109650109651109652109653109654109655109656109657109658109659109660109661109662109663109664109665109666109667109668109669109670109671109672109673109674109675109676109677109678109679109680109681109682109683109684109685109686109687109688109689109690109691109692109693109694109695109696109697109698109699109700109701109702109703109704109705109706109707109708109709109710109711109712109713109714109715109716109717109718109719109720109721109722109723109724109725109726109727109728109729109730109731109732109733109734109735109736109737109738109739109740109741109742109743109744109745109746109747109748109749109750109751109752109753109754109755109756109757109758109759109760109761109762109763109764109765109766109767109768109769109770109771109772109773109774109775109776109777109778109779109780109781109782109783109784109785109786109787109788109789109790109791109792109793109794109795109796109797109798109799109800109801109802109803109804109805109806109807109808109809109810109811109812109813109814109815109816109817109818109819109820109821109822109823109824109825109826109827109828109829109830109831109832109833109834109835109836109837109838109839109840109841109842109843109844109845109846109847109848109849109850109851109852109853109854109855109856109857109858109859109860109861109862109863109864109865109866109867109868109869109870109871109872109873109874109875109876109877109878109879109880109881109882109883109884109885109886109887109888109889109890109891109892109893109894109895109896109897109898109899109900109901109902109903109904109905109906109907109908109909109910109911109912109913109914109915109916109917109918109919109920109921109922109923109924109925109926109927109928109929109930109931109932109933109934109935109936109937109938109939109940109941109942109943109944109945109946109947109948109949109950109951109952109953109954109955109956109957109958109959109960109961109962109963109964109965109966109967109968109969109970109971109972109973109974109975109976109977109978109979109980109981109982109983109984109985109986109987109988109989109990109991109992109993109994109995109996109997109998109999110000110001110002110003110004110005110006110007110008110009110010110011110012110013110014110015110016110017110018110019110020110021110022110023110024110025110026110027110028110029110030110031110032110033110034110035110036110037110038110039110040110041110042110043110044110045110046110047110048110049110050110051110052110053110054110055110056110057110058110059110060110061110062110063110064110065110066110067110068110069110070110071110072110073110074110075110076110077110078110079110080110081110082110083110084110085110086110087110088110089110090110091110092110093110094110095110096110097110098110099110100110101110102110103110104110105110106110107110108110109110110110111110112110113110114110115110116110117110118110119110120110121110122110123110124110125110126110127110128110129110130110131110132110133110134110135110136110137110138110139110140110141110142110143110144110145110146110147110148110149110150110151110152110153110154110155110156110157110158110159110160110161110162110163110164110165110166110167110168110169110170110171110172110173110174110175110176110177110178110179110180110181110182110183110184110185110186110187110188110189110190110191110192110193110194110195110196110197110198110199110200110201110202110203110204110205110206110207110208110209110210110211110212110213110214110215110216110217110218110219110220110221110222110223110224110225110226110227110228110229110230110231110232110233110234110235110236110237110238110239110240110241110242110243110244110245110246110247110248110249110250110251110252110253110254110255110256110257110258110259110260110261110262110263110264110265110266110267110268110269110270110271110272110273110274110275110276110277110278110279110280110281110282110283110284110285110286110287110288110289110290110291110292110293110294110295110296110297110298110299110300110301110302110303110304110305110306110307110308110309110310110311110312110313110314110315110316110317110318110319110320110321110322110323110324110325110326110327110328110329110330110331110332110333110334110335110336110337110338110339110340110341110342110343110344110345110346110347110348110349110350110351110352110353110354110355110356110357110358110359110360110361110362110363110364110365110366110367110368110369110370110371110372110373110374110375110376110377110378110379110380110381110382110383110384110385110386110387110388110389110390110391110392110393110394110395110396110397110398110399110400110401110402110403110404110405110406110407110408110409110410110411110412110413110414110415110416110417110418110419110420110421110422110423110424110425110426110427110428110429110430110431110432110433110434110435110436110437110438110439110440110441110442110443110444110445110446110447110448110449110450110451110452110453110454110455110456110457110458110459110460110461110462110463110464110465110466110467110468110469110470110471110472110473110474110475110476110477110478110479110480110481110482110483110484110485110486110487110488110489110490110491110492110493110494110495110496110497110498110499110500110501110502110503110504110505110506110507110508110509110510110511110512110513110514110515110516110517110518110519110520110521110522110523110524110525110526110527110528110529110530110531110532110533110534110535110536110537110538110539110540110541110542110543110544110545110546110547110548110549110550110551110552110553110554110555110556110557110558110559110560110561110562110563110564110565110566110567110568110569110570110571110572110573110574110575110576110577110578110579110580110581110582110583110584110585110586110587110588110589110590110591110592110593110594110595110596110597110598110599110600110601110602110603110604110605110606110607110608110609110610110611110612110613110614110615110616110617110618110619110620110621110622110623110624110625110626110627110628110629110630110631110632110633110634110635110636110637110638110639110640110641110642110643110644110645110646110647110648110649110650110651110652110653110654110655110656110657110658110659110660110661110662110663110664110665110666110667110668110669110670110671110672110673110674110675110676110677110678110679110680110681110682110683110684110685110686110687110688110689110690110691110692110693110694110695110696110697110698110699110700110701110702110703110704110705110706110707110708110709110710110711110712110713110714110715110716110717110718110719110720110721110722110723110724110725110726110727110728110729110730110731110732110733110734110735110736110737110738110739110740110741110742110743110744110745110746110747110748110749110750110751110752110753110754110755110756110757110758110759110760110761110762110763110764110765110766110767110768110769110770110771110772110773110774110775110776110777110778110779110780110781110782110783110784110785110786110787110788110789110790110791110792110793110794110795110796110797110798110799110800110801110802110803110804110805110806110807110808110809110810110811110812110813110814110815110816110817110818110819110820110821110822110823110824110825110826110827110828110829110830110831110832110833110834110835110836110837110838110839110840110841110842110843110844110845110846110847110848110849110850110851110852110853110854110855110856110857110858110859110860110861110862110863110864110865110866110867110868110869110870110871110872110873110874110875110876110877110878110879110880110881110882110883110884110885110886110887110888110889110890110891110892110893110894110895110896110897110898110899110900110901110902110903110904110905110906110907110908110909110910110911110912110913110914110915110916110917110918110919110920110921110922110923110924110925110926110927110928110929110930110931110932110933110934110935110936110937110938110939110940110941110942110943110944110945110946110947110948110949110950110951110952110953110954110955110956110957110958110959110960110961110962110963110964110965110966110967110968110969110970110971110972110973110974110975110976110977110978110979110980110981110982110983110984110985110986110987110988110989110990110991110992110993110994110995110996110997110998110999111000111001111002111003111004111005111006111007111008111009111010111011111012111013111014111015111016111017111018111019111020111021111022111023111024111025111026111027111028111029111030111031111032111033111034111035111036111037111038111039111040111041111042111043111044111045111046111047111048111049111050111051111052111053111054111055111056111057111058111059111060111061111062111063111064111065111066111067111068111069111070111071111072111073111074111075111076111077111078111079111080111081111082111083111084111085111086111087111088111089111090111091111092111093111094111095111096111097111098111099111100111101111102111103111104111105111106111107111108111109111110111111111112111113111114111115111116111117111118111119111120111121111122111123111124111125111126111127111128111129111130111131111132111133111134111135111136111137111138111139111140111141111142111143111144111145111146111147111148111149111150111151111152111153111154111155111156111157111158111159111160111161111162111163111164111165111166111167111168111169111170111171111172111173111174111175111176111177111178111179111180111181111182111183111184111185111186111187111188111189111190111191111192111193111194111195111196111197111198111199111200111201111202111203111204111205111206111207111208111209111210111211111212111213111214111215111216111217111218111219111220111221111222111223111224111225111226111227111228111229111230111231111232111233111234111235111236111237111238111239111240111241111242111243111244111245111246111247111248111249111250111251111252111253111254111255111256111257111258111259111260111261111262111263111264111265111266111267111268111269111270111271111272111273111274111275111276111277111278111279111280111281111282111283111284111285111286111287111288111289111290111291111292111293111294111295111296111297111298111299111300111301111302111303111304111305111306111307111308111309111310111311111312111313111314111315111316111317111318111319111320111321111322111323111324111325111326111327111328111329111330111331111332111333111334111335111336111337111338111339111340111341111342111343111344111345111346111347111348111349111350111351111352111353111354111355111356111357111358111359111360111361111362111363111364111365111366111367111368111369111370111371111372111373111374111375111376111377111378111379111380111381111382111383111384111385111386111387111388111389111390111391111392111393111394111395111396111397111398111399111400111401111402111403111404111405111406111407111408111409111410111411111412111413111414111415111416111417111418111419111420111421111422111423111424111425111426111427111428111429111430111431111432111433111434111435111436111437111438111439111440111441111442111443111444111445111446111447111448111449111450111451111452111453111454111455111456111457111458111459111460111461111462111463111464111465111466111467111468111469111470111471111472111473111474111475111476111477111478111479111480111481111482111483111484111485111486111487111488111489111490111491111492111493111494111495111496111497111498111499111500111501111502111503111504111505111506111507111508111509111510111511111512111513111514111515111516111517111518111519111520111521111522111523111524111525111526111527111528111529111530111531111532111533111534111535111536111537111538111539111540111541111542111543111544111545111546111547111548111549111550111551111552111553111554111555111556111557111558111559111560111561111562111563111564111565111566111567111568111569111570111571111572111573111574111575111576111577111578111579111580111581111582111583111584111585111586111587111588111589111590111591111592111593111594111595111596111597111598111599111600111601111602111603111604111605111606111607111608111609111610111611111612111613111614111615111616111617111618111619111620111621111622111623111624111625111626111627111628111629111630111631111632111633111634111635111636111637111638111639111640111641111642111643111644111645111646111647111648111649111650111651111652111653111654111655111656111657111658111659111660111661111662111663111664111665111666111667111668111669111670111671111672111673111674111675111676111677111678111679111680111681111682111683111684111685111686111687111688111689111690111691111692111693111694111695111696111697111698111699111700111701111702111703111704111705111706111707111708111709111710111711111712111713111714111715111716111717111718111719111720111721111722111723111724111725111726111727111728111729111730111731111732111733111734111735111736111737111738111739111740111741111742111743111744111745111746111747111748111749111750111751111752111753111754111755111756111757111758111759111760111761111762111763111764111765111766111767111768111769111770111771111772111773111774111775111776111777111778111779111780111781111782111783111784111785111786111787111788111789111790111791111792111793111794111795111796111797111798111799111800111801111802111803111804111805111806111807111808111809111810111811111812111813111814111815111816111817111818111819111820111821111822111823111824111825111826111827111828111829111830111831111832111833111834111835111836111837111838111839111840111841111842111843111844111845111846111847111848111849111850111851111852111853111854111855111856111857111858111859111860111861111862111863111864111865111866111867111868111869111870111871111872111873111874111875111876111877111878111879111880111881111882111883111884111885111886111887111888111889111890111891111892111893111894111895111896111897111898111899111900111901111902111903111904111905111906111907111908111909111910111911111912111913111914111915111916111917111918111919111920111921111922111923111924111925111926111927111928111929111930111931111932111933111934111935111936111937111938111939111940111941111942111943111944111945111946111947111948111949111950111951111952111953111954111955111956111957111958111959111960111961111962111963111964111965111966111967111968111969111970111971111972111973111974111975111976111977111978111979111980111981111982111983111984111985111986111987111988111989111990111991111992111993111994111995111996111997111998111999112000112001112002112003112004112005112006112007112008112009112010112011112012112013112014112015112016112017112018112019112020112021112022112023112024112025112026112027112028112029112030112031112032112033112034112035112036112037112038112039112040112041112042112043112044112045112046112047112048112049112050112051112052112053112054112055112056112057112058112059112060112061112062112063112064112065112066112067112068112069112070112071112072112073112074112075112076112077112078112079112080112081112082112083112084112085112086112087112088112089112090112091112092112093112094112095112096112097112098112099112100112101112102112103112104112105112106112107112108112109112110112111112112112113112114112115112116112117112118112119112120112121112122112123112124112125112126112127112128112129112130112131112132112133112134112135112136112137112138112139112140112141112142112143112144112145112146112147112148112149112150112151112152112153112154112155112156112157112158112159112160112161112162112163112164112165112166112167112168112169112170112171112172112173112174112175112176112177112178112179112180112181112182112183112184112185112186112187112188112189112190112191112192112193112194112195112196112197112198112199112200112201112202112203112204112205112206112207112208112209112210112211112212112213112214112215112216112217112218112219112220112221112222112223112224112225112226112227112228112229112230112231112232112233112234112235112236112237112238112239112240112241112242112243112244112245112246112247112248112249112250112251112252112253112254112255112256112257112258112259112260112261112262112263112264112265112266112267112268112269112270112271112272112273112274112275112276112277112278112279112280112281112282112283112284112285112286112287112288112289112290112291112292112293112294112295112296112297112298112299112300112301112302112303112304112305112306112307112308112309112310112311112312112313112314112315112316112317112318112319112320112321112322112323112324112325112326112327112328112329112330112331112332112333112334112335112336112337112338112339112340112341112342112343112344112345112346112347112348112349112350112351112352112353112354112355112356112357112358112359112360112361112362112363112364112365112366112367112368112369112370112371112372112373112374112375112376112377112378112379112380112381112382112383112384112385112386112387112388112389112390112391112392112393112394112395112396112397112398112399112400112401112402112403112404112405112406112407112408112409112410112411112412112413112414112415112416112417112418112419112420112421112422112423112424112425112426112427112428112429112430112431112432112433112434112435112436112437112438112439112440112441112442112443112444112445112446112447112448112449112450112451112452112453112454112455112456112457112458112459112460112461112462112463112464112465112466112467112468112469112470112471112472112473112474112475112476112477112478112479112480112481112482112483112484112485112486112487112488112489112490112491112492112493112494112495112496112497112498112499112500112501112502112503112504112505112506112507112508112509112510112511112512112513112514112515112516112517112518112519112520112521112522112523112524112525112526112527112528112529112530112531112532112533112534112535112536112537112538112539112540112541112542112543112544112545112546112547112548112549112550112551112552112553112554112555112556112557112558112559112560112561112562112563112564112565112566112567112568112569112570112571112572112573112574112575112576112577112578112579112580112581112582112583112584112585112586112587112588112589112590112591112592112593112594112595112596112597112598112599112600112601112602112603112604112605112606112607112608112609112610112611112612112613112614112615112616112617112618112619112620112621112622112623112624112625112626112627112628112629112630112631112632112633112634112635112636112637112638112639112640112641112642112643112644112645112646112647112648112649112650112651112652112653112654112655112656112657112658112659112660112661112662112663112664112665112666112667112668112669112670112671112672112673112674112675112676112677112678112679112680112681112682112683112684112685112686112687112688112689112690112691112692112693112694112695112696112697112698112699112700112701112702112703112704112705112706112707112708112709112710112711112712112713112714112715112716112717112718112719112720112721112722112723112724112725112726112727112728112729112730112731112732112733112734112735112736112737112738112739112740112741112742112743112744112745112746112747112748112749112750112751112752112753112754112755112756112757112758112759112760112761112762112763112764112765112766112767112768112769112770112771112772112773112774112775112776112777112778112779112780112781112782112783112784112785112786112787112788112789112790112791112792112793112794112795112796112797112798112799112800112801112802112803112804112805112806112807112808112809112810112811112812112813112814112815112816112817112818112819112820112821112822112823112824112825112826112827112828112829112830112831112832112833112834112835112836112837112838112839112840112841112842112843112844112845112846112847112848112849112850112851112852112853112854112855112856112857112858112859112860112861112862112863112864112865112866112867112868112869112870112871112872112873112874112875112876112877112878112879112880112881112882112883112884112885112886112887112888112889112890112891112892112893112894112895112896112897112898112899112900112901112902112903112904112905112906112907112908112909112910112911112912112913112914112915112916112917112918112919112920112921112922112923112924112925112926112927112928112929112930112931112932112933112934112935112936112937112938112939112940112941112942112943112944112945112946112947112948112949112950112951112952112953112954112955112956112957112958112959112960112961112962112963112964112965112966112967112968112969112970112971112972112973112974112975112976112977112978112979112980112981112982112983112984112985112986112987112988112989112990112991112992112993112994112995112996112997112998112999113000113001113002113003113004113005113006113007113008113009113010113011113012113013113014113015113016113017113018113019113020113021113022113023113024113025113026113027113028113029113030113031113032113033113034113035113036113037113038113039113040113041113042113043113044113045113046113047113048113049113050113051113052113053113054113055113056113057113058113059113060113061113062113063113064113065113066113067113068113069113070113071113072113073113074113075113076113077113078113079113080113081113082113083113084113085113086113087113088113089113090113091113092113093113094113095113096113097113098113099113100113101113102113103113104113105113106113107113108113109113110113111113112113113113114113115113116113117113118113119113120113121113122113123113124113125113126113127113128113129113130113131113132113133113134113135113136113137113138113139113140113141113142113143113144113145113146113147113148113149113150113151113152113153113154113155113156113157113158113159113160113161113162113163113164113165113166113167113168113169113170113171113172113173113174113175113176113177113178113179113180113181113182113183113184113185113186113187113188113189113190113191113192113193113194113195113196113197113198113199113200113201113202113203113204113205113206113207113208113209113210113211113212113213113214113215113216113217113218113219113220113221113222113223113224113225113226113227113228113229113230113231113232113233113234113235113236113237113238113239113240113241113242113243113244113245113246113247113248113249113250113251113252113253113254113255113256113257113258113259113260113261113262113263113264113265113266113267113268113269113270113271113272113273113274113275113276113277113278113279113280113281113282113283113284113285113286113287113288113289113290113291113292113293113294113295113296113297113298113299113300113301113302113303113304113305113306113307113308113309113310113311113312113313113314113315113316113317113318113319113320113321113322113323113324113325113326113327113328113329113330113331113332113333113334113335113336113337113338113339113340113341113342113343113344113345113346113347113348113349113350113351113352113353113354113355113356113357113358113359113360113361113362113363113364113365113366113367113368113369113370113371113372113373113374113375113376113377113378113379113380113381113382113383113384113385113386113387113388113389113390113391113392113393113394113395113396113397113398113399113400113401113402113403113404113405113406113407113408113409113410113411113412113413113414113415113416113417113418113419113420113421113422113423113424113425113426113427113428113429113430113431113432113433113434113435113436113437113438113439113440113441113442113443113444113445113446113447113448113449113450113451113452113453113454113455113456113457113458113459113460113461113462113463113464113465113466113467113468113469113470113471113472113473113474113475113476113477113478113479113480113481113482113483113484113485113486113487113488113489113490113491113492113493113494113495113496113497113498113499113500113501113502113503113504113505113506113507113508113509113510113511113512113513113514113515113516113517113518113519113520113521113522113523113524113525113526113527113528113529113530113531113532113533113534113535113536113537113538113539113540113541113542113543113544113545113546113547113548113549113550113551113552113553113554113555113556113557113558113559113560113561113562113563113564113565113566113567113568113569113570113571113572113573113574113575113576113577113578113579113580113581113582113583113584113585113586113587113588113589113590113591113592113593113594113595113596113597113598113599113600113601113602113603113604113605113606113607113608113609113610113611113612113613113614113615113616113617113618113619113620113621113622113623113624113625113626113627113628113629113630113631113632113633113634113635113636113637113638113639113640113641113642113643113644113645113646113647113648113649113650113651113652113653113654113655113656113657113658113659113660113661113662113663113664113665113666113667113668113669113670113671113672113673113674113675113676113677113678113679113680113681113682113683113684113685113686113687113688113689113690113691113692113693113694113695113696113697113698113699113700113701113702113703113704113705113706113707113708113709113710113711113712113713113714113715113716113717113718113719113720113721113722113723113724113725113726113727113728113729113730113731113732113733113734113735113736113737113738113739113740113741113742113743113744113745113746113747113748113749113750113751113752113753113754113755113756113757113758113759113760113761113762113763113764113765113766113767113768113769113770113771113772113773113774113775113776113777113778113779113780113781113782113783113784113785113786113787113788113789113790113791113792113793113794113795113796113797113798113799113800113801113802113803113804113805113806113807113808113809113810113811113812113813113814113815113816113817113818113819113820113821113822113823113824113825113826113827113828113829113830113831113832113833113834113835113836113837113838113839113840113841113842113843113844113845113846113847113848113849113850113851113852113853113854113855113856113857113858113859113860113861113862113863113864113865113866113867113868113869113870113871113872113873113874113875113876113877113878113879113880113881113882113883113884113885113886113887113888113889113890113891113892113893113894113895113896113897113898113899113900113901113902113903113904113905113906113907113908113909113910113911113912113913113914113915113916113917113918113919113920113921113922113923113924113925113926113927113928113929113930113931113932113933113934113935113936113937113938113939113940113941113942113943113944113945113946113947113948113949113950113951113952113953113954113955113956113957113958113959113960113961113962113963113964113965113966113967113968113969113970113971113972113973113974113975113976113977113978113979113980113981113982113983113984113985113986113987113988113989113990113991113992113993113994113995113996113997113998113999114000114001114002114003114004114005114006114007114008114009114010114011114012114013114014114015114016114017114018114019114020114021114022114023114024114025114026114027114028114029114030114031114032114033114034114035114036114037114038114039114040114041114042114043114044114045114046114047114048114049114050114051114052114053114054114055114056114057114058114059114060114061114062114063114064114065114066114067114068114069114070114071114072114073114074114075114076114077114078114079114080114081114082114083114084114085114086114087114088114089114090114091114092114093114094114095114096114097114098114099114100114101114102114103114104114105114106114107114108114109114110114111114112114113114114114115114116114117114118114119114120114121114122114123114124114125114126114127114128114129114130114131114132114133114134114135114136114137114138114139114140114141114142114143114144114145114146114147114148114149114150114151114152114153114154114155114156114157114158114159114160114161114162114163114164114165114166114167114168114169114170114171114172114173114174114175114176114177114178114179114180114181114182114183114184114185114186114187114188114189114190114191114192114193114194114195114196114197114198114199114200114201114202114203114204114205114206114207114208114209114210114211114212114213114214114215114216114217114218114219114220114221114222114223114224114225114226114227114228114229114230114231114232114233114234114235114236114237114238114239114240114241114242114243114244114245114246114247114248114249114250114251114252114253114254114255114256114257114258114259114260114261114262114263114264114265114266114267114268114269114270114271114272114273114274114275114276114277114278114279114280114281114282114283114284114285114286114287114288114289114290114291114292114293114294114295114296114297114298114299114300114301114302114303114304114305114306114307114308114309114310114311114312114313114314114315114316114317114318114319114320114321114322114323114324114325114326114327114328114329114330114331114332114333114334114335114336114337114338114339114340114341114342114343114344114345114346114347114348114349114350114351114352114353114354114355114356114357114358114359114360114361114362114363114364114365114366114367114368114369114370114371114372114373114374114375114376114377114378114379114380114381114382114383114384114385114386114387114388114389114390114391114392114393114394114395114396114397114398114399114400114401114402114403114404114405114406114407114408114409114410114411114412114413114414114415114416114417114418114419114420114421114422114423114424114425114426114427114428114429114430114431114432114433114434114435114436114437114438114439114440114441114442114443114444114445114446114447114448114449114450114451114452114453114454114455114456114457114458114459114460114461114462114463114464114465114466114467114468114469114470114471114472114473114474114475114476114477114478114479114480114481114482114483114484114485114486114487114488114489114490114491114492114493114494114495114496114497114498114499114500114501114502114503114504114505114506114507114508114509114510114511114512114513114514114515114516114517114518114519114520114521114522114523114524114525114526114527114528114529114530114531114532114533114534114535114536114537114538114539114540114541114542114543114544114545114546114547114548114549114550114551114552114553114554114555114556114557114558114559114560114561114562114563114564114565114566114567114568114569114570114571114572114573114574114575114576114577114578114579114580114581114582114583114584114585114586114587114588114589114590114591114592114593114594114595114596114597114598114599114600114601114602114603114604114605114606114607114608114609114610114611114612114613114614114615114616114617114618114619114620114621114622114623114624114625114626114627114628114629114630114631114632114633114634114635114636114637114638114639114640114641114642114643114644114645114646114647114648114649114650114651114652114653114654114655114656114657114658114659114660114661114662114663114664114665114666114667114668114669114670114671114672114673114674114675114676114677114678114679114680114681114682114683114684114685114686114687114688114689114690114691114692114693114694114695114696114697114698114699114700114701114702114703114704114705114706114707114708114709114710114711114712114713114714114715114716114717114718114719114720114721114722114723114724114725114726114727114728114729114730114731114732114733114734114735114736114737114738114739114740114741114742114743114744114745114746114747114748114749114750114751114752114753114754114755114756114757114758114759114760114761114762114763114764114765114766114767114768114769114770114771114772114773114774114775114776114777114778114779114780114781114782114783114784114785114786114787114788114789114790114791114792114793114794114795114796114797114798114799114800114801114802114803114804114805114806114807114808114809114810114811114812114813114814114815114816114817114818114819114820114821114822114823114824114825114826114827114828114829114830114831114832114833114834114835114836114837114838114839114840114841114842114843114844114845114846114847114848114849114850114851114852114853114854114855114856114857114858114859114860114861114862114863114864114865114866114867114868114869114870114871114872114873114874114875114876114877114878114879114880114881114882114883114884114885114886114887114888114889114890114891114892114893114894114895114896114897114898114899114900114901114902114903114904114905114906114907114908114909114910114911114912114913114914114915114916114917114918114919114920114921114922114923114924114925114926114927114928114929114930114931114932114933114934114935114936114937114938114939114940114941114942114943114944114945114946114947114948114949114950114951114952114953114954114955114956114957114958114959114960114961114962114963114964114965114966114967114968114969114970114971114972114973114974114975114976114977114978114979114980114981114982114983114984114985114986114987114988114989114990114991114992114993114994114995114996114997114998114999115000115001115002115003115004115005115006115007115008115009115010115011115012115013115014115015115016115017115018115019115020115021115022115023115024115025115026115027115028115029115030115031115032115033115034115035115036115037115038115039115040115041115042115043115044115045115046115047115048115049115050115051115052115053115054115055115056115057115058115059115060115061115062115063115064115065115066115067115068115069115070115071115072115073115074115075115076115077115078115079115080115081115082115083115084115085115086115087115088115089115090115091115092115093115094115095115096115097115098115099115100115101115102115103115104115105115106115107115108115109115110115111115112115113115114115115115116115117115118115119115120115121115122115123115124115125115126115127115128115129115130115131115132115133115134115135115136115137115138115139115140115141115142115143115144115145115146115147115148115149115150115151115152115153115154115155115156115157115158115159115160115161115162115163115164115165115166115167115168115169115170115171115172115173115174115175115176115177115178115179115180115181115182115183115184115185115186115187115188115189115190115191115192115193115194115195115196115197115198115199115200115201115202115203115204115205115206115207115208115209115210115211115212115213115214115215115216115217115218115219115220115221115222115223115224115225115226115227115228115229115230115231115232115233115234115235115236115237115238115239115240115241115242115243115244115245115246115247115248115249115250115251115252115253115254115255115256115257115258115259115260115261115262115263115264115265115266115267115268115269115270115271115272115273115274115275115276115277115278115279115280115281115282115283115284115285115286115287115288115289115290115291115292115293115294115295115296115297115298115299115300115301115302115303115304115305115306115307115308115309115310115311115312115313115314115315115316115317115318115319115320115321115322115323115324115325115326115327115328115329115330115331115332115333115334115335115336115337115338115339115340115341115342115343115344115345115346115347115348115349115350115351115352115353115354115355115356115357115358115359115360115361115362115363115364115365115366115367115368115369115370115371115372115373115374115375115376115377115378115379115380115381115382115383115384115385115386115387115388115389115390115391115392115393115394115395115396115397115398115399115400115401115402115403115404115405115406115407115408115409115410115411115412115413115414115415115416115417115418115419115420115421115422115423115424115425115426115427115428115429115430115431115432115433115434115435115436115437115438115439115440115441115442115443115444115445115446115447115448115449115450115451115452115453115454115455115456115457115458115459115460115461115462115463115464115465115466115467115468115469115470115471115472115473115474115475115476115477115478115479115480115481115482115483115484115485115486115487115488115489115490115491115492115493115494115495115496115497115498115499115500115501115502115503115504115505115506115507115508115509115510115511115512115513115514115515115516115517115518115519115520115521115522115523115524115525115526115527115528115529115530115531115532115533115534115535115536115537115538115539115540115541115542115543115544115545115546115547115548115549115550115551115552115553115554115555115556115557115558115559115560115561115562115563115564115565115566115567115568115569115570115571115572115573115574115575115576115577115578115579115580115581115582115583115584115585115586115587115588115589115590115591115592115593115594115595115596115597115598115599115600115601115602115603115604115605115606115607115608115609115610115611115612115613115614115615115616115617115618115619115620115621115622115623115624115625115626115627115628115629115630115631115632115633115634115635115636115637115638115639115640115641115642115643115644115645115646115647115648115649115650115651115652115653115654115655115656115657115658115659115660115661115662115663115664115665115666115667115668115669115670115671115672115673115674115675115676115677115678115679115680115681115682115683115684115685115686115687115688115689115690115691115692115693115694115695115696115697115698115699115700115701115702115703115704115705115706115707115708115709115710115711115712115713115714115715115716115717115718115719115720115721115722115723115724115725115726115727115728115729115730115731115732115733115734115735115736115737115738115739115740115741115742115743115744115745115746115747115748115749115750115751115752115753115754115755115756115757115758115759115760115761115762115763115764115765115766115767115768115769115770115771115772115773115774115775115776115777115778115779115780115781115782115783115784115785115786115787115788115789115790115791115792115793115794115795115796115797115798115799115800115801115802115803115804115805115806115807115808115809115810115811115812115813115814115815115816115817115818115819115820115821115822115823115824115825115826115827115828115829115830115831115832115833115834115835115836115837115838115839115840115841115842115843115844115845115846115847115848115849115850115851115852115853115854115855115856115857115858115859115860115861115862115863115864115865115866115867115868115869115870115871115872115873115874115875115876115877115878115879115880115881115882115883115884115885115886115887115888115889115890115891115892115893115894115895115896115897115898115899115900115901115902115903115904115905115906115907115908115909115910115911115912115913115914115915115916115917115918115919115920115921115922115923115924115925115926115927115928115929115930115931115932115933115934115935115936115937115938115939115940115941115942115943115944115945115946115947115948115949115950115951115952115953115954115955115956115957115958115959115960115961115962115963115964115965115966115967115968115969115970115971115972115973115974115975115976115977115978115979115980115981115982115983115984115985115986115987115988115989115990115991115992115993115994115995115996115997115998115999116000116001116002116003116004116005116006116007116008116009116010116011116012116013116014116015116016116017116018116019116020116021116022116023116024116025116026116027116028116029116030116031116032116033116034116035116036116037116038116039116040116041116042116043116044116045116046116047116048116049116050116051116052116053116054116055116056116057116058116059116060116061116062116063116064116065116066116067116068116069116070116071116072116073116074116075116076116077116078116079116080116081116082116083116084116085116086116087116088116089116090116091116092116093116094116095116096116097116098116099116100116101116102116103116104116105116106116107116108116109116110116111116112116113116114116115116116116117116118116119116120116121116122116123116124116125116126116127116128116129116130116131116132116133116134116135116136116137116138116139116140116141116142116143116144116145116146116147116148116149116150116151116152116153116154116155116156116157116158116159116160116161116162116163116164116165116166116167116168116169116170116171116172116173116174116175116176116177116178116179116180116181116182116183116184116185116186116187116188116189116190116191116192116193116194116195116196116197116198116199116200116201116202116203116204116205116206116207116208116209116210116211116212116213116214116215116216116217116218116219116220116221116222116223116224116225116226116227116228116229116230116231116232116233116234116235116236116237116238116239116240116241116242116243116244116245116246116247116248116249116250116251116252116253116254116255116256116257116258116259116260116261116262116263116264116265116266116267116268116269116270116271116272116273116274116275116276116277116278116279116280116281116282116283116284116285116286116287116288116289116290116291116292116293116294116295116296116297116298116299116300116301116302116303116304116305116306116307116308116309116310116311116312116313116314116315116316116317116318116319116320116321116322116323116324116325116326116327116328116329116330116331116332116333116334116335116336116337116338116339116340116341116342116343116344116345116346116347116348116349116350116351116352116353116354116355116356116357116358116359116360116361116362116363116364116365116366116367116368116369116370116371116372116373116374116375116376116377116378116379116380116381116382116383116384116385116386116387116388116389116390116391116392116393116394116395116396116397116398116399116400116401116402116403116404116405116406116407116408116409116410116411116412116413116414116415116416116417116418116419116420116421116422116423116424116425116426116427116428116429116430116431116432116433116434116435116436116437116438116439116440116441116442116443116444116445116446116447116448116449116450116451116452116453116454116455116456116457116458116459116460116461116462116463116464116465116466116467116468116469116470116471116472116473116474116475116476116477116478116479116480116481116482116483116484116485116486116487116488116489116490116491116492116493116494116495116496116497116498116499116500116501116502116503116504116505116506116507116508116509116510116511116512116513116514116515116516116517116518116519116520116521116522116523116524116525116526116527116528116529116530116531116532116533116534116535116536116537116538116539116540116541116542116543116544116545116546116547116548116549116550116551116552116553116554116555116556116557116558116559116560116561116562116563116564116565116566116567116568116569116570116571116572116573116574116575116576116577116578116579116580116581116582116583116584116585116586116587116588116589116590116591116592116593116594116595116596116597116598116599116600116601116602116603116604116605116606116607116608116609116610116611116612116613116614116615116616116617116618116619116620116621116622116623116624116625116626116627116628116629116630116631116632116633116634116635116636116637116638116639116640116641116642116643116644116645116646116647116648116649116650116651116652116653116654116655116656116657116658116659116660116661116662116663116664116665116666116667116668116669116670116671116672116673116674116675116676116677116678116679116680116681116682116683116684116685116686116687116688116689116690116691116692116693116694116695116696116697116698116699116700116701116702116703116704116705116706116707116708116709116710116711116712116713116714116715116716116717116718116719116720116721116722116723116724116725116726116727116728116729116730116731116732116733116734116735116736116737116738116739116740116741116742116743116744116745116746116747116748116749116750116751116752116753116754116755116756116757116758116759116760116761116762116763116764116765116766116767116768116769116770116771116772116773116774116775116776116777116778116779116780116781116782116783116784116785116786116787116788116789116790116791116792116793116794116795116796116797116798116799116800116801116802116803116804116805116806116807116808116809116810116811116812116813116814116815116816116817116818116819116820116821116822116823116824116825116826116827116828116829116830116831116832116833116834116835116836116837116838116839116840116841116842116843116844116845116846116847116848116849116850116851116852116853116854116855116856116857116858116859116860116861116862116863116864116865116866116867116868116869116870116871116872116873116874116875116876116877116878116879116880116881116882116883116884116885116886116887116888116889116890116891116892116893116894116895116896116897116898116899116900116901116902116903116904116905116906116907116908116909116910116911116912116913116914116915116916116917116918116919116920116921116922116923116924116925116926116927116928116929116930116931116932116933116934116935116936116937116938116939116940116941116942116943116944116945116946116947116948116949116950116951116952116953116954116955116956116957116958116959116960116961116962116963116964116965116966116967116968116969116970116971116972116973116974116975116976116977116978116979116980116981116982116983116984116985116986116987116988116989116990116991116992116993116994116995116996116997116998116999117000117001117002117003117004117005117006117007117008117009117010117011117012117013117014117015117016117017117018117019117020117021117022117023117024117025117026117027117028117029117030117031117032117033117034117035117036117037117038117039117040117041117042117043117044117045117046117047117048117049117050117051117052117053117054117055117056117057117058117059117060117061117062117063117064117065117066117067117068117069117070117071117072117073117074117075117076117077117078117079117080117081117082117083117084117085117086117087117088117089117090117091117092117093117094117095117096117097117098117099117100117101117102117103117104117105117106117107117108117109117110117111117112117113117114117115117116117117117118117119117120117121117122117123117124117125117126117127117128117129117130117131117132117133117134117135117136117137117138117139117140117141117142117143117144117145117146117147117148117149117150117151117152117153117154117155117156117157117158117159117160117161117162117163117164117165117166117167117168117169117170117171117172117173117174117175117176117177117178117179117180117181117182117183117184117185117186117187117188117189117190117191117192117193117194117195117196117197117198117199117200117201117202117203117204117205117206117207117208117209117210117211117212117213117214117215117216117217117218117219117220117221117222117223117224117225117226117227117228117229117230117231117232117233117234117235117236117237117238117239117240117241117242117243117244117245117246117247117248117249117250117251117252117253117254117255117256117257117258117259117260117261117262117263117264117265117266117267117268117269117270117271117272117273117274117275117276117277117278117279117280117281117282117283117284117285117286117287117288117289117290117291117292117293117294117295117296117297117298117299117300117301117302117303117304117305117306117307117308117309117310117311117312117313117314117315117316117317117318117319117320117321117322117323117324117325117326117327117328117329117330117331117332117333117334117335117336117337117338117339117340117341117342117343117344117345117346117347117348117349117350117351117352117353117354117355117356117357117358117359117360117361117362117363117364117365117366117367117368117369117370117371117372117373117374117375117376117377117378117379117380117381117382117383117384117385117386117387117388117389117390117391117392117393117394117395117396117397117398117399117400117401117402117403117404117405117406117407117408117409117410117411117412117413117414117415117416117417117418117419117420117421117422117423117424117425117426117427117428117429117430117431117432117433117434117435117436117437117438117439117440117441117442117443117444117445117446117447117448117449117450117451117452117453117454117455117456117457117458117459117460117461117462117463117464117465117466117467117468117469117470117471117472117473117474117475117476117477117478117479117480117481117482117483117484117485117486117487117488117489117490117491117492117493117494117495117496117497117498117499117500117501117502117503117504117505117506117507117508117509117510117511117512117513117514117515117516117517117518117519117520117521117522117523117524117525117526117527117528117529117530117531117532117533117534117535117536117537117538117539117540117541117542117543117544117545117546117547117548117549117550117551117552117553117554117555117556117557117558117559117560117561117562117563117564117565117566117567117568117569117570117571117572117573117574117575117576117577117578117579117580117581117582117583117584117585117586117587117588117589117590117591117592117593117594117595117596117597117598117599117600117601117602117603117604117605117606117607117608117609117610117611117612117613117614117615117616117617117618117619117620117621117622117623117624117625117626117627117628117629117630117631117632117633117634117635117636117637117638117639117640117641117642117643117644117645117646117647117648117649117650117651117652117653117654117655117656117657117658117659117660117661117662117663117664117665117666117667117668117669117670117671117672117673117674117675117676117677117678117679117680117681117682117683117684117685117686117687117688117689117690117691117692117693117694117695117696117697117698117699117700117701117702117703117704117705117706117707117708117709117710117711117712117713117714117715117716117717117718117719117720117721117722117723117724117725117726117727117728117729117730117731117732117733117734117735117736117737117738117739117740117741117742117743117744117745117746117747117748117749117750117751117752117753117754117755117756117757117758117759117760117761117762117763117764117765117766117767117768117769117770117771117772117773117774117775117776117777117778117779117780117781117782117783117784117785117786117787117788117789117790117791117792117793117794117795117796117797117798117799117800117801117802117803117804117805117806117807117808117809117810117811117812117813117814117815117816117817117818117819117820117821117822117823117824117825117826117827117828117829117830117831117832117833117834117835117836117837117838117839117840117841117842117843117844117845117846117847117848117849117850117851117852117853117854117855117856117857117858117859117860117861117862117863117864117865117866117867117868117869117870117871117872117873117874117875117876117877117878117879117880117881117882117883117884117885117886117887117888117889117890117891117892117893117894117895117896117897117898117899117900117901117902117903117904117905117906117907117908117909117910117911117912117913117914117915117916117917117918117919117920117921117922117923117924117925117926117927117928117929117930117931117932117933117934117935117936117937117938117939117940117941117942117943117944117945117946117947117948117949117950117951117952117953117954117955117956117957117958117959117960117961117962117963117964117965117966117967117968117969117970117971117972117973117974117975117976117977117978117979117980117981117982117983117984117985117986117987117988117989117990117991117992117993117994117995117996117997117998117999118000118001118002118003118004118005118006118007118008118009118010118011118012118013118014118015118016118017118018118019118020118021118022118023118024118025118026118027118028118029118030118031118032118033118034118035118036118037118038118039118040118041118042118043118044118045118046118047118048118049118050118051118052118053118054118055118056118057118058118059118060118061118062118063118064118065118066118067118068118069118070118071118072118073118074118075118076118077118078118079118080118081118082118083118084118085118086118087118088118089118090118091118092118093118094118095118096118097118098118099118100118101118102118103118104118105118106118107118108118109118110118111118112118113118114118115118116118117118118118119118120118121118122118123118124118125118126118127118128118129118130118131118132118133118134118135118136118137118138118139118140118141118142118143118144118145118146118147118148118149118150118151118152118153118154118155118156118157118158118159118160118161118162118163118164118165118166118167118168118169118170118171118172118173118174118175118176118177118178118179118180118181118182118183118184118185118186118187118188118189118190118191118192118193118194118195118196118197118198118199118200118201118202118203118204118205118206118207118208118209118210118211118212118213118214118215118216118217118218118219118220118221118222118223118224118225118226118227118228118229118230118231118232118233118234118235118236118237118238118239118240118241118242118243118244118245118246118247118248118249118250118251118252118253118254118255118256118257118258118259118260118261118262118263118264118265118266118267118268118269118270118271118272118273118274118275118276118277118278118279118280118281118282118283118284118285118286118287118288118289118290118291118292118293118294118295118296118297118298118299118300118301118302118303118304118305118306118307118308118309118310118311118312118313118314118315118316118317118318118319118320118321118322118323118324118325118326118327118328118329118330118331118332118333118334118335118336118337118338118339118340118341118342118343118344118345118346118347118348118349118350118351118352118353118354118355118356118357118358118359118360118361118362118363118364118365118366118367118368118369118370118371118372118373118374118375118376118377118378118379118380118381118382118383118384118385118386118387118388118389118390118391118392118393118394118395118396118397118398118399118400118401118402118403118404118405118406118407118408118409118410118411118412118413118414118415118416118417118418118419118420118421118422118423118424118425118426118427118428118429118430118431118432118433118434118435118436118437118438118439118440118441118442118443118444118445118446118447118448118449118450118451118452118453118454118455118456118457118458118459118460118461118462118463118464118465118466118467118468118469118470118471118472118473118474118475118476118477118478118479118480118481118482118483118484118485118486118487118488118489118490118491118492118493118494118495118496118497118498118499118500118501118502118503118504118505118506118507118508118509118510118511118512118513118514118515118516118517118518118519118520118521118522118523118524118525118526118527118528118529118530118531118532118533118534118535118536118537118538118539118540118541118542118543118544118545118546118547118548118549118550118551118552118553118554118555118556118557118558118559118560118561118562118563118564118565118566118567118568118569118570118571118572118573118574118575118576118577118578118579118580118581118582118583118584118585118586118587118588118589118590118591118592118593118594118595118596118597118598118599118600118601118602118603118604118605118606118607118608118609118610118611118612118613118614118615118616118617118618118619118620118621118622118623118624118625118626118627118628118629118630118631118632118633118634118635118636118637118638118639118640118641118642118643118644118645118646118647118648118649118650118651118652118653118654118655118656118657118658118659118660118661118662118663118664118665118666118667118668118669118670118671118672118673118674118675118676118677118678118679118680118681118682118683118684118685118686118687118688118689118690118691118692118693118694118695118696118697118698118699118700118701118702118703118704118705118706118707118708118709118710118711118712118713118714118715118716118717118718118719118720118721118722118723118724118725118726118727118728118729118730118731118732118733118734118735118736118737118738118739118740118741118742118743118744118745118746118747118748118749118750118751118752118753118754118755118756118757118758118759118760118761118762118763118764118765118766118767118768118769118770118771118772118773118774118775118776118777118778118779118780118781118782118783118784118785118786118787118788118789118790118791118792118793118794118795118796118797118798118799118800118801118802118803118804118805118806118807118808118809118810118811118812118813118814118815118816118817118818118819118820118821118822118823118824118825118826118827118828118829118830118831118832118833118834118835118836118837118838118839118840118841118842118843118844118845118846118847118848118849118850118851118852118853118854118855118856118857118858118859118860118861118862118863118864118865118866118867118868118869118870118871118872118873118874118875118876118877118878118879118880118881118882118883118884118885118886118887118888118889118890118891118892118893118894118895118896118897118898118899118900118901118902118903118904118905118906118907118908118909118910118911118912118913118914118915118916118917118918118919118920118921118922118923118924118925118926118927118928118929118930118931118932118933118934118935118936118937118938118939118940118941118942118943118944118945118946118947118948118949118950118951118952118953118954118955118956118957118958118959118960118961118962118963118964118965118966118967118968118969118970118971118972118973118974118975118976118977118978118979118980118981118982118983118984118985118986118987118988118989118990118991118992118993118994118995118996118997118998118999119000119001119002119003119004119005119006119007119008119009119010119011119012119013119014119015119016119017119018119019119020119021119022119023119024119025119026119027119028119029119030119031119032119033119034119035119036119037119038119039119040119041119042119043119044119045119046119047119048119049119050119051119052119053119054119055119056119057119058119059119060119061119062119063119064119065119066119067119068119069119070119071119072119073119074119075119076119077119078119079119080119081119082119083119084119085119086119087119088119089119090119091119092119093119094119095119096119097119098119099119100119101119102119103119104119105119106119107119108119109119110119111119112119113119114119115119116119117119118119119119120119121119122119123119124119125119126119127119128119129119130119131119132119133119134119135119136119137119138119139119140119141119142119143119144119145119146119147119148119149119150119151119152119153119154119155119156119157119158119159119160119161119162119163119164119165119166119167119168119169119170119171119172119173119174119175119176119177119178119179119180119181119182119183119184119185119186119187119188119189119190119191119192119193119194119195119196119197119198119199119200119201119202119203119204119205119206119207119208119209119210119211119212119213119214119215119216119217119218119219119220119221119222119223119224119225119226119227119228119229119230119231119232119233119234119235119236119237119238119239119240119241119242119243119244119245119246119247119248119249119250119251119252119253119254119255119256119257119258119259119260119261119262119263119264119265119266119267119268119269119270119271119272119273119274119275119276119277119278119279119280119281119282119283119284119285119286119287119288119289119290119291119292119293119294119295119296119297119298119299119300119301119302119303119304119305119306119307119308119309119310119311119312119313119314119315119316119317119318119319119320119321119322119323119324119325119326119327119328119329119330119331119332119333119334119335119336119337119338119339119340119341119342119343119344119345119346119347119348119349119350119351119352119353119354119355119356119357119358119359119360119361119362119363119364119365119366119367119368119369119370119371119372119373119374119375119376119377119378119379119380119381119382119383119384119385119386119387119388119389119390119391119392119393119394119395119396119397119398119399119400119401119402119403119404119405119406119407119408119409119410119411119412119413119414119415119416119417119418119419119420119421119422119423119424119425119426119427119428119429119430119431119432119433119434119435119436119437119438119439119440119441119442119443119444119445119446119447119448119449119450119451119452119453119454119455119456119457119458119459119460119461119462119463119464119465119466119467119468119469119470119471119472119473119474119475119476119477119478119479119480119481119482119483119484119485119486119487119488119489119490119491119492119493119494119495119496119497119498119499119500119501119502119503119504119505119506119507119508119509119510119511119512119513119514119515119516119517119518119519119520119521119522119523119524119525119526119527119528119529119530119531119532119533119534119535119536119537119538119539119540119541119542119543119544119545119546119547119548119549119550119551119552119553119554119555119556119557119558119559119560119561119562119563119564119565119566119567119568119569119570119571119572119573119574119575119576119577119578119579119580119581119582119583119584119585119586119587119588119589119590119591119592119593119594119595119596119597119598119599119600119601119602119603119604119605119606119607119608119609119610119611119612119613119614119615119616119617119618119619119620119621119622119623119624119625119626119627119628119629119630119631119632119633119634119635119636119637119638119639119640119641119642119643119644119645119646119647119648119649119650119651119652119653119654119655119656119657119658119659119660119661119662119663119664119665119666119667119668119669119670119671119672119673119674119675119676119677119678119679119680119681119682119683119684119685119686119687119688119689119690119691119692119693119694119695119696119697119698119699119700119701119702119703119704119705119706119707119708119709119710119711119712119713119714119715119716119717119718119719119720119721119722119723119724119725119726119727119728119729119730119731119732119733119734119735119736119737119738119739119740119741119742119743119744119745119746119747119748119749119750119751119752119753119754119755119756119757119758119759119760119761119762119763119764119765119766119767119768119769119770119771119772119773119774119775119776119777119778119779119780119781119782119783119784119785119786119787119788119789119790119791119792119793119794119795119796119797119798119799119800119801119802119803119804119805119806119807119808119809119810119811119812119813119814119815119816119817119818119819119820119821119822119823119824119825119826119827119828119829119830119831119832119833119834119835119836119837119838119839119840119841119842119843119844119845119846119847119848119849119850119851119852119853119854119855119856119857119858119859119860119861119862119863119864119865119866119867119868119869119870119871119872119873119874119875119876119877119878119879119880119881119882119883119884119885119886119887119888119889119890119891119892119893119894119895119896119897119898119899119900119901119902119903119904119905119906119907119908119909119910119911119912119913119914119915119916119917119918119919119920119921119922119923119924119925119926119927119928119929119930119931119932119933119934119935119936119937119938119939119940119941119942119943119944119945119946119947119948119949119950119951119952119953119954119955119956119957119958119959119960119961119962119963119964119965119966119967119968119969119970119971119972119973119974119975119976119977119978119979119980119981119982119983119984119985119986119987119988119989119990119991119992119993119994119995119996119997119998119999120000120001120002120003120004120005120006120007120008120009120010120011120012120013120014120015120016120017120018120019120020120021120022120023120024120025120026120027120028120029120030120031120032120033120034120035120036120037120038120039120040120041120042120043120044120045120046120047120048120049120050120051120052120053120054120055120056120057120058120059120060120061120062120063120064120065120066120067120068120069120070120071120072120073120074120075120076120077120078120079120080120081120082120083120084120085120086120087120088120089120090120091120092120093120094120095120096120097120098120099120100120101120102120103120104120105120106120107120108120109120110120111120112120113120114120115120116120117120118120119120120120121120122120123120124120125120126120127120128120129120130120131120132120133120134120135120136120137120138120139120140120141120142120143120144120145120146120147120148120149120150120151120152120153120154120155120156120157120158120159120160120161120162120163120164120165120166120167120168120169120170120171120172120173120174120175120176120177120178120179120180120181120182120183120184120185120186120187120188120189120190120191120192120193120194120195120196120197120198120199120200120201120202120203120204120205120206120207120208120209120210120211120212120213120214120215120216120217120218120219120220120221120222120223120224120225120226120227120228120229120230120231120232120233120234120235120236120237120238120239120240120241120242120243120244120245120246120247120248120249120250120251120252120253120254120255120256120257120258120259120260120261120262120263120264120265120266120267120268120269120270120271120272120273120274120275120276120277120278120279120280120281120282120283120284120285120286120287120288120289120290120291120292120293120294120295120296120297120298120299120300120301120302120303120304120305120306120307120308120309120310120311120312120313120314120315120316120317120318120319120320120321120322120323120324120325120326120327120328120329120330120331120332120333120334120335120336120337120338120339120340120341120342120343120344120345120346120347120348120349120350120351120352120353120354120355120356120357120358120359120360120361120362120363120364120365120366120367120368120369120370120371120372120373120374120375120376120377120378120379120380120381120382120383120384120385120386120387120388120389120390120391120392120393120394120395120396120397120398120399120400120401120402120403120404120405120406120407120408120409120410120411120412120413120414120415120416120417120418120419120420120421120422120423120424120425120426120427120428120429120430120431120432120433120434120435120436120437120438120439120440120441120442120443120444120445120446120447120448120449120450120451120452120453120454120455120456120457120458120459120460120461120462120463120464120465120466120467120468120469120470120471120472120473120474120475120476120477120478120479120480120481120482120483120484120485120486120487120488120489120490120491120492120493120494120495120496120497120498120499120500120501120502120503120504120505120506120507120508120509120510120511120512120513120514120515120516120517120518120519120520120521120522120523120524120525120526120527120528120529120530120531120532120533120534120535120536120537120538120539120540120541120542120543120544120545120546120547120548120549120550120551120552120553120554120555120556120557120558120559120560120561120562120563120564120565120566120567120568120569120570120571120572120573120574120575120576120577120578120579120580120581120582120583120584120585120586120587120588120589120590120591120592120593120594120595120596120597120598120599120600120601120602120603120604120605120606120607120608120609120610120611120612120613120614120615120616120617120618120619120620120621120622120623120624120625120626120627120628120629120630120631120632120633120634120635120636120637120638120639120640120641120642120643120644120645120646120647120648120649120650120651120652120653120654120655120656120657120658120659120660120661120662120663120664120665120666120667120668120669120670120671120672120673120674120675120676120677120678120679120680120681120682120683120684120685120686120687120688120689120690120691120692120693120694120695120696120697120698120699120700120701120702120703120704120705120706120707120708120709120710120711120712120713120714120715120716120717120718120719120720120721120722120723120724120725120726120727120728120729120730120731120732120733120734120735120736120737120738120739120740120741120742120743120744120745120746120747120748120749120750120751120752120753120754120755120756120757120758120759120760120761120762120763120764120765120766120767120768120769120770120771120772120773120774120775120776120777120778120779120780120781120782120783120784120785120786120787120788120789120790120791120792120793120794120795120796120797120798120799120800120801120802120803120804120805120806120807120808120809120810120811120812120813120814120815120816120817120818120819120820120821120822120823120824120825120826120827120828120829120830120831120832120833120834120835120836120837120838120839120840120841120842120843120844120845120846120847120848120849120850120851120852120853120854120855120856120857120858120859120860120861120862120863120864120865120866120867120868120869120870120871120872120873120874120875120876120877120878120879120880120881120882120883120884120885120886120887120888120889120890120891120892120893120894120895120896120897120898120899120900120901120902120903120904120905120906120907120908120909120910120911120912120913120914120915120916120917120918120919120920120921120922120923120924120925120926120927120928120929120930120931120932120933120934120935120936120937120938120939120940120941120942120943120944120945120946120947120948120949120950120951120952120953120954120955120956120957120958120959120960120961120962120963120964120965120966120967120968120969120970120971120972120973120974120975120976120977120978120979120980120981120982120983120984120985120986120987120988120989120990120991120992120993120994120995120996120997120998120999121000121001121002121003121004121005121006121007121008121009121010121011121012121013121014121015121016121017121018121019121020121021121022121023121024121025121026121027121028121029121030121031121032121033121034121035121036121037121038121039121040121041121042121043121044121045121046121047121048121049121050121051121052121053121054121055121056121057121058121059121060121061121062121063121064121065121066121067121068121069121070121071121072121073121074121075121076121077121078121079121080121081121082121083121084121085121086121087121088121089121090121091121092121093121094121095121096121097121098121099121100121101121102121103121104121105121106121107121108121109121110121111121112121113121114121115121116121117121118121119121120121121121122121123121124121125121126121127121128121129121130121131121132121133121134121135121136121137121138121139121140121141121142121143121144121145121146121147121148121149121150121151121152121153121154121155121156121157121158121159121160121161121162121163121164121165121166121167121168121169121170121171121172121173121174121175121176121177121178121179121180121181121182121183121184121185121186121187121188121189121190121191121192121193121194121195121196121197121198121199121200121201121202121203121204121205121206121207121208121209121210121211121212121213121214121215121216121217121218121219121220121221121222121223121224121225121226121227121228121229121230121231121232121233121234121235121236121237121238121239121240121241121242121243121244121245121246121247121248121249121250121251121252121253121254121255121256121257121258121259121260121261121262121263121264121265121266121267121268121269121270121271121272121273121274121275121276121277121278121279121280121281121282121283121284121285121286121287121288121289121290121291121292121293121294121295121296121297121298121299121300121301121302121303121304121305121306121307121308121309121310121311121312121313121314121315121316121317121318121319121320121321121322121323121324121325121326121327121328121329121330121331121332121333121334121335121336121337121338121339121340121341121342121343121344121345121346121347121348121349121350121351121352121353121354121355121356121357121358121359121360121361121362121363121364121365121366121367121368121369121370121371121372121373121374121375121376121377121378121379121380121381121382121383121384121385121386121387121388121389121390121391121392121393121394121395121396121397121398121399121400121401121402121403121404121405121406121407121408121409121410121411121412121413121414121415121416121417121418121419121420121421121422121423121424121425121426121427121428121429121430121431121432121433121434121435121436121437121438121439121440121441121442121443121444121445121446121447121448121449121450121451121452121453121454121455121456121457121458121459121460121461121462121463121464121465121466121467121468121469121470121471121472121473121474121475121476121477121478121479121480121481121482121483121484121485121486121487121488121489121490121491121492121493121494121495121496121497121498121499121500121501121502121503121504121505121506121507121508121509121510121511121512121513121514121515121516121517121518121519121520121521121522121523121524121525121526121527121528121529121530121531121532121533121534121535121536121537121538121539121540121541121542121543121544121545121546121547121548121549121550121551121552121553121554121555121556121557121558121559121560121561121562121563121564121565121566121567121568121569121570121571121572121573121574121575121576121577121578121579121580121581121582121583121584121585121586121587121588121589121590121591121592121593121594121595121596121597121598121599121600121601121602121603121604121605121606121607121608121609121610121611121612121613121614121615121616121617121618121619121620121621121622121623121624121625121626121627121628121629121630121631121632121633121634121635121636121637121638121639121640121641121642121643121644121645121646121647121648121649121650121651121652121653121654121655121656121657121658121659121660121661121662121663121664121665121666121667121668121669121670121671121672121673121674121675121676121677121678121679121680121681121682121683121684121685121686121687121688121689121690121691121692121693121694121695121696121697121698121699121700121701121702121703121704121705121706121707121708121709121710121711121712121713121714121715121716121717121718121719121720121721121722121723121724121725121726121727121728121729121730121731121732121733121734121735121736121737121738121739121740121741121742121743121744121745121746121747121748121749121750121751121752121753121754121755121756121757121758121759121760121761121762121763121764121765121766121767121768121769121770121771121772121773121774121775121776121777121778121779121780121781121782121783121784121785121786121787121788121789121790121791121792121793121794121795121796121797121798121799121800121801121802121803121804121805121806121807121808121809121810121811121812121813121814121815121816121817121818121819121820121821121822121823121824121825121826121827121828121829121830121831121832121833121834121835121836121837121838121839121840121841121842121843121844121845121846121847121848121849121850121851121852121853121854121855121856121857121858121859121860121861121862121863121864121865121866121867121868121869121870121871121872121873121874121875121876121877121878121879121880121881121882121883121884121885121886121887121888121889121890121891121892121893121894121895121896121897121898121899121900121901121902121903121904121905121906121907121908121909121910121911121912121913121914121915121916121917121918121919121920121921121922121923121924121925121926121927121928121929121930121931121932121933121934121935121936121937121938121939121940121941121942121943121944121945121946121947121948121949121950121951121952121953121954121955121956121957121958121959121960121961121962121963121964121965121966121967121968121969121970121971121972121973121974121975121976121977121978121979121980121981121982121983121984121985121986121987121988121989121990121991121992121993121994121995121996121997121998121999122000122001122002122003122004122005122006122007122008122009122010122011122012122013122014122015122016122017122018122019122020122021122022122023122024122025122026122027122028122029122030122031122032122033122034122035122036122037122038122039122040122041122042122043122044122045122046122047122048122049122050122051122052122053122054122055122056122057122058122059122060122061122062122063122064122065122066122067122068122069122070122071122072122073122074122075122076122077122078122079122080122081122082122083122084122085122086122087122088122089122090122091122092122093122094122095122096122097122098122099122100122101122102122103122104122105122106122107122108122109122110122111122112122113122114122115122116122117122118122119122120122121122122122123122124122125122126122127122128122129122130122131122132122133122134122135122136122137122138122139122140122141122142122143122144122145122146122147122148122149122150122151122152122153122154122155122156122157122158122159122160122161122162122163122164122165122166122167122168122169122170122171122172122173122174122175122176122177122178122179122180122181122182122183122184122185122186122187122188122189122190122191122192122193122194122195122196122197122198122199122200122201122202122203122204122205122206122207122208122209122210122211122212122213122214122215122216122217122218122219122220122221122222122223122224122225122226122227122228122229122230122231122232122233122234122235122236122237122238122239122240122241122242122243122244122245122246122247122248122249122250122251122252122253122254122255122256122257122258122259122260122261122262122263122264122265122266122267122268122269122270122271122272122273122274122275122276122277122278122279122280122281122282122283122284122285122286122287122288122289122290122291122292122293122294122295122296122297122298122299122300122301122302122303122304122305122306122307122308122309122310122311122312122313122314122315122316122317122318122319122320122321122322122323122324122325122326122327122328122329122330122331122332122333122334122335122336122337122338122339122340122341122342122343122344122345122346122347122348122349122350122351122352122353122354122355122356122357122358122359122360122361122362122363122364122365122366122367122368122369122370122371122372122373122374122375122376122377122378122379122380122381122382122383122384122385122386122387122388122389122390122391122392122393122394122395122396122397122398122399122400122401122402122403122404122405122406122407122408122409122410122411122412122413122414122415122416122417122418122419122420122421122422122423122424122425122426122427122428122429122430122431122432122433122434122435122436122437122438122439122440122441122442122443122444122445122446122447122448122449122450122451122452122453122454122455122456122457122458122459122460122461122462122463122464122465122466122467122468122469122470122471122472122473122474122475122476122477122478122479122480122481122482122483122484122485122486122487122488122489122490122491122492122493122494122495122496122497122498122499122500122501122502122503122504122505122506122507122508122509122510122511122512122513122514122515122516122517122518122519122520122521122522122523122524122525122526122527122528122529122530122531122532122533122534122535122536122537122538122539122540122541122542122543122544122545122546122547122548122549122550122551122552122553122554122555122556122557122558122559122560122561122562122563122564122565122566122567122568122569122570122571122572122573122574122575122576122577122578122579122580122581122582122583122584122585122586122587122588122589122590122591122592122593122594122595122596122597122598122599122600122601122602122603122604122605122606122607122608122609122610122611122612122613122614122615122616122617122618122619122620122621122622122623122624122625122626122627122628122629122630122631122632122633122634122635122636122637122638122639122640122641122642122643122644122645122646122647122648122649122650122651122652122653122654122655122656122657122658122659122660122661122662122663122664122665122666122667122668122669122670122671122672122673122674122675122676122677122678122679122680122681122682122683122684122685122686122687122688122689122690122691122692122693122694122695122696122697122698122699122700122701122702122703122704122705122706122707122708122709122710122711122712122713122714122715122716122717122718122719122720122721122722122723122724122725122726122727122728122729122730122731122732122733122734122735122736122737122738122739122740122741122742122743122744122745122746122747122748122749122750122751122752122753122754122755122756122757122758122759122760122761122762122763122764122765122766122767122768122769122770122771122772122773122774122775122776122777122778122779122780122781122782122783122784122785122786122787122788122789122790122791122792122793122794122795122796122797122798122799122800122801122802122803122804122805122806122807122808122809122810122811122812122813122814122815122816122817122818122819122820122821122822122823122824122825122826122827122828122829122830122831122832122833122834122835122836122837122838122839122840122841122842122843122844122845122846122847122848122849122850122851122852122853122854122855122856122857122858122859122860122861122862122863122864122865122866122867122868122869122870122871122872122873122874122875122876122877122878122879122880122881122882122883122884122885122886122887122888122889122890122891122892122893122894122895122896122897122898122899122900122901122902122903122904122905122906122907122908122909122910122911122912122913122914122915122916122917122918122919122920122921122922122923122924122925122926122927122928122929122930122931122932122933122934122935122936122937122938122939122940122941122942122943122944122945122946122947122948122949122950122951122952122953122954122955122956122957122958122959122960122961122962122963122964122965122966122967122968122969122970122971122972122973122974122975122976122977122978122979122980122981122982122983122984122985122986122987122988122989122990122991122992122993122994122995122996122997122998122999123000123001123002123003123004123005123006123007123008123009123010123011123012123013123014123015123016123017123018123019123020123021123022123023123024123025123026123027123028123029123030123031123032123033123034123035123036123037123038123039123040123041123042123043123044123045123046123047123048123049123050123051123052123053123054123055123056123057123058123059123060123061123062123063123064123065123066123067123068123069123070123071123072123073123074123075123076123077123078123079123080123081123082123083123084123085123086123087123088123089123090123091123092123093123094123095123096123097123098123099123100123101123102123103123104123105123106123107123108123109123110123111123112123113123114123115123116123117123118123119123120123121123122123123123124123125123126123127123128123129123130123131123132123133123134123135123136123137123138123139123140123141123142123143123144123145123146123147123148123149123150123151123152123153123154123155123156123157123158123159123160123161123162123163123164123165123166123167123168123169123170123171123172123173123174123175123176123177123178123179123180123181123182123183123184123185123186123187123188123189123190123191123192123193123194123195123196123197123198123199123200123201123202123203123204123205123206123207123208123209123210123211123212123213123214123215123216123217123218123219123220123221123222123223123224123225123226123227123228123229123230123231123232123233123234123235123236123237123238123239123240123241123242123243123244123245123246123247123248123249123250123251123252123253123254123255123256123257123258123259123260123261123262123263123264123265123266123267123268123269123270123271123272123273123274123275123276123277123278123279123280123281123282123283123284123285123286123287123288123289123290123291123292123293123294123295123296123297123298123299123300123301123302123303123304123305123306123307123308123309123310123311123312123313123314123315123316123317123318123319123320123321123322123323123324123325123326123327123328123329123330123331123332123333123334123335123336123337123338123339123340123341123342123343123344123345123346123347123348123349123350123351123352123353123354123355123356123357123358123359123360123361123362123363123364123365123366123367123368123369123370123371123372123373123374123375123376123377123378123379123380123381123382123383123384123385123386123387123388123389123390123391123392123393123394123395123396123397123398123399123400123401123402123403123404123405123406123407123408123409123410123411123412123413123414123415123416123417123418123419123420123421123422123423123424123425123426123427123428123429123430123431123432123433123434123435123436123437123438123439123440123441123442123443123444123445123446123447123448123449123450123451123452123453123454123455123456123457123458123459123460123461123462123463123464123465123466123467123468123469123470123471123472123473123474123475123476123477123478123479123480123481123482123483123484123485123486123487123488123489123490123491123492123493123494123495123496123497123498123499123500123501123502123503123504123505123506123507123508123509123510123511123512123513123514123515123516123517123518123519123520123521123522123523123524123525123526123527123528123529123530123531123532123533123534123535123536123537123538123539123540123541123542123543123544123545123546123547123548123549123550123551123552123553123554123555123556123557123558123559123560123561123562123563123564123565123566123567123568123569123570123571123572123573123574123575123576123577123578123579123580123581123582123583123584123585123586123587123588123589123590123591123592123593123594123595123596123597123598123599123600123601123602123603123604123605123606123607123608123609123610123611123612123613123614123615123616123617123618123619123620123621123622123623123624123625123626123627123628123629123630123631123632123633123634123635123636123637123638123639123640123641123642123643123644123645123646123647123648123649123650123651123652123653123654123655123656123657123658123659123660123661123662123663123664123665123666123667123668123669123670123671123672123673123674123675123676123677123678123679123680123681123682123683123684123685123686123687123688123689123690123691123692123693123694123695123696123697123698123699123700123701123702123703123704123705123706123707123708123709123710123711123712123713123714123715123716123717123718123719123720123721123722123723123724123725123726123727123728123729123730123731123732123733123734123735123736123737123738123739123740123741123742123743123744123745123746123747123748123749123750123751123752123753123754123755123756123757123758123759123760123761123762123763123764123765123766123767123768123769123770123771123772123773123774123775123776123777123778123779123780123781123782123783123784123785123786123787123788123789123790123791123792123793123794123795123796123797123798123799123800123801123802123803123804123805123806123807123808123809123810123811123812123813123814123815123816123817123818123819123820123821123822123823123824123825123826123827123828123829123830123831123832123833123834123835123836123837123838123839123840123841123842123843123844123845123846123847123848123849123850123851123852123853123854123855123856123857123858123859123860123861123862123863123864123865123866123867123868123869123870123871123872123873123874123875123876123877123878123879123880123881123882123883123884123885123886123887123888123889123890123891123892123893123894123895123896123897123898123899123900123901123902123903123904123905123906123907123908123909123910123911123912123913123914123915123916123917123918123919123920123921123922123923123924123925123926123927123928123929123930123931123932123933123934123935123936123937123938123939123940123941123942123943123944123945123946123947123948123949123950123951123952123953123954123955123956123957123958123959123960123961123962123963123964123965123966123967123968123969123970123971123972123973123974123975123976123977123978123979123980123981123982123983123984123985123986123987123988123989123990123991123992123993123994123995123996123997123998123999124000124001124002124003124004124005124006124007124008124009124010124011124012124013124014124015124016124017124018124019124020124021124022124023124024124025124026124027124028124029124030124031124032124033124034124035124036124037124038124039124040124041124042124043124044124045124046124047124048124049124050124051124052124053124054124055124056124057124058124059124060124061124062124063124064124065124066124067124068124069124070124071124072124073124074124075124076124077124078124079124080124081124082124083124084124085124086124087124088124089124090124091124092124093124094124095124096124097124098124099124100124101124102124103124104124105124106124107124108124109124110124111124112124113124114124115124116124117124118124119124120124121124122124123124124124125124126124127124128124129124130124131124132124133124134124135124136124137124138124139124140124141124142124143124144124145124146124147124148124149124150124151124152124153124154124155124156124157124158124159124160124161124162124163124164124165124166124167124168124169124170124171124172124173124174124175124176124177124178124179124180124181124182124183124184124185124186124187124188124189124190124191124192124193124194124195124196124197124198124199124200124201124202124203124204124205124206124207124208124209124210124211124212124213124214124215124216124217124218124219124220124221124222124223124224124225124226124227124228124229124230124231124232124233124234124235124236124237124238124239124240124241124242124243124244124245124246124247124248124249124250124251124252124253124254124255124256124257124258124259124260124261124262124263124264124265124266124267124268124269124270124271124272124273124274124275124276124277124278124279124280124281124282124283124284124285124286124287124288124289124290124291124292124293124294124295124296124297124298124299124300124301124302124303124304124305124306124307124308124309124310124311124312124313124314124315124316124317124318124319124320124321124322124323124324124325124326124327124328124329124330124331124332124333124334124335124336124337124338124339124340124341124342124343124344124345124346124347124348124349124350124351124352124353124354124355124356124357124358124359124360124361124362124363124364124365124366124367124368124369124370124371124372124373124374124375124376124377124378124379124380124381124382124383124384124385124386124387124388124389124390124391124392124393124394124395124396124397124398124399124400124401124402124403124404124405124406124407124408124409124410124411124412124413124414124415124416124417124418124419124420124421124422124423124424124425124426124427124428124429124430124431124432124433124434124435124436124437124438124439124440124441124442124443124444124445124446124447124448124449124450124451124452124453124454124455124456124457124458124459124460124461124462124463124464124465124466124467124468124469124470124471124472124473124474124475124476124477124478124479124480124481124482124483124484124485124486124487124488124489124490124491124492124493124494124495124496124497124498124499124500124501124502124503124504124505124506124507124508124509124510124511124512124513124514124515124516124517124518124519124520124521124522124523124524124525124526124527124528124529124530124531124532124533124534124535124536124537124538124539124540124541124542124543124544124545124546124547124548124549124550124551124552124553124554124555124556124557124558124559124560124561124562124563124564124565124566124567124568124569124570124571124572124573124574124575124576124577124578124579124580124581124582124583124584124585124586124587124588124589124590124591124592124593124594124595124596124597124598124599124600124601124602124603124604124605124606124607124608124609124610124611124612124613124614124615124616124617124618124619124620124621124622124623124624124625124626124627124628124629124630124631124632124633124634124635124636124637124638124639124640124641124642124643124644124645124646124647124648124649124650124651124652124653124654124655124656124657124658124659124660124661124662124663124664124665124666124667124668124669124670124671124672124673124674124675124676124677124678124679124680124681124682124683124684124685124686124687124688124689124690124691124692124693124694124695124696124697124698124699124700124701124702124703124704124705124706124707124708124709124710124711124712124713124714124715124716124717124718124719124720124721124722124723124724124725124726124727124728124729124730124731124732124733124734124735124736124737124738124739124740124741124742124743124744124745124746124747124748124749124750124751124752124753124754124755124756124757124758124759124760124761124762124763124764124765124766124767124768124769124770124771124772124773124774124775124776124777124778124779124780124781124782124783124784124785124786124787124788124789124790124791124792124793124794124795124796124797124798124799124800124801124802124803124804124805124806124807124808124809124810124811124812124813124814124815124816124817124818124819124820124821124822124823124824124825124826124827124828124829124830124831124832124833124834124835124836124837124838124839124840124841124842124843124844124845124846124847124848124849124850124851124852124853124854124855124856124857124858124859124860124861124862124863124864124865124866124867124868124869124870124871124872124873124874124875124876124877124878124879124880124881124882124883124884124885124886124887124888124889124890124891124892124893124894124895124896124897124898124899124900124901124902124903124904124905124906124907124908124909124910124911124912124913124914124915124916124917124918124919124920124921124922124923124924124925124926124927124928124929124930124931124932124933124934124935124936124937124938124939124940124941124942124943124944124945124946124947124948124949124950124951124952124953124954124955124956124957124958124959124960124961124962124963124964124965124966124967124968124969124970124971124972124973124974124975124976124977124978124979124980124981124982124983124984124985124986124987124988124989124990124991124992124993124994124995124996124997124998124999125000125001125002125003125004125005125006125007125008125009125010125011125012125013125014125015125016125017125018125019125020125021125022125023125024125025125026125027125028125029125030125031125032125033125034125035125036125037125038125039125040125041125042125043125044125045125046125047125048125049125050125051125052125053125054125055125056125057125058125059125060125061125062125063125064125065125066125067125068125069125070125071125072125073125074125075125076125077125078125079125080125081125082125083125084125085125086125087125088125089125090125091125092125093125094125095125096125097125098125099125100125101125102125103125104125105125106125107125108125109125110125111125112125113125114125115125116125117125118125119125120125121125122125123125124125125125126125127125128125129125130125131125132125133125134125135125136125137125138125139125140125141125142125143125144125145125146125147125148125149125150125151125152125153125154125155125156125157125158125159125160125161125162125163125164125165125166125167125168125169125170125171125172125173125174125175125176125177125178125179125180125181125182125183125184125185125186125187125188125189125190125191125192125193125194125195125196125197125198125199125200125201125202125203125204125205125206125207125208125209125210125211125212125213125214125215125216125217125218125219125220125221125222125223125224125225125226125227125228125229125230125231125232125233125234125235125236125237125238125239125240125241125242125243125244125245125246125247125248125249125250125251125252125253125254125255125256125257125258125259125260125261125262125263125264125265125266125267125268125269125270125271125272125273125274125275125276125277125278125279125280125281125282125283125284125285125286125287125288125289125290125291125292125293125294125295125296125297125298125299125300125301125302125303125304125305125306125307125308125309125310125311125312125313125314125315125316125317125318125319125320125321125322125323125324125325125326125327125328125329125330125331125332125333125334125335125336125337125338125339125340125341125342125343125344125345125346125347125348125349125350125351125352125353125354125355125356125357125358125359125360125361125362125363125364125365125366125367125368125369125370125371125372125373125374125375125376125377125378125379125380125381125382125383125384125385125386125387125388125389125390125391125392125393125394125395125396125397125398125399125400125401125402125403125404125405125406125407125408125409125410125411125412125413125414125415125416125417125418125419125420125421125422125423125424125425125426125427125428125429125430125431125432125433125434125435125436125437125438125439125440125441125442125443125444125445125446125447125448125449125450125451125452125453125454125455125456125457125458125459125460125461125462125463125464125465125466125467125468125469125470125471125472125473125474125475125476125477125478125479125480125481125482125483125484125485125486125487125488125489125490125491125492125493125494125495125496125497125498125499125500125501125502125503125504125505125506125507125508125509125510125511125512125513125514125515125516125517125518125519125520125521125522125523125524125525125526125527125528125529125530125531125532125533125534125535125536125537125538125539125540125541125542125543125544125545125546125547125548125549125550125551125552125553125554125555125556125557125558125559125560125561125562125563125564125565125566125567125568125569125570125571125572125573125574125575125576125577125578125579125580125581125582125583125584125585125586125587125588125589125590125591125592125593125594125595125596125597125598125599125600125601125602125603125604125605125606125607125608125609125610125611125612125613125614125615125616125617125618125619125620125621125622125623125624125625125626125627125628125629125630125631125632125633125634125635125636125637125638125639125640125641125642125643125644125645125646125647125648125649125650125651125652125653125654125655125656125657125658125659125660125661125662125663125664125665125666125667125668125669125670125671125672125673125674125675125676125677125678125679125680125681125682125683125684125685125686125687125688125689125690125691125692125693125694125695125696125697125698125699125700125701125702125703125704125705125706125707125708125709125710125711125712125713125714125715125716125717125718125719125720125721125722125723125724125725125726125727125728125729125730125731125732125733125734125735125736125737125738125739125740125741125742125743125744125745125746125747125748125749125750125751125752125753125754125755125756125757125758125759125760125761125762125763125764125765125766125767125768125769125770125771125772125773125774125775125776125777125778125779125780125781125782125783125784125785125786125787125788125789125790125791125792125793125794125795125796125797125798125799125800125801125802125803125804125805125806125807125808125809125810125811125812125813125814125815125816125817125818125819125820125821125822125823125824125825125826125827125828125829125830125831125832125833125834125835125836125837125838125839125840125841125842125843125844125845125846125847125848125849125850125851125852125853125854125855125856125857125858125859125860125861125862125863125864125865125866125867125868125869125870125871125872125873125874125875125876125877125878125879125880125881125882125883125884125885125886125887125888125889125890125891125892125893125894125895125896125897125898125899125900125901125902125903125904125905125906125907125908125909125910125911125912125913125914125915125916125917125918125919125920125921125922125923125924125925125926125927125928125929125930125931125932125933125934125935125936125937125938125939125940125941125942125943125944125945125946125947125948125949125950125951125952125953125954125955125956125957125958125959125960125961125962125963125964125965125966125967125968125969125970125971125972125973125974125975125976125977125978125979125980125981125982125983125984125985125986125987125988125989125990125991125992125993125994125995125996125997125998125999126000126001126002126003126004126005126006126007126008126009126010126011126012126013126014126015126016126017126018126019126020126021126022126023126024126025126026126027126028126029126030126031126032126033126034126035126036126037126038126039126040126041126042126043126044126045126046126047126048126049126050126051126052126053126054126055126056126057126058126059126060126061126062126063126064126065126066126067126068126069126070126071126072126073126074126075126076126077126078126079126080126081126082126083126084126085126086126087126088126089126090126091126092126093126094126095126096126097126098126099126100126101126102126103126104126105126106126107126108126109126110126111126112126113126114126115126116126117126118126119126120126121126122126123126124126125126126126127126128126129126130126131126132126133126134126135126136126137126138126139126140126141126142126143126144126145126146126147126148126149126150126151126152126153126154126155126156126157126158126159126160126161126162126163126164126165126166126167126168126169126170126171126172126173126174126175126176126177126178126179126180126181126182126183126184126185126186126187126188126189126190126191126192126193126194126195126196126197126198126199126200126201126202126203126204126205126206126207126208126209126210126211126212126213126214126215126216126217126218126219126220126221126222126223126224126225126226126227126228126229126230126231126232126233126234126235126236126237126238126239126240126241126242126243126244126245126246126247126248126249126250126251126252126253126254126255126256126257126258126259126260126261126262126263126264126265126266126267126268126269126270126271126272126273126274126275126276126277126278126279126280126281126282126283126284126285126286126287126288126289126290126291126292126293126294126295126296126297126298126299126300126301126302126303126304126305126306126307126308126309126310126311126312126313126314126315126316126317126318126319126320126321126322126323126324126325126326126327126328126329126330126331126332126333126334126335126336126337126338126339126340126341126342126343126344126345126346126347126348126349126350126351126352126353126354126355126356126357126358126359126360126361126362126363126364126365126366126367126368126369126370126371126372126373126374126375126376126377126378126379126380126381126382126383126384126385126386126387126388126389126390126391126392126393126394126395126396126397126398126399126400126401126402126403126404126405126406126407126408126409126410126411126412126413126414126415126416126417126418126419126420126421126422126423126424126425126426126427126428126429126430126431126432126433126434126435126436126437126438126439126440126441126442126443126444126445126446126447126448126449126450126451126452126453126454126455126456126457126458126459126460126461126462126463126464126465126466126467126468126469126470126471126472126473126474126475126476126477126478126479126480126481126482126483126484126485126486126487126488126489126490126491126492126493126494126495126496126497126498126499126500126501126502126503126504126505126506126507126508126509126510126511126512126513126514126515126516126517126518126519126520126521126522126523126524126525126526126527126528126529126530126531126532126533126534126535126536126537126538126539126540126541126542126543126544126545126546126547126548126549126550126551126552126553126554126555126556126557126558126559126560126561126562126563126564126565126566126567126568126569126570126571126572126573126574126575126576126577126578126579126580126581126582126583126584126585126586126587126588126589126590126591126592126593126594126595126596126597126598126599126600126601126602126603126604126605126606126607126608126609126610126611126612126613126614126615126616126617126618126619126620126621126622126623126624126625126626126627126628126629126630126631126632126633126634126635126636126637126638126639126640126641126642126643126644126645126646126647126648126649126650126651126652126653126654126655126656126657126658126659126660126661126662126663126664126665126666126667126668126669126670126671126672126673126674126675126676126677126678126679126680126681126682126683126684126685126686126687126688126689126690126691126692126693126694126695126696126697126698126699126700126701126702126703126704126705126706126707126708126709126710126711126712126713126714126715126716126717126718126719126720126721126722126723126724126725126726126727126728126729126730126731126732126733126734126735126736126737126738126739126740126741126742126743126744126745126746126747126748126749126750126751126752126753126754126755126756126757126758126759126760126761126762126763126764126765126766126767126768126769126770126771126772126773126774126775126776126777126778126779126780126781126782126783126784126785126786126787126788126789126790126791126792126793126794126795126796126797126798126799126800126801126802126803126804126805126806126807126808126809126810126811126812126813126814126815126816126817126818126819126820126821126822126823126824126825126826126827126828126829126830126831126832126833126834126835126836126837126838126839126840126841126842126843126844126845126846126847126848126849126850126851126852126853126854126855126856126857126858126859126860126861126862126863126864126865126866126867126868126869126870126871126872126873126874126875126876126877126878126879126880126881126882126883126884126885126886126887126888126889126890126891126892126893126894126895126896126897126898126899126900126901126902126903126904126905126906126907126908126909126910126911126912126913126914126915126916126917126918126919126920126921126922126923126924126925126926126927126928126929126930126931126932126933126934126935126936126937126938126939126940126941126942126943126944126945126946126947126948126949126950126951126952126953126954126955126956126957126958126959126960126961126962126963126964126965126966126967126968126969126970126971126972126973126974126975126976126977126978126979126980126981126982126983126984126985126986126987126988126989126990126991126992126993126994126995126996126997126998126999127000127001127002127003127004127005127006127007127008127009127010127011127012127013127014127015127016127017127018127019127020127021127022127023127024127025127026127027127028127029127030127031127032127033127034127035127036127037127038127039127040127041127042127043127044127045127046127047127048127049127050127051127052127053127054127055127056127057127058127059127060127061127062127063127064127065127066127067127068127069127070127071127072127073127074127075127076127077127078127079127080127081127082127083127084127085127086127087127088127089127090127091127092127093127094127095127096127097127098127099127100127101127102127103127104127105127106127107127108127109127110127111127112127113127114127115127116127117127118127119127120127121127122127123127124127125127126127127127128127129127130127131127132127133127134127135127136127137127138127139127140127141127142127143127144127145127146127147127148127149127150127151127152127153127154127155127156127157127158127159127160127161127162127163127164127165127166127167127168127169127170127171127172127173127174127175127176127177127178127179127180127181127182127183127184127185127186127187127188127189127190127191127192127193127194127195127196127197127198127199127200127201127202127203127204127205127206127207127208127209127210127211127212127213127214127215127216127217127218127219127220127221127222127223127224127225127226127227127228127229127230127231127232127233127234127235127236127237127238127239127240127241127242127243127244127245127246127247127248127249127250127251127252127253127254127255127256127257127258127259127260127261127262127263127264127265127266127267127268127269127270127271127272127273127274127275127276127277127278127279127280127281127282127283127284127285127286127287127288127289127290127291127292127293127294127295127296127297127298127299127300127301127302127303127304127305127306127307127308127309127310127311127312127313127314127315127316127317127318127319127320127321127322127323127324127325127326127327127328127329127330127331127332127333127334127335127336127337127338127339127340127341127342127343127344127345127346127347127348127349127350127351127352127353127354127355127356127357127358127359127360127361127362127363127364127365127366127367127368127369127370127371127372127373127374127375127376127377127378127379127380127381127382127383127384127385127386127387127388127389127390127391127392127393127394127395127396127397127398127399127400127401127402127403127404127405127406127407127408127409127410127411127412127413127414127415127416127417127418127419127420127421127422127423127424127425127426127427127428127429127430127431127432127433127434127435127436127437127438127439127440127441127442127443127444127445127446127447127448127449127450127451127452127453127454127455127456127457127458127459127460127461127462127463127464127465127466127467127468127469127470127471127472127473127474127475127476127477127478127479127480127481127482127483127484127485127486127487127488127489127490127491127492127493127494127495127496127497127498127499127500127501127502127503127504127505127506127507127508127509127510127511127512127513127514127515127516127517127518127519127520127521127522127523127524127525127526127527127528127529127530127531127532127533127534127535127536127537127538127539127540127541127542127543127544127545127546127547127548127549127550127551127552127553127554127555127556127557127558127559127560127561127562127563127564127565127566127567127568127569127570127571127572127573127574127575127576127577127578127579127580127581127582127583127584127585127586127587127588127589127590127591127592127593127594127595127596127597127598127599127600127601127602127603127604127605127606127607127608127609127610127611127612127613127614127615127616127617127618127619127620127621127622127623127624127625127626127627127628127629127630127631127632127633127634127635127636127637127638127639127640127641127642127643127644127645127646127647127648127649127650127651127652127653127654127655127656127657127658127659127660127661127662127663127664127665127666127667127668127669127670127671127672127673127674127675127676127677127678127679127680127681127682127683127684127685127686127687127688127689127690127691127692127693127694127695127696127697127698127699127700127701127702127703127704127705127706127707127708127709127710127711127712127713127714127715127716127717127718127719127720127721127722127723127724127725127726127727127728127729127730127731127732127733127734127735127736127737127738127739127740127741127742127743127744127745127746127747127748127749127750127751127752127753127754127755127756127757127758127759127760127761127762127763127764127765127766127767127768127769127770127771127772127773127774127775127776127777127778127779127780127781127782127783127784127785127786127787127788127789127790127791127792127793127794127795127796127797127798127799127800127801127802127803127804127805127806127807127808127809127810127811127812127813127814127815127816127817127818127819127820127821127822127823127824127825127826127827127828127829127830127831127832127833127834127835127836127837127838127839127840127841127842127843127844127845127846127847127848127849127850127851127852127853127854127855127856127857127858127859127860127861127862127863127864127865127866127867127868127869127870127871127872127873127874127875127876127877127878127879127880127881127882127883127884127885127886127887127888127889127890127891127892127893127894127895127896127897127898127899127900127901127902127903127904127905127906127907127908127909127910127911127912127913127914127915127916127917127918127919127920127921127922127923127924127925127926127927127928127929127930127931127932127933127934127935127936127937127938127939127940127941127942127943127944127945127946127947127948127949127950127951127952127953127954127955127956127957127958127959127960127961127962127963127964127965127966127967127968127969127970127971127972127973127974127975127976127977127978127979127980127981127982127983127984127985127986127987127988127989127990127991127992127993127994127995127996127997127998127999128000128001128002128003128004128005128006128007128008128009128010128011128012128013128014128015128016128017128018128019128020128021128022128023128024128025128026128027128028128029128030128031128032128033128034128035128036128037128038128039128040128041128042128043128044128045128046128047128048128049128050128051128052128053128054128055128056128057128058128059128060128061128062128063128064128065128066128067128068128069128070128071128072128073128074128075128076128077128078128079128080128081128082128083128084128085128086128087128088128089128090128091128092128093128094128095128096128097128098128099128100128101128102128103128104128105128106128107128108128109128110128111128112128113128114128115128116128117128118128119128120128121128122128123128124128125128126128127128128128129128130128131128132128133128134128135128136128137128138128139128140128141128142128143128144128145128146128147128148128149128150128151128152128153128154128155128156128157128158128159128160128161128162128163128164128165128166128167128168128169128170128171128172128173128174128175128176128177128178128179128180128181128182128183128184128185128186128187128188128189128190128191128192128193128194128195128196128197128198128199128200128201128202128203128204128205128206128207128208128209128210128211128212128213128214128215128216128217128218128219128220128221128222128223128224128225128226128227128228128229128230128231128232128233128234128235128236128237128238128239128240128241128242128243128244128245128246128247128248128249128250128251128252128253128254128255128256128257128258128259128260128261128262128263128264128265128266128267128268128269128270128271128272128273128274128275128276128277128278128279128280128281128282128283128284128285128286128287128288128289128290128291128292128293128294128295128296128297128298128299128300128301128302128303128304128305128306128307128308128309128310128311128312128313128314128315128316128317128318128319128320128321128322128323128324128325128326128327128328128329128330128331128332128333128334128335128336128337128338128339128340128341128342128343128344128345128346128347128348128349128350128351128352128353128354128355128356128357128358128359128360128361128362128363128364128365128366128367128368128369128370128371128372128373128374128375128376128377128378128379128380128381128382128383128384128385128386128387128388128389128390128391128392128393128394128395128396128397128398128399128400128401128402128403128404128405128406128407128408128409128410128411128412128413128414128415128416128417128418128419128420128421128422128423128424128425128426128427128428128429128430128431128432128433128434128435128436128437128438128439128440128441128442128443128444128445128446128447128448128449128450128451128452128453128454128455128456128457128458128459128460128461128462128463128464128465128466128467128468128469128470128471128472128473128474128475128476128477128478128479128480128481128482128483128484128485128486128487128488128489128490128491128492128493128494128495128496128497128498128499128500128501128502128503128504128505128506128507128508128509128510128511128512128513128514128515128516128517128518128519128520128521128522128523128524128525128526128527128528128529128530128531128532128533128534128535128536128537128538128539128540128541128542128543128544128545128546128547128548128549128550128551128552128553128554128555128556128557128558128559128560128561128562128563128564128565128566128567128568128569128570128571128572128573128574128575128576128577128578128579128580128581128582128583128584128585128586128587128588128589128590128591128592128593128594128595128596128597128598128599128600128601128602128603128604128605128606128607128608128609128610128611128612128613128614128615128616128617128618128619128620128621128622128623128624128625128626128627128628128629128630128631128632128633128634128635128636128637128638128639128640128641128642128643128644128645128646128647128648128649128650128651128652128653128654128655128656128657128658128659128660128661128662128663128664128665128666128667128668128669128670128671128672128673128674128675128676128677128678128679128680128681128682128683128684128685128686128687128688128689128690128691128692128693128694128695128696128697128698128699128700128701128702128703128704128705128706128707128708128709128710128711128712128713128714128715128716128717128718128719128720128721128722128723128724128725128726128727128728128729128730128731128732128733128734128735128736128737128738128739128740128741128742128743128744128745128746128747128748128749128750128751128752128753128754128755128756128757128758128759128760128761128762128763128764128765128766128767128768128769128770128771128772128773128774128775128776128777128778128779128780128781128782128783128784128785128786128787128788128789128790128791128792128793128794128795128796128797128798128799128800128801128802128803128804128805128806128807128808128809128810128811128812128813128814128815128816128817128818128819128820128821128822128823128824128825128826128827128828128829128830128831128832128833128834128835128836128837128838128839128840128841128842128843128844128845128846128847128848128849128850128851128852128853128854128855128856128857128858128859128860128861128862128863128864128865128866128867128868128869128870128871128872128873128874128875128876128877128878128879128880128881128882128883128884128885128886128887128888128889128890128891128892128893128894128895128896128897128898128899128900128901128902128903128904128905128906128907128908128909128910128911128912128913128914128915128916128917128918128919128920128921128922128923128924128925128926128927128928128929128930128931128932128933128934128935128936128937128938128939128940128941128942128943128944128945128946128947128948128949128950128951128952128953128954128955128956128957128958128959128960128961128962128963128964128965128966128967128968128969128970128971128972128973128974128975128976128977128978128979128980128981128982128983128984128985128986128987128988128989128990128991128992128993128994128995128996128997128998128999129000129001129002129003129004129005129006129007129008129009129010129011129012129013129014129015129016129017129018129019129020129021129022129023129024129025129026129027129028129029129030129031129032129033129034129035129036129037129038129039129040129041129042129043129044129045129046129047129048129049129050129051129052129053129054129055129056129057129058129059129060129061129062129063129064129065129066129067129068129069129070129071129072129073129074129075129076129077129078129079129080129081129082129083129084129085129086129087129088129089129090129091129092129093129094129095129096129097129098129099129100129101129102129103129104129105129106129107129108129109129110129111129112129113129114129115129116129117129118129119129120129121129122129123129124129125129126129127129128129129129130129131129132129133129134129135129136129137129138129139129140129141129142129143129144129145129146129147129148129149129150129151129152129153129154129155129156129157129158129159129160129161129162129163129164129165129166129167129168129169129170129171129172129173129174129175129176129177129178129179129180129181129182129183129184129185129186129187129188129189129190129191129192129193129194129195129196129197129198129199129200129201129202129203129204129205129206129207129208129209129210129211129212129213129214129215129216129217129218129219129220129221129222129223129224129225129226129227129228129229129230129231129232129233129234129235129236129237129238129239129240129241129242129243129244129245129246129247129248129249129250129251129252129253129254129255129256129257129258129259129260129261129262129263129264129265129266129267129268129269129270129271129272129273129274129275129276129277129278129279129280129281129282129283129284129285129286129287129288129289129290129291129292129293129294129295129296129297129298129299129300129301129302129303129304129305129306129307129308129309129310129311129312129313129314129315129316129317129318129319129320129321129322129323129324129325129326129327129328129329129330129331129332129333129334129335129336129337129338129339129340129341129342129343129344129345129346129347129348129349129350129351129352129353129354129355129356129357129358129359129360129361129362129363129364129365129366129367129368129369129370129371129372129373129374129375129376129377129378129379129380129381129382129383129384129385129386129387129388129389129390129391129392129393129394129395129396129397129398129399129400129401129402129403129404129405129406129407129408129409129410129411129412129413129414129415129416129417129418129419129420129421129422129423129424129425129426129427129428129429129430129431129432129433129434129435129436129437129438129439129440129441129442129443129444129445129446129447129448129449129450129451129452129453129454129455129456129457129458129459129460129461129462129463129464129465129466129467129468129469129470129471129472129473129474129475129476129477129478129479129480129481129482129483129484129485129486129487129488129489129490129491129492129493129494129495129496129497129498129499129500129501129502129503129504129505129506129507129508129509129510129511129512129513129514129515129516129517129518129519129520129521129522129523129524129525129526129527129528129529129530129531129532129533129534129535129536129537129538129539129540129541129542129543129544129545129546129547129548129549129550129551129552129553129554129555129556129557129558129559129560129561129562129563129564129565129566129567129568129569129570129571129572129573129574129575129576129577129578129579129580129581129582129583129584129585129586129587129588129589129590129591129592129593129594129595129596129597129598129599129600129601129602129603129604129605129606129607129608129609129610129611129612129613129614129615129616129617129618129619129620129621129622129623129624129625129626129627129628129629129630129631129632129633129634129635129636129637129638129639129640129641129642129643129644129645129646129647129648129649129650129651129652129653129654129655129656129657129658129659129660129661129662129663129664129665129666129667129668129669129670129671129672129673129674129675129676129677129678129679129680129681129682129683129684129685129686129687129688129689129690129691129692129693129694129695129696129697129698129699129700129701129702129703129704129705129706129707129708129709129710129711129712129713129714129715129716129717129718129719129720129721129722129723129724129725129726129727129728129729129730129731129732129733129734129735129736129737129738129739129740129741129742129743129744129745129746129747129748129749129750129751129752129753129754129755129756129757129758129759129760129761129762129763129764129765129766129767129768129769129770129771129772129773129774129775129776129777129778129779129780129781129782129783129784129785129786129787129788129789129790129791129792129793129794129795129796129797129798129799129800129801129802129803129804129805129806129807129808129809129810129811129812129813129814129815129816129817129818129819129820129821129822129823129824129825129826129827129828129829129830129831129832129833129834129835129836129837129838129839129840129841129842129843129844129845129846129847129848129849129850129851129852129853129854129855129856129857129858129859129860129861129862129863129864129865129866129867129868129869129870129871129872129873129874129875129876129877129878129879129880129881129882129883129884129885129886129887129888129889129890129891129892129893129894129895129896129897129898129899129900129901129902129903129904129905129906129907129908129909129910129911129912129913129914129915129916129917129918129919129920129921129922129923129924129925129926129927129928129929129930129931129932129933129934129935129936129937129938129939129940129941129942129943129944129945129946129947129948129949129950129951129952129953129954129955129956129957129958129959129960129961129962129963129964129965129966129967129968129969129970129971129972129973129974129975129976129977129978129979129980129981129982129983129984129985129986129987129988129989129990129991129992129993129994129995129996129997129998129999130000130001130002130003130004130005130006130007130008130009130010130011130012130013130014130015130016130017130018130019130020130021130022130023130024130025130026130027130028130029130030130031130032130033130034130035130036130037130038130039130040130041130042130043130044130045130046130047130048130049130050130051130052130053130054130055130056130057130058130059130060130061130062130063130064130065130066130067130068130069130070130071130072130073130074130075130076130077130078130079130080130081130082130083130084130085130086130087130088130089130090130091130092130093130094130095130096130097130098130099130100130101130102130103130104130105130106130107130108130109130110130111130112130113130114130115130116130117130118130119130120130121130122130123130124130125130126130127130128130129130130130131130132130133130134130135130136130137130138130139130140130141130142130143130144130145130146130147130148130149130150130151130152130153130154130155130156130157130158130159130160130161130162130163130164130165130166130167130168130169130170130171130172130173130174130175130176130177130178130179130180130181130182130183130184130185130186130187130188130189130190130191130192130193130194130195130196130197130198130199130200130201130202130203130204130205130206130207130208130209130210130211130212130213130214130215130216130217130218130219130220130221130222130223130224130225130226130227130228130229130230130231130232130233130234130235130236130237130238130239130240130241130242130243130244130245130246130247130248130249130250130251130252130253130254130255130256130257130258130259130260130261130262130263130264130265130266130267130268130269130270130271130272130273130274130275130276130277130278130279130280130281130282130283130284130285130286130287130288130289130290130291130292130293130294130295130296130297130298130299130300130301130302130303130304130305130306130307130308130309130310130311130312130313130314130315130316130317130318130319130320130321130322130323130324130325130326130327130328130329130330130331130332130333130334130335130336130337130338130339130340130341130342130343130344130345130346130347130348130349130350130351130352130353130354130355130356130357130358130359130360130361130362130363130364130365130366130367130368130369130370130371130372130373130374130375130376130377130378130379130380130381130382130383130384130385130386130387130388130389130390130391130392130393130394130395130396130397130398130399130400130401130402130403130404130405130406130407130408130409130410130411130412130413130414130415130416130417130418130419130420130421130422130423130424130425130426130427130428130429130430130431130432130433130434130435130436130437130438130439130440130441130442130443130444130445130446130447130448130449130450130451130452130453130454130455130456130457130458130459130460130461130462130463130464130465130466130467130468130469130470130471130472130473130474130475130476130477130478130479130480130481130482130483130484130485130486130487130488130489130490130491130492130493130494130495130496130497130498130499130500130501130502130503130504130505130506130507130508130509130510130511130512130513130514130515130516130517130518130519130520130521130522130523130524130525130526130527130528130529130530130531130532130533130534130535130536130537130538130539130540130541130542130543130544130545130546130547130548130549130550130551130552130553130554130555130556130557130558130559130560130561130562130563130564130565130566130567130568130569130570130571130572130573130574130575130576130577130578130579130580130581130582130583130584130585130586130587130588130589130590130591130592130593130594130595130596130597130598130599130600130601130602130603130604130605130606130607130608130609130610130611130612130613130614130615130616130617130618130619130620130621130622130623130624130625130626130627130628130629130630130631130632130633130634130635130636130637130638130639130640130641130642130643130644130645130646130647130648130649130650130651130652130653130654130655130656130657130658130659130660130661130662130663130664130665130666130667130668130669130670130671130672130673130674130675130676130677130678130679130680130681130682130683130684130685130686130687130688130689130690130691130692130693130694130695130696130697130698130699130700130701130702130703130704130705130706130707130708130709130710130711130712130713130714130715130716130717130718130719130720130721130722130723130724130725130726130727130728130729130730130731130732130733130734130735130736130737130738130739130740130741130742130743130744130745130746130747130748130749130750130751130752130753130754130755130756130757130758130759130760130761130762130763130764130765130766130767130768130769130770130771130772130773130774130775130776130777130778130779130780130781130782130783130784130785130786130787130788130789130790130791130792130793130794130795130796130797130798130799130800130801130802130803130804130805130806130807130808130809130810130811130812130813130814130815130816130817130818130819130820130821130822130823130824130825130826130827130828130829130830130831130832130833130834130835130836130837130838130839130840130841130842130843130844130845130846130847130848130849130850130851130852130853130854130855130856130857130858130859130860130861130862130863130864130865130866130867130868130869130870130871130872130873130874130875130876130877130878130879130880130881130882130883130884130885130886130887130888130889130890130891130892130893130894130895130896130897130898130899130900130901130902130903130904130905130906130907130908130909130910130911130912130913130914130915130916130917130918130919130920130921130922130923130924130925130926130927130928130929130930130931130932130933130934130935130936130937130938130939130940130941130942130943130944130945130946130947130948130949130950130951130952130953130954130955130956130957130958130959130960130961130962130963130964130965130966130967130968130969130970130971130972130973130974130975130976130977130978130979130980130981130982130983130984130985130986130987130988130989130990130991130992130993130994130995130996130997130998130999131000131001131002131003131004131005131006131007131008131009131010131011131012131013131014131015131016131017131018131019131020131021131022131023131024131025131026131027131028131029131030131031131032131033131034131035131036131037131038131039131040131041131042131043131044131045131046131047131048131049131050131051131052131053131054131055131056131057131058131059131060131061131062131063131064131065131066131067131068131069131070131071131072131073131074131075131076131077131078131079131080131081131082131083131084131085131086131087131088131089131090131091131092131093131094131095131096131097131098131099131100131101131102131103131104131105131106131107131108131109131110131111131112131113131114131115131116131117131118131119131120131121131122131123131124131125131126131127131128131129131130131131131132131133131134131135131136131137131138131139131140131141131142131143131144131145131146131147131148131149131150131151131152131153131154131155131156131157131158131159131160131161131162131163131164131165131166131167131168131169131170131171131172131173131174131175131176131177131178131179131180131181131182131183131184131185131186131187131188131189131190131191131192131193131194131195131196131197131198131199131200131201131202131203131204131205131206131207131208131209131210131211131212131213131214131215131216131217131218131219131220131221131222131223131224131225131226131227131228131229131230131231131232131233131234131235131236131237131238131239131240131241131242131243131244131245131246131247131248131249131250131251131252131253131254131255131256131257131258131259131260131261131262131263131264131265131266131267131268131269131270131271131272131273131274131275131276131277131278131279131280131281131282131283131284131285131286131287131288131289131290131291131292131293131294131295131296131297131298131299131300131301131302131303131304131305131306131307131308131309131310131311131312131313131314131315131316131317131318131319131320131321131322131323131324131325131326131327131328131329131330131331131332131333131334131335131336131337131338131339131340131341131342131343131344131345131346131347131348131349131350131351131352131353131354131355131356131357131358131359131360131361131362131363131364131365131366131367131368131369131370131371131372131373131374131375131376131377131378131379131380131381131382131383131384131385131386131387131388131389131390131391131392131393131394131395131396131397131398131399131400131401131402131403131404131405131406131407131408131409131410131411131412131413131414131415131416131417131418131419131420131421131422131423131424131425131426131427131428131429131430131431131432131433131434131435131436131437131438131439131440131441131442131443131444131445131446131447131448131449131450131451131452131453131454131455131456131457131458131459131460131461131462131463131464131465131466131467131468131469131470131471131472131473131474131475131476131477131478131479131480131481131482131483131484131485131486131487131488131489131490131491131492131493131494131495131496131497131498131499131500131501131502131503131504131505131506131507131508131509131510131511131512131513131514131515131516131517131518131519131520131521131522131523131524131525131526131527131528131529131530131531131532131533131534131535131536131537131538131539131540131541131542131543131544131545131546131547131548131549131550131551131552131553131554131555131556131557131558131559131560131561131562131563131564131565131566131567131568131569131570131571131572131573131574131575131576131577131578131579131580131581131582131583131584131585131586131587131588131589131590131591131592131593131594131595131596131597131598131599131600131601131602131603131604131605131606131607131608131609131610131611131612131613131614131615131616131617131618131619131620131621131622131623131624131625131626131627131628131629131630131631131632131633131634131635131636131637131638131639131640131641131642131643131644131645131646131647131648131649131650131651131652131653131654131655131656131657131658131659131660131661131662131663131664131665131666131667131668131669131670131671131672131673131674131675131676131677131678131679131680131681131682131683131684131685131686131687131688131689131690131691131692131693131694131695131696131697131698131699131700131701131702131703131704131705131706131707131708131709131710131711131712131713131714131715131716131717131718131719131720131721131722131723131724131725131726131727131728131729131730131731131732131733131734131735131736131737131738131739131740131741131742131743131744131745131746131747131748131749131750131751131752131753131754131755131756131757131758131759131760131761131762131763131764131765131766131767131768131769131770131771131772131773131774131775131776131777131778131779131780131781131782131783131784131785131786131787131788131789131790131791131792131793131794131795131796131797131798131799131800131801131802131803131804131805131806131807131808131809131810131811131812131813131814131815131816131817131818131819131820131821131822131823131824131825131826131827131828131829131830131831131832131833131834131835131836131837131838131839131840131841131842131843131844131845131846131847131848131849131850131851131852131853131854131855131856131857131858131859131860131861131862131863131864131865131866131867131868131869131870131871131872131873131874131875131876131877131878131879131880131881131882131883131884131885131886131887131888131889131890131891131892131893131894131895131896131897131898131899131900131901131902131903131904131905131906131907131908131909131910131911131912131913131914131915131916131917131918131919131920131921131922131923131924131925131926131927131928131929131930131931131932131933131934131935131936131937131938131939131940131941131942131943131944131945131946131947131948131949131950131951131952131953131954131955131956131957131958131959131960131961131962131963131964131965131966131967131968131969131970131971131972131973131974131975131976131977131978131979131980131981131982131983131984131985131986131987131988131989131990131991131992131993131994131995131996131997131998131999132000132001132002132003132004132005132006132007132008132009132010132011132012132013132014132015132016132017132018132019132020132021132022132023132024132025132026132027132028132029132030132031132032132033132034132035132036132037132038132039132040132041132042132043132044132045132046132047132048132049132050132051132052132053132054132055132056132057132058132059132060132061132062132063132064132065132066132067132068132069132070132071132072132073132074132075132076132077132078132079132080132081132082132083132084132085132086132087132088132089132090132091132092132093132094132095132096132097132098132099132100132101132102132103132104132105132106132107132108132109132110132111132112132113132114132115132116132117132118132119132120132121132122132123132124132125132126132127132128132129132130132131132132132133132134132135132136132137132138132139132140132141132142132143132144132145132146132147132148132149132150132151132152132153132154132155132156132157132158132159132160132161132162132163132164132165132166132167132168132169132170132171132172132173132174132175132176132177132178132179132180132181132182132183132184132185132186132187132188132189132190132191132192132193132194132195132196132197132198132199132200132201132202132203132204132205132206132207132208132209132210132211132212132213132214132215132216132217132218132219132220132221132222132223132224132225132226132227132228132229132230132231132232132233132234132235132236132237132238132239132240132241132242132243132244132245132246132247132248132249132250132251132252132253132254132255132256132257132258132259132260132261132262132263132264132265132266132267132268132269132270132271132272132273132274132275132276132277132278132279132280132281132282132283132284132285132286132287132288132289132290132291132292132293132294132295132296132297132298132299132300132301132302132303132304132305132306132307132308132309132310132311132312132313132314132315132316132317132318132319132320132321132322132323132324132325132326132327132328132329132330132331132332132333132334132335132336132337132338132339132340132341132342132343132344132345132346132347132348132349132350132351132352132353132354132355132356132357132358132359132360132361132362132363132364132365132366132367132368132369132370132371132372132373132374132375132376132377132378132379132380132381132382132383132384132385132386132387132388132389132390132391132392132393132394132395132396132397132398132399132400132401132402132403132404132405132406132407132408132409132410132411132412132413132414132415132416132417132418132419132420132421132422132423132424132425132426132427132428132429132430132431132432132433132434132435132436132437132438132439132440132441132442132443132444132445132446132447132448132449132450132451132452132453132454132455132456132457132458132459132460132461132462132463132464132465132466132467132468132469132470132471132472132473132474132475132476132477132478132479132480132481132482132483132484132485132486132487132488132489132490132491132492132493132494132495132496132497132498132499132500132501132502132503132504132505132506132507132508132509132510132511132512132513132514132515132516132517132518132519132520132521132522132523132524132525132526132527132528132529132530132531132532132533132534132535132536132537132538132539132540132541132542132543132544132545132546132547132548132549132550132551132552132553132554132555132556132557132558132559132560132561132562132563132564132565132566132567132568132569132570132571132572132573132574132575132576132577132578132579132580132581132582132583132584132585132586132587132588132589132590132591132592132593132594132595132596132597132598132599132600132601132602132603132604132605132606132607132608132609132610132611132612132613132614132615132616132617132618132619132620132621132622132623132624132625132626132627132628132629132630132631132632132633132634132635132636132637132638132639132640132641132642132643132644132645132646132647132648132649132650132651132652132653132654132655132656132657132658132659132660132661132662132663132664132665132666132667132668132669132670132671132672132673132674132675132676132677132678132679132680132681132682132683132684132685132686132687132688132689132690132691132692132693132694132695132696132697132698132699132700132701132702132703132704132705132706132707132708132709132710132711132712132713132714132715132716132717132718132719132720132721132722132723132724132725132726132727132728132729132730132731132732132733132734132735132736132737132738132739132740132741132742132743132744132745132746132747132748132749132750132751132752132753132754132755132756132757132758132759132760132761132762132763132764132765132766132767132768132769132770132771132772132773132774132775132776132777132778132779132780132781132782132783132784132785132786132787132788132789132790132791132792132793132794132795132796132797132798132799132800132801132802132803132804132805132806132807132808132809132810132811132812132813132814132815132816132817132818132819132820132821132822132823132824132825132826132827132828132829132830132831132832132833132834132835132836132837132838132839132840132841132842132843132844132845132846132847132848132849132850132851132852132853132854132855132856132857132858132859132860132861132862132863132864132865132866132867132868132869132870132871132872132873132874132875132876132877132878132879132880132881132882132883132884132885132886132887132888132889132890132891132892132893132894132895132896132897132898132899132900132901132902132903132904132905132906132907132908132909132910132911132912132913132914132915132916132917132918132919132920132921132922132923132924132925132926132927132928132929132930132931132932132933132934132935132936132937132938132939132940132941132942132943132944132945132946132947132948132949132950132951132952132953132954132955132956132957132958132959132960132961132962132963132964132965132966132967132968132969132970132971132972132973132974132975132976132977132978132979132980132981132982132983132984132985132986132987132988132989132990132991132992132993132994132995132996132997132998132999133000133001133002133003133004133005133006133007133008133009133010133011133012133013133014133015133016133017133018133019133020133021133022133023133024133025133026133027133028133029133030133031133032133033133034133035133036133037133038133039133040133041133042133043133044133045133046133047133048133049133050133051133052133053133054133055133056133057133058133059133060133061133062133063133064133065133066133067133068133069133070133071133072133073133074133075133076133077133078133079133080133081133082133083133084133085133086133087133088133089133090133091133092133093133094133095133096133097133098133099133100133101133102133103133104133105133106133107133108133109133110133111133112133113133114133115133116133117133118133119133120133121133122133123133124133125133126133127133128133129133130133131133132133133133134133135133136133137133138133139133140133141133142133143133144133145133146133147133148133149133150133151133152133153133154133155133156133157133158133159133160133161133162133163133164133165133166133167133168133169133170133171133172133173133174133175133176133177133178133179133180133181133182133183133184133185133186133187133188133189133190133191133192133193133194133195133196133197133198133199133200133201133202133203133204133205133206133207133208133209133210133211133212133213133214133215133216133217133218133219133220133221133222133223133224133225133226133227133228133229133230133231133232133233133234133235133236133237133238133239133240133241133242133243133244133245133246133247133248133249133250133251133252133253133254133255133256133257133258133259133260133261133262133263133264133265133266133267133268133269133270133271133272133273133274133275133276133277133278133279133280133281133282133283133284133285133286133287133288133289133290133291133292133293133294133295133296133297133298133299133300133301133302133303133304133305133306133307133308133309133310133311133312133313133314133315133316133317133318133319133320133321133322133323133324133325133326133327133328133329133330133331133332133333133334133335133336133337133338133339133340133341133342133343133344133345133346133347133348133349133350133351133352133353133354133355133356133357133358133359133360133361133362133363133364133365133366133367133368133369133370133371133372133373133374133375133376133377133378133379133380133381133382133383133384133385133386133387133388133389133390133391133392133393133394133395133396133397133398133399133400133401133402133403133404133405133406133407133408133409133410133411133412133413133414133415133416133417133418133419133420133421133422133423133424133425133426133427133428133429133430133431133432133433133434133435133436133437133438133439133440133441133442133443133444133445133446133447133448133449133450133451133452133453133454133455133456133457133458133459133460133461133462133463133464133465133466133467133468133469133470133471133472133473133474133475133476133477133478133479133480133481133482133483133484133485133486133487133488133489133490133491133492133493133494133495133496133497133498133499133500133501133502133503133504133505133506133507133508133509133510133511133512133513133514133515133516133517133518133519133520133521133522133523133524133525133526133527133528133529133530133531133532133533133534133535133536133537133538133539133540133541133542133543133544133545133546133547133548133549133550133551133552133553133554133555133556133557133558133559133560133561133562133563133564133565133566133567133568133569133570133571133572133573133574133575133576133577133578133579133580133581133582133583133584133585133586133587133588133589133590133591133592133593133594133595133596133597133598133599133600133601133602133603133604133605133606133607133608133609133610133611133612133613133614133615133616133617133618133619133620133621133622133623133624133625133626133627133628133629133630133631133632133633133634133635133636133637133638133639133640133641133642133643133644133645133646133647133648133649133650133651133652133653133654133655133656133657133658133659133660133661133662133663133664133665133666133667133668133669133670133671133672133673133674133675133676133677133678133679133680133681133682133683133684133685133686133687133688133689133690133691133692133693133694133695133696133697133698133699133700133701133702133703133704133705133706133707133708133709133710133711133712133713133714133715133716133717133718133719133720133721133722133723133724133725133726133727133728133729133730133731133732133733133734133735133736133737133738133739133740133741133742133743133744133745133746133747133748133749133750133751133752133753133754133755133756133757133758133759133760133761133762133763133764133765133766133767133768133769133770133771133772133773133774133775133776133777133778133779133780133781133782133783133784133785133786133787133788133789133790133791133792133793133794133795133796133797133798133799133800133801133802133803133804133805133806133807133808133809133810133811133812133813133814133815133816133817133818133819133820133821133822133823133824133825133826133827133828133829133830133831133832133833133834133835133836133837133838133839133840133841133842133843133844133845133846133847133848133849133850133851133852133853133854133855133856133857133858133859133860133861133862133863133864133865133866133867133868133869133870133871133872133873133874133875133876133877133878133879133880133881133882133883133884133885133886133887133888133889133890133891133892133893133894133895133896133897133898133899133900133901133902133903133904133905133906133907133908133909133910133911133912133913133914133915133916133917133918133919133920133921133922133923133924133925133926133927133928133929133930133931133932133933133934133935133936133937133938133939133940133941133942133943133944133945133946133947133948133949133950133951133952133953133954133955133956133957133958133959133960133961133962133963133964133965133966133967133968133969133970133971133972133973133974133975133976133977133978133979133980133981133982133983133984133985133986133987133988133989133990133991133992133993133994133995133996133997133998133999134000134001134002134003134004134005134006134007134008134009134010134011134012134013134014134015134016134017134018134019134020134021134022134023134024134025134026134027134028134029134030134031134032134033134034134035134036134037134038134039134040134041134042134043134044134045134046134047134048134049134050134051134052134053134054134055134056134057134058134059134060134061134062134063134064134065134066134067134068134069134070134071134072134073134074134075134076134077134078134079134080134081134082134083134084134085134086134087134088134089134090134091134092134093134094134095134096134097134098134099134100134101134102134103134104134105134106134107134108134109134110134111134112134113134114134115134116134117134118134119134120134121134122134123134124134125134126134127134128134129134130134131134132134133134134134135134136134137134138134139134140134141134142134143134144134145134146134147134148134149134150134151134152134153134154134155134156134157134158134159134160134161134162134163134164134165134166134167134168134169134170134171134172134173134174134175134176134177134178134179134180134181134182134183134184134185134186134187134188134189134190134191134192134193134194134195134196134197134198134199134200134201134202134203134204134205134206134207134208134209134210134211134212134213134214134215134216134217134218134219134220134221134222134223134224134225134226134227134228134229134230134231134232134233134234134235134236134237134238134239134240134241134242134243134244134245134246134247134248134249134250134251134252134253134254134255134256134257134258134259134260134261134262134263134264134265134266134267134268134269134270134271134272134273134274134275134276134277134278134279134280134281134282134283134284134285134286134287134288134289134290134291134292134293134294134295134296134297134298134299134300134301134302134303134304134305134306134307134308134309134310134311134312134313134314134315134316134317134318134319134320134321134322134323134324134325134326134327134328134329134330134331134332134333134334134335134336134337134338134339134340134341134342134343134344134345134346134347134348134349134350134351134352134353134354134355134356134357134358134359134360134361134362134363134364134365134366134367134368134369134370134371134372134373134374134375134376134377134378134379134380134381134382134383134384134385134386134387134388134389134390134391134392134393134394134395134396134397134398134399134400134401134402134403134404134405134406134407134408134409134410134411134412134413134414134415134416134417134418134419134420134421134422134423134424134425134426134427134428134429134430134431134432134433134434134435134436134437134438134439134440134441134442134443134444134445134446134447134448134449134450134451134452134453134454134455134456134457134458134459134460134461134462134463134464134465134466134467134468134469134470134471134472134473134474134475134476134477134478134479134480134481134482134483134484134485134486134487134488134489134490134491134492134493134494134495134496134497134498134499134500134501134502134503134504134505134506134507134508134509134510134511134512134513134514134515134516134517134518134519134520134521134522134523134524134525134526134527134528134529134530134531134532134533134534134535134536134537134538134539134540134541134542134543134544134545134546134547134548134549134550134551134552134553134554134555134556134557134558134559134560134561134562134563134564134565134566134567134568134569134570134571134572134573134574134575134576134577134578134579134580134581134582134583134584134585134586134587134588134589134590134591134592134593134594134595134596134597134598134599134600134601134602134603134604134605134606134607134608134609134610134611134612134613134614134615134616134617134618134619134620134621134622134623134624134625134626134627134628134629134630134631134632134633134634134635134636134637134638134639134640134641134642134643134644134645134646134647134648134649134650134651134652134653134654134655134656134657134658134659134660134661134662134663134664134665134666134667134668134669134670134671134672134673134674134675134676134677134678134679134680134681134682134683134684134685134686134687134688134689134690134691134692134693134694134695134696134697134698134699134700134701134702134703134704134705134706134707134708134709134710134711134712134713134714134715134716134717134718134719134720134721134722134723134724134725134726134727134728134729134730134731134732134733134734134735134736134737134738134739134740134741134742134743134744134745134746134747134748134749134750134751134752134753134754134755134756134757134758134759134760134761134762134763134764134765134766134767134768134769134770134771134772134773134774134775134776134777134778134779134780134781134782134783134784134785134786134787134788134789134790134791134792134793134794134795134796134797134798134799134800134801134802134803134804134805134806134807134808134809134810134811134812134813134814134815134816134817134818134819134820134821134822134823134824134825134826134827134828134829134830134831134832134833134834134835134836134837134838134839134840134841134842134843134844134845134846134847134848134849134850134851134852134853134854134855134856134857134858134859134860134861134862134863134864134865134866134867134868134869134870134871134872134873134874134875134876134877134878134879134880134881134882134883134884134885134886134887134888134889134890134891134892134893134894134895134896134897134898134899134900134901134902134903134904134905134906134907134908134909134910134911134912134913134914134915134916134917134918134919134920134921134922134923134924134925134926134927134928134929134930134931134932134933134934134935134936134937134938134939134940134941134942134943134944134945134946134947134948134949134950134951134952134953134954134955134956134957134958134959134960134961134962134963134964134965134966134967134968134969134970134971134972134973134974134975134976134977134978134979134980134981134982134983134984134985134986134987134988134989134990134991134992134993134994134995134996134997134998134999135000135001135002135003135004135005135006135007135008135009135010135011135012135013135014135015135016135017135018135019135020135021135022135023135024135025135026135027135028135029135030135031135032135033135034135035135036135037135038135039135040135041135042135043135044135045135046135047135048135049135050135051135052135053135054135055135056135057135058135059135060135061135062135063135064135065135066135067135068135069135070135071135072135073135074135075135076135077135078135079135080135081135082135083135084135085135086135087135088135089135090135091135092135093135094135095135096135097135098135099135100135101135102135103135104135105135106135107135108135109135110135111135112135113135114135115135116135117135118135119135120135121135122135123135124135125135126135127135128135129135130135131135132135133135134135135135136135137135138135139135140135141135142135143135144135145135146135147135148135149135150135151135152135153135154135155135156135157135158135159135160135161135162135163135164135165135166135167135168135169135170135171135172135173135174135175135176135177135178135179135180135181135182135183135184135185135186135187135188135189135190135191135192135193135194135195135196135197135198135199135200135201135202135203135204135205135206135207135208135209135210135211135212135213135214135215135216135217135218135219135220135221135222135223135224135225135226135227135228135229135230135231135232135233135234135235135236135237135238135239135240135241135242135243135244135245135246135247135248135249135250135251135252135253135254135255135256135257135258135259135260135261135262135263135264135265135266135267135268135269135270135271135272135273135274135275135276135277135278135279135280135281135282135283135284135285135286135287135288135289135290135291135292135293135294135295135296135297135298135299135300135301135302135303135304135305135306135307135308135309135310135311135312135313135314135315135316135317135318135319135320135321135322135323135324135325135326135327135328135329135330135331135332135333135334135335135336135337135338135339135340135341135342135343135344135345135346135347135348135349135350135351135352135353135354135355135356135357135358135359135360135361135362135363135364135365135366135367135368135369135370135371135372135373135374135375135376135377135378135379135380135381135382135383135384135385135386135387135388135389135390135391135392135393135394135395135396135397135398135399135400135401135402135403135404135405135406135407135408135409135410135411135412135413135414135415135416135417135418135419135420135421135422135423135424135425135426135427135428135429135430135431135432135433135434135435135436135437135438135439135440135441135442135443135444135445135446135447135448135449135450135451135452135453135454135455135456135457135458135459135460135461135462135463135464135465135466135467135468135469135470135471135472135473135474135475135476135477135478135479135480135481135482135483135484135485135486135487135488135489135490135491135492135493135494135495135496135497135498135499135500135501135502135503135504135505135506135507135508135509135510135511135512135513135514135515135516135517135518135519135520135521135522135523135524135525135526135527135528135529135530135531135532135533135534135535135536135537135538135539135540135541135542135543135544135545135546135547135548135549135550135551135552135553135554135555135556135557135558135559135560135561135562135563135564135565135566135567135568135569135570135571135572135573135574135575135576135577135578135579135580135581135582135583135584135585135586135587135588135589135590135591135592135593135594135595135596135597135598135599135600135601135602135603135604135605135606135607135608135609135610135611135612135613135614135615135616135617135618135619135620135621135622135623135624135625135626135627135628135629135630135631135632135633135634135635135636135637135638135639135640135641135642135643135644135645135646135647135648135649135650135651135652135653135654135655135656135657135658135659135660135661135662135663135664135665135666135667135668135669135670135671135672135673135674135675135676135677135678135679135680135681135682135683135684135685135686135687135688135689135690135691135692135693135694135695135696135697135698135699135700135701135702135703135704135705135706135707135708135709135710135711135712135713135714135715135716135717135718135719135720135721135722135723135724135725135726135727135728135729135730135731135732135733135734135735135736135737135738135739135740135741135742135743135744135745135746135747135748135749135750135751135752135753135754135755135756135757135758135759135760135761135762135763135764135765135766135767135768135769135770135771135772135773135774135775135776135777135778135779135780135781135782135783135784135785135786135787135788135789135790135791135792135793135794135795135796135797135798135799135800135801135802135803135804135805135806135807135808135809135810135811135812135813135814135815135816135817135818135819135820135821135822135823135824135825135826135827135828135829135830135831135832135833135834135835135836135837135838135839135840135841135842135843135844135845135846135847135848135849135850135851135852135853135854135855135856135857135858135859135860135861135862135863135864135865135866135867135868135869135870135871135872135873135874135875135876135877135878135879135880135881135882135883135884135885135886135887135888135889135890135891135892135893135894135895135896135897135898135899135900135901135902135903135904135905135906135907135908135909135910135911135912135913135914135915135916135917135918135919135920135921135922135923135924135925135926135927135928135929135930135931135932135933135934135935135936135937135938135939135940135941135942135943135944135945135946135947135948135949135950135951135952135953135954135955135956135957135958135959135960135961135962135963135964135965135966135967135968135969135970135971135972135973135974135975135976135977135978135979135980135981135982135983135984135985135986135987135988135989135990135991135992135993135994135995135996135997135998135999136000136001136002136003136004136005136006136007136008136009136010136011136012136013136014136015136016136017136018136019136020136021136022136023136024136025136026136027136028136029136030136031136032136033136034136035136036136037136038136039136040136041136042136043136044136045136046136047136048136049136050136051136052136053136054136055136056136057136058136059136060136061136062136063136064136065136066136067136068136069136070136071136072136073136074136075136076136077136078136079136080136081136082136083136084136085136086136087136088136089136090136091136092136093136094136095136096136097136098136099136100136101136102136103136104136105136106136107136108136109136110136111136112136113136114136115136116136117136118136119136120136121136122136123136124136125136126136127136128136129136130136131136132136133136134136135136136136137136138136139136140136141136142136143136144136145136146136147136148136149136150136151136152136153136154136155136156136157136158136159136160136161136162136163136164136165136166136167136168136169136170136171136172136173136174136175136176136177136178136179136180136181136182136183136184136185136186136187136188136189136190136191136192136193136194136195136196136197136198136199136200136201136202136203136204136205136206136207136208136209136210136211136212136213136214136215136216136217136218136219136220136221136222136223136224136225136226136227136228136229136230136231136232136233136234136235136236136237136238136239136240136241136242136243136244136245136246136247136248136249136250136251136252136253136254136255136256136257136258136259136260136261136262136263136264136265136266136267136268136269136270136271136272136273136274136275136276136277136278136279136280136281136282136283136284136285136286136287136288136289136290136291136292136293136294136295136296136297136298136299136300136301136302136303136304136305136306136307136308136309136310136311136312136313136314136315136316136317136318136319136320136321136322136323136324136325136326136327136328136329136330136331136332136333136334136335136336136337136338136339136340136341136342136343136344136345136346136347136348136349136350136351136352136353136354136355136356136357136358136359136360136361136362136363136364136365136366136367136368136369136370136371136372136373136374136375136376136377136378136379136380136381136382136383136384136385136386136387136388136389136390136391136392136393136394136395136396136397136398136399136400136401136402136403136404136405136406136407136408136409136410136411136412136413136414136415136416136417136418136419136420136421136422136423136424136425136426136427136428136429136430136431136432136433136434136435136436136437136438136439136440136441136442136443136444136445136446136447136448136449136450136451136452136453136454136455136456136457136458136459136460136461136462136463136464136465136466136467136468136469136470136471136472136473136474136475136476136477136478136479136480136481136482136483136484136485136486136487136488136489136490136491136492136493136494136495136496136497136498136499136500136501136502136503136504136505136506136507136508136509136510136511136512136513136514136515136516136517136518136519136520136521136522136523136524136525136526136527136528136529136530136531136532136533136534136535136536136537136538136539136540136541136542136543136544136545136546136547136548136549136550136551136552136553136554136555136556136557136558136559136560136561136562136563136564136565136566136567136568136569136570136571136572136573136574136575136576136577136578136579136580136581136582136583136584136585136586136587136588136589136590136591136592136593136594136595136596136597136598136599136600136601136602136603136604136605136606136607136608136609136610136611136612136613136614136615136616136617136618136619136620136621136622136623136624136625136626136627136628136629136630136631136632136633136634136635136636136637136638136639136640136641136642136643136644136645136646136647136648136649136650136651136652136653136654136655136656136657136658136659136660136661136662136663136664136665136666136667136668136669136670136671136672136673136674136675136676136677136678136679136680136681136682136683136684136685136686136687136688136689136690136691136692136693136694136695136696136697136698136699136700136701136702136703136704136705136706136707136708136709136710136711136712136713136714136715136716136717136718136719136720136721136722136723136724136725136726136727136728136729136730136731136732136733136734136735136736136737136738136739136740136741136742136743136744136745136746136747136748136749136750136751136752136753136754136755136756136757136758136759136760136761136762136763136764136765136766136767136768136769136770136771136772136773136774136775136776136777136778136779136780136781136782136783136784136785136786136787136788136789136790136791136792136793136794136795136796136797136798136799136800136801136802136803136804136805136806136807136808136809136810136811136812136813136814136815136816136817136818136819136820136821136822136823136824136825136826136827136828136829136830136831136832136833136834136835136836136837136838136839136840136841136842136843136844136845136846136847136848136849136850136851136852136853136854136855136856136857136858136859136860136861136862136863136864136865136866136867136868136869136870136871136872136873136874136875136876136877136878136879136880136881136882136883136884136885136886136887136888136889136890136891136892136893136894136895136896136897136898136899136900136901136902136903136904136905136906136907136908136909136910136911136912136913136914136915136916136917136918136919136920136921136922136923136924136925136926136927136928136929136930136931136932136933136934136935136936136937136938136939136940136941136942136943136944136945136946136947136948136949136950136951136952136953136954136955136956136957136958136959136960136961136962136963136964136965136966136967136968136969136970136971136972136973136974136975136976136977136978136979136980136981136982136983136984136985136986136987136988136989136990136991136992136993136994136995136996136997136998136999137000137001137002137003137004137005137006137007137008137009137010137011137012137013137014137015137016137017137018137019137020137021137022137023137024137025137026137027137028137029137030137031137032137033137034137035137036137037137038137039137040137041137042137043137044137045137046137047137048137049137050137051137052137053137054137055137056137057137058137059137060137061137062137063137064137065137066137067137068137069137070137071137072137073137074137075137076137077137078137079137080137081137082137083137084137085137086137087137088137089137090137091137092137093137094137095137096137097137098137099137100137101137102137103137104137105137106137107137108137109137110137111137112137113137114137115137116137117137118137119137120137121137122137123137124137125137126137127137128137129137130137131137132137133137134137135137136137137137138137139137140137141137142137143137144137145137146137147137148137149137150137151137152137153137154137155137156137157137158137159137160137161137162137163137164137165137166137167137168137169137170137171137172137173137174137175137176137177137178137179137180137181137182137183137184137185137186137187137188137189137190137191137192137193137194137195137196137197137198137199137200137201137202137203137204137205137206137207137208137209137210137211137212137213137214137215137216137217137218137219137220137221137222137223137224137225137226137227137228137229137230137231137232137233137234137235137236137237137238137239137240137241137242137243137244137245137246137247137248137249137250137251137252137253137254137255137256137257137258137259137260137261137262137263137264137265137266137267137268137269137270137271137272137273137274137275137276137277137278137279137280137281137282137283137284137285137286137287137288137289137290137291137292137293137294137295137296137297137298137299137300137301137302137303137304137305137306137307137308137309137310137311137312137313137314137315137316137317137318137319137320137321137322137323137324137325137326137327137328137329137330137331137332137333137334137335137336137337137338137339137340137341137342137343137344137345137346137347137348137349137350137351137352137353137354137355137356137357137358137359137360137361137362137363137364137365137366137367137368137369137370137371137372137373137374137375137376137377137378137379137380137381137382137383137384137385137386137387137388137389137390137391137392137393137394137395137396137397137398137399137400137401137402137403137404137405137406137407137408137409137410137411137412137413137414137415137416137417137418137419137420137421137422137423137424137425137426137427137428137429137430137431137432137433137434137435137436137437137438137439137440137441137442137443137444137445137446137447137448137449137450137451137452137453137454137455137456137457137458137459137460137461137462137463137464137465137466137467137468137469137470137471137472137473137474137475137476137477137478137479137480137481137482137483137484137485137486137487137488137489137490137491137492137493137494137495137496137497137498137499137500137501137502137503137504137505137506137507137508137509137510137511137512137513137514137515137516137517137518137519137520137521137522137523137524137525137526137527137528137529137530137531137532137533137534137535137536137537137538137539137540137541137542137543137544137545137546137547137548137549137550137551137552137553137554137555137556137557137558137559137560137561137562137563137564137565137566137567137568137569137570137571137572137573137574137575137576137577137578137579137580137581137582137583137584137585137586137587137588137589137590137591137592137593137594137595137596137597137598137599137600137601137602137603137604137605137606137607137608137609137610137611137612137613137614137615137616137617137618137619137620137621137622137623137624137625137626137627137628137629137630137631137632137633137634137635137636137637137638137639137640137641137642137643137644137645137646137647137648137649137650137651137652137653137654137655137656137657137658137659137660137661137662137663137664137665137666137667137668137669137670137671137672137673137674137675137676137677137678137679137680137681137682137683137684137685137686137687137688137689137690137691137692137693137694137695137696137697137698137699137700137701137702137703137704137705137706137707137708137709137710137711137712137713137714137715137716137717137718137719137720137721137722137723137724137725137726137727137728137729137730137731137732137733137734137735137736137737137738137739137740137741137742137743137744137745137746137747137748137749137750137751137752137753137754137755137756137757137758137759137760137761137762137763137764137765137766137767137768137769137770137771137772137773137774137775137776137777137778137779137780137781137782137783137784137785137786137787137788137789137790137791137792137793137794137795137796137797137798137799137800137801137802137803137804137805137806137807137808137809137810137811137812137813137814137815137816137817137818137819137820137821137822137823137824137825137826137827137828137829137830137831137832137833137834137835137836137837137838137839137840137841137842137843137844137845137846137847137848137849137850137851137852137853137854137855137856137857137858137859137860137861137862137863137864137865137866137867137868137869137870137871137872137873137874137875137876137877137878137879137880137881137882137883137884137885137886137887137888137889137890137891137892137893137894137895137896137897137898137899137900137901137902137903137904137905137906137907137908137909137910137911137912137913137914137915137916137917137918137919137920137921137922137923137924137925137926137927137928137929137930137931137932137933137934137935137936137937137938137939137940137941137942137943137944137945137946137947137948137949137950137951137952137953137954137955137956137957137958137959137960137961137962137963137964137965137966137967137968137969137970137971137972137973137974137975137976137977137978137979137980137981137982137983137984137985137986137987137988137989137990137991137992137993137994137995137996137997137998137999138000138001138002138003138004138005138006138007138008138009138010138011138012138013138014138015138016138017138018138019138020138021138022138023138024138025138026138027138028138029138030138031138032138033138034138035138036138037138038138039138040138041138042138043138044138045138046138047138048138049138050138051138052138053138054138055138056138057138058138059138060138061138062138063138064138065138066138067138068138069138070138071138072138073138074138075138076138077138078138079138080138081138082138083138084138085138086138087138088138089138090138091138092138093138094138095138096138097138098138099138100138101138102138103138104138105138106138107138108138109138110138111138112138113138114138115138116138117138118138119138120138121138122138123138124138125138126138127138128138129138130138131138132138133138134138135138136138137138138138139138140138141138142138143138144138145138146138147138148138149138150138151138152138153138154138155138156138157138158138159138160138161138162138163138164138165138166138167138168138169138170138171138172138173138174138175138176138177138178138179138180138181138182138183138184138185138186138187138188138189138190138191138192138193138194138195138196138197138198138199138200138201138202138203138204138205138206138207138208138209138210138211138212138213138214138215138216138217138218138219138220138221138222138223138224138225138226138227138228138229138230138231138232138233138234138235138236138237138238138239138240138241138242138243138244138245138246138247138248138249138250138251138252138253138254138255138256138257138258138259138260138261138262138263138264138265138266138267138268138269138270138271138272138273138274138275138276138277138278138279138280138281138282138283138284138285138286138287138288138289138290138291138292138293138294138295138296138297138298138299138300138301138302138303138304138305138306138307138308138309138310138311138312138313138314138315138316138317138318138319138320138321138322138323138324138325138326138327138328138329138330138331138332138333138334138335138336138337138338138339138340138341138342138343138344138345138346138347138348138349138350138351138352138353138354138355138356138357138358138359138360138361138362138363138364138365138366138367138368138369138370138371138372138373138374138375138376138377138378138379138380138381138382138383138384138385138386138387138388138389138390138391138392138393138394138395138396138397138398138399138400138401138402138403138404138405138406138407138408138409138410138411138412138413138414138415138416138417138418138419138420138421138422138423138424138425138426138427138428138429138430138431138432138433138434138435138436138437138438138439138440138441138442138443138444138445138446138447138448138449138450138451138452138453138454138455138456138457138458138459138460138461138462138463138464138465138466138467138468138469138470138471138472138473138474138475138476138477138478138479138480138481138482138483138484138485138486138487138488138489138490138491138492138493138494138495138496138497138498138499138500138501138502138503138504138505138506138507138508138509138510138511138512138513138514138515138516138517138518138519138520138521138522138523138524138525138526138527138528138529138530138531138532138533138534138535138536138537138538138539138540138541138542138543138544138545138546138547138548138549138550138551138552138553138554138555138556138557138558138559138560138561138562138563138564138565138566138567138568138569138570138571138572138573138574138575138576138577138578138579138580138581138582138583138584138585138586138587138588138589138590138591138592138593138594138595138596138597138598138599138600138601138602138603138604138605138606138607138608138609138610138611138612138613138614138615138616138617138618138619138620138621138622138623138624138625138626138627138628138629138630138631138632138633138634138635138636138637138638138639138640138641138642138643138644138645138646138647138648138649138650138651138652138653138654138655138656138657138658138659138660138661138662138663138664138665138666138667138668138669138670138671138672138673138674138675138676138677138678138679138680138681138682138683138684138685138686138687138688138689138690138691138692138693138694138695138696138697138698138699138700138701138702138703138704138705138706138707138708138709138710138711138712138713138714138715138716138717138718138719138720138721138722138723138724138725138726138727138728138729138730138731138732138733138734138735138736138737138738138739138740138741138742138743138744138745138746138747138748138749138750138751138752138753138754138755138756138757138758138759138760138761138762138763138764138765138766138767138768138769138770138771138772138773138774138775138776138777138778138779138780138781138782138783138784138785138786138787138788138789138790138791138792138793138794138795138796138797138798138799138800138801138802138803138804138805138806138807138808138809138810138811138812138813138814138815138816138817138818138819138820138821138822138823138824138825138826138827138828138829138830138831138832138833138834138835138836138837138838138839138840138841138842138843138844138845138846138847138848138849138850138851138852138853138854138855138856138857138858138859138860138861138862138863138864138865138866138867138868138869138870138871138872138873138874138875138876138877138878138879138880138881138882138883138884138885138886138887138888138889138890138891138892138893138894138895138896138897138898138899138900138901138902138903138904138905138906138907138908138909138910138911138912138913138914138915138916138917138918138919138920138921138922138923138924138925138926138927138928138929138930138931138932138933138934138935138936138937138938138939138940138941138942138943138944138945138946138947138948138949138950138951138952138953138954138955138956138957138958138959138960138961138962138963138964138965138966138967138968138969138970138971138972138973138974138975138976138977138978138979138980138981138982138983138984138985138986138987138988138989138990138991138992138993138994138995138996138997138998138999139000139001139002139003139004139005139006139007139008139009139010139011139012139013139014139015139016139017139018139019139020139021139022139023139024139025139026139027139028139029139030139031139032139033139034139035139036139037139038139039139040139041139042139043139044139045139046139047139048139049139050139051139052139053139054139055139056139057139058139059139060139061139062139063139064139065139066139067139068139069139070139071139072139073139074139075139076139077139078139079139080139081139082139083139084139085139086139087139088139089139090139091139092139093139094139095139096139097139098139099139100139101139102139103139104139105139106139107139108139109139110139111139112139113139114139115139116139117139118139119139120139121139122139123139124139125139126139127139128139129139130139131139132139133139134139135139136139137139138139139139140139141139142139143139144139145139146139147139148139149139150139151139152139153139154139155139156139157139158139159139160139161139162139163139164139165139166139167139168139169139170139171139172139173139174139175139176139177139178139179139180139181139182139183139184139185139186139187139188139189139190139191139192139193139194139195139196139197139198139199139200139201139202139203139204139205139206139207139208139209139210139211139212139213139214139215139216139217139218139219139220139221139222139223139224139225139226139227139228139229139230139231139232139233139234139235139236139237139238139239139240139241139242139243139244139245139246139247139248139249139250139251139252139253139254139255139256139257139258139259139260139261139262139263139264139265139266139267139268139269139270139271139272139273139274139275139276139277139278139279139280139281139282139283139284139285139286139287139288139289139290139291139292139293139294139295139296139297139298139299139300139301139302139303139304139305139306139307139308139309139310139311139312139313139314139315139316139317139318139319139320139321139322139323139324139325139326139327139328139329139330139331139332139333139334139335139336139337139338139339139340139341139342139343139344139345139346139347139348139349139350139351139352139353139354139355139356139357139358139359139360139361139362139363139364139365139366139367139368139369139370139371139372139373139374139375139376139377139378139379139380139381139382139383139384139385139386139387139388139389139390139391139392139393139394139395139396139397139398139399139400139401139402139403139404139405139406139407139408139409139410139411139412139413139414139415139416139417139418139419139420139421139422139423139424139425139426139427139428139429139430139431139432139433139434139435139436139437139438139439139440139441139442139443139444139445139446139447139448139449139450139451139452139453139454139455139456139457139458139459139460139461139462139463139464139465139466139467139468139469139470139471139472139473139474139475139476139477139478139479139480139481139482139483139484139485139486139487139488139489139490139491139492139493139494139495139496139497139498139499139500139501139502139503139504139505139506139507139508139509139510139511139512139513139514139515139516139517139518139519139520139521139522139523139524139525139526139527139528139529139530139531139532139533139534139535139536139537139538139539139540139541139542139543139544139545139546139547139548139549139550139551139552139553139554139555139556139557139558139559139560139561139562139563139564139565139566139567139568139569139570139571139572139573139574139575139576139577139578139579139580139581139582139583139584139585139586139587139588139589139590139591139592139593139594139595139596139597139598139599139600139601139602139603139604139605139606139607139608139609139610139611139612139613139614139615139616139617139618139619139620139621139622139623139624139625139626139627139628139629139630139631139632139633139634139635139636139637139638139639139640139641139642139643139644139645139646139647139648139649139650139651139652139653139654139655139656139657139658139659139660139661139662139663139664139665139666139667139668139669139670139671139672139673139674139675139676139677139678139679139680139681139682139683139684139685139686139687139688139689139690139691139692139693139694139695139696139697139698139699139700139701139702139703139704139705139706139707139708139709139710139711139712139713139714139715139716139717139718139719139720139721139722139723139724139725139726139727139728139729139730139731139732139733139734139735139736139737139738139739139740139741139742139743139744139745139746139747139748139749139750139751139752139753139754139755139756139757139758139759139760139761139762139763139764139765139766139767139768139769139770139771139772139773139774139775139776139777139778139779139780139781139782139783139784139785139786139787139788139789139790139791139792139793139794139795139796139797139798139799139800139801139802139803139804139805139806139807139808139809139810139811139812139813139814139815139816139817139818139819139820139821139822139823139824139825139826139827139828139829139830139831139832139833139834139835139836139837139838139839139840139841139842139843139844139845139846139847139848139849139850139851139852139853139854139855139856139857139858139859139860139861139862139863139864139865139866139867139868139869139870139871139872139873139874139875139876139877139878139879139880139881139882139883139884139885139886139887139888139889139890139891139892139893139894139895139896139897139898139899139900139901139902139903139904139905139906139907139908139909139910139911139912139913139914139915139916139917139918139919139920139921139922139923139924139925139926139927139928139929139930139931139932139933139934139935139936139937139938139939139940139941139942139943139944139945139946139947139948139949139950139951139952139953139954139955139956139957139958139959139960139961139962
  1. (function webpackUniversalModuleDefinition(root, factory) {
  2. if(typeof exports === 'object' && typeof module === 'object')
  3. module.exports = factory();
  4. else if(typeof define === 'function' && define.amd)
  5. define("babylonjs", [], factory);
  6. else if(typeof exports === 'object')
  7. exports["babylonjs"] = factory();
  8. else
  9. root["BABYLON"] = factory();
  10. })(window, function() {
  11. return /******/ (function(modules) { // webpackBootstrap
  12. /******/ // The module cache
  13. /******/ var installedModules = {};
  14. /******/
  15. /******/ // The require function
  16. /******/ function __webpack_require__(moduleId) {
  17. /******/
  18. /******/ // Check if module is in cache
  19. /******/ if(installedModules[moduleId]) {
  20. /******/ return installedModules[moduleId].exports;
  21. /******/ }
  22. /******/ // Create a new module (and put it into the cache)
  23. /******/ var module = installedModules[moduleId] = {
  24. /******/ i: moduleId,
  25. /******/ l: false,
  26. /******/ exports: {}
  27. /******/ };
  28. /******/
  29. /******/ // Execute the module function
  30. /******/ modules[moduleId].call(module.exports, module, module.exports, __webpack_require__);
  31. /******/
  32. /******/ // Flag the module as loaded
  33. /******/ module.l = true;
  34. /******/
  35. /******/ // Return the exports of the module
  36. /******/ return module.exports;
  37. /******/ }
  38. /******/
  39. /******/
  40. /******/ // expose the modules object (__webpack_modules__)
  41. /******/ __webpack_require__.m = modules;
  42. /******/
  43. /******/ // expose the module cache
  44. /******/ __webpack_require__.c = installedModules;
  45. /******/
  46. /******/ // define getter function for harmony exports
  47. /******/ __webpack_require__.d = function(exports, name, getter) {
  48. /******/ if(!__webpack_require__.o(exports, name)) {
  49. /******/ Object.defineProperty(exports, name, { enumerable: true, get: getter });
  50. /******/ }
  51. /******/ };
  52. /******/
  53. /******/ // define __esModule on exports
  54. /******/ __webpack_require__.r = function(exports) {
  55. /******/ if(typeof Symbol !== 'undefined' && Symbol.toStringTag) {
  56. /******/ Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
  57. /******/ }
  58. /******/ Object.defineProperty(exports, '__esModule', { value: true });
  59. /******/ };
  60. /******/
  61. /******/ // create a fake namespace object
  62. /******/ // mode & 1: value is a module id, require it
  63. /******/ // mode & 2: merge all properties of value into the ns
  64. /******/ // mode & 4: return value when already ns object
  65. /******/ // mode & 8|1: behave like require
  66. /******/ __webpack_require__.t = function(value, mode) {
  67. /******/ if(mode & 1) value = __webpack_require__(value);
  68. /******/ if(mode & 8) return value;
  69. /******/ if((mode & 4) && typeof value === 'object' && value && value.__esModule) return value;
  70. /******/ var ns = Object.create(null);
  71. /******/ __webpack_require__.r(ns);
  72. /******/ Object.defineProperty(ns, 'default', { enumerable: true, value: value });
  73. /******/ if(mode & 2 && typeof value != 'string') for(var key in value) __webpack_require__.d(ns, key, function(key) { return value[key]; }.bind(null, key));
  74. /******/ return ns;
  75. /******/ };
  76. /******/
  77. /******/ // getDefaultExport function for compatibility with non-harmony modules
  78. /******/ __webpack_require__.n = function(module) {
  79. /******/ var getter = module && module.__esModule ?
  80. /******/ function getDefault() { return module['default']; } :
  81. /******/ function getModuleExports() { return module; };
  82. /******/ __webpack_require__.d(getter, 'a', getter);
  83. /******/ return getter;
  84. /******/ };
  85. /******/
  86. /******/ // Object.prototype.hasOwnProperty.call
  87. /******/ __webpack_require__.o = function(object, property) { return Object.prototype.hasOwnProperty.call(object, property); };
  88. /******/
  89. /******/ // __webpack_public_path__
  90. /******/ __webpack_require__.p = "";
  91. /******/
  92. /******/
  93. /******/ // Load entry module and return exports
  94. /******/ return __webpack_require__(__webpack_require__.s = "./Legacy/legacy.ts");
  95. /******/ })
  96. /************************************************************************/
  97. /******/ ({
  98. /***/ "../node_modules/tslib/tslib.es6.js":
  99. /*!******************************************!*\
  100. !*** ../node_modules/tslib/tslib.es6.js ***!
  101. \******************************************/
  102. /*! exports provided: __extends, __assign, __rest, __decorate, __param, __metadata, __awaiter, __generator, __exportStar, __values, __read, __spread, __await, __asyncGenerator, __asyncDelegator, __asyncValues, __makeTemplateObject, __importStar, __importDefault */
  103. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104. "use strict";
  105. __webpack_require__.r(__webpack_exports__);
  106. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__extends", function() { return __extends; });
  107. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__assign", function() { return __assign; });
  108. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__rest", function() { return __rest; });
  109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__decorate", function() { return __decorate; });
  110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__param", function() { return __param; });
  111. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__metadata", function() { return __metadata; });
  112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__awaiter", function() { return __awaiter; });
  113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__generator", function() { return __generator; });
  114. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__exportStar", function() { return __exportStar; });
  115. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__values", function() { return __values; });
  116. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__read", function() { return __read; });
  117. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__spread", function() { return __spread; });
  118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__await", function() { return __await; });
  119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncGenerator", function() { return __asyncGenerator; });
  120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncDelegator", function() { return __asyncDelegator; });
  121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__asyncValues", function() { return __asyncValues; });
  122. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__makeTemplateObject", function() { return __makeTemplateObject; });
  123. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importStar", function() { return __importStar; });
  124. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "__importDefault", function() { return __importDefault; });
  125. /*! *****************************************************************************
  126. Copyright (c) Microsoft Corporation. All rights reserved.
  127. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  128. this file except in compliance with the License. You may obtain a copy of the
  129. License at http://www.apache.org/licenses/LICENSE-2.0
  130. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  131. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  132. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  133. MERCHANTABLITY OR NON-INFRINGEMENT.
  134. See the Apache Version 2.0 License for specific language governing permissions
  135. and limitations under the License.
  136. ***************************************************************************** */
  137. /* global Reflect, Promise */
  138. var extendStatics = function(d, b) {
  139. extendStatics = Object.setPrototypeOf ||
  140. ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) ||
  141. function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; };
  142. return extendStatics(d, b);
  143. };
  144. function __extends(d, b) {
  145. extendStatics(d, b);
  146. function __() { this.constructor = d; }
  147. d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
  148. }
  149. var __assign = function() {
  150. __assign = Object.assign || function __assign(t) {
  151. for (var s, i = 1, n = arguments.length; i < n; i++) {
  152. s = arguments[i];
  153. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
  154. }
  155. return t;
  156. }
  157. return __assign.apply(this, arguments);
  158. }
  159. function __rest(s, e) {
  160. var t = {};
  161. for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
  162. t[p] = s[p];
  163. if (s != null && typeof Object.getOwnPropertySymbols === "function")
  164. for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) if (e.indexOf(p[i]) < 0)
  165. t[p[i]] = s[p[i]];
  166. return t;
  167. }
  168. function __decorate(decorators, target, key, desc) {
  169. var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
  170. if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
  171. else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
  172. return c > 3 && r && Object.defineProperty(target, key, r), r;
  173. }
  174. function __param(paramIndex, decorator) {
  175. return function (target, key) { decorator(target, key, paramIndex); }
  176. }
  177. function __metadata(metadataKey, metadataValue) {
  178. if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(metadataKey, metadataValue);
  179. }
  180. function __awaiter(thisArg, _arguments, P, generator) {
  181. return new (P || (P = Promise))(function (resolve, reject) {
  182. function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
  183. function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
  184. function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
  185. step((generator = generator.apply(thisArg, _arguments || [])).next());
  186. });
  187. }
  188. function __generator(thisArg, body) {
  189. var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
  190. return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
  191. function verb(n) { return function (v) { return step([n, v]); }; }
  192. function step(op) {
  193. if (f) throw new TypeError("Generator is already executing.");
  194. while (_) try {
  195. if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
  196. if (y = 0, t) op = [op[0] & 2, t.value];
  197. switch (op[0]) {
  198. case 0: case 1: t = op; break;
  199. case 4: _.label++; return { value: op[1], done: false };
  200. case 5: _.label++; y = op[1]; op = [0]; continue;
  201. case 7: op = _.ops.pop(); _.trys.pop(); continue;
  202. default:
  203. if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
  204. if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
  205. if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
  206. if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
  207. if (t[2]) _.ops.pop();
  208. _.trys.pop(); continue;
  209. }
  210. op = body.call(thisArg, _);
  211. } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
  212. if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
  213. }
  214. }
  215. function __exportStar(m, exports) {
  216. for (var p in m) if (!exports.hasOwnProperty(p)) exports[p] = m[p];
  217. }
  218. function __values(o) {
  219. var m = typeof Symbol === "function" && o[Symbol.iterator], i = 0;
  220. if (m) return m.call(o);
  221. return {
  222. next: function () {
  223. if (o && i >= o.length) o = void 0;
  224. return { value: o && o[i++], done: !o };
  225. }
  226. };
  227. }
  228. function __read(o, n) {
  229. var m = typeof Symbol === "function" && o[Symbol.iterator];
  230. if (!m) return o;
  231. var i = m.call(o), r, ar = [], e;
  232. try {
  233. while ((n === void 0 || n-- > 0) && !(r = i.next()).done) ar.push(r.value);
  234. }
  235. catch (error) { e = { error: error }; }
  236. finally {
  237. try {
  238. if (r && !r.done && (m = i["return"])) m.call(i);
  239. }
  240. finally { if (e) throw e.error; }
  241. }
  242. return ar;
  243. }
  244. function __spread() {
  245. for (var ar = [], i = 0; i < arguments.length; i++)
  246. ar = ar.concat(__read(arguments[i]));
  247. return ar;
  248. }
  249. function __await(v) {
  250. return this instanceof __await ? (this.v = v, this) : new __await(v);
  251. }
  252. function __asyncGenerator(thisArg, _arguments, generator) {
  253. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  254. var g = generator.apply(thisArg, _arguments || []), i, q = [];
  255. return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i;
  256. function verb(n) { if (g[n]) i[n] = function (v) { return new Promise(function (a, b) { q.push([n, v, a, b]) > 1 || resume(n, v); }); }; }
  257. function resume(n, v) { try { step(g[n](v)); } catch (e) { settle(q[0][3], e); } }
  258. function step(r) { r.value instanceof __await ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r); }
  259. function fulfill(value) { resume("next", value); }
  260. function reject(value) { resume("throw", value); }
  261. function settle(f, v) { if (f(v), q.shift(), q.length) resume(q[0][0], q[0][1]); }
  262. }
  263. function __asyncDelegator(o) {
  264. var i, p;
  265. return i = {}, verb("next"), verb("throw", function (e) { throw e; }), verb("return"), i[Symbol.iterator] = function () { return this; }, i;
  266. function verb(n, f) { i[n] = o[n] ? function (v) { return (p = !p) ? { value: __await(o[n](v)), done: n === "return" } : f ? f(v) : v; } : f; }
  267. }
  268. function __asyncValues(o) {
  269. if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
  270. var m = o[Symbol.asyncIterator], i;
  271. return m ? m.call(o) : (o = typeof __values === "function" ? __values(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function () { return this; }, i);
  272. function verb(n) { i[n] = o[n] && function (v) { return new Promise(function (resolve, reject) { v = o[n](v), settle(resolve, reject, v.done, v.value); }); }; }
  273. function settle(resolve, reject, d, v) { Promise.resolve(v).then(function(v) { resolve({ value: v, done: d }); }, reject); }
  274. }
  275. function __makeTemplateObject(cooked, raw) {
  276. if (Object.defineProperty) { Object.defineProperty(cooked, "raw", { value: raw }); } else { cooked.raw = raw; }
  277. return cooked;
  278. };
  279. function __importStar(mod) {
  280. if (mod && mod.__esModule) return mod;
  281. var result = {};
  282. if (mod != null) for (var k in mod) if (Object.hasOwnProperty.call(mod, k)) result[k] = mod[k];
  283. result.default = mod;
  284. return result;
  285. }
  286. function __importDefault(mod) {
  287. return (mod && mod.__esModule) ? mod : { default: mod };
  288. }
  289. /***/ }),
  290. /***/ "../node_modules/webpack/buildin/global.js":
  291. /*!*************************************************!*\
  292. !*** ../node_modules/webpack/buildin/global.js ***!
  293. \*************************************************/
  294. /*! no static exports found */
  295. /***/ (function(module, exports) {
  296. var g;
  297. // This works in non-strict mode
  298. g = (function() {
  299. return this;
  300. })();
  301. try {
  302. // This works if eval is allowed (see CSP)
  303. g = g || new Function("return this")();
  304. } catch (e) {
  305. // This works if the window reference is available
  306. if (typeof window === "object") g = window;
  307. }
  308. // g can still be undefined, but nothing to do about it...
  309. // We return undefined, instead of nothing here, so it's
  310. // easier to handle this case. if(!global) { ...}
  311. module.exports = g;
  312. /***/ }),
  313. /***/ "./Actions/abstractActionManager.ts":
  314. /*!******************************************!*\
  315. !*** ./Actions/abstractActionManager.ts ***!
  316. \******************************************/
  317. /*! exports provided: AbstractActionManager */
  318. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  319. "use strict";
  320. __webpack_require__.r(__webpack_exports__);
  321. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractActionManager", function() { return AbstractActionManager; });
  322. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  323. /**
  324. * Abstract class used to decouple action Manager from scene and meshes.
  325. * Do not instantiate.
  326. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  327. */
  328. var AbstractActionManager = /** @class */ (function () {
  329. function AbstractActionManager() {
  330. /** Gets the cursor to use when hovering items */
  331. this.hoverCursor = '';
  332. /** Gets the list of actions */
  333. this.actions = new Array();
  334. /**
  335. * Gets or sets a boolean indicating that the manager is recursive meaning that it can trigger action from children
  336. */
  337. this.isRecursive = false;
  338. }
  339. Object.defineProperty(AbstractActionManager, "HasTriggers", {
  340. /**
  341. * Does exist one action manager with at least one trigger
  342. **/
  343. get: function () {
  344. for (var t in AbstractActionManager.Triggers) {
  345. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  346. return true;
  347. }
  348. }
  349. return false;
  350. },
  351. enumerable: true,
  352. configurable: true
  353. });
  354. Object.defineProperty(AbstractActionManager, "HasPickTriggers", {
  355. /**
  356. * Does exist one action manager with at least one pick trigger
  357. **/
  358. get: function () {
  359. for (var t in AbstractActionManager.Triggers) {
  360. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  361. var t_int = parseInt(t);
  362. if (t_int >= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickTrigger && t_int <= _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ACTION_OnPickUpTrigger) {
  363. return true;
  364. }
  365. }
  366. }
  367. return false;
  368. },
  369. enumerable: true,
  370. configurable: true
  371. });
  372. /**
  373. * Does exist one action manager that handles actions of a given trigger
  374. * @param trigger defines the trigger to be tested
  375. * @return a boolean indicating whether the trigger is handeled by at least one action manager
  376. **/
  377. AbstractActionManager.HasSpecificTrigger = function (trigger) {
  378. for (var t in AbstractActionManager.Triggers) {
  379. if (AbstractActionManager.Triggers.hasOwnProperty(t)) {
  380. var t_int = parseInt(t);
  381. if (t_int === trigger) {
  382. return true;
  383. }
  384. }
  385. }
  386. return false;
  387. };
  388. /** Gets the list of active triggers */
  389. AbstractActionManager.Triggers = {};
  390. return AbstractActionManager;
  391. }());
  392. /***/ }),
  393. /***/ "./Actions/action.ts":
  394. /*!***************************!*\
  395. !*** ./Actions/action.ts ***!
  396. \***************************/
  397. /*! exports provided: Action */
  398. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  399. "use strict";
  400. __webpack_require__.r(__webpack_exports__);
  401. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return Action; });
  402. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  404. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  405. /**
  406. * The action to be carried out following a trigger
  407. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#available-actions
  408. */
  409. var Action = /** @class */ (function () {
  410. /**
  411. * Creates a new Action
  412. * @param triggerOptions the trigger, with or without parameters, for the action
  413. * @param condition an optional determinant of action
  414. */
  415. function Action(
  416. /** the trigger, with or without parameters, for the action */
  417. triggerOptions, condition) {
  418. this.triggerOptions = triggerOptions;
  419. /**
  420. * An event triggered prior to action being executed.
  421. */
  422. this.onBeforeExecuteObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  423. if (triggerOptions.parameter) {
  424. this.trigger = triggerOptions.trigger;
  425. this._triggerParameter = triggerOptions.parameter;
  426. }
  427. else if (triggerOptions.trigger) {
  428. this.trigger = triggerOptions.trigger;
  429. }
  430. else {
  431. this.trigger = triggerOptions;
  432. }
  433. this._nextActiveAction = this;
  434. this._condition = condition;
  435. }
  436. /**
  437. * Internal only
  438. * @hidden
  439. */
  440. Action.prototype._prepare = function () {
  441. };
  442. /**
  443. * Gets the trigger parameters
  444. * @returns the trigger parameters
  445. */
  446. Action.prototype.getTriggerParameter = function () {
  447. return this._triggerParameter;
  448. };
  449. /**
  450. * Internal only - executes current action event
  451. * @hidden
  452. */
  453. Action.prototype._executeCurrent = function (evt) {
  454. if (this._nextActiveAction._condition) {
  455. var condition = this._nextActiveAction._condition;
  456. var currentRenderId = this._actionManager.getScene().getRenderId();
  457. // We cache the current evaluation for the current frame
  458. if (condition._evaluationId === currentRenderId) {
  459. if (!condition._currentResult) {
  460. return;
  461. }
  462. }
  463. else {
  464. condition._evaluationId = currentRenderId;
  465. if (!condition.isValid()) {
  466. condition._currentResult = false;
  467. return;
  468. }
  469. condition._currentResult = true;
  470. }
  471. }
  472. this.onBeforeExecuteObservable.notifyObservers(this);
  473. this._nextActiveAction.execute(evt);
  474. this.skipToNextActiveAction();
  475. };
  476. /**
  477. * Execute placeholder for child classes
  478. * @param evt optional action event
  479. */
  480. Action.prototype.execute = function (evt) {
  481. };
  482. /**
  483. * Skips to next active action
  484. */
  485. Action.prototype.skipToNextActiveAction = function () {
  486. if (this._nextActiveAction._child) {
  487. if (!this._nextActiveAction._child._actionManager) {
  488. this._nextActiveAction._child._actionManager = this._actionManager;
  489. }
  490. this._nextActiveAction = this._nextActiveAction._child;
  491. }
  492. else {
  493. this._nextActiveAction = this;
  494. }
  495. };
  496. /**
  497. * Adds action to chain of actions, may be a DoNothingAction
  498. * @param action defines the next action to execute
  499. * @returns The action passed in
  500. * @see https://www.babylonjs-playground.com/#1T30HR#0
  501. */
  502. Action.prototype.then = function (action) {
  503. this._child = action;
  504. action._actionManager = this._actionManager;
  505. action._prepare();
  506. return action;
  507. };
  508. /**
  509. * Internal only
  510. * @hidden
  511. */
  512. Action.prototype._getProperty = function (propertyPath) {
  513. return this._actionManager._getProperty(propertyPath);
  514. };
  515. /**
  516. * Internal only
  517. * @hidden
  518. */
  519. Action.prototype._getEffectiveTarget = function (target, propertyPath) {
  520. return this._actionManager._getEffectiveTarget(target, propertyPath);
  521. };
  522. /**
  523. * Serialize placeholder for child classes
  524. * @param parent of child
  525. * @returns the serialized object
  526. */
  527. Action.prototype.serialize = function (parent) {
  528. };
  529. /**
  530. * Internal only called by serialize
  531. * @hidden
  532. */
  533. Action.prototype._serialize = function (serializedAction, parent) {
  534. var serializationObject = {
  535. type: 1,
  536. children: [],
  537. name: serializedAction.name,
  538. properties: serializedAction.properties || []
  539. };
  540. // Serialize child
  541. if (this._child) {
  542. this._child.serialize(serializationObject);
  543. }
  544. // Check if "this" has a condition
  545. if (this._condition) {
  546. var serializedCondition = this._condition.serialize();
  547. serializedCondition.children.push(serializationObject);
  548. if (parent) {
  549. parent.children.push(serializedCondition);
  550. }
  551. return serializedCondition;
  552. }
  553. if (parent) {
  554. parent.children.push(serializationObject);
  555. }
  556. return serializationObject;
  557. };
  558. /**
  559. * Internal only
  560. * @hidden
  561. */
  562. Action._SerializeValueAsString = function (value) {
  563. if (typeof value === "number") {
  564. return value.toString();
  565. }
  566. if (typeof value === "boolean") {
  567. return value ? "true" : "false";
  568. }
  569. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]) {
  570. return value.x + ", " + value.y;
  571. }
  572. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  573. return value.x + ", " + value.y + ", " + value.z;
  574. }
  575. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  576. return value.r + ", " + value.g + ", " + value.b;
  577. }
  578. if (value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  579. return value.r + ", " + value.g + ", " + value.b + ", " + value.a;
  580. }
  581. return value; // string
  582. };
  583. /**
  584. * Internal only
  585. * @hidden
  586. */
  587. Action._GetTargetProperty = function (target) {
  588. return {
  589. name: "target",
  590. targetType: target._isMesh ? "MeshProperties"
  591. : target._isLight ? "LightProperties"
  592. : target._isCamera ? "CameraProperties"
  593. : "SceneProperties",
  594. value: target._isScene ? "Scene" : target.name
  595. };
  596. };
  597. return Action;
  598. }());
  599. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.Action"] = Action;
  600. /***/ }),
  601. /***/ "./Actions/actionEvent.ts":
  602. /*!********************************!*\
  603. !*** ./Actions/actionEvent.ts ***!
  604. \********************************/
  605. /*! exports provided: ActionEvent */
  606. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  607. "use strict";
  608. __webpack_require__.r(__webpack_exports__);
  609. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return ActionEvent; });
  610. /**
  611. * ActionEvent is the event being sent when an action is triggered.
  612. */
  613. var ActionEvent = /** @class */ (function () {
  614. /**
  615. * Creates a new ActionEvent
  616. * @param source The mesh or sprite that triggered the action
  617. * @param pointerX The X mouse cursor position at the time of the event
  618. * @param pointerY The Y mouse cursor position at the time of the event
  619. * @param meshUnderPointer The mesh that is currently pointed at (can be null)
  620. * @param sourceEvent the original (browser) event that triggered the ActionEvent
  621. * @param additionalData additional data for the event
  622. */
  623. function ActionEvent(
  624. /** The mesh or sprite that triggered the action */
  625. source,
  626. /** The X mouse cursor position at the time of the event */
  627. pointerX,
  628. /** The Y mouse cursor position at the time of the event */
  629. pointerY,
  630. /** The mesh that is currently pointed at (can be null) */
  631. meshUnderPointer,
  632. /** the original (browser) event that triggered the ActionEvent */
  633. sourceEvent,
  634. /** additional data for the event */
  635. additionalData) {
  636. this.source = source;
  637. this.pointerX = pointerX;
  638. this.pointerY = pointerY;
  639. this.meshUnderPointer = meshUnderPointer;
  640. this.sourceEvent = sourceEvent;
  641. this.additionalData = additionalData;
  642. }
  643. /**
  644. * Helper function to auto-create an ActionEvent from a source mesh.
  645. * @param source The source mesh that triggered the event
  646. * @param evt The original (browser) event
  647. * @param additionalData additional data for the event
  648. * @returns the new ActionEvent
  649. */
  650. ActionEvent.CreateNew = function (source, evt, additionalData) {
  651. var scene = source.getScene();
  652. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  653. };
  654. /**
  655. * Helper function to auto-create an ActionEvent from a source sprite
  656. * @param source The source sprite that triggered the event
  657. * @param scene Scene associated with the sprite
  658. * @param evt The original (browser) event
  659. * @param additionalData additional data for the event
  660. * @returns the new ActionEvent
  661. */
  662. ActionEvent.CreateNewFromSprite = function (source, scene, evt, additionalData) {
  663. return new ActionEvent(source, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt, additionalData);
  664. };
  665. /**
  666. * Helper function to auto-create an ActionEvent from a scene. If triggered by a mesh use ActionEvent.CreateNew
  667. * @param scene the scene where the event occurred
  668. * @param evt The original (browser) event
  669. * @returns the new ActionEvent
  670. */
  671. ActionEvent.CreateNewFromScene = function (scene, evt) {
  672. return new ActionEvent(null, scene.pointerX, scene.pointerY, scene.meshUnderPointer, evt);
  673. };
  674. /**
  675. * Helper function to auto-create an ActionEvent from a primitive
  676. * @param prim defines the target primitive
  677. * @param pointerPos defines the pointer position
  678. * @param evt The original (browser) event
  679. * @param additionalData additional data for the event
  680. * @returns the new ActionEvent
  681. */
  682. ActionEvent.CreateNewFromPrimitive = function (prim, pointerPos, evt, additionalData) {
  683. return new ActionEvent(prim, pointerPos.x, pointerPos.y, null, evt, additionalData);
  684. };
  685. return ActionEvent;
  686. }());
  687. /***/ }),
  688. /***/ "./Actions/actionManager.ts":
  689. /*!**********************************!*\
  690. !*** ./Actions/actionManager.ts ***!
  691. \**********************************/
  692. /*! exports provided: ActionManager */
  693. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  694. "use strict";
  695. __webpack_require__.r(__webpack_exports__);
  696. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return ActionManager; });
  697. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  698. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  699. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  700. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  701. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  702. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  703. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  704. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  705. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  706. /* harmony import */ var _abstractActionManager__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./abstractActionManager */ "./Actions/abstractActionManager.ts");
  707. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  708. /**
  709. * Action Manager manages all events to be triggered on a given mesh or the global scene.
  710. * A single scene can have many Action Managers to handle predefined actions on specific meshes.
  711. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  712. */
  713. var ActionManager = /** @class */ (function (_super) {
  714. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ActionManager, _super);
  715. /**
  716. * Creates a new action manager
  717. * @param scene defines the hosting scene
  718. */
  719. function ActionManager(scene) {
  720. var _this = _super.call(this) || this;
  721. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  722. scene.actionManagers.push(_this);
  723. return _this;
  724. }
  725. // Methods
  726. /**
  727. * Releases all associated resources
  728. */
  729. ActionManager.prototype.dispose = function () {
  730. var index = this._scene.actionManagers.indexOf(this);
  731. for (var i = 0; i < this.actions.length; i++) {
  732. var action = this.actions[i];
  733. ActionManager.Triggers[action.trigger]--;
  734. if (ActionManager.Triggers[action.trigger] === 0) {
  735. delete ActionManager.Triggers[action.trigger];
  736. }
  737. }
  738. if (index > -1) {
  739. this._scene.actionManagers.splice(index, 1);
  740. }
  741. };
  742. /**
  743. * Gets hosting scene
  744. * @returns the hosting scene
  745. */
  746. ActionManager.prototype.getScene = function () {
  747. return this._scene;
  748. };
  749. /**
  750. * Does this action manager handles actions of any of the given triggers
  751. * @param triggers defines the triggers to be tested
  752. * @return a boolean indicating whether one (or more) of the triggers is handled
  753. */
  754. ActionManager.prototype.hasSpecificTriggers = function (triggers) {
  755. for (var index = 0; index < this.actions.length; index++) {
  756. var action = this.actions[index];
  757. if (triggers.indexOf(action.trigger) > -1) {
  758. return true;
  759. }
  760. }
  761. return false;
  762. };
  763. /**
  764. * Does this action manager handles actions of any of the given triggers. This function takes two arguments for
  765. * speed.
  766. * @param triggerA defines the trigger to be tested
  767. * @param triggerB defines the trigger to be tested
  768. * @return a boolean indicating whether one (or more) of the triggers is handled
  769. */
  770. ActionManager.prototype.hasSpecificTriggers2 = function (triggerA, triggerB) {
  771. for (var index = 0; index < this.actions.length; index++) {
  772. var action = this.actions[index];
  773. if (triggerA == action.trigger || triggerB == action.trigger) {
  774. return true;
  775. }
  776. }
  777. return false;
  778. };
  779. /**
  780. * Does this action manager handles actions of a given trigger
  781. * @param trigger defines the trigger to be tested
  782. * @param parameterPredicate defines an optional predicate to filter triggers by parameter
  783. * @return whether the trigger is handled
  784. */
  785. ActionManager.prototype.hasSpecificTrigger = function (trigger, parameterPredicate) {
  786. for (var index = 0; index < this.actions.length; index++) {
  787. var action = this.actions[index];
  788. if (action.trigger === trigger) {
  789. if (parameterPredicate) {
  790. if (parameterPredicate(action.getTriggerParameter())) {
  791. return true;
  792. }
  793. }
  794. else {
  795. return true;
  796. }
  797. }
  798. }
  799. return false;
  800. };
  801. Object.defineProperty(ActionManager.prototype, "hasPointerTriggers", {
  802. /**
  803. * Does this action manager has pointer triggers
  804. */
  805. get: function () {
  806. for (var index = 0; index < this.actions.length; index++) {
  807. var action = this.actions[index];
  808. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPointerOutTrigger) {
  809. return true;
  810. }
  811. }
  812. return false;
  813. },
  814. enumerable: true,
  815. configurable: true
  816. });
  817. Object.defineProperty(ActionManager.prototype, "hasPickTriggers", {
  818. /**
  819. * Does this action manager has pick triggers
  820. */
  821. get: function () {
  822. for (var index = 0; index < this.actions.length; index++) {
  823. var action = this.actions[index];
  824. if (action.trigger >= ActionManager.OnPickTrigger && action.trigger <= ActionManager.OnPickUpTrigger) {
  825. return true;
  826. }
  827. }
  828. return false;
  829. },
  830. enumerable: true,
  831. configurable: true
  832. });
  833. /**
  834. * Registers an action to this action manager
  835. * @param action defines the action to be registered
  836. * @return the action amended (prepared) after registration
  837. */
  838. ActionManager.prototype.registerAction = function (action) {
  839. if (action.trigger === ActionManager.OnEveryFrameTrigger) {
  840. if (this.getScene().actionManager !== this) {
  841. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Warn("OnEveryFrameTrigger can only be used with scene.actionManager");
  842. return null;
  843. }
  844. }
  845. this.actions.push(action);
  846. if (ActionManager.Triggers[action.trigger]) {
  847. ActionManager.Triggers[action.trigger]++;
  848. }
  849. else {
  850. ActionManager.Triggers[action.trigger] = 1;
  851. }
  852. action._actionManager = this;
  853. action._prepare();
  854. return action;
  855. };
  856. /**
  857. * Unregisters an action to this action manager
  858. * @param action defines the action to be unregistered
  859. * @return a boolean indicating whether the action has been unregistered
  860. */
  861. ActionManager.prototype.unregisterAction = function (action) {
  862. var index = this.actions.indexOf(action);
  863. if (index !== -1) {
  864. this.actions.splice(index, 1);
  865. ActionManager.Triggers[action.trigger] -= 1;
  866. if (ActionManager.Triggers[action.trigger] === 0) {
  867. delete ActionManager.Triggers[action.trigger];
  868. }
  869. delete action._actionManager;
  870. return true;
  871. }
  872. return false;
  873. };
  874. /**
  875. * Process a specific trigger
  876. * @param trigger defines the trigger to process
  877. * @param evt defines the event details to be processed
  878. */
  879. ActionManager.prototype.processTrigger = function (trigger, evt) {
  880. for (var index = 0; index < this.actions.length; index++) {
  881. var action = this.actions[index];
  882. if (action.trigger === trigger) {
  883. if (evt) {
  884. if (trigger === ActionManager.OnKeyUpTrigger
  885. || trigger === ActionManager.OnKeyDownTrigger) {
  886. var parameter = action.getTriggerParameter();
  887. if (parameter && parameter !== evt.sourceEvent.keyCode) {
  888. if (!parameter.toLowerCase) {
  889. continue;
  890. }
  891. var lowerCase = parameter.toLowerCase();
  892. if (lowerCase !== evt.sourceEvent.key) {
  893. var unicode = evt.sourceEvent.charCode ? evt.sourceEvent.charCode : evt.sourceEvent.keyCode;
  894. var actualkey = String.fromCharCode(unicode).toLowerCase();
  895. if (actualkey !== lowerCase) {
  896. continue;
  897. }
  898. }
  899. }
  900. }
  901. }
  902. action._executeCurrent(evt);
  903. }
  904. }
  905. };
  906. /** @hidden */
  907. ActionManager.prototype._getEffectiveTarget = function (target, propertyPath) {
  908. var properties = propertyPath.split(".");
  909. for (var index = 0; index < properties.length - 1; index++) {
  910. target = target[properties[index]];
  911. }
  912. return target;
  913. };
  914. /** @hidden */
  915. ActionManager.prototype._getProperty = function (propertyPath) {
  916. var properties = propertyPath.split(".");
  917. return properties[properties.length - 1];
  918. };
  919. /**
  920. * Serialize this manager to a JSON object
  921. * @param name defines the property name to store this manager
  922. * @returns a JSON representation of this manager
  923. */
  924. ActionManager.prototype.serialize = function (name) {
  925. var root = {
  926. children: new Array(),
  927. name: name,
  928. type: 3,
  929. properties: new Array() // Empty for root but required
  930. };
  931. for (var i = 0; i < this.actions.length; i++) {
  932. var triggerObject = {
  933. type: 0,
  934. children: new Array(),
  935. name: ActionManager.GetTriggerName(this.actions[i].trigger),
  936. properties: new Array()
  937. };
  938. var triggerOptions = this.actions[i].triggerOptions;
  939. if (triggerOptions && typeof triggerOptions !== "number") {
  940. if (triggerOptions.parameter instanceof Node) {
  941. triggerObject.properties.push(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(triggerOptions.parameter));
  942. }
  943. else {
  944. var parameter = {};
  945. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_7__["DeepCopier"].DeepCopy(triggerOptions.parameter, parameter, ["mesh"]);
  946. if (triggerOptions.parameter && triggerOptions.parameter.mesh) {
  947. parameter._meshId = triggerOptions.parameter.mesh.id;
  948. }
  949. triggerObject.properties.push({ name: "parameter", targetType: null, value: parameter });
  950. }
  951. }
  952. // Serialize child action, recursively
  953. this.actions[i].serialize(triggerObject);
  954. // Add serialized trigger
  955. root.children.push(triggerObject);
  956. }
  957. return root;
  958. };
  959. /**
  960. * Creates a new ActionManager from a JSON data
  961. * @param parsedActions defines the JSON data to read from
  962. * @param object defines the hosting mesh
  963. * @param scene defines the hosting scene
  964. */
  965. ActionManager.Parse = function (parsedActions, object, scene) {
  966. var actionManager = new ActionManager(scene);
  967. if (object === null) {
  968. scene.actionManager = actionManager;
  969. }
  970. else {
  971. object.actionManager = actionManager;
  972. }
  973. // instanciate a new object
  974. var instanciate = function (name, params) {
  975. var internalClassType = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON." + name);
  976. if (internalClassType) {
  977. var newInstance = Object.create(internalClassType.prototype);
  978. newInstance.constructor.apply(newInstance, params);
  979. return newInstance;
  980. }
  981. };
  982. var parseParameter = function (name, value, target, propertyPath) {
  983. if (propertyPath === null) {
  984. // String, boolean or float
  985. var floatValue = parseFloat(value);
  986. if (value === "true" || value === "false") {
  987. return value === "true";
  988. }
  989. else {
  990. return isNaN(floatValue) ? value : floatValue;
  991. }
  992. }
  993. var effectiveTarget = propertyPath.split(".");
  994. var values = value.split(",");
  995. // Get effective Target
  996. for (var i = 0; i < effectiveTarget.length; i++) {
  997. target = target[effectiveTarget[i]];
  998. }
  999. // Return appropriate value with its type
  1000. if (typeof (target) === "boolean") {
  1001. return values[0] === "true";
  1002. }
  1003. if (typeof (target) === "string") {
  1004. return values[0];
  1005. }
  1006. // Parameters with multiple values such as Vector3 etc.
  1007. var split = new Array();
  1008. for (var i = 0; i < values.length; i++) {
  1009. split.push(parseFloat(values[i]));
  1010. }
  1011. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]) {
  1012. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(split);
  1013. }
  1014. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]) {
  1015. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector4"].FromArray(split);
  1016. }
  1017. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"]) {
  1018. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(split);
  1019. }
  1020. if (target instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"]) {
  1021. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(split);
  1022. }
  1023. return parseFloat(values[0]);
  1024. };
  1025. // traverse graph per trigger
  1026. var traverse = function (parsedAction, trigger, condition, action, combineArray) {
  1027. if (combineArray === void 0) { combineArray = null; }
  1028. if (parsedAction.detached) {
  1029. return;
  1030. }
  1031. var parameters = new Array();
  1032. var target = null;
  1033. var propertyPath = null;
  1034. var combine = parsedAction.combine && parsedAction.combine.length > 0;
  1035. // Parameters
  1036. if (parsedAction.type === 2) {
  1037. parameters.push(actionManager);
  1038. }
  1039. else {
  1040. parameters.push(trigger);
  1041. }
  1042. if (combine) {
  1043. var actions = new Array();
  1044. for (var j = 0; j < parsedAction.combine.length; j++) {
  1045. traverse(parsedAction.combine[j], ActionManager.NothingTrigger, condition, action, actions);
  1046. }
  1047. parameters.push(actions);
  1048. }
  1049. else {
  1050. for (var i = 0; i < parsedAction.properties.length; i++) {
  1051. var value = parsedAction.properties[i].value;
  1052. var name = parsedAction.properties[i].name;
  1053. var targetType = parsedAction.properties[i].targetType;
  1054. if (name === "target") {
  1055. if (targetType !== null && targetType === "SceneProperties") {
  1056. value = target = scene;
  1057. }
  1058. else {
  1059. value = target = scene.getNodeByName(value);
  1060. }
  1061. }
  1062. else if (name === "parent") {
  1063. value = scene.getNodeByName(value);
  1064. }
  1065. else if (name === "sound") {
  1066. // Can not externalize to component, so only checks for the presence off the API.
  1067. if (scene.getSoundByName) {
  1068. value = scene.getSoundByName(value);
  1069. }
  1070. }
  1071. else if (name !== "propertyPath") {
  1072. if (parsedAction.type === 2 && name === "operator") {
  1073. value = _condition__WEBPACK_IMPORTED_MODULE_2__["ValueCondition"][value];
  1074. }
  1075. else {
  1076. value = parseParameter(name, value, target, name === "value" ? propertyPath : null);
  1077. }
  1078. }
  1079. else {
  1080. propertyPath = value;
  1081. }
  1082. parameters.push(value);
  1083. }
  1084. }
  1085. if (combineArray === null) {
  1086. parameters.push(condition);
  1087. }
  1088. else {
  1089. parameters.push(null);
  1090. }
  1091. // If interpolate value action
  1092. if (parsedAction.name === "InterpolateValueAction") {
  1093. var param = parameters[parameters.length - 2];
  1094. parameters[parameters.length - 1] = param;
  1095. parameters[parameters.length - 2] = condition;
  1096. }
  1097. // Action or condition(s) and not CombineAction
  1098. var newAction = instanciate(parsedAction.name, parameters);
  1099. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"] && condition !== null) {
  1100. var nothing = new _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"](trigger, condition);
  1101. if (action) {
  1102. action.then(nothing);
  1103. }
  1104. else {
  1105. actionManager.registerAction(nothing);
  1106. }
  1107. action = nothing;
  1108. }
  1109. if (combineArray === null) {
  1110. if (newAction instanceof _condition__WEBPACK_IMPORTED_MODULE_2__["Condition"]) {
  1111. condition = newAction;
  1112. newAction = action;
  1113. }
  1114. else {
  1115. condition = null;
  1116. if (action) {
  1117. action.then(newAction);
  1118. }
  1119. else {
  1120. actionManager.registerAction(newAction);
  1121. }
  1122. }
  1123. }
  1124. else {
  1125. combineArray.push(newAction);
  1126. }
  1127. for (var i = 0; i < parsedAction.children.length; i++) {
  1128. traverse(parsedAction.children[i], trigger, condition, newAction, null);
  1129. }
  1130. };
  1131. // triggers
  1132. for (var i = 0; i < parsedActions.children.length; i++) {
  1133. var triggerParams;
  1134. var trigger = parsedActions.children[i];
  1135. if (trigger.properties.length > 0) {
  1136. var param = trigger.properties[0].value;
  1137. var value = trigger.properties[0].targetType === null ? param : scene.getMeshByName(param);
  1138. if (value._meshId) {
  1139. value.mesh = scene.getMeshByID(value._meshId);
  1140. }
  1141. triggerParams = { trigger: ActionManager[trigger.name], parameter: value };
  1142. }
  1143. else {
  1144. triggerParams = ActionManager[trigger.name];
  1145. }
  1146. for (var j = 0; j < trigger.children.length; j++) {
  1147. if (!trigger.detached) {
  1148. traverse(trigger.children[j], triggerParams, null, null);
  1149. }
  1150. }
  1151. }
  1152. };
  1153. /**
  1154. * Get a trigger name by index
  1155. * @param trigger defines the trigger index
  1156. * @returns a trigger name
  1157. */
  1158. ActionManager.GetTriggerName = function (trigger) {
  1159. switch (trigger) {
  1160. case 0: return "NothingTrigger";
  1161. case 1: return "OnPickTrigger";
  1162. case 2: return "OnLeftPickTrigger";
  1163. case 3: return "OnRightPickTrigger";
  1164. case 4: return "OnCenterPickTrigger";
  1165. case 5: return "OnPickDownTrigger";
  1166. case 6: return "OnPickUpTrigger";
  1167. case 7: return "OnLongPressTrigger";
  1168. case 8: return "OnPointerOverTrigger";
  1169. case 9: return "OnPointerOutTrigger";
  1170. case 10: return "OnEveryFrameTrigger";
  1171. case 11: return "OnIntersectionEnterTrigger";
  1172. case 12: return "OnIntersectionExitTrigger";
  1173. case 13: return "OnKeyDownTrigger";
  1174. case 14: return "OnKeyUpTrigger";
  1175. case 15: return "OnPickOutTrigger";
  1176. default: return "";
  1177. }
  1178. };
  1179. /**
  1180. * Nothing
  1181. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1182. */
  1183. ActionManager.NothingTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_NothingTrigger;
  1184. /**
  1185. * On pick
  1186. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1187. */
  1188. ActionManager.OnPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickTrigger;
  1189. /**
  1190. * On left pick
  1191. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1192. */
  1193. ActionManager.OnLeftPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLeftPickTrigger;
  1194. /**
  1195. * On right pick
  1196. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1197. */
  1198. ActionManager.OnRightPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnRightPickTrigger;
  1199. /**
  1200. * On center pick
  1201. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1202. */
  1203. ActionManager.OnCenterPickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnCenterPickTrigger;
  1204. /**
  1205. * On pick down
  1206. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1207. */
  1208. ActionManager.OnPickDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickDownTrigger;
  1209. /**
  1210. * On double pick
  1211. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1212. */
  1213. ActionManager.OnDoublePickTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnDoublePickTrigger;
  1214. /**
  1215. * On pick up
  1216. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1217. */
  1218. ActionManager.OnPickUpTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickUpTrigger;
  1219. /**
  1220. * On pick out.
  1221. * This trigger will only be raised if you also declared a OnPickDown
  1222. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1223. */
  1224. ActionManager.OnPickOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPickOutTrigger;
  1225. /**
  1226. * On long press
  1227. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1228. */
  1229. ActionManager.OnLongPressTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnLongPressTrigger;
  1230. /**
  1231. * On pointer over
  1232. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1233. */
  1234. ActionManager.OnPointerOverTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOverTrigger;
  1235. /**
  1236. * On pointer out
  1237. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1238. */
  1239. ActionManager.OnPointerOutTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnPointerOutTrigger;
  1240. /**
  1241. * On every frame
  1242. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1243. */
  1244. ActionManager.OnEveryFrameTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnEveryFrameTrigger;
  1245. /**
  1246. * On intersection enter
  1247. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1248. */
  1249. ActionManager.OnIntersectionEnterTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionEnterTrigger;
  1250. /**
  1251. * On intersection exit
  1252. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1253. */
  1254. ActionManager.OnIntersectionExitTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnIntersectionExitTrigger;
  1255. /**
  1256. * On key down
  1257. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1258. */
  1259. ActionManager.OnKeyDownTrigger = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ACTION_OnKeyDownTrigger;
  1260. /**
  1261. * On key up
  1262. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  1263. */
  1264. ActionManager.OnKeyUpTrigger = 15;
  1265. return ActionManager;
  1266. }(_abstractActionManager__WEBPACK_IMPORTED_MODULE_9__["AbstractActionManager"]));
  1267. /***/ }),
  1268. /***/ "./Actions/condition.ts":
  1269. /*!******************************!*\
  1270. !*** ./Actions/condition.ts ***!
  1271. \******************************/
  1272. /*! exports provided: Condition, ValueCondition, PredicateCondition, StateCondition */
  1273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1274. "use strict";
  1275. __webpack_require__.r(__webpack_exports__);
  1276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return Condition; });
  1277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return ValueCondition; });
  1278. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return PredicateCondition; });
  1279. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return StateCondition; });
  1280. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1281. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1282. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1283. /**
  1284. * A Condition applied to an Action
  1285. */
  1286. var Condition = /** @class */ (function () {
  1287. /**
  1288. * Creates a new Condition
  1289. * @param actionManager the manager of the action the condition is applied to
  1290. */
  1291. function Condition(actionManager) {
  1292. this._actionManager = actionManager;
  1293. }
  1294. /**
  1295. * Check if the current condition is valid
  1296. * @returns a boolean
  1297. */
  1298. Condition.prototype.isValid = function () {
  1299. return true;
  1300. };
  1301. /**
  1302. * Internal only
  1303. * @hidden
  1304. */
  1305. Condition.prototype._getProperty = function (propertyPath) {
  1306. return this._actionManager._getProperty(propertyPath);
  1307. };
  1308. /**
  1309. * Internal only
  1310. * @hidden
  1311. */
  1312. Condition.prototype._getEffectiveTarget = function (target, propertyPath) {
  1313. return this._actionManager._getEffectiveTarget(target, propertyPath);
  1314. };
  1315. /**
  1316. * Serialize placeholder for child classes
  1317. * @returns the serialized object
  1318. */
  1319. Condition.prototype.serialize = function () {
  1320. };
  1321. /**
  1322. * Internal only
  1323. * @hidden
  1324. */
  1325. Condition.prototype._serialize = function (serializedCondition) {
  1326. return {
  1327. type: 2,
  1328. children: [],
  1329. name: serializedCondition.name,
  1330. properties: serializedCondition.properties
  1331. };
  1332. };
  1333. return Condition;
  1334. }());
  1335. /**
  1336. * Defines specific conditional operators as extensions of Condition
  1337. */
  1338. var ValueCondition = /** @class */ (function (_super) {
  1339. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ValueCondition, _super);
  1340. /**
  1341. * Creates a new ValueCondition
  1342. * @param actionManager manager for the action the condition applies to
  1343. * @param target for the action
  1344. * @param propertyPath path to specify the property of the target the conditional operator uses
  1345. * @param value the value compared by the conditional operator against the current value of the property
  1346. * @param operator the conditional operator, default ValueCondition.IsEqual
  1347. */
  1348. function ValueCondition(actionManager, target,
  1349. /** path to specify the property of the target the conditional operator uses */
  1350. propertyPath,
  1351. /** the value compared by the conditional operator against the current value of the property */
  1352. value,
  1353. /** the conditional operator, default ValueCondition.IsEqual */
  1354. operator) {
  1355. if (operator === void 0) { operator = ValueCondition.IsEqual; }
  1356. var _this = _super.call(this, actionManager) || this;
  1357. _this.propertyPath = propertyPath;
  1358. _this.value = value;
  1359. _this.operator = operator;
  1360. _this._target = target;
  1361. _this._effectiveTarget = _this._getEffectiveTarget(target, _this.propertyPath);
  1362. _this._property = _this._getProperty(_this.propertyPath);
  1363. return _this;
  1364. }
  1365. Object.defineProperty(ValueCondition, "IsEqual", {
  1366. /**
  1367. * returns the number for IsEqual
  1368. */
  1369. get: function () {
  1370. return ValueCondition._IsEqual;
  1371. },
  1372. enumerable: true,
  1373. configurable: true
  1374. });
  1375. Object.defineProperty(ValueCondition, "IsDifferent", {
  1376. /**
  1377. * Returns the number for IsDifferent
  1378. */
  1379. get: function () {
  1380. return ValueCondition._IsDifferent;
  1381. },
  1382. enumerable: true,
  1383. configurable: true
  1384. });
  1385. Object.defineProperty(ValueCondition, "IsGreater", {
  1386. /**
  1387. * Returns the number for IsGreater
  1388. */
  1389. get: function () {
  1390. return ValueCondition._IsGreater;
  1391. },
  1392. enumerable: true,
  1393. configurable: true
  1394. });
  1395. Object.defineProperty(ValueCondition, "IsLesser", {
  1396. /**
  1397. * Returns the number for IsLesser
  1398. */
  1399. get: function () {
  1400. return ValueCondition._IsLesser;
  1401. },
  1402. enumerable: true,
  1403. configurable: true
  1404. });
  1405. /**
  1406. * Compares the given value with the property value for the specified conditional operator
  1407. * @returns the result of the comparison
  1408. */
  1409. ValueCondition.prototype.isValid = function () {
  1410. switch (this.operator) {
  1411. case ValueCondition.IsGreater:
  1412. return this._effectiveTarget[this._property] > this.value;
  1413. case ValueCondition.IsLesser:
  1414. return this._effectiveTarget[this._property] < this.value;
  1415. case ValueCondition.IsEqual:
  1416. case ValueCondition.IsDifferent:
  1417. var check;
  1418. if (this.value.equals) {
  1419. check = this.value.equals(this._effectiveTarget[this._property]);
  1420. }
  1421. else {
  1422. check = this.value === this._effectiveTarget[this._property];
  1423. }
  1424. return this.operator === ValueCondition.IsEqual ? check : !check;
  1425. }
  1426. return false;
  1427. };
  1428. /**
  1429. * Serialize the ValueCondition into a JSON compatible object
  1430. * @returns serialization object
  1431. */
  1432. ValueCondition.prototype.serialize = function () {
  1433. return this._serialize({
  1434. name: "ValueCondition",
  1435. properties: [
  1436. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1437. { name: "propertyPath", value: this.propertyPath },
  1438. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  1439. { name: "operator", value: ValueCondition.GetOperatorName(this.operator) }
  1440. ]
  1441. });
  1442. };
  1443. /**
  1444. * Gets the name of the conditional operator for the ValueCondition
  1445. * @param operator the conditional operator
  1446. * @returns the name
  1447. */
  1448. ValueCondition.GetOperatorName = function (operator) {
  1449. switch (operator) {
  1450. case ValueCondition._IsEqual: return "IsEqual";
  1451. case ValueCondition._IsDifferent: return "IsDifferent";
  1452. case ValueCondition._IsGreater: return "IsGreater";
  1453. case ValueCondition._IsLesser: return "IsLesser";
  1454. default: return "";
  1455. }
  1456. };
  1457. /**
  1458. * Internal only
  1459. * @hidden
  1460. */
  1461. ValueCondition._IsEqual = 0;
  1462. /**
  1463. * Internal only
  1464. * @hidden
  1465. */
  1466. ValueCondition._IsDifferent = 1;
  1467. /**
  1468. * Internal only
  1469. * @hidden
  1470. */
  1471. ValueCondition._IsGreater = 2;
  1472. /**
  1473. * Internal only
  1474. * @hidden
  1475. */
  1476. ValueCondition._IsLesser = 3;
  1477. return ValueCondition;
  1478. }(Condition));
  1479. /**
  1480. * Defines a predicate condition as an extension of Condition
  1481. */
  1482. var PredicateCondition = /** @class */ (function (_super) {
  1483. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PredicateCondition, _super);
  1484. /**
  1485. * Creates a new PredicateCondition
  1486. * @param actionManager manager for the action the condition applies to
  1487. * @param predicate defines the predicate function used to validate the condition
  1488. */
  1489. function PredicateCondition(actionManager,
  1490. /** defines the predicate function used to validate the condition */
  1491. predicate) {
  1492. var _this = _super.call(this, actionManager) || this;
  1493. _this.predicate = predicate;
  1494. return _this;
  1495. }
  1496. /**
  1497. * @returns the validity of the predicate condition
  1498. */
  1499. PredicateCondition.prototype.isValid = function () {
  1500. return this.predicate();
  1501. };
  1502. return PredicateCondition;
  1503. }(Condition));
  1504. /**
  1505. * Defines a state condition as an extension of Condition
  1506. */
  1507. var StateCondition = /** @class */ (function (_super) {
  1508. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StateCondition, _super);
  1509. /**
  1510. * Creates a new StateCondition
  1511. * @param actionManager manager for the action the condition applies to
  1512. * @param target of the condition
  1513. * @param value to compare with target state
  1514. */
  1515. function StateCondition(actionManager, target,
  1516. /** Value to compare with target state */
  1517. value) {
  1518. var _this = _super.call(this, actionManager) || this;
  1519. _this.value = value;
  1520. _this._target = target;
  1521. return _this;
  1522. }
  1523. /**
  1524. * Gets a boolean indicating if the current condition is met
  1525. * @returns the validity of the state
  1526. */
  1527. StateCondition.prototype.isValid = function () {
  1528. return this._target.state === this.value;
  1529. };
  1530. /**
  1531. * Serialize the StateCondition into a JSON compatible object
  1532. * @returns serialization object
  1533. */
  1534. StateCondition.prototype.serialize = function () {
  1535. return this._serialize({
  1536. name: "StateCondition",
  1537. properties: [
  1538. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  1539. { name: "value", value: this.value }
  1540. ]
  1541. });
  1542. };
  1543. return StateCondition;
  1544. }(Condition));
  1545. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.ValueCondition"] = ValueCondition;
  1546. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PredicateCondition"] = PredicateCondition;
  1547. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StateCondition"] = StateCondition;
  1548. /***/ }),
  1549. /***/ "./Actions/directActions.ts":
  1550. /*!**********************************!*\
  1551. !*** ./Actions/directActions.ts ***!
  1552. \**********************************/
  1553. /*! exports provided: SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction */
  1554. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  1555. "use strict";
  1556. __webpack_require__.r(__webpack_exports__);
  1557. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return SwitchBooleanAction; });
  1558. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return SetStateAction; });
  1559. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return SetValueAction; });
  1560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return IncrementValueAction; });
  1561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return PlayAnimationAction; });
  1562. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return StopAnimationAction; });
  1563. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return DoNothingAction; });
  1564. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return CombineAction; });
  1565. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return ExecuteCodeAction; });
  1566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return SetParentAction; });
  1567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  1568. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  1569. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  1570. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  1571. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  1572. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  1573. /**
  1574. * This defines an action responsible to toggle a boolean once triggered.
  1575. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1576. */
  1577. var SwitchBooleanAction = /** @class */ (function (_super) {
  1578. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SwitchBooleanAction, _super);
  1579. /**
  1580. * Instantiate the action
  1581. * @param triggerOptions defines the trigger options
  1582. * @param target defines the object containing the boolean
  1583. * @param propertyPath defines the path to the boolean property in the target object
  1584. * @param condition defines the trigger related conditions
  1585. */
  1586. function SwitchBooleanAction(triggerOptions, target, propertyPath, condition) {
  1587. var _this = _super.call(this, triggerOptions, condition) || this;
  1588. _this.propertyPath = propertyPath;
  1589. _this._target = _this._effectiveTarget = target;
  1590. return _this;
  1591. }
  1592. /** @hidden */
  1593. SwitchBooleanAction.prototype._prepare = function () {
  1594. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1595. this._property = this._getProperty(this.propertyPath);
  1596. };
  1597. /**
  1598. * Execute the action toggle the boolean value.
  1599. */
  1600. SwitchBooleanAction.prototype.execute = function () {
  1601. this._effectiveTarget[this._property] = !this._effectiveTarget[this._property];
  1602. };
  1603. /**
  1604. * Serializes the actions and its related information.
  1605. * @param parent defines the object to serialize in
  1606. * @returns the serialized object
  1607. */
  1608. SwitchBooleanAction.prototype.serialize = function (parent) {
  1609. return _super.prototype._serialize.call(this, {
  1610. name: "SwitchBooleanAction",
  1611. properties: [
  1612. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1613. { name: "propertyPath", value: this.propertyPath }
  1614. ]
  1615. }, parent);
  1616. };
  1617. return SwitchBooleanAction;
  1618. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1619. /**
  1620. * This defines an action responsible to set a the state field of the target
  1621. * to a desired value once triggered.
  1622. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1623. */
  1624. var SetStateAction = /** @class */ (function (_super) {
  1625. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetStateAction, _super);
  1626. /**
  1627. * Instantiate the action
  1628. * @param triggerOptions defines the trigger options
  1629. * @param target defines the object containing the state property
  1630. * @param value defines the value to store in the state field
  1631. * @param condition defines the trigger related conditions
  1632. */
  1633. function SetStateAction(triggerOptions, target, value, condition) {
  1634. var _this = _super.call(this, triggerOptions, condition) || this;
  1635. _this.value = value;
  1636. _this._target = target;
  1637. return _this;
  1638. }
  1639. /**
  1640. * Execute the action and store the value on the target state property.
  1641. */
  1642. SetStateAction.prototype.execute = function () {
  1643. this._target.state = this.value;
  1644. };
  1645. /**
  1646. * Serializes the actions and its related information.
  1647. * @param parent defines the object to serialize in
  1648. * @returns the serialized object
  1649. */
  1650. SetStateAction.prototype.serialize = function (parent) {
  1651. return _super.prototype._serialize.call(this, {
  1652. name: "SetStateAction",
  1653. properties: [
  1654. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1655. { name: "value", value: this.value }
  1656. ]
  1657. }, parent);
  1658. };
  1659. return SetStateAction;
  1660. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1661. /**
  1662. * This defines an action responsible to set a property of the target
  1663. * to a desired value once triggered.
  1664. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1665. */
  1666. var SetValueAction = /** @class */ (function (_super) {
  1667. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetValueAction, _super);
  1668. /**
  1669. * Instantiate the action
  1670. * @param triggerOptions defines the trigger options
  1671. * @param target defines the object containing the property
  1672. * @param propertyPath defines the path of the property to set in the target
  1673. * @param value defines the value to set in the property
  1674. * @param condition defines the trigger related conditions
  1675. */
  1676. function SetValueAction(triggerOptions, target, propertyPath, value, condition) {
  1677. var _this = _super.call(this, triggerOptions, condition) || this;
  1678. _this.propertyPath = propertyPath;
  1679. _this.value = value;
  1680. _this._target = _this._effectiveTarget = target;
  1681. return _this;
  1682. }
  1683. /** @hidden */
  1684. SetValueAction.prototype._prepare = function () {
  1685. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1686. this._property = this._getProperty(this.propertyPath);
  1687. };
  1688. /**
  1689. * Execute the action and set the targetted property to the desired value.
  1690. */
  1691. SetValueAction.prototype.execute = function () {
  1692. this._effectiveTarget[this._property] = this.value;
  1693. if (this._target.markAsDirty) {
  1694. this._target.markAsDirty(this._property);
  1695. }
  1696. };
  1697. /**
  1698. * Serializes the actions and its related information.
  1699. * @param parent defines the object to serialize in
  1700. * @returns the serialized object
  1701. */
  1702. SetValueAction.prototype.serialize = function (parent) {
  1703. return _super.prototype._serialize.call(this, {
  1704. name: "SetValueAction",
  1705. properties: [
  1706. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1707. { name: "propertyPath", value: this.propertyPath },
  1708. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1709. ]
  1710. }, parent);
  1711. };
  1712. return SetValueAction;
  1713. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1714. /**
  1715. * This defines an action responsible to increment the target value
  1716. * to a desired value once triggered.
  1717. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1718. */
  1719. var IncrementValueAction = /** @class */ (function (_super) {
  1720. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IncrementValueAction, _super);
  1721. /**
  1722. * Instantiate the action
  1723. * @param triggerOptions defines the trigger options
  1724. * @param target defines the object containing the property
  1725. * @param propertyPath defines the path of the property to increment in the target
  1726. * @param value defines the value value we should increment the property by
  1727. * @param condition defines the trigger related conditions
  1728. */
  1729. function IncrementValueAction(triggerOptions, target, propertyPath, value, condition) {
  1730. var _this = _super.call(this, triggerOptions, condition) || this;
  1731. _this.propertyPath = propertyPath;
  1732. _this.value = value;
  1733. _this._target = _this._effectiveTarget = target;
  1734. return _this;
  1735. }
  1736. /** @hidden */
  1737. IncrementValueAction.prototype._prepare = function () {
  1738. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  1739. this._property = this._getProperty(this.propertyPath);
  1740. if (typeof this._effectiveTarget[this._property] !== "number") {
  1741. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Warning: IncrementValueAction can only be used with number values");
  1742. }
  1743. };
  1744. /**
  1745. * Execute the action and increment the target of the value amount.
  1746. */
  1747. IncrementValueAction.prototype.execute = function () {
  1748. this._effectiveTarget[this._property] += this.value;
  1749. if (this._target.markAsDirty) {
  1750. this._target.markAsDirty(this._property);
  1751. }
  1752. };
  1753. /**
  1754. * Serializes the actions and its related information.
  1755. * @param parent defines the object to serialize in
  1756. * @returns the serialized object
  1757. */
  1758. IncrementValueAction.prototype.serialize = function (parent) {
  1759. return _super.prototype._serialize.call(this, {
  1760. name: "IncrementValueAction",
  1761. properties: [
  1762. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1763. { name: "propertyPath", value: this.propertyPath },
  1764. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.value) }
  1765. ]
  1766. }, parent);
  1767. };
  1768. return IncrementValueAction;
  1769. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1770. /**
  1771. * This defines an action responsible to start an animation once triggered.
  1772. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1773. */
  1774. var PlayAnimationAction = /** @class */ (function (_super) {
  1775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlayAnimationAction, _super);
  1776. /**
  1777. * Instantiate the action
  1778. * @param triggerOptions defines the trigger options
  1779. * @param target defines the target animation or animation name
  1780. * @param from defines from where the animation should start (animation frame)
  1781. * @param end defines where the animation should stop (animation frame)
  1782. * @param loop defines if the animation should loop or stop after the first play
  1783. * @param condition defines the trigger related conditions
  1784. */
  1785. function PlayAnimationAction(triggerOptions, target, from, to, loop, condition) {
  1786. var _this = _super.call(this, triggerOptions, condition) || this;
  1787. _this.from = from;
  1788. _this.to = to;
  1789. _this.loop = loop;
  1790. _this._target = target;
  1791. return _this;
  1792. }
  1793. /** @hidden */
  1794. PlayAnimationAction.prototype._prepare = function () {
  1795. };
  1796. /**
  1797. * Execute the action and play the animation.
  1798. */
  1799. PlayAnimationAction.prototype.execute = function () {
  1800. var scene = this._actionManager.getScene();
  1801. scene.beginAnimation(this._target, this.from, this.to, this.loop);
  1802. };
  1803. /**
  1804. * Serializes the actions and its related information.
  1805. * @param parent defines the object to serialize in
  1806. * @returns the serialized object
  1807. */
  1808. PlayAnimationAction.prototype.serialize = function (parent) {
  1809. return _super.prototype._serialize.call(this, {
  1810. name: "PlayAnimationAction",
  1811. properties: [
  1812. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  1813. { name: "from", value: String(this.from) },
  1814. { name: "to", value: String(this.to) },
  1815. { name: "loop", value: _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._SerializeValueAsString(this.loop) || false }
  1816. ]
  1817. }, parent);
  1818. };
  1819. return PlayAnimationAction;
  1820. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1821. /**
  1822. * This defines an action responsible to stop an animation once triggered.
  1823. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1824. */
  1825. var StopAnimationAction = /** @class */ (function (_super) {
  1826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopAnimationAction, _super);
  1827. /**
  1828. * Instantiate the action
  1829. * @param triggerOptions defines the trigger options
  1830. * @param target defines the target animation or animation name
  1831. * @param condition defines the trigger related conditions
  1832. */
  1833. function StopAnimationAction(triggerOptions, target, condition) {
  1834. var _this = _super.call(this, triggerOptions, condition) || this;
  1835. _this._target = target;
  1836. return _this;
  1837. }
  1838. /** @hidden */
  1839. StopAnimationAction.prototype._prepare = function () {
  1840. };
  1841. /**
  1842. * Execute the action and stop the animation.
  1843. */
  1844. StopAnimationAction.prototype.execute = function () {
  1845. var scene = this._actionManager.getScene();
  1846. scene.stopAnimation(this._target);
  1847. };
  1848. /**
  1849. * Serializes the actions and its related information.
  1850. * @param parent defines the object to serialize in
  1851. * @returns the serialized object
  1852. */
  1853. StopAnimationAction.prototype.serialize = function (parent) {
  1854. return _super.prototype._serialize.call(this, {
  1855. name: "StopAnimationAction",
  1856. properties: [_action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target)]
  1857. }, parent);
  1858. };
  1859. return StopAnimationAction;
  1860. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1861. /**
  1862. * This defines an action responsible that does nothing once triggered.
  1863. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1864. */
  1865. var DoNothingAction = /** @class */ (function (_super) {
  1866. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DoNothingAction, _super);
  1867. /**
  1868. * Instantiate the action
  1869. * @param triggerOptions defines the trigger options
  1870. * @param condition defines the trigger related conditions
  1871. */
  1872. function DoNothingAction(triggerOptions, condition) {
  1873. if (triggerOptions === void 0) { triggerOptions = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ACTION_NothingTrigger; }
  1874. return _super.call(this, triggerOptions, condition) || this;
  1875. }
  1876. /**
  1877. * Execute the action and do nothing.
  1878. */
  1879. DoNothingAction.prototype.execute = function () {
  1880. };
  1881. /**
  1882. * Serializes the actions and its related information.
  1883. * @param parent defines the object to serialize in
  1884. * @returns the serialized object
  1885. */
  1886. DoNothingAction.prototype.serialize = function (parent) {
  1887. return _super.prototype._serialize.call(this, {
  1888. name: "DoNothingAction",
  1889. properties: []
  1890. }, parent);
  1891. };
  1892. return DoNothingAction;
  1893. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1894. /**
  1895. * This defines an action responsible to trigger several actions once triggered.
  1896. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1897. */
  1898. var CombineAction = /** @class */ (function (_super) {
  1899. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CombineAction, _super);
  1900. /**
  1901. * Instantiate the action
  1902. * @param triggerOptions defines the trigger options
  1903. * @param children defines the list of aggregated animations to run
  1904. * @param condition defines the trigger related conditions
  1905. */
  1906. function CombineAction(triggerOptions, children, condition) {
  1907. var _this = _super.call(this, triggerOptions, condition) || this;
  1908. _this.children = children;
  1909. return _this;
  1910. }
  1911. /** @hidden */
  1912. CombineAction.prototype._prepare = function () {
  1913. for (var index = 0; index < this.children.length; index++) {
  1914. this.children[index]._actionManager = this._actionManager;
  1915. this.children[index]._prepare();
  1916. }
  1917. };
  1918. /**
  1919. * Execute the action and executes all the aggregated actions.
  1920. */
  1921. CombineAction.prototype.execute = function (evt) {
  1922. for (var index = 0; index < this.children.length; index++) {
  1923. this.children[index].execute(evt);
  1924. }
  1925. };
  1926. /**
  1927. * Serializes the actions and its related information.
  1928. * @param parent defines the object to serialize in
  1929. * @returns the serialized object
  1930. */
  1931. CombineAction.prototype.serialize = function (parent) {
  1932. var serializationObject = _super.prototype._serialize.call(this, {
  1933. name: "CombineAction",
  1934. properties: [],
  1935. combine: []
  1936. }, parent);
  1937. for (var i = 0; i < this.children.length; i++) {
  1938. serializationObject.combine.push(this.children[i].serialize(null));
  1939. }
  1940. return serializationObject;
  1941. };
  1942. return CombineAction;
  1943. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1944. /**
  1945. * This defines an action responsible to run code (external event) once triggered.
  1946. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1947. */
  1948. var ExecuteCodeAction = /** @class */ (function (_super) {
  1949. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExecuteCodeAction, _super);
  1950. /**
  1951. * Instantiate the action
  1952. * @param triggerOptions defines the trigger options
  1953. * @param func defines the callback function to run
  1954. * @param condition defines the trigger related conditions
  1955. */
  1956. function ExecuteCodeAction(triggerOptions, func, condition) {
  1957. var _this = _super.call(this, triggerOptions, condition) || this;
  1958. _this.func = func;
  1959. return _this;
  1960. }
  1961. /**
  1962. * Execute the action and run the attached code.
  1963. */
  1964. ExecuteCodeAction.prototype.execute = function (evt) {
  1965. this.func(evt);
  1966. };
  1967. return ExecuteCodeAction;
  1968. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  1969. /**
  1970. * This defines an action responsible to set the parent property of the target once triggered.
  1971. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  1972. */
  1973. var SetParentAction = /** @class */ (function (_super) {
  1974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SetParentAction, _super);
  1975. /**
  1976. * Instantiate the action
  1977. * @param triggerOptions defines the trigger options
  1978. * @param target defines the target containing the parent property
  1979. * @param parent defines from where the animation should start (animation frame)
  1980. * @param condition defines the trigger related conditions
  1981. */
  1982. function SetParentAction(triggerOptions, target, parent, condition) {
  1983. var _this = _super.call(this, triggerOptions, condition) || this;
  1984. _this._target = target;
  1985. _this._parent = parent;
  1986. return _this;
  1987. }
  1988. /** @hidden */
  1989. SetParentAction.prototype._prepare = function () {
  1990. };
  1991. /**
  1992. * Execute the action and set the parent property.
  1993. */
  1994. SetParentAction.prototype.execute = function () {
  1995. if (this._target.parent === this._parent) {
  1996. return;
  1997. }
  1998. var invertParentWorldMatrix = this._parent.getWorldMatrix().clone();
  1999. invertParentWorldMatrix.invert();
  2000. this._target.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this._target.position, invertParentWorldMatrix);
  2001. this._target.parent = this._parent;
  2002. };
  2003. /**
  2004. * Serializes the actions and its related information.
  2005. * @param parent defines the object to serialize in
  2006. * @returns the serialized object
  2007. */
  2008. SetParentAction.prototype.serialize = function (parent) {
  2009. return _super.prototype._serialize.call(this, {
  2010. name: "SetParentAction",
  2011. properties: [
  2012. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._target),
  2013. _action__WEBPACK_IMPORTED_MODULE_3__["Action"]._GetTargetProperty(this._parent),
  2014. ]
  2015. }, parent);
  2016. };
  2017. return SetParentAction;
  2018. }(_action__WEBPACK_IMPORTED_MODULE_3__["Action"]));
  2019. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2020. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.ExecuteCodeAction"] = ExecuteCodeAction;
  2021. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.DoNothingAction"] = DoNothingAction;
  2022. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.StopAnimationAction"] = StopAnimationAction;
  2023. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PlayAnimationAction"] = PlayAnimationAction;
  2024. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.IncrementValueAction"] = IncrementValueAction;
  2025. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetValueAction"] = SetValueAction;
  2026. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetStateAction"] = SetStateAction;
  2027. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.SetParentAction"] = SetParentAction;
  2028. /***/ }),
  2029. /***/ "./Actions/directAudioActions.ts":
  2030. /*!***************************************!*\
  2031. !*** ./Actions/directAudioActions.ts ***!
  2032. \***************************************/
  2033. /*! exports provided: PlaySoundAction, StopSoundAction */
  2034. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2035. "use strict";
  2036. __webpack_require__.r(__webpack_exports__);
  2037. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return PlaySoundAction; });
  2038. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return StopSoundAction; });
  2039. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2040. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2041. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2042. /**
  2043. * This defines an action helpful to play a defined sound on a triggered action.
  2044. */
  2045. var PlaySoundAction = /** @class */ (function (_super) {
  2046. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaySoundAction, _super);
  2047. /**
  2048. * Instantiate the action
  2049. * @param triggerOptions defines the trigger options
  2050. * @param sound defines the sound to play
  2051. * @param condition defines the trigger related conditions
  2052. */
  2053. function PlaySoundAction(triggerOptions, sound, condition) {
  2054. var _this = _super.call(this, triggerOptions, condition) || this;
  2055. _this._sound = sound;
  2056. return _this;
  2057. }
  2058. /** @hidden */
  2059. PlaySoundAction.prototype._prepare = function () {
  2060. };
  2061. /**
  2062. * Execute the action and play the sound.
  2063. */
  2064. PlaySoundAction.prototype.execute = function () {
  2065. if (this._sound !== undefined) {
  2066. this._sound.play();
  2067. }
  2068. };
  2069. /**
  2070. * Serializes the actions and its related information.
  2071. * @param parent defines the object to serialize in
  2072. * @returns the serialized object
  2073. */
  2074. PlaySoundAction.prototype.serialize = function (parent) {
  2075. return _super.prototype._serialize.call(this, {
  2076. name: "PlaySoundAction",
  2077. properties: [{ name: "sound", value: this._sound.name }]
  2078. }, parent);
  2079. };
  2080. return PlaySoundAction;
  2081. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2082. /**
  2083. * This defines an action helpful to stop a defined sound on a triggered action.
  2084. */
  2085. var StopSoundAction = /** @class */ (function (_super) {
  2086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StopSoundAction, _super);
  2087. /**
  2088. * Instantiate the action
  2089. * @param triggerOptions defines the trigger options
  2090. * @param sound defines the sound to stop
  2091. * @param condition defines the trigger related conditions
  2092. */
  2093. function StopSoundAction(triggerOptions, sound, condition) {
  2094. var _this = _super.call(this, triggerOptions, condition) || this;
  2095. _this._sound = sound;
  2096. return _this;
  2097. }
  2098. /** @hidden */
  2099. StopSoundAction.prototype._prepare = function () {
  2100. };
  2101. /**
  2102. * Execute the action and stop the sound.
  2103. */
  2104. StopSoundAction.prototype.execute = function () {
  2105. if (this._sound !== undefined) {
  2106. this._sound.stop();
  2107. }
  2108. };
  2109. /**
  2110. * Serializes the actions and its related information.
  2111. * @param parent defines the object to serialize in
  2112. * @returns the serialized object
  2113. */
  2114. StopSoundAction.prototype.serialize = function (parent) {
  2115. return _super.prototype._serialize.call(this, {
  2116. name: "StopSoundAction",
  2117. properties: [{ name: "sound", value: this._sound.name }]
  2118. }, parent);
  2119. };
  2120. return StopSoundAction;
  2121. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2122. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.PlaySoundAction"] = StopSoundAction;
  2123. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_2__["_TypeStore"].RegisteredTypes["BABYLON.StopSoundAction"] = StopSoundAction;
  2124. /***/ }),
  2125. /***/ "./Actions/index.ts":
  2126. /*!**************************!*\
  2127. !*** ./Actions/index.ts ***!
  2128. \**************************/
  2129. /*! exports provided: Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction */
  2130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2131. "use strict";
  2132. __webpack_require__.r(__webpack_exports__);
  2133. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2134. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _action__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  2135. /* harmony import */ var _actionEvent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./actionEvent */ "./Actions/actionEvent.ts");
  2136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _actionEvent__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  2137. /* harmony import */ var _actionManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./actionManager */ "./Actions/actionManager.ts");
  2138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _actionManager__WEBPACK_IMPORTED_MODULE_2__["ActionManager"]; });
  2139. /* harmony import */ var _condition__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./condition */ "./Actions/condition.ts");
  2140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["Condition"]; });
  2141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["ValueCondition"]; });
  2142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["PredicateCondition"]; });
  2143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _condition__WEBPACK_IMPORTED_MODULE_3__["StateCondition"]; });
  2144. /* harmony import */ var _directActions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./directActions */ "./Actions/directActions.ts");
  2145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SwitchBooleanAction"]; });
  2146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetStateAction"]; });
  2147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetValueAction"]; });
  2148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["IncrementValueAction"]; });
  2149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["PlayAnimationAction"]; });
  2150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["StopAnimationAction"]; });
  2151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["DoNothingAction"]; });
  2152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["CombineAction"]; });
  2153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["ExecuteCodeAction"]; });
  2154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _directActions__WEBPACK_IMPORTED_MODULE_4__["SetParentAction"]; });
  2155. /* harmony import */ var _directAudioActions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./directAudioActions */ "./Actions/directAudioActions.ts");
  2156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["PlaySoundAction"]; });
  2157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _directAudioActions__WEBPACK_IMPORTED_MODULE_5__["StopSoundAction"]; });
  2158. /* harmony import */ var _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./interpolateValueAction */ "./Actions/interpolateValueAction.ts");
  2159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _interpolateValueAction__WEBPACK_IMPORTED_MODULE_6__["InterpolateValueAction"]; });
  2160. /***/ }),
  2161. /***/ "./Actions/interpolateValueAction.ts":
  2162. /*!*******************************************!*\
  2163. !*** ./Actions/interpolateValueAction.ts ***!
  2164. \*******************************************/
  2165. /*! exports provided: InterpolateValueAction */
  2166. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2167. "use strict";
  2168. __webpack_require__.r(__webpack_exports__);
  2169. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return InterpolateValueAction; });
  2170. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  2171. /* harmony import */ var _action__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./action */ "./Actions/action.ts");
  2172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  2173. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2174. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2175. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  2176. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  2177. /**
  2178. * This defines an action responsible to change the value of a property
  2179. * by interpolating between its current value and the newly set one once triggered.
  2180. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  2181. */
  2182. var InterpolateValueAction = /** @class */ (function (_super) {
  2183. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InterpolateValueAction, _super);
  2184. /**
  2185. * Instantiate the action
  2186. * @param triggerOptions defines the trigger options
  2187. * @param target defines the object containing the value to interpolate
  2188. * @param propertyPath defines the path to the property in the target object
  2189. * @param value defines the target value at the end of the interpolation
  2190. * @param duration deines the time it will take for the property to interpolate to the value.
  2191. * @param condition defines the trigger related conditions
  2192. * @param stopOtherAnimations defines if the other scene animations should be stopped when the action has been triggered
  2193. * @param onInterpolationDone defines a callback raised once the interpolation animation has been done
  2194. */
  2195. function InterpolateValueAction(triggerOptions, target, propertyPath, value, duration, condition, stopOtherAnimations, onInterpolationDone) {
  2196. if (duration === void 0) { duration = 1000; }
  2197. var _this = _super.call(this, triggerOptions, condition) || this;
  2198. /**
  2199. * Defines the time it will take for the property to interpolate to the value.
  2200. */
  2201. _this.duration = 1000;
  2202. /**
  2203. * Observable triggered once the interpolation animation has been done.
  2204. */
  2205. _this.onInterpolationDoneObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  2206. _this.propertyPath = propertyPath;
  2207. _this.value = value;
  2208. _this.duration = duration;
  2209. _this.stopOtherAnimations = stopOtherAnimations;
  2210. _this.onInterpolationDone = onInterpolationDone;
  2211. _this._target = _this._effectiveTarget = target;
  2212. return _this;
  2213. }
  2214. /** @hidden */
  2215. InterpolateValueAction.prototype._prepare = function () {
  2216. this._effectiveTarget = this._getEffectiveTarget(this._effectiveTarget, this.propertyPath);
  2217. this._property = this._getProperty(this.propertyPath);
  2218. };
  2219. /**
  2220. * Execute the action starts the value interpolation.
  2221. */
  2222. InterpolateValueAction.prototype.execute = function () {
  2223. var _this = this;
  2224. var scene = this._actionManager.getScene();
  2225. var keys = [
  2226. {
  2227. frame: 0,
  2228. value: this._effectiveTarget[this._property]
  2229. }, {
  2230. frame: 100,
  2231. value: this.value
  2232. }
  2233. ];
  2234. var dataType;
  2235. if (typeof this.value === "number") {
  2236. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT;
  2237. }
  2238. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"]) {
  2239. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_COLOR3;
  2240. }
  2241. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"]) {
  2242. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3;
  2243. }
  2244. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]) {
  2245. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_MATRIX;
  2246. }
  2247. else if (this.value instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]) {
  2248. dataType = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_QUATERNION;
  2249. }
  2250. else {
  2251. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("InterpolateValueAction: Unsupported type (" + typeof this.value + ")");
  2252. return;
  2253. }
  2254. var animation = new _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"]("InterpolateValueAction", this._property, 100 * (1000.0 / this.duration), dataType, _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONLOOPMODE_CONSTANT);
  2255. animation.setKeys(keys);
  2256. if (this.stopOtherAnimations) {
  2257. scene.stopAnimation(this._effectiveTarget);
  2258. }
  2259. var wrapper = function () {
  2260. _this.onInterpolationDoneObservable.notifyObservers(_this);
  2261. if (_this.onInterpolationDone) {
  2262. _this.onInterpolationDone();
  2263. }
  2264. };
  2265. scene.beginDirectAnimation(this._effectiveTarget, [animation], 0, 100, false, 1, wrapper);
  2266. };
  2267. /**
  2268. * Serializes the actions and its related information.
  2269. * @param parent defines the object to serialize in
  2270. * @returns the serialized object
  2271. */
  2272. InterpolateValueAction.prototype.serialize = function (parent) {
  2273. return _super.prototype._serialize.call(this, {
  2274. name: "InterpolateValueAction",
  2275. properties: [
  2276. _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._GetTargetProperty(this._target),
  2277. { name: "propertyPath", value: this.propertyPath },
  2278. { name: "value", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.value) },
  2279. { name: "duration", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.duration) },
  2280. { name: "stopOtherAnimations", value: _action__WEBPACK_IMPORTED_MODULE_1__["Action"]._SerializeValueAsString(this.stopOtherAnimations) || false }
  2281. ]
  2282. }, parent);
  2283. };
  2284. return InterpolateValueAction;
  2285. }(_action__WEBPACK_IMPORTED_MODULE_1__["Action"]));
  2286. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_6__["_TypeStore"].RegisteredTypes["BABYLON.InterpolateValueAction"] = _action__WEBPACK_IMPORTED_MODULE_1__["Action"];
  2287. /***/ }),
  2288. /***/ "./Animations/animatable.ts":
  2289. /*!**********************************!*\
  2290. !*** ./Animations/animatable.ts ***!
  2291. \**********************************/
  2292. /*! exports provided: Animatable */
  2293. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  2294. "use strict";
  2295. __webpack_require__.r(__webpack_exports__);
  2296. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return Animatable; });
  2297. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  2298. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  2299. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  2300. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  2301. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  2302. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/precisionDate */ "./Misc/precisionDate.ts");
  2303. /* harmony import */ var _Bones_bone__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Bones/bone */ "./Bones/bone.ts");
  2304. /**
  2305. * Class used to store an actual running animation
  2306. */
  2307. var Animatable = /** @class */ (function () {
  2308. /**
  2309. * Creates a new Animatable
  2310. * @param scene defines the hosting scene
  2311. * @param target defines the target object
  2312. * @param fromFrame defines the starting frame number (default is 0)
  2313. * @param toFrame defines the ending frame number (default is 100)
  2314. * @param loopAnimation defines if the animation must loop (default is false)
  2315. * @param speedRatio defines the factor to apply to animation speed (default is 1)
  2316. * @param onAnimationEnd defines a callback to call when animation ends if it is not looping
  2317. * @param animations defines a group of animation to add to the new Animatable
  2318. * @param onAnimationLoop defines a callback to call when animation loops
  2319. */
  2320. function Animatable(scene,
  2321. /** defines the target object */
  2322. target,
  2323. /** defines the starting frame number (default is 0) */
  2324. fromFrame,
  2325. /** defines the ending frame number (default is 100) */
  2326. toFrame,
  2327. /** defines if the animation must loop (default is false) */
  2328. loopAnimation, speedRatio,
  2329. /** defines a callback to call when animation ends if it is not looping */
  2330. onAnimationEnd, animations,
  2331. /** defines a callback to call when animation loops */
  2332. onAnimationLoop) {
  2333. if (fromFrame === void 0) { fromFrame = 0; }
  2334. if (toFrame === void 0) { toFrame = 100; }
  2335. if (loopAnimation === void 0) { loopAnimation = false; }
  2336. if (speedRatio === void 0) { speedRatio = 1.0; }
  2337. this.target = target;
  2338. this.fromFrame = fromFrame;
  2339. this.toFrame = toFrame;
  2340. this.loopAnimation = loopAnimation;
  2341. this.onAnimationEnd = onAnimationEnd;
  2342. this.onAnimationLoop = onAnimationLoop;
  2343. this._localDelayOffset = null;
  2344. this._pausedDelay = null;
  2345. this._runtimeAnimations = new Array();
  2346. this._paused = false;
  2347. this._speedRatio = 1;
  2348. this._weight = -1.0;
  2349. /**
  2350. * Gets or sets a boolean indicating if the animatable must be disposed and removed at the end of the animation.
  2351. * This will only apply for non looping animation (default is true)
  2352. */
  2353. this.disposeOnEnd = true;
  2354. /**
  2355. * Gets a boolean indicating if the animation has started
  2356. */
  2357. this.animationStarted = false;
  2358. /**
  2359. * Observer raised when the animation ends
  2360. */
  2361. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2362. /**
  2363. * Observer raised when the animation loops
  2364. */
  2365. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  2366. this._scene = scene;
  2367. if (animations) {
  2368. this.appendAnimations(target, animations);
  2369. }
  2370. this._speedRatio = speedRatio;
  2371. scene._activeAnimatables.push(this);
  2372. }
  2373. Object.defineProperty(Animatable.prototype, "syncRoot", {
  2374. /**
  2375. * Gets the root Animatable used to synchronize and normalize animations
  2376. */
  2377. get: function () {
  2378. return this._syncRoot;
  2379. },
  2380. enumerable: true,
  2381. configurable: true
  2382. });
  2383. Object.defineProperty(Animatable.prototype, "masterFrame", {
  2384. /**
  2385. * Gets the current frame of the first RuntimeAnimation
  2386. * Used to synchronize Animatables
  2387. */
  2388. get: function () {
  2389. if (this._runtimeAnimations.length === 0) {
  2390. return 0;
  2391. }
  2392. return this._runtimeAnimations[0].currentFrame;
  2393. },
  2394. enumerable: true,
  2395. configurable: true
  2396. });
  2397. Object.defineProperty(Animatable.prototype, "weight", {
  2398. /**
  2399. * Gets or sets the animatable weight (-1.0 by default meaning not weighted)
  2400. */
  2401. get: function () {
  2402. return this._weight;
  2403. },
  2404. set: function (value) {
  2405. if (value === -1) { // -1 is ok and means no weight
  2406. this._weight = -1;
  2407. return;
  2408. }
  2409. // Else weight must be in [0, 1] range
  2410. this._weight = Math.min(Math.max(value, 0), 1.0);
  2411. },
  2412. enumerable: true,
  2413. configurable: true
  2414. });
  2415. Object.defineProperty(Animatable.prototype, "speedRatio", {
  2416. /**
  2417. * Gets or sets the speed ratio to apply to the animatable (1.0 by default)
  2418. */
  2419. get: function () {
  2420. return this._speedRatio;
  2421. },
  2422. set: function (value) {
  2423. for (var index = 0; index < this._runtimeAnimations.length; index++) {
  2424. var animation = this._runtimeAnimations[index];
  2425. animation._prepareForSpeedRatioChange(value);
  2426. }
  2427. this._speedRatio = value;
  2428. },
  2429. enumerable: true,
  2430. configurable: true
  2431. });
  2432. // Methods
  2433. /**
  2434. * Synchronize and normalize current Animatable with a source Animatable
  2435. * This is useful when using animation weights and when animations are not of the same length
  2436. * @param root defines the root Animatable to synchronize with
  2437. * @returns the current Animatable
  2438. */
  2439. Animatable.prototype.syncWith = function (root) {
  2440. this._syncRoot = root;
  2441. if (root) {
  2442. // Make sure this animatable will animate after the root
  2443. var index = this._scene._activeAnimatables.indexOf(this);
  2444. if (index > -1) {
  2445. this._scene._activeAnimatables.splice(index, 1);
  2446. this._scene._activeAnimatables.push(this);
  2447. }
  2448. }
  2449. return this;
  2450. };
  2451. /**
  2452. * Gets the list of runtime animations
  2453. * @returns an array of RuntimeAnimation
  2454. */
  2455. Animatable.prototype.getAnimations = function () {
  2456. return this._runtimeAnimations;
  2457. };
  2458. /**
  2459. * Adds more animations to the current animatable
  2460. * @param target defines the target of the animations
  2461. * @param animations defines the new animations to add
  2462. */
  2463. Animatable.prototype.appendAnimations = function (target, animations) {
  2464. for (var index = 0; index < animations.length; index++) {
  2465. var animation = animations[index];
  2466. this._runtimeAnimations.push(new _runtimeAnimation__WEBPACK_IMPORTED_MODULE_1__["RuntimeAnimation"](target, animation, this._scene, this));
  2467. }
  2468. };
  2469. /**
  2470. * Gets the source animation for a specific property
  2471. * @param property defines the propertyu to look for
  2472. * @returns null or the source animation for the given property
  2473. */
  2474. Animatable.prototype.getAnimationByTargetProperty = function (property) {
  2475. var runtimeAnimations = this._runtimeAnimations;
  2476. for (var index = 0; index < runtimeAnimations.length; index++) {
  2477. if (runtimeAnimations[index].animation.targetProperty === property) {
  2478. return runtimeAnimations[index].animation;
  2479. }
  2480. }
  2481. return null;
  2482. };
  2483. /**
  2484. * Gets the runtime animation for a specific property
  2485. * @param property defines the propertyu to look for
  2486. * @returns null or the runtime animation for the given property
  2487. */
  2488. Animatable.prototype.getRuntimeAnimationByTargetProperty = function (property) {
  2489. var runtimeAnimations = this._runtimeAnimations;
  2490. for (var index = 0; index < runtimeAnimations.length; index++) {
  2491. if (runtimeAnimations[index].animation.targetProperty === property) {
  2492. return runtimeAnimations[index];
  2493. }
  2494. }
  2495. return null;
  2496. };
  2497. /**
  2498. * Resets the animatable to its original state
  2499. */
  2500. Animatable.prototype.reset = function () {
  2501. var runtimeAnimations = this._runtimeAnimations;
  2502. for (var index = 0; index < runtimeAnimations.length; index++) {
  2503. runtimeAnimations[index].reset(true);
  2504. }
  2505. this._localDelayOffset = null;
  2506. this._pausedDelay = null;
  2507. };
  2508. /**
  2509. * Allows the animatable to blend with current running animations
  2510. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2511. * @param blendingSpeed defines the blending speed to use
  2512. */
  2513. Animatable.prototype.enableBlending = function (blendingSpeed) {
  2514. var runtimeAnimations = this._runtimeAnimations;
  2515. for (var index = 0; index < runtimeAnimations.length; index++) {
  2516. runtimeAnimations[index].animation.enableBlending = true;
  2517. runtimeAnimations[index].animation.blendingSpeed = blendingSpeed;
  2518. }
  2519. };
  2520. /**
  2521. * Disable animation blending
  2522. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  2523. */
  2524. Animatable.prototype.disableBlending = function () {
  2525. var runtimeAnimations = this._runtimeAnimations;
  2526. for (var index = 0; index < runtimeAnimations.length; index++) {
  2527. runtimeAnimations[index].animation.enableBlending = false;
  2528. }
  2529. };
  2530. /**
  2531. * Jump directly to a given frame
  2532. * @param frame defines the frame to jump to
  2533. */
  2534. Animatable.prototype.goToFrame = function (frame) {
  2535. var runtimeAnimations = this._runtimeAnimations;
  2536. if (runtimeAnimations[0]) {
  2537. var fps = runtimeAnimations[0].animation.framePerSecond;
  2538. var currentFrame = runtimeAnimations[0].currentFrame;
  2539. var adjustTime = frame - currentFrame;
  2540. var delay = adjustTime * 1000 / (fps * this.speedRatio);
  2541. if (this._localDelayOffset === null) {
  2542. this._localDelayOffset = 0;
  2543. }
  2544. this._localDelayOffset -= delay;
  2545. }
  2546. for (var index = 0; index < runtimeAnimations.length; index++) {
  2547. runtimeAnimations[index].goToFrame(frame);
  2548. }
  2549. };
  2550. /**
  2551. * Pause the animation
  2552. */
  2553. Animatable.prototype.pause = function () {
  2554. if (this._paused) {
  2555. return;
  2556. }
  2557. this._paused = true;
  2558. };
  2559. /**
  2560. * Restart the animation
  2561. */
  2562. Animatable.prototype.restart = function () {
  2563. this._paused = false;
  2564. };
  2565. Animatable.prototype._raiseOnAnimationEnd = function () {
  2566. if (this.onAnimationEnd) {
  2567. this.onAnimationEnd();
  2568. }
  2569. this.onAnimationEndObservable.notifyObservers(this);
  2570. };
  2571. /**
  2572. * Stop and delete the current animation
  2573. * @param animationName defines a string used to only stop some of the runtime animations instead of all
  2574. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2575. */
  2576. Animatable.prototype.stop = function (animationName, targetMask) {
  2577. if (animationName || targetMask) {
  2578. var idx = this._scene._activeAnimatables.indexOf(this);
  2579. if (idx > -1) {
  2580. var runtimeAnimations = this._runtimeAnimations;
  2581. for (var index = runtimeAnimations.length - 1; index >= 0; index--) {
  2582. var runtimeAnimation = runtimeAnimations[index];
  2583. if (animationName && runtimeAnimation.animation.name != animationName) {
  2584. continue;
  2585. }
  2586. if (targetMask && !targetMask(runtimeAnimation.target)) {
  2587. continue;
  2588. }
  2589. runtimeAnimation.dispose();
  2590. runtimeAnimations.splice(index, 1);
  2591. }
  2592. if (runtimeAnimations.length == 0) {
  2593. this._scene._activeAnimatables.splice(idx, 1);
  2594. this._raiseOnAnimationEnd();
  2595. }
  2596. }
  2597. }
  2598. else {
  2599. var index = this._scene._activeAnimatables.indexOf(this);
  2600. if (index > -1) {
  2601. this._scene._activeAnimatables.splice(index, 1);
  2602. var runtimeAnimations = this._runtimeAnimations;
  2603. for (var index = 0; index < runtimeAnimations.length; index++) {
  2604. runtimeAnimations[index].dispose();
  2605. }
  2606. this._raiseOnAnimationEnd();
  2607. }
  2608. }
  2609. };
  2610. /**
  2611. * Wait asynchronously for the animation to end
  2612. * @returns a promise which will be fullfilled when the animation ends
  2613. */
  2614. Animatable.prototype.waitAsync = function () {
  2615. var _this = this;
  2616. return new Promise(function (resolve, reject) {
  2617. _this.onAnimationEndObservable.add(function () {
  2618. resolve(_this);
  2619. }, undefined, undefined, _this, true);
  2620. });
  2621. };
  2622. /** @hidden */
  2623. Animatable.prototype._animate = function (delay) {
  2624. var _this = this;
  2625. if (this._paused) {
  2626. this.animationStarted = false;
  2627. if (this._pausedDelay === null) {
  2628. this._pausedDelay = delay;
  2629. }
  2630. return true;
  2631. }
  2632. if (this._localDelayOffset === null) {
  2633. this._localDelayOffset = delay;
  2634. this._pausedDelay = null;
  2635. }
  2636. else if (this._pausedDelay !== null) {
  2637. this._localDelayOffset += delay - this._pausedDelay;
  2638. this._pausedDelay = null;
  2639. }
  2640. if (this._weight === 0) { // We consider that an animation with a weight === 0 is "actively" paused
  2641. return true;
  2642. }
  2643. // Animating
  2644. var running = false;
  2645. var runtimeAnimations = this._runtimeAnimations;
  2646. var index;
  2647. for (index = 0; index < runtimeAnimations.length; index++) {
  2648. var animation = runtimeAnimations[index];
  2649. var isRunning = animation.animate(delay - this._localDelayOffset, this.fromFrame, this.toFrame, this.loopAnimation, this._speedRatio, this._weight, function () {
  2650. _this.onAnimationLoopObservable.notifyObservers(_this);
  2651. if (_this.onAnimationLoop) {
  2652. _this.onAnimationLoop();
  2653. }
  2654. });
  2655. running = running || isRunning;
  2656. }
  2657. this.animationStarted = running;
  2658. if (!running) {
  2659. if (this.disposeOnEnd) {
  2660. // Remove from active animatables
  2661. index = this._scene._activeAnimatables.indexOf(this);
  2662. this._scene._activeAnimatables.splice(index, 1);
  2663. // Dispose all runtime animations
  2664. for (index = 0; index < runtimeAnimations.length; index++) {
  2665. runtimeAnimations[index].dispose();
  2666. }
  2667. }
  2668. this._raiseOnAnimationEnd();
  2669. if (this.disposeOnEnd) {
  2670. this.onAnimationEnd = null;
  2671. this.onAnimationLoop = null;
  2672. this.onAnimationLoopObservable.clear();
  2673. this.onAnimationEndObservable.clear();
  2674. }
  2675. }
  2676. return running;
  2677. };
  2678. return Animatable;
  2679. }());
  2680. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._animate = function () {
  2681. if (!this.animationsEnabled || this._activeAnimatables.length === 0) {
  2682. return;
  2683. }
  2684. // Getting time
  2685. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_5__["PrecisionDate"].Now;
  2686. if (!this._animationTimeLast) {
  2687. if (this._pendingData.length > 0) {
  2688. return;
  2689. }
  2690. this._animationTimeLast = now;
  2691. }
  2692. var deltaTime = this.useConstantAnimationDeltaTime ? 16.0 : (now - this._animationTimeLast) * this.animationTimeScale;
  2693. this._animationTime += deltaTime;
  2694. this._animationTimeLast = now;
  2695. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2696. this._activeAnimatables[index]._animate(this._animationTime);
  2697. }
  2698. // Late animation bindings
  2699. this._processLateAnimationBindings();
  2700. };
  2701. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginWeightedAnimation = function (target, from, to, weight, loop, speedRatio, onAnimationEnd, animatable, targetMask, onAnimationLoop) {
  2702. if (weight === void 0) { weight = 1.0; }
  2703. if (speedRatio === void 0) { speedRatio = 1.0; }
  2704. var returnedAnimatable = this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, false, targetMask, onAnimationLoop);
  2705. returnedAnimatable.weight = weight;
  2706. return returnedAnimatable;
  2707. };
  2708. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginAnimation = function (target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2709. if (speedRatio === void 0) { speedRatio = 1.0; }
  2710. if (stopCurrent === void 0) { stopCurrent = true; }
  2711. if (from > to && speedRatio > 0) {
  2712. speedRatio *= -1;
  2713. }
  2714. if (stopCurrent) {
  2715. this.stopAnimation(target, undefined, targetMask);
  2716. }
  2717. if (!animatable) {
  2718. animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, undefined, onAnimationLoop);
  2719. }
  2720. var shouldRunTargetAnimations = targetMask ? targetMask(target) : true;
  2721. // Local animations
  2722. if (target.animations && shouldRunTargetAnimations) {
  2723. animatable.appendAnimations(target, target.animations);
  2724. }
  2725. // Children animations
  2726. if (target.getAnimatables) {
  2727. var animatables = target.getAnimatables();
  2728. for (var index = 0; index < animatables.length; index++) {
  2729. this.beginAnimation(animatables[index], from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop);
  2730. }
  2731. }
  2732. animatable.reset();
  2733. return animatable;
  2734. };
  2735. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginHierarchyAnimation = function (target, directDescendantsOnly, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask, onAnimationLoop) {
  2736. if (speedRatio === void 0) { speedRatio = 1.0; }
  2737. if (stopCurrent === void 0) { stopCurrent = true; }
  2738. var children = target.getDescendants(directDescendantsOnly);
  2739. var result = [];
  2740. result.push(this.beginAnimation(target, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2741. for (var _i = 0, children_1 = children; _i < children_1.length; _i++) {
  2742. var child = children_1[_i];
  2743. result.push(this.beginAnimation(child, from, to, loop, speedRatio, onAnimationEnd, animatable, stopCurrent, targetMask));
  2744. }
  2745. return result;
  2746. };
  2747. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectAnimation = function (target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2748. if (speedRatio === undefined) {
  2749. speedRatio = 1.0;
  2750. }
  2751. var animatable = new Animatable(this, target, from, to, loop, speedRatio, onAnimationEnd, animations, onAnimationLoop);
  2752. return animatable;
  2753. };
  2754. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.beginDirectHierarchyAnimation = function (target, directDescendantsOnly, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop) {
  2755. var children = target.getDescendants(directDescendantsOnly);
  2756. var result = [];
  2757. result.push(this.beginDirectAnimation(target, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2758. for (var _i = 0, children_2 = children; _i < children_2.length; _i++) {
  2759. var child = children_2[_i];
  2760. result.push(this.beginDirectAnimation(child, animations, from, to, loop, speedRatio, onAnimationEnd, onAnimationLoop));
  2761. }
  2762. return result;
  2763. };
  2764. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAnimatableByTarget = function (target) {
  2765. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2766. if (this._activeAnimatables[index].target === target) {
  2767. return this._activeAnimatables[index];
  2768. }
  2769. }
  2770. return null;
  2771. };
  2772. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.getAllAnimatablesByTarget = function (target) {
  2773. var result = [];
  2774. for (var index = 0; index < this._activeAnimatables.length; index++) {
  2775. if (this._activeAnimatables[index].target === target) {
  2776. result.push(this._activeAnimatables[index]);
  2777. }
  2778. }
  2779. return result;
  2780. };
  2781. /**
  2782. * Will stop the animation of the given target
  2783. * @param target - the target
  2784. * @param animationName - the name of the animation to stop (all animations will be stopped if both this and targetMask are empty)
  2785. * @param targetMask - a function that determines if the animation should be stopped based on its target (all animations will be stopped if both this and animationName are empty)
  2786. */
  2787. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAnimation = function (target, animationName, targetMask) {
  2788. var animatables = this.getAllAnimatablesByTarget(target);
  2789. for (var _i = 0, animatables_1 = animatables; _i < animatables_1.length; _i++) {
  2790. var animatable = animatables_1[_i];
  2791. animatable.stop(animationName, targetMask);
  2792. }
  2793. };
  2794. /**
  2795. * Stops and removes all animations that have been applied to the scene
  2796. */
  2797. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype.stopAllAnimations = function () {
  2798. if (this._activeAnimatables) {
  2799. for (var i = 0; i < this._activeAnimatables.length; i++) {
  2800. this._activeAnimatables[i].stop();
  2801. }
  2802. this._activeAnimatables = [];
  2803. }
  2804. for (var _i = 0, _a = this.animationGroups; _i < _a.length; _i++) {
  2805. var group = _a[_i];
  2806. group.stop();
  2807. }
  2808. };
  2809. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._registerTargetForLateAnimationBinding = function (runtimeAnimation, originalValue) {
  2810. var target = runtimeAnimation.target;
  2811. this._registeredForLateAnimationBindings.pushNoDuplicate(target);
  2812. if (!target._lateAnimationHolders) {
  2813. target._lateAnimationHolders = {};
  2814. }
  2815. if (!target._lateAnimationHolders[runtimeAnimation.targetPath]) {
  2816. target._lateAnimationHolders[runtimeAnimation.targetPath] = {
  2817. totalWeight: 0,
  2818. animations: [],
  2819. originalValue: originalValue
  2820. };
  2821. }
  2822. target._lateAnimationHolders[runtimeAnimation.targetPath].animations.push(runtimeAnimation);
  2823. target._lateAnimationHolders[runtimeAnimation.targetPath].totalWeight += runtimeAnimation.weight;
  2824. };
  2825. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForMatrices = function (holder) {
  2826. var normalizer = 1.0;
  2827. var finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  2828. var finalScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  2829. var finalQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[0];
  2830. var startIndex = 0;
  2831. var originalAnimation = holder.animations[0];
  2832. var originalValue = holder.originalValue;
  2833. var scale = 1;
  2834. if (holder.totalWeight < 1.0) {
  2835. // We need to mix the original value in
  2836. originalValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2837. scale = 1.0 - holder.totalWeight;
  2838. }
  2839. else {
  2840. startIndex = 1;
  2841. // We need to normalize the weights
  2842. normalizer = holder.totalWeight;
  2843. originalAnimation.currentValue.decompose(finalScaling, finalQuaternion, finalPosition);
  2844. scale = originalAnimation.weight / normalizer;
  2845. if (scale == 1) {
  2846. return originalAnimation.currentValue;
  2847. }
  2848. }
  2849. finalScaling.scaleInPlace(scale);
  2850. finalPosition.scaleInPlace(scale);
  2851. finalQuaternion.scaleInPlace(scale);
  2852. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2853. var runtimeAnimation = holder.animations[animIndex];
  2854. var scale = runtimeAnimation.weight / normalizer;
  2855. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[2];
  2856. var currentScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[3];
  2857. var currentQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Quaternion[1];
  2858. runtimeAnimation.currentValue.decompose(currentScaling, currentQuaternion, currentPosition);
  2859. currentScaling.scaleAndAddToRef(scale, finalScaling);
  2860. currentQuaternion.scaleAndAddToRef(scale, finalQuaternion);
  2861. currentPosition.scaleAndAddToRef(scale, finalPosition);
  2862. }
  2863. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(finalScaling, finalQuaternion, finalPosition, originalAnimation._workValue);
  2864. return originalAnimation._workValue;
  2865. };
  2866. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindingsForQuaternions = function (holder, refQuaternion) {
  2867. var originalAnimation = holder.animations[0];
  2868. var originalValue = holder.originalValue;
  2869. if (holder.animations.length === 1) {
  2870. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(originalValue, originalAnimation.currentValue, Math.min(1.0, holder.totalWeight), refQuaternion);
  2871. return refQuaternion;
  2872. }
  2873. var normalizer = 1.0;
  2874. var quaternions;
  2875. var weights;
  2876. if (holder.totalWeight < 1.0) {
  2877. var scale = 1.0 - holder.totalWeight;
  2878. quaternions = [];
  2879. weights = [];
  2880. quaternions.push(originalValue);
  2881. weights.push(scale);
  2882. }
  2883. else {
  2884. if (holder.animations.length === 2) { // Slerp as soon as we can
  2885. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(holder.animations[0].currentValue, holder.animations[1].currentValue, holder.animations[1].weight / holder.totalWeight, refQuaternion);
  2886. return refQuaternion;
  2887. }
  2888. quaternions = [];
  2889. weights = [];
  2890. normalizer = holder.totalWeight;
  2891. }
  2892. for (var animIndex = 0; animIndex < holder.animations.length; animIndex++) {
  2893. var runtimeAnimation = holder.animations[animIndex];
  2894. quaternions.push(runtimeAnimation.currentValue);
  2895. weights.push(runtimeAnimation.weight / normalizer);
  2896. }
  2897. // https://gamedev.stackexchange.com/questions/62354/method-for-interpolation-between-3-quaternions
  2898. var cumulativeAmount = 0;
  2899. var cumulativeQuaternion = null;
  2900. for (var index = 0; index < quaternions.length;) {
  2901. if (!cumulativeQuaternion) {
  2902. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(quaternions[index], quaternions[index + 1], weights[index + 1] / (weights[index] + weights[index + 1]), refQuaternion);
  2903. cumulativeQuaternion = refQuaternion;
  2904. cumulativeAmount = weights[index] + weights[index + 1];
  2905. index += 2;
  2906. continue;
  2907. }
  2908. cumulativeAmount += weights[index];
  2909. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].SlerpToRef(cumulativeQuaternion, quaternions[index], weights[index] / cumulativeAmount, cumulativeQuaternion);
  2910. index++;
  2911. }
  2912. return cumulativeQuaternion;
  2913. };
  2914. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype._processLateAnimationBindings = function () {
  2915. if (!this._registeredForLateAnimationBindings.length) {
  2916. return;
  2917. }
  2918. for (var index = 0; index < this._registeredForLateAnimationBindings.length; index++) {
  2919. var target = this._registeredForLateAnimationBindings.data[index];
  2920. for (var path in target._lateAnimationHolders) {
  2921. var holder = target._lateAnimationHolders[path];
  2922. var originalAnimation = holder.animations[0];
  2923. var originalValue = holder.originalValue;
  2924. var matrixDecomposeMode = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].AllowMatrixDecomposeForInterpolation && originalValue.m; // ie. data is matrix
  2925. var finalValue = target[path];
  2926. if (matrixDecomposeMode) {
  2927. finalValue = this._processLateAnimationBindingsForMatrices(holder);
  2928. }
  2929. else {
  2930. var quaternionMode = originalValue.w !== undefined;
  2931. if (quaternionMode) {
  2932. finalValue = this._processLateAnimationBindingsForQuaternions(holder, finalValue || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity());
  2933. }
  2934. else {
  2935. var startIndex = 0;
  2936. var normalizer = 1.0;
  2937. if (holder.totalWeight < 1.0) {
  2938. // We need to mix the original value in
  2939. if (originalValue.scale) {
  2940. finalValue = originalValue.scale(1.0 - holder.totalWeight);
  2941. }
  2942. else {
  2943. finalValue = originalValue * (1.0 - holder.totalWeight);
  2944. }
  2945. }
  2946. else {
  2947. // We need to normalize the weights
  2948. normalizer = holder.totalWeight;
  2949. var scale_1 = originalAnimation.weight / normalizer;
  2950. if (scale_1 !== 1) {
  2951. if (originalAnimation.currentValue.scale) {
  2952. finalValue = originalAnimation.currentValue.scale(scale_1);
  2953. }
  2954. else {
  2955. finalValue = originalAnimation.currentValue * scale_1;
  2956. }
  2957. }
  2958. else {
  2959. finalValue = originalAnimation.currentValue;
  2960. }
  2961. startIndex = 1;
  2962. }
  2963. for (var animIndex = startIndex; animIndex < holder.animations.length; animIndex++) {
  2964. var runtimeAnimation = holder.animations[animIndex];
  2965. var scale = runtimeAnimation.weight / normalizer;
  2966. if (runtimeAnimation.currentValue.scaleAndAddToRef) {
  2967. runtimeAnimation.currentValue.scaleAndAddToRef(scale, finalValue);
  2968. }
  2969. else {
  2970. finalValue += runtimeAnimation.currentValue * scale;
  2971. }
  2972. }
  2973. }
  2974. }
  2975. target[path] = finalValue;
  2976. }
  2977. target._lateAnimationHolders = {};
  2978. }
  2979. this._registeredForLateAnimationBindings.reset();
  2980. };
  2981. _Bones_bone__WEBPACK_IMPORTED_MODULE_6__["Bone"].prototype.copyAnimationRange = function (source, rangeName, frameOffset, rescaleAsRequired, skelDimensionsRatio) {
  2982. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  2983. if (skelDimensionsRatio === void 0) { skelDimensionsRatio = null; }
  2984. // all animation may be coming from a library skeleton, so may need to create animation
  2985. if (this.animations.length === 0) {
  2986. this.animations.push(new _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"](this.name, "_matrix", source.animations[0].framePerSecond, _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONTYPE_MATRIX, 0));
  2987. this.animations[0].setKeys([]);
  2988. }
  2989. // get animation info / verify there is such a range from the source bone
  2990. var sourceRange = source.animations[0].getRange(rangeName);
  2991. if (!sourceRange) {
  2992. return false;
  2993. }
  2994. var from = sourceRange.from;
  2995. var to = sourceRange.to;
  2996. var sourceKeys = source.animations[0].getKeys();
  2997. // rescaling prep
  2998. var sourceBoneLength = source.length;
  2999. var sourceParent = source.getParent();
  3000. var parent = this.getParent();
  3001. var parentScalingReqd = rescaleAsRequired && sourceParent && sourceBoneLength && this.length && sourceBoneLength !== this.length;
  3002. var parentRatio = parentScalingReqd && parent && sourceParent ? parent.length / sourceParent.length : 1;
  3003. var dimensionsScalingReqd = rescaleAsRequired && !parent && skelDimensionsRatio && (skelDimensionsRatio.x !== 1 || skelDimensionsRatio.y !== 1 || skelDimensionsRatio.z !== 1);
  3004. var destKeys = this.animations[0].getKeys();
  3005. // loop vars declaration
  3006. var orig;
  3007. var origTranslation;
  3008. var mat;
  3009. for (var key = 0, nKeys = sourceKeys.length; key < nKeys; key++) {
  3010. orig = sourceKeys[key];
  3011. if (orig.frame >= from && orig.frame <= to) {
  3012. if (rescaleAsRequired) {
  3013. mat = orig.value.clone();
  3014. // scale based on parent ratio, when bone has parent
  3015. if (parentScalingReqd) {
  3016. origTranslation = mat.getTranslation();
  3017. mat.setTranslation(origTranslation.scaleInPlace(parentRatio));
  3018. // scale based on skeleton dimension ratio when root bone, and value is passed
  3019. }
  3020. else if (dimensionsScalingReqd && skelDimensionsRatio) {
  3021. origTranslation = mat.getTranslation();
  3022. mat.setTranslation(origTranslation.multiplyInPlace(skelDimensionsRatio));
  3023. // use original when root bone, and no data for skelDimensionsRatio
  3024. }
  3025. else {
  3026. mat = orig.value;
  3027. }
  3028. }
  3029. else {
  3030. mat = orig.value;
  3031. }
  3032. destKeys.push({ frame: orig.frame + frameOffset, value: mat });
  3033. }
  3034. }
  3035. this.animations[0].createRange(rangeName, from + frameOffset, to + frameOffset);
  3036. return true;
  3037. };
  3038. /***/ }),
  3039. /***/ "./Animations/animation.ts":
  3040. /*!*********************************!*\
  3041. !*** ./Animations/animation.ts ***!
  3042. \*********************************/
  3043. /*! exports provided: Animation */
  3044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  3045. "use strict";
  3046. __webpack_require__.r(__webpack_exports__);
  3047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return Animation; });
  3048. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  3049. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  3050. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  3051. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  3052. /* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  3053. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  3054. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  3055. /**
  3056. * Class used to store any kind of animation
  3057. */
  3058. var Animation = /** @class */ (function () {
  3059. /**
  3060. * Initializes the animation
  3061. * @param name Name of the animation
  3062. * @param targetProperty Property to animate
  3063. * @param framePerSecond The frames per second of the animation
  3064. * @param dataType The data type of the animation
  3065. * @param loopMode The loop mode of the animation
  3066. * @param enableBlending Specifies if blending should be enabled
  3067. */
  3068. function Animation(
  3069. /**Name of the animation */
  3070. name,
  3071. /**Property to animate */
  3072. targetProperty,
  3073. /**The frames per second of the animation */
  3074. framePerSecond,
  3075. /**The data type of the animation */
  3076. dataType,
  3077. /**The loop mode of the animation */
  3078. loopMode,
  3079. /**Specifies if blending should be enabled */
  3080. enableBlending) {
  3081. this.name = name;
  3082. this.targetProperty = targetProperty;
  3083. this.framePerSecond = framePerSecond;
  3084. this.dataType = dataType;
  3085. this.loopMode = loopMode;
  3086. this.enableBlending = enableBlending;
  3087. /**
  3088. * @hidden Internal use only
  3089. */
  3090. this._runtimeAnimations = new Array();
  3091. /**
  3092. * The set of event that will be linked to this animation
  3093. */
  3094. this._events = new Array();
  3095. /**
  3096. * Stores the blending speed of the animation
  3097. */
  3098. this.blendingSpeed = 0.01;
  3099. /**
  3100. * Stores the animation ranges for the animation
  3101. */
  3102. this._ranges = {};
  3103. this.targetPropertyPath = targetProperty.split(".");
  3104. this.dataType = dataType;
  3105. this.loopMode = loopMode === undefined ? Animation.ANIMATIONLOOPMODE_CYCLE : loopMode;
  3106. }
  3107. /**
  3108. * @hidden Internal use
  3109. */
  3110. Animation._PrepareAnimation = function (name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction) {
  3111. var dataType = undefined;
  3112. if (!isNaN(parseFloat(from)) && isFinite(from)) {
  3113. dataType = Animation.ANIMATIONTYPE_FLOAT;
  3114. }
  3115. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]) {
  3116. dataType = Animation.ANIMATIONTYPE_QUATERNION;
  3117. }
  3118. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  3119. dataType = Animation.ANIMATIONTYPE_VECTOR3;
  3120. }
  3121. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"]) {
  3122. dataType = Animation.ANIMATIONTYPE_VECTOR2;
  3123. }
  3124. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"]) {
  3125. dataType = Animation.ANIMATIONTYPE_COLOR3;
  3126. }
  3127. else if (from instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"]) {
  3128. dataType = Animation.ANIMATIONTYPE_SIZE;
  3129. }
  3130. if (dataType == undefined) {
  3131. return null;
  3132. }
  3133. var animation = new Animation(name, targetProperty, framePerSecond, dataType, loopMode);
  3134. var keys = [{ frame: 0, value: from }, { frame: totalFrame, value: to }];
  3135. animation.setKeys(keys);
  3136. if (easingFunction !== undefined) {
  3137. animation.setEasingFunction(easingFunction);
  3138. }
  3139. return animation;
  3140. };
  3141. /**
  3142. * Sets up an animation
  3143. * @param property The property to animate
  3144. * @param animationType The animation type to apply
  3145. * @param framePerSecond The frames per second of the animation
  3146. * @param easingFunction The easing function used in the animation
  3147. * @returns The created animation
  3148. */
  3149. Animation.CreateAnimation = function (property, animationType, framePerSecond, easingFunction) {
  3150. var animation = new Animation(property + "Animation", property, framePerSecond, animationType, Animation.ANIMATIONLOOPMODE_CONSTANT);
  3151. animation.setEasingFunction(easingFunction);
  3152. return animation;
  3153. };
  3154. /**
  3155. * Create and start an animation on a node
  3156. * @param name defines the name of the global animation that will be run on all nodes
  3157. * @param node defines the root node where the animation will take place
  3158. * @param targetProperty defines property to animate
  3159. * @param framePerSecond defines the number of frame per second yo use
  3160. * @param totalFrame defines the number of frames in total
  3161. * @param from defines the initial value
  3162. * @param to defines the final value
  3163. * @param loopMode defines which loop mode you want to use (off by default)
  3164. * @param easingFunction defines the easing function to use (linear by default)
  3165. * @param onAnimationEnd defines the callback to call when animation end
  3166. * @returns the animatable created for this animation
  3167. */
  3168. Animation.CreateAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3169. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3170. if (!animation) {
  3171. return null;
  3172. }
  3173. return node.getScene().beginDirectAnimation(node, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3174. };
  3175. /**
  3176. * Create and start an animation on a node and its descendants
  3177. * @param name defines the name of the global animation that will be run on all nodes
  3178. * @param node defines the root node where the animation will take place
  3179. * @param directDescendantsOnly if true only direct descendants will be used, if false direct and also indirect (children of children, an so on in a recursive manner) descendants will be used
  3180. * @param targetProperty defines property to animate
  3181. * @param framePerSecond defines the number of frame per second to use
  3182. * @param totalFrame defines the number of frames in total
  3183. * @param from defines the initial value
  3184. * @param to defines the final value
  3185. * @param loopMode defines which loop mode you want to use (off by default)
  3186. * @param easingFunction defines the easing function to use (linear by default)
  3187. * @param onAnimationEnd defines the callback to call when an animation ends (will be called once per node)
  3188. * @returns the list of animatables created for all nodes
  3189. * @example https://www.babylonjs-playground.com/#MH0VLI
  3190. */
  3191. Animation.CreateAndStartHierarchyAnimation = function (name, node, directDescendantsOnly, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3192. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3193. if (!animation) {
  3194. return null;
  3195. }
  3196. var scene = node.getScene();
  3197. return scene.beginDirectHierarchyAnimation(node, directDescendantsOnly, [animation], 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3198. };
  3199. /**
  3200. * Creates a new animation, merges it with the existing animations and starts it
  3201. * @param name Name of the animation
  3202. * @param node Node which contains the scene that begins the animations
  3203. * @param targetProperty Specifies which property to animate
  3204. * @param framePerSecond The frames per second of the animation
  3205. * @param totalFrame The total number of frames
  3206. * @param from The frame at the beginning of the animation
  3207. * @param to The frame at the end of the animation
  3208. * @param loopMode Specifies the loop mode of the animation
  3209. * @param easingFunction (Optional) The easing function of the animation, which allow custom mathematical formulas for animations
  3210. * @param onAnimationEnd Callback to run once the animation is complete
  3211. * @returns Nullable animation
  3212. */
  3213. Animation.CreateMergeAndStartAnimation = function (name, node, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction, onAnimationEnd) {
  3214. var animation = Animation._PrepareAnimation(name, targetProperty, framePerSecond, totalFrame, from, to, loopMode, easingFunction);
  3215. if (!animation) {
  3216. return null;
  3217. }
  3218. node.animations.push(animation);
  3219. return node.getScene().beginAnimation(node, 0, totalFrame, (animation.loopMode === 1), 1.0, onAnimationEnd);
  3220. };
  3221. /**
  3222. * Transition property of an host to the target Value
  3223. * @param property The property to transition
  3224. * @param targetValue The target Value of the property
  3225. * @param host The object where the property to animate belongs
  3226. * @param scene Scene used to run the animation
  3227. * @param frameRate Framerate (in frame/s) to use
  3228. * @param transition The transition type we want to use
  3229. * @param duration The duration of the animation, in milliseconds
  3230. * @param onAnimationEnd Callback trigger at the end of the animation
  3231. * @returns Nullable animation
  3232. */
  3233. Animation.TransitionTo = function (property, targetValue, host, scene, frameRate, transition, duration, onAnimationEnd) {
  3234. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  3235. if (duration <= 0) {
  3236. host[property] = targetValue;
  3237. if (onAnimationEnd) {
  3238. onAnimationEnd();
  3239. }
  3240. return null;
  3241. }
  3242. var endFrame = frameRate * (duration / 1000);
  3243. transition.setKeys([{
  3244. frame: 0,
  3245. value: host[property].clone ? host[property].clone() : host[property]
  3246. },
  3247. {
  3248. frame: endFrame,
  3249. value: targetValue
  3250. }]);
  3251. if (!host.animations) {
  3252. host.animations = [];
  3253. }
  3254. host.animations.push(transition);
  3255. var animation = scene.beginAnimation(host, 0, endFrame, false);
  3256. animation.onAnimationEnd = onAnimationEnd;
  3257. return animation;
  3258. };
  3259. Object.defineProperty(Animation.prototype, "runtimeAnimations", {
  3260. /**
  3261. * Return the array of runtime animations currently using this animation
  3262. */
  3263. get: function () {
  3264. return this._runtimeAnimations;
  3265. },
  3266. enumerable: true,
  3267. configurable: true
  3268. });
  3269. Object.defineProperty(Animation.prototype, "hasRunningRuntimeAnimations", {
  3270. /**
  3271. * Specifies if any of the runtime animations are currently running
  3272. */
  3273. get: function () {
  3274. for (var _i = 0, _a = this._runtimeAnimations; _i < _a.length; _i++) {
  3275. var runtimeAnimation = _a[_i];
  3276. if (!runtimeAnimation.isStopped) {
  3277. return true;
  3278. }
  3279. }
  3280. return false;
  3281. },
  3282. enumerable: true,
  3283. configurable: true
  3284. });
  3285. // Methods
  3286. /**
  3287. * Converts the animation to a string
  3288. * @param fullDetails support for multiple levels of logging within scene loading
  3289. * @returns String form of the animation
  3290. */
  3291. Animation.prototype.toString = function (fullDetails) {
  3292. var ret = "Name: " + this.name + ", property: " + this.targetProperty;
  3293. ret += ", datatype: " + (["Float", "Vector3", "Quaternion", "Matrix", "Color3", "Vector2"])[this.dataType];
  3294. ret += ", nKeys: " + (this._keys ? this._keys.length : "none");
  3295. ret += ", nRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  3296. if (fullDetails) {
  3297. ret += ", Ranges: {";
  3298. var first = true;
  3299. for (var name in this._ranges) {
  3300. if (first) {
  3301. ret += ", ";
  3302. first = false;
  3303. }
  3304. ret += name;
  3305. }
  3306. ret += "}";
  3307. }
  3308. return ret;
  3309. };
  3310. /**
  3311. * Add an event to this animation
  3312. * @param event Event to add
  3313. */
  3314. Animation.prototype.addEvent = function (event) {
  3315. this._events.push(event);
  3316. };
  3317. /**
  3318. * Remove all events found at the given frame
  3319. * @param frame The frame to remove events from
  3320. */
  3321. Animation.prototype.removeEvents = function (frame) {
  3322. for (var index = 0; index < this._events.length; index++) {
  3323. if (this._events[index].frame === frame) {
  3324. this._events.splice(index, 1);
  3325. index--;
  3326. }
  3327. }
  3328. };
  3329. /**
  3330. * Retrieves all the events from the animation
  3331. * @returns Events from the animation
  3332. */
  3333. Animation.prototype.getEvents = function () {
  3334. return this._events;
  3335. };
  3336. /**
  3337. * Creates an animation range
  3338. * @param name Name of the animation range
  3339. * @param from Starting frame of the animation range
  3340. * @param to Ending frame of the animation
  3341. */
  3342. Animation.prototype.createRange = function (name, from, to) {
  3343. // check name not already in use; could happen for bones after serialized
  3344. if (!this._ranges[name]) {
  3345. this._ranges[name] = new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  3346. }
  3347. };
  3348. /**
  3349. * Deletes an animation range by name
  3350. * @param name Name of the animation range to delete
  3351. * @param deleteFrames Specifies if the key frames for the range should also be deleted (true) or not (false)
  3352. */
  3353. Animation.prototype.deleteRange = function (name, deleteFrames) {
  3354. if (deleteFrames === void 0) { deleteFrames = true; }
  3355. var range = this._ranges[name];
  3356. if (!range) {
  3357. return;
  3358. }
  3359. if (deleteFrames) {
  3360. var from = range.from;
  3361. var to = range.to;
  3362. // this loop MUST go high to low for multiple splices to work
  3363. for (var key = this._keys.length - 1; key >= 0; key--) {
  3364. if (this._keys[key].frame >= from && this._keys[key].frame <= to) {
  3365. this._keys.splice(key, 1);
  3366. }
  3367. }
  3368. }
  3369. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  3370. };
  3371. /**
  3372. * Gets the animation range by name, or null if not defined
  3373. * @param name Name of the animation range
  3374. * @returns Nullable animation range
  3375. */
  3376. Animation.prototype.getRange = function (name) {
  3377. return this._ranges[name];
  3378. };
  3379. /**
  3380. * Gets the key frames from the animation
  3381. * @returns The key frames of the animation
  3382. */
  3383. Animation.prototype.getKeys = function () {
  3384. return this._keys;
  3385. };
  3386. /**
  3387. * Gets the highest frame rate of the animation
  3388. * @returns Highest frame rate of the animation
  3389. */
  3390. Animation.prototype.getHighestFrame = function () {
  3391. var ret = 0;
  3392. for (var key = 0, nKeys = this._keys.length; key < nKeys; key++) {
  3393. if (ret < this._keys[key].frame) {
  3394. ret = this._keys[key].frame;
  3395. }
  3396. }
  3397. return ret;
  3398. };
  3399. /**
  3400. * Gets the easing function of the animation
  3401. * @returns Easing function of the animation
  3402. */
  3403. Animation.prototype.getEasingFunction = function () {
  3404. return this._easingFunction;
  3405. };
  3406. /**
  3407. * Sets the easing function of the animation
  3408. * @param easingFunction A custom mathematical formula for animation
  3409. */
  3410. Animation.prototype.setEasingFunction = function (easingFunction) {
  3411. this._easingFunction = easingFunction;
  3412. };
  3413. /**
  3414. * Interpolates a scalar linearly
  3415. * @param startValue Start value of the animation curve
  3416. * @param endValue End value of the animation curve
  3417. * @param gradient Scalar amount to interpolate
  3418. * @returns Interpolated scalar value
  3419. */
  3420. Animation.prototype.floatInterpolateFunction = function (startValue, endValue, gradient) {
  3421. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Lerp(startValue, endValue, gradient);
  3422. };
  3423. /**
  3424. * Interpolates a scalar cubically
  3425. * @param startValue Start value of the animation curve
  3426. * @param outTangent End tangent of the animation
  3427. * @param endValue End value of the animation curve
  3428. * @param inTangent Start tangent of the animation curve
  3429. * @param gradient Scalar amount to interpolate
  3430. * @returns Interpolated scalar value
  3431. */
  3432. Animation.prototype.floatInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3433. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3434. };
  3435. /**
  3436. * Interpolates a quaternion using a spherical linear interpolation
  3437. * @param startValue Start value of the animation curve
  3438. * @param endValue End value of the animation curve
  3439. * @param gradient Scalar amount to interpolate
  3440. * @returns Interpolated quaternion value
  3441. */
  3442. Animation.prototype.quaternionInterpolateFunction = function (startValue, endValue, gradient) {
  3443. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Slerp(startValue, endValue, gradient);
  3444. };
  3445. /**
  3446. * Interpolates a quaternion cubically
  3447. * @param startValue Start value of the animation curve
  3448. * @param outTangent End tangent of the animation curve
  3449. * @param endValue End value of the animation curve
  3450. * @param inTangent Start tangent of the animation curve
  3451. * @param gradient Scalar amount to interpolate
  3452. * @returns Interpolated quaternion value
  3453. */
  3454. Animation.prototype.quaternionInterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3455. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Hermite(startValue, outTangent, endValue, inTangent, gradient).normalize();
  3456. };
  3457. /**
  3458. * Interpolates a Vector3 linearl
  3459. * @param startValue Start value of the animation curve
  3460. * @param endValue End value of the animation curve
  3461. * @param gradient Scalar amount to interpolate
  3462. * @returns Interpolated scalar value
  3463. */
  3464. Animation.prototype.vector3InterpolateFunction = function (startValue, endValue, gradient) {
  3465. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(startValue, endValue, gradient);
  3466. };
  3467. /**
  3468. * Interpolates a Vector3 cubically
  3469. * @param startValue Start value of the animation curve
  3470. * @param outTangent End tangent of the animation
  3471. * @param endValue End value of the animation curve
  3472. * @param inTangent Start tangent of the animation curve
  3473. * @param gradient Scalar amount to interpolate
  3474. * @returns InterpolatedVector3 value
  3475. */
  3476. Animation.prototype.vector3InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3477. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3478. };
  3479. /**
  3480. * Interpolates a Vector2 linearly
  3481. * @param startValue Start value of the animation curve
  3482. * @param endValue End value of the animation curve
  3483. * @param gradient Scalar amount to interpolate
  3484. * @returns Interpolated Vector2 value
  3485. */
  3486. Animation.prototype.vector2InterpolateFunction = function (startValue, endValue, gradient) {
  3487. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(startValue, endValue, gradient);
  3488. };
  3489. /**
  3490. * Interpolates a Vector2 cubically
  3491. * @param startValue Start value of the animation curve
  3492. * @param outTangent End tangent of the animation
  3493. * @param endValue End value of the animation curve
  3494. * @param inTangent Start tangent of the animation curve
  3495. * @param gradient Scalar amount to interpolate
  3496. * @returns Interpolated Vector2 value
  3497. */
  3498. Animation.prototype.vector2InterpolateFunctionWithTangents = function (startValue, outTangent, endValue, inTangent, gradient) {
  3499. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Hermite(startValue, outTangent, endValue, inTangent, gradient);
  3500. };
  3501. /**
  3502. * Interpolates a size linearly
  3503. * @param startValue Start value of the animation curve
  3504. * @param endValue End value of the animation curve
  3505. * @param gradient Scalar amount to interpolate
  3506. * @returns Interpolated Size value
  3507. */
  3508. Animation.prototype.sizeInterpolateFunction = function (startValue, endValue, gradient) {
  3509. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Lerp(startValue, endValue, gradient);
  3510. };
  3511. /**
  3512. * Interpolates a Color3 linearly
  3513. * @param startValue Start value of the animation curve
  3514. * @param endValue End value of the animation curve
  3515. * @param gradient Scalar amount to interpolate
  3516. * @returns Interpolated Color3 value
  3517. */
  3518. Animation.prototype.color3InterpolateFunction = function (startValue, endValue, gradient) {
  3519. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Lerp(startValue, endValue, gradient);
  3520. };
  3521. /**
  3522. * @hidden Internal use only
  3523. */
  3524. Animation.prototype._getKeyValue = function (value) {
  3525. if (typeof value === "function") {
  3526. return value();
  3527. }
  3528. return value;
  3529. };
  3530. /**
  3531. * @hidden Internal use only
  3532. */
  3533. Animation.prototype._interpolate = function (currentFrame, repeatCount, workValue, loopMode, offsetValue, highLimitValue) {
  3534. if (loopMode === Animation.ANIMATIONLOOPMODE_CONSTANT && repeatCount > 0) {
  3535. return highLimitValue.clone ? highLimitValue.clone() : highLimitValue;
  3536. }
  3537. var keys = this.getKeys();
  3538. if (keys.length === 1) {
  3539. return this._getKeyValue(keys[0].value);
  3540. }
  3541. // Try to get a hash to find the right key
  3542. var startKeyIndex = Math.max(0, Math.min(keys.length - 1, Math.floor(keys.length * (currentFrame - keys[0].frame) / (keys[keys.length - 1].frame - keys[0].frame)) - 1));
  3543. if (keys[startKeyIndex].frame >= currentFrame) {
  3544. while (startKeyIndex - 1 >= 0 && keys[startKeyIndex].frame >= currentFrame) {
  3545. startKeyIndex--;
  3546. }
  3547. }
  3548. for (var key = startKeyIndex; key < keys.length; key++) {
  3549. var endKey = keys[key + 1];
  3550. if (endKey.frame >= currentFrame) {
  3551. var startKey = keys[key];
  3552. var startValue = this._getKeyValue(startKey.value);
  3553. if (startKey.interpolation === _animationKey__WEBPACK_IMPORTED_MODULE_4__["AnimationKeyInterpolation"].STEP) {
  3554. return startValue;
  3555. }
  3556. var endValue = this._getKeyValue(endKey.value);
  3557. var useTangent = startKey.outTangent !== undefined && endKey.inTangent !== undefined;
  3558. var frameDelta = endKey.frame - startKey.frame;
  3559. // gradient : percent of currentFrame between the frame inf and the frame sup
  3560. var gradient = (currentFrame - startKey.frame) / frameDelta;
  3561. // check for easingFunction and correction of gradient
  3562. var easingFunction = this.getEasingFunction();
  3563. if (easingFunction != null) {
  3564. gradient = easingFunction.ease(gradient);
  3565. }
  3566. switch (this.dataType) {
  3567. // Float
  3568. case Animation.ANIMATIONTYPE_FLOAT:
  3569. var floatValue = useTangent ? this.floatInterpolateFunctionWithTangents(startValue, startKey.outTangent * frameDelta, endValue, endKey.inTangent * frameDelta, gradient) : this.floatInterpolateFunction(startValue, endValue, gradient);
  3570. switch (loopMode) {
  3571. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3572. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3573. return floatValue;
  3574. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3575. return offsetValue * repeatCount + floatValue;
  3576. }
  3577. break;
  3578. // Quaternion
  3579. case Animation.ANIMATIONTYPE_QUATERNION:
  3580. var quatValue = useTangent ? this.quaternionInterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.quaternionInterpolateFunction(startValue, endValue, gradient);
  3581. switch (loopMode) {
  3582. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3583. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3584. return quatValue;
  3585. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3586. return quatValue.addInPlace(offsetValue.scale(repeatCount));
  3587. }
  3588. return quatValue;
  3589. // Vector3
  3590. case Animation.ANIMATIONTYPE_VECTOR3:
  3591. var vec3Value = useTangent ? this.vector3InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector3InterpolateFunction(startValue, endValue, gradient);
  3592. switch (loopMode) {
  3593. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3594. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3595. return vec3Value;
  3596. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3597. return vec3Value.add(offsetValue.scale(repeatCount));
  3598. }
  3599. // Vector2
  3600. case Animation.ANIMATIONTYPE_VECTOR2:
  3601. var vec2Value = useTangent ? this.vector2InterpolateFunctionWithTangents(startValue, startKey.outTangent.scale(frameDelta), endValue, endKey.inTangent.scale(frameDelta), gradient) : this.vector2InterpolateFunction(startValue, endValue, gradient);
  3602. switch (loopMode) {
  3603. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3604. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3605. return vec2Value;
  3606. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3607. return vec2Value.add(offsetValue.scale(repeatCount));
  3608. }
  3609. // Size
  3610. case Animation.ANIMATIONTYPE_SIZE:
  3611. switch (loopMode) {
  3612. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3613. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3614. return this.sizeInterpolateFunction(startValue, endValue, gradient);
  3615. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3616. return this.sizeInterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3617. }
  3618. // Color3
  3619. case Animation.ANIMATIONTYPE_COLOR3:
  3620. switch (loopMode) {
  3621. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3622. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3623. return this.color3InterpolateFunction(startValue, endValue, gradient);
  3624. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3625. return this.color3InterpolateFunction(startValue, endValue, gradient).add(offsetValue.scale(repeatCount));
  3626. }
  3627. // Matrix
  3628. case Animation.ANIMATIONTYPE_MATRIX:
  3629. switch (loopMode) {
  3630. case Animation.ANIMATIONLOOPMODE_CYCLE:
  3631. case Animation.ANIMATIONLOOPMODE_CONSTANT:
  3632. if (Animation.AllowMatricesInterpolation) {
  3633. return this.matrixInterpolateFunction(startValue, endValue, gradient, workValue);
  3634. }
  3635. case Animation.ANIMATIONLOOPMODE_RELATIVE:
  3636. return startValue;
  3637. }
  3638. default:
  3639. break;
  3640. }
  3641. break;
  3642. }
  3643. }
  3644. return this._getKeyValue(keys[keys.length - 1].value);
  3645. };
  3646. /**
  3647. * Defines the function to use to interpolate matrices
  3648. * @param startValue defines the start matrix
  3649. * @param endValue defines the end matrix
  3650. * @param gradient defines the gradient between both matrices
  3651. * @param result defines an optional target matrix where to store the interpolation
  3652. * @returns the interpolated matrix
  3653. */
  3654. Animation.prototype.matrixInterpolateFunction = function (startValue, endValue, gradient, result) {
  3655. if (Animation.AllowMatrixDecomposeForInterpolation) {
  3656. if (result) {
  3657. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(startValue, endValue, gradient, result);
  3658. return result;
  3659. }
  3660. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(startValue, endValue, gradient);
  3661. }
  3662. if (result) {
  3663. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(startValue, endValue, gradient, result);
  3664. return result;
  3665. }
  3666. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(startValue, endValue, gradient);
  3667. };
  3668. /**
  3669. * Makes a copy of the animation
  3670. * @returns Cloned animation
  3671. */
  3672. Animation.prototype.clone = function () {
  3673. var clone = new Animation(this.name, this.targetPropertyPath.join("."), this.framePerSecond, this.dataType, this.loopMode);
  3674. clone.enableBlending = this.enableBlending;
  3675. clone.blendingSpeed = this.blendingSpeed;
  3676. if (this._keys) {
  3677. clone.setKeys(this._keys);
  3678. }
  3679. if (this._ranges) {
  3680. clone._ranges = {};
  3681. for (var name in this._ranges) {
  3682. var range = this._ranges[name];
  3683. if (!range) {
  3684. continue;
  3685. }
  3686. clone._ranges[name] = range.clone();
  3687. }
  3688. }
  3689. return clone;
  3690. };
  3691. /**
  3692. * Sets the key frames of the animation
  3693. * @param values The animation key frames to set
  3694. */
  3695. Animation.prototype.setKeys = function (values) {
  3696. this._keys = values.slice(0);
  3697. };
  3698. /**
  3699. * Serializes the animation to an object
  3700. * @returns Serialized object
  3701. */
  3702. Animation.prototype.serialize = function () {
  3703. var serializationObject = {};
  3704. serializationObject.name = this.name;
  3705. serializationObject.property = this.targetProperty;
  3706. serializationObject.framePerSecond = this.framePerSecond;
  3707. serializationObject.dataType = this.dataType;
  3708. serializationObject.loopBehavior = this.loopMode;
  3709. serializationObject.enableBlending = this.enableBlending;
  3710. serializationObject.blendingSpeed = this.blendingSpeed;
  3711. var dataType = this.dataType;
  3712. serializationObject.keys = [];
  3713. var keys = this.getKeys();
  3714. for (var index = 0; index < keys.length; index++) {
  3715. var animationKey = keys[index];
  3716. var key = {};
  3717. key.frame = animationKey.frame;
  3718. switch (dataType) {
  3719. case Animation.ANIMATIONTYPE_FLOAT:
  3720. key.values = [animationKey.value];
  3721. break;
  3722. case Animation.ANIMATIONTYPE_QUATERNION:
  3723. case Animation.ANIMATIONTYPE_MATRIX:
  3724. case Animation.ANIMATIONTYPE_VECTOR3:
  3725. case Animation.ANIMATIONTYPE_COLOR3:
  3726. key.values = animationKey.value.asArray();
  3727. break;
  3728. }
  3729. serializationObject.keys.push(key);
  3730. }
  3731. serializationObject.ranges = [];
  3732. for (var name in this._ranges) {
  3733. var source = this._ranges[name];
  3734. if (!source) {
  3735. continue;
  3736. }
  3737. var range = {};
  3738. range.name = name;
  3739. range.from = source.from;
  3740. range.to = source.to;
  3741. serializationObject.ranges.push(range);
  3742. }
  3743. return serializationObject;
  3744. };
  3745. Object.defineProperty(Animation, "ANIMATIONTYPE_FLOAT", {
  3746. /**
  3747. * Get the float animation type
  3748. */
  3749. get: function () {
  3750. return Animation._ANIMATIONTYPE_FLOAT;
  3751. },
  3752. enumerable: true,
  3753. configurable: true
  3754. });
  3755. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR3", {
  3756. /**
  3757. * Get the Vector3 animation type
  3758. */
  3759. get: function () {
  3760. return Animation._ANIMATIONTYPE_VECTOR3;
  3761. },
  3762. enumerable: true,
  3763. configurable: true
  3764. });
  3765. Object.defineProperty(Animation, "ANIMATIONTYPE_VECTOR2", {
  3766. /**
  3767. * Get the Vector2 animation type
  3768. */
  3769. get: function () {
  3770. return Animation._ANIMATIONTYPE_VECTOR2;
  3771. },
  3772. enumerable: true,
  3773. configurable: true
  3774. });
  3775. Object.defineProperty(Animation, "ANIMATIONTYPE_SIZE", {
  3776. /**
  3777. * Get the Size animation type
  3778. */
  3779. get: function () {
  3780. return Animation._ANIMATIONTYPE_SIZE;
  3781. },
  3782. enumerable: true,
  3783. configurable: true
  3784. });
  3785. Object.defineProperty(Animation, "ANIMATIONTYPE_QUATERNION", {
  3786. /**
  3787. * Get the Quaternion animation type
  3788. */
  3789. get: function () {
  3790. return Animation._ANIMATIONTYPE_QUATERNION;
  3791. },
  3792. enumerable: true,
  3793. configurable: true
  3794. });
  3795. Object.defineProperty(Animation, "ANIMATIONTYPE_MATRIX", {
  3796. /**
  3797. * Get the Matrix animation type
  3798. */
  3799. get: function () {
  3800. return Animation._ANIMATIONTYPE_MATRIX;
  3801. },
  3802. enumerable: true,
  3803. configurable: true
  3804. });
  3805. Object.defineProperty(Animation, "ANIMATIONTYPE_COLOR3", {
  3806. /**
  3807. * Get the Color3 animation type
  3808. */
  3809. get: function () {
  3810. return Animation._ANIMATIONTYPE_COLOR3;
  3811. },
  3812. enumerable: true,
  3813. configurable: true
  3814. });
  3815. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_RELATIVE", {
  3816. /**
  3817. * Get the Relative Loop Mode
  3818. */
  3819. get: function () {
  3820. return Animation._ANIMATIONLOOPMODE_RELATIVE;
  3821. },
  3822. enumerable: true,
  3823. configurable: true
  3824. });
  3825. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CYCLE", {
  3826. /**
  3827. * Get the Cycle Loop Mode
  3828. */
  3829. get: function () {
  3830. return Animation._ANIMATIONLOOPMODE_CYCLE;
  3831. },
  3832. enumerable: true,
  3833. configurable: true
  3834. });
  3835. Object.defineProperty(Animation, "ANIMATIONLOOPMODE_CONSTANT", {
  3836. /**
  3837. * Get the Constant Loop Mode
  3838. */
  3839. get: function () {
  3840. return Animation._ANIMATIONLOOPMODE_CONSTANT;
  3841. },
  3842. enumerable: true,
  3843. configurable: true
  3844. });
  3845. /** @hidden */
  3846. Animation._UniversalLerp = function (left, right, amount) {
  3847. var constructor = left.constructor;
  3848. if (constructor.Lerp) { // Lerp supported
  3849. return constructor.Lerp(left, right, amount);
  3850. }
  3851. else if (constructor.Slerp) { // Slerp supported
  3852. return constructor.Slerp(left, right, amount);
  3853. }
  3854. else if (left.toFixed) { // Number
  3855. return left * (1.0 - amount) + amount * right;
  3856. }
  3857. else { // Blending not supported
  3858. return right;
  3859. }
  3860. };
  3861. /**
  3862. * Parses an animation object and creates an animation
  3863. * @param parsedAnimation Parsed animation object
  3864. * @returns Animation object
  3865. */
  3866. Animation.Parse = function (parsedAnimation) {
  3867. var animation = new Animation(parsedAnimation.name, parsedAnimation.property, parsedAnimation.framePerSecond, parsedAnimation.dataType, parsedAnimation.loopBehavior);
  3868. var dataType = parsedAnimation.dataType;
  3869. var keys = [];
  3870. var data;
  3871. var index;
  3872. if (parsedAnimation.enableBlending) {
  3873. animation.enableBlending = parsedAnimation.enableBlending;
  3874. }
  3875. if (parsedAnimation.blendingSpeed) {
  3876. animation.blendingSpeed = parsedAnimation.blendingSpeed;
  3877. }
  3878. for (index = 0; index < parsedAnimation.keys.length; index++) {
  3879. var key = parsedAnimation.keys[index];
  3880. var inTangent;
  3881. var outTangent;
  3882. switch (dataType) {
  3883. case Animation.ANIMATIONTYPE_FLOAT:
  3884. data = key.values[0];
  3885. if (key.values.length >= 1) {
  3886. inTangent = key.values[1];
  3887. }
  3888. if (key.values.length >= 2) {
  3889. outTangent = key.values[2];
  3890. }
  3891. break;
  3892. case Animation.ANIMATIONTYPE_QUATERNION:
  3893. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values);
  3894. if (key.values.length >= 8) {
  3895. var _inTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(4, 8));
  3896. if (!_inTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3897. inTangent = _inTangent;
  3898. }
  3899. }
  3900. if (key.values.length >= 12) {
  3901. var _outTangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromArray(key.values.slice(8, 12));
  3902. if (!_outTangent.equals(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Zero())) {
  3903. outTangent = _outTangent;
  3904. }
  3905. }
  3906. break;
  3907. case Animation.ANIMATIONTYPE_MATRIX:
  3908. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromArray(key.values);
  3909. break;
  3910. case Animation.ANIMATIONTYPE_COLOR3:
  3911. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(key.values);
  3912. break;
  3913. case Animation.ANIMATIONTYPE_VECTOR3:
  3914. default:
  3915. data = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(key.values);
  3916. break;
  3917. }
  3918. var keyData = {};
  3919. keyData.frame = key.frame;
  3920. keyData.value = data;
  3921. if (inTangent != undefined) {
  3922. keyData.inTangent = inTangent;
  3923. }
  3924. if (outTangent != undefined) {
  3925. keyData.outTangent = outTangent;
  3926. }
  3927. keys.push(keyData);
  3928. }
  3929. animation.setKeys(keys);
  3930. if (parsedAnimation.ranges) {
  3931. for (index = 0; index < parsedAnimation.ranges.length; index++) {
  3932. data = parsedAnimation.ranges[index];
  3933. animation.createRange(data.name, data.from, data.to);
  3934. }
  3935. }
  3936. return animation;
  3937. };
  3938. /**
  3939. * Appends the serialized animations from the source animations
  3940. * @param source Source containing the animations
  3941. * @param destination Target to store the animations
  3942. */
  3943. Animation.AppendSerializedAnimations = function (source, destination) {
  3944. _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].AppendSerializedAnimations(source, destination);
  3945. };
  3946. /**
  3947. * Use matrix interpolation instead of using direct key value when animating matrices
  3948. */
  3949. Animation.AllowMatricesInterpolation = false;
  3950. /**
  3951. * When matrix interpolation is enabled, this boolean forces the system to use Matrix.DecomposeLerp instead of Matrix.Lerp. Interpolation is more precise but slower
  3952. */
  3953. Animation.AllowMatrixDecomposeForInterpolation = true;
  3954. // Statics
  3955. /**
  3956. * Float animation type
  3957. */
  3958. Animation._ANIMATIONTYPE_FLOAT = 0;
  3959. /**
  3960. * Vector3 animation type
  3961. */
  3962. Animation._ANIMATIONTYPE_VECTOR3 = 1;
  3963. /**
  3964. * Quaternion animation type
  3965. */
  3966. Animation._ANIMATIONTYPE_QUATERNION = 2;
  3967. /**
  3968. * Matrix animation type
  3969. */
  3970. Animation._ANIMATIONTYPE_MATRIX = 3;
  3971. /**
  3972. * Color3 animation type
  3973. */
  3974. Animation._ANIMATIONTYPE_COLOR3 = 4;
  3975. /**
  3976. * Vector2 animation type
  3977. */
  3978. Animation._ANIMATIONTYPE_VECTOR2 = 5;
  3979. /**
  3980. * Size animation type
  3981. */
  3982. Animation._ANIMATIONTYPE_SIZE = 6;
  3983. /**
  3984. * Relative Loop Mode
  3985. */
  3986. Animation._ANIMATIONLOOPMODE_RELATIVE = 0;
  3987. /**
  3988. * Cycle Loop Mode
  3989. */
  3990. Animation._ANIMATIONLOOPMODE_CYCLE = 1;
  3991. /**
  3992. * Constant Loop Mode
  3993. */
  3994. Animation._ANIMATIONLOOPMODE_CONSTANT = 2;
  3995. return Animation;
  3996. }());
  3997. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.Animation"] = Animation;
  3998. _node__WEBPACK_IMPORTED_MODULE_6__["Node"]._AnimationRangeFactory = function (name, from, to) { return new _animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to); };
  3999. /***/ }),
  4000. /***/ "./Animations/animationEvent.ts":
  4001. /*!**************************************!*\
  4002. !*** ./Animations/animationEvent.ts ***!
  4003. \**************************************/
  4004. /*! exports provided: AnimationEvent */
  4005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4006. "use strict";
  4007. __webpack_require__.r(__webpack_exports__);
  4008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return AnimationEvent; });
  4009. /**
  4010. * Composed of a frame, and an action function
  4011. */
  4012. var AnimationEvent = /** @class */ (function () {
  4013. /**
  4014. * Initializes the animation event
  4015. * @param frame The frame for which the event is triggered
  4016. * @param action The event to perform when triggered
  4017. * @param onlyOnce Specifies if the event should be triggered only once
  4018. */
  4019. function AnimationEvent(
  4020. /** The frame for which the event is triggered **/
  4021. frame,
  4022. /** The event to perform when triggered **/
  4023. action,
  4024. /** Specifies if the event should be triggered only once**/
  4025. onlyOnce) {
  4026. this.frame = frame;
  4027. this.action = action;
  4028. this.onlyOnce = onlyOnce;
  4029. /**
  4030. * Specifies if the animation event is done
  4031. */
  4032. this.isDone = false;
  4033. }
  4034. /** @hidden */
  4035. AnimationEvent.prototype._clone = function () {
  4036. return new AnimationEvent(this.frame, this.action, this.onlyOnce);
  4037. };
  4038. return AnimationEvent;
  4039. }());
  4040. /***/ }),
  4041. /***/ "./Animations/animationGroup.ts":
  4042. /*!**************************************!*\
  4043. !*** ./Animations/animationGroup.ts ***!
  4044. \**************************************/
  4045. /*! exports provided: TargetedAnimation, AnimationGroup */
  4046. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4047. "use strict";
  4048. __webpack_require__.r(__webpack_exports__);
  4049. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return TargetedAnimation; });
  4050. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return AnimationGroup; });
  4051. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  4052. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  4053. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  4054. /**
  4055. * This class defines the direct association between an animation and a target
  4056. */
  4057. var TargetedAnimation = /** @class */ (function () {
  4058. function TargetedAnimation() {
  4059. }
  4060. return TargetedAnimation;
  4061. }());
  4062. /**
  4063. * Use this class to create coordinated animations on multiple targets
  4064. */
  4065. var AnimationGroup = /** @class */ (function () {
  4066. /**
  4067. * Instantiates a new Animation Group.
  4068. * This helps managing several animations at once.
  4069. * @see http://doc.babylonjs.com/how_to/group
  4070. * @param name Defines the name of the group
  4071. * @param scene Defines the scene the group belongs to
  4072. */
  4073. function AnimationGroup(
  4074. /** The name of the animation group */
  4075. name, scene) {
  4076. if (scene === void 0) { scene = null; }
  4077. this.name = name;
  4078. this._targetedAnimations = new Array();
  4079. this._animatables = new Array();
  4080. this._from = Number.MAX_VALUE;
  4081. this._to = -Number.MAX_VALUE;
  4082. this._speedRatio = 1;
  4083. /**
  4084. * This observable will notify when one animation have ended
  4085. */
  4086. this.onAnimationEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4087. /**
  4088. * Observer raised when one animation loops
  4089. */
  4090. this.onAnimationLoopObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4091. /**
  4092. * This observable will notify when all animations have ended.
  4093. */
  4094. this.onAnimationGroupEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4095. /**
  4096. * This observable will notify when all animations have paused.
  4097. */
  4098. this.onAnimationGroupPauseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4099. /**
  4100. * This observable will notify when all animations are playing.
  4101. */
  4102. this.onAnimationGroupPlayObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  4103. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  4104. this.uniqueId = this._scene.getUniqueId();
  4105. this._scene.animationGroups.push(this);
  4106. }
  4107. Object.defineProperty(AnimationGroup.prototype, "from", {
  4108. /**
  4109. * Gets the first frame
  4110. */
  4111. get: function () {
  4112. return this._from;
  4113. },
  4114. enumerable: true,
  4115. configurable: true
  4116. });
  4117. Object.defineProperty(AnimationGroup.prototype, "to", {
  4118. /**
  4119. * Gets the last frame
  4120. */
  4121. get: function () {
  4122. return this._to;
  4123. },
  4124. enumerable: true,
  4125. configurable: true
  4126. });
  4127. Object.defineProperty(AnimationGroup.prototype, "isStarted", {
  4128. /**
  4129. * Define if the animations are started
  4130. */
  4131. get: function () {
  4132. return this._isStarted;
  4133. },
  4134. enumerable: true,
  4135. configurable: true
  4136. });
  4137. Object.defineProperty(AnimationGroup.prototype, "isPlaying", {
  4138. /**
  4139. * Gets a value indicating that the current group is playing
  4140. */
  4141. get: function () {
  4142. return this._isStarted && !this._isPaused;
  4143. },
  4144. enumerable: true,
  4145. configurable: true
  4146. });
  4147. Object.defineProperty(AnimationGroup.prototype, "speedRatio", {
  4148. /**
  4149. * Gets or sets the speed ratio to use for all animations
  4150. */
  4151. get: function () {
  4152. return this._speedRatio;
  4153. },
  4154. /**
  4155. * Gets or sets the speed ratio to use for all animations
  4156. */
  4157. set: function (value) {
  4158. if (this._speedRatio === value) {
  4159. return;
  4160. }
  4161. this._speedRatio = value;
  4162. for (var index = 0; index < this._animatables.length; index++) {
  4163. var animatable = this._animatables[index];
  4164. animatable.speedRatio = this._speedRatio;
  4165. }
  4166. },
  4167. enumerable: true,
  4168. configurable: true
  4169. });
  4170. Object.defineProperty(AnimationGroup.prototype, "targetedAnimations", {
  4171. /**
  4172. * Gets the targeted animations for this animation group
  4173. */
  4174. get: function () {
  4175. return this._targetedAnimations;
  4176. },
  4177. enumerable: true,
  4178. configurable: true
  4179. });
  4180. Object.defineProperty(AnimationGroup.prototype, "animatables", {
  4181. /**
  4182. * returning the list of animatables controlled by this animation group.
  4183. */
  4184. get: function () {
  4185. return this._animatables;
  4186. },
  4187. enumerable: true,
  4188. configurable: true
  4189. });
  4190. /**
  4191. * Add an animation (with its target) in the group
  4192. * @param animation defines the animation we want to add
  4193. * @param target defines the target of the animation
  4194. * @returns the TargetedAnimation object
  4195. */
  4196. AnimationGroup.prototype.addTargetedAnimation = function (animation, target) {
  4197. var targetedAnimation = {
  4198. animation: animation,
  4199. target: target
  4200. };
  4201. var keys = animation.getKeys();
  4202. if (this._from > keys[0].frame) {
  4203. this._from = keys[0].frame;
  4204. }
  4205. if (this._to < keys[keys.length - 1].frame) {
  4206. this._to = keys[keys.length - 1].frame;
  4207. }
  4208. this._targetedAnimations.push(targetedAnimation);
  4209. return targetedAnimation;
  4210. };
  4211. /**
  4212. * This function will normalize every animation in the group to make sure they all go from beginFrame to endFrame
  4213. * It can add constant keys at begin or end
  4214. * @param beginFrame defines the new begin frame for all animations or the smallest begin frame of all animations if null (defaults to null)
  4215. * @param endFrame defines the new end frame for all animations or the largest end frame of all animations if null (defaults to null)
  4216. * @returns the animation group
  4217. */
  4218. AnimationGroup.prototype.normalize = function (beginFrame, endFrame) {
  4219. if (beginFrame === void 0) { beginFrame = null; }
  4220. if (endFrame === void 0) { endFrame = null; }
  4221. if (beginFrame == null) {
  4222. beginFrame = this._from;
  4223. }
  4224. if (endFrame == null) {
  4225. endFrame = this._to;
  4226. }
  4227. for (var index = 0; index < this._targetedAnimations.length; index++) {
  4228. var targetedAnimation = this._targetedAnimations[index];
  4229. var keys = targetedAnimation.animation.getKeys();
  4230. var startKey = keys[0];
  4231. var endKey = keys[keys.length - 1];
  4232. if (startKey.frame > beginFrame) {
  4233. var newKey = {
  4234. frame: beginFrame,
  4235. value: startKey.value,
  4236. inTangent: startKey.inTangent,
  4237. outTangent: startKey.outTangent,
  4238. interpolation: startKey.interpolation
  4239. };
  4240. keys.splice(0, 0, newKey);
  4241. }
  4242. if (endKey.frame < endFrame) {
  4243. var newKey = {
  4244. frame: endFrame,
  4245. value: endKey.value,
  4246. inTangent: endKey.outTangent,
  4247. outTangent: endKey.outTangent,
  4248. interpolation: endKey.interpolation
  4249. };
  4250. keys.push(newKey);
  4251. }
  4252. }
  4253. this._from = beginFrame;
  4254. this._to = endFrame;
  4255. return this;
  4256. };
  4257. /**
  4258. * Start all animations on given targets
  4259. * @param loop defines if animations must loop
  4260. * @param speedRatio defines the ratio to apply to animation speed (1 by default)
  4261. * @param from defines the from key (optional)
  4262. * @param to defines the to key (optional)
  4263. * @returns the current animation group
  4264. */
  4265. AnimationGroup.prototype.start = function (loop, speedRatio, from, to) {
  4266. var _this = this;
  4267. if (loop === void 0) { loop = false; }
  4268. if (speedRatio === void 0) { speedRatio = 1; }
  4269. if (this._isStarted || this._targetedAnimations.length === 0) {
  4270. return this;
  4271. }
  4272. var _loop_1 = function (targetedAnimation) {
  4273. var animatable = this_1._scene.beginDirectAnimation(targetedAnimation.target, [targetedAnimation.animation], from !== undefined ? from : this_1._from, to !== undefined ? to : this_1._to, loop, speedRatio);
  4274. animatable.onAnimationEnd = function () {
  4275. _this.onAnimationEndObservable.notifyObservers(targetedAnimation);
  4276. _this._checkAnimationGroupEnded(animatable);
  4277. };
  4278. animatable.onAnimationLoop = function () {
  4279. _this.onAnimationLoopObservable.notifyObservers(targetedAnimation);
  4280. };
  4281. this_1._animatables.push(animatable);
  4282. };
  4283. var this_1 = this;
  4284. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4285. var targetedAnimation = _a[_i];
  4286. _loop_1(targetedAnimation);
  4287. }
  4288. this._speedRatio = speedRatio;
  4289. if (from !== undefined && to !== undefined && from > to && this._speedRatio > 0) {
  4290. this._speedRatio = -speedRatio;
  4291. }
  4292. this._isStarted = true;
  4293. this._isPaused = false;
  4294. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4295. return this;
  4296. };
  4297. /**
  4298. * Pause all animations
  4299. * @returns the animation group
  4300. */
  4301. AnimationGroup.prototype.pause = function () {
  4302. if (!this._isStarted) {
  4303. return this;
  4304. }
  4305. this._isPaused = true;
  4306. for (var index = 0; index < this._animatables.length; index++) {
  4307. var animatable = this._animatables[index];
  4308. animatable.pause();
  4309. }
  4310. this.onAnimationGroupPauseObservable.notifyObservers(this);
  4311. return this;
  4312. };
  4313. /**
  4314. * Play all animations to initial state
  4315. * This function will start() the animations if they were not started or will restart() them if they were paused
  4316. * @param loop defines if animations must loop
  4317. * @returns the animation group
  4318. */
  4319. AnimationGroup.prototype.play = function (loop) {
  4320. // only if all animatables are ready and exist
  4321. if (this.isStarted && this._animatables.length === this._targetedAnimations.length) {
  4322. if (loop !== undefined) {
  4323. for (var index = 0; index < this._animatables.length; index++) {
  4324. var animatable = this._animatables[index];
  4325. animatable.loopAnimation = loop;
  4326. }
  4327. }
  4328. this.restart();
  4329. }
  4330. else {
  4331. this.stop();
  4332. this.start(loop, this._speedRatio);
  4333. }
  4334. this._isPaused = false;
  4335. return this;
  4336. };
  4337. /**
  4338. * Reset all animations to initial state
  4339. * @returns the animation group
  4340. */
  4341. AnimationGroup.prototype.reset = function () {
  4342. if (!this._isStarted) {
  4343. return this;
  4344. }
  4345. for (var index = 0; index < this._animatables.length; index++) {
  4346. var animatable = this._animatables[index];
  4347. animatable.reset();
  4348. }
  4349. return this;
  4350. };
  4351. /**
  4352. * Restart animations from key 0
  4353. * @returns the animation group
  4354. */
  4355. AnimationGroup.prototype.restart = function () {
  4356. if (!this._isStarted) {
  4357. return this;
  4358. }
  4359. for (var index = 0; index < this._animatables.length; index++) {
  4360. var animatable = this._animatables[index];
  4361. animatable.restart();
  4362. }
  4363. this.onAnimationGroupPlayObservable.notifyObservers(this);
  4364. return this;
  4365. };
  4366. /**
  4367. * Stop all animations
  4368. * @returns the animation group
  4369. */
  4370. AnimationGroup.prototype.stop = function () {
  4371. if (!this._isStarted) {
  4372. return this;
  4373. }
  4374. var list = this._animatables.slice();
  4375. for (var index = 0; index < list.length; index++) {
  4376. list[index].stop();
  4377. }
  4378. this._isStarted = false;
  4379. return this;
  4380. };
  4381. /**
  4382. * Set animation weight for all animatables
  4383. * @param weight defines the weight to use
  4384. * @return the animationGroup
  4385. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4386. */
  4387. AnimationGroup.prototype.setWeightForAllAnimatables = function (weight) {
  4388. for (var index = 0; index < this._animatables.length; index++) {
  4389. var animatable = this._animatables[index];
  4390. animatable.weight = weight;
  4391. }
  4392. return this;
  4393. };
  4394. /**
  4395. * Synchronize and normalize all animatables with a source animatable
  4396. * @param root defines the root animatable to synchronize with
  4397. * @return the animationGroup
  4398. * @see http://doc.babylonjs.com/babylon101/animations#animation-weights
  4399. */
  4400. AnimationGroup.prototype.syncAllAnimationsWith = function (root) {
  4401. for (var index = 0; index < this._animatables.length; index++) {
  4402. var animatable = this._animatables[index];
  4403. animatable.syncWith(root);
  4404. }
  4405. return this;
  4406. };
  4407. /**
  4408. * Goes to a specific frame in this animation group
  4409. * @param frame the frame number to go to
  4410. * @return the animationGroup
  4411. */
  4412. AnimationGroup.prototype.goToFrame = function (frame) {
  4413. if (!this._isStarted) {
  4414. return this;
  4415. }
  4416. for (var index = 0; index < this._animatables.length; index++) {
  4417. var animatable = this._animatables[index];
  4418. animatable.goToFrame(frame);
  4419. }
  4420. return this;
  4421. };
  4422. /**
  4423. * Dispose all associated resources
  4424. */
  4425. AnimationGroup.prototype.dispose = function () {
  4426. this._targetedAnimations = [];
  4427. this._animatables = [];
  4428. var index = this._scene.animationGroups.indexOf(this);
  4429. if (index > -1) {
  4430. this._scene.animationGroups.splice(index, 1);
  4431. }
  4432. this.onAnimationEndObservable.clear();
  4433. this.onAnimationGroupEndObservable.clear();
  4434. this.onAnimationGroupPauseObservable.clear();
  4435. this.onAnimationGroupPlayObservable.clear();
  4436. this.onAnimationLoopObservable.clear();
  4437. };
  4438. AnimationGroup.prototype._checkAnimationGroupEnded = function (animatable) {
  4439. // animatable should be taken out of the array
  4440. var idx = this._animatables.indexOf(animatable);
  4441. if (idx > -1) {
  4442. this._animatables.splice(idx, 1);
  4443. }
  4444. // all animatables were removed? animation group ended!
  4445. if (this._animatables.length === 0) {
  4446. this._isStarted = false;
  4447. this.onAnimationGroupEndObservable.notifyObservers(this);
  4448. }
  4449. };
  4450. /**
  4451. * Clone the current animation group and returns a copy
  4452. * @param newName defines the name of the new group
  4453. * @param targetConverter defines an optional function used to convert current animation targets to new ones
  4454. * @returns the new aniamtion group
  4455. */
  4456. AnimationGroup.prototype.clone = function (newName, targetConverter) {
  4457. var newGroup = new AnimationGroup(newName || this.name, this._scene);
  4458. for (var _i = 0, _a = this._targetedAnimations; _i < _a.length; _i++) {
  4459. var targetAnimation = _a[_i];
  4460. newGroup.addTargetedAnimation(targetAnimation.animation.clone(), targetConverter ? targetConverter(targetAnimation.target) : targetAnimation.target);
  4461. }
  4462. return newGroup;
  4463. };
  4464. // Statics
  4465. /**
  4466. * Returns a new AnimationGroup object parsed from the source provided.
  4467. * @param parsedAnimationGroup defines the source
  4468. * @param scene defines the scene that will receive the animationGroup
  4469. * @returns a new AnimationGroup
  4470. */
  4471. AnimationGroup.Parse = function (parsedAnimationGroup, scene) {
  4472. var animationGroup = new AnimationGroup(parsedAnimationGroup.name, scene);
  4473. for (var i = 0; i < parsedAnimationGroup.targetedAnimations.length; i++) {
  4474. var targetedAnimation = parsedAnimationGroup.targetedAnimations[i];
  4475. var animation = _animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].Parse(targetedAnimation.animation);
  4476. var id = targetedAnimation.targetId;
  4477. if (targetedAnimation.animation.property === "influence") { // morph target animation
  4478. var morphTarget = scene.getMorphTargetById(id);
  4479. if (morphTarget) {
  4480. animationGroup.addTargetedAnimation(animation, morphTarget);
  4481. }
  4482. }
  4483. else {
  4484. var targetNode = scene.getNodeByID(id);
  4485. if (targetNode != null) {
  4486. animationGroup.addTargetedAnimation(animation, targetNode);
  4487. }
  4488. }
  4489. }
  4490. if (parsedAnimationGroup.from !== null && parsedAnimationGroup.from !== null) {
  4491. animationGroup.normalize(parsedAnimationGroup.from, parsedAnimationGroup.to);
  4492. }
  4493. return animationGroup;
  4494. };
  4495. /**
  4496. * Returns the string "AnimationGroup"
  4497. * @returns "AnimationGroup"
  4498. */
  4499. AnimationGroup.prototype.getClassName = function () {
  4500. return "AnimationGroup";
  4501. };
  4502. /**
  4503. * Creates a detailled string about the object
  4504. * @param fullDetails defines if the output string will support multiple levels of logging within scene loading
  4505. * @returns a string representing the object
  4506. */
  4507. AnimationGroup.prototype.toString = function (fullDetails) {
  4508. var ret = "Name: " + this.name;
  4509. ret += ", type: " + this.getClassName();
  4510. if (fullDetails) {
  4511. ret += ", from: " + this._from;
  4512. ret += ", to: " + this._to;
  4513. ret += ", isStarted: " + this._isStarted;
  4514. ret += ", speedRatio: " + this._speedRatio;
  4515. ret += ", targetedAnimations length: " + this._targetedAnimations.length;
  4516. ret += ", animatables length: " + this._animatables;
  4517. }
  4518. return ret;
  4519. };
  4520. return AnimationGroup;
  4521. }());
  4522. /***/ }),
  4523. /***/ "./Animations/animationKey.ts":
  4524. /*!************************************!*\
  4525. !*** ./Animations/animationKey.ts ***!
  4526. \************************************/
  4527. /*! exports provided: AnimationKeyInterpolation */
  4528. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4529. "use strict";
  4530. __webpack_require__.r(__webpack_exports__);
  4531. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return AnimationKeyInterpolation; });
  4532. /**
  4533. * Enum for the animation key frame interpolation type
  4534. */
  4535. var AnimationKeyInterpolation;
  4536. (function (AnimationKeyInterpolation) {
  4537. /**
  4538. * Do not interpolate between keys and use the start key value only. Tangents are ignored
  4539. */
  4540. AnimationKeyInterpolation[AnimationKeyInterpolation["STEP"] = 1] = "STEP";
  4541. })(AnimationKeyInterpolation || (AnimationKeyInterpolation = {}));
  4542. /***/ }),
  4543. /***/ "./Animations/animationPropertiesOverride.ts":
  4544. /*!***************************************************!*\
  4545. !*** ./Animations/animationPropertiesOverride.ts ***!
  4546. \***************************************************/
  4547. /*! exports provided: AnimationPropertiesOverride */
  4548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4549. "use strict";
  4550. __webpack_require__.r(__webpack_exports__);
  4551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return AnimationPropertiesOverride; });
  4552. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  4553. /**
  4554. * Class used to override all child animations of a given target
  4555. */
  4556. var AnimationPropertiesOverride = /** @class */ (function () {
  4557. function AnimationPropertiesOverride() {
  4558. /**
  4559. * Gets or sets a value indicating if animation blending must be used
  4560. */
  4561. this.enableBlending = false;
  4562. /**
  4563. * Gets or sets the blending speed to use when enableBlending is true
  4564. */
  4565. this.blendingSpeed = 0.01;
  4566. /**
  4567. * Gets or sets the default loop mode to use
  4568. */
  4569. this.loopMode = _Animations_animation__WEBPACK_IMPORTED_MODULE_0__["Animation"].ANIMATIONLOOPMODE_CYCLE;
  4570. }
  4571. return AnimationPropertiesOverride;
  4572. }());
  4573. /***/ }),
  4574. /***/ "./Animations/animationRange.ts":
  4575. /*!**************************************!*\
  4576. !*** ./Animations/animationRange.ts ***!
  4577. \**************************************/
  4578. /*! exports provided: AnimationRange */
  4579. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4580. "use strict";
  4581. __webpack_require__.r(__webpack_exports__);
  4582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return AnimationRange; });
  4583. /**
  4584. * Represents the range of an animation
  4585. */
  4586. var AnimationRange = /** @class */ (function () {
  4587. /**
  4588. * Initializes the range of an animation
  4589. * @param name The name of the animation range
  4590. * @param from The starting frame of the animation
  4591. * @param to The ending frame of the animation
  4592. */
  4593. function AnimationRange(
  4594. /**The name of the animation range**/
  4595. name,
  4596. /**The starting frame of the animation */
  4597. from,
  4598. /**The ending frame of the animation*/
  4599. to) {
  4600. this.name = name;
  4601. this.from = from;
  4602. this.to = to;
  4603. }
  4604. /**
  4605. * Makes a copy of the animation range
  4606. * @returns A copy of the animation range
  4607. */
  4608. AnimationRange.prototype.clone = function () {
  4609. return new AnimationRange(this.name, this.from, this.to);
  4610. };
  4611. return AnimationRange;
  4612. }());
  4613. /***/ }),
  4614. /***/ "./Animations/easing.ts":
  4615. /*!******************************!*\
  4616. !*** ./Animations/easing.ts ***!
  4617. \******************************/
  4618. /*! exports provided: EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase */
  4619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  4620. "use strict";
  4621. __webpack_require__.r(__webpack_exports__);
  4622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return EasingFunction; });
  4623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return CircleEase; });
  4624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return BackEase; });
  4625. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return BounceEase; });
  4626. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return CubicEase; });
  4627. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return ElasticEase; });
  4628. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return ExponentialEase; });
  4629. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return PowerEase; });
  4630. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return QuadraticEase; });
  4631. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return QuarticEase; });
  4632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return QuinticEase; });
  4633. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return SineEase; });
  4634. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return BezierCurveEase; });
  4635. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  4636. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  4637. /**
  4638. * Base class used for every default easing function.
  4639. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4640. */
  4641. var EasingFunction = /** @class */ (function () {
  4642. function EasingFunction() {
  4643. this._easingMode = EasingFunction.EASINGMODE_EASEIN;
  4644. }
  4645. /**
  4646. * Sets the easing mode of the current function.
  4647. * @param easingMode Defines the willing mode (EASINGMODE_EASEIN, EASINGMODE_EASEOUT or EASINGMODE_EASEINOUT)
  4648. */
  4649. EasingFunction.prototype.setEasingMode = function (easingMode) {
  4650. var n = Math.min(Math.max(easingMode, 0), 2);
  4651. this._easingMode = n;
  4652. };
  4653. /**
  4654. * Gets the current easing mode.
  4655. * @returns the easing mode
  4656. */
  4657. EasingFunction.prototype.getEasingMode = function () {
  4658. return this._easingMode;
  4659. };
  4660. /**
  4661. * @hidden
  4662. */
  4663. EasingFunction.prototype.easeInCore = function (gradient) {
  4664. throw new Error('You must implement this method');
  4665. };
  4666. /**
  4667. * Given an input gradient between 0 and 1, this returns the corrseponding value
  4668. * of the easing function.
  4669. * @param gradient Defines the value between 0 and 1 we want the easing value for
  4670. * @returns the corresponding value on the curve defined by the easing function
  4671. */
  4672. EasingFunction.prototype.ease = function (gradient) {
  4673. switch (this._easingMode) {
  4674. case EasingFunction.EASINGMODE_EASEIN:
  4675. return this.easeInCore(gradient);
  4676. case EasingFunction.EASINGMODE_EASEOUT:
  4677. return (1 - this.easeInCore(1 - gradient));
  4678. }
  4679. if (gradient >= 0.5) {
  4680. return (((1 - this.easeInCore((1 - gradient) * 2)) * 0.5) + 0.5);
  4681. }
  4682. return (this.easeInCore(gradient * 2) * 0.5);
  4683. };
  4684. /**
  4685. * Interpolation follows the mathematical formula associated with the easing function.
  4686. */
  4687. EasingFunction.EASINGMODE_EASEIN = 0;
  4688. /**
  4689. * Interpolation follows 100% interpolation minus the output of the formula associated with the easing function.
  4690. */
  4691. EasingFunction.EASINGMODE_EASEOUT = 1;
  4692. /**
  4693. * Interpolation uses EaseIn for the first half of the animation and EaseOut for the second half.
  4694. */
  4695. EasingFunction.EASINGMODE_EASEINOUT = 2;
  4696. return EasingFunction;
  4697. }());
  4698. /**
  4699. * Easing function with a circle shape (see link below).
  4700. * @see https://easings.net/#easeInCirc
  4701. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4702. */
  4703. var CircleEase = /** @class */ (function (_super) {
  4704. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleEase, _super);
  4705. function CircleEase() {
  4706. return _super !== null && _super.apply(this, arguments) || this;
  4707. }
  4708. /** @hidden */
  4709. CircleEase.prototype.easeInCore = function (gradient) {
  4710. gradient = Math.max(0, Math.min(1, gradient));
  4711. return (1.0 - Math.sqrt(1.0 - (gradient * gradient)));
  4712. };
  4713. return CircleEase;
  4714. }(EasingFunction));
  4715. /**
  4716. * Easing function with a ease back shape (see link below).
  4717. * @see https://easings.net/#easeInBack
  4718. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4719. */
  4720. var BackEase = /** @class */ (function (_super) {
  4721. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackEase, _super);
  4722. /**
  4723. * Instantiates a back ease easing
  4724. * @see https://easings.net/#easeInBack
  4725. * @param amplitude Defines the amplitude of the function
  4726. */
  4727. function BackEase(
  4728. /** Defines the amplitude of the function */
  4729. amplitude) {
  4730. if (amplitude === void 0) { amplitude = 1; }
  4731. var _this = _super.call(this) || this;
  4732. _this.amplitude = amplitude;
  4733. return _this;
  4734. }
  4735. /** @hidden */
  4736. BackEase.prototype.easeInCore = function (gradient) {
  4737. var num = Math.max(0, this.amplitude);
  4738. return (Math.pow(gradient, 3.0) - ((gradient * num) * Math.sin(3.1415926535897931 * gradient)));
  4739. };
  4740. return BackEase;
  4741. }(EasingFunction));
  4742. /**
  4743. * Easing function with a bouncing shape (see link below).
  4744. * @see https://easings.net/#easeInBounce
  4745. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4746. */
  4747. var BounceEase = /** @class */ (function (_super) {
  4748. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BounceEase, _super);
  4749. /**
  4750. * Instantiates a bounce easing
  4751. * @see https://easings.net/#easeInBounce
  4752. * @param bounces Defines the number of bounces
  4753. * @param bounciness Defines the amplitude of the bounce
  4754. */
  4755. function BounceEase(
  4756. /** Defines the number of bounces */
  4757. bounces,
  4758. /** Defines the amplitude of the bounce */
  4759. bounciness) {
  4760. if (bounces === void 0) { bounces = 3; }
  4761. if (bounciness === void 0) { bounciness = 2; }
  4762. var _this = _super.call(this) || this;
  4763. _this.bounces = bounces;
  4764. _this.bounciness = bounciness;
  4765. return _this;
  4766. }
  4767. /** @hidden */
  4768. BounceEase.prototype.easeInCore = function (gradient) {
  4769. var y = Math.max(0.0, this.bounces);
  4770. var bounciness = this.bounciness;
  4771. if (bounciness <= 1.0) {
  4772. bounciness = 1.001;
  4773. }
  4774. var num9 = Math.pow(bounciness, y);
  4775. var num5 = 1.0 - bounciness;
  4776. var num4 = ((1.0 - num9) / num5) + (num9 * 0.5);
  4777. var num15 = gradient * num4;
  4778. var num65 = Math.log((-num15 * (1.0 - bounciness)) + 1.0) / Math.log(bounciness);
  4779. var num3 = Math.floor(num65);
  4780. var num13 = num3 + 1.0;
  4781. var num8 = (1.0 - Math.pow(bounciness, num3)) / (num5 * num4);
  4782. var num12 = (1.0 - Math.pow(bounciness, num13)) / (num5 * num4);
  4783. var num7 = (num8 + num12) * 0.5;
  4784. var num6 = gradient - num7;
  4785. var num2 = num7 - num8;
  4786. return (((-Math.pow(1.0 / bounciness, y - num3) / (num2 * num2)) * (num6 - num2)) * (num6 + num2));
  4787. };
  4788. return BounceEase;
  4789. }(EasingFunction));
  4790. /**
  4791. * Easing function with a power of 3 shape (see link below).
  4792. * @see https://easings.net/#easeInCubic
  4793. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4794. */
  4795. var CubicEase = /** @class */ (function (_super) {
  4796. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubicEase, _super);
  4797. function CubicEase() {
  4798. return _super !== null && _super.apply(this, arguments) || this;
  4799. }
  4800. /** @hidden */
  4801. CubicEase.prototype.easeInCore = function (gradient) {
  4802. return (gradient * gradient * gradient);
  4803. };
  4804. return CubicEase;
  4805. }(EasingFunction));
  4806. /**
  4807. * Easing function with an elastic shape (see link below).
  4808. * @see https://easings.net/#easeInElastic
  4809. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4810. */
  4811. var ElasticEase = /** @class */ (function (_super) {
  4812. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ElasticEase, _super);
  4813. /**
  4814. * Instantiates an elastic easing function
  4815. * @see https://easings.net/#easeInElastic
  4816. * @param oscillations Defines the number of oscillations
  4817. * @param springiness Defines the amplitude of the oscillations
  4818. */
  4819. function ElasticEase(
  4820. /** Defines the number of oscillations*/
  4821. oscillations,
  4822. /** Defines the amplitude of the oscillations*/
  4823. springiness) {
  4824. if (oscillations === void 0) { oscillations = 3; }
  4825. if (springiness === void 0) { springiness = 3; }
  4826. var _this = _super.call(this) || this;
  4827. _this.oscillations = oscillations;
  4828. _this.springiness = springiness;
  4829. return _this;
  4830. }
  4831. /** @hidden */
  4832. ElasticEase.prototype.easeInCore = function (gradient) {
  4833. var num2;
  4834. var num3 = Math.max(0.0, this.oscillations);
  4835. var num = Math.max(0.0, this.springiness);
  4836. if (num == 0) {
  4837. num2 = gradient;
  4838. }
  4839. else {
  4840. num2 = (Math.exp(num * gradient) - 1.0) / (Math.exp(num) - 1.0);
  4841. }
  4842. return (num2 * Math.sin(((6.2831853071795862 * num3) + 1.5707963267948966) * gradient));
  4843. };
  4844. return ElasticEase;
  4845. }(EasingFunction));
  4846. /**
  4847. * Easing function with an exponential shape (see link below).
  4848. * @see https://easings.net/#easeInExpo
  4849. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4850. */
  4851. var ExponentialEase = /** @class */ (function (_super) {
  4852. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExponentialEase, _super);
  4853. /**
  4854. * Instantiates an exponential easing function
  4855. * @see https://easings.net/#easeInExpo
  4856. * @param exponent Defines the exponent of the function
  4857. */
  4858. function ExponentialEase(
  4859. /** Defines the exponent of the function */
  4860. exponent) {
  4861. if (exponent === void 0) { exponent = 2; }
  4862. var _this = _super.call(this) || this;
  4863. _this.exponent = exponent;
  4864. return _this;
  4865. }
  4866. /** @hidden */
  4867. ExponentialEase.prototype.easeInCore = function (gradient) {
  4868. if (this.exponent <= 0) {
  4869. return gradient;
  4870. }
  4871. return ((Math.exp(this.exponent * gradient) - 1.0) / (Math.exp(this.exponent) - 1.0));
  4872. };
  4873. return ExponentialEase;
  4874. }(EasingFunction));
  4875. /**
  4876. * Easing function with a power shape (see link below).
  4877. * @see https://easings.net/#easeInQuad
  4878. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4879. */
  4880. var PowerEase = /** @class */ (function (_super) {
  4881. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PowerEase, _super);
  4882. /**
  4883. * Instantiates an power base easing function
  4884. * @see https://easings.net/#easeInQuad
  4885. * @param power Defines the power of the function
  4886. */
  4887. function PowerEase(
  4888. /** Defines the power of the function */
  4889. power) {
  4890. if (power === void 0) { power = 2; }
  4891. var _this = _super.call(this) || this;
  4892. _this.power = power;
  4893. return _this;
  4894. }
  4895. /** @hidden */
  4896. PowerEase.prototype.easeInCore = function (gradient) {
  4897. var y = Math.max(0.0, this.power);
  4898. return Math.pow(gradient, y);
  4899. };
  4900. return PowerEase;
  4901. }(EasingFunction));
  4902. /**
  4903. * Easing function with a power of 2 shape (see link below).
  4904. * @see https://easings.net/#easeInQuad
  4905. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4906. */
  4907. var QuadraticEase = /** @class */ (function (_super) {
  4908. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuadraticEase, _super);
  4909. function QuadraticEase() {
  4910. return _super !== null && _super.apply(this, arguments) || this;
  4911. }
  4912. /** @hidden */
  4913. QuadraticEase.prototype.easeInCore = function (gradient) {
  4914. return (gradient * gradient);
  4915. };
  4916. return QuadraticEase;
  4917. }(EasingFunction));
  4918. /**
  4919. * Easing function with a power of 4 shape (see link below).
  4920. * @see https://easings.net/#easeInQuart
  4921. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4922. */
  4923. var QuarticEase = /** @class */ (function (_super) {
  4924. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuarticEase, _super);
  4925. function QuarticEase() {
  4926. return _super !== null && _super.apply(this, arguments) || this;
  4927. }
  4928. /** @hidden */
  4929. QuarticEase.prototype.easeInCore = function (gradient) {
  4930. return (gradient * gradient * gradient * gradient);
  4931. };
  4932. return QuarticEase;
  4933. }(EasingFunction));
  4934. /**
  4935. * Easing function with a power of 5 shape (see link below).
  4936. * @see https://easings.net/#easeInQuint
  4937. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4938. */
  4939. var QuinticEase = /** @class */ (function (_super) {
  4940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](QuinticEase, _super);
  4941. function QuinticEase() {
  4942. return _super !== null && _super.apply(this, arguments) || this;
  4943. }
  4944. /** @hidden */
  4945. QuinticEase.prototype.easeInCore = function (gradient) {
  4946. return (gradient * gradient * gradient * gradient * gradient);
  4947. };
  4948. return QuinticEase;
  4949. }(EasingFunction));
  4950. /**
  4951. * Easing function with a sin shape (see link below).
  4952. * @see https://easings.net/#easeInSine
  4953. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4954. */
  4955. var SineEase = /** @class */ (function (_super) {
  4956. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SineEase, _super);
  4957. function SineEase() {
  4958. return _super !== null && _super.apply(this, arguments) || this;
  4959. }
  4960. /** @hidden */
  4961. SineEase.prototype.easeInCore = function (gradient) {
  4962. return (1.0 - Math.sin(1.5707963267948966 * (1.0 - gradient)));
  4963. };
  4964. return SineEase;
  4965. }(EasingFunction));
  4966. /**
  4967. * Easing function with a bezier shape (see link below).
  4968. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4969. * @see http://doc.babylonjs.com/babylon101/animations#easing-functions
  4970. */
  4971. var BezierCurveEase = /** @class */ (function (_super) {
  4972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BezierCurveEase, _super);
  4973. /**
  4974. * Instantiates a bezier function
  4975. * @see http://cubic-bezier.com/#.17,.67,.83,.67
  4976. * @param x1 Defines the x component of the start tangent in the bezier curve
  4977. * @param y1 Defines the y component of the start tangent in the bezier curve
  4978. * @param x2 Defines the x component of the end tangent in the bezier curve
  4979. * @param y2 Defines the y component of the end tangent in the bezier curve
  4980. */
  4981. function BezierCurveEase(
  4982. /** Defines the x component of the start tangent in the bezier curve */
  4983. x1,
  4984. /** Defines the y component of the start tangent in the bezier curve */
  4985. y1,
  4986. /** Defines the x component of the end tangent in the bezier curve */
  4987. x2,
  4988. /** Defines the y component of the end tangent in the bezier curve */
  4989. y2) {
  4990. if (x1 === void 0) { x1 = 0; }
  4991. if (y1 === void 0) { y1 = 0; }
  4992. if (x2 === void 0) { x2 = 1; }
  4993. if (y2 === void 0) { y2 = 1; }
  4994. var _this = _super.call(this) || this;
  4995. _this.x1 = x1;
  4996. _this.y1 = y1;
  4997. _this.x2 = x2;
  4998. _this.y2 = y2;
  4999. return _this;
  5000. }
  5001. /** @hidden */
  5002. BezierCurveEase.prototype.easeInCore = function (gradient) {
  5003. return _Maths_math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"].Interpolate(gradient, this.x1, this.y1, this.x2, this.y2);
  5004. };
  5005. return BezierCurveEase;
  5006. }(EasingFunction));
  5007. /***/ }),
  5008. /***/ "./Animations/index.ts":
  5009. /*!*****************************!*\
  5010. !*** ./Animations/index.ts ***!
  5011. \*****************************/
  5012. /*! exports provided: Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange */
  5013. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5014. "use strict";
  5015. __webpack_require__.r(__webpack_exports__);
  5016. /* harmony import */ var _animatable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./animatable */ "./Animations/animatable.ts");
  5017. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _animatable__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  5018. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5019. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]; });
  5020. /* harmony import */ var _animationGroup__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./animationGroup */ "./Animations/animationGroup.ts");
  5021. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  5022. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _animationGroup__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  5023. /* harmony import */ var _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./animationPropertiesOverride */ "./Animations/animationPropertiesOverride.ts");
  5024. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _animationPropertiesOverride__WEBPACK_IMPORTED_MODULE_3__["AnimationPropertiesOverride"]; });
  5025. /* harmony import */ var _easing__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./easing */ "./Animations/easing.ts");
  5026. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["EasingFunction"]; });
  5027. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CircleEase"]; });
  5028. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BackEase"]; });
  5029. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BounceEase"]; });
  5030. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["CubicEase"]; });
  5031. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ElasticEase"]; });
  5032. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["ExponentialEase"]; });
  5033. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["PowerEase"]; });
  5034. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuadraticEase"]; });
  5035. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuarticEase"]; });
  5036. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["QuinticEase"]; });
  5037. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["SineEase"]; });
  5038. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _easing__WEBPACK_IMPORTED_MODULE_4__["BezierCurveEase"]; });
  5039. /* harmony import */ var _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./runtimeAnimation */ "./Animations/runtimeAnimation.ts");
  5040. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _runtimeAnimation__WEBPACK_IMPORTED_MODULE_5__["RuntimeAnimation"]; });
  5041. /* harmony import */ var _animationEvent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./animationEvent */ "./Animations/animationEvent.ts");
  5042. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _animationEvent__WEBPACK_IMPORTED_MODULE_6__["AnimationEvent"]; });
  5043. /* empty/unused harmony star reexport *//* harmony import */ var _animationKey__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./animationKey */ "./Animations/animationKey.ts");
  5044. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _animationKey__WEBPACK_IMPORTED_MODULE_7__["AnimationKeyInterpolation"]; });
  5045. /* harmony import */ var _animationRange__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./animationRange */ "./Animations/animationRange.ts");
  5046. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _animationRange__WEBPACK_IMPORTED_MODULE_8__["AnimationRange"]; });
  5047. /***/ }),
  5048. /***/ "./Animations/runtimeAnimation.ts":
  5049. /*!****************************************!*\
  5050. !*** ./Animations/runtimeAnimation.ts ***!
  5051. \****************************************/
  5052. /*! exports provided: RuntimeAnimation */
  5053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5054. "use strict";
  5055. __webpack_require__.r(__webpack_exports__);
  5056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return RuntimeAnimation; });
  5057. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  5058. /* harmony import */ var _animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./animation */ "./Animations/animation.ts");
  5059. // Static values to help the garbage collector
  5060. // Quaternion
  5061. var _staticOffsetValueQuaternion = Object.freeze(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"](0, 0, 0, 0));
  5062. // Vector3
  5063. var _staticOffsetValueVector3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero());
  5064. // Vector2
  5065. var _staticOffsetValueVector2 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero());
  5066. // Size
  5067. var _staticOffsetValueSize = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Size"].Zero());
  5068. // Color3
  5069. var _staticOffsetValueColor3 = Object.freeze(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Black());
  5070. /**
  5071. * Defines a runtime animation
  5072. */
  5073. var RuntimeAnimation = /** @class */ (function () {
  5074. /**
  5075. * Create a new RuntimeAnimation object
  5076. * @param target defines the target of the animation
  5077. * @param animation defines the source animation object
  5078. * @param scene defines the hosting scene
  5079. * @param host defines the initiating Animatable
  5080. */
  5081. function RuntimeAnimation(target, animation, scene, host) {
  5082. var _this = this;
  5083. this._events = new Array();
  5084. /**
  5085. * The current frame of the runtime animation
  5086. */
  5087. this._currentFrame = 0;
  5088. /**
  5089. * The original value of the runtime animation
  5090. */
  5091. this._originalValue = new Array();
  5092. /**
  5093. * The offsets cache of the runtime animation
  5094. */
  5095. this._offsetsCache = {};
  5096. /**
  5097. * The high limits cache of the runtime animation
  5098. */
  5099. this._highLimitsCache = {};
  5100. /**
  5101. * Specifies if the runtime animation has been stopped
  5102. */
  5103. this._stopped = false;
  5104. /**
  5105. * The blending factor of the runtime animation
  5106. */
  5107. this._blendingFactor = 0;
  5108. /**
  5109. * The target path of the runtime animation
  5110. */
  5111. this._targetPath = "";
  5112. /**
  5113. * The weight of the runtime animation
  5114. */
  5115. this._weight = 1.0;
  5116. /**
  5117. * The ratio offset of the runtime animation
  5118. */
  5119. this._ratioOffset = 0;
  5120. /**
  5121. * The previous delay of the runtime animation
  5122. */
  5123. this._previousDelay = 0;
  5124. /**
  5125. * The previous ratio of the runtime animation
  5126. */
  5127. this._previousRatio = 0;
  5128. this._animation = animation;
  5129. this._target = target;
  5130. this._scene = scene;
  5131. this._host = host;
  5132. animation._runtimeAnimations.push(this);
  5133. // Cloning events locally
  5134. var events = animation.getEvents();
  5135. if (events && events.length > 0) {
  5136. events.forEach(function (e) {
  5137. _this._events.push(e._clone());
  5138. });
  5139. }
  5140. }
  5141. Object.defineProperty(RuntimeAnimation.prototype, "currentFrame", {
  5142. /**
  5143. * Gets the current frame of the runtime animation
  5144. */
  5145. get: function () {
  5146. return this._currentFrame;
  5147. },
  5148. enumerable: true,
  5149. configurable: true
  5150. });
  5151. Object.defineProperty(RuntimeAnimation.prototype, "weight", {
  5152. /**
  5153. * Gets the weight of the runtime animation
  5154. */
  5155. get: function () {
  5156. return this._weight;
  5157. },
  5158. enumerable: true,
  5159. configurable: true
  5160. });
  5161. Object.defineProperty(RuntimeAnimation.prototype, "currentValue", {
  5162. /**
  5163. * Gets the current value of the runtime animation
  5164. */
  5165. get: function () {
  5166. return this._currentValue;
  5167. },
  5168. enumerable: true,
  5169. configurable: true
  5170. });
  5171. Object.defineProperty(RuntimeAnimation.prototype, "targetPath", {
  5172. /**
  5173. * Gets the target path of the runtime animation
  5174. */
  5175. get: function () {
  5176. return this._targetPath;
  5177. },
  5178. enumerable: true,
  5179. configurable: true
  5180. });
  5181. Object.defineProperty(RuntimeAnimation.prototype, "target", {
  5182. /**
  5183. * Gets the actual target of the runtime animation
  5184. */
  5185. get: function () {
  5186. return this._activeTarget;
  5187. },
  5188. enumerable: true,
  5189. configurable: true
  5190. });
  5191. Object.defineProperty(RuntimeAnimation.prototype, "animation", {
  5192. /**
  5193. * Gets the animation from the runtime animation
  5194. */
  5195. get: function () {
  5196. return this._animation;
  5197. },
  5198. enumerable: true,
  5199. configurable: true
  5200. });
  5201. /**
  5202. * Resets the runtime animation to the beginning
  5203. * @param restoreOriginal defines whether to restore the target property to the original value
  5204. */
  5205. RuntimeAnimation.prototype.reset = function (restoreOriginal) {
  5206. if (restoreOriginal === void 0) { restoreOriginal = false; }
  5207. if (restoreOriginal) {
  5208. if (this._target instanceof Array) {
  5209. var index = 0;
  5210. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5211. var target = _a[_i];
  5212. if (this._originalValue[index] !== undefined) {
  5213. this._setValue(target, this._originalValue[index], -1);
  5214. }
  5215. index++;
  5216. }
  5217. }
  5218. else {
  5219. if (this._originalValue[0] !== undefined) {
  5220. this._setValue(this._target, this._originalValue[0], -1);
  5221. }
  5222. }
  5223. }
  5224. this._offsetsCache = {};
  5225. this._highLimitsCache = {};
  5226. this._currentFrame = 0;
  5227. this._blendingFactor = 0;
  5228. this._originalValue = new Array();
  5229. // Events
  5230. for (var index = 0; index < this._events.length; index++) {
  5231. this._events[index].isDone = false;
  5232. }
  5233. };
  5234. /**
  5235. * Specifies if the runtime animation is stopped
  5236. * @returns Boolean specifying if the runtime animation is stopped
  5237. */
  5238. RuntimeAnimation.prototype.isStopped = function () {
  5239. return this._stopped;
  5240. };
  5241. /**
  5242. * Disposes of the runtime animation
  5243. */
  5244. RuntimeAnimation.prototype.dispose = function () {
  5245. var index = this._animation.runtimeAnimations.indexOf(this);
  5246. if (index > -1) {
  5247. this._animation.runtimeAnimations.splice(index, 1);
  5248. }
  5249. };
  5250. /**
  5251. * Interpolates the animation from the current frame
  5252. * @param currentFrame The frame to interpolate the animation to
  5253. * @param repeatCount The number of times that the animation should loop
  5254. * @param loopMode The type of looping mode to use
  5255. * @param offsetValue Animation offset value
  5256. * @param highLimitValue The high limit value
  5257. * @returns The interpolated value
  5258. */
  5259. RuntimeAnimation.prototype._interpolate = function (currentFrame, repeatCount, loopMode, offsetValue, highLimitValue) {
  5260. this._currentFrame = currentFrame;
  5261. if (this._animation.dataType === _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_MATRIX && !this._workValue) {
  5262. this._workValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Zero();
  5263. }
  5264. return this._animation._interpolate(currentFrame, repeatCount, this._workValue, loopMode, offsetValue, highLimitValue);
  5265. };
  5266. /**
  5267. * Apply the interpolated value to the target
  5268. * @param currentValue defines the value computed by the animation
  5269. * @param weight defines the weight to apply to this value (Defaults to 1.0)
  5270. */
  5271. RuntimeAnimation.prototype.setValue = function (currentValue, weight) {
  5272. if (weight === void 0) { weight = 1.0; }
  5273. if (this._target instanceof Array) {
  5274. var index = 0;
  5275. for (var _i = 0, _a = this._target; _i < _a.length; _i++) {
  5276. var target = _a[_i];
  5277. this._setValue(target, currentValue, weight, index);
  5278. index++;
  5279. }
  5280. }
  5281. else {
  5282. this._setValue(this._target, currentValue, weight);
  5283. }
  5284. };
  5285. RuntimeAnimation.prototype._setValue = function (target, currentValue, weight, targetIndex) {
  5286. if (targetIndex === void 0) { targetIndex = 0; }
  5287. // Set value
  5288. var path;
  5289. var destination;
  5290. var targetPropertyPath = this._animation.targetPropertyPath;
  5291. if (targetPropertyPath.length > 1) {
  5292. var property = target[targetPropertyPath[0]];
  5293. for (var index = 1; index < targetPropertyPath.length - 1; index++) {
  5294. property = property[targetPropertyPath[index]];
  5295. }
  5296. path = targetPropertyPath[targetPropertyPath.length - 1];
  5297. destination = property;
  5298. }
  5299. else {
  5300. path = targetPropertyPath[0];
  5301. destination = target;
  5302. }
  5303. this._targetPath = path;
  5304. this._activeTarget = destination;
  5305. this._weight = weight;
  5306. if (this._originalValue[targetIndex] === undefined) {
  5307. var originalValue = void 0;
  5308. if (destination.getRestPose && path === "_matrix") { // For bones
  5309. originalValue = destination.getRestPose();
  5310. }
  5311. else {
  5312. originalValue = destination[path];
  5313. }
  5314. if (originalValue && originalValue.clone) {
  5315. this._originalValue[targetIndex] = originalValue.clone();
  5316. }
  5317. else {
  5318. this._originalValue[targetIndex] = originalValue;
  5319. }
  5320. }
  5321. // Blending
  5322. var enableBlending = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.enableBlending : this._animation.enableBlending;
  5323. if (enableBlending && this._blendingFactor <= 1.0) {
  5324. if (!this._originalBlendValue) {
  5325. var originalValue = destination[path];
  5326. if (originalValue.clone) {
  5327. this._originalBlendValue = originalValue.clone();
  5328. }
  5329. else {
  5330. this._originalBlendValue = originalValue;
  5331. }
  5332. }
  5333. if (this._originalBlendValue.m) { // Matrix
  5334. if (_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].AllowMatrixDecomposeForInterpolation) {
  5335. if (this._currentValue) {
  5336. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5337. }
  5338. else {
  5339. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].DecomposeLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5340. }
  5341. }
  5342. else {
  5343. if (this._currentValue) {
  5344. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LerpToRef(this._originalBlendValue, currentValue, this._blendingFactor, this._currentValue);
  5345. }
  5346. else {
  5347. this._currentValue = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Lerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5348. }
  5349. }
  5350. }
  5351. else {
  5352. this._currentValue = _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"]._UniversalLerp(this._originalBlendValue, currentValue, this._blendingFactor);
  5353. }
  5354. var blendingSpeed = target && target.animationPropertiesOverride ? target.animationPropertiesOverride.blendingSpeed : this._animation.blendingSpeed;
  5355. this._blendingFactor += blendingSpeed;
  5356. }
  5357. else {
  5358. this._currentValue = currentValue;
  5359. }
  5360. if (weight !== -1.0) {
  5361. this._scene._registerTargetForLateAnimationBinding(this, this._originalValue[targetIndex]);
  5362. }
  5363. else {
  5364. destination[path] = this._currentValue;
  5365. }
  5366. if (target.markAsDirty) {
  5367. target.markAsDirty(this._animation.targetProperty);
  5368. }
  5369. };
  5370. /**
  5371. * Gets the loop pmode of the runtime animation
  5372. * @returns Loop Mode
  5373. */
  5374. RuntimeAnimation.prototype._getCorrectLoopMode = function () {
  5375. if (this._target && this._target.animationPropertiesOverride) {
  5376. return this._target.animationPropertiesOverride.loopMode;
  5377. }
  5378. return this._animation.loopMode;
  5379. };
  5380. /**
  5381. * Move the current animation to a given frame
  5382. * @param frame defines the frame to move to
  5383. */
  5384. RuntimeAnimation.prototype.goToFrame = function (frame) {
  5385. var keys = this._animation.getKeys();
  5386. if (frame < keys[0].frame) {
  5387. frame = keys[0].frame;
  5388. }
  5389. else if (frame > keys[keys.length - 1].frame) {
  5390. frame = keys[keys.length - 1].frame;
  5391. }
  5392. var currentValue = this._interpolate(frame, 0, this._getCorrectLoopMode());
  5393. this.setValue(currentValue, -1);
  5394. };
  5395. /**
  5396. * @hidden Internal use only
  5397. */
  5398. RuntimeAnimation.prototype._prepareForSpeedRatioChange = function (newSpeedRatio) {
  5399. var newRatio = this._previousDelay * (this._animation.framePerSecond * newSpeedRatio) / 1000.0;
  5400. this._ratioOffset = this._previousRatio - newRatio;
  5401. };
  5402. /**
  5403. * Execute the current animation
  5404. * @param delay defines the delay to add to the current frame
  5405. * @param from defines the lower bound of the animation range
  5406. * @param to defines the upper bound of the animation range
  5407. * @param loop defines if the current animation must loop
  5408. * @param speedRatio defines the current speed ratio
  5409. * @param weight defines the weight of the animation (default is -1 so no weight)
  5410. * @param onLoop optional callback called when animation loops
  5411. * @returns a boolean indicating if the animation is running
  5412. */
  5413. RuntimeAnimation.prototype.animate = function (delay, from, to, loop, speedRatio, weight, onLoop) {
  5414. if (weight === void 0) { weight = -1.0; }
  5415. var targetPropertyPath = this._animation.targetPropertyPath;
  5416. if (!targetPropertyPath || targetPropertyPath.length < 1) {
  5417. this._stopped = true;
  5418. return false;
  5419. }
  5420. var returnValue = true;
  5421. var keys = this._animation.getKeys();
  5422. var min = keys[0].frame;
  5423. var max = keys[keys.length - 1].frame;
  5424. // Add a start key at frame 0 if missing
  5425. if (min !== 0) {
  5426. var newKey = { frame: 0, value: keys[0].value };
  5427. keys.splice(0, 0, newKey);
  5428. }
  5429. // Check limits
  5430. if (from < min || from > max) {
  5431. from = min;
  5432. }
  5433. if (to < min || to > max) {
  5434. to = max;
  5435. }
  5436. var range = to - from;
  5437. var offsetValue;
  5438. // Compute ratio which represents the frame delta between from and to
  5439. var ratio = (delay * (this._animation.framePerSecond * speedRatio) / 1000.0) + this._ratioOffset;
  5440. var highLimitValue = 0;
  5441. this._previousDelay = delay;
  5442. this._previousRatio = ratio;
  5443. if (((to > from && ratio >= range) || (from > to && ratio <= range)) && !loop) { // If we are out of range and not looping get back to caller
  5444. returnValue = false;
  5445. highLimitValue = this._animation._getKeyValue(keys[keys.length - 1].value);
  5446. }
  5447. else {
  5448. // Get max value if required
  5449. if (this._getCorrectLoopMode() !== _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE) {
  5450. var keyOffset = to.toString() + from.toString();
  5451. if (!this._offsetsCache[keyOffset]) {
  5452. var fromValue = this._interpolate(from, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5453. var toValue = this._interpolate(to, 0, _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONLOOPMODE_CYCLE);
  5454. switch (this._animation.dataType) {
  5455. // Float
  5456. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5457. this._offsetsCache[keyOffset] = toValue - fromValue;
  5458. break;
  5459. // Quaternion
  5460. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5461. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5462. break;
  5463. // Vector3
  5464. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5465. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5466. // Vector2
  5467. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5468. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5469. // Size
  5470. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5471. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5472. // Color3
  5473. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5474. this._offsetsCache[keyOffset] = toValue.subtract(fromValue);
  5475. default:
  5476. break;
  5477. }
  5478. this._highLimitsCache[keyOffset] = toValue;
  5479. }
  5480. highLimitValue = this._highLimitsCache[keyOffset];
  5481. offsetValue = this._offsetsCache[keyOffset];
  5482. }
  5483. }
  5484. if (offsetValue === undefined) {
  5485. switch (this._animation.dataType) {
  5486. // Float
  5487. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT:
  5488. offsetValue = 0;
  5489. break;
  5490. // Quaternion
  5491. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_QUATERNION:
  5492. offsetValue = _staticOffsetValueQuaternion;
  5493. break;
  5494. // Vector3
  5495. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR3:
  5496. offsetValue = _staticOffsetValueVector3;
  5497. break;
  5498. // Vector2
  5499. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_VECTOR2:
  5500. offsetValue = _staticOffsetValueVector2;
  5501. break;
  5502. // Size
  5503. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_SIZE:
  5504. offsetValue = _staticOffsetValueSize;
  5505. break;
  5506. // Color3
  5507. case _animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_COLOR3:
  5508. offsetValue = _staticOffsetValueColor3;
  5509. }
  5510. }
  5511. // Compute value
  5512. var currentFrame = (returnValue && range !== 0) ? from + ratio % range : to;
  5513. // Need to normalize?
  5514. if (this._host && this._host.syncRoot) {
  5515. var syncRoot = this._host.syncRoot;
  5516. var hostNormalizedFrame = (syncRoot.masterFrame - syncRoot.fromFrame) / (syncRoot.toFrame - syncRoot.fromFrame);
  5517. currentFrame = from + (to - from) * hostNormalizedFrame;
  5518. }
  5519. // Reset events if looping
  5520. var events = this._events;
  5521. if (range > 0 && this.currentFrame > currentFrame ||
  5522. range < 0 && this.currentFrame < currentFrame) {
  5523. if (onLoop) {
  5524. onLoop();
  5525. }
  5526. // Need to reset animation events
  5527. for (var index = 0; index < events.length; index++) {
  5528. if (!events[index].onlyOnce) {
  5529. // reset event, the animation is looping
  5530. events[index].isDone = false;
  5531. }
  5532. }
  5533. }
  5534. var repeatCount = range === 0 ? 0 : (ratio / range) >> 0;
  5535. var currentValue = this._interpolate(currentFrame, repeatCount, this._getCorrectLoopMode(), offsetValue, highLimitValue);
  5536. // Set value
  5537. this.setValue(currentValue, weight);
  5538. // Check events
  5539. for (var index = 0; index < events.length; index++) {
  5540. // Make sure current frame has passed event frame and that event frame is within the current range
  5541. // Also, handle both forward and reverse animations
  5542. if ((range > 0 && currentFrame >= events[index].frame && events[index].frame >= from) ||
  5543. (range < 0 && currentFrame <= events[index].frame && events[index].frame <= from)) {
  5544. var event = events[index];
  5545. if (!event.isDone) {
  5546. // If event should be done only once, remove it.
  5547. if (event.onlyOnce) {
  5548. events.splice(index, 1);
  5549. index--;
  5550. }
  5551. event.isDone = true;
  5552. event.action(currentFrame);
  5553. } // Don't do anything if the event has already be done.
  5554. }
  5555. }
  5556. if (!returnValue) {
  5557. this._stopped = true;
  5558. }
  5559. return returnValue;
  5560. };
  5561. return RuntimeAnimation;
  5562. }());
  5563. /***/ }),
  5564. /***/ "./Audio/analyser.ts":
  5565. /*!***************************!*\
  5566. !*** ./Audio/analyser.ts ***!
  5567. \***************************/
  5568. /*! exports provided: Analyser */
  5569. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5570. "use strict";
  5571. __webpack_require__.r(__webpack_exports__);
  5572. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return Analyser; });
  5573. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5574. /**
  5575. * Class used to work with sound analyzer using fast fourier transform (FFT)
  5576. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5577. */
  5578. var Analyser = /** @class */ (function () {
  5579. /**
  5580. * Creates a new analyser
  5581. * @param scene defines hosting scene
  5582. */
  5583. function Analyser(scene) {
  5584. /**
  5585. * Gets or sets the smoothing
  5586. * @ignorenaming
  5587. */
  5588. this.SMOOTHING = 0.75;
  5589. /**
  5590. * Gets or sets the FFT table size
  5591. * @ignorenaming
  5592. */
  5593. this.FFT_SIZE = 512;
  5594. /**
  5595. * Gets or sets the bar graph amplitude
  5596. * @ignorenaming
  5597. */
  5598. this.BARGRAPHAMPLITUDE = 256;
  5599. /**
  5600. * Gets or sets the position of the debug canvas
  5601. * @ignorenaming
  5602. */
  5603. this.DEBUGCANVASPOS = { x: 20, y: 20 };
  5604. /**
  5605. * Gets or sets the debug canvas size
  5606. * @ignorenaming
  5607. */
  5608. this.DEBUGCANVASSIZE = { width: 320, height: 200 };
  5609. this._scene = scene;
  5610. this._audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine;
  5611. if (this._audioEngine.canUseWebAudio && this._audioEngine.audioContext) {
  5612. this._webAudioAnalyser = this._audioEngine.audioContext.createAnalyser();
  5613. this._webAudioAnalyser.minDecibels = -140;
  5614. this._webAudioAnalyser.maxDecibels = 0;
  5615. this._byteFreqs = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5616. this._byteTime = new Uint8Array(this._webAudioAnalyser.frequencyBinCount);
  5617. this._floatFreqs = new Float32Array(this._webAudioAnalyser.frequencyBinCount);
  5618. }
  5619. }
  5620. /**
  5621. * Get the number of data values you will have to play with for the visualization
  5622. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/frequencyBinCount
  5623. * @returns a number
  5624. */
  5625. Analyser.prototype.getFrequencyBinCount = function () {
  5626. if (this._audioEngine.canUseWebAudio) {
  5627. return this._webAudioAnalyser.frequencyBinCount;
  5628. }
  5629. else {
  5630. return 0;
  5631. }
  5632. };
  5633. /**
  5634. * Gets the current frequency data as a byte array
  5635. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5636. * @returns a Uint8Array
  5637. */
  5638. Analyser.prototype.getByteFrequencyData = function () {
  5639. if (this._audioEngine.canUseWebAudio) {
  5640. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5641. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5642. this._webAudioAnalyser.getByteFrequencyData(this._byteFreqs);
  5643. }
  5644. return this._byteFreqs;
  5645. };
  5646. /**
  5647. * Gets the current waveform as a byte array
  5648. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteTimeDomainData
  5649. * @returns a Uint8Array
  5650. */
  5651. Analyser.prototype.getByteTimeDomainData = function () {
  5652. if (this._audioEngine.canUseWebAudio) {
  5653. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5654. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5655. this._webAudioAnalyser.getByteTimeDomainData(this._byteTime);
  5656. }
  5657. return this._byteTime;
  5658. };
  5659. /**
  5660. * Gets the current frequency data as a float array
  5661. * @see https://developer.mozilla.org/en-US/docs/Web/API/AnalyserNode/getByteFrequencyData
  5662. * @returns a Float32Array
  5663. */
  5664. Analyser.prototype.getFloatFrequencyData = function () {
  5665. if (this._audioEngine.canUseWebAudio) {
  5666. this._webAudioAnalyser.smoothingTimeConstant = this.SMOOTHING;
  5667. this._webAudioAnalyser.fftSize = this.FFT_SIZE;
  5668. this._webAudioAnalyser.getFloatFrequencyData(this._floatFreqs);
  5669. }
  5670. return this._floatFreqs;
  5671. };
  5672. /**
  5673. * Renders the debug canvas
  5674. */
  5675. Analyser.prototype.drawDebugCanvas = function () {
  5676. var _this = this;
  5677. if (this._audioEngine.canUseWebAudio) {
  5678. if (!this._debugCanvas) {
  5679. this._debugCanvas = document.createElement("canvas");
  5680. this._debugCanvas.width = this.DEBUGCANVASSIZE.width;
  5681. this._debugCanvas.height = this.DEBUGCANVASSIZE.height;
  5682. this._debugCanvas.style.position = "absolute";
  5683. this._debugCanvas.style.top = this.DEBUGCANVASPOS.y + "px";
  5684. this._debugCanvas.style.left = this.DEBUGCANVASPOS.x + "px";
  5685. this._debugCanvasContext = this._debugCanvas.getContext("2d");
  5686. document.body.appendChild(this._debugCanvas);
  5687. this._registerFunc = function () {
  5688. _this.drawDebugCanvas();
  5689. };
  5690. this._scene.registerBeforeRender(this._registerFunc);
  5691. }
  5692. if (this._registerFunc && this._debugCanvasContext) {
  5693. var workingArray = this.getByteFrequencyData();
  5694. this._debugCanvasContext.fillStyle = 'rgb(0, 0, 0)';
  5695. this._debugCanvasContext.fillRect(0, 0, this.DEBUGCANVASSIZE.width, this.DEBUGCANVASSIZE.height);
  5696. // Draw the frequency domain chart.
  5697. for (var i = 0; i < this.getFrequencyBinCount(); i++) {
  5698. var value = workingArray[i];
  5699. var percent = value / this.BARGRAPHAMPLITUDE;
  5700. var height = this.DEBUGCANVASSIZE.height * percent;
  5701. var offset = this.DEBUGCANVASSIZE.height - height - 1;
  5702. var barWidth = this.DEBUGCANVASSIZE.width / this.getFrequencyBinCount();
  5703. var hue = i / this.getFrequencyBinCount() * 360;
  5704. this._debugCanvasContext.fillStyle = 'hsl(' + hue + ', 100%, 50%)';
  5705. this._debugCanvasContext.fillRect(i * barWidth, offset, barWidth, height);
  5706. }
  5707. }
  5708. }
  5709. };
  5710. /**
  5711. * Stops rendering the debug canvas and removes it
  5712. */
  5713. Analyser.prototype.stopDebugCanvas = function () {
  5714. if (this._debugCanvas) {
  5715. if (this._registerFunc) {
  5716. this._scene.unregisterBeforeRender(this._registerFunc);
  5717. this._registerFunc = null;
  5718. }
  5719. document.body.removeChild(this._debugCanvas);
  5720. this._debugCanvas = null;
  5721. this._debugCanvasContext = null;
  5722. }
  5723. };
  5724. /**
  5725. * Connects two audio nodes
  5726. * @param inputAudioNode defines first node to connect
  5727. * @param outputAudioNode defines second node to connect
  5728. */
  5729. Analyser.prototype.connectAudioNodes = function (inputAudioNode, outputAudioNode) {
  5730. if (this._audioEngine.canUseWebAudio) {
  5731. inputAudioNode.connect(this._webAudioAnalyser);
  5732. this._webAudioAnalyser.connect(outputAudioNode);
  5733. }
  5734. };
  5735. /**
  5736. * Releases all associated resources
  5737. */
  5738. Analyser.prototype.dispose = function () {
  5739. if (this._audioEngine.canUseWebAudio) {
  5740. this._webAudioAnalyser.disconnect();
  5741. }
  5742. };
  5743. return Analyser;
  5744. }());
  5745. /***/ }),
  5746. /***/ "./Audio/audioEngine.ts":
  5747. /*!******************************!*\
  5748. !*** ./Audio/audioEngine.ts ***!
  5749. \******************************/
  5750. /*! exports provided: AudioEngine */
  5751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  5752. "use strict";
  5753. __webpack_require__.r(__webpack_exports__);
  5754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return AudioEngine; });
  5755. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  5756. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  5757. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  5758. // Sets the default audio engine to Babylon.js
  5759. _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].AudioEngineFactory = function (hostElement) { return new AudioEngine(hostElement); };
  5760. /**
  5761. * This represents the default audio engine used in babylon.
  5762. * It is responsible to play, synchronize and analyse sounds throughout the application.
  5763. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  5764. */
  5765. var AudioEngine = /** @class */ (function () {
  5766. /**
  5767. * Instantiates a new audio engine.
  5768. *
  5769. * There should be only one per page as some browsers restrict the number
  5770. * of audio contexts you can create.
  5771. * @param hostElement defines the host element where to display the mute icon if necessary
  5772. */
  5773. function AudioEngine(hostElement) {
  5774. if (hostElement === void 0) { hostElement = null; }
  5775. var _this = this;
  5776. this._audioContext = null;
  5777. this._audioContextInitialized = false;
  5778. this._muteButton = null;
  5779. /**
  5780. * Gets whether the current host supports Web Audio and thus could create AudioContexts.
  5781. */
  5782. this.canUseWebAudio = false;
  5783. /**
  5784. * Defines if Babylon should emit a warning if WebAudio is not supported.
  5785. * @ignoreNaming
  5786. */
  5787. this.WarnedWebAudioUnsupported = false;
  5788. /**
  5789. * Gets whether or not mp3 are supported by your browser.
  5790. */
  5791. this.isMP3supported = false;
  5792. /**
  5793. * Gets whether or not ogg are supported by your browser.
  5794. */
  5795. this.isOGGsupported = false;
  5796. /**
  5797. * Gets whether audio has been unlocked on the device.
  5798. * Some Browsers have strong restrictions about Audio and won t autoplay unless
  5799. * a user interaction has happened.
  5800. */
  5801. this.unlocked = true;
  5802. /**
  5803. * Defines if the audio engine relies on a custom unlocked button.
  5804. * In this case, the embedded button will not be displayed.
  5805. */
  5806. this.useCustomUnlockedButton = false;
  5807. /**
  5808. * Event raised when audio has been unlocked on the browser.
  5809. */
  5810. this.onAudioUnlockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5811. /**
  5812. * Event raised when audio has been locked on the browser.
  5813. */
  5814. this.onAudioLockedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  5815. this._tryToRun = false;
  5816. this._onResize = function () {
  5817. _this._moveButtonToTopLeft();
  5818. };
  5819. if (typeof window.AudioContext !== 'undefined' || typeof window.webkitAudioContext !== 'undefined') {
  5820. window.AudioContext = window.AudioContext || window.webkitAudioContext;
  5821. this.canUseWebAudio = true;
  5822. }
  5823. var audioElem = document.createElement('audio');
  5824. this._hostElement = hostElement;
  5825. try {
  5826. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/mpeg; codecs="mp3"').replace(/^no$/, '')) {
  5827. this.isMP3supported = true;
  5828. }
  5829. }
  5830. catch (e) {
  5831. // protect error during capability check.
  5832. }
  5833. try {
  5834. if (audioElem && !!audioElem.canPlayType && audioElem.canPlayType('audio/ogg; codecs="vorbis"').replace(/^no$/, '')) {
  5835. this.isOGGsupported = true;
  5836. }
  5837. }
  5838. catch (e) {
  5839. // protect error during capability check.
  5840. }
  5841. }
  5842. Object.defineProperty(AudioEngine.prototype, "audioContext", {
  5843. /**
  5844. * Gets the current AudioContext if available.
  5845. */
  5846. get: function () {
  5847. if (!this._audioContextInitialized) {
  5848. this._initializeAudioContext();
  5849. }
  5850. else {
  5851. if (!this.unlocked && !this._muteButton) {
  5852. this._displayMuteButton();
  5853. }
  5854. }
  5855. return this._audioContext;
  5856. },
  5857. enumerable: true,
  5858. configurable: true
  5859. });
  5860. /**
  5861. * Flags the audio engine in Locked state.
  5862. * This happens due to new browser policies preventing audio to autoplay.
  5863. */
  5864. AudioEngine.prototype.lock = function () {
  5865. this._triggerSuspendedState();
  5866. };
  5867. /**
  5868. * Unlocks the audio engine once a user action has been done on the dom.
  5869. * This is helpful to resume play once browser policies have been satisfied.
  5870. */
  5871. AudioEngine.prototype.unlock = function () {
  5872. this._triggerRunningState();
  5873. };
  5874. AudioEngine.prototype._resumeAudioContext = function () {
  5875. var result;
  5876. if (this._audioContext.resume) {
  5877. result = this._audioContext.resume();
  5878. }
  5879. return result || Promise.resolve();
  5880. };
  5881. AudioEngine.prototype._initializeAudioContext = function () {
  5882. try {
  5883. if (this.canUseWebAudio) {
  5884. this._audioContext = new AudioContext();
  5885. // create a global volume gain node
  5886. this.masterGain = this._audioContext.createGain();
  5887. this.masterGain.gain.value = 1;
  5888. this.masterGain.connect(this._audioContext.destination);
  5889. this._audioContextInitialized = true;
  5890. if (this._audioContext.state === "running") {
  5891. // Do not wait for the promise to unlock.
  5892. this._triggerRunningState();
  5893. }
  5894. }
  5895. }
  5896. catch (e) {
  5897. this.canUseWebAudio = false;
  5898. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Web Audio: " + e.message);
  5899. }
  5900. };
  5901. AudioEngine.prototype._triggerRunningState = function () {
  5902. var _this = this;
  5903. if (this._tryToRun) {
  5904. return;
  5905. }
  5906. this._tryToRun = true;
  5907. this._resumeAudioContext()
  5908. .then(function () {
  5909. _this._tryToRun = false;
  5910. if (_this._muteButton) {
  5911. _this._hideMuteButton();
  5912. }
  5913. }).catch(function () {
  5914. _this._tryToRun = false;
  5915. _this.unlocked = false;
  5916. });
  5917. // Notify users that the audio stack is unlocked/unmuted
  5918. this.unlocked = true;
  5919. this.onAudioUnlockedObservable.notifyObservers(this);
  5920. };
  5921. AudioEngine.prototype._triggerSuspendedState = function () {
  5922. this.unlocked = false;
  5923. this.onAudioLockedObservable.notifyObservers(this);
  5924. this._displayMuteButton();
  5925. };
  5926. AudioEngine.prototype._displayMuteButton = function () {
  5927. var _this = this;
  5928. if (this.useCustomUnlockedButton || this._muteButton) {
  5929. return;
  5930. }
  5931. this._muteButton = document.createElement("BUTTON");
  5932. this._muteButton.className = "babylonUnmuteIcon";
  5933. this._muteButton.id = "babylonUnmuteIconBtn";
  5934. this._muteButton.title = "Unmute";
  5935. var css = ".babylonUnmuteIcon { position: absolute; left: 20px; top: 20px; height: 40px; width: 60px; background-color: rgba(51,51,51,0.7); background-image: url(data:image/svg+xml;charset=UTF-8,%3Csvg%20version%3D%221.1%22%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%2239%22%20height%3D%2232%22%20viewBox%3D%220%200%2039%2032%22%3E%3Cpath%20fill%3D%22white%22%20d%3D%22M9.625%2018.938l-0.031%200.016h-4.953q-0.016%200-0.031-0.016v-12.453q0-0.016%200.031-0.016h4.953q0.031%200%200.031%200.016v12.453zM12.125%207.688l8.719-8.703v27.453l-8.719-8.719-0.016-0.047v-9.938zM23.359%207.875l1.406-1.406%204.219%204.203%204.203-4.203%201.422%201.406-4.219%204.219%204.219%204.203-1.484%201.359-4.141-4.156-4.219%204.219-1.406-1.422%204.219-4.203z%22%3E%3C%2Fpath%3E%3C%2Fsvg%3E); background-size: 80%; background-repeat:no-repeat; background-position: center; background-position-y: 4px; border: none; outline: none; transition: transform 0.125s ease-out; cursor: pointer; z-index: 9999; } .babylonUnmuteIcon:hover { transform: scale(1.05) } .babylonUnmuteIcon:active { background-color: rgba(51,51,51,1) }";
  5936. var style = document.createElement('style');
  5937. style.appendChild(document.createTextNode(css));
  5938. document.getElementsByTagName('head')[0].appendChild(style);
  5939. document.body.appendChild(this._muteButton);
  5940. this._moveButtonToTopLeft();
  5941. this._muteButton.addEventListener('touchend', function () {
  5942. _this._triggerRunningState();
  5943. }, true);
  5944. this._muteButton.addEventListener('click', function () {
  5945. _this._triggerRunningState();
  5946. }, true);
  5947. window.addEventListener("resize", this._onResize);
  5948. };
  5949. AudioEngine.prototype._moveButtonToTopLeft = function () {
  5950. if (this._hostElement && this._muteButton) {
  5951. this._muteButton.style.top = this._hostElement.offsetTop + 20 + "px";
  5952. this._muteButton.style.left = this._hostElement.offsetLeft + 20 + "px";
  5953. }
  5954. };
  5955. AudioEngine.prototype._hideMuteButton = function () {
  5956. if (this._muteButton) {
  5957. document.body.removeChild(this._muteButton);
  5958. this._muteButton = null;
  5959. }
  5960. };
  5961. /**
  5962. * Destroy and release the resources associated with the audio ccontext.
  5963. */
  5964. AudioEngine.prototype.dispose = function () {
  5965. if (this.canUseWebAudio && this._audioContextInitialized) {
  5966. if (this._connectedAnalyser && this._audioContext) {
  5967. this._connectedAnalyser.stopDebugCanvas();
  5968. this._connectedAnalyser.dispose();
  5969. this.masterGain.disconnect();
  5970. this.masterGain.connect(this._audioContext.destination);
  5971. this._connectedAnalyser = null;
  5972. }
  5973. this.masterGain.gain.value = 1;
  5974. }
  5975. this.WarnedWebAudioUnsupported = false;
  5976. this._hideMuteButton();
  5977. window.removeEventListener("resize", this._onResize);
  5978. this.onAudioUnlockedObservable.clear();
  5979. this.onAudioLockedObservable.clear();
  5980. };
  5981. /**
  5982. * Gets the global volume sets on the master gain.
  5983. * @returns the global volume if set or -1 otherwise
  5984. */
  5985. AudioEngine.prototype.getGlobalVolume = function () {
  5986. if (this.canUseWebAudio && this._audioContextInitialized) {
  5987. return this.masterGain.gain.value;
  5988. }
  5989. else {
  5990. return -1;
  5991. }
  5992. };
  5993. /**
  5994. * Sets the global volume of your experience (sets on the master gain).
  5995. * @param newVolume Defines the new global volume of the application
  5996. */
  5997. AudioEngine.prototype.setGlobalVolume = function (newVolume) {
  5998. if (this.canUseWebAudio && this._audioContextInitialized) {
  5999. this.masterGain.gain.value = newVolume;
  6000. }
  6001. };
  6002. /**
  6003. * Connect the audio engine to an audio analyser allowing some amazing
  6004. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  6005. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  6006. * @param analyser The analyser to connect to the engine
  6007. */
  6008. AudioEngine.prototype.connectToAnalyser = function (analyser) {
  6009. if (this._connectedAnalyser) {
  6010. this._connectedAnalyser.stopDebugCanvas();
  6011. }
  6012. if (this.canUseWebAudio && this._audioContextInitialized && this._audioContext) {
  6013. this._connectedAnalyser = analyser;
  6014. this.masterGain.disconnect();
  6015. this._connectedAnalyser.connectAudioNodes(this.masterGain, this._audioContext.destination);
  6016. }
  6017. };
  6018. return AudioEngine;
  6019. }());
  6020. /***/ }),
  6021. /***/ "./Audio/audioSceneComponent.ts":
  6022. /*!**************************************!*\
  6023. !*** ./Audio/audioSceneComponent.ts ***!
  6024. \**************************************/
  6025. /*! exports provided: AudioSceneComponent */
  6026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6027. "use strict";
  6028. __webpack_require__.r(__webpack_exports__);
  6029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return AudioSceneComponent; });
  6030. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6031. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6032. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6033. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6034. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  6035. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  6036. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  6037. // Adds the parser to the scene parsers.
  6038. _abstractScene__WEBPACK_IMPORTED_MODULE_6__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO, function (parsedData, scene, container, rootUrl) {
  6039. // TODO: add sound
  6040. var loadedSounds = [];
  6041. var loadedSound;
  6042. container.sounds = container.sounds || [];
  6043. if (parsedData.sounds !== undefined && parsedData.sounds !== null) {
  6044. for (var index = 0, cache = parsedData.sounds.length; index < cache; index++) {
  6045. var parsedSound = parsedData.sounds[index];
  6046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine.canUseWebAudio) {
  6047. if (!parsedSound.url) {
  6048. parsedSound.url = parsedSound.name;
  6049. }
  6050. if (!loadedSounds[parsedSound.url]) {
  6051. loadedSound = _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl);
  6052. loadedSounds[parsedSound.url] = loadedSound;
  6053. container.sounds.push(loadedSound);
  6054. }
  6055. else {
  6056. container.sounds.push(_sound__WEBPACK_IMPORTED_MODULE_0__["Sound"].Parse(parsedSound, scene, rootUrl, loadedSounds[parsedSound.url]));
  6057. }
  6058. }
  6059. else {
  6060. container.sounds.push(new _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"](parsedSound.name, null, scene));
  6061. }
  6062. }
  6063. }
  6064. loadedSounds = [];
  6065. });
  6066. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "mainSoundTrack", {
  6067. get: function () {
  6068. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6069. if (!compo) {
  6070. compo = new AudioSceneComponent(this);
  6071. this._addComponent(compo);
  6072. }
  6073. if (!this._mainSoundTrack) {
  6074. this._mainSoundTrack = new _soundTrack__WEBPACK_IMPORTED_MODULE_1__["SoundTrack"](this, { mainTrack: true });
  6075. }
  6076. return this._mainSoundTrack;
  6077. },
  6078. enumerable: true,
  6079. configurable: true
  6080. });
  6081. _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype.getSoundByName = function (name) {
  6082. var index;
  6083. for (index = 0; index < this.mainSoundTrack.soundCollection.length; index++) {
  6084. if (this.mainSoundTrack.soundCollection[index].name === name) {
  6085. return this.mainSoundTrack.soundCollection[index];
  6086. }
  6087. }
  6088. if (this.soundTracks) {
  6089. for (var sdIndex = 0; sdIndex < this.soundTracks.length; sdIndex++) {
  6090. for (index = 0; index < this.soundTracks[sdIndex].soundCollection.length; index++) {
  6091. if (this.soundTracks[sdIndex].soundCollection[index].name === name) {
  6092. return this.soundTracks[sdIndex].soundCollection[index];
  6093. }
  6094. }
  6095. }
  6096. }
  6097. return null;
  6098. };
  6099. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "audioEnabled", {
  6100. get: function () {
  6101. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6102. if (!compo) {
  6103. compo = new AudioSceneComponent(this);
  6104. this._addComponent(compo);
  6105. }
  6106. return compo.audioEnabled;
  6107. },
  6108. set: function (value) {
  6109. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6110. if (!compo) {
  6111. compo = new AudioSceneComponent(this);
  6112. this._addComponent(compo);
  6113. }
  6114. if (value) {
  6115. compo.enableAudio();
  6116. }
  6117. else {
  6118. compo.disableAudio();
  6119. }
  6120. },
  6121. enumerable: true,
  6122. configurable: true
  6123. });
  6124. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].prototype, "headphone", {
  6125. get: function () {
  6126. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6127. if (!compo) {
  6128. compo = new AudioSceneComponent(this);
  6129. this._addComponent(compo);
  6130. }
  6131. return compo.headphone;
  6132. },
  6133. set: function (value) {
  6134. var compo = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6135. if (!compo) {
  6136. compo = new AudioSceneComponent(this);
  6137. this._addComponent(compo);
  6138. }
  6139. if (value) {
  6140. compo.switchAudioModeForHeadphones();
  6141. }
  6142. else {
  6143. compo.switchAudioModeForNormalSpeakers();
  6144. }
  6145. },
  6146. enumerable: true,
  6147. configurable: true
  6148. });
  6149. /**
  6150. * Defines the sound scene component responsible to manage any sounds
  6151. * in a given scene.
  6152. */
  6153. var AudioSceneComponent = /** @class */ (function () {
  6154. /**
  6155. * Creates a new instance of the component for the given scene
  6156. * @param scene Defines the scene to register the component in
  6157. */
  6158. function AudioSceneComponent(scene) {
  6159. /**
  6160. * The component name helpfull to identify the component in the list of scene components.
  6161. */
  6162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO;
  6163. this._audioEnabled = true;
  6164. this._headphone = false;
  6165. this.scene = scene;
  6166. scene.soundTracks = new Array();
  6167. scene.sounds = new Array();
  6168. }
  6169. Object.defineProperty(AudioSceneComponent.prototype, "audioEnabled", {
  6170. /**
  6171. * Gets whether audio is enabled or not.
  6172. * Please use related enable/disable method to switch state.
  6173. */
  6174. get: function () {
  6175. return this._audioEnabled;
  6176. },
  6177. enumerable: true,
  6178. configurable: true
  6179. });
  6180. Object.defineProperty(AudioSceneComponent.prototype, "headphone", {
  6181. /**
  6182. * Gets whether audio is outputing to headphone or not.
  6183. * Please use the according Switch methods to change output.
  6184. */
  6185. get: function () {
  6186. return this._headphone;
  6187. },
  6188. enumerable: true,
  6189. configurable: true
  6190. });
  6191. /**
  6192. * Registers the component in a given scene
  6193. */
  6194. AudioSceneComponent.prototype.register = function () {
  6195. this.scene._afterRenderStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDER_AUDIO, this, this._afterRender);
  6196. };
  6197. /**
  6198. * Rebuilds the elements related to this component in case of
  6199. * context lost for instance.
  6200. */
  6201. AudioSceneComponent.prototype.rebuild = function () {
  6202. // Nothing to do here. (Not rendering related)
  6203. };
  6204. /**
  6205. * Serializes the component data to the specified json object
  6206. * @param serializationObject The object to serialize to
  6207. */
  6208. AudioSceneComponent.prototype.serialize = function (serializationObject) {
  6209. serializationObject.sounds = [];
  6210. if (this.scene.soundTracks) {
  6211. for (var index = 0; index < this.scene.soundTracks.length; index++) {
  6212. var soundtrack = this.scene.soundTracks[index];
  6213. for (var soundId = 0; soundId < soundtrack.soundCollection.length; soundId++) {
  6214. serializationObject.sounds.push(soundtrack.soundCollection[soundId].serialize());
  6215. }
  6216. }
  6217. }
  6218. };
  6219. /**
  6220. * Adds all the element from the container to the scene
  6221. * @param container the container holding the elements
  6222. */
  6223. AudioSceneComponent.prototype.addFromContainer = function (container) {
  6224. var _this = this;
  6225. if (!container.sounds) {
  6226. return;
  6227. }
  6228. container.sounds.forEach(function (sound) {
  6229. sound.play();
  6230. sound.autoplay = true;
  6231. _this.scene.mainSoundTrack.AddSound(sound);
  6232. });
  6233. };
  6234. /**
  6235. * Removes all the elements in the container from the scene
  6236. * @param container contains the elements to remove
  6237. */
  6238. AudioSceneComponent.prototype.removeFromContainer = function (container) {
  6239. var _this = this;
  6240. if (!container.sounds) {
  6241. return;
  6242. }
  6243. container.sounds.forEach(function (sound) {
  6244. sound.stop();
  6245. sound.autoplay = false;
  6246. _this.scene.mainSoundTrack.RemoveSound(sound);
  6247. });
  6248. };
  6249. /**
  6250. * Disposes the component and the associated ressources.
  6251. */
  6252. AudioSceneComponent.prototype.dispose = function () {
  6253. var scene = this.scene;
  6254. if (scene._mainSoundTrack) {
  6255. scene.mainSoundTrack.dispose();
  6256. }
  6257. if (scene.soundTracks) {
  6258. for (var scIndex = 0; scIndex < scene.soundTracks.length; scIndex++) {
  6259. scene.soundTracks[scIndex].dispose();
  6260. }
  6261. }
  6262. };
  6263. /**
  6264. * Disables audio in the associated scene.
  6265. */
  6266. AudioSceneComponent.prototype.disableAudio = function () {
  6267. var scene = this.scene;
  6268. this._audioEnabled = false;
  6269. var i;
  6270. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6271. scene.mainSoundTrack.soundCollection[i].pause();
  6272. }
  6273. if (scene.soundTracks) {
  6274. for (i = 0; i < scene.soundTracks.length; i++) {
  6275. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6276. scene.soundTracks[i].soundCollection[j].pause();
  6277. }
  6278. }
  6279. }
  6280. };
  6281. /**
  6282. * Enables audio in the associated scene.
  6283. */
  6284. AudioSceneComponent.prototype.enableAudio = function () {
  6285. var scene = this.scene;
  6286. this._audioEnabled = true;
  6287. var i;
  6288. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6289. if (scene.mainSoundTrack.soundCollection[i].isPaused) {
  6290. scene.mainSoundTrack.soundCollection[i].play();
  6291. }
  6292. }
  6293. if (scene.soundTracks) {
  6294. for (i = 0; i < scene.soundTracks.length; i++) {
  6295. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6296. if (scene.soundTracks[i].soundCollection[j].isPaused) {
  6297. scene.soundTracks[i].soundCollection[j].play();
  6298. }
  6299. }
  6300. }
  6301. }
  6302. };
  6303. /**
  6304. * Switch audio to headphone output.
  6305. */
  6306. AudioSceneComponent.prototype.switchAudioModeForHeadphones = function () {
  6307. var scene = this.scene;
  6308. this._headphone = true;
  6309. scene.mainSoundTrack.switchPanningModelToHRTF();
  6310. if (scene.soundTracks) {
  6311. for (var i = 0; i < scene.soundTracks.length; i++) {
  6312. scene.soundTracks[i].switchPanningModelToHRTF();
  6313. }
  6314. }
  6315. };
  6316. /**
  6317. * Switch audio to normal speakers.
  6318. */
  6319. AudioSceneComponent.prototype.switchAudioModeForNormalSpeakers = function () {
  6320. var scene = this.scene;
  6321. this._headphone = false;
  6322. scene.mainSoundTrack.switchPanningModelToEqualPower();
  6323. if (scene.soundTracks) {
  6324. for (var i = 0; i < scene.soundTracks.length; i++) {
  6325. scene.soundTracks[i].switchPanningModelToEqualPower();
  6326. }
  6327. }
  6328. };
  6329. AudioSceneComponent.prototype._afterRender = function () {
  6330. var scene = this.scene;
  6331. if (!this._audioEnabled || !scene._mainSoundTrack || !scene.soundTracks || (scene._mainSoundTrack.soundCollection.length === 0 && scene.soundTracks.length === 1)) {
  6332. return;
  6333. }
  6334. var listeningCamera;
  6335. var audioEngine = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].audioEngine;
  6336. if (scene.activeCameras.length > 0) {
  6337. listeningCamera = scene.activeCameras[0];
  6338. }
  6339. else {
  6340. listeningCamera = scene.activeCamera;
  6341. }
  6342. if (listeningCamera && audioEngine.audioContext) {
  6343. audioEngine.audioContext.listener.setPosition(listeningCamera.position.x, listeningCamera.position.y, listeningCamera.position.z);
  6344. // for VR cameras
  6345. if (listeningCamera.rigCameras && listeningCamera.rigCameras.length > 0) {
  6346. listeningCamera = listeningCamera.rigCameras[0];
  6347. }
  6348. var mat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(listeningCamera.getViewMatrix());
  6349. var cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1), mat);
  6350. cameraDirection.normalize();
  6351. // To avoid some errors on GearVR
  6352. if (!isNaN(cameraDirection.x) && !isNaN(cameraDirection.y) && !isNaN(cameraDirection.z)) {
  6353. audioEngine.audioContext.listener.setOrientation(cameraDirection.x, cameraDirection.y, cameraDirection.z, 0, 1, 0);
  6354. }
  6355. var i;
  6356. for (i = 0; i < scene.mainSoundTrack.soundCollection.length; i++) {
  6357. var sound = scene.mainSoundTrack.soundCollection[i];
  6358. if (sound.useCustomAttenuation) {
  6359. sound.updateDistanceFromListener();
  6360. }
  6361. }
  6362. if (scene.soundTracks) {
  6363. for (i = 0; i < scene.soundTracks.length; i++) {
  6364. for (var j = 0; j < scene.soundTracks[i].soundCollection.length; j++) {
  6365. sound = scene.soundTracks[i].soundCollection[j];
  6366. if (sound.useCustomAttenuation) {
  6367. sound.updateDistanceFromListener();
  6368. }
  6369. }
  6370. }
  6371. }
  6372. }
  6373. };
  6374. return AudioSceneComponent;
  6375. }());
  6376. _sound__WEBPACK_IMPORTED_MODULE_0__["Sound"]._SceneComponentInitialization = function (scene) {
  6377. var compo = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_AUDIO);
  6378. if (!compo) {
  6379. compo = new AudioSceneComponent(scene);
  6380. scene._addComponent(compo);
  6381. }
  6382. };
  6383. /***/ }),
  6384. /***/ "./Audio/index.ts":
  6385. /*!************************!*\
  6386. !*** ./Audio/index.ts ***!
  6387. \************************/
  6388. /*! exports provided: Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound */
  6389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6390. "use strict";
  6391. __webpack_require__.r(__webpack_exports__);
  6392. /* harmony import */ var _analyser__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./analyser */ "./Audio/analyser.ts");
  6393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _analyser__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  6394. /* harmony import */ var _audioEngine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./audioEngine */ "./Audio/audioEngine.ts");
  6395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _audioEngine__WEBPACK_IMPORTED_MODULE_1__["AudioEngine"]; });
  6396. /* harmony import */ var _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./audioSceneComponent */ "./Audio/audioSceneComponent.ts");
  6397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _audioSceneComponent__WEBPACK_IMPORTED_MODULE_2__["AudioSceneComponent"]; });
  6398. /* harmony import */ var _sound__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sound */ "./Audio/sound.ts");
  6399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _sound__WEBPACK_IMPORTED_MODULE_3__["Sound"]; });
  6400. /* harmony import */ var _soundTrack__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./soundTrack */ "./Audio/soundTrack.ts");
  6401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _soundTrack__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  6402. /* harmony import */ var _weightedsound__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./weightedsound */ "./Audio/weightedsound.ts");
  6403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _weightedsound__WEBPACK_IMPORTED_MODULE_5__["WeightedSound"]; });
  6404. /***/ }),
  6405. /***/ "./Audio/sound.ts":
  6406. /*!************************!*\
  6407. !*** ./Audio/sound.ts ***!
  6408. \************************/
  6409. /*! exports provided: Sound */
  6410. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  6411. "use strict";
  6412. __webpack_require__.r(__webpack_exports__);
  6413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return Sound; });
  6414. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  6415. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  6416. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  6417. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  6418. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  6419. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  6420. /**
  6421. * Defines a sound that can be played in the application.
  6422. * The sound can either be an ambient track or a simple sound played in reaction to a user action.
  6423. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music
  6424. */
  6425. var Sound = /** @class */ (function () {
  6426. /**
  6427. * Create a sound and attach it to a scene
  6428. * @param name Name of your sound
  6429. * @param urlOrArrayBuffer Url to the sound to load async or ArrayBuffer, it also works with MediaStreams
  6430. * @param scene defines the scene the sound belongs to
  6431. * @param readyToPlayCallback Provide a callback function if you'd like to load your code once the sound is ready to be played
  6432. * @param options Objects to provide with the current available options: autoplay, loop, volume, spatialSound, maxDistance, rolloffFactor, refDistance, distanceModel, panningModel, streaming
  6433. */
  6434. function Sound(name, urlOrArrayBuffer, scene, readyToPlayCallback, options) {
  6435. if (readyToPlayCallback === void 0) { readyToPlayCallback = null; }
  6436. var _this = this;
  6437. /**
  6438. * Does the sound autoplay once loaded.
  6439. */
  6440. this.autoplay = false;
  6441. /**
  6442. * Does the sound loop after it finishes playing once.
  6443. */
  6444. this.loop = false;
  6445. /**
  6446. * Does the sound use a custom attenuation curve to simulate the falloff
  6447. * happening when the source gets further away from the camera.
  6448. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6449. */
  6450. this.useCustomAttenuation = false;
  6451. /**
  6452. * Is this sound currently played.
  6453. */
  6454. this.isPlaying = false;
  6455. /**
  6456. * Is this sound currently paused.
  6457. */
  6458. this.isPaused = false;
  6459. /**
  6460. * Does this sound enables spatial sound.
  6461. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6462. */
  6463. this.spatialSound = false;
  6464. /**
  6465. * Define the reference distance the sound should be heard perfectly.
  6466. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6467. */
  6468. this.refDistance = 1;
  6469. /**
  6470. * Define the roll off factor of spatial sounds.
  6471. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6472. */
  6473. this.rolloffFactor = 1;
  6474. /**
  6475. * Define the max distance the sound should be heard (intensity just became 0 at this point).
  6476. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6477. */
  6478. this.maxDistance = 100;
  6479. /**
  6480. * Define the distance attenuation model the sound will follow.
  6481. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6482. */
  6483. this.distanceModel = "linear";
  6484. /**
  6485. * Observable event when the current playing sound finishes.
  6486. */
  6487. this.onEndedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  6488. this._panningModel = "equalpower";
  6489. this._playbackRate = 1;
  6490. this._streaming = false;
  6491. this._startTime = 0;
  6492. this._startOffset = 0;
  6493. this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  6494. /** @hidden */
  6495. this._positionInEmitterSpace = false;
  6496. this._localDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 0, 0);
  6497. this._volume = 1;
  6498. this._isReadyToPlay = false;
  6499. this._isDirectional = false;
  6500. // Used if you'd like to create a directional sound.
  6501. // If not set, the sound will be omnidirectional
  6502. this._coneInnerAngle = 360;
  6503. this._coneOuterAngle = 360;
  6504. this._coneOuterGain = 0;
  6505. this._isOutputConnected = false;
  6506. this._urlType = "Unknown";
  6507. this.name = name;
  6508. this._scene = scene;
  6509. Sound._SceneComponentInitialization(scene);
  6510. this._readyToPlayCallback = readyToPlayCallback;
  6511. // Default custom attenuation function is a linear attenuation
  6512. this._customAttenuationFunction = function (currentVolume, currentDistance, maxDistance, refDistance, rolloffFactor) {
  6513. if (currentDistance < maxDistance) {
  6514. return currentVolume * (1 - currentDistance / maxDistance);
  6515. }
  6516. else {
  6517. return 0;
  6518. }
  6519. };
  6520. if (options) {
  6521. this.autoplay = options.autoplay || false;
  6522. this.loop = options.loop || false;
  6523. // if volume === 0, we need another way to check this option
  6524. if (options.volume !== undefined) {
  6525. this._volume = options.volume;
  6526. }
  6527. this.spatialSound = options.spatialSound || false;
  6528. this.maxDistance = options.maxDistance || 100;
  6529. this.useCustomAttenuation = options.useCustomAttenuation || false;
  6530. this.rolloffFactor = options.rolloffFactor || 1;
  6531. this.refDistance = options.refDistance || 1;
  6532. this.distanceModel = options.distanceModel || "linear";
  6533. this._playbackRate = options.playbackRate || 1;
  6534. this._streaming = options.streaming || false;
  6535. }
  6536. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6537. this._soundGain = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createGain();
  6538. this._soundGain.gain.value = this._volume;
  6539. this._inputAudioNode = this._soundGain;
  6540. this._outputAudioNode = this._soundGain;
  6541. if (this.spatialSound) {
  6542. this._createSpatialParameters();
  6543. }
  6544. this._scene.mainSoundTrack.AddSound(this);
  6545. var validParameter = true;
  6546. // if no parameter is passed, you need to call setAudioBuffer yourself to prepare the sound
  6547. if (urlOrArrayBuffer) {
  6548. try {
  6549. if (typeof (urlOrArrayBuffer) === "string") {
  6550. this._urlType = "String";
  6551. }
  6552. else if (urlOrArrayBuffer instanceof ArrayBuffer) {
  6553. this._urlType = "ArrayBuffer";
  6554. }
  6555. else if (urlOrArrayBuffer instanceof MediaStream) {
  6556. this._urlType = "MediaStream";
  6557. }
  6558. else if (Array.isArray(urlOrArrayBuffer)) {
  6559. this._urlType = "Array";
  6560. }
  6561. var urls = [];
  6562. var codecSupportedFound = false;
  6563. switch (this._urlType) {
  6564. case "MediaStream":
  6565. this._streaming = true;
  6566. this._isReadyToPlay = true;
  6567. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(urlOrArrayBuffer);
  6568. if (this.autoplay) {
  6569. this.play();
  6570. }
  6571. if (this._readyToPlayCallback) {
  6572. this._readyToPlayCallback();
  6573. }
  6574. break;
  6575. case "ArrayBuffer":
  6576. if (urlOrArrayBuffer.byteLength > 0) {
  6577. codecSupportedFound = true;
  6578. this._soundLoaded(urlOrArrayBuffer);
  6579. }
  6580. break;
  6581. case "String":
  6582. urls.push(urlOrArrayBuffer);
  6583. case "Array":
  6584. if (urls.length === 0) {
  6585. urls = urlOrArrayBuffer;
  6586. }
  6587. // If we found a supported format, we load it immediately and stop the loop
  6588. for (var i = 0; i < urls.length; i++) {
  6589. var url = urls[i];
  6590. if (url.indexOf(".mp3", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isMP3supported) {
  6591. codecSupportedFound = true;
  6592. }
  6593. if (url.indexOf(".ogg", url.length - 4) !== -1 && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.isOGGsupported) {
  6594. codecSupportedFound = true;
  6595. }
  6596. if (url.indexOf(".wav", url.length - 4) !== -1) {
  6597. codecSupportedFound = true;
  6598. }
  6599. if (url.indexOf("blob:") !== -1) {
  6600. codecSupportedFound = true;
  6601. }
  6602. if (codecSupportedFound) {
  6603. // Loading sound using XHR2
  6604. if (!this._streaming) {
  6605. this._scene._loadFile(url, function (data) {
  6606. _this._soundLoaded(data);
  6607. }, undefined, true, true, function (exception) {
  6608. if (exception) {
  6609. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("XHR " + exception.status + " error on: " + url + ".");
  6610. }
  6611. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Sound creation aborted.");
  6612. _this._scene.mainSoundTrack.RemoveSound(_this);
  6613. });
  6614. }
  6615. // Streaming sound using HTML5 Audio tag
  6616. else {
  6617. this._htmlAudioElement = new Audio(url);
  6618. this._htmlAudioElement.controls = false;
  6619. this._htmlAudioElement.loop = this.loop;
  6620. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetCorsBehavior(url, this._htmlAudioElement);
  6621. this._htmlAudioElement.preload = "auto";
  6622. this._htmlAudioElement.addEventListener("canplaythrough", function () {
  6623. _this._isReadyToPlay = true;
  6624. if (_this.autoplay) {
  6625. _this.play();
  6626. }
  6627. if (_this._readyToPlayCallback) {
  6628. _this._readyToPlayCallback();
  6629. }
  6630. });
  6631. document.body.appendChild(this._htmlAudioElement);
  6632. this._htmlAudioElement.load();
  6633. }
  6634. break;
  6635. }
  6636. }
  6637. break;
  6638. default:
  6639. validParameter = false;
  6640. break;
  6641. }
  6642. if (!validParameter) {
  6643. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Parameter must be a URL to the sound, an Array of URLs (.mp3 & .ogg) or an ArrayBuffer of the sound.");
  6644. }
  6645. else {
  6646. if (!codecSupportedFound) {
  6647. this._isReadyToPlay = true;
  6648. // Simulating a ready to play event to avoid breaking code path
  6649. if (this._readyToPlayCallback) {
  6650. window.setTimeout(function () {
  6651. if (_this._readyToPlayCallback) {
  6652. _this._readyToPlayCallback();
  6653. }
  6654. }, 1000);
  6655. }
  6656. }
  6657. }
  6658. }
  6659. catch (ex) {
  6660. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Unexpected error. Sound creation aborted.");
  6661. this._scene.mainSoundTrack.RemoveSound(this);
  6662. }
  6663. }
  6664. }
  6665. else {
  6666. // Adding an empty sound to avoid breaking audio calls for non Web Audio browsers
  6667. this._scene.mainSoundTrack.AddSound(this);
  6668. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported) {
  6669. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Web Audio is not supported by your browser.");
  6670. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.WarnedWebAudioUnsupported = true;
  6671. }
  6672. // Simulating a ready to play event to avoid breaking code for non web audio browsers
  6673. if (this._readyToPlayCallback) {
  6674. window.setTimeout(function () {
  6675. if (_this._readyToPlayCallback) {
  6676. _this._readyToPlayCallback();
  6677. }
  6678. }, 1000);
  6679. }
  6680. }
  6681. }
  6682. /**
  6683. * Release the sound and its associated resources
  6684. */
  6685. Sound.prototype.dispose = function () {
  6686. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6687. if (this.isPlaying) {
  6688. this.stop();
  6689. }
  6690. this._isReadyToPlay = false;
  6691. if (this.soundTrackId === -1) {
  6692. this._scene.mainSoundTrack.RemoveSound(this);
  6693. }
  6694. else if (this._scene.soundTracks) {
  6695. this._scene.soundTracks[this.soundTrackId].RemoveSound(this);
  6696. }
  6697. if (this._soundGain) {
  6698. this._soundGain.disconnect();
  6699. this._soundGain = null;
  6700. }
  6701. if (this._soundPanner) {
  6702. this._soundPanner.disconnect();
  6703. this._soundPanner = null;
  6704. }
  6705. if (this._soundSource) {
  6706. this._soundSource.disconnect();
  6707. this._soundSource = null;
  6708. }
  6709. this._audioBuffer = null;
  6710. if (this._htmlAudioElement) {
  6711. this._htmlAudioElement.pause();
  6712. this._htmlAudioElement.src = "";
  6713. document.body.removeChild(this._htmlAudioElement);
  6714. }
  6715. if (this._streamingSource) {
  6716. this._streamingSource.disconnect();
  6717. }
  6718. if (this._connectedTransformNode && this._registerFunc) {
  6719. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  6720. this._connectedTransformNode = null;
  6721. }
  6722. }
  6723. };
  6724. /**
  6725. * Gets if the sounds is ready to be played or not.
  6726. * @returns true if ready, otherwise false
  6727. */
  6728. Sound.prototype.isReady = function () {
  6729. return this._isReadyToPlay;
  6730. };
  6731. Sound.prototype._soundLoaded = function (audioData) {
  6732. var _this = this;
  6733. if (!_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6734. return;
  6735. }
  6736. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.decodeAudioData(audioData, function (buffer) {
  6737. _this._audioBuffer = buffer;
  6738. _this._isReadyToPlay = true;
  6739. if (_this.autoplay) {
  6740. _this.play();
  6741. }
  6742. if (_this._readyToPlayCallback) {
  6743. _this._readyToPlayCallback();
  6744. }
  6745. }, function (err) { _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while decoding audio data for: " + _this.name + " / Error: " + err); });
  6746. };
  6747. /**
  6748. * Sets the data of the sound from an audiobuffer
  6749. * @param audioBuffer The audioBuffer containing the data
  6750. */
  6751. Sound.prototype.setAudioBuffer = function (audioBuffer) {
  6752. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6753. this._audioBuffer = audioBuffer;
  6754. this._isReadyToPlay = true;
  6755. }
  6756. };
  6757. /**
  6758. * Updates the current sounds options such as maxdistance, loop...
  6759. * @param options A JSON object containing values named as the object properties
  6760. */
  6761. Sound.prototype.updateOptions = function (options) {
  6762. if (options) {
  6763. this.loop = options.loop || this.loop;
  6764. this.maxDistance = options.maxDistance || this.maxDistance;
  6765. this.useCustomAttenuation = options.useCustomAttenuation || this.useCustomAttenuation;
  6766. this.rolloffFactor = options.rolloffFactor || this.rolloffFactor;
  6767. this.refDistance = options.refDistance || this.refDistance;
  6768. this.distanceModel = options.distanceModel || this.distanceModel;
  6769. this._playbackRate = options.playbackRate || this._playbackRate;
  6770. this._updateSpatialParameters();
  6771. if (this.isPlaying) {
  6772. if (this._streaming && this._htmlAudioElement) {
  6773. this._htmlAudioElement.playbackRate = this._playbackRate;
  6774. }
  6775. else {
  6776. if (this._soundSource) {
  6777. this._soundSource.playbackRate.value = this._playbackRate;
  6778. }
  6779. }
  6780. }
  6781. }
  6782. };
  6783. Sound.prototype._createSpatialParameters = function () {
  6784. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6785. if (this._scene.headphone) {
  6786. this._panningModel = "HRTF";
  6787. }
  6788. this._soundPanner = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createPanner();
  6789. this._updateSpatialParameters();
  6790. this._soundPanner.connect(this._outputAudioNode);
  6791. this._inputAudioNode = this._soundPanner;
  6792. }
  6793. };
  6794. Sound.prototype._updateSpatialParameters = function () {
  6795. if (this.spatialSound && this._soundPanner) {
  6796. if (this.useCustomAttenuation) {
  6797. // Tricks to disable in a way embedded Web Audio attenuation
  6798. this._soundPanner.distanceModel = "linear";
  6799. this._soundPanner.maxDistance = Number.MAX_VALUE;
  6800. this._soundPanner.refDistance = 1;
  6801. this._soundPanner.rolloffFactor = 1;
  6802. this._soundPanner.panningModel = this._panningModel;
  6803. }
  6804. else {
  6805. this._soundPanner.distanceModel = this.distanceModel;
  6806. this._soundPanner.maxDistance = this.maxDistance;
  6807. this._soundPanner.refDistance = this.refDistance;
  6808. this._soundPanner.rolloffFactor = this.rolloffFactor;
  6809. this._soundPanner.panningModel = this._panningModel;
  6810. }
  6811. }
  6812. };
  6813. /**
  6814. * Switch the panning model to HRTF:
  6815. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  6816. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6817. */
  6818. Sound.prototype.switchPanningModelToHRTF = function () {
  6819. this._panningModel = "HRTF";
  6820. this._switchPanningModel();
  6821. };
  6822. /**
  6823. * Switch the panning model to Equal Power:
  6824. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  6825. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  6826. */
  6827. Sound.prototype.switchPanningModelToEqualPower = function () {
  6828. this._panningModel = "equalpower";
  6829. this._switchPanningModel();
  6830. };
  6831. Sound.prototype._switchPanningModel = function () {
  6832. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6833. this._soundPanner.panningModel = this._panningModel;
  6834. }
  6835. };
  6836. /**
  6837. * Connect this sound to a sound track audio node like gain...
  6838. * @param soundTrackAudioNode the sound track audio node to connect to
  6839. */
  6840. Sound.prototype.connectToSoundTrackAudioNode = function (soundTrackAudioNode) {
  6841. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio) {
  6842. if (this._isOutputConnected) {
  6843. this._outputAudioNode.disconnect();
  6844. }
  6845. this._outputAudioNode.connect(soundTrackAudioNode);
  6846. this._isOutputConnected = true;
  6847. }
  6848. };
  6849. /**
  6850. * Transform this sound into a directional source
  6851. * @param coneInnerAngle Size of the inner cone in degree
  6852. * @param coneOuterAngle Size of the outer cone in degree
  6853. * @param coneOuterGain Volume of the sound outside the outer cone (between 0.0 and 1.0)
  6854. */
  6855. Sound.prototype.setDirectionalCone = function (coneInnerAngle, coneOuterAngle, coneOuterGain) {
  6856. if (coneOuterAngle < coneInnerAngle) {
  6857. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("setDirectionalCone(): outer angle of the cone must be superior or equal to the inner angle.");
  6858. return;
  6859. }
  6860. this._coneInnerAngle = coneInnerAngle;
  6861. this._coneOuterAngle = coneOuterAngle;
  6862. this._coneOuterGain = coneOuterGain;
  6863. this._isDirectional = true;
  6864. if (this.isPlaying && this.loop) {
  6865. this.stop();
  6866. this.play();
  6867. }
  6868. };
  6869. Object.defineProperty(Sound.prototype, "directionalConeInnerAngle", {
  6870. /**
  6871. * Gets or sets the inner angle for the directional cone.
  6872. */
  6873. get: function () {
  6874. return this._coneInnerAngle;
  6875. },
  6876. /**
  6877. * Gets or sets the inner angle for the directional cone.
  6878. */
  6879. set: function (value) {
  6880. if (value != this._coneInnerAngle) {
  6881. if (this._coneOuterAngle < value) {
  6882. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6883. return;
  6884. }
  6885. this._coneInnerAngle = value;
  6886. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6887. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6888. }
  6889. }
  6890. },
  6891. enumerable: true,
  6892. configurable: true
  6893. });
  6894. Object.defineProperty(Sound.prototype, "directionalConeOuterAngle", {
  6895. /**
  6896. * Gets or sets the outer angle for the directional cone.
  6897. */
  6898. get: function () {
  6899. return this._coneOuterAngle;
  6900. },
  6901. /**
  6902. * Gets or sets the outer angle for the directional cone.
  6903. */
  6904. set: function (value) {
  6905. if (value != this._coneOuterAngle) {
  6906. if (value < this._coneInnerAngle) {
  6907. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  6908. return;
  6909. }
  6910. this._coneOuterAngle = value;
  6911. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner) {
  6912. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6913. }
  6914. }
  6915. },
  6916. enumerable: true,
  6917. configurable: true
  6918. });
  6919. /**
  6920. * Sets the position of the emitter if spatial sound is enabled
  6921. * @param newPosition Defines the new posisiton
  6922. */
  6923. Sound.prototype.setPosition = function (newPosition) {
  6924. this._position = newPosition;
  6925. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this.spatialSound && this._soundPanner && !isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6926. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6927. }
  6928. };
  6929. /**
  6930. * Sets the local direction of the emitter if spatial sound is enabled
  6931. * @param newLocalDirection Defines the new local direction
  6932. */
  6933. Sound.prototype.setLocalDirectionToMesh = function (newLocalDirection) {
  6934. this._localDirection = newLocalDirection;
  6935. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.isPlaying) {
  6936. this._updateDirection();
  6937. }
  6938. };
  6939. Sound.prototype._updateDirection = function () {
  6940. if (!this._connectedTransformNode || !this._soundPanner) {
  6941. return;
  6942. }
  6943. var mat = this._connectedTransformNode.getWorldMatrix();
  6944. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(this._localDirection, mat);
  6945. direction.normalize();
  6946. this._soundPanner.setOrientation(direction.x, direction.y, direction.z);
  6947. };
  6948. /** @hidden */
  6949. Sound.prototype.updateDistanceFromListener = function () {
  6950. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._connectedTransformNode && this.useCustomAttenuation && this._soundGain && this._scene.activeCamera) {
  6951. var distance = this._connectedTransformNode.getDistanceToCamera(this._scene.activeCamera);
  6952. this._soundGain.gain.value = this._customAttenuationFunction(this._volume, distance, this.maxDistance, this.refDistance, this.rolloffFactor);
  6953. }
  6954. };
  6955. /**
  6956. * Sets a new custom attenuation function for the sound.
  6957. * @param callback Defines the function used for the attenuation
  6958. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-your-own-custom-attenuation-function
  6959. */
  6960. Sound.prototype.setAttenuationFunction = function (callback) {
  6961. this._customAttenuationFunction = callback;
  6962. };
  6963. /**
  6964. * Play the sound
  6965. * @param time (optional) Start the sound after X seconds. Start immediately (0) by default.
  6966. * @param offset (optional) Start the sound setting it at a specific time
  6967. */
  6968. Sound.prototype.play = function (time, offset) {
  6969. var _this = this;
  6970. if (this._isReadyToPlay && this._scene.audioEnabled && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  6971. try {
  6972. if (this._startOffset < 0) {
  6973. time = -this._startOffset;
  6974. this._startOffset = 0;
  6975. }
  6976. var startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  6977. if (!this._soundSource || !this._streamingSource) {
  6978. if (this.spatialSound && this._soundPanner) {
  6979. if (!isNaN(this._position.x) && !isNaN(this._position.y) && !isNaN(this._position.z)) {
  6980. this._soundPanner.setPosition(this._position.x, this._position.y, this._position.z);
  6981. }
  6982. if (this._isDirectional) {
  6983. this._soundPanner.coneInnerAngle = this._coneInnerAngle;
  6984. this._soundPanner.coneOuterAngle = this._coneOuterAngle;
  6985. this._soundPanner.coneOuterGain = this._coneOuterGain;
  6986. if (this._connectedTransformNode) {
  6987. this._updateDirection();
  6988. }
  6989. else {
  6990. this._soundPanner.setOrientation(this._localDirection.x, this._localDirection.y, this._localDirection.z);
  6991. }
  6992. }
  6993. }
  6994. }
  6995. if (this._streaming) {
  6996. if (!this._streamingSource) {
  6997. this._streamingSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createMediaElementSource(this._htmlAudioElement);
  6998. this._htmlAudioElement.onended = function () { _this._onended(); };
  6999. this._htmlAudioElement.playbackRate = this._playbackRate;
  7000. }
  7001. this._streamingSource.disconnect();
  7002. this._streamingSource.connect(this._inputAudioNode);
  7003. if (this._htmlAudioElement) {
  7004. // required to manage properly the new suspended default state of Chrome
  7005. // When the option 'streaming: true' is used, we need first to wait for
  7006. // the audio engine to be unlocked by a user gesture before trying to play
  7007. // an HTML Audio elememt
  7008. var tryToPlay = function () {
  7009. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.unlocked) {
  7010. var playPromise = _this._htmlAudioElement.play();
  7011. // In browsers that don’t yet support this functionality,
  7012. // playPromise won’t be defined.
  7013. if (playPromise !== undefined) {
  7014. playPromise.catch(function (error) {
  7015. // Automatic playback failed.
  7016. // Waiting for the audio engine to be unlocked by user click on unmute
  7017. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7018. if (_this.loop || _this.autoplay) {
  7019. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7020. }
  7021. });
  7022. }
  7023. }
  7024. else {
  7025. if (_this.loop || _this.autoplay) {
  7026. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7027. }
  7028. }
  7029. };
  7030. tryToPlay();
  7031. }
  7032. }
  7033. else {
  7034. var tryToPlay = function () {
  7035. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7036. _this._soundSource = _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.createBufferSource();
  7037. _this._soundSource.buffer = _this._audioBuffer;
  7038. _this._soundSource.connect(_this._inputAudioNode);
  7039. _this._soundSource.loop = _this.loop;
  7040. _this._soundSource.playbackRate.value = _this._playbackRate;
  7041. _this._soundSource.onended = function () { _this._onended(); };
  7042. startTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7043. _this._soundSource.start(startTime, _this.isPaused ? _this._startOffset % _this._soundSource.buffer.duration : offset ? offset : 0);
  7044. }
  7045. };
  7046. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7047. // Wait a bit for FF as context seems late to be ready.
  7048. setTimeout(function () {
  7049. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.state === "suspended") {
  7050. // Automatic playback failed.
  7051. // Waiting for the audio engine to be unlocked by user click on unmute
  7052. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.lock();
  7053. if (_this.loop || _this.autoplay) {
  7054. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.onAudioUnlockedObservable.addOnce(function () { tryToPlay(); });
  7055. }
  7056. }
  7057. else {
  7058. tryToPlay();
  7059. }
  7060. }, 500);
  7061. }
  7062. else {
  7063. tryToPlay();
  7064. }
  7065. }
  7066. this._startTime = startTime;
  7067. this.isPlaying = true;
  7068. this.isPaused = false;
  7069. }
  7070. catch (ex) {
  7071. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Error while trying to play audio: " + this.name + ", " + ex.message);
  7072. }
  7073. }
  7074. };
  7075. Sound.prototype._onended = function () {
  7076. this.isPlaying = false;
  7077. if (this.onended) {
  7078. this.onended();
  7079. }
  7080. this.onEndedObservable.notifyObservers(this);
  7081. };
  7082. /**
  7083. * Stop the sound
  7084. * @param time (optional) Stop the sound after X seconds. Stop immediately (0) by default.
  7085. */
  7086. Sound.prototype.stop = function (time) {
  7087. if (this.isPlaying) {
  7088. if (this._streaming) {
  7089. if (this._htmlAudioElement) {
  7090. this._htmlAudioElement.pause();
  7091. // Test needed for Firefox or it will generate an Invalid State Error
  7092. if (this._htmlAudioElement.currentTime > 0) {
  7093. this._htmlAudioElement.currentTime = 0;
  7094. }
  7095. }
  7096. else {
  7097. this._streamingSource.disconnect();
  7098. }
  7099. }
  7100. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext && this._soundSource) {
  7101. var stopTime = time ? _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time : _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime;
  7102. this._soundSource.stop(stopTime);
  7103. this._soundSource.onended = function () { };
  7104. if (!this.isPaused) {
  7105. this._startOffset = 0;
  7106. }
  7107. }
  7108. this.isPlaying = false;
  7109. }
  7110. };
  7111. /**
  7112. * Put the sound in pause
  7113. */
  7114. Sound.prototype.pause = function () {
  7115. if (this.isPlaying) {
  7116. this.isPaused = true;
  7117. if (this._streaming) {
  7118. if (this._htmlAudioElement) {
  7119. this._htmlAudioElement.pause();
  7120. }
  7121. else {
  7122. this._streamingSource.disconnect();
  7123. }
  7124. }
  7125. else if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7126. this.stop(0);
  7127. this._startOffset += _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime - this._startTime;
  7128. }
  7129. }
  7130. };
  7131. /**
  7132. * Sets a dedicated volume for this sounds
  7133. * @param newVolume Define the new volume of the sound
  7134. * @param time Define in how long the sound should be at this value
  7135. */
  7136. Sound.prototype.setVolume = function (newVolume, time) {
  7137. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._soundGain) {
  7138. if (time && _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext) {
  7139. this._soundGain.gain.cancelScheduledValues(_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7140. this._soundGain.gain.setValueAtTime(this._soundGain.gain.value, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime);
  7141. this._soundGain.gain.linearRampToValueAtTime(newVolume, _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.audioContext.currentTime + time);
  7142. }
  7143. else {
  7144. this._soundGain.gain.value = newVolume;
  7145. }
  7146. }
  7147. this._volume = newVolume;
  7148. };
  7149. /**
  7150. * Set the sound play back rate
  7151. * @param newPlaybackRate Define the playback rate the sound should be played at
  7152. */
  7153. Sound.prototype.setPlaybackRate = function (newPlaybackRate) {
  7154. this._playbackRate = newPlaybackRate;
  7155. if (this.isPlaying) {
  7156. if (this._streaming && this._htmlAudioElement) {
  7157. this._htmlAudioElement.playbackRate = this._playbackRate;
  7158. }
  7159. else if (this._soundSource) {
  7160. this._soundSource.playbackRate.value = this._playbackRate;
  7161. }
  7162. }
  7163. };
  7164. /**
  7165. * Gets the volume of the sound.
  7166. * @returns the volume of the sound
  7167. */
  7168. Sound.prototype.getVolume = function () {
  7169. return this._volume;
  7170. };
  7171. /**
  7172. * Attach the sound to a dedicated mesh
  7173. * @param transformNode The transform node to connect the sound with
  7174. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7175. */
  7176. Sound.prototype.attachToMesh = function (transformNode) {
  7177. var _this = this;
  7178. if (this._connectedTransformNode && this._registerFunc) {
  7179. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7180. this._registerFunc = null;
  7181. }
  7182. this._connectedTransformNode = transformNode;
  7183. if (!this.spatialSound) {
  7184. this.spatialSound = true;
  7185. this._createSpatialParameters();
  7186. if (this.isPlaying && this.loop) {
  7187. this.stop();
  7188. this.play();
  7189. }
  7190. }
  7191. this._onRegisterAfterWorldMatrixUpdate(this._connectedTransformNode);
  7192. this._registerFunc = function (transformNode) { return _this._onRegisterAfterWorldMatrixUpdate(transformNode); };
  7193. this._connectedTransformNode.registerAfterWorldMatrixUpdate(this._registerFunc);
  7194. };
  7195. /**
  7196. * Detach the sound from the previously attached mesh
  7197. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#attaching-a-sound-to-a-mesh
  7198. */
  7199. Sound.prototype.detachFromMesh = function () {
  7200. if (this._connectedTransformNode && this._registerFunc) {
  7201. this._connectedTransformNode.unregisterAfterWorldMatrixUpdate(this._registerFunc);
  7202. this._registerFunc = null;
  7203. this._connectedTransformNode = null;
  7204. }
  7205. };
  7206. Sound.prototype._onRegisterAfterWorldMatrixUpdate = function (node) {
  7207. if (!node.getBoundingInfo) {
  7208. return;
  7209. }
  7210. var mesh = node;
  7211. if (this._positionInEmitterSpace) {
  7212. mesh.worldMatrixFromCache.invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0]);
  7213. this.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[0].getTranslation());
  7214. }
  7215. else {
  7216. var boundingInfo = mesh.getBoundingInfo();
  7217. this.setPosition(boundingInfo.boundingSphere.centerWorld);
  7218. }
  7219. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].audioEngine.canUseWebAudio && this._isDirectional && this.isPlaying) {
  7220. this._updateDirection();
  7221. }
  7222. };
  7223. /**
  7224. * Clone the current sound in the scene.
  7225. * @returns the new sound clone
  7226. */
  7227. Sound.prototype.clone = function () {
  7228. var _this = this;
  7229. if (!this._streaming) {
  7230. var setBufferAndRun = function () {
  7231. if (_this._isReadyToPlay) {
  7232. clonedSound._audioBuffer = _this.getAudioBuffer();
  7233. clonedSound._isReadyToPlay = true;
  7234. if (clonedSound.autoplay) {
  7235. clonedSound.play();
  7236. }
  7237. }
  7238. else {
  7239. window.setTimeout(setBufferAndRun, 300);
  7240. }
  7241. };
  7242. var currentOptions = {
  7243. autoplay: this.autoplay, loop: this.loop,
  7244. volume: this._volume, spatialSound: this.spatialSound, maxDistance: this.maxDistance,
  7245. useCustomAttenuation: this.useCustomAttenuation, rolloffFactor: this.rolloffFactor,
  7246. refDistance: this.refDistance, distanceModel: this.distanceModel
  7247. };
  7248. var clonedSound = new Sound(this.name + "_cloned", new ArrayBuffer(0), this._scene, null, currentOptions);
  7249. if (this.useCustomAttenuation) {
  7250. clonedSound.setAttenuationFunction(this._customAttenuationFunction);
  7251. }
  7252. clonedSound.setPosition(this._position);
  7253. clonedSound.setPlaybackRate(this._playbackRate);
  7254. setBufferAndRun();
  7255. return clonedSound;
  7256. }
  7257. // Can't clone a streaming sound
  7258. else {
  7259. return null;
  7260. }
  7261. };
  7262. /**
  7263. * Gets the current underlying audio buffer containing the data
  7264. * @returns the audio buffer
  7265. */
  7266. Sound.prototype.getAudioBuffer = function () {
  7267. return this._audioBuffer;
  7268. };
  7269. /**
  7270. * Serializes the Sound in a JSON representation
  7271. * @returns the JSON representation of the sound
  7272. */
  7273. Sound.prototype.serialize = function () {
  7274. var serializationObject = {
  7275. name: this.name,
  7276. url: this.name,
  7277. autoplay: this.autoplay,
  7278. loop: this.loop,
  7279. volume: this._volume,
  7280. spatialSound: this.spatialSound,
  7281. maxDistance: this.maxDistance,
  7282. rolloffFactor: this.rolloffFactor,
  7283. refDistance: this.refDistance,
  7284. distanceModel: this.distanceModel,
  7285. playbackRate: this._playbackRate,
  7286. panningModel: this._panningModel,
  7287. soundTrackId: this.soundTrackId
  7288. };
  7289. if (this.spatialSound) {
  7290. if (this._connectedTransformNode) {
  7291. serializationObject.connectedMeshId = this._connectedTransformNode.id;
  7292. }
  7293. serializationObject.position = this._position.asArray();
  7294. serializationObject.refDistance = this.refDistance;
  7295. serializationObject.distanceModel = this.distanceModel;
  7296. serializationObject.isDirectional = this._isDirectional;
  7297. serializationObject.localDirectionToMesh = this._localDirection.asArray();
  7298. serializationObject.coneInnerAngle = this._coneInnerAngle;
  7299. serializationObject.coneOuterAngle = this._coneOuterAngle;
  7300. serializationObject.coneOuterGain = this._coneOuterGain;
  7301. }
  7302. return serializationObject;
  7303. };
  7304. /**
  7305. * Parse a JSON representation of a sound to innstantiate in a given scene
  7306. * @param parsedSound Define the JSON representation of the sound (usually coming from the serialize method)
  7307. * @param scene Define the scene the new parsed sound should be created in
  7308. * @param rootUrl Define the rooturl of the load in case we need to fetch relative dependencies
  7309. * @param sourceSound Define a cound place holder if do not need to instantiate a new one
  7310. * @returns the newly parsed sound
  7311. */
  7312. Sound.Parse = function (parsedSound, scene, rootUrl, sourceSound) {
  7313. var soundName = parsedSound.name;
  7314. var soundUrl;
  7315. if (parsedSound.url) {
  7316. soundUrl = rootUrl + parsedSound.url;
  7317. }
  7318. else {
  7319. soundUrl = rootUrl + soundName;
  7320. }
  7321. var options = {
  7322. autoplay: parsedSound.autoplay, loop: parsedSound.loop, volume: parsedSound.volume,
  7323. spatialSound: parsedSound.spatialSound, maxDistance: parsedSound.maxDistance,
  7324. rolloffFactor: parsedSound.rolloffFactor,
  7325. refDistance: parsedSound.refDistance,
  7326. distanceModel: parsedSound.distanceModel,
  7327. playbackRate: parsedSound.playbackRate
  7328. };
  7329. var newSound;
  7330. if (!sourceSound) {
  7331. newSound = new Sound(soundName, soundUrl, scene, function () { scene._removePendingData(newSound); }, options);
  7332. scene._addPendingData(newSound);
  7333. }
  7334. else {
  7335. var setBufferAndRun = function () {
  7336. if (sourceSound._isReadyToPlay) {
  7337. newSound._audioBuffer = sourceSound.getAudioBuffer();
  7338. newSound._isReadyToPlay = true;
  7339. if (newSound.autoplay) {
  7340. newSound.play();
  7341. }
  7342. }
  7343. else {
  7344. window.setTimeout(setBufferAndRun, 300);
  7345. }
  7346. };
  7347. newSound = new Sound(soundName, new ArrayBuffer(0), scene, null, options);
  7348. setBufferAndRun();
  7349. }
  7350. if (parsedSound.position) {
  7351. var soundPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.position);
  7352. newSound.setPosition(soundPosition);
  7353. }
  7354. if (parsedSound.isDirectional) {
  7355. newSound.setDirectionalCone(parsedSound.coneInnerAngle || 360, parsedSound.coneOuterAngle || 360, parsedSound.coneOuterGain || 0);
  7356. if (parsedSound.localDirectionToMesh) {
  7357. var localDirectionToMesh = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSound.localDirectionToMesh);
  7358. newSound.setLocalDirectionToMesh(localDirectionToMesh);
  7359. }
  7360. }
  7361. if (parsedSound.connectedMeshId) {
  7362. var connectedMesh = scene.getMeshByID(parsedSound.connectedMeshId);
  7363. if (connectedMesh) {
  7364. newSound.attachToMesh(connectedMesh);
  7365. }
  7366. }
  7367. return newSound;
  7368. };
  7369. /** @hidden */
  7370. Sound._SceneComponentInitialization = function (_) {
  7371. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AudioSceneComponent");
  7372. };
  7373. return Sound;
  7374. }());
  7375. /***/ }),
  7376. /***/ "./Audio/soundTrack.ts":
  7377. /*!*****************************!*\
  7378. !*** ./Audio/soundTrack.ts ***!
  7379. \*****************************/
  7380. /*! exports provided: SoundTrack */
  7381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7382. "use strict";
  7383. __webpack_require__.r(__webpack_exports__);
  7384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return SoundTrack; });
  7385. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  7386. /**
  7387. * It could be useful to isolate your music & sounds on several tracks to better manage volume on a grouped instance of sounds.
  7388. * It will be also used in a future release to apply effects on a specific track.
  7389. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7390. */
  7391. var SoundTrack = /** @class */ (function () {
  7392. /**
  7393. * Creates a new sound track.
  7394. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-sound-tracks
  7395. * @param scene Define the scene the sound track belongs to
  7396. * @param options
  7397. */
  7398. function SoundTrack(scene, options) {
  7399. if (options === void 0) { options = {}; }
  7400. /**
  7401. * The unique identifier of the sound track in the scene.
  7402. */
  7403. this.id = -1;
  7404. this._isMainTrack = false;
  7405. this._isInitialized = false;
  7406. this._scene = scene;
  7407. this.soundCollection = new Array();
  7408. this._options = options;
  7409. if (!this._isMainTrack && this._scene.soundTracks) {
  7410. this._scene.soundTracks.push(this);
  7411. this.id = this._scene.soundTracks.length - 1;
  7412. }
  7413. }
  7414. SoundTrack.prototype._initializeSoundTrackAudioGraph = function () {
  7415. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext) {
  7416. this._outputAudioNode = _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.audioContext.createGain();
  7417. this._outputAudioNode.connect(_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7418. if (this._options) {
  7419. if (this._options.volume) {
  7420. this._outputAudioNode.gain.value = this._options.volume;
  7421. }
  7422. if (this._options.mainTrack) {
  7423. this._isMainTrack = this._options.mainTrack;
  7424. }
  7425. }
  7426. this._isInitialized = true;
  7427. }
  7428. };
  7429. /**
  7430. * Release the sound track and its associated resources
  7431. */
  7432. SoundTrack.prototype.dispose = function () {
  7433. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine && _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7434. if (this._connectedAnalyser) {
  7435. this._connectedAnalyser.stopDebugCanvas();
  7436. }
  7437. while (this.soundCollection.length) {
  7438. this.soundCollection[0].dispose();
  7439. }
  7440. if (this._outputAudioNode) {
  7441. this._outputAudioNode.disconnect();
  7442. }
  7443. this._outputAudioNode = null;
  7444. }
  7445. };
  7446. /**
  7447. * Adds a sound to this sound track
  7448. * @param sound define the cound to add
  7449. * @ignoreNaming
  7450. */
  7451. SoundTrack.prototype.AddSound = function (sound) {
  7452. if (!this._isInitialized) {
  7453. this._initializeSoundTrackAudioGraph();
  7454. }
  7455. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7456. sound.connectToSoundTrackAudioNode(this._outputAudioNode);
  7457. }
  7458. if (sound.soundTrackId) {
  7459. if (sound.soundTrackId === -1) {
  7460. this._scene.mainSoundTrack.RemoveSound(sound);
  7461. }
  7462. else if (this._scene.soundTracks) {
  7463. this._scene.soundTracks[sound.soundTrackId].RemoveSound(sound);
  7464. }
  7465. }
  7466. this.soundCollection.push(sound);
  7467. sound.soundTrackId = this.id;
  7468. };
  7469. /**
  7470. * Removes a sound to this sound track
  7471. * @param sound define the cound to remove
  7472. * @ignoreNaming
  7473. */
  7474. SoundTrack.prototype.RemoveSound = function (sound) {
  7475. var index = this.soundCollection.indexOf(sound);
  7476. if (index !== -1) {
  7477. this.soundCollection.splice(index, 1);
  7478. }
  7479. };
  7480. /**
  7481. * Set a global volume for the full sound track.
  7482. * @param newVolume Define the new volume of the sound track
  7483. */
  7484. SoundTrack.prototype.setVolume = function (newVolume) {
  7485. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7486. this._outputAudioNode.gain.value = newVolume;
  7487. }
  7488. };
  7489. /**
  7490. * Switch the panning model to HRTF:
  7491. * Renders a stereo output of higher quality than equalpower — it uses a convolution with measured impulse responses from human subjects.
  7492. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7493. */
  7494. SoundTrack.prototype.switchPanningModelToHRTF = function () {
  7495. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7496. for (var i = 0; i < this.soundCollection.length; i++) {
  7497. this.soundCollection[i].switchPanningModelToHRTF();
  7498. }
  7499. }
  7500. };
  7501. /**
  7502. * Switch the panning model to Equal Power:
  7503. * Represents the equal-power panning algorithm, generally regarded as simple and efficient. equalpower is the default value.
  7504. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#creating-a-spatial-3d-sound
  7505. */
  7506. SoundTrack.prototype.switchPanningModelToEqualPower = function () {
  7507. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio) {
  7508. for (var i = 0; i < this.soundCollection.length; i++) {
  7509. this.soundCollection[i].switchPanningModelToEqualPower();
  7510. }
  7511. }
  7512. };
  7513. /**
  7514. * Connect the sound track to an audio analyser allowing some amazing
  7515. * synchornization between the sounds/music and your visualization (VuMeter for instance).
  7516. * @see http://doc.babylonjs.com/how_to/playing_sounds_and_music#using-the-analyser
  7517. * @param analyser The analyser to connect to the engine
  7518. */
  7519. SoundTrack.prototype.connectToAnalyser = function (analyser) {
  7520. if (this._connectedAnalyser) {
  7521. this._connectedAnalyser.stopDebugCanvas();
  7522. }
  7523. this._connectedAnalyser = analyser;
  7524. if (_Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.canUseWebAudio && this._outputAudioNode) {
  7525. this._outputAudioNode.disconnect();
  7526. this._connectedAnalyser.connectAudioNodes(this._outputAudioNode, _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].audioEngine.masterGain);
  7527. }
  7528. };
  7529. return SoundTrack;
  7530. }());
  7531. /***/ }),
  7532. /***/ "./Audio/weightedsound.ts":
  7533. /*!********************************!*\
  7534. !*** ./Audio/weightedsound.ts ***!
  7535. \********************************/
  7536. /*! exports provided: WeightedSound */
  7537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7538. "use strict";
  7539. __webpack_require__.r(__webpack_exports__);
  7540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return WeightedSound; });
  7541. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  7542. /**
  7543. * Wraps one or more Sound objects and selects one with random weight for playback.
  7544. */
  7545. var WeightedSound = /** @class */ (function () {
  7546. /**
  7547. * Creates a new WeightedSound from the list of sounds given.
  7548. * @param loop When true a Sound will be selected and played when the current playing Sound completes.
  7549. * @param sounds Array of Sounds that will be selected from.
  7550. * @param weights Array of number values for selection weights; length must equal sounds, values will be normalized to 1
  7551. */
  7552. function WeightedSound(loop, sounds, weights) {
  7553. var _this = this;
  7554. /** When true a Sound will be selected and played when the current playing Sound completes. */
  7555. this.loop = false;
  7556. this._coneInnerAngle = 360;
  7557. this._coneOuterAngle = 360;
  7558. this._volume = 1;
  7559. /** A Sound is currently playing. */
  7560. this.isPlaying = false;
  7561. /** A Sound is currently paused. */
  7562. this.isPaused = false;
  7563. this._sounds = [];
  7564. this._weights = [];
  7565. if (sounds.length !== weights.length) {
  7566. throw new Error('Sounds length does not equal weights length');
  7567. }
  7568. this.loop = loop;
  7569. this._weights = weights;
  7570. // Normalize the weights
  7571. var weightSum = 0;
  7572. for (var _i = 0, weights_1 = weights; _i < weights_1.length; _i++) {
  7573. var weight = weights_1[_i];
  7574. weightSum += weight;
  7575. }
  7576. var invWeightSum = weightSum > 0 ? 1 / weightSum : 0;
  7577. for (var i = 0; i < this._weights.length; i++) {
  7578. this._weights[i] *= invWeightSum;
  7579. }
  7580. this._sounds = sounds;
  7581. for (var _a = 0, _b = this._sounds; _a < _b.length; _a++) {
  7582. var sound = _b[_a];
  7583. sound.onEndedObservable.add(function () { _this._onended(); });
  7584. }
  7585. }
  7586. Object.defineProperty(WeightedSound.prototype, "directionalConeInnerAngle", {
  7587. /**
  7588. * The size of cone in degrees for a directional sound in which there will be no attenuation.
  7589. */
  7590. get: function () {
  7591. return this._coneInnerAngle;
  7592. },
  7593. /**
  7594. * The size of cone in degress for a directional sound in which there will be no attenuation.
  7595. */
  7596. set: function (value) {
  7597. if (value !== this._coneInnerAngle) {
  7598. if (this._coneOuterAngle < value) {
  7599. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeInnerAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7600. return;
  7601. }
  7602. this._coneInnerAngle = value;
  7603. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7604. var sound = _a[_i];
  7605. sound.directionalConeInnerAngle = value;
  7606. }
  7607. }
  7608. },
  7609. enumerable: true,
  7610. configurable: true
  7611. });
  7612. Object.defineProperty(WeightedSound.prototype, "directionalConeOuterAngle", {
  7613. /**
  7614. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7615. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7616. */
  7617. get: function () {
  7618. return this._coneOuterAngle;
  7619. },
  7620. /**
  7621. * Size of cone in degrees for a directional sound outside of which there will be no sound.
  7622. * Listener angles between innerAngle and outerAngle will falloff linearly.
  7623. */
  7624. set: function (value) {
  7625. if (value !== this._coneOuterAngle) {
  7626. if (value < this._coneInnerAngle) {
  7627. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("directionalConeOuterAngle: outer angle of the cone must be superior or equal to the inner angle.");
  7628. return;
  7629. }
  7630. this._coneOuterAngle = value;
  7631. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7632. var sound = _a[_i];
  7633. sound.directionalConeOuterAngle = value;
  7634. }
  7635. }
  7636. },
  7637. enumerable: true,
  7638. configurable: true
  7639. });
  7640. Object.defineProperty(WeightedSound.prototype, "volume", {
  7641. /**
  7642. * Playback volume.
  7643. */
  7644. get: function () {
  7645. return this._volume;
  7646. },
  7647. /**
  7648. * Playback volume.
  7649. */
  7650. set: function (value) {
  7651. if (value !== this._volume) {
  7652. for (var _i = 0, _a = this._sounds; _i < _a.length; _i++) {
  7653. var sound = _a[_i];
  7654. sound.setVolume(value);
  7655. }
  7656. }
  7657. },
  7658. enumerable: true,
  7659. configurable: true
  7660. });
  7661. WeightedSound.prototype._onended = function () {
  7662. if (this._currentIndex !== undefined) {
  7663. this._sounds[this._currentIndex].autoplay = false;
  7664. }
  7665. if (this.loop && this.isPlaying) {
  7666. this.play();
  7667. }
  7668. else {
  7669. this.isPlaying = false;
  7670. }
  7671. };
  7672. /**
  7673. * Suspend playback
  7674. */
  7675. WeightedSound.prototype.pause = function () {
  7676. this.isPaused = true;
  7677. if (this._currentIndex !== undefined) {
  7678. this._sounds[this._currentIndex].pause();
  7679. }
  7680. };
  7681. /**
  7682. * Stop playback
  7683. */
  7684. WeightedSound.prototype.stop = function () {
  7685. this.isPlaying = false;
  7686. if (this._currentIndex !== undefined) {
  7687. this._sounds[this._currentIndex].stop();
  7688. }
  7689. };
  7690. /**
  7691. * Start playback.
  7692. * @param startOffset Position the clip head at a specific time in seconds.
  7693. */
  7694. WeightedSound.prototype.play = function (startOffset) {
  7695. if (!this.isPaused) {
  7696. this.stop();
  7697. var randomValue = Math.random();
  7698. var total = 0;
  7699. for (var i = 0; i < this._weights.length; i++) {
  7700. total += this._weights[i];
  7701. if (randomValue <= total) {
  7702. this._currentIndex = i;
  7703. break;
  7704. }
  7705. }
  7706. }
  7707. var sound = this._sounds[this._currentIndex];
  7708. if (sound.isReady()) {
  7709. sound.play(0, this.isPaused ? undefined : startOffset);
  7710. }
  7711. else {
  7712. sound.autoplay = true;
  7713. }
  7714. this.isPlaying = true;
  7715. this.isPaused = false;
  7716. };
  7717. return WeightedSound;
  7718. }());
  7719. /***/ }),
  7720. /***/ "./Behaviors/Cameras/autoRotationBehavior.ts":
  7721. /*!***************************************************!*\
  7722. !*** ./Behaviors/Cameras/autoRotationBehavior.ts ***!
  7723. \***************************************************/
  7724. /*! exports provided: AutoRotationBehavior */
  7725. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7726. "use strict";
  7727. __webpack_require__.r(__webpack_exports__);
  7728. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return AutoRotationBehavior; });
  7729. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  7730. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  7731. /**
  7732. * The autoRotation behavior (AutoRotationBehavior) is designed to create a smooth rotation of an ArcRotateCamera when there is no user interaction.
  7733. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  7734. */
  7735. var AutoRotationBehavior = /** @class */ (function () {
  7736. function AutoRotationBehavior() {
  7737. this._zoomStopsAnimation = false;
  7738. this._idleRotationSpeed = 0.05;
  7739. this._idleRotationWaitTime = 2000;
  7740. this._idleRotationSpinupTime = 2000;
  7741. this._isPointerDown = false;
  7742. this._lastFrameTime = null;
  7743. this._lastInteractionTime = -Infinity;
  7744. this._cameraRotationSpeed = 0;
  7745. this._lastFrameRadius = 0;
  7746. }
  7747. Object.defineProperty(AutoRotationBehavior.prototype, "name", {
  7748. /**
  7749. * Gets the name of the behavior.
  7750. */
  7751. get: function () {
  7752. return "AutoRotation";
  7753. },
  7754. enumerable: true,
  7755. configurable: true
  7756. });
  7757. Object.defineProperty(AutoRotationBehavior.prototype, "zoomStopsAnimation", {
  7758. /**
  7759. * Gets the flag that indicates if user zooming should stop animation.
  7760. */
  7761. get: function () {
  7762. return this._zoomStopsAnimation;
  7763. },
  7764. /**
  7765. * Sets the flag that indicates if user zooming should stop animation.
  7766. */
  7767. set: function (flag) {
  7768. this._zoomStopsAnimation = flag;
  7769. },
  7770. enumerable: true,
  7771. configurable: true
  7772. });
  7773. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpeed", {
  7774. /**
  7775. * Gets the default speed at which the camera rotates around the model.
  7776. */
  7777. get: function () {
  7778. return this._idleRotationSpeed;
  7779. },
  7780. /**
  7781. * Sets the default speed at which the camera rotates around the model.
  7782. */
  7783. set: function (speed) {
  7784. this._idleRotationSpeed = speed;
  7785. },
  7786. enumerable: true,
  7787. configurable: true
  7788. });
  7789. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationWaitTime", {
  7790. /**
  7791. * Gets the time (milliseconds) to wait after user interaction before the camera starts rotating.
  7792. */
  7793. get: function () {
  7794. return this._idleRotationWaitTime;
  7795. },
  7796. /**
  7797. * Sets the time (in milliseconds) to wait after user interaction before the camera starts rotating.
  7798. */
  7799. set: function (time) {
  7800. this._idleRotationWaitTime = time;
  7801. },
  7802. enumerable: true,
  7803. configurable: true
  7804. });
  7805. Object.defineProperty(AutoRotationBehavior.prototype, "idleRotationSpinupTime", {
  7806. /**
  7807. * Gets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7808. */
  7809. get: function () {
  7810. return this._idleRotationSpinupTime;
  7811. },
  7812. /**
  7813. * Sets the time (milliseconds) to take to spin up to the full idle rotation speed.
  7814. */
  7815. set: function (time) {
  7816. this._idleRotationSpinupTime = time;
  7817. },
  7818. enumerable: true,
  7819. configurable: true
  7820. });
  7821. Object.defineProperty(AutoRotationBehavior.prototype, "rotationInProgress", {
  7822. /**
  7823. * Gets a value indicating if the camera is currently rotating because of this behavior
  7824. */
  7825. get: function () {
  7826. return Math.abs(this._cameraRotationSpeed) > 0;
  7827. },
  7828. enumerable: true,
  7829. configurable: true
  7830. });
  7831. /**
  7832. * Initializes the behavior.
  7833. */
  7834. AutoRotationBehavior.prototype.init = function () {
  7835. // Do notihng
  7836. };
  7837. /**
  7838. * Attaches the behavior to its arc rotate camera.
  7839. * @param camera Defines the camera to attach the behavior to
  7840. */
  7841. AutoRotationBehavior.prototype.attach = function (camera) {
  7842. var _this = this;
  7843. this._attachedCamera = camera;
  7844. var scene = this._attachedCamera.getScene();
  7845. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  7846. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERDOWN) {
  7847. _this._isPointerDown = true;
  7848. return;
  7849. }
  7850. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"].POINTERUP) {
  7851. _this._isPointerDown = false;
  7852. }
  7853. });
  7854. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  7855. var now = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7856. var dt = 0;
  7857. if (_this._lastFrameTime != null) {
  7858. dt = now - _this._lastFrameTime;
  7859. }
  7860. _this._lastFrameTime = now;
  7861. // Stop the animation if there is user interaction and the animation should stop for this interaction
  7862. _this._applyUserInteraction();
  7863. var timeToRotation = now - _this._lastInteractionTime - _this._idleRotationWaitTime;
  7864. var scale = Math.max(Math.min(timeToRotation / (_this._idleRotationSpinupTime), 1), 0);
  7865. _this._cameraRotationSpeed = _this._idleRotationSpeed * scale;
  7866. // Step camera rotation by rotation speed
  7867. if (_this._attachedCamera) {
  7868. _this._attachedCamera.alpha -= _this._cameraRotationSpeed * (dt / 1000);
  7869. }
  7870. });
  7871. };
  7872. /**
  7873. * Detaches the behavior from its current arc rotate camera.
  7874. */
  7875. AutoRotationBehavior.prototype.detach = function () {
  7876. if (!this._attachedCamera) {
  7877. return;
  7878. }
  7879. var scene = this._attachedCamera.getScene();
  7880. if (this._onPrePointerObservableObserver) {
  7881. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  7882. }
  7883. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  7884. this._attachedCamera = null;
  7885. };
  7886. /**
  7887. * Returns true if user is scrolling.
  7888. * @return true if user is scrolling.
  7889. */
  7890. AutoRotationBehavior.prototype._userIsZooming = function () {
  7891. if (!this._attachedCamera) {
  7892. return false;
  7893. }
  7894. return this._attachedCamera.inertialRadiusOffset !== 0;
  7895. };
  7896. AutoRotationBehavior.prototype._shouldAnimationStopForInteraction = function () {
  7897. if (!this._attachedCamera) {
  7898. return false;
  7899. }
  7900. var zoomHasHitLimit = false;
  7901. if (this._lastFrameRadius === this._attachedCamera.radius && this._attachedCamera.inertialRadiusOffset !== 0) {
  7902. zoomHasHitLimit = true;
  7903. }
  7904. // Update the record of previous radius - works as an approx. indicator of hitting radius limits
  7905. this._lastFrameRadius = this._attachedCamera.radius;
  7906. return this._zoomStopsAnimation ? zoomHasHitLimit : this._userIsZooming();
  7907. };
  7908. /**
  7909. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  7910. */
  7911. AutoRotationBehavior.prototype._applyUserInteraction = function () {
  7912. if (this._userIsMoving() && !this._shouldAnimationStopForInteraction()) {
  7913. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_1__["PrecisionDate"].Now;
  7914. }
  7915. };
  7916. // Tools
  7917. AutoRotationBehavior.prototype._userIsMoving = function () {
  7918. if (!this._attachedCamera) {
  7919. return false;
  7920. }
  7921. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  7922. this._attachedCamera.inertialBetaOffset !== 0 ||
  7923. this._attachedCamera.inertialRadiusOffset !== 0 ||
  7924. this._attachedCamera.inertialPanningX !== 0 ||
  7925. this._attachedCamera.inertialPanningY !== 0 ||
  7926. this._isPointerDown;
  7927. };
  7928. return AutoRotationBehavior;
  7929. }());
  7930. /***/ }),
  7931. /***/ "./Behaviors/Cameras/bouncingBehavior.ts":
  7932. /*!***********************************************!*\
  7933. !*** ./Behaviors/Cameras/bouncingBehavior.ts ***!
  7934. \***********************************************/
  7935. /*! exports provided: BouncingBehavior */
  7936. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  7937. "use strict";
  7938. __webpack_require__.r(__webpack_exports__);
  7939. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return BouncingBehavior; });
  7940. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  7941. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  7942. /**
  7943. * Add a bouncing effect to an ArcRotateCamera when reaching a specified minimum and maximum radius
  7944. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  7945. */
  7946. var BouncingBehavior = /** @class */ (function () {
  7947. function BouncingBehavior() {
  7948. /**
  7949. * The duration of the animation, in milliseconds
  7950. */
  7951. this.transitionDuration = 450;
  7952. /**
  7953. * Length of the distance animated by the transition when lower radius is reached
  7954. */
  7955. this.lowerRadiusTransitionRange = 2;
  7956. /**
  7957. * Length of the distance animated by the transition when upper radius is reached
  7958. */
  7959. this.upperRadiusTransitionRange = -2;
  7960. this._autoTransitionRange = false;
  7961. // Animations
  7962. this._radiusIsAnimating = false;
  7963. this._radiusBounceTransition = null;
  7964. this._animatables = new Array();
  7965. }
  7966. Object.defineProperty(BouncingBehavior.prototype, "name", {
  7967. /**
  7968. * Gets the name of the behavior.
  7969. */
  7970. get: function () {
  7971. return "Bouncing";
  7972. },
  7973. enumerable: true,
  7974. configurable: true
  7975. });
  7976. Object.defineProperty(BouncingBehavior.prototype, "autoTransitionRange", {
  7977. /**
  7978. * Gets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7979. */
  7980. get: function () {
  7981. return this._autoTransitionRange;
  7982. },
  7983. /**
  7984. * Sets a value indicating if the lowerRadiusTransitionRange and upperRadiusTransitionRange are defined automatically
  7985. * Transition ranges will be set to 5% of the bounding box diagonal in world space
  7986. */
  7987. set: function (value) {
  7988. var _this = this;
  7989. if (this._autoTransitionRange === value) {
  7990. return;
  7991. }
  7992. this._autoTransitionRange = value;
  7993. var camera = this._attachedCamera;
  7994. if (!camera) {
  7995. return;
  7996. }
  7997. if (value) {
  7998. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  7999. if (!mesh) {
  8000. return;
  8001. }
  8002. mesh.computeWorldMatrix(true);
  8003. var diagonal = mesh.getBoundingInfo().diagonalLength;
  8004. _this.lowerRadiusTransitionRange = diagonal * 0.05;
  8005. _this.upperRadiusTransitionRange = diagonal * 0.05;
  8006. });
  8007. }
  8008. else if (this._onMeshTargetChangedObserver) {
  8009. camera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8010. }
  8011. },
  8012. enumerable: true,
  8013. configurable: true
  8014. });
  8015. /**
  8016. * Initializes the behavior.
  8017. */
  8018. BouncingBehavior.prototype.init = function () {
  8019. // Do notihng
  8020. };
  8021. /**
  8022. * Attaches the behavior to its arc rotate camera.
  8023. * @param camera Defines the camera to attach the behavior to
  8024. */
  8025. BouncingBehavior.prototype.attach = function (camera) {
  8026. var _this = this;
  8027. this._attachedCamera = camera;
  8028. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8029. if (!_this._attachedCamera) {
  8030. return;
  8031. }
  8032. // Add the bounce animation to the lower radius limit
  8033. if (_this._isRadiusAtLimit(_this._attachedCamera.lowerRadiusLimit)) {
  8034. _this._applyBoundRadiusAnimation(_this.lowerRadiusTransitionRange);
  8035. }
  8036. // Add the bounce animation to the upper radius limit
  8037. if (_this._isRadiusAtLimit(_this._attachedCamera.upperRadiusLimit)) {
  8038. _this._applyBoundRadiusAnimation(_this.upperRadiusTransitionRange);
  8039. }
  8040. });
  8041. };
  8042. /**
  8043. * Detaches the behavior from its current arc rotate camera.
  8044. */
  8045. BouncingBehavior.prototype.detach = function () {
  8046. if (!this._attachedCamera) {
  8047. return;
  8048. }
  8049. if (this._onAfterCheckInputsObserver) {
  8050. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8051. }
  8052. if (this._onMeshTargetChangedObserver) {
  8053. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8054. }
  8055. this._attachedCamera = null;
  8056. };
  8057. /**
  8058. * Checks if the camera radius is at the specified limit. Takes into account animation locks.
  8059. * @param radiusLimit The limit to check against.
  8060. * @return Bool to indicate if at limit.
  8061. */
  8062. BouncingBehavior.prototype._isRadiusAtLimit = function (radiusLimit) {
  8063. if (!this._attachedCamera) {
  8064. return false;
  8065. }
  8066. if (this._attachedCamera.radius === radiusLimit && !this._radiusIsAnimating) {
  8067. return true;
  8068. }
  8069. return false;
  8070. };
  8071. /**
  8072. * Applies an animation to the radius of the camera, extending by the radiusDelta.
  8073. * @param radiusDelta The delta by which to animate to. Can be negative.
  8074. */
  8075. BouncingBehavior.prototype._applyBoundRadiusAnimation = function (radiusDelta) {
  8076. var _this = this;
  8077. if (!this._attachedCamera) {
  8078. return;
  8079. }
  8080. if (!this._radiusBounceTransition) {
  8081. BouncingBehavior.EasingFunction.setEasingMode(BouncingBehavior.EasingMode);
  8082. this._radiusBounceTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_1__["Animation"].ANIMATIONTYPE_FLOAT, 60, BouncingBehavior.EasingFunction);
  8083. }
  8084. // Prevent zoom until bounce has completed
  8085. this._cachedWheelPrecision = this._attachedCamera.wheelPrecision;
  8086. this._attachedCamera.wheelPrecision = Infinity;
  8087. this._attachedCamera.inertialRadiusOffset = 0;
  8088. // Animate to the radius limit
  8089. this.stopAllAnimations();
  8090. this._radiusIsAnimating = true;
  8091. 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(); });
  8092. if (animatable) {
  8093. this._animatables.push(animatable);
  8094. }
  8095. };
  8096. /**
  8097. * Removes all animation locks. Allows new animations to be added to any of the camera properties.
  8098. */
  8099. BouncingBehavior.prototype._clearAnimationLocks = function () {
  8100. this._radiusIsAnimating = false;
  8101. if (this._attachedCamera) {
  8102. this._attachedCamera.wheelPrecision = this._cachedWheelPrecision;
  8103. }
  8104. };
  8105. /**
  8106. * Stops and removes all animations that have been applied to the camera
  8107. */
  8108. BouncingBehavior.prototype.stopAllAnimations = function () {
  8109. if (this._attachedCamera) {
  8110. this._attachedCamera.animations = [];
  8111. }
  8112. while (this._animatables.length) {
  8113. this._animatables[0].onAnimationEnd = null;
  8114. this._animatables[0].stop();
  8115. this._animatables.shift();
  8116. }
  8117. };
  8118. /**
  8119. * The easing function used by animations
  8120. */
  8121. BouncingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["BackEase"](0.3);
  8122. /**
  8123. * The easing mode used by animations
  8124. */
  8125. BouncingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEOUT;
  8126. return BouncingBehavior;
  8127. }());
  8128. /***/ }),
  8129. /***/ "./Behaviors/Cameras/framingBehavior.ts":
  8130. /*!**********************************************!*\
  8131. !*** ./Behaviors/Cameras/framingBehavior.ts ***!
  8132. \**********************************************/
  8133. /*! exports provided: FramingBehavior */
  8134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8135. "use strict";
  8136. __webpack_require__.r(__webpack_exports__);
  8137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return FramingBehavior; });
  8138. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  8139. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  8140. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  8141. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/precisionDate */ "./Misc/precisionDate.ts");
  8142. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8143. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  8144. /**
  8145. * 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.
  8146. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  8147. */
  8148. var FramingBehavior = /** @class */ (function () {
  8149. function FramingBehavior() {
  8150. this._mode = FramingBehavior.FitFrustumSidesMode;
  8151. this._radiusScale = 1.0;
  8152. this._positionScale = 0.5;
  8153. this._defaultElevation = 0.3;
  8154. this._elevationReturnTime = 1500;
  8155. this._elevationReturnWaitTime = 1000;
  8156. this._zoomStopsAnimation = false;
  8157. this._framingTime = 1500;
  8158. /**
  8159. * Define if the behavior should automatically change the configured
  8160. * camera limits and sensibilities.
  8161. */
  8162. this.autoCorrectCameraLimitsAndSensibility = true;
  8163. this._isPointerDown = false;
  8164. this._lastInteractionTime = -Infinity;
  8165. // Framing control
  8166. this._animatables = new Array();
  8167. this._betaIsAnimating = false;
  8168. }
  8169. Object.defineProperty(FramingBehavior.prototype, "name", {
  8170. /**
  8171. * Gets the name of the behavior.
  8172. */
  8173. get: function () {
  8174. return "Framing";
  8175. },
  8176. enumerable: true,
  8177. configurable: true
  8178. });
  8179. Object.defineProperty(FramingBehavior.prototype, "mode", {
  8180. /**
  8181. * Gets current mode used by the behavior.
  8182. */
  8183. get: function () {
  8184. return this._mode;
  8185. },
  8186. /**
  8187. * Sets the current mode used by the behavior
  8188. */
  8189. set: function (mode) {
  8190. this._mode = mode;
  8191. },
  8192. enumerable: true,
  8193. configurable: true
  8194. });
  8195. Object.defineProperty(FramingBehavior.prototype, "radiusScale", {
  8196. /**
  8197. * Gets the scale applied to the radius
  8198. */
  8199. get: function () {
  8200. return this._radiusScale;
  8201. },
  8202. /**
  8203. * Sets the scale applied to the radius (1 by default)
  8204. */
  8205. set: function (radius) {
  8206. this._radiusScale = radius;
  8207. },
  8208. enumerable: true,
  8209. configurable: true
  8210. });
  8211. Object.defineProperty(FramingBehavior.prototype, "positionScale", {
  8212. /**
  8213. * Gets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8214. */
  8215. get: function () {
  8216. return this._positionScale;
  8217. },
  8218. /**
  8219. * Sets the scale to apply on Y axis to position camera focus. 0.5 by default which means the center of the bounding box.
  8220. */
  8221. set: function (scale) {
  8222. this._positionScale = scale;
  8223. },
  8224. enumerable: true,
  8225. configurable: true
  8226. });
  8227. Object.defineProperty(FramingBehavior.prototype, "defaultElevation", {
  8228. /**
  8229. * Gets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8230. * behaviour is triggered, in radians.
  8231. */
  8232. get: function () {
  8233. return this._defaultElevation;
  8234. },
  8235. /**
  8236. * Sets the angle above/below the horizontal plane to return to when the return to default elevation idle
  8237. * behaviour is triggered, in radians.
  8238. */
  8239. set: function (elevation) {
  8240. this._defaultElevation = elevation;
  8241. },
  8242. enumerable: true,
  8243. configurable: true
  8244. });
  8245. Object.defineProperty(FramingBehavior.prototype, "elevationReturnTime", {
  8246. /**
  8247. * Gets the time (in milliseconds) taken to return to the default beta position.
  8248. * Negative value indicates camera should not return to default.
  8249. */
  8250. get: function () {
  8251. return this._elevationReturnTime;
  8252. },
  8253. /**
  8254. * Sets the time (in milliseconds) taken to return to the default beta position.
  8255. * Negative value indicates camera should not return to default.
  8256. */
  8257. set: function (speed) {
  8258. this._elevationReturnTime = speed;
  8259. },
  8260. enumerable: true,
  8261. configurable: true
  8262. });
  8263. Object.defineProperty(FramingBehavior.prototype, "elevationReturnWaitTime", {
  8264. /**
  8265. * Gets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8266. */
  8267. get: function () {
  8268. return this._elevationReturnWaitTime;
  8269. },
  8270. /**
  8271. * Sets the delay (in milliseconds) taken before the camera returns to the default beta position.
  8272. */
  8273. set: function (time) {
  8274. this._elevationReturnWaitTime = time;
  8275. },
  8276. enumerable: true,
  8277. configurable: true
  8278. });
  8279. Object.defineProperty(FramingBehavior.prototype, "zoomStopsAnimation", {
  8280. /**
  8281. * Gets the flag that indicates if user zooming should stop animation.
  8282. */
  8283. get: function () {
  8284. return this._zoomStopsAnimation;
  8285. },
  8286. /**
  8287. * Sets the flag that indicates if user zooming should stop animation.
  8288. */
  8289. set: function (flag) {
  8290. this._zoomStopsAnimation = flag;
  8291. },
  8292. enumerable: true,
  8293. configurable: true
  8294. });
  8295. Object.defineProperty(FramingBehavior.prototype, "framingTime", {
  8296. /**
  8297. * Gets the transition time when framing the mesh, in milliseconds
  8298. */
  8299. get: function () {
  8300. return this._framingTime;
  8301. },
  8302. /**
  8303. * Sets the transition time when framing the mesh, in milliseconds
  8304. */
  8305. set: function (time) {
  8306. this._framingTime = time;
  8307. },
  8308. enumerable: true,
  8309. configurable: true
  8310. });
  8311. /**
  8312. * Initializes the behavior.
  8313. */
  8314. FramingBehavior.prototype.init = function () {
  8315. // Do notihng
  8316. };
  8317. /**
  8318. * Attaches the behavior to its arc rotate camera.
  8319. * @param camera Defines the camera to attach the behavior to
  8320. */
  8321. FramingBehavior.prototype.attach = function (camera) {
  8322. var _this = this;
  8323. this._attachedCamera = camera;
  8324. var scene = this._attachedCamera.getScene();
  8325. FramingBehavior.EasingFunction.setEasingMode(FramingBehavior.EasingMode);
  8326. this._onPrePointerObservableObserver = scene.onPrePointerObservable.add(function (pointerInfoPre) {
  8327. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  8328. _this._isPointerDown = true;
  8329. return;
  8330. }
  8331. if (pointerInfoPre.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERUP) {
  8332. _this._isPointerDown = false;
  8333. }
  8334. });
  8335. this._onMeshTargetChangedObserver = camera.onMeshTargetChangedObservable.add(function (mesh) {
  8336. if (mesh) {
  8337. _this.zoomOnMesh(mesh);
  8338. }
  8339. });
  8340. this._onAfterCheckInputsObserver = camera.onAfterCheckInputsObservable.add(function () {
  8341. // Stop the animation if there is user interaction and the animation should stop for this interaction
  8342. _this._applyUserInteraction();
  8343. // Maintain the camera above the ground. If the user pulls the camera beneath the ground plane, lift it
  8344. // back to the default position after a given timeout
  8345. _this._maintainCameraAboveGround();
  8346. });
  8347. };
  8348. /**
  8349. * Detaches the behavior from its current arc rotate camera.
  8350. */
  8351. FramingBehavior.prototype.detach = function () {
  8352. if (!this._attachedCamera) {
  8353. return;
  8354. }
  8355. var scene = this._attachedCamera.getScene();
  8356. if (this._onPrePointerObservableObserver) {
  8357. scene.onPrePointerObservable.remove(this._onPrePointerObservableObserver);
  8358. }
  8359. if (this._onAfterCheckInputsObserver) {
  8360. this._attachedCamera.onAfterCheckInputsObservable.remove(this._onAfterCheckInputsObserver);
  8361. }
  8362. if (this._onMeshTargetChangedObserver) {
  8363. this._attachedCamera.onMeshTargetChangedObservable.remove(this._onMeshTargetChangedObserver);
  8364. }
  8365. this._attachedCamera = null;
  8366. };
  8367. /**
  8368. * Targets the given mesh and updates zoom level accordingly.
  8369. * @param mesh The mesh to target.
  8370. * @param radius Optional. If a cached radius position already exists, overrides default.
  8371. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8372. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8373. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8374. */
  8375. FramingBehavior.prototype.zoomOnMesh = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8376. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8377. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8378. mesh.computeWorldMatrix(true);
  8379. var boundingBox = mesh.getBoundingInfo().boundingBox;
  8380. this.zoomOnBoundingInfo(boundingBox.minimumWorld, boundingBox.maximumWorld, focusOnOriginXZ, onAnimationEnd);
  8381. };
  8382. /**
  8383. * Targets the given mesh with its children and updates zoom level accordingly.
  8384. * @param mesh The mesh to target.
  8385. * @param radius Optional. If a cached radius position already exists, overrides default.
  8386. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8387. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8388. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8389. */
  8390. FramingBehavior.prototype.zoomOnMeshHierarchy = function (mesh, focusOnOriginXZ, onAnimationEnd) {
  8391. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8392. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8393. mesh.computeWorldMatrix(true);
  8394. var boundingBox = mesh.getHierarchyBoundingVectors(true);
  8395. this.zoomOnBoundingInfo(boundingBox.min, boundingBox.max, focusOnOriginXZ, onAnimationEnd);
  8396. };
  8397. /**
  8398. * Targets the given meshes with their children and updates zoom level accordingly.
  8399. * @param meshes The mesh to target.
  8400. * @param radius Optional. If a cached radius position already exists, overrides default.
  8401. * @param framingPositionY Position on mesh to center camera focus where 0 corresponds bottom of its bounding box and 1, the top
  8402. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8403. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8404. */
  8405. FramingBehavior.prototype.zoomOnMeshesHierarchy = function (meshes, focusOnOriginXZ, onAnimationEnd) {
  8406. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8407. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8408. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  8409. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  8410. for (var i = 0; i < meshes.length; i++) {
  8411. var boundingInfo = meshes[i].getHierarchyBoundingVectors(true);
  8412. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.min, min, max);
  8413. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].CheckExtends(boundingInfo.max, min, max);
  8414. }
  8415. this.zoomOnBoundingInfo(min, max, focusOnOriginXZ, onAnimationEnd);
  8416. };
  8417. /**
  8418. * Targets the bounding box info defined by its extends and updates zoom level accordingly.
  8419. * @param minimumWorld Determines the smaller position of the bounding box extend
  8420. * @param maximumWorld Determines the bigger position of the bounding box extend
  8421. * @param focusOnOriginXZ Determines if the camera should focus on 0 in the X and Z axis instead of the mesh
  8422. * @param onAnimationEnd Callback triggered at the end of the framing animation
  8423. */
  8424. FramingBehavior.prototype.zoomOnBoundingInfo = function (minimumWorld, maximumWorld, focusOnOriginXZ, onAnimationEnd) {
  8425. var _this = this;
  8426. if (focusOnOriginXZ === void 0) { focusOnOriginXZ = false; }
  8427. if (onAnimationEnd === void 0) { onAnimationEnd = null; }
  8428. var zoomTarget;
  8429. if (!this._attachedCamera) {
  8430. return;
  8431. }
  8432. // Find target by interpolating from bottom of bounding box in world-space to top via framingPositionY
  8433. var bottom = minimumWorld.y;
  8434. var top = maximumWorld.y;
  8435. var zoomTargetY = bottom + (top - bottom) * this._positionScale;
  8436. var radiusWorld = maximumWorld.subtract(minimumWorld).scale(0.5);
  8437. if (focusOnOriginXZ) {
  8438. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, zoomTargetY, 0);
  8439. }
  8440. else {
  8441. var centerWorld = minimumWorld.add(radiusWorld);
  8442. zoomTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](centerWorld.x, zoomTargetY, centerWorld.z);
  8443. }
  8444. if (!this._vectorTransition) {
  8445. this._vectorTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("target", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_VECTOR3, 60, FramingBehavior.EasingFunction);
  8446. }
  8447. this._betaIsAnimating = true;
  8448. var animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("target", zoomTarget, this._attachedCamera, this._attachedCamera.getScene(), 60, this._vectorTransition, this._framingTime);
  8449. if (animatable) {
  8450. this._animatables.push(animatable);
  8451. }
  8452. // sets the radius and lower radius bounds
  8453. // Small delta ensures camera is not always at lower zoom limit.
  8454. var radius = 0;
  8455. if (this._mode === FramingBehavior.FitFrustumSidesMode) {
  8456. var position = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8457. if (this.autoCorrectCameraLimitsAndSensibility) {
  8458. this._attachedCamera.lowerRadiusLimit = radiusWorld.length() + this._attachedCamera.minZ;
  8459. }
  8460. radius = position;
  8461. }
  8462. else if (this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8463. radius = this._calculateLowerRadiusFromModelBoundingSphere(minimumWorld, maximumWorld);
  8464. if (this.autoCorrectCameraLimitsAndSensibility && this._attachedCamera.lowerRadiusLimit === null) {
  8465. this._attachedCamera.lowerRadiusLimit = this._attachedCamera.minZ;
  8466. }
  8467. }
  8468. // Set sensibilities
  8469. if (this.autoCorrectCameraLimitsAndSensibility) {
  8470. var extend = maximumWorld.subtract(minimumWorld).length();
  8471. this._attachedCamera.panningSensibility = 5000 / extend;
  8472. this._attachedCamera.wheelPrecision = 100 / radius;
  8473. }
  8474. // transition to new radius
  8475. if (!this._radiusTransition) {
  8476. this._radiusTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("radius", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8477. }
  8478. animatable = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("radius", radius, this._attachedCamera, this._attachedCamera.getScene(), 60, this._radiusTransition, this._framingTime, function () {
  8479. _this.stopAllAnimations();
  8480. if (onAnimationEnd) {
  8481. onAnimationEnd();
  8482. }
  8483. if (_this._attachedCamera && _this._attachedCamera.useInputToRestoreState) {
  8484. _this._attachedCamera.storeState();
  8485. }
  8486. });
  8487. if (animatable) {
  8488. this._animatables.push(animatable);
  8489. }
  8490. };
  8491. /**
  8492. * Calculates the lowest radius for the camera based on the bounding box of the mesh.
  8493. * @param mesh The mesh on which to base the calculation. mesh boundingInfo used to estimate necessary
  8494. * frustum width.
  8495. * @return The minimum distance from the primary mesh's center point at which the camera must be kept in order
  8496. * to fully enclose the mesh in the viewing frustum.
  8497. */
  8498. FramingBehavior.prototype._calculateLowerRadiusFromModelBoundingSphere = function (minimumWorld, maximumWorld) {
  8499. var size = maximumWorld.subtract(minimumWorld);
  8500. var boxVectorGlobalDiagonal = size.length();
  8501. var frustumSlope = this._getFrustumSlope();
  8502. // Formula for setting distance
  8503. // (Good explanation: http://stackoverflow.com/questions/2866350/move-camera-to-fit-3d-scene)
  8504. var radiusWithoutFraming = boxVectorGlobalDiagonal * 0.5;
  8505. // Horizon distance
  8506. var radius = radiusWithoutFraming * this._radiusScale;
  8507. var distanceForHorizontalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.x * frustumSlope.x));
  8508. var distanceForVerticalFrustum = radius * Math.sqrt(1.0 + 1.0 / (frustumSlope.y * frustumSlope.y));
  8509. var distance = Math.max(distanceForHorizontalFrustum, distanceForVerticalFrustum);
  8510. var camera = this._attachedCamera;
  8511. if (!camera) {
  8512. return 0;
  8513. }
  8514. if (camera.lowerRadiusLimit && this._mode === FramingBehavior.IgnoreBoundsSizeMode) {
  8515. // Don't exceed the requested limit
  8516. distance = distance < camera.lowerRadiusLimit ? camera.lowerRadiusLimit : distance;
  8517. }
  8518. // Don't exceed the upper radius limit
  8519. if (camera.upperRadiusLimit) {
  8520. distance = distance > camera.upperRadiusLimit ? camera.upperRadiusLimit : distance;
  8521. }
  8522. return distance;
  8523. };
  8524. /**
  8525. * Keeps the camera above the ground plane. If the user pulls the camera below the ground plane, the camera
  8526. * is automatically returned to its default position (expected to be above ground plane).
  8527. */
  8528. FramingBehavior.prototype._maintainCameraAboveGround = function () {
  8529. var _this = this;
  8530. if (this._elevationReturnTime < 0) {
  8531. return;
  8532. }
  8533. var timeSinceInteraction = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now - this._lastInteractionTime;
  8534. var defaultBeta = Math.PI * 0.5 - this._defaultElevation;
  8535. var limitBeta = Math.PI * 0.5;
  8536. // Bring the camera back up if below the ground plane
  8537. if (this._attachedCamera && !this._betaIsAnimating && this._attachedCamera.beta > limitBeta && timeSinceInteraction >= this._elevationReturnWaitTime) {
  8538. this._betaIsAnimating = true;
  8539. //Transition to new position
  8540. this.stopAllAnimations();
  8541. if (!this._betaTransition) {
  8542. this._betaTransition = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].CreateAnimation("beta", _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].ANIMATIONTYPE_FLOAT, 60, FramingBehavior.EasingFunction);
  8543. }
  8544. var animatabe = _Animations_animation__WEBPACK_IMPORTED_MODULE_5__["Animation"].TransitionTo("beta", defaultBeta, this._attachedCamera, this._attachedCamera.getScene(), 60, this._betaTransition, this._elevationReturnTime, function () {
  8545. _this._clearAnimationLocks();
  8546. _this.stopAllAnimations();
  8547. });
  8548. if (animatabe) {
  8549. this._animatables.push(animatabe);
  8550. }
  8551. }
  8552. };
  8553. /**
  8554. * Returns the frustum slope based on the canvas ratio and camera FOV
  8555. * @returns The frustum slope represented as a Vector2 with X and Y slopes
  8556. */
  8557. FramingBehavior.prototype._getFrustumSlope = function () {
  8558. // Calculate the viewport ratio
  8559. // Aspect Ratio is Height/Width.
  8560. var camera = this._attachedCamera;
  8561. if (!camera) {
  8562. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"].Zero();
  8563. }
  8564. var engine = camera.getScene().getEngine();
  8565. var aspectRatio = engine.getAspectRatio(camera);
  8566. // Camera FOV is the vertical field of view (top-bottom) in radians.
  8567. // Slope of the frustum top/bottom planes in view space, relative to the forward vector.
  8568. var frustumSlopeY = Math.tan(camera.fov / 2);
  8569. // Slope of the frustum left/right planes in view space, relative to the forward vector.
  8570. // Provides the amount that one side (e.g. left) of the frustum gets wider for every unit
  8571. // along the forward vector.
  8572. var frustumSlopeX = frustumSlopeY * aspectRatio;
  8573. return new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector2"](frustumSlopeX, frustumSlopeY);
  8574. };
  8575. /**
  8576. * Removes all animation locks. Allows new animations to be added to any of the arcCamera properties.
  8577. */
  8578. FramingBehavior.prototype._clearAnimationLocks = function () {
  8579. this._betaIsAnimating = false;
  8580. };
  8581. /**
  8582. * Applies any current user interaction to the camera. Takes into account maximum alpha rotation.
  8583. */
  8584. FramingBehavior.prototype._applyUserInteraction = function () {
  8585. if (this.isUserIsMoving) {
  8586. this._lastInteractionTime = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_3__["PrecisionDate"].Now;
  8587. this.stopAllAnimations();
  8588. this._clearAnimationLocks();
  8589. }
  8590. };
  8591. /**
  8592. * Stops and removes all animations that have been applied to the camera
  8593. */
  8594. FramingBehavior.prototype.stopAllAnimations = function () {
  8595. if (this._attachedCamera) {
  8596. this._attachedCamera.animations = [];
  8597. }
  8598. while (this._animatables.length) {
  8599. if (this._animatables[0]) {
  8600. this._animatables[0].onAnimationEnd = null;
  8601. this._animatables[0].stop();
  8602. }
  8603. this._animatables.shift();
  8604. }
  8605. };
  8606. Object.defineProperty(FramingBehavior.prototype, "isUserIsMoving", {
  8607. /**
  8608. * Gets a value indicating if the user is moving the camera
  8609. */
  8610. get: function () {
  8611. if (!this._attachedCamera) {
  8612. return false;
  8613. }
  8614. return this._attachedCamera.inertialAlphaOffset !== 0 ||
  8615. this._attachedCamera.inertialBetaOffset !== 0 ||
  8616. this._attachedCamera.inertialRadiusOffset !== 0 ||
  8617. this._attachedCamera.inertialPanningX !== 0 ||
  8618. this._attachedCamera.inertialPanningY !== 0 ||
  8619. this._isPointerDown;
  8620. },
  8621. enumerable: true,
  8622. configurable: true
  8623. });
  8624. /**
  8625. * The easing function used by animations
  8626. */
  8627. FramingBehavior.EasingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]();
  8628. /**
  8629. * The easing mode used by animations
  8630. */
  8631. FramingBehavior.EasingMode = _Animations_easing__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"].EASINGMODE_EASEINOUT;
  8632. // Statics
  8633. /**
  8634. * The camera can move all the way towards the mesh.
  8635. */
  8636. FramingBehavior.IgnoreBoundsSizeMode = 0;
  8637. /**
  8638. * The camera is not allowed to zoom closer to the mesh than the point at which the adjusted bounding sphere touches the frustum sides
  8639. */
  8640. FramingBehavior.FitFrustumSidesMode = 1;
  8641. return FramingBehavior;
  8642. }());
  8643. /***/ }),
  8644. /***/ "./Behaviors/Cameras/index.ts":
  8645. /*!************************************!*\
  8646. !*** ./Behaviors/Cameras/index.ts ***!
  8647. \************************************/
  8648. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior */
  8649. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8650. "use strict";
  8651. __webpack_require__.r(__webpack_exports__);
  8652. /* harmony import */ var _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  8653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _autoRotationBehavior__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  8654. /* harmony import */ var _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  8655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _bouncingBehavior__WEBPACK_IMPORTED_MODULE_1__["BouncingBehavior"]; });
  8656. /* harmony import */ var _framingBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  8657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _framingBehavior__WEBPACK_IMPORTED_MODULE_2__["FramingBehavior"]; });
  8658. /***/ }),
  8659. /***/ "./Behaviors/Meshes/attachToBoxBehavior.ts":
  8660. /*!*************************************************!*\
  8661. !*** ./Behaviors/Meshes/attachToBoxBehavior.ts ***!
  8662. \*************************************************/
  8663. /*! exports provided: AttachToBoxBehavior */
  8664. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8665. "use strict";
  8666. __webpack_require__.r(__webpack_exports__);
  8667. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return AttachToBoxBehavior; });
  8668. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8669. /**
  8670. * @hidden
  8671. */
  8672. var FaceDirectionInfo = /** @class */ (function () {
  8673. function FaceDirectionInfo(direction, rotatedDirection, diff, ignore) {
  8674. if (rotatedDirection === void 0) { rotatedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](); }
  8675. if (diff === void 0) { diff = 0; }
  8676. if (ignore === void 0) { ignore = false; }
  8677. this.direction = direction;
  8678. this.rotatedDirection = rotatedDirection;
  8679. this.diff = diff;
  8680. this.ignore = ignore;
  8681. }
  8682. return FaceDirectionInfo;
  8683. }());
  8684. /**
  8685. * A behavior that when attached to a mesh will will place a specified node on the meshes face pointing towards the camera
  8686. */
  8687. var AttachToBoxBehavior = /** @class */ (function () {
  8688. /**
  8689. * Creates the AttachToBoxBehavior, used to attach UI to the closest face of the box to a camera
  8690. * @param ui The transform node that should be attched to the mesh
  8691. */
  8692. function AttachToBoxBehavior(ui) {
  8693. this.ui = ui;
  8694. /**
  8695. * The name of the behavior
  8696. */
  8697. this.name = "AttachToBoxBehavior";
  8698. /**
  8699. * The distance away from the face of the mesh that the UI should be attached to (default: 0.15)
  8700. */
  8701. this.distanceAwayFromFace = 0.15;
  8702. /**
  8703. * The distance from the bottom of the face that the UI should be attached to (default: 0.15)
  8704. */
  8705. this.distanceAwayFromBottomOfFace = 0.15;
  8706. 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))];
  8707. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8708. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  8709. this._zeroVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  8710. this._lookAtTmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  8711. /* Does nothing */
  8712. }
  8713. /**
  8714. * Initializes the behavior
  8715. */
  8716. AttachToBoxBehavior.prototype.init = function () {
  8717. /* Does nothing */
  8718. };
  8719. AttachToBoxBehavior.prototype._closestFace = function (targetDirection) {
  8720. var _this = this;
  8721. // Go over each face and calculate the angle between the face's normal and targetDirection
  8722. this._faceVectors.forEach(function (v) {
  8723. if (!_this._target.rotationQuaternion) {
  8724. _this._target.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this._target.rotation.y, _this._target.rotation.x, _this._target.rotation.z);
  8725. }
  8726. _this._target.rotationQuaternion.toRotationMatrix(_this._tmpMatrix);
  8727. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(v.direction, _this._tmpMatrix, v.rotatedDirection);
  8728. v.diff = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetAngleBetweenVectors(v.rotatedDirection, targetDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v.rotatedDirection, targetDirection));
  8729. });
  8730. // Return the face information of the one with the normal closeset to target direction
  8731. return this._faceVectors.reduce(function (min, p) {
  8732. if (min.ignore) {
  8733. return p;
  8734. }
  8735. else if (p.ignore) {
  8736. return min;
  8737. }
  8738. else {
  8739. return min.diff < p.diff ? min : p;
  8740. }
  8741. }, this._faceVectors[0]);
  8742. };
  8743. AttachToBoxBehavior.prototype._lookAtToRef = function (pos, up, ref) {
  8744. if (up === void 0) { up = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0); }
  8745. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].LookAtLHToRef(this._zeroVector, pos, up, this._lookAtTmpMatrix);
  8746. this._lookAtTmpMatrix.invert();
  8747. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._lookAtTmpMatrix, ref);
  8748. };
  8749. /**
  8750. * Attaches the AttachToBoxBehavior to the passed in mesh
  8751. * @param target The mesh that the specified node will be attached to
  8752. */
  8753. AttachToBoxBehavior.prototype.attach = function (target) {
  8754. var _this = this;
  8755. this._target = target;
  8756. this._scene = this._target.getScene();
  8757. // Every frame, update the app bars position
  8758. this._onRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  8759. if (!_this._scene.activeCamera) {
  8760. return;
  8761. }
  8762. // Find the face closest to the cameras position
  8763. var cameraPos = _this._scene.activeCamera.position;
  8764. if (_this._scene.activeCamera.devicePosition) {
  8765. cameraPos = _this._scene.activeCamera.devicePosition;
  8766. }
  8767. var facing = _this._closestFace(cameraPos.subtract(target.position));
  8768. if (_this._scene.activeCamera.leftCamera) {
  8769. _this._scene.activeCamera.leftCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8770. }
  8771. else {
  8772. _this._scene.activeCamera.computeWorldMatrix().getRotationMatrixToRef(_this._tmpMatrix);
  8773. }
  8774. // Get camera up direction
  8775. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _this._tmpMatrix, _this._tmpVector);
  8776. // Ignore faces to not select a parrelel face for the up vector of the UI
  8777. _this._faceVectors.forEach(function (v) {
  8778. if (facing.direction.x && v.direction.x) {
  8779. v.ignore = true;
  8780. }
  8781. if (facing.direction.y && v.direction.y) {
  8782. v.ignore = true;
  8783. }
  8784. if (facing.direction.z && v.direction.z) {
  8785. v.ignore = true;
  8786. }
  8787. });
  8788. var facingUp = _this._closestFace(_this._tmpVector);
  8789. // Unignore faces
  8790. _this._faceVectors.forEach(function (v) {
  8791. v.ignore = false;
  8792. });
  8793. // Position the app bar on that face
  8794. _this.ui.position.copyFrom(target.position);
  8795. if (facing.direction.x) {
  8796. facing.rotatedDirection.scaleToRef((target.scaling.x / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8797. _this.ui.position.addInPlace(_this._tmpVector);
  8798. }
  8799. if (facing.direction.y) {
  8800. facing.rotatedDirection.scaleToRef((target.scaling.y / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8801. _this.ui.position.addInPlace(_this._tmpVector);
  8802. }
  8803. if (facing.direction.z) {
  8804. facing.rotatedDirection.scaleToRef((target.scaling.z / 2) + _this.distanceAwayFromFace, _this._tmpVector);
  8805. _this.ui.position.addInPlace(_this._tmpVector);
  8806. }
  8807. // Rotate to be oriented properly to the camera
  8808. if (!_this.ui.rotationQuaternion) {
  8809. _this.ui.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(_this.ui.rotation.y, _this.ui.rotation.x, _this.ui.rotation.z);
  8810. }
  8811. facing.rotatedDirection.scaleToRef(-1, _this._tmpVector);
  8812. _this._lookAtToRef(_this._tmpVector, facingUp.rotatedDirection, _this.ui.rotationQuaternion);
  8813. // Place ui the correct distance from the bottom of the mesh
  8814. if (facingUp.direction.x) {
  8815. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.x / 2, _this._tmpVector);
  8816. }
  8817. if (facingUp.direction.y) {
  8818. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.y / 2, _this._tmpVector);
  8819. }
  8820. if (facingUp.direction.z) {
  8821. _this.ui.up.scaleToRef(_this.distanceAwayFromBottomOfFace - target.scaling.z / 2, _this._tmpVector);
  8822. }
  8823. _this.ui.position.addInPlace(_this._tmpVector);
  8824. });
  8825. };
  8826. /**
  8827. * Detaches the behavior from the mesh
  8828. */
  8829. AttachToBoxBehavior.prototype.detach = function () {
  8830. this._scene.onBeforeRenderObservable.remove(this._onRenderObserver);
  8831. };
  8832. return AttachToBoxBehavior;
  8833. }());
  8834. /***/ }),
  8835. /***/ "./Behaviors/Meshes/fadeInOutBehavior.ts":
  8836. /*!***********************************************!*\
  8837. !*** ./Behaviors/Meshes/fadeInOutBehavior.ts ***!
  8838. \***********************************************/
  8839. /*! exports provided: FadeInOutBehavior */
  8840. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8841. "use strict";
  8842. __webpack_require__.r(__webpack_exports__);
  8843. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return FadeInOutBehavior; });
  8844. /**
  8845. * A behavior that when attached to a mesh will allow the mesh to fade in and out
  8846. */
  8847. var FadeInOutBehavior = /** @class */ (function () {
  8848. /**
  8849. * Instatiates the FadeInOutBehavior
  8850. */
  8851. function FadeInOutBehavior() {
  8852. var _this = this;
  8853. /**
  8854. * Time in milliseconds to delay before fading in (Default: 0)
  8855. */
  8856. this.delay = 0;
  8857. /**
  8858. * Time in milliseconds for the mesh to fade in (Default: 300)
  8859. */
  8860. this.fadeInTime = 300;
  8861. this._millisecondsPerFrame = 1000 / 60;
  8862. this._hovered = false;
  8863. this._hoverValue = 0;
  8864. this._ownerNode = null;
  8865. this._update = function () {
  8866. if (_this._ownerNode) {
  8867. _this._hoverValue += _this._hovered ? _this._millisecondsPerFrame : -_this._millisecondsPerFrame;
  8868. _this._setAllVisibility(_this._ownerNode, (_this._hoverValue - _this.delay) / _this.fadeInTime);
  8869. if (_this._ownerNode.visibility > 1) {
  8870. _this._setAllVisibility(_this._ownerNode, 1);
  8871. _this._hoverValue = _this.fadeInTime + _this.delay;
  8872. return;
  8873. }
  8874. else if (_this._ownerNode.visibility < 0) {
  8875. _this._setAllVisibility(_this._ownerNode, 0);
  8876. if (_this._hoverValue < 0) {
  8877. _this._hoverValue = 0;
  8878. return;
  8879. }
  8880. }
  8881. setTimeout(_this._update, _this._millisecondsPerFrame);
  8882. }
  8883. };
  8884. }
  8885. Object.defineProperty(FadeInOutBehavior.prototype, "name", {
  8886. /**
  8887. * The name of the behavior
  8888. */
  8889. get: function () {
  8890. return "FadeInOut";
  8891. },
  8892. enumerable: true,
  8893. configurable: true
  8894. });
  8895. /**
  8896. * Initializes the behavior
  8897. */
  8898. FadeInOutBehavior.prototype.init = function () {
  8899. };
  8900. /**
  8901. * Attaches the fade behavior on the passed in mesh
  8902. * @param ownerNode The mesh that will be faded in/out once attached
  8903. */
  8904. FadeInOutBehavior.prototype.attach = function (ownerNode) {
  8905. this._ownerNode = ownerNode;
  8906. this._setAllVisibility(this._ownerNode, 0);
  8907. };
  8908. /**
  8909. * Detaches the behavior from the mesh
  8910. */
  8911. FadeInOutBehavior.prototype.detach = function () {
  8912. this._ownerNode = null;
  8913. };
  8914. /**
  8915. * Triggers the mesh to begin fading in or out
  8916. * @param value if the object should fade in or out (true to fade in)
  8917. */
  8918. FadeInOutBehavior.prototype.fadeIn = function (value) {
  8919. this._hovered = value;
  8920. this._update();
  8921. };
  8922. FadeInOutBehavior.prototype._setAllVisibility = function (mesh, value) {
  8923. var _this = this;
  8924. mesh.visibility = value;
  8925. mesh.getChildMeshes().forEach(function (c) {
  8926. _this._setAllVisibility(c, value);
  8927. });
  8928. };
  8929. return FadeInOutBehavior;
  8930. }());
  8931. /***/ }),
  8932. /***/ "./Behaviors/Meshes/index.ts":
  8933. /*!***********************************!*\
  8934. !*** ./Behaviors/Meshes/index.ts ***!
  8935. \***********************************/
  8936. /*! exports provided: AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  8937. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8938. "use strict";
  8939. __webpack_require__.r(__webpack_exports__);
  8940. /* harmony import */ var _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./attachToBoxBehavior */ "./Behaviors/Meshes/attachToBoxBehavior.ts");
  8941. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _attachToBoxBehavior__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  8942. /* harmony import */ var _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./fadeInOutBehavior */ "./Behaviors/Meshes/fadeInOutBehavior.ts");
  8943. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _fadeInOutBehavior__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  8944. /* harmony import */ var _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./multiPointerScaleBehavior */ "./Behaviors/Meshes/multiPointerScaleBehavior.ts");
  8945. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _multiPointerScaleBehavior__WEBPACK_IMPORTED_MODULE_2__["MultiPointerScaleBehavior"]; });
  8946. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8947. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_3__["PointerDragBehavior"]; });
  8948. /* harmony import */ var _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  8949. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_4__["SixDofDragBehavior"]; });
  8950. /***/ }),
  8951. /***/ "./Behaviors/Meshes/multiPointerScaleBehavior.ts":
  8952. /*!*******************************************************!*\
  8953. !*** ./Behaviors/Meshes/multiPointerScaleBehavior.ts ***!
  8954. \*******************************************************/
  8955. /*! exports provided: MultiPointerScaleBehavior */
  8956. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  8957. "use strict";
  8958. __webpack_require__.r(__webpack_exports__);
  8959. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return MultiPointerScaleBehavior; });
  8960. /* harmony import */ var _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  8961. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  8962. /**
  8963. * A behavior that when attached to a mesh will allow the mesh to be scaled
  8964. */
  8965. var MultiPointerScaleBehavior = /** @class */ (function () {
  8966. /**
  8967. * Instantiate a new behavior that when attached to a mesh will allow the mesh to be scaled
  8968. */
  8969. function MultiPointerScaleBehavior() {
  8970. this._startDistance = 0;
  8971. this._initialScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8972. this._targetScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0);
  8973. this._sceneRenderObserver = null;
  8974. this._dragBehaviorA = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8975. this._dragBehaviorA.moveAttached = false;
  8976. this._dragBehaviorB = new _pointerDragBehavior__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]({});
  8977. this._dragBehaviorB.moveAttached = false;
  8978. }
  8979. Object.defineProperty(MultiPointerScaleBehavior.prototype, "name", {
  8980. /**
  8981. * The name of the behavior
  8982. */
  8983. get: function () {
  8984. return "MultiPointerScale";
  8985. },
  8986. enumerable: true,
  8987. configurable: true
  8988. });
  8989. /**
  8990. * Initializes the behavior
  8991. */
  8992. MultiPointerScaleBehavior.prototype.init = function () { };
  8993. MultiPointerScaleBehavior.prototype._getCurrentDistance = function () {
  8994. return this._dragBehaviorA.lastDragPosition.subtract(this._dragBehaviorB.lastDragPosition).length();
  8995. };
  8996. /**
  8997. * Attaches the scale behavior the passed in mesh
  8998. * @param ownerNode The mesh that will be scaled around once attached
  8999. */
  9000. MultiPointerScaleBehavior.prototype.attach = function (ownerNode) {
  9001. var _this = this;
  9002. this._ownerNode = ownerNode;
  9003. // Create 2 drag behaviors such that each will only be triggered by a separate pointer
  9004. this._dragBehaviorA.onDragStartObservable.add(function (e) {
  9005. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9006. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9007. _this._dragBehaviorA.releaseDrag();
  9008. }
  9009. else {
  9010. _this._initialScale.copyFrom(ownerNode.scaling);
  9011. _this._startDistance = _this._getCurrentDistance();
  9012. }
  9013. }
  9014. });
  9015. this._dragBehaviorB.onDragStartObservable.add(function (e) {
  9016. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9017. if (_this._dragBehaviorA.currentDraggingPointerID == _this._dragBehaviorB.currentDraggingPointerID) {
  9018. _this._dragBehaviorB.releaseDrag();
  9019. }
  9020. else {
  9021. _this._initialScale.copyFrom(ownerNode.scaling);
  9022. _this._startDistance = _this._getCurrentDistance();
  9023. }
  9024. }
  9025. });
  9026. // Once both drag behaviors are active scale based on the distance between the two pointers
  9027. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9028. behavior.onDragObservable.add(function () {
  9029. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9030. var ratio = _this._getCurrentDistance() / _this._startDistance;
  9031. _this._initialScale.scaleToRef(ratio, _this._targetScale);
  9032. }
  9033. });
  9034. });
  9035. ownerNode.addBehavior(this._dragBehaviorA);
  9036. ownerNode.addBehavior(this._dragBehaviorB);
  9037. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9038. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9039. if (_this._dragBehaviorA.dragging && _this._dragBehaviorB.dragging) {
  9040. var change = _this._targetScale.subtract(ownerNode.scaling).scaleInPlace(0.1);
  9041. if (change.length() > 0.01) {
  9042. ownerNode.scaling.addInPlace(change);
  9043. }
  9044. }
  9045. });
  9046. };
  9047. /**
  9048. * Detaches the behavior from the mesh
  9049. */
  9050. MultiPointerScaleBehavior.prototype.detach = function () {
  9051. var _this = this;
  9052. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9053. [this._dragBehaviorA, this._dragBehaviorB].forEach(function (behavior) {
  9054. behavior.onDragStartObservable.clear();
  9055. behavior.onDragObservable.clear();
  9056. _this._ownerNode.removeBehavior(behavior);
  9057. });
  9058. };
  9059. return MultiPointerScaleBehavior;
  9060. }());
  9061. /***/ }),
  9062. /***/ "./Behaviors/Meshes/pointerDragBehavior.ts":
  9063. /*!*************************************************!*\
  9064. !*** ./Behaviors/Meshes/pointerDragBehavior.ts ***!
  9065. \*************************************************/
  9066. /*! exports provided: PointerDragBehavior */
  9067. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9068. "use strict";
  9069. __webpack_require__.r(__webpack_exports__);
  9070. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return PointerDragBehavior; });
  9071. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  9072. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9073. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9074. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9075. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9076. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  9077. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9078. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  9079. /**
  9080. * A behavior that when attached to a mesh will allow the mesh to be dragged around the screen based on pointer events
  9081. */
  9082. var PointerDragBehavior = /** @class */ (function () {
  9083. /**
  9084. * Creates a pointer drag behavior that can be attached to a mesh
  9085. * @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)
  9086. */
  9087. function PointerDragBehavior(options) {
  9088. this._useAlternatePickedPointAboveMaxDragAngleDragSpeed = -1.1;
  9089. /**
  9090. * 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)
  9091. */
  9092. this.maxDragAngle = 0;
  9093. /**
  9094. * @hidden
  9095. */
  9096. this._useAlternatePickedPointAboveMaxDragAngle = false;
  9097. /**
  9098. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9099. */
  9100. this.currentDraggingPointerID = -1;
  9101. /**
  9102. * If the behavior is currently in a dragging state
  9103. */
  9104. this.dragging = false;
  9105. /**
  9106. * 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)
  9107. */
  9108. this.dragDeltaRatio = 0.2;
  9109. /**
  9110. * If the drag plane orientation should be updated during the dragging (Default: true)
  9111. */
  9112. this.updateDragPlane = true;
  9113. // Debug mode will display drag planes to help visualize behavior
  9114. this._debugMode = false;
  9115. this._moving = false;
  9116. /**
  9117. * Fires each time the attached mesh is dragged with the pointer
  9118. * * delta between last drag position and current drag position in world space
  9119. * * dragDistance along the drag axis
  9120. * * dragPlaneNormal normal of the current drag plane used during the drag
  9121. * * dragPlanePoint in world space where the drag intersects the drag plane
  9122. */
  9123. this.onDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9124. /**
  9125. * Fires each time a drag begins (eg. mouse down on mesh)
  9126. */
  9127. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9128. /**
  9129. * Fires each time a drag ends (eg. mouse release after drag)
  9130. */
  9131. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  9132. /**
  9133. * If the attached mesh should be moved when dragged
  9134. */
  9135. this.moveAttached = true;
  9136. /**
  9137. * If the drag behavior will react to drag events (Default: true)
  9138. */
  9139. this.enabled = true;
  9140. /**
  9141. * If camera controls should be detached during the drag
  9142. */
  9143. this.detachCameraControls = true;
  9144. /**
  9145. * If set, the drag plane/axis will be rotated based on the attached mesh's world rotation (Default: true)
  9146. */
  9147. this.useObjectOrienationForDragging = true;
  9148. /**
  9149. * Predicate to determine if it is valid to move the object to a new position when it is moved
  9150. */
  9151. this.validateDrag = function (targetPosition) { return true; };
  9152. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9153. this._alternatePickedPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9154. this._worldDragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9155. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9156. this._attachedElement = null;
  9157. 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"]());
  9158. this._lastPointerRay = {};
  9159. this._dragDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  9160. // Variables to avoid instantiation in the below method
  9161. this._pointA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9162. this._pointB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9163. this._pointC = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9164. this._lineA = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9165. this._lineB = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9166. this._localAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9167. this._lookAt = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9168. this._options = options ? options : {};
  9169. var optionCount = 0;
  9170. if (this._options.dragAxis) {
  9171. optionCount++;
  9172. }
  9173. if (this._options.dragPlaneNormal) {
  9174. optionCount++;
  9175. }
  9176. if (optionCount > 1) {
  9177. throw "Multiple drag modes specified in dragBehavior options. Only one expected";
  9178. }
  9179. }
  9180. Object.defineProperty(PointerDragBehavior.prototype, "name", {
  9181. /**
  9182. * The name of the behavior
  9183. */
  9184. get: function () {
  9185. return "PointerDrag";
  9186. },
  9187. enumerable: true,
  9188. configurable: true
  9189. });
  9190. /**
  9191. * Initializes the behavior
  9192. */
  9193. PointerDragBehavior.prototype.init = function () { };
  9194. /**
  9195. * Attaches the drag behavior the passed in mesh
  9196. * @param ownerNode The mesh that will be dragged around once attached
  9197. */
  9198. PointerDragBehavior.prototype.attach = function (ownerNode) {
  9199. var _this = this;
  9200. this._scene = ownerNode.getScene();
  9201. this._attachedNode = ownerNode;
  9202. // Initialize drag plane to not interfere with existing scene
  9203. if (!PointerDragBehavior._planeScene) {
  9204. if (this._debugMode) {
  9205. PointerDragBehavior._planeScene = this._scene;
  9206. }
  9207. else {
  9208. PointerDragBehavior._planeScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9209. PointerDragBehavior._planeScene.detachControl();
  9210. this._scene.getEngine().scenes.pop();
  9211. this._scene.onDisposeObservable.addOnce(function () {
  9212. PointerDragBehavior._planeScene.dispose();
  9213. PointerDragBehavior._planeScene = null;
  9214. });
  9215. }
  9216. }
  9217. 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);
  9218. // State of the drag
  9219. this.lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9220. var pickPredicate = function (m) {
  9221. return _this._attachedNode == m || m.isDescendantOf(_this._attachedNode);
  9222. };
  9223. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9224. if (!_this.enabled) {
  9225. return;
  9226. }
  9227. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN) {
  9228. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.pickedPoint && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9229. _this._startDrag(pointerInfo.event.pointerId, pointerInfo.pickInfo.ray, pointerInfo.pickInfo.pickedPoint);
  9230. }
  9231. }
  9232. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP) {
  9233. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9234. _this.releaseDrag();
  9235. }
  9236. }
  9237. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  9238. var pointerId = pointerInfo.event.pointerId;
  9239. // If drag was started with anyMouseID specified, set pointerID to the next mouse that moved
  9240. if (_this.currentDraggingPointerID === PointerDragBehavior._AnyMouseID && pointerId !== PointerDragBehavior._AnyMouseID && pointerInfo.event.pointerType == "mouse") {
  9241. if (_this._lastPointerRay[_this.currentDraggingPointerID]) {
  9242. _this._lastPointerRay[pointerId] = _this._lastPointerRay[_this.currentDraggingPointerID];
  9243. delete _this._lastPointerRay[_this.currentDraggingPointerID];
  9244. }
  9245. _this.currentDraggingPointerID = pointerId;
  9246. }
  9247. // Keep track of last pointer ray, this is used simulating the start of a drag in startDrag()
  9248. if (!_this._lastPointerRay[pointerId]) {
  9249. _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"]());
  9250. }
  9251. if (pointerInfo.pickInfo && pointerInfo.pickInfo.ray) {
  9252. _this._lastPointerRay[pointerId].origin.copyFrom(pointerInfo.pickInfo.ray.origin);
  9253. _this._lastPointerRay[pointerId].direction.copyFrom(pointerInfo.pickInfo.ray.direction);
  9254. if (_this.currentDraggingPointerID == pointerId && _this.dragging) {
  9255. _this._moveDrag(pointerInfo.pickInfo.ray);
  9256. }
  9257. }
  9258. }
  9259. });
  9260. this._beforeRenderObserver = this._scene.onBeforeRenderObservable.add(function () {
  9261. if (_this._moving && _this.moveAttached) {
  9262. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(_this._attachedNode);
  9263. // Slowly move mesh to avoid jitter
  9264. _this._targetPosition.subtractToRef((_this._attachedNode).absolutePosition, _this._tmpVector);
  9265. _this._tmpVector.scaleInPlace(_this.dragDeltaRatio);
  9266. (_this._attachedNode).getAbsolutePosition().addToRef(_this._tmpVector, _this._tmpVector);
  9267. if (_this.validateDrag(_this._tmpVector)) {
  9268. (_this._attachedNode).setAbsolutePosition(_this._tmpVector);
  9269. }
  9270. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(_this._attachedNode);
  9271. }
  9272. });
  9273. };
  9274. /**
  9275. * Force relase the drag action by code.
  9276. */
  9277. PointerDragBehavior.prototype.releaseDrag = function () {
  9278. this.dragging = false;
  9279. this.onDragEndObservable.notifyObservers({ dragPlanePoint: this.lastDragPosition, pointerId: this.currentDraggingPointerID });
  9280. this.currentDraggingPointerID = -1;
  9281. this._moving = false;
  9282. // Reattach camera controls
  9283. if (this.detachCameraControls && this._attachedElement && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9284. this._scene.activeCamera.attachControl(this._attachedElement, true);
  9285. }
  9286. };
  9287. /**
  9288. * Simulates the start of a pointer drag event on the behavior
  9289. * @param pointerId pointerID of the pointer that should be simulated (Default: Any mouse pointer ID)
  9290. * @param fromRay initial ray of the pointer to be simulated (Default: Ray from camera to attached mesh)
  9291. * @param startPickedPoint picked point of the pointer to be simulated (Default: attached mesh position)
  9292. */
  9293. PointerDragBehavior.prototype.startDrag = function (pointerId, fromRay, startPickedPoint) {
  9294. if (pointerId === void 0) { pointerId = PointerDragBehavior._AnyMouseID; }
  9295. this._startDrag(pointerId, fromRay, startPickedPoint);
  9296. var lastRay = this._lastPointerRay[pointerId];
  9297. if (pointerId === PointerDragBehavior._AnyMouseID) {
  9298. lastRay = this._lastPointerRay[Object.keys(this._lastPointerRay)[0]];
  9299. }
  9300. if (lastRay) {
  9301. // if there was a last pointer ray drag the object there
  9302. this._moveDrag(lastRay);
  9303. }
  9304. };
  9305. PointerDragBehavior.prototype._startDrag = function (pointerId, fromRay, startPickedPoint) {
  9306. if (!this._scene.activeCamera || this.dragging || !this._attachedNode) {
  9307. return;
  9308. }
  9309. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(this._attachedNode);
  9310. // Create start ray from the camera to the object
  9311. if (fromRay) {
  9312. this._startDragRay.direction.copyFrom(fromRay.direction);
  9313. this._startDragRay.origin.copyFrom(fromRay.origin);
  9314. }
  9315. else {
  9316. this._startDragRay.origin.copyFrom(this._scene.activeCamera.position);
  9317. this._attachedNode.getWorldMatrix().getTranslationToRef(this._tmpVector);
  9318. this._tmpVector.subtractToRef(this._scene.activeCamera.position, this._startDragRay.direction);
  9319. }
  9320. this._updateDragPlanePosition(this._startDragRay, startPickedPoint ? startPickedPoint : this._tmpVector);
  9321. var pickedPoint = this._pickWithRayOnDragPlane(this._startDragRay);
  9322. if (pickedPoint) {
  9323. this.dragging = true;
  9324. this.currentDraggingPointerID = pointerId;
  9325. this.lastDragPosition.copyFrom(pickedPoint);
  9326. this.onDragStartObservable.notifyObservers({ dragPlanePoint: pickedPoint, pointerId: this.currentDraggingPointerID });
  9327. this._targetPosition.copyFrom((this._attachedNode).absolutePosition);
  9328. // Detatch camera controls
  9329. if (this.detachCameraControls && this._scene.activeCamera && !this._scene.activeCamera.leftCamera) {
  9330. if (this._scene.activeCamera.inputs.attachedElement) {
  9331. this._attachedElement = this._scene.activeCamera.inputs.attachedElement;
  9332. this._scene.activeCamera.detachControl(this._scene.activeCamera.inputs.attachedElement);
  9333. }
  9334. else {
  9335. this._attachedElement = null;
  9336. }
  9337. }
  9338. }
  9339. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(this._attachedNode);
  9340. };
  9341. PointerDragBehavior.prototype._moveDrag = function (ray) {
  9342. this._moving = true;
  9343. var pickedPoint = this._pickWithRayOnDragPlane(ray);
  9344. if (pickedPoint) {
  9345. if (this.updateDragPlane) {
  9346. this._updateDragPlanePosition(ray, pickedPoint);
  9347. }
  9348. var dragLength = 0;
  9349. // depending on the drag mode option drag accordingly
  9350. if (this._options.dragAxis) {
  9351. // Convert local drag axis to world
  9352. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._options.dragAxis, this._attachedNode.getWorldMatrix().getRotationMatrix(), this._worldDragAxis);
  9353. // Project delta drag from the drag plane onto the drag axis
  9354. pickedPoint.subtractToRef(this.lastDragPosition, this._tmpVector);
  9355. dragLength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._tmpVector, this._worldDragAxis);
  9356. this._worldDragAxis.scaleToRef(dragLength, this._dragDelta);
  9357. }
  9358. else {
  9359. dragLength = this._dragDelta.length();
  9360. pickedPoint.subtractToRef(this.lastDragPosition, this._dragDelta);
  9361. }
  9362. this._targetPosition.addInPlace(this._dragDelta);
  9363. this.onDragObservable.notifyObservers({ dragDistance: dragLength, delta: this._dragDelta, dragPlanePoint: pickedPoint, dragPlaneNormal: this._dragPlane.forward, pointerId: this.currentDraggingPointerID });
  9364. this.lastDragPosition.copyFrom(pickedPoint);
  9365. }
  9366. };
  9367. PointerDragBehavior.prototype._pickWithRayOnDragPlane = function (ray) {
  9368. var _this = this;
  9369. if (!ray) {
  9370. return null;
  9371. }
  9372. // Calculate angle between plane normal and ray
  9373. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, ray.direction));
  9374. // Correct if ray is casted from oposite side
  9375. if (angle > Math.PI / 2) {
  9376. angle = Math.PI - angle;
  9377. }
  9378. // If the angle is too perpendicular to the plane pick another point on the plane where it is looking
  9379. if (this.maxDragAngle > 0 && angle > this.maxDragAngle) {
  9380. if (this._useAlternatePickedPointAboveMaxDragAngle) {
  9381. // Invert ray direction along the towards object axis
  9382. this._tmpVector.copyFrom(ray.direction);
  9383. (this._attachedNode).absolutePosition.subtractToRef(ray.origin, this._alternatePickedPoint);
  9384. this._alternatePickedPoint.normalize();
  9385. this._alternatePickedPoint.scaleInPlace(this._useAlternatePickedPointAboveMaxDragAngleDragSpeed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._alternatePickedPoint, this._tmpVector));
  9386. this._tmpVector.addInPlace(this._alternatePickedPoint);
  9387. // Project resulting vector onto the drag plane and add it to the attached nodes absolute position to get a picked point
  9388. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(this._dragPlane.forward, this._tmpVector);
  9389. this._dragPlane.forward.scaleToRef(-dot, this._alternatePickedPoint);
  9390. this._alternatePickedPoint.addInPlace(this._tmpVector);
  9391. this._alternatePickedPoint.addInPlace((this._attachedNode).absolutePosition);
  9392. return this._alternatePickedPoint;
  9393. }
  9394. else {
  9395. return null;
  9396. }
  9397. }
  9398. var pickResult = PointerDragBehavior._planeScene.pickWithRay(ray, function (m) { return m == _this._dragPlane; });
  9399. if (pickResult && pickResult.hit && pickResult.pickedMesh && pickResult.pickedPoint) {
  9400. return pickResult.pickedPoint;
  9401. }
  9402. else {
  9403. return null;
  9404. }
  9405. };
  9406. // Position the drag plane based on the attached mesh position, for single axis rotate the plane along the axis to face the camera
  9407. PointerDragBehavior.prototype._updateDragPlanePosition = function (ray, dragPlanePosition) {
  9408. this._pointA.copyFrom(dragPlanePosition);
  9409. if (this._options.dragAxis) {
  9410. 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);
  9411. // Calculate plane normal in direction of camera but perpendicular to drag axis
  9412. this._pointA.addToRef(this._localAxis, this._pointB); // towards drag axis
  9413. ray.origin.subtractToRef(this._pointA, this._pointC);
  9414. this._pointA.addToRef(this._pointC.normalize(), this._pointC); // towards camera
  9415. // Get perpendicular line from direction to camera and drag axis
  9416. this._pointB.subtractToRef(this._pointA, this._lineA);
  9417. this._pointC.subtractToRef(this._pointA, this._lineB);
  9418. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lineB, this._lookAt);
  9419. // Get perpendicular line from previous result and drag axis to adjust lineB to be perpendiculat to camera
  9420. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(this._lineA, this._lookAt, this._lookAt);
  9421. this._lookAt.normalize();
  9422. this._dragPlane.position.copyFrom(this._pointA);
  9423. this._pointA.addToRef(this._lookAt, this._lookAt);
  9424. this._dragPlane.lookAt(this._lookAt);
  9425. }
  9426. else if (this._options.dragPlaneNormal) {
  9427. 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);
  9428. this._dragPlane.position.copyFrom(this._pointA);
  9429. this._pointA.addToRef(this._localAxis, this._lookAt);
  9430. this._dragPlane.lookAt(this._lookAt);
  9431. }
  9432. else {
  9433. this._dragPlane.position.copyFrom(this._pointA);
  9434. this._dragPlane.lookAt(ray.origin);
  9435. }
  9436. // 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)
  9437. this._dragPlane.position.copyFrom(this._attachedNode.absolutePosition);
  9438. this._dragPlane.computeWorldMatrix(true);
  9439. };
  9440. /**
  9441. * Detaches the behavior from the mesh
  9442. */
  9443. PointerDragBehavior.prototype.detach = function () {
  9444. if (this._pointerObserver) {
  9445. this._scene.onPointerObservable.remove(this._pointerObserver);
  9446. }
  9447. if (this._beforeRenderObserver) {
  9448. this._scene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  9449. }
  9450. };
  9451. PointerDragBehavior._AnyMouseID = -2;
  9452. return PointerDragBehavior;
  9453. }());
  9454. /***/ }),
  9455. /***/ "./Behaviors/Meshes/sixDofDragBehavior.ts":
  9456. /*!************************************************!*\
  9457. !*** ./Behaviors/Meshes/sixDofDragBehavior.ts ***!
  9458. \************************************************/
  9459. /*! exports provided: SixDofDragBehavior */
  9460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9461. "use strict";
  9462. __webpack_require__.r(__webpack_exports__);
  9463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return SixDofDragBehavior; });
  9464. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  9465. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  9466. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  9467. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  9468. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  9469. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  9470. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/pivotTools */ "./Misc/pivotTools.ts");
  9471. /**
  9472. * A behavior that when attached to a mesh will allow the mesh to be dragged around based on directions and origin of the pointer's ray
  9473. */
  9474. var SixDofDragBehavior = /** @class */ (function () {
  9475. /**
  9476. * 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
  9477. */
  9478. function SixDofDragBehavior() {
  9479. this._sceneRenderObserver = null;
  9480. this._targetPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9481. this._moving = false;
  9482. this._startingOrientation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9483. /**
  9484. * 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)
  9485. */
  9486. this.zDragFactor = 3;
  9487. /**
  9488. * If the object should rotate to face the drag origin
  9489. */
  9490. this.rotateDraggedObject = true;
  9491. /**
  9492. * If the behavior is currently in a dragging state
  9493. */
  9494. this.dragging = false;
  9495. /**
  9496. * 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)
  9497. */
  9498. this.dragDeltaRatio = 0.2;
  9499. /**
  9500. * The id of the pointer that is currently interacting with the behavior (-1 when no pointer is active)
  9501. */
  9502. this.currentDraggingPointerID = -1;
  9503. /**
  9504. * If camera controls should be detached during the drag
  9505. */
  9506. this.detachCameraControls = true;
  9507. /**
  9508. * Fires each time a drag starts
  9509. */
  9510. this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9511. /**
  9512. * Fires each time a drag ends (eg. mouse release after drag)
  9513. */
  9514. this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  9515. }
  9516. Object.defineProperty(SixDofDragBehavior.prototype, "name", {
  9517. /**
  9518. * The name of the behavior
  9519. */
  9520. get: function () {
  9521. return "SixDofDrag";
  9522. },
  9523. enumerable: true,
  9524. configurable: true
  9525. });
  9526. /**
  9527. * Initializes the behavior
  9528. */
  9529. SixDofDragBehavior.prototype.init = function () { };
  9530. /**
  9531. * Attaches the scale behavior the passed in mesh
  9532. * @param ownerNode The mesh that will be scaled around once attached
  9533. */
  9534. SixDofDragBehavior.prototype.attach = function (ownerNode) {
  9535. var _this = this;
  9536. this._ownerNode = ownerNode;
  9537. this._scene = this._ownerNode.getScene();
  9538. if (!SixDofDragBehavior._virtualScene) {
  9539. SixDofDragBehavior._virtualScene = new _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"](this._scene.getEngine());
  9540. SixDofDragBehavior._virtualScene.detachControl();
  9541. this._scene.getEngine().scenes.pop();
  9542. }
  9543. var pickedMesh = null;
  9544. var lastSixDofOriginPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  9545. // Setup virtual meshes to be used for dragging without dirtying the existing scene
  9546. this._virtualOriginMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9547. this._virtualOriginMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9548. this._virtualDragMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]("", SixDofDragBehavior._virtualScene);
  9549. this._virtualDragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9550. var pickPredicate = function (m) {
  9551. return _this._ownerNode == m || m.isDescendantOf(_this._ownerNode);
  9552. };
  9553. var attachedElement = null;
  9554. this._pointerObserver = this._scene.onPointerObservable.add(function (pointerInfo, eventState) {
  9555. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  9556. if (!_this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.hit && pointerInfo.pickInfo.pickedMesh && pointerInfo.pickInfo.ray && pickPredicate(pointerInfo.pickInfo.pickedMesh)) {
  9557. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9558. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9559. }
  9560. pickedMesh = _this._ownerNode;
  9561. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9562. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9563. // Set position and orientation of the controller
  9564. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9565. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9566. // Attach the virtual drag mesh to the virtual origin mesh so it can be dragged
  9567. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9568. pickedMesh.computeWorldMatrix();
  9569. _this._virtualDragMesh.position.copyFrom(pickedMesh.absolutePosition);
  9570. if (!pickedMesh.rotationQuaternion) {
  9571. pickedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(pickedMesh.rotation.y, pickedMesh.rotation.x, pickedMesh.rotation.z);
  9572. }
  9573. var oldParent = pickedMesh.parent;
  9574. pickedMesh.setParent(null);
  9575. _this._virtualDragMesh.rotationQuaternion.copyFrom(pickedMesh.rotationQuaternion);
  9576. pickedMesh.setParent(oldParent);
  9577. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9578. // Update state
  9579. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9580. _this.dragging = true;
  9581. _this.currentDraggingPointerID = pointerInfo.event.pointerId;
  9582. // Detatch camera controls
  9583. if (_this.detachCameraControls && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9584. if (_this._scene.activeCamera.inputs.attachedElement) {
  9585. attachedElement = _this._scene.activeCamera.inputs.attachedElement;
  9586. _this._scene.activeCamera.detachControl(_this._scene.activeCamera.inputs.attachedElement);
  9587. }
  9588. else {
  9589. attachedElement = null;
  9590. }
  9591. }
  9592. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9593. _this.onDragStartObservable.notifyObservers({});
  9594. }
  9595. }
  9596. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP) {
  9597. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId) {
  9598. _this.dragging = false;
  9599. _this._moving = false;
  9600. _this.currentDraggingPointerID = -1;
  9601. pickedMesh = null;
  9602. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9603. // Reattach camera controls
  9604. if (_this.detachCameraControls && attachedElement && _this._scene.activeCamera && !_this._scene.activeCamera.leftCamera) {
  9605. _this._scene.activeCamera.attachControl(attachedElement, true);
  9606. }
  9607. _this.onDragEndObservable.notifyObservers({});
  9608. }
  9609. }
  9610. else if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE) {
  9611. if (_this.currentDraggingPointerID == pointerInfo.event.pointerId && _this.dragging && pointerInfo.pickInfo && pointerInfo.pickInfo.ray && pickedMesh) {
  9612. var zDragFactor = _this.zDragFactor;
  9613. if (_this._scene.activeCamera && _this._scene.activeCamera.cameraRigMode == _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].RIG_MODE_NONE) {
  9614. pointerInfo.pickInfo.ray.origin.copyFrom(_this._scene.activeCamera.globalPosition);
  9615. zDragFactor = 0;
  9616. }
  9617. // Calculate controller drag distance in controller space
  9618. var originDragDifference = pointerInfo.pickInfo.ray.origin.subtract(lastSixDofOriginPosition);
  9619. lastSixDofOriginPosition.copyFrom(pointerInfo.pickInfo.ray.origin);
  9620. var localOriginDragDifference = -_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(originDragDifference, pointerInfo.pickInfo.ray.direction);
  9621. _this._virtualOriginMesh.addChild(_this._virtualDragMesh);
  9622. // Determine how much the controller moved to/away towards the dragged object and use this to move the object further when its further away
  9623. _this._virtualDragMesh.position.z -= _this._virtualDragMesh.position.z < 1 ? localOriginDragDifference * _this.zDragFactor : localOriginDragDifference * zDragFactor * _this._virtualDragMesh.position.z;
  9624. if (_this._virtualDragMesh.position.z < 0) {
  9625. _this._virtualDragMesh.position.z = 0;
  9626. }
  9627. // Update the controller position
  9628. _this._virtualOriginMesh.position.copyFrom(pointerInfo.pickInfo.ray.origin);
  9629. _this._virtualOriginMesh.lookAt(pointerInfo.pickInfo.ray.origin.add(pointerInfo.pickInfo.ray.direction));
  9630. _this._virtualOriginMesh.removeChild(_this._virtualDragMesh);
  9631. // Move the virtualObjectsPosition into the picked mesh's space if needed
  9632. _this._targetPosition.copyFrom(_this._virtualDragMesh.absolutePosition);
  9633. if (pickedMesh.parent) {
  9634. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._targetPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(pickedMesh.parent.getWorldMatrix()), _this._targetPosition);
  9635. }
  9636. if (!_this._moving) {
  9637. _this._startingOrientation.copyFrom(_this._virtualDragMesh.rotationQuaternion);
  9638. }
  9639. _this._moving = true;
  9640. }
  9641. }
  9642. });
  9643. var tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  9644. // On every frame move towards target scaling to avoid jitter caused by vr controllers
  9645. this._sceneRenderObserver = ownerNode.getScene().onBeforeRenderObservable.add(function () {
  9646. if (_this.dragging && _this._moving && pickedMesh) {
  9647. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RemoveAndStorePivotPoint(pickedMesh);
  9648. // Slowly move mesh to avoid jitter
  9649. pickedMesh.position.addInPlace(_this._targetPosition.subtract(pickedMesh.position).scale(_this.dragDeltaRatio));
  9650. if (_this.rotateDraggedObject) {
  9651. // Get change in rotation
  9652. tmpQuaternion.copyFrom(_this._startingOrientation);
  9653. tmpQuaternion.x = -tmpQuaternion.x;
  9654. tmpQuaternion.y = -tmpQuaternion.y;
  9655. tmpQuaternion.z = -tmpQuaternion.z;
  9656. _this._virtualDragMesh.rotationQuaternion.multiplyToRef(tmpQuaternion, tmpQuaternion);
  9657. // Convert change in rotation to only y axis rotation
  9658. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(tmpQuaternion.toEulerAngles("xyz").y, 0, 0, tmpQuaternion);
  9659. tmpQuaternion.multiplyToRef(_this._startingOrientation, tmpQuaternion);
  9660. // Slowly move mesh to avoid jitter
  9661. var oldParent = pickedMesh.parent;
  9662. // Only rotate the mesh if it's parent has uniform scaling
  9663. if (!oldParent || (oldParent.scaling && !oldParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  9664. pickedMesh.setParent(null);
  9665. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(pickedMesh.rotationQuaternion, tmpQuaternion, _this.dragDeltaRatio, pickedMesh.rotationQuaternion);
  9666. pickedMesh.setParent(oldParent);
  9667. }
  9668. }
  9669. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_6__["PivotTools"]._RestorePivotPoint(pickedMesh);
  9670. }
  9671. });
  9672. };
  9673. /**
  9674. * Detaches the behavior from the mesh
  9675. */
  9676. SixDofDragBehavior.prototype.detach = function () {
  9677. if (this._scene) {
  9678. this._scene.onPointerObservable.remove(this._pointerObserver);
  9679. }
  9680. if (this._ownerNode) {
  9681. this._ownerNode.getScene().onBeforeRenderObservable.remove(this._sceneRenderObserver);
  9682. }
  9683. if (this._virtualOriginMesh) {
  9684. this._virtualOriginMesh.dispose();
  9685. }
  9686. if (this._virtualDragMesh) {
  9687. this._virtualDragMesh.dispose();
  9688. }
  9689. this.onDragEndObservable.clear();
  9690. this.onDragStartObservable.clear();
  9691. };
  9692. return SixDofDragBehavior;
  9693. }());
  9694. /***/ }),
  9695. /***/ "./Behaviors/index.ts":
  9696. /*!****************************!*\
  9697. !*** ./Behaviors/index.ts ***!
  9698. \****************************/
  9699. /*! exports provided: AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior */
  9700. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9701. "use strict";
  9702. __webpack_require__.r(__webpack_exports__);
  9703. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Cameras/index */ "./Behaviors/Cameras/index.ts");
  9704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  9705. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  9706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  9707. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Meshes/index */ "./Behaviors/Meshes/index.ts");
  9708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["AttachToBoxBehavior"]; });
  9709. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["FadeInOutBehavior"]; });
  9710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["MultiPointerScaleBehavior"]; });
  9711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["PointerDragBehavior"]; });
  9712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_1__["SixDofDragBehavior"]; });
  9713. /***/ }),
  9714. /***/ "./Bones/bone.ts":
  9715. /*!***********************!*\
  9716. !*** ./Bones/bone.ts ***!
  9717. \***********************/
  9718. /*! exports provided: Bone */
  9719. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  9720. "use strict";
  9721. __webpack_require__.r(__webpack_exports__);
  9722. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return Bone; });
  9723. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  9724. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  9725. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  9726. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  9727. /**
  9728. * Class used to store bone information
  9729. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  9730. */
  9731. var Bone = /** @class */ (function (_super) {
  9732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Bone, _super);
  9733. /**
  9734. * Create a new bone
  9735. * @param name defines the bone name
  9736. * @param skeleton defines the parent skeleton
  9737. * @param parentBone defines the parent (can be null if the bone is the root)
  9738. * @param localMatrix defines the local matrix
  9739. * @param restPose defines the rest pose matrix
  9740. * @param baseMatrix defines the base matrix
  9741. * @param index defines index of the bone in the hiearchy
  9742. */
  9743. function Bone(
  9744. /**
  9745. * defines the bone name
  9746. */
  9747. name, skeleton, parentBone, localMatrix, restPose, baseMatrix, index) {
  9748. if (parentBone === void 0) { parentBone = null; }
  9749. if (localMatrix === void 0) { localMatrix = null; }
  9750. if (restPose === void 0) { restPose = null; }
  9751. if (baseMatrix === void 0) { baseMatrix = null; }
  9752. if (index === void 0) { index = null; }
  9753. var _this = _super.call(this, name, skeleton.getScene(), false) || this;
  9754. _this.name = name;
  9755. /**
  9756. * Gets the list of child bones
  9757. */
  9758. _this.children = new Array();
  9759. /** Gets the animations associated with this bone */
  9760. _this.animations = new Array();
  9761. /**
  9762. * @hidden Internal only
  9763. * Set this value to map this bone to a different index in the transform matrices
  9764. * Set this value to -1 to exclude the bone from the transform matrices
  9765. */
  9766. _this._index = null;
  9767. _this._absoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9768. _this._invertedAbsoluteTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9769. _this._scalingDeterminant = 1;
  9770. _this._worldTransform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  9771. _this._needToDecompose = true;
  9772. _this._needToCompose = false;
  9773. /** @hidden */
  9774. _this._linkedTransformNode = null;
  9775. _this._skeleton = skeleton;
  9776. _this._localMatrix = localMatrix ? localMatrix.clone() : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  9777. _this._restPose = restPose ? restPose : _this._localMatrix.clone();
  9778. _this._baseMatrix = baseMatrix ? baseMatrix : _this._localMatrix.clone();
  9779. _this._index = index;
  9780. skeleton.bones.push(_this);
  9781. _this.setParent(parentBone, false);
  9782. if (baseMatrix || localMatrix) {
  9783. _this._updateDifferenceMatrix();
  9784. }
  9785. return _this;
  9786. }
  9787. Object.defineProperty(Bone.prototype, "_matrix", {
  9788. /** @hidden */
  9789. get: function () {
  9790. this._compose();
  9791. return this._localMatrix;
  9792. },
  9793. /** @hidden */
  9794. set: function (value) {
  9795. this._localMatrix.copyFrom(value);
  9796. this._needToDecompose = true;
  9797. },
  9798. enumerable: true,
  9799. configurable: true
  9800. });
  9801. // Members
  9802. /**
  9803. * Gets the parent skeleton
  9804. * @returns a skeleton
  9805. */
  9806. Bone.prototype.getSkeleton = function () {
  9807. return this._skeleton;
  9808. };
  9809. /**
  9810. * Gets parent bone
  9811. * @returns a bone or null if the bone is the root of the bone hierarchy
  9812. */
  9813. Bone.prototype.getParent = function () {
  9814. return this._parent;
  9815. };
  9816. /**
  9817. * Sets the parent bone
  9818. * @param parent defines the parent (can be null if the bone is the root)
  9819. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9820. */
  9821. Bone.prototype.setParent = function (parent, updateDifferenceMatrix) {
  9822. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9823. if (this._parent === parent) {
  9824. return;
  9825. }
  9826. if (this._parent) {
  9827. var index = this._parent.children.indexOf(this);
  9828. if (index !== -1) {
  9829. this._parent.children.splice(index, 1);
  9830. }
  9831. }
  9832. this._parent = parent;
  9833. if (this._parent) {
  9834. this._parent.children.push(this);
  9835. }
  9836. if (updateDifferenceMatrix) {
  9837. this._updateDifferenceMatrix();
  9838. }
  9839. this.markAsDirty();
  9840. };
  9841. /**
  9842. * Gets the local matrix
  9843. * @returns a matrix
  9844. */
  9845. Bone.prototype.getLocalMatrix = function () {
  9846. this._compose();
  9847. return this._localMatrix;
  9848. };
  9849. /**
  9850. * Gets the base matrix (initial matrix which remains unchanged)
  9851. * @returns a matrix
  9852. */
  9853. Bone.prototype.getBaseMatrix = function () {
  9854. return this._baseMatrix;
  9855. };
  9856. /**
  9857. * Gets the rest pose matrix
  9858. * @returns a matrix
  9859. */
  9860. Bone.prototype.getRestPose = function () {
  9861. return this._restPose;
  9862. };
  9863. /**
  9864. * Gets a matrix used to store world matrix (ie. the matrix sent to shaders)
  9865. */
  9866. Bone.prototype.getWorldMatrix = function () {
  9867. return this._worldTransform;
  9868. };
  9869. /**
  9870. * Sets the local matrix to rest pose matrix
  9871. */
  9872. Bone.prototype.returnToRest = function () {
  9873. this.updateMatrix(this._restPose.clone());
  9874. };
  9875. /**
  9876. * Gets the inverse of the absolute transform matrix.
  9877. * This matrix will be multiplied by local matrix to get the difference matrix (ie. the difference between original state and current state)
  9878. * @returns a matrix
  9879. */
  9880. Bone.prototype.getInvertedAbsoluteTransform = function () {
  9881. return this._invertedAbsoluteTransform;
  9882. };
  9883. /**
  9884. * Gets the absolute transform matrix (ie base matrix * parent world matrix)
  9885. * @returns a matrix
  9886. */
  9887. Bone.prototype.getAbsoluteTransform = function () {
  9888. return this._absoluteTransform;
  9889. };
  9890. /**
  9891. * Links with the given transform node.
  9892. * The local matrix of this bone is copied from the transform node every frame.
  9893. * @param transformNode defines the transform node to link to
  9894. */
  9895. Bone.prototype.linkTransformNode = function (transformNode) {
  9896. if (this._linkedTransformNode) {
  9897. this._skeleton._numBonesWithLinkedTransformNode--;
  9898. }
  9899. this._linkedTransformNode = transformNode;
  9900. if (this._linkedTransformNode) {
  9901. this._skeleton._numBonesWithLinkedTransformNode++;
  9902. }
  9903. };
  9904. Object.defineProperty(Bone.prototype, "position", {
  9905. // Properties (matches AbstractMesh properties)
  9906. /** Gets or sets current position (in local space) */
  9907. get: function () {
  9908. this._decompose();
  9909. return this._localPosition;
  9910. },
  9911. set: function (newPosition) {
  9912. this._decompose();
  9913. this._localPosition.copyFrom(newPosition);
  9914. this._markAsDirtyAndCompose();
  9915. },
  9916. enumerable: true,
  9917. configurable: true
  9918. });
  9919. Object.defineProperty(Bone.prototype, "rotation", {
  9920. /** Gets or sets current rotation (in local space) */
  9921. get: function () {
  9922. return this.getRotation();
  9923. },
  9924. set: function (newRotation) {
  9925. this.setRotation(newRotation);
  9926. },
  9927. enumerable: true,
  9928. configurable: true
  9929. });
  9930. Object.defineProperty(Bone.prototype, "rotationQuaternion", {
  9931. /** Gets or sets current rotation quaternion (in local space) */
  9932. get: function () {
  9933. this._decompose();
  9934. return this._localRotation;
  9935. },
  9936. set: function (newRotation) {
  9937. this.setRotationQuaternion(newRotation);
  9938. },
  9939. enumerable: true,
  9940. configurable: true
  9941. });
  9942. Object.defineProperty(Bone.prototype, "scaling", {
  9943. /** Gets or sets current scaling (in local space) */
  9944. get: function () {
  9945. return this.getScale();
  9946. },
  9947. set: function (newScaling) {
  9948. this.setScale(newScaling);
  9949. },
  9950. enumerable: true,
  9951. configurable: true
  9952. });
  9953. Object.defineProperty(Bone.prototype, "animationPropertiesOverride", {
  9954. /**
  9955. * Gets the animation properties override
  9956. */
  9957. get: function () {
  9958. return this._skeleton.animationPropertiesOverride;
  9959. },
  9960. enumerable: true,
  9961. configurable: true
  9962. });
  9963. // Methods
  9964. Bone.prototype._decompose = function () {
  9965. if (!this._needToDecompose) {
  9966. return;
  9967. }
  9968. this._needToDecompose = false;
  9969. if (!this._localScaling) {
  9970. this._localScaling = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9971. this._localRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Zero();
  9972. this._localPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  9973. }
  9974. this._localMatrix.decompose(this._localScaling, this._localRotation, this._localPosition);
  9975. };
  9976. Bone.prototype._compose = function () {
  9977. if (!this._needToCompose) {
  9978. return;
  9979. }
  9980. this._needToCompose = false;
  9981. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ComposeToRef(this._localScaling, this._localRotation, this._localPosition, this._localMatrix);
  9982. };
  9983. /**
  9984. * Update the base and local matrices
  9985. * @param matrix defines the new base or local matrix
  9986. * @param updateDifferenceMatrix defines if the difference matrix must be updated
  9987. * @param updateLocalMatrix defines if the local matrix should be updated
  9988. */
  9989. Bone.prototype.updateMatrix = function (matrix, updateDifferenceMatrix, updateLocalMatrix) {
  9990. if (updateDifferenceMatrix === void 0) { updateDifferenceMatrix = true; }
  9991. if (updateLocalMatrix === void 0) { updateLocalMatrix = true; }
  9992. this._baseMatrix.copyFrom(matrix);
  9993. if (updateDifferenceMatrix) {
  9994. this._updateDifferenceMatrix();
  9995. }
  9996. if (updateLocalMatrix) {
  9997. this._localMatrix.copyFrom(matrix);
  9998. this._markAsDirtyAndDecompose();
  9999. }
  10000. else {
  10001. this.markAsDirty();
  10002. }
  10003. };
  10004. /** @hidden */
  10005. Bone.prototype._updateDifferenceMatrix = function (rootMatrix, updateChildren) {
  10006. if (updateChildren === void 0) { updateChildren = true; }
  10007. if (!rootMatrix) {
  10008. rootMatrix = this._baseMatrix;
  10009. }
  10010. if (this._parent) {
  10011. rootMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10012. }
  10013. else {
  10014. this._absoluteTransform.copyFrom(rootMatrix);
  10015. }
  10016. this._absoluteTransform.invertToRef(this._invertedAbsoluteTransform);
  10017. if (updateChildren) {
  10018. for (var index = 0; index < this.children.length; index++) {
  10019. this.children[index]._updateDifferenceMatrix();
  10020. }
  10021. }
  10022. this._scalingDeterminant = (this._absoluteTransform.determinant() < 0 ? -1 : 1);
  10023. };
  10024. /**
  10025. * Flag the bone as dirty (Forcing it to update everything)
  10026. */
  10027. Bone.prototype.markAsDirty = function () {
  10028. this._currentRenderId++;
  10029. this._childRenderId++;
  10030. this._skeleton._markAsDirty();
  10031. };
  10032. Bone.prototype._markAsDirtyAndCompose = function () {
  10033. this.markAsDirty();
  10034. this._needToCompose = true;
  10035. };
  10036. Bone.prototype._markAsDirtyAndDecompose = function () {
  10037. this.markAsDirty();
  10038. this._needToDecompose = true;
  10039. };
  10040. /**
  10041. * Translate the bone in local or world space
  10042. * @param vec The amount to translate the bone
  10043. * @param space The space that the translation is in
  10044. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10045. */
  10046. Bone.prototype.translate = function (vec, space, mesh) {
  10047. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10048. var lm = this.getLocalMatrix();
  10049. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10050. lm.addAtIndex(12, vec.x);
  10051. lm.addAtIndex(13, vec.y);
  10052. lm.addAtIndex(14, vec.z);
  10053. }
  10054. else {
  10055. var wm = null;
  10056. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10057. if (mesh) {
  10058. wm = mesh.getWorldMatrix();
  10059. }
  10060. this._skeleton.computeAbsoluteTransforms();
  10061. var tmat = Bone._tmpMats[0];
  10062. var tvec = Bone._tmpVecs[0];
  10063. if (this._parent) {
  10064. if (mesh && wm) {
  10065. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10066. tmat.multiplyToRef(wm, tmat);
  10067. }
  10068. else {
  10069. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10070. }
  10071. }
  10072. tmat.setTranslationFromFloats(0, 0, 0);
  10073. tmat.invert();
  10074. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vec, tmat, tvec);
  10075. lm.addAtIndex(12, tvec.x);
  10076. lm.addAtIndex(13, tvec.y);
  10077. lm.addAtIndex(14, tvec.z);
  10078. }
  10079. this._markAsDirtyAndDecompose();
  10080. };
  10081. /**
  10082. * Set the postion of the bone in local or world space
  10083. * @param position The position to set the bone
  10084. * @param space The space that the position is in
  10085. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10086. */
  10087. Bone.prototype.setPosition = function (position, space, mesh) {
  10088. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10089. var lm = this.getLocalMatrix();
  10090. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10091. lm.setTranslationFromFloats(position.x, position.y, position.z);
  10092. }
  10093. else {
  10094. var wm = null;
  10095. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10096. if (mesh) {
  10097. wm = mesh.getWorldMatrix();
  10098. }
  10099. this._skeleton.computeAbsoluteTransforms();
  10100. var tmat = Bone._tmpMats[0];
  10101. var vec = Bone._tmpVecs[0];
  10102. if (this._parent) {
  10103. if (mesh && wm) {
  10104. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10105. tmat.multiplyToRef(wm, tmat);
  10106. }
  10107. else {
  10108. tmat.copyFrom(this._parent.getAbsoluteTransform());
  10109. }
  10110. }
  10111. tmat.invert();
  10112. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, vec);
  10113. lm.setTranslationFromFloats(vec.x, vec.y, vec.z);
  10114. }
  10115. this._markAsDirtyAndDecompose();
  10116. };
  10117. /**
  10118. * Set the absolute position of the bone (world space)
  10119. * @param position The position to set the bone
  10120. * @param mesh The mesh that this bone is attached to
  10121. */
  10122. Bone.prototype.setAbsolutePosition = function (position, mesh) {
  10123. this.setPosition(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh);
  10124. };
  10125. /**
  10126. * Scale the bone on the x, y and z axes (in local space)
  10127. * @param x The amount to scale the bone on the x axis
  10128. * @param y The amount to scale the bone on the y axis
  10129. * @param z The amount to scale the bone on the z axis
  10130. * @param scaleChildren sets this to true if children of the bone should be scaled as well (false by default)
  10131. */
  10132. Bone.prototype.scale = function (x, y, z, scaleChildren) {
  10133. if (scaleChildren === void 0) { scaleChildren = false; }
  10134. var locMat = this.getLocalMatrix();
  10135. // Apply new scaling on top of current local matrix
  10136. var scaleMat = Bone._tmpMats[0];
  10137. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(x, y, z, scaleMat);
  10138. scaleMat.multiplyToRef(locMat, locMat);
  10139. // Invert scaling matrix and apply the inverse to all children
  10140. scaleMat.invert();
  10141. for (var _i = 0, _a = this.children; _i < _a.length; _i++) {
  10142. var child = _a[_i];
  10143. var cm = child.getLocalMatrix();
  10144. cm.multiplyToRef(scaleMat, cm);
  10145. cm.multiplyAtIndex(12, x);
  10146. cm.multiplyAtIndex(13, y);
  10147. cm.multiplyAtIndex(14, z);
  10148. child._markAsDirtyAndDecompose();
  10149. }
  10150. this._markAsDirtyAndDecompose();
  10151. if (scaleChildren) {
  10152. for (var _b = 0, _c = this.children; _b < _c.length; _b++) {
  10153. var child = _c[_b];
  10154. child.scale(x, y, z, scaleChildren);
  10155. }
  10156. }
  10157. };
  10158. /**
  10159. * Set the bone scaling in local space
  10160. * @param scale defines the scaling vector
  10161. */
  10162. Bone.prototype.setScale = function (scale) {
  10163. this._decompose();
  10164. this._localScaling.copyFrom(scale);
  10165. this._markAsDirtyAndCompose();
  10166. };
  10167. /**
  10168. * Gets the current scaling in local space
  10169. * @returns the current scaling vector
  10170. */
  10171. Bone.prototype.getScale = function () {
  10172. this._decompose();
  10173. return this._localScaling;
  10174. };
  10175. /**
  10176. * Gets the current scaling in local space and stores it in a target vector
  10177. * @param result defines the target vector
  10178. */
  10179. Bone.prototype.getScaleToRef = function (result) {
  10180. this._decompose();
  10181. result.copyFrom(this._localScaling);
  10182. };
  10183. /**
  10184. * Set the yaw, pitch, and roll of the bone in local or world space
  10185. * @param yaw The rotation of the bone on the y axis
  10186. * @param pitch The rotation of the bone on the x axis
  10187. * @param roll The rotation of the bone on the z axis
  10188. * @param space The space that the axes of rotation are in
  10189. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10190. */
  10191. Bone.prototype.setYawPitchRoll = function (yaw, pitch, roll, space, mesh) {
  10192. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10193. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10194. var quat = Bone._tmpQuat;
  10195. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationYawPitchRollToRef(yaw, pitch, roll, quat);
  10196. this.setRotationQuaternion(quat, space, mesh);
  10197. return;
  10198. }
  10199. var rotMatInv = Bone._tmpMats[0];
  10200. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10201. return;
  10202. }
  10203. var rotMat = Bone._tmpMats[1];
  10204. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(yaw, pitch, roll, rotMat);
  10205. rotMatInv.multiplyToRef(rotMat, rotMat);
  10206. this._rotateWithMatrix(rotMat, space, mesh);
  10207. };
  10208. /**
  10209. * Add a rotation to the bone on an axis in local or world space
  10210. * @param axis The axis to rotate the bone on
  10211. * @param amount The amount to rotate the bone
  10212. * @param space The space that the axis is in
  10213. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10214. */
  10215. Bone.prototype.rotate = function (axis, amount, space, mesh) {
  10216. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10217. var rmat = Bone._tmpMats[0];
  10218. rmat.setTranslationFromFloats(0, 0, 0);
  10219. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, amount, rmat);
  10220. this._rotateWithMatrix(rmat, space, mesh);
  10221. };
  10222. /**
  10223. * Set the rotation of the bone to a particular axis angle in local or world space
  10224. * @param axis The axis to rotate the bone on
  10225. * @param angle The angle that the bone should be rotated to
  10226. * @param space The space that the axis is in
  10227. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10228. */
  10229. Bone.prototype.setAxisAngle = function (axis, angle, space, mesh) {
  10230. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10231. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10232. var quat = Bone._tmpQuat;
  10233. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].RotationAxisToRef(axis, angle, quat);
  10234. this.setRotationQuaternion(quat, space, mesh);
  10235. return;
  10236. }
  10237. var rotMatInv = Bone._tmpMats[0];
  10238. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10239. return;
  10240. }
  10241. var rotMat = Bone._tmpMats[1];
  10242. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationAxisToRef(axis, angle, rotMat);
  10243. rotMatInv.multiplyToRef(rotMat, rotMat);
  10244. this._rotateWithMatrix(rotMat, space, mesh);
  10245. };
  10246. /**
  10247. * Set the euler rotation of the bone in local of world space
  10248. * @param rotation The euler rotation that the bone should be set to
  10249. * @param space The space that the rotation is in
  10250. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10251. */
  10252. Bone.prototype.setRotation = function (rotation, space, mesh) {
  10253. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10254. this.setYawPitchRoll(rotation.y, rotation.x, rotation.z, space, mesh);
  10255. };
  10256. /**
  10257. * Set the quaternion rotation of the bone in local of world space
  10258. * @param quat The quaternion rotation that the bone should be set to
  10259. * @param space The space that the rotation is in
  10260. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10261. */
  10262. Bone.prototype.setRotationQuaternion = function (quat, space, mesh) {
  10263. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10264. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10265. this._decompose();
  10266. this._localRotation.copyFrom(quat);
  10267. this._markAsDirtyAndCompose();
  10268. return;
  10269. }
  10270. var rotMatInv = Bone._tmpMats[0];
  10271. if (!this._getNegativeRotationToRef(rotMatInv, mesh)) {
  10272. return;
  10273. }
  10274. var rotMat = Bone._tmpMats[1];
  10275. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromQuaternionToRef(quat, rotMat);
  10276. rotMatInv.multiplyToRef(rotMat, rotMat);
  10277. this._rotateWithMatrix(rotMat, space, mesh);
  10278. };
  10279. /**
  10280. * Set the rotation matrix of the bone in local of world space
  10281. * @param rotMat The rotation matrix that the bone should be set to
  10282. * @param space The space that the rotation is in
  10283. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10284. */
  10285. Bone.prototype.setRotationMatrix = function (rotMat, 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"].FromRotationMatrixToRef(rotMat, 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 rotMat2 = Bone._tmpMats[1];
  10298. rotMat2.copyFrom(rotMat);
  10299. rotMatInv.multiplyToRef(rotMat, rotMat2);
  10300. this._rotateWithMatrix(rotMat2, space, mesh);
  10301. };
  10302. Bone.prototype._rotateWithMatrix = function (rmat, space, mesh) {
  10303. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10304. var lmat = this.getLocalMatrix();
  10305. var lx = lmat.m[12];
  10306. var ly = lmat.m[13];
  10307. var lz = lmat.m[14];
  10308. var parent = this.getParent();
  10309. var parentScale = Bone._tmpMats[3];
  10310. var parentScaleInv = Bone._tmpMats[4];
  10311. if (parent && space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD) {
  10312. if (mesh) {
  10313. parentScale.copyFrom(mesh.getWorldMatrix());
  10314. parent.getAbsoluteTransform().multiplyToRef(parentScale, parentScale);
  10315. }
  10316. else {
  10317. parentScale.copyFrom(parent.getAbsoluteTransform());
  10318. }
  10319. parentScaleInv.copyFrom(parentScale);
  10320. parentScaleInv.invert();
  10321. lmat.multiplyToRef(parentScale, lmat);
  10322. lmat.multiplyToRef(rmat, lmat);
  10323. lmat.multiplyToRef(parentScaleInv, lmat);
  10324. }
  10325. else {
  10326. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD && mesh) {
  10327. parentScale.copyFrom(mesh.getWorldMatrix());
  10328. parentScaleInv.copyFrom(parentScale);
  10329. parentScaleInv.invert();
  10330. lmat.multiplyToRef(parentScale, lmat);
  10331. lmat.multiplyToRef(rmat, lmat);
  10332. lmat.multiplyToRef(parentScaleInv, lmat);
  10333. }
  10334. else {
  10335. lmat.multiplyToRef(rmat, lmat);
  10336. }
  10337. }
  10338. lmat.setTranslationFromFloats(lx, ly, lz);
  10339. this.computeAbsoluteTransforms();
  10340. this._markAsDirtyAndDecompose();
  10341. };
  10342. Bone.prototype._getNegativeRotationToRef = function (rotMatInv, mesh) {
  10343. var scaleMatrix = Bone._tmpMats[2];
  10344. rotMatInv.copyFrom(this.getAbsoluteTransform());
  10345. if (mesh) {
  10346. rotMatInv.multiplyToRef(mesh.getWorldMatrix(), rotMatInv);
  10347. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ScalingToRef(mesh.scaling.x, mesh.scaling.y, mesh.scaling.z, scaleMatrix);
  10348. }
  10349. rotMatInv.invert();
  10350. if (isNaN(rotMatInv.m[0])) {
  10351. // Matrix failed to invert.
  10352. // This can happen if scale is zero for example.
  10353. return false;
  10354. }
  10355. scaleMatrix.multiplyAtIndex(0, this._scalingDeterminant);
  10356. rotMatInv.multiplyToRef(scaleMatrix, rotMatInv);
  10357. return true;
  10358. };
  10359. /**
  10360. * Get the position of the bone in local or world space
  10361. * @param space The space that the returned position is in
  10362. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10363. * @returns The position of the bone
  10364. */
  10365. Bone.prototype.getPosition = function (space, mesh) {
  10366. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10367. if (mesh === void 0) { mesh = null; }
  10368. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10369. this.getPositionToRef(space, mesh, pos);
  10370. return pos;
  10371. };
  10372. /**
  10373. * Copy the position of the bone to a vector3 in local or world space
  10374. * @param space The space that the returned position is in
  10375. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10376. * @param result The vector3 to copy the position to
  10377. */
  10378. Bone.prototype.getPositionToRef = function (space, mesh, result) {
  10379. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10380. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10381. var lm = this.getLocalMatrix();
  10382. result.x = lm.m[12];
  10383. result.y = lm.m[13];
  10384. result.z = lm.m[14];
  10385. }
  10386. else {
  10387. var wm = null;
  10388. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10389. if (mesh) {
  10390. wm = mesh.getWorldMatrix();
  10391. }
  10392. this._skeleton.computeAbsoluteTransforms();
  10393. var tmat = Bone._tmpMats[0];
  10394. if (mesh && wm) {
  10395. tmat.copyFrom(this.getAbsoluteTransform());
  10396. tmat.multiplyToRef(wm, tmat);
  10397. }
  10398. else {
  10399. tmat = this.getAbsoluteTransform();
  10400. }
  10401. result.x = tmat.m[12];
  10402. result.y = tmat.m[13];
  10403. result.z = tmat.m[14];
  10404. }
  10405. };
  10406. /**
  10407. * Get the absolute position of the bone (world space)
  10408. * @param mesh The mesh that this bone is attached to
  10409. * @returns The absolute position of the bone
  10410. */
  10411. Bone.prototype.getAbsolutePosition = function (mesh) {
  10412. if (mesh === void 0) { mesh = null; }
  10413. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10414. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, pos);
  10415. return pos;
  10416. };
  10417. /**
  10418. * Copy the absolute position of the bone (world space) to the result param
  10419. * @param mesh The mesh that this bone is attached to
  10420. * @param result The vector3 to copy the absolute position to
  10421. */
  10422. Bone.prototype.getAbsolutePositionToRef = function (mesh, result) {
  10423. this.getPositionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, mesh, result);
  10424. };
  10425. /**
  10426. * Compute the absolute transforms of this bone and its children
  10427. */
  10428. Bone.prototype.computeAbsoluteTransforms = function () {
  10429. this._compose();
  10430. if (this._parent) {
  10431. this._localMatrix.multiplyToRef(this._parent._absoluteTransform, this._absoluteTransform);
  10432. }
  10433. else {
  10434. this._absoluteTransform.copyFrom(this._localMatrix);
  10435. var poseMatrix = this._skeleton.getPoseMatrix();
  10436. if (poseMatrix) {
  10437. this._absoluteTransform.multiplyToRef(poseMatrix, this._absoluteTransform);
  10438. }
  10439. }
  10440. var children = this.children;
  10441. var len = children.length;
  10442. for (var i = 0; i < len; i++) {
  10443. children[i].computeAbsoluteTransforms();
  10444. }
  10445. };
  10446. /**
  10447. * Get the world direction from an axis that is in the local space of the bone
  10448. * @param localAxis The local direction that is used to compute the world direction
  10449. * @param mesh The mesh that this bone is attached to
  10450. * @returns The world direction
  10451. */
  10452. Bone.prototype.getDirection = function (localAxis, mesh) {
  10453. if (mesh === void 0) { mesh = null; }
  10454. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10455. this.getDirectionToRef(localAxis, mesh, result);
  10456. return result;
  10457. };
  10458. /**
  10459. * Copy the world direction to a vector3 from an axis that is in the local space of the bone
  10460. * @param localAxis The local direction that is used to compute the world direction
  10461. * @param mesh The mesh that this bone is attached to
  10462. * @param result The vector3 that the world direction will be copied to
  10463. */
  10464. Bone.prototype.getDirectionToRef = function (localAxis, mesh, result) {
  10465. if (mesh === void 0) { mesh = null; }
  10466. var wm = null;
  10467. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10468. if (mesh) {
  10469. wm = mesh.getWorldMatrix();
  10470. }
  10471. this._skeleton.computeAbsoluteTransforms();
  10472. var mat = Bone._tmpMats[0];
  10473. mat.copyFrom(this.getAbsoluteTransform());
  10474. if (mesh && wm) {
  10475. mat.multiplyToRef(wm, mat);
  10476. }
  10477. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(localAxis, mat, result);
  10478. result.normalize();
  10479. };
  10480. /**
  10481. * Get the euler rotation of the bone in local or world space
  10482. * @param space The space that the rotation should be in
  10483. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10484. * @returns The euler rotation
  10485. */
  10486. Bone.prototype.getRotation = function (space, mesh) {
  10487. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10488. if (mesh === void 0) { mesh = null; }
  10489. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10490. this.getRotationToRef(space, mesh, result);
  10491. return result;
  10492. };
  10493. /**
  10494. * Copy the euler rotation of the bone to a vector3. The rotation can be in either local or world space
  10495. * @param space The space that the rotation should be in
  10496. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10497. * @param result The vector3 that the rotation should be copied to
  10498. */
  10499. Bone.prototype.getRotationToRef = function (space, mesh, result) {
  10500. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10501. if (mesh === void 0) { mesh = null; }
  10502. var quat = Bone._tmpQuat;
  10503. this.getRotationQuaternionToRef(space, mesh, quat);
  10504. quat.toEulerAnglesToRef(result);
  10505. };
  10506. /**
  10507. * Get the quaternion rotation of the bone in either local or world space
  10508. * @param space The space that the rotation should be in
  10509. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10510. * @returns The quaternion rotation
  10511. */
  10512. Bone.prototype.getRotationQuaternion = function (space, mesh) {
  10513. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10514. if (mesh === void 0) { mesh = null; }
  10515. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10516. this.getRotationQuaternionToRef(space, mesh, result);
  10517. return result;
  10518. };
  10519. /**
  10520. * Copy the quaternion rotation of the bone to a quaternion. The rotation can be in either local or world space
  10521. * @param space The space that the rotation should be in
  10522. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10523. * @param result The quaternion that the rotation should be copied to
  10524. */
  10525. Bone.prototype.getRotationQuaternionToRef = function (space, mesh, result) {
  10526. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10527. if (mesh === void 0) { mesh = null; }
  10528. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10529. this._decompose();
  10530. result.copyFrom(this._localRotation);
  10531. }
  10532. else {
  10533. var mat = Bone._tmpMats[0];
  10534. var amat = this.getAbsoluteTransform();
  10535. if (mesh) {
  10536. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10537. }
  10538. else {
  10539. mat.copyFrom(amat);
  10540. }
  10541. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10542. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10543. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10544. mat.decompose(undefined, result, undefined);
  10545. }
  10546. };
  10547. /**
  10548. * Get the rotation matrix of the bone in local or world space
  10549. * @param space The space that the rotation should be in
  10550. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10551. * @returns The rotation matrix
  10552. */
  10553. Bone.prototype.getRotationMatrix = function (space, mesh) {
  10554. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10555. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  10556. this.getRotationMatrixToRef(space, mesh, result);
  10557. return result;
  10558. };
  10559. /**
  10560. * Copy the rotation matrix of the bone to a matrix. The rotation can be in either local or world space
  10561. * @param space The space that the rotation should be in
  10562. * @param mesh The mesh that this bone is attached to. This is only used in world space
  10563. * @param result The quaternion that the rotation should be copied to
  10564. */
  10565. Bone.prototype.getRotationMatrixToRef = function (space, mesh, result) {
  10566. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL; }
  10567. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  10568. this.getLocalMatrix().getRotationMatrixToRef(result);
  10569. }
  10570. else {
  10571. var mat = Bone._tmpMats[0];
  10572. var amat = this.getAbsoluteTransform();
  10573. if (mesh) {
  10574. amat.multiplyToRef(mesh.getWorldMatrix(), mat);
  10575. }
  10576. else {
  10577. mat.copyFrom(amat);
  10578. }
  10579. mat.multiplyAtIndex(0, this._scalingDeterminant);
  10580. mat.multiplyAtIndex(1, this._scalingDeterminant);
  10581. mat.multiplyAtIndex(2, this._scalingDeterminant);
  10582. mat.getRotationMatrixToRef(result);
  10583. }
  10584. };
  10585. /**
  10586. * Get the world position of a point that is in the local space of the bone
  10587. * @param position The local position
  10588. * @param mesh The mesh that this bone is attached to
  10589. * @returns The world position
  10590. */
  10591. Bone.prototype.getAbsolutePositionFromLocal = function (position, mesh) {
  10592. if (mesh === void 0) { mesh = null; }
  10593. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10594. this.getAbsolutePositionFromLocalToRef(position, mesh, result);
  10595. return result;
  10596. };
  10597. /**
  10598. * Get the world position of a point that is in the local space of the bone and copy it to the result param
  10599. * @param position The local position
  10600. * @param mesh The mesh that this bone is attached to
  10601. * @param result The vector3 that the world position should be copied to
  10602. */
  10603. Bone.prototype.getAbsolutePositionFromLocalToRef = function (position, mesh, result) {
  10604. if (mesh === void 0) { mesh = null; }
  10605. var wm = null;
  10606. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10607. if (mesh) {
  10608. wm = mesh.getWorldMatrix();
  10609. }
  10610. this._skeleton.computeAbsoluteTransforms();
  10611. var tmat = Bone._tmpMats[0];
  10612. if (mesh && wm) {
  10613. tmat.copyFrom(this.getAbsoluteTransform());
  10614. tmat.multiplyToRef(wm, tmat);
  10615. }
  10616. else {
  10617. tmat = this.getAbsoluteTransform();
  10618. }
  10619. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10620. };
  10621. /**
  10622. * Get the local position of a point that is in world space
  10623. * @param position The world position
  10624. * @param mesh The mesh that this bone is attached to
  10625. * @returns The local position
  10626. */
  10627. Bone.prototype.getLocalPositionFromAbsolute = function (position, mesh) {
  10628. if (mesh === void 0) { mesh = null; }
  10629. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  10630. this.getLocalPositionFromAbsoluteToRef(position, mesh, result);
  10631. return result;
  10632. };
  10633. /**
  10634. * Get the local position of a point that is in world space and copy it to the result param
  10635. * @param position The world position
  10636. * @param mesh The mesh that this bone is attached to
  10637. * @param result The vector3 that the local position should be copied to
  10638. */
  10639. Bone.prototype.getLocalPositionFromAbsoluteToRef = function (position, mesh, result) {
  10640. if (mesh === void 0) { mesh = null; }
  10641. var wm = null;
  10642. //mesh.getWorldMatrix() needs to be called before skeleton.computeAbsoluteTransforms()
  10643. if (mesh) {
  10644. wm = mesh.getWorldMatrix();
  10645. }
  10646. this._skeleton.computeAbsoluteTransforms();
  10647. var tmat = Bone._tmpMats[0];
  10648. tmat.copyFrom(this.getAbsoluteTransform());
  10649. if (mesh && wm) {
  10650. tmat.multiplyToRef(wm, tmat);
  10651. }
  10652. tmat.invert();
  10653. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(position, tmat, result);
  10654. };
  10655. Bone._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  10656. Bone._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10657. Bone._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_2__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  10658. return Bone;
  10659. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  10660. /***/ }),
  10661. /***/ "./Bones/boneIKController.ts":
  10662. /*!***********************************!*\
  10663. !*** ./Bones/boneIKController.ts ***!
  10664. \***********************************/
  10665. /*! exports provided: BoneIKController */
  10666. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10667. "use strict";
  10668. __webpack_require__.r(__webpack_exports__);
  10669. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return BoneIKController; });
  10670. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10671. /**
  10672. * Class used to apply inverse kinematics to bones
  10673. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#boneikcontroller
  10674. */
  10675. var BoneIKController = /** @class */ (function () {
  10676. /**
  10677. * Creates a new BoneIKController
  10678. * @param mesh defines the mesh to control
  10679. * @param bone defines the bone to control
  10680. * @param options defines options to set up the controller
  10681. */
  10682. function BoneIKController(mesh, bone, options) {
  10683. /**
  10684. * Gets or sets the target position
  10685. */
  10686. this.targetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10687. /**
  10688. * Gets or sets the pole target position
  10689. */
  10690. this.poleTargetPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10691. /**
  10692. * Gets or sets the pole target local offset
  10693. */
  10694. this.poleTargetLocalOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  10695. /**
  10696. * Gets or sets the pole angle
  10697. */
  10698. this.poleAngle = 0;
  10699. /**
  10700. * 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)
  10701. */
  10702. this.slerpAmount = 1;
  10703. this._bone1Quat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10704. this._bone1Mat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  10705. this._bone2Ang = Math.PI;
  10706. this._maxAngle = Math.PI;
  10707. this._rightHandedSystem = false;
  10708. this._bendAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right();
  10709. this._slerping = false;
  10710. this._adjustRoll = 0;
  10711. this._bone2 = bone;
  10712. this._bone1 = bone.getParent();
  10713. if (!this._bone1) {
  10714. return;
  10715. }
  10716. this.mesh = mesh;
  10717. var bonePos = bone.getPosition();
  10718. if (bone.getAbsoluteTransform().determinant() > 0) {
  10719. this._rightHandedSystem = true;
  10720. this._bendAxis.x = 0;
  10721. this._bendAxis.y = 0;
  10722. this._bendAxis.z = -1;
  10723. if (bonePos.x > bonePos.y && bonePos.x > bonePos.z) {
  10724. this._adjustRoll = Math.PI * .5;
  10725. this._bendAxis.z = 1;
  10726. }
  10727. }
  10728. if (this._bone1.length) {
  10729. var boneScale1 = this._bone1.getScale();
  10730. var boneScale2 = this._bone2.getScale();
  10731. this._bone1Length = this._bone1.length * boneScale1.y * this.mesh.scaling.y;
  10732. this._bone2Length = this._bone2.length * boneScale2.y * this.mesh.scaling.y;
  10733. }
  10734. else if (this._bone1.children[0]) {
  10735. mesh.computeWorldMatrix(true);
  10736. var pos1 = this._bone2.children[0].getAbsolutePosition(mesh);
  10737. var pos2 = this._bone2.getAbsolutePosition(mesh);
  10738. var pos3 = this._bone1.getAbsolutePosition(mesh);
  10739. this._bone1Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos1, pos2);
  10740. this._bone2Length = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(pos2, pos3);
  10741. }
  10742. this._bone1.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, mesh, this._bone1Mat);
  10743. this.maxAngle = Math.PI;
  10744. if (options) {
  10745. if (options.targetMesh) {
  10746. this.targetMesh = options.targetMesh;
  10747. this.targetMesh.computeWorldMatrix(true);
  10748. }
  10749. if (options.poleTargetMesh) {
  10750. this.poleTargetMesh = options.poleTargetMesh;
  10751. this.poleTargetMesh.computeWorldMatrix(true);
  10752. }
  10753. else if (options.poleTargetBone) {
  10754. this.poleTargetBone = options.poleTargetBone;
  10755. }
  10756. else if (this._bone1.getParent()) {
  10757. this.poleTargetBone = this._bone1.getParent();
  10758. }
  10759. if (options.poleTargetLocalOffset) {
  10760. this.poleTargetLocalOffset.copyFrom(options.poleTargetLocalOffset);
  10761. }
  10762. if (options.poleAngle) {
  10763. this.poleAngle = options.poleAngle;
  10764. }
  10765. if (options.bendAxis) {
  10766. this._bendAxis.copyFrom(options.bendAxis);
  10767. }
  10768. if (options.maxAngle) {
  10769. this.maxAngle = options.maxAngle;
  10770. }
  10771. if (options.slerpAmount) {
  10772. this.slerpAmount = options.slerpAmount;
  10773. }
  10774. }
  10775. }
  10776. Object.defineProperty(BoneIKController.prototype, "maxAngle", {
  10777. /**
  10778. * Gets or sets maximum allowed angle
  10779. */
  10780. get: function () {
  10781. return this._maxAngle;
  10782. },
  10783. set: function (value) {
  10784. this._setMaxAngle(value);
  10785. },
  10786. enumerable: true,
  10787. configurable: true
  10788. });
  10789. BoneIKController.prototype._setMaxAngle = function (ang) {
  10790. if (ang < 0) {
  10791. ang = 0;
  10792. }
  10793. if (ang > Math.PI || ang == undefined) {
  10794. ang = Math.PI;
  10795. }
  10796. this._maxAngle = ang;
  10797. var a = this._bone1Length;
  10798. var b = this._bone2Length;
  10799. this._maxReach = Math.sqrt(a * a + b * b - 2 * a * b * Math.cos(ang));
  10800. };
  10801. /**
  10802. * Force the controller to update the bones
  10803. */
  10804. BoneIKController.prototype.update = function () {
  10805. var bone1 = this._bone1;
  10806. if (!bone1) {
  10807. return;
  10808. }
  10809. var target = this.targetPosition;
  10810. var poleTarget = this.poleTargetPosition;
  10811. var mat1 = BoneIKController._tmpMats[0];
  10812. var mat2 = BoneIKController._tmpMats[1];
  10813. if (this.targetMesh) {
  10814. target.copyFrom(this.targetMesh.getAbsolutePosition());
  10815. }
  10816. if (this.poleTargetBone) {
  10817. this.poleTargetBone.getAbsolutePositionFromLocalToRef(this.poleTargetLocalOffset, this.mesh, poleTarget);
  10818. }
  10819. else if (this.poleTargetMesh) {
  10820. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this.poleTargetLocalOffset, this.poleTargetMesh.getWorldMatrix(), poleTarget);
  10821. }
  10822. var bonePos = BoneIKController._tmpVecs[0];
  10823. var zaxis = BoneIKController._tmpVecs[1];
  10824. var xaxis = BoneIKController._tmpVecs[2];
  10825. var yaxis = BoneIKController._tmpVecs[3];
  10826. var upAxis = BoneIKController._tmpVecs[4];
  10827. var _tmpQuat = BoneIKController._tmpQuat;
  10828. bone1.getAbsolutePositionToRef(this.mesh, bonePos);
  10829. poleTarget.subtractToRef(bonePos, upAxis);
  10830. if (upAxis.x == 0 && upAxis.y == 0 && upAxis.z == 0) {
  10831. upAxis.y = 1;
  10832. }
  10833. else {
  10834. upAxis.normalize();
  10835. }
  10836. target.subtractToRef(bonePos, yaxis);
  10837. yaxis.normalize();
  10838. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, upAxis, zaxis);
  10839. zaxis.normalize();
  10840. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(yaxis, zaxis, xaxis);
  10841. xaxis.normalize();
  10842. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, mat1);
  10843. var a = this._bone1Length;
  10844. var b = this._bone2Length;
  10845. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(bonePos, target);
  10846. if (this._maxReach > 0) {
  10847. c = Math.min(this._maxReach, c);
  10848. }
  10849. var acosa = (b * b + c * c - a * a) / (2 * b * c);
  10850. var acosb = (c * c + a * a - b * b) / (2 * c * a);
  10851. if (acosa > 1) {
  10852. acosa = 1;
  10853. }
  10854. if (acosb > 1) {
  10855. acosb = 1;
  10856. }
  10857. if (acosa < -1) {
  10858. acosa = -1;
  10859. }
  10860. if (acosb < -1) {
  10861. acosb = -1;
  10862. }
  10863. var angA = Math.acos(acosa);
  10864. var angB = Math.acos(acosb);
  10865. var angC = -angA - angB;
  10866. if (this._rightHandedSystem) {
  10867. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationYawPitchRollToRef(0, 0, this._adjustRoll, mat2);
  10868. mat2.multiplyToRef(mat1, mat1);
  10869. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(this._bendAxis, angB, mat2);
  10870. mat2.multiplyToRef(mat1, mat1);
  10871. }
  10872. else {
  10873. var _tmpVec = BoneIKController._tmpVecs[5];
  10874. _tmpVec.copyFrom(this._bendAxis);
  10875. _tmpVec.x *= -1;
  10876. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(_tmpVec, -angB, mat2);
  10877. mat2.multiplyToRef(mat1, mat1);
  10878. }
  10879. if (this.poleAngle) {
  10880. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(yaxis, this.poleAngle, mat2);
  10881. mat1.multiplyToRef(mat2, mat1);
  10882. }
  10883. if (this._bone1) {
  10884. if (this.slerpAmount < 1) {
  10885. if (!this._slerping) {
  10886. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._bone1Mat, this._bone1Quat);
  10887. }
  10888. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(mat1, _tmpQuat);
  10889. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].SlerpToRef(this._bone1Quat, _tmpQuat, this.slerpAmount, this._bone1Quat);
  10890. angC = this._bone2Ang * (1.0 - this.slerpAmount) + angC * this.slerpAmount;
  10891. this._bone1.setRotationQuaternion(this._bone1Quat, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10892. this._slerping = true;
  10893. }
  10894. else {
  10895. this._bone1.setRotationMatrix(mat1, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].WORLD, this.mesh);
  10896. this._bone1Mat.copyFrom(mat1);
  10897. this._slerping = false;
  10898. }
  10899. }
  10900. this._bone2.setAxisAngle(this._bendAxis, angC, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Space"].LOCAL);
  10901. this._bone2Ang = angC;
  10902. };
  10903. 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()];
  10904. BoneIKController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].Identity();
  10905. BoneIKController._tmpMats = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity()];
  10906. return BoneIKController;
  10907. }());
  10908. /***/ }),
  10909. /***/ "./Bones/boneLookController.ts":
  10910. /*!*************************************!*\
  10911. !*** ./Bones/boneLookController.ts ***!
  10912. \*************************************/
  10913. /*! exports provided: BoneLookController */
  10914. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  10915. "use strict";
  10916. __webpack_require__.r(__webpack_exports__);
  10917. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return BoneLookController; });
  10918. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  10919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  10920. /**
  10921. * Class used to make a bone look toward a point in space
  10922. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons#bonelookcontroller
  10923. */
  10924. var BoneLookController = /** @class */ (function () {
  10925. /**
  10926. * Create a BoneLookController
  10927. * @param mesh the mesh that the bone belongs to
  10928. * @param bone the bone that will be looking to the target
  10929. * @param target the target Vector3 to look at
  10930. * @param options optional settings:
  10931. * * maxYaw: the maximum angle the bone will yaw to
  10932. * * minYaw: the minimum angle the bone will yaw to
  10933. * * maxPitch: the maximum angle the bone will pitch to
  10934. * * minPitch: the minimum angle the bone will yaw to
  10935. * * slerpAmount: set the between 0 and 1 to make the bone slerp to the target.
  10936. * * upAxis: the up axis of the coordinate system
  10937. * * upAxisSpace: the space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD.
  10938. * * yawAxis: set yawAxis if the bone does not yaw on the y axis
  10939. * * pitchAxis: set pitchAxis if the bone does not pitch on the x axis
  10940. * * adjustYaw: used to make an adjustment to the yaw of the bone
  10941. * * adjustPitch: used to make an adjustment to the pitch of the bone
  10942. * * adjustRoll: used to make an adjustment to the roll of the bone
  10943. **/
  10944. function BoneLookController(mesh, bone, target, options) {
  10945. /**
  10946. * The up axis of the coordinate system that is used when the bone is rotated
  10947. */
  10948. this.upAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up();
  10949. /**
  10950. * The space that the up axis is in - Space.BONE, Space.LOCAL (default), or Space.WORLD
  10951. */
  10952. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  10953. /**
  10954. * Used to make an adjustment to the yaw of the bone
  10955. */
  10956. this.adjustYaw = 0;
  10957. /**
  10958. * Used to make an adjustment to the pitch of the bone
  10959. */
  10960. this.adjustPitch = 0;
  10961. /**
  10962. * Used to make an adjustment to the roll of the bone
  10963. */
  10964. this.adjustRoll = 0;
  10965. /**
  10966. * 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)
  10967. */
  10968. this.slerpAmount = 1;
  10969. this._boneQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  10970. this._slerping = false;
  10971. this._firstFrameSkipped = false;
  10972. this._fowardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Forward();
  10973. this.mesh = mesh;
  10974. this.bone = bone;
  10975. this.target = target;
  10976. if (options) {
  10977. if (options.adjustYaw) {
  10978. this.adjustYaw = options.adjustYaw;
  10979. }
  10980. if (options.adjustPitch) {
  10981. this.adjustPitch = options.adjustPitch;
  10982. }
  10983. if (options.adjustRoll) {
  10984. this.adjustRoll = options.adjustRoll;
  10985. }
  10986. if (options.maxYaw != null) {
  10987. this.maxYaw = options.maxYaw;
  10988. }
  10989. else {
  10990. this.maxYaw = Math.PI;
  10991. }
  10992. if (options.minYaw != null) {
  10993. this.minYaw = options.minYaw;
  10994. }
  10995. else {
  10996. this.minYaw = -Math.PI;
  10997. }
  10998. if (options.maxPitch != null) {
  10999. this.maxPitch = options.maxPitch;
  11000. }
  11001. else {
  11002. this.maxPitch = Math.PI;
  11003. }
  11004. if (options.minPitch != null) {
  11005. this.minPitch = options.minPitch;
  11006. }
  11007. else {
  11008. this.minPitch = -Math.PI;
  11009. }
  11010. if (options.slerpAmount != null) {
  11011. this.slerpAmount = options.slerpAmount;
  11012. }
  11013. if (options.upAxis != null) {
  11014. this.upAxis = options.upAxis;
  11015. }
  11016. if (options.upAxisSpace != null) {
  11017. this.upAxisSpace = options.upAxisSpace;
  11018. }
  11019. if (options.yawAxis != null || options.pitchAxis != null) {
  11020. var newYawAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Y;
  11021. var newPitchAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].X;
  11022. if (options.yawAxis != null) {
  11023. newYawAxis = options.yawAxis.clone();
  11024. newYawAxis.normalize();
  11025. }
  11026. if (options.pitchAxis != null) {
  11027. newPitchAxis = options.pitchAxis.clone();
  11028. newPitchAxis.normalize();
  11029. }
  11030. var newRollAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(newPitchAxis, newYawAxis);
  11031. this._transformYawPitch = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  11032. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(newPitchAxis, newYawAxis, newRollAxis, this._transformYawPitch);
  11033. this._transformYawPitchInv = this._transformYawPitch.clone();
  11034. this._transformYawPitch.invert();
  11035. }
  11036. }
  11037. if (!bone.getParent() && this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE) {
  11038. this.upAxisSpace = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL;
  11039. }
  11040. }
  11041. Object.defineProperty(BoneLookController.prototype, "minYaw", {
  11042. /**
  11043. * Gets or sets the minimum yaw angle that the bone can look to
  11044. */
  11045. get: function () {
  11046. return this._minYaw;
  11047. },
  11048. set: function (value) {
  11049. this._minYaw = value;
  11050. this._minYawSin = Math.sin(value);
  11051. this._minYawCos = Math.cos(value);
  11052. if (this._maxYaw != null) {
  11053. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11054. this._yawRange = this._maxYaw - this._minYaw;
  11055. }
  11056. },
  11057. enumerable: true,
  11058. configurable: true
  11059. });
  11060. Object.defineProperty(BoneLookController.prototype, "maxYaw", {
  11061. /**
  11062. * Gets or sets the maximum yaw angle that the bone can look to
  11063. */
  11064. get: function () {
  11065. return this._maxYaw;
  11066. },
  11067. set: function (value) {
  11068. this._maxYaw = value;
  11069. this._maxYawSin = Math.sin(value);
  11070. this._maxYawCos = Math.cos(value);
  11071. if (this._minYaw != null) {
  11072. this._midYawConstraint = this._getAngleDiff(this._minYaw, this._maxYaw) * .5 + this._minYaw;
  11073. this._yawRange = this._maxYaw - this._minYaw;
  11074. }
  11075. },
  11076. enumerable: true,
  11077. configurable: true
  11078. });
  11079. Object.defineProperty(BoneLookController.prototype, "minPitch", {
  11080. /**
  11081. * Gets or sets the minimum pitch angle that the bone can look to
  11082. */
  11083. get: function () {
  11084. return this._minPitch;
  11085. },
  11086. set: function (value) {
  11087. this._minPitch = value;
  11088. this._minPitchTan = Math.tan(value);
  11089. },
  11090. enumerable: true,
  11091. configurable: true
  11092. });
  11093. Object.defineProperty(BoneLookController.prototype, "maxPitch", {
  11094. /**
  11095. * Gets or sets the maximum pitch angle that the bone can look to
  11096. */
  11097. get: function () {
  11098. return this._maxPitch;
  11099. },
  11100. set: function (value) {
  11101. this._maxPitch = value;
  11102. this._maxPitchTan = Math.tan(value);
  11103. },
  11104. enumerable: true,
  11105. configurable: true
  11106. });
  11107. /**
  11108. * Update the bone to look at the target. This should be called before the scene is rendered (use scene.registerBeforeRender())
  11109. */
  11110. BoneLookController.prototype.update = function () {
  11111. //skip the first frame when slerping so that the mesh rotation is correct
  11112. if (this.slerpAmount < 1 && !this._firstFrameSkipped) {
  11113. this._firstFrameSkipped = true;
  11114. return;
  11115. }
  11116. var bone = this.bone;
  11117. var bonePos = BoneLookController._tmpVecs[0];
  11118. bone.getAbsolutePositionToRef(this.mesh, bonePos);
  11119. var target = this.target;
  11120. var _tmpMat1 = BoneLookController._tmpMats[0];
  11121. var _tmpMat2 = BoneLookController._tmpMats[1];
  11122. var mesh = this.mesh;
  11123. var parentBone = bone.getParent();
  11124. var upAxis = BoneLookController._tmpVecs[1];
  11125. upAxis.copyFrom(this.upAxis);
  11126. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && parentBone) {
  11127. if (this._transformYawPitch) {
  11128. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(upAxis, this._transformYawPitchInv, upAxis);
  11129. }
  11130. parentBone.getDirectionToRef(upAxis, this.mesh, upAxis);
  11131. }
  11132. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL) {
  11133. mesh.getDirectionToRef(upAxis, upAxis);
  11134. if (mesh.scaling.x != 1 || mesh.scaling.y != 1 || mesh.scaling.z != 1) {
  11135. upAxis.normalize();
  11136. }
  11137. }
  11138. var checkYaw = false;
  11139. var checkPitch = false;
  11140. if (this._maxYaw != Math.PI || this._minYaw != -Math.PI) {
  11141. checkYaw = true;
  11142. }
  11143. if (this._maxPitch != Math.PI || this._minPitch != -Math.PI) {
  11144. checkPitch = true;
  11145. }
  11146. if (checkYaw || checkPitch) {
  11147. var spaceMat = BoneLookController._tmpMats[2];
  11148. var spaceMatInv = BoneLookController._tmpMats[3];
  11149. if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].BONE && upAxis.y == 1 && parentBone) {
  11150. parentBone.getRotationMatrixToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, spaceMat);
  11151. }
  11152. else if (this.upAxisSpace == _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].LOCAL && upAxis.y == 1 && !parentBone) {
  11153. spaceMat.copyFrom(mesh.getWorldMatrix());
  11154. }
  11155. else {
  11156. var forwardAxis = BoneLookController._tmpVecs[2];
  11157. forwardAxis.copyFrom(this._fowardAxis);
  11158. if (this._transformYawPitch) {
  11159. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(forwardAxis, this._transformYawPitchInv, forwardAxis);
  11160. }
  11161. if (parentBone) {
  11162. parentBone.getDirectionToRef(forwardAxis, this.mesh, forwardAxis);
  11163. }
  11164. else {
  11165. mesh.getDirectionToRef(forwardAxis, forwardAxis);
  11166. }
  11167. var rightAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(upAxis, forwardAxis);
  11168. rightAxis.normalize();
  11169. var forwardAxis = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(rightAxis, upAxis);
  11170. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(rightAxis, upAxis, forwardAxis, spaceMat);
  11171. }
  11172. spaceMat.invertToRef(spaceMatInv);
  11173. var xzlen = null;
  11174. if (checkPitch) {
  11175. var localTarget = BoneLookController._tmpVecs[3];
  11176. target.subtractToRef(bonePos, localTarget);
  11177. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11178. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11179. var pitch = Math.atan2(localTarget.y, xzlen);
  11180. var newPitch = pitch;
  11181. if (pitch > this._maxPitch) {
  11182. localTarget.y = this._maxPitchTan * xzlen;
  11183. newPitch = this._maxPitch;
  11184. }
  11185. else if (pitch < this._minPitch) {
  11186. localTarget.y = this._minPitchTan * xzlen;
  11187. newPitch = this._minPitch;
  11188. }
  11189. if (pitch != newPitch) {
  11190. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11191. localTarget.addInPlace(bonePos);
  11192. target = localTarget;
  11193. }
  11194. }
  11195. if (checkYaw) {
  11196. var localTarget = BoneLookController._tmpVecs[4];
  11197. target.subtractToRef(bonePos, localTarget);
  11198. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMatInv, localTarget);
  11199. var yaw = Math.atan2(localTarget.x, localTarget.z);
  11200. var newYaw = yaw;
  11201. if (yaw > this._maxYaw || yaw < this._minYaw) {
  11202. if (xzlen == null) {
  11203. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11204. }
  11205. if (this._yawRange > Math.PI) {
  11206. if (this._isAngleBetween(yaw, this._maxYaw, this._midYawConstraint)) {
  11207. localTarget.z = this._maxYawCos * xzlen;
  11208. localTarget.x = this._maxYawSin * xzlen;
  11209. newYaw = this._maxYaw;
  11210. }
  11211. else if (this._isAngleBetween(yaw, this._midYawConstraint, this._minYaw)) {
  11212. localTarget.z = this._minYawCos * xzlen;
  11213. localTarget.x = this._minYawSin * xzlen;
  11214. newYaw = this._minYaw;
  11215. }
  11216. }
  11217. else {
  11218. if (yaw > this._maxYaw) {
  11219. localTarget.z = this._maxYawCos * xzlen;
  11220. localTarget.x = this._maxYawSin * xzlen;
  11221. newYaw = this._maxYaw;
  11222. }
  11223. else if (yaw < this._minYaw) {
  11224. localTarget.z = this._minYawCos * xzlen;
  11225. localTarget.x = this._minYawSin * xzlen;
  11226. newYaw = this._minYaw;
  11227. }
  11228. }
  11229. }
  11230. if (this._slerping && this._yawRange > Math.PI) {
  11231. //are we going to be crossing into the min/max region?
  11232. var boneFwd = BoneLookController._tmpVecs[8];
  11233. boneFwd.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Axis"].Z);
  11234. if (this._transformYawPitch) {
  11235. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, this._transformYawPitchInv, boneFwd);
  11236. }
  11237. var boneRotMat = BoneLookController._tmpMats[4];
  11238. this._boneQuat.toRotationMatrix(boneRotMat);
  11239. this.mesh.getWorldMatrix().multiplyToRef(boneRotMat, boneRotMat);
  11240. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, boneRotMat, boneFwd);
  11241. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(boneFwd, spaceMatInv, boneFwd);
  11242. var boneYaw = Math.atan2(boneFwd.x, boneFwd.z);
  11243. var angBtwTar = this._getAngleBetween(boneYaw, yaw);
  11244. var angBtwMidYaw = this._getAngleBetween(boneYaw, this._midYawConstraint);
  11245. if (angBtwTar > angBtwMidYaw) {
  11246. if (xzlen == null) {
  11247. xzlen = Math.sqrt(localTarget.x * localTarget.x + localTarget.z * localTarget.z);
  11248. }
  11249. var angBtwMax = this._getAngleBetween(boneYaw, this._maxYaw);
  11250. var angBtwMin = this._getAngleBetween(boneYaw, this._minYaw);
  11251. if (angBtwMin < angBtwMax) {
  11252. newYaw = boneYaw + Math.PI * .75;
  11253. localTarget.z = Math.cos(newYaw) * xzlen;
  11254. localTarget.x = Math.sin(newYaw) * xzlen;
  11255. }
  11256. else {
  11257. newYaw = boneYaw - Math.PI * .75;
  11258. localTarget.z = Math.cos(newYaw) * xzlen;
  11259. localTarget.x = Math.sin(newYaw) * xzlen;
  11260. }
  11261. }
  11262. }
  11263. if (yaw != newYaw) {
  11264. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(localTarget, spaceMat, localTarget);
  11265. localTarget.addInPlace(bonePos);
  11266. target = localTarget;
  11267. }
  11268. }
  11269. }
  11270. var zaxis = BoneLookController._tmpVecs[5];
  11271. var xaxis = BoneLookController._tmpVecs[6];
  11272. var yaxis = BoneLookController._tmpVecs[7];
  11273. var _tmpQuat = BoneLookController._tmpQuat;
  11274. target.subtractToRef(bonePos, zaxis);
  11275. zaxis.normalize();
  11276. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(upAxis, zaxis, xaxis);
  11277. xaxis.normalize();
  11278. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(zaxis, xaxis, yaxis);
  11279. yaxis.normalize();
  11280. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromXYZAxesToRef(xaxis, yaxis, zaxis, _tmpMat1);
  11281. if (xaxis.x === 0 && xaxis.y === 0 && xaxis.z === 0) {
  11282. return;
  11283. }
  11284. if (yaxis.x === 0 && yaxis.y === 0 && yaxis.z === 0) {
  11285. return;
  11286. }
  11287. if (zaxis.x === 0 && zaxis.y === 0 && zaxis.z === 0) {
  11288. return;
  11289. }
  11290. if (this.adjustYaw || this.adjustPitch || this.adjustRoll) {
  11291. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationYawPitchRollToRef(this.adjustYaw, this.adjustPitch, this.adjustRoll, _tmpMat2);
  11292. _tmpMat2.multiplyToRef(_tmpMat1, _tmpMat1);
  11293. }
  11294. if (this.slerpAmount < 1) {
  11295. if (!this._slerping) {
  11296. this.bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh, this._boneQuat);
  11297. }
  11298. if (this._transformYawPitch) {
  11299. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11300. }
  11301. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(_tmpMat1, _tmpQuat);
  11302. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].SlerpToRef(this._boneQuat, _tmpQuat, this.slerpAmount, this._boneQuat);
  11303. this.bone.setRotationQuaternion(this._boneQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11304. this._slerping = true;
  11305. }
  11306. else {
  11307. if (this._transformYawPitch) {
  11308. this._transformYawPitch.multiplyToRef(_tmpMat1, _tmpMat1);
  11309. }
  11310. this.bone.setRotationMatrix(_tmpMat1, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Space"].WORLD, this.mesh);
  11311. this._slerping = false;
  11312. }
  11313. };
  11314. BoneLookController.prototype._getAngleDiff = function (ang1, ang2) {
  11315. var angDiff = ang2 - ang1;
  11316. angDiff %= Math.PI * 2;
  11317. if (angDiff > Math.PI) {
  11318. angDiff -= Math.PI * 2;
  11319. }
  11320. else if (angDiff < -Math.PI) {
  11321. angDiff += Math.PI * 2;
  11322. }
  11323. return angDiff;
  11324. };
  11325. BoneLookController.prototype._getAngleBetween = function (ang1, ang2) {
  11326. ang1 %= (2 * Math.PI);
  11327. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11328. ang2 %= (2 * Math.PI);
  11329. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11330. var ab = 0;
  11331. if (ang1 < ang2) {
  11332. ab = ang2 - ang1;
  11333. }
  11334. else {
  11335. ab = ang1 - ang2;
  11336. }
  11337. if (ab > Math.PI) {
  11338. ab = Math.PI * 2 - ab;
  11339. }
  11340. return ab;
  11341. };
  11342. BoneLookController.prototype._isAngleBetween = function (ang, ang1, ang2) {
  11343. ang %= (2 * Math.PI);
  11344. ang = (ang < 0) ? ang + (2 * Math.PI) : ang;
  11345. ang1 %= (2 * Math.PI);
  11346. ang1 = (ang1 < 0) ? ang1 + (2 * Math.PI) : ang1;
  11347. ang2 %= (2 * Math.PI);
  11348. ang2 = (ang2 < 0) ? ang2 + (2 * Math.PI) : ang2;
  11349. if (ang1 < ang2) {
  11350. if (ang > ang1 && ang < ang2) {
  11351. return true;
  11352. }
  11353. }
  11354. else {
  11355. if (ang > ang2 && ang < ang1) {
  11356. return true;
  11357. }
  11358. }
  11359. return false;
  11360. };
  11361. BoneLookController._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(10, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  11362. BoneLookController._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Identity();
  11363. BoneLookController._tmpMats = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(5, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity);
  11364. return BoneLookController;
  11365. }());
  11366. /***/ }),
  11367. /***/ "./Bones/index.ts":
  11368. /*!************************!*\
  11369. !*** ./Bones/index.ts ***!
  11370. \************************/
  11371. /*! exports provided: Bone, BoneIKController, BoneLookController, Skeleton */
  11372. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11373. "use strict";
  11374. __webpack_require__.r(__webpack_exports__);
  11375. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  11377. /* harmony import */ var _boneIKController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneIKController */ "./Bones/boneIKController.ts");
  11378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _boneIKController__WEBPACK_IMPORTED_MODULE_1__["BoneIKController"]; });
  11379. /* harmony import */ var _boneLookController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boneLookController */ "./Bones/boneLookController.ts");
  11380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _boneLookController__WEBPACK_IMPORTED_MODULE_2__["BoneLookController"]; });
  11381. /* harmony import */ var _skeleton__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./skeleton */ "./Bones/skeleton.ts");
  11382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _skeleton__WEBPACK_IMPORTED_MODULE_3__["Skeleton"]; });
  11383. /***/ }),
  11384. /***/ "./Bones/skeleton.ts":
  11385. /*!***************************!*\
  11386. !*** ./Bones/skeleton.ts ***!
  11387. \***************************/
  11388. /*! exports provided: Skeleton */
  11389. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  11390. "use strict";
  11391. __webpack_require__.r(__webpack_exports__);
  11392. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return Skeleton; });
  11393. /* harmony import */ var _bone__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./bone */ "./Bones/bone.ts");
  11394. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  11395. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  11396. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  11397. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Animations/animation */ "./Animations/animation.ts");
  11398. /* harmony import */ var _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Animations/animationRange */ "./Animations/animationRange.ts");
  11399. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  11400. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  11401. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  11402. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  11403. /**
  11404. * Class used to handle skinning animations
  11405. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  11406. */
  11407. var Skeleton = /** @class */ (function () {
  11408. /**
  11409. * Creates a new skeleton
  11410. * @param name defines the skeleton name
  11411. * @param id defines the skeleton Id
  11412. * @param scene defines the hosting scene
  11413. */
  11414. function Skeleton(
  11415. /** defines the skeleton name */
  11416. name,
  11417. /** defines the skeleton Id */
  11418. id, scene) {
  11419. this.name = name;
  11420. this.id = id;
  11421. /**
  11422. * Defines the list of child bones
  11423. */
  11424. this.bones = new Array();
  11425. /**
  11426. * Defines a boolean indicating if the root matrix is provided by meshes or by the current skeleton (this is the default value)
  11427. */
  11428. this.needInitialSkinMatrix = false;
  11429. /**
  11430. * Defines a mesh that override the matrix used to get the world matrix (null by default).
  11431. */
  11432. this.overrideMesh = null;
  11433. this._isDirty = true;
  11434. this._meshesWithPoseMatrix = new Array();
  11435. this._identity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  11436. this._ranges = {};
  11437. this._lastAbsoluteTransformsUpdateId = -1;
  11438. this._canUseTextureForBones = false;
  11439. /** @hidden */
  11440. this._numBonesWithLinkedTransformNode = 0;
  11441. /**
  11442. * Specifies if the skeleton should be serialized
  11443. */
  11444. this.doNotSerialize = false;
  11445. /**
  11446. * Gets or sets a boolean indicating that bone matrices should be stored as a texture instead of using shader uniforms (default is true).
  11447. * Please note that this option is not available when needInitialSkinMatrix === true or if the hardware does not support it
  11448. */
  11449. this.useTextureToStoreBoneMatrices = true;
  11450. this._animationPropertiesOverride = null;
  11451. // Events
  11452. /**
  11453. * An observable triggered before computing the skeleton's matrices
  11454. */
  11455. this.onBeforeComputeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  11456. this.bones = [];
  11457. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  11458. this._scene.skeletons.push(this);
  11459. //make sure it will recalculate the matrix next time prepare is called.
  11460. this._isDirty = true;
  11461. var engineCaps = this._scene.getEngine().getCaps();
  11462. this._canUseTextureForBones = engineCaps.textureFloat && engineCaps.maxVertexTextureImageUnits > 0;
  11463. }
  11464. Object.defineProperty(Skeleton.prototype, "animationPropertiesOverride", {
  11465. /**
  11466. * Gets or sets the animation properties override
  11467. */
  11468. get: function () {
  11469. if (!this._animationPropertiesOverride) {
  11470. return this._scene.animationPropertiesOverride;
  11471. }
  11472. return this._animationPropertiesOverride;
  11473. },
  11474. set: function (value) {
  11475. this._animationPropertiesOverride = value;
  11476. },
  11477. enumerable: true,
  11478. configurable: true
  11479. });
  11480. Object.defineProperty(Skeleton.prototype, "isUsingTextureForMatrices", {
  11481. /**
  11482. * Gets a boolean indicating that the skeleton effectively stores matrices into a texture
  11483. */
  11484. get: function () {
  11485. return this.useTextureToStoreBoneMatrices && this._canUseTextureForBones && !this.needInitialSkinMatrix;
  11486. },
  11487. enumerable: true,
  11488. configurable: true
  11489. });
  11490. // Members
  11491. /**
  11492. * Gets the list of transform matrices to send to shaders (one matrix per bone)
  11493. * @param mesh defines the mesh to use to get the root matrix (if needInitialSkinMatrix === true)
  11494. * @returns a Float32Array containing matrices data
  11495. */
  11496. Skeleton.prototype.getTransformMatrices = function (mesh) {
  11497. if (this.needInitialSkinMatrix && mesh._bonesTransformMatrices) {
  11498. return mesh._bonesTransformMatrices;
  11499. }
  11500. if (!this._transformMatrices) {
  11501. this.prepare();
  11502. }
  11503. return this._transformMatrices;
  11504. };
  11505. /**
  11506. * Gets the list of transform matrices to send to shaders inside a texture (one matrix per bone)
  11507. * @returns a raw texture containing the data
  11508. */
  11509. Skeleton.prototype.getTransformMatrixTexture = function () {
  11510. return this._transformMatrixTexture;
  11511. };
  11512. /**
  11513. * Gets the current hosting scene
  11514. * @returns a scene object
  11515. */
  11516. Skeleton.prototype.getScene = function () {
  11517. return this._scene;
  11518. };
  11519. // Methods
  11520. /**
  11521. * Gets a string representing the current skeleton data
  11522. * @param fullDetails defines a boolean indicating if we want a verbose version
  11523. * @returns a string representing the current skeleton data
  11524. */
  11525. Skeleton.prototype.toString = function (fullDetails) {
  11526. var ret = "Name: " + this.name + ", nBones: " + this.bones.length;
  11527. ret += ", nAnimationRanges: " + (this._ranges ? Object.keys(this._ranges).length : "none");
  11528. if (fullDetails) {
  11529. ret += ", Ranges: {";
  11530. var first = true;
  11531. for (var name_1 in this._ranges) {
  11532. if (first) {
  11533. ret += ", ";
  11534. first = false;
  11535. }
  11536. ret += name_1;
  11537. }
  11538. ret += "}";
  11539. }
  11540. return ret;
  11541. };
  11542. /**
  11543. * Get bone's index searching by name
  11544. * @param name defines bone's name to search for
  11545. * @return the indice of the bone. Returns -1 if not found
  11546. */
  11547. Skeleton.prototype.getBoneIndexByName = function (name) {
  11548. for (var boneIndex = 0, cache = this.bones.length; boneIndex < cache; boneIndex++) {
  11549. if (this.bones[boneIndex].name === name) {
  11550. return boneIndex;
  11551. }
  11552. }
  11553. return -1;
  11554. };
  11555. /**
  11556. * Creater a new animation range
  11557. * @param name defines the name of the range
  11558. * @param from defines the start key
  11559. * @param to defines the end key
  11560. */
  11561. Skeleton.prototype.createAnimationRange = function (name, from, to) {
  11562. // check name not already in use
  11563. if (!this._ranges[name]) {
  11564. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, from, to);
  11565. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11566. if (this.bones[i].animations[0]) {
  11567. this.bones[i].animations[0].createRange(name, from, to);
  11568. }
  11569. }
  11570. }
  11571. };
  11572. /**
  11573. * Delete a specific animation range
  11574. * @param name defines the name of the range
  11575. * @param deleteFrames defines if frames must be removed as well
  11576. */
  11577. Skeleton.prototype.deleteAnimationRange = function (name, deleteFrames) {
  11578. if (deleteFrames === void 0) { deleteFrames = true; }
  11579. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11580. if (this.bones[i].animations[0]) {
  11581. this.bones[i].animations[0].deleteRange(name, deleteFrames);
  11582. }
  11583. }
  11584. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  11585. };
  11586. /**
  11587. * Gets a specific animation range
  11588. * @param name defines the name of the range to look for
  11589. * @returns the requested animation range or null if not found
  11590. */
  11591. Skeleton.prototype.getAnimationRange = function (name) {
  11592. return this._ranges[name];
  11593. };
  11594. /**
  11595. * Gets the list of all animation ranges defined on this skeleton
  11596. * @returns an array
  11597. */
  11598. Skeleton.prototype.getAnimationRanges = function () {
  11599. var animationRanges = [];
  11600. var name;
  11601. var i = 0;
  11602. for (name in this._ranges) {
  11603. animationRanges[i] = this._ranges[name];
  11604. i++;
  11605. }
  11606. return animationRanges;
  11607. };
  11608. /**
  11609. * Copy animation range from a source skeleton.
  11610. * This is not for a complete retargeting, only between very similar skeleton's with only possible bone length differences
  11611. * @param source defines the source skeleton
  11612. * @param name defines the name of the range to copy
  11613. * @param rescaleAsRequired defines if rescaling must be applied if required
  11614. * @returns true if operation was successful
  11615. */
  11616. Skeleton.prototype.copyAnimationRange = function (source, name, rescaleAsRequired) {
  11617. if (rescaleAsRequired === void 0) { rescaleAsRequired = false; }
  11618. if (this._ranges[name] || !source.getAnimationRange(name)) {
  11619. return false;
  11620. }
  11621. var ret = true;
  11622. var frameOffset = this._getHighestAnimationFrame() + 1;
  11623. // make a dictionary of source skeleton's bones, so exact same order or doublely nested loop is not required
  11624. var boneDict = {};
  11625. var sourceBones = source.bones;
  11626. var nBones;
  11627. var i;
  11628. for (i = 0, nBones = sourceBones.length; i < nBones; i++) {
  11629. boneDict[sourceBones[i].name] = sourceBones[i];
  11630. }
  11631. if (this.bones.length !== sourceBones.length) {
  11632. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: this rig has " + this.bones.length + " bones, while source as " + sourceBones.length);
  11633. ret = false;
  11634. }
  11635. var skelDimensionsRatio = (rescaleAsRequired && this.dimensionsAtRest && source.dimensionsAtRest) ? this.dimensionsAtRest.divide(source.dimensionsAtRest) : null;
  11636. for (i = 0, nBones = this.bones.length; i < nBones; i++) {
  11637. var boneName = this.bones[i].name;
  11638. var sourceBone = boneDict[boneName];
  11639. if (sourceBone) {
  11640. ret = ret && this.bones[i].copyAnimationRange(sourceBone, name, frameOffset, rescaleAsRequired, skelDimensionsRatio);
  11641. }
  11642. else {
  11643. _Misc_logger__WEBPACK_IMPORTED_MODULE_8__["Logger"].Warn("copyAnimationRange: not same rig, missing source bone " + boneName);
  11644. ret = false;
  11645. }
  11646. }
  11647. // do not call createAnimationRange(), since it also is done to bones, which was already done
  11648. var range = source.getAnimationRange(name);
  11649. if (range) {
  11650. this._ranges[name] = new _Animations_animationRange__WEBPACK_IMPORTED_MODULE_5__["AnimationRange"](name, range.from + frameOffset, range.to + frameOffset);
  11651. }
  11652. return ret;
  11653. };
  11654. /**
  11655. * Forces the skeleton to go to rest pose
  11656. */
  11657. Skeleton.prototype.returnToRest = function () {
  11658. for (var index = 0; index < this.bones.length; index++) {
  11659. this.bones[index].returnToRest();
  11660. }
  11661. };
  11662. Skeleton.prototype._getHighestAnimationFrame = function () {
  11663. var ret = 0;
  11664. for (var i = 0, nBones = this.bones.length; i < nBones; i++) {
  11665. if (this.bones[i].animations[0]) {
  11666. var highest = this.bones[i].animations[0].getHighestFrame();
  11667. if (ret < highest) {
  11668. ret = highest;
  11669. }
  11670. }
  11671. }
  11672. return ret;
  11673. };
  11674. /**
  11675. * Begin a specific animation range
  11676. * @param name defines the name of the range to start
  11677. * @param loop defines if looping must be turned on (false by default)
  11678. * @param speedRatio defines the speed ratio to apply (1 by default)
  11679. * @param onAnimationEnd defines a callback which will be called when animation will end
  11680. * @returns a new animatable
  11681. */
  11682. Skeleton.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  11683. var range = this.getAnimationRange(name);
  11684. if (!range) {
  11685. return null;
  11686. }
  11687. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  11688. };
  11689. /** @hidden */
  11690. Skeleton.prototype._markAsDirty = function () {
  11691. this._isDirty = true;
  11692. };
  11693. /** @hidden */
  11694. Skeleton.prototype._registerMeshWithPoseMatrix = function (mesh) {
  11695. this._meshesWithPoseMatrix.push(mesh);
  11696. };
  11697. /** @hidden */
  11698. Skeleton.prototype._unregisterMeshWithPoseMatrix = function (mesh) {
  11699. var index = this._meshesWithPoseMatrix.indexOf(mesh);
  11700. if (index > -1) {
  11701. this._meshesWithPoseMatrix.splice(index, 1);
  11702. }
  11703. };
  11704. Skeleton.prototype._computeTransformMatrices = function (targetMatrix, initialSkinMatrix) {
  11705. this.onBeforeComputeObservable.notifyObservers(this);
  11706. for (var index = 0; index < this.bones.length; index++) {
  11707. var bone = this.bones[index];
  11708. var parentBone = bone.getParent();
  11709. if (parentBone) {
  11710. bone.getLocalMatrix().multiplyToRef(parentBone.getWorldMatrix(), bone.getWorldMatrix());
  11711. }
  11712. else {
  11713. if (initialSkinMatrix) {
  11714. bone.getLocalMatrix().multiplyToRef(initialSkinMatrix, bone.getWorldMatrix());
  11715. }
  11716. else {
  11717. bone.getWorldMatrix().copyFrom(bone.getLocalMatrix());
  11718. }
  11719. }
  11720. if (bone._index !== -1) {
  11721. var mappedIndex = bone._index === null ? index : bone._index;
  11722. bone.getInvertedAbsoluteTransform().multiplyToArray(bone.getWorldMatrix(), targetMatrix, mappedIndex * 16);
  11723. }
  11724. }
  11725. this._identity.copyToArray(targetMatrix, this.bones.length * 16);
  11726. };
  11727. /**
  11728. * Build all resources required to render a skeleton
  11729. */
  11730. Skeleton.prototype.prepare = function () {
  11731. // Update the local matrix of bones with linked transform nodes.
  11732. if (this._numBonesWithLinkedTransformNode > 0) {
  11733. for (var _i = 0, _a = this.bones; _i < _a.length; _i++) {
  11734. var bone_1 = _a[_i];
  11735. if (bone_1._linkedTransformNode) {
  11736. // Computing the world matrix also computes the local matrix.
  11737. bone_1._linkedTransformNode.computeWorldMatrix();
  11738. bone_1._matrix = bone_1._linkedTransformNode._localMatrix;
  11739. bone_1.markAsDirty();
  11740. }
  11741. }
  11742. }
  11743. if (!this._isDirty) {
  11744. return;
  11745. }
  11746. if (this.needInitialSkinMatrix) {
  11747. for (var index = 0; index < this._meshesWithPoseMatrix.length; index++) {
  11748. var mesh = this._meshesWithPoseMatrix[index];
  11749. var poseMatrix = mesh.getPoseMatrix();
  11750. if (!mesh._bonesTransformMatrices || mesh._bonesTransformMatrices.length !== 16 * (this.bones.length + 1)) {
  11751. mesh._bonesTransformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11752. }
  11753. if (this._synchronizedWithMesh !== mesh) {
  11754. this._synchronizedWithMesh = mesh;
  11755. // Prepare bones
  11756. for (var boneIndex = 0; boneIndex < this.bones.length; boneIndex++) {
  11757. var bone = this.bones[boneIndex];
  11758. if (!bone.getParent()) {
  11759. var matrix = bone.getBaseMatrix();
  11760. matrix.multiplyToRef(poseMatrix, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11761. bone._updateDifferenceMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Matrix[1]);
  11762. }
  11763. }
  11764. }
  11765. this._computeTransformMatrices(mesh._bonesTransformMatrices, poseMatrix);
  11766. }
  11767. }
  11768. else {
  11769. if (!this._transformMatrices || this._transformMatrices.length !== 16 * (this.bones.length + 1)) {
  11770. this._transformMatrices = new Float32Array(16 * (this.bones.length + 1));
  11771. if (this.isUsingTextureForMatrices) {
  11772. if (this._transformMatrixTexture) {
  11773. this._transformMatrixTexture.dispose();
  11774. }
  11775. 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);
  11776. }
  11777. }
  11778. this._computeTransformMatrices(this._transformMatrices, null);
  11779. if (this.isUsingTextureForMatrices && this._transformMatrixTexture) {
  11780. this._transformMatrixTexture.update(this._transformMatrices);
  11781. }
  11782. }
  11783. this._isDirty = false;
  11784. this._scene._activeBones.addCount(this.bones.length, false);
  11785. };
  11786. /**
  11787. * Gets the list of animatables currently running for this skeleton
  11788. * @returns an array of animatables
  11789. */
  11790. Skeleton.prototype.getAnimatables = function () {
  11791. if (!this._animatables || this._animatables.length !== this.bones.length) {
  11792. this._animatables = [];
  11793. for (var index = 0; index < this.bones.length; index++) {
  11794. this._animatables.push(this.bones[index]);
  11795. }
  11796. }
  11797. return this._animatables;
  11798. };
  11799. /**
  11800. * Clone the current skeleton
  11801. * @param name defines the name of the new skeleton
  11802. * @param id defines the id of the enw skeleton
  11803. * @returns the new skeleton
  11804. */
  11805. Skeleton.prototype.clone = function (name, id) {
  11806. var result = new Skeleton(name, id || name, this._scene);
  11807. result.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11808. for (var index = 0; index < this.bones.length; index++) {
  11809. var source = this.bones[index];
  11810. var parentBone = null;
  11811. var parent_1 = source.getParent();
  11812. if (parent_1) {
  11813. var parentIndex = this.bones.indexOf(parent_1);
  11814. parentBone = result.bones[parentIndex];
  11815. }
  11816. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](source.name, result, parentBone, source.getBaseMatrix().clone(), source.getRestPose().clone());
  11817. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source.animations, bone.animations);
  11818. }
  11819. if (this._ranges) {
  11820. result._ranges = {};
  11821. for (var rangeName in this._ranges) {
  11822. var range = this._ranges[rangeName];
  11823. if (range) {
  11824. result._ranges[rangeName] = range.clone();
  11825. }
  11826. }
  11827. }
  11828. this._isDirty = true;
  11829. return result;
  11830. };
  11831. /**
  11832. * Enable animation blending for this skeleton
  11833. * @param blendingSpeed defines the blending speed to apply
  11834. * @see http://doc.babylonjs.com/babylon101/animations#animation-blending
  11835. */
  11836. Skeleton.prototype.enableBlending = function (blendingSpeed) {
  11837. if (blendingSpeed === void 0) { blendingSpeed = 0.01; }
  11838. this.bones.forEach(function (bone) {
  11839. bone.animations.forEach(function (animation) {
  11840. animation.enableBlending = true;
  11841. animation.blendingSpeed = blendingSpeed;
  11842. });
  11843. });
  11844. };
  11845. /**
  11846. * Releases all resources associated with the current skeleton
  11847. */
  11848. Skeleton.prototype.dispose = function () {
  11849. this._meshesWithPoseMatrix = [];
  11850. // Animations
  11851. this.getScene().stopAnimation(this);
  11852. // Remove from scene
  11853. this.getScene().removeSkeleton(this);
  11854. if (this._transformMatrixTexture) {
  11855. this._transformMatrixTexture.dispose();
  11856. this._transformMatrixTexture = null;
  11857. }
  11858. };
  11859. /**
  11860. * Serialize the skeleton in a JSON object
  11861. * @returns a JSON object
  11862. */
  11863. Skeleton.prototype.serialize = function () {
  11864. var serializationObject = {};
  11865. serializationObject.name = this.name;
  11866. serializationObject.id = this.id;
  11867. if (this.dimensionsAtRest) {
  11868. serializationObject.dimensionsAtRest = this.dimensionsAtRest.asArray();
  11869. }
  11870. serializationObject.bones = [];
  11871. serializationObject.needInitialSkinMatrix = this.needInitialSkinMatrix;
  11872. for (var index = 0; index < this.bones.length; index++) {
  11873. var bone = this.bones[index];
  11874. var parent_2 = bone.getParent();
  11875. var serializedBone = {
  11876. parentBoneIndex: parent_2 ? this.bones.indexOf(parent_2) : -1,
  11877. name: bone.name,
  11878. matrix: bone.getBaseMatrix().toArray(),
  11879. rest: bone.getRestPose().toArray()
  11880. };
  11881. serializationObject.bones.push(serializedBone);
  11882. if (bone.length) {
  11883. serializedBone.length = bone.length;
  11884. }
  11885. if (bone.metadata) {
  11886. serializedBone.metadata = bone.metadata;
  11887. }
  11888. if (bone.animations && bone.animations.length > 0) {
  11889. serializedBone.animation = bone.animations[0].serialize();
  11890. }
  11891. serializationObject.ranges = [];
  11892. for (var name in this._ranges) {
  11893. var source = this._ranges[name];
  11894. if (!source) {
  11895. continue;
  11896. }
  11897. var range = {};
  11898. range.name = name;
  11899. range.from = source.from;
  11900. range.to = source.to;
  11901. serializationObject.ranges.push(range);
  11902. }
  11903. }
  11904. return serializationObject;
  11905. };
  11906. /**
  11907. * Creates a new skeleton from serialized data
  11908. * @param parsedSkeleton defines the serialized data
  11909. * @param scene defines the hosting scene
  11910. * @returns a new skeleton
  11911. */
  11912. Skeleton.Parse = function (parsedSkeleton, scene) {
  11913. var skeleton = new Skeleton(parsedSkeleton.name, parsedSkeleton.id, scene);
  11914. if (parsedSkeleton.dimensionsAtRest) {
  11915. skeleton.dimensionsAtRest = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedSkeleton.dimensionsAtRest);
  11916. }
  11917. skeleton.needInitialSkinMatrix = parsedSkeleton.needInitialSkinMatrix;
  11918. var index;
  11919. for (index = 0; index < parsedSkeleton.bones.length; index++) {
  11920. var parsedBone = parsedSkeleton.bones[index];
  11921. var parentBone = null;
  11922. if (parsedBone.parentBoneIndex > -1) {
  11923. parentBone = skeleton.bones[parsedBone.parentBoneIndex];
  11924. }
  11925. var rest = parsedBone.rest ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.rest) : null;
  11926. var bone = new _bone__WEBPACK_IMPORTED_MODULE_0__["Bone"](parsedBone.name, skeleton, parentBone, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(parsedBone.matrix), rest);
  11927. if (parsedBone.id !== undefined && parsedBone.id !== null) {
  11928. bone.id = parsedBone.id;
  11929. }
  11930. if (parsedBone.length) {
  11931. bone.length = parsedBone.length;
  11932. }
  11933. if (parsedBone.metadata) {
  11934. bone.metadata = parsedBone.metadata;
  11935. }
  11936. if (parsedBone.animation) {
  11937. bone.animations.push(_Animations_animation__WEBPACK_IMPORTED_MODULE_4__["Animation"].Parse(parsedBone.animation));
  11938. }
  11939. }
  11940. // placed after bones, so createAnimationRange can cascade down
  11941. if (parsedSkeleton.ranges) {
  11942. for (index = 0; index < parsedSkeleton.ranges.length; index++) {
  11943. var data = parsedSkeleton.ranges[index];
  11944. skeleton.createAnimationRange(data.name, data.from, data.to);
  11945. }
  11946. }
  11947. return skeleton;
  11948. };
  11949. /**
  11950. * Compute all node absolute transforms
  11951. * @param forceUpdate defines if computation must be done even if cache is up to date
  11952. */
  11953. Skeleton.prototype.computeAbsoluteTransforms = function (forceUpdate) {
  11954. if (forceUpdate === void 0) { forceUpdate = false; }
  11955. var renderId = this._scene.getRenderId();
  11956. if (this._lastAbsoluteTransformsUpdateId != renderId || forceUpdate) {
  11957. this.bones[0].computeAbsoluteTransforms();
  11958. this._lastAbsoluteTransformsUpdateId = renderId;
  11959. }
  11960. };
  11961. /**
  11962. * Gets the root pose matrix
  11963. * @returns a matrix
  11964. */
  11965. Skeleton.prototype.getPoseMatrix = function () {
  11966. var poseMatrix = null;
  11967. if (this._meshesWithPoseMatrix.length > 0) {
  11968. poseMatrix = this._meshesWithPoseMatrix[0].getPoseMatrix();
  11969. }
  11970. return poseMatrix;
  11971. };
  11972. /**
  11973. * Sorts bones per internal index
  11974. */
  11975. Skeleton.prototype.sortBones = function () {
  11976. var bones = new Array();
  11977. var visited = new Array(this.bones.length);
  11978. for (var index = 0; index < this.bones.length; index++) {
  11979. this._sortBones(index, bones, visited);
  11980. }
  11981. this.bones = bones;
  11982. };
  11983. Skeleton.prototype._sortBones = function (index, bones, visited) {
  11984. if (visited[index]) {
  11985. return;
  11986. }
  11987. visited[index] = true;
  11988. var bone = this.bones[index];
  11989. if (bone._index === undefined) {
  11990. bone._index = index;
  11991. }
  11992. var parentBone = bone.getParent();
  11993. if (parentBone) {
  11994. this._sortBones(this.bones.indexOf(parentBone), bones, visited);
  11995. }
  11996. bones.push(bone);
  11997. };
  11998. return Skeleton;
  11999. }());
  12000. /***/ }),
  12001. /***/ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts":
  12002. /*!*******************************************************!*\
  12003. !*** ./Cameras/Inputs/arcRotateCameraGamepadInput.ts ***!
  12004. \*******************************************************/
  12005. /*! exports provided: ArcRotateCameraGamepadInput */
  12006. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12007. "use strict";
  12008. __webpack_require__.r(__webpack_exports__);
  12009. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return ArcRotateCameraGamepadInput; });
  12010. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12011. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12012. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12013. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  12014. /**
  12015. * Manage the gamepad inputs to control an arc rotate camera.
  12016. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12017. */
  12018. var ArcRotateCameraGamepadInput = /** @class */ (function () {
  12019. function ArcRotateCameraGamepadInput() {
  12020. /**
  12021. * Defines the gamepad rotation sensiblity.
  12022. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  12023. */
  12024. this.gamepadRotationSensibility = 80;
  12025. /**
  12026. * Defines the gamepad move sensiblity.
  12027. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  12028. */
  12029. this.gamepadMoveSensibility = 40;
  12030. }
  12031. /**
  12032. * Attach the input controls to a specific dom element to get the input from.
  12033. * @param element Defines the element the controls should be listened from
  12034. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12035. */
  12036. ArcRotateCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  12037. var _this = this;
  12038. var manager = this.camera.getScene().gamepadManager;
  12039. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  12040. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].POSE_ENABLED) {
  12041. // prioritize XBOX gamepads.
  12042. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX) {
  12043. _this.gamepad = gamepad;
  12044. }
  12045. }
  12046. });
  12047. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  12048. if (_this.gamepad === gamepad) {
  12049. _this.gamepad = null;
  12050. }
  12051. });
  12052. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_3__["Gamepad"].XBOX);
  12053. };
  12054. /**
  12055. * Detach the current controls from the specified dom element.
  12056. * @param element Defines the element to stop listening the inputs from
  12057. */
  12058. ArcRotateCameraGamepadInput.prototype.detachControl = function (element) {
  12059. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  12060. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  12061. this.gamepad = null;
  12062. };
  12063. /**
  12064. * Update the current camera state depending on the inputs that have been used this frame.
  12065. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12066. */
  12067. ArcRotateCameraGamepadInput.prototype.checkInputs = function () {
  12068. if (this.gamepad) {
  12069. var camera = this.camera;
  12070. var RSValues = this.gamepad.rightStick;
  12071. if (RSValues) {
  12072. if (RSValues.x != 0) {
  12073. var normalizedRX = RSValues.x / this.gamepadRotationSensibility;
  12074. if (normalizedRX != 0 && Math.abs(normalizedRX) > 0.005) {
  12075. camera.inertialAlphaOffset += normalizedRX;
  12076. }
  12077. }
  12078. if (RSValues.y != 0) {
  12079. var normalizedRY = RSValues.y / this.gamepadRotationSensibility;
  12080. if (normalizedRY != 0 && Math.abs(normalizedRY) > 0.005) {
  12081. camera.inertialBetaOffset += normalizedRY;
  12082. }
  12083. }
  12084. }
  12085. var LSValues = this.gamepad.leftStick;
  12086. if (LSValues && LSValues.y != 0) {
  12087. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  12088. if (normalizedLY != 0 && Math.abs(normalizedLY) > 0.005) {
  12089. this.camera.inertialRadiusOffset -= normalizedLY;
  12090. }
  12091. }
  12092. }
  12093. };
  12094. /**
  12095. * Gets the class name of the current intput.
  12096. * @returns the class name
  12097. */
  12098. ArcRotateCameraGamepadInput.prototype.getClassName = function () {
  12099. return "ArcRotateCameraGamepadInput";
  12100. };
  12101. /**
  12102. * Get the friendly name associated with the input class.
  12103. * @returns the input friendly name
  12104. */
  12105. ArcRotateCameraGamepadInput.prototype.getSimpleName = function () {
  12106. return "gamepad";
  12107. };
  12108. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12109. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12110. ], ArcRotateCameraGamepadInput.prototype, "gamepadRotationSensibility", void 0);
  12111. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12112. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12113. ], ArcRotateCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  12114. return ArcRotateCameraGamepadInput;
  12115. }());
  12116. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraGamepadInput"] = ArcRotateCameraGamepadInput;
  12117. /***/ }),
  12118. /***/ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts":
  12119. /*!************************************************************!*\
  12120. !*** ./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts ***!
  12121. \************************************************************/
  12122. /*! exports provided: ArcRotateCameraKeyboardMoveInput */
  12123. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12124. "use strict";
  12125. __webpack_require__.r(__webpack_exports__);
  12126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return ArcRotateCameraKeyboardMoveInput; });
  12127. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12128. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12129. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12130. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12131. /**
  12132. * Manage the keyboard inputs to control the movement of an arc rotate camera.
  12133. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12134. */
  12135. var ArcRotateCameraKeyboardMoveInput = /** @class */ (function () {
  12136. function ArcRotateCameraKeyboardMoveInput() {
  12137. /**
  12138. * Defines the list of key codes associated with the up action (increase alpha)
  12139. */
  12140. this.keysUp = [38];
  12141. /**
  12142. * Defines the list of key codes associated with the down action (decrease alpha)
  12143. */
  12144. this.keysDown = [40];
  12145. /**
  12146. * Defines the list of key codes associated with the left action (increase beta)
  12147. */
  12148. this.keysLeft = [37];
  12149. /**
  12150. * Defines the list of key codes associated with the right action (decrease beta)
  12151. */
  12152. this.keysRight = [39];
  12153. /**
  12154. * Defines the list of key codes associated with the reset action.
  12155. * Those keys reset the camera to its last stored state (with the method camera.storeState())
  12156. */
  12157. this.keysReset = [220];
  12158. /**
  12159. * Defines the panning sensibility of the inputs.
  12160. * (How fast is the camera paning)
  12161. */
  12162. this.panningSensibility = 50.0;
  12163. /**
  12164. * Defines the zooming sensibility of the inputs.
  12165. * (How fast is the camera zooming)
  12166. */
  12167. this.zoomingSensibility = 25.0;
  12168. /**
  12169. * Defines wether maintaining the alt key down switch the movement mode from
  12170. * orientation to zoom.
  12171. */
  12172. this.useAltToZoom = true;
  12173. /**
  12174. * Rotation speed of the camera
  12175. */
  12176. this.angularSpeed = 0.01;
  12177. this._keys = new Array();
  12178. }
  12179. /**
  12180. * Attach the input controls to a specific dom element to get the input from.
  12181. * @param element Defines the element the controls should be listened from
  12182. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12183. */
  12184. ArcRotateCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  12185. var _this = this;
  12186. if (this._onCanvasBlurObserver) {
  12187. return;
  12188. }
  12189. this._scene = this.camera.getScene();
  12190. this._engine = this._scene.getEngine();
  12191. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  12192. _this._keys = [];
  12193. });
  12194. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  12195. var evt = info.event;
  12196. if (!evt.metaKey) {
  12197. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  12198. _this._ctrlPressed = evt.ctrlKey;
  12199. _this._altPressed = evt.altKey;
  12200. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12201. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12202. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12203. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12204. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12205. var index = _this._keys.indexOf(evt.keyCode);
  12206. if (index === -1) {
  12207. _this._keys.push(evt.keyCode);
  12208. }
  12209. if (evt.preventDefault) {
  12210. if (!noPreventDefault) {
  12211. evt.preventDefault();
  12212. }
  12213. }
  12214. }
  12215. }
  12216. else {
  12217. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  12218. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  12219. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  12220. _this.keysRight.indexOf(evt.keyCode) !== -1 ||
  12221. _this.keysReset.indexOf(evt.keyCode) !== -1) {
  12222. var index = _this._keys.indexOf(evt.keyCode);
  12223. if (index >= 0) {
  12224. _this._keys.splice(index, 1);
  12225. }
  12226. if (evt.preventDefault) {
  12227. if (!noPreventDefault) {
  12228. evt.preventDefault();
  12229. }
  12230. }
  12231. }
  12232. }
  12233. }
  12234. });
  12235. };
  12236. /**
  12237. * Detach the current controls from the specified dom element.
  12238. * @param element Defines the element to stop listening the inputs from
  12239. */
  12240. ArcRotateCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  12241. if (this._scene) {
  12242. if (this._onKeyboardObserver) {
  12243. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  12244. }
  12245. if (this._onCanvasBlurObserver) {
  12246. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  12247. }
  12248. this._onKeyboardObserver = null;
  12249. this._onCanvasBlurObserver = null;
  12250. }
  12251. this._keys = [];
  12252. };
  12253. /**
  12254. * Update the current camera state depending on the inputs that have been used this frame.
  12255. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12256. */
  12257. ArcRotateCameraKeyboardMoveInput.prototype.checkInputs = function () {
  12258. if (this._onKeyboardObserver) {
  12259. var camera = this.camera;
  12260. for (var index = 0; index < this._keys.length; index++) {
  12261. var keyCode = this._keys[index];
  12262. if (this.keysLeft.indexOf(keyCode) !== -1) {
  12263. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12264. camera.inertialPanningX -= 1 / this.panningSensibility;
  12265. }
  12266. else {
  12267. camera.inertialAlphaOffset -= this.angularSpeed;
  12268. }
  12269. }
  12270. else if (this.keysUp.indexOf(keyCode) !== -1) {
  12271. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12272. camera.inertialPanningY += 1 / this.panningSensibility;
  12273. }
  12274. else if (this._altPressed && this.useAltToZoom) {
  12275. camera.inertialRadiusOffset += 1 / this.zoomingSensibility;
  12276. }
  12277. else {
  12278. camera.inertialBetaOffset -= this.angularSpeed;
  12279. }
  12280. }
  12281. else if (this.keysRight.indexOf(keyCode) !== -1) {
  12282. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12283. camera.inertialPanningX += 1 / this.panningSensibility;
  12284. }
  12285. else {
  12286. camera.inertialAlphaOffset += this.angularSpeed;
  12287. }
  12288. }
  12289. else if (this.keysDown.indexOf(keyCode) !== -1) {
  12290. if (this._ctrlPressed && this.camera._useCtrlForPanning) {
  12291. camera.inertialPanningY -= 1 / this.panningSensibility;
  12292. }
  12293. else if (this._altPressed && this.useAltToZoom) {
  12294. camera.inertialRadiusOffset -= 1 / this.zoomingSensibility;
  12295. }
  12296. else {
  12297. camera.inertialBetaOffset += this.angularSpeed;
  12298. }
  12299. }
  12300. else if (this.keysReset.indexOf(keyCode) !== -1) {
  12301. if (camera.useInputToRestoreState) {
  12302. camera.restoreState();
  12303. }
  12304. }
  12305. }
  12306. }
  12307. };
  12308. /**
  12309. * Gets the class name of the current intput.
  12310. * @returns the class name
  12311. */
  12312. ArcRotateCameraKeyboardMoveInput.prototype.getClassName = function () {
  12313. return "ArcRotateCameraKeyboardMoveInput";
  12314. };
  12315. /**
  12316. * Get the friendly name associated with the input class.
  12317. * @returns the input friendly name
  12318. */
  12319. ArcRotateCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  12320. return "keyboard";
  12321. };
  12322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12324. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  12325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12327. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  12328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12330. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  12331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12333. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  12334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12336. ], ArcRotateCameraKeyboardMoveInput.prototype, "keysReset", void 0);
  12337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12339. ], ArcRotateCameraKeyboardMoveInput.prototype, "panningSensibility", void 0);
  12340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12342. ], ArcRotateCameraKeyboardMoveInput.prototype, "zoomingSensibility", void 0);
  12343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12345. ], ArcRotateCameraKeyboardMoveInput.prototype, "useAltToZoom", void 0);
  12346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12348. ], ArcRotateCameraKeyboardMoveInput.prototype, "angularSpeed", void 0);
  12349. return ArcRotateCameraKeyboardMoveInput;
  12350. }());
  12351. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraKeyboardMoveInput"] = ArcRotateCameraKeyboardMoveInput;
  12352. /***/ }),
  12353. /***/ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts":
  12354. /*!**********************************************************!*\
  12355. !*** ./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts ***!
  12356. \**********************************************************/
  12357. /*! exports provided: ArcRotateCameraMouseWheelInput */
  12358. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12359. "use strict";
  12360. __webpack_require__.r(__webpack_exports__);
  12361. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return ArcRotateCameraMouseWheelInput; });
  12362. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12363. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12364. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12365. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12366. /**
  12367. * Manage the mouse wheel inputs to control an arc rotate camera.
  12368. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12369. */
  12370. var ArcRotateCameraMouseWheelInput = /** @class */ (function () {
  12371. function ArcRotateCameraMouseWheelInput() {
  12372. /**
  12373. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  12374. */
  12375. this.wheelPrecision = 3.0;
  12376. /**
  12377. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  12378. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  12379. */
  12380. this.wheelDeltaPercentage = 0;
  12381. }
  12382. /**
  12383. * Attach the input controls to a specific dom element to get the input from.
  12384. * @param element Defines the element the controls should be listened from
  12385. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12386. */
  12387. ArcRotateCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  12388. var _this = this;
  12389. this._wheel = function (p, s) {
  12390. //sanity check - this should be a PointerWheel event.
  12391. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  12392. return;
  12393. }
  12394. var event = p.event;
  12395. var delta = 0;
  12396. var mouseWheelLegacyEvent = event;
  12397. if (mouseWheelLegacyEvent.wheelDelta) {
  12398. if (_this.wheelDeltaPercentage) {
  12399. var wheelDelta = (mouseWheelLegacyEvent.wheelDelta * 0.01 * _this.wheelDeltaPercentage) * _this.camera.radius;
  12400. if (mouseWheelLegacyEvent.wheelDelta > 0) {
  12401. delta = wheelDelta / (1.0 + _this.wheelDeltaPercentage);
  12402. }
  12403. else {
  12404. delta = wheelDelta * (1.0 + _this.wheelDeltaPercentage);
  12405. }
  12406. }
  12407. else {
  12408. delta = mouseWheelLegacyEvent.wheelDelta / (_this.wheelPrecision * 40);
  12409. }
  12410. }
  12411. else {
  12412. var deltaValue = event.deltaY || event.detail;
  12413. delta = -deltaValue / _this.wheelPrecision;
  12414. }
  12415. if (delta) {
  12416. _this.camera.inertialRadiusOffset += delta;
  12417. }
  12418. if (event.preventDefault) {
  12419. if (!noPreventDefault) {
  12420. event.preventDefault();
  12421. }
  12422. }
  12423. };
  12424. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  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. ArcRotateCameraMouseWheelInput.prototype.detachControl = function (element) {
  12431. if (this._observer && element) {
  12432. this.camera.getScene().onPointerObservable.remove(this._observer);
  12433. this._observer = null;
  12434. this._wheel = null;
  12435. }
  12436. };
  12437. /**
  12438. * Gets the class name of the current intput.
  12439. * @returns the class name
  12440. */
  12441. ArcRotateCameraMouseWheelInput.prototype.getClassName = function () {
  12442. return "ArcRotateCameraMouseWheelInput";
  12443. };
  12444. /**
  12445. * Get the friendly name associated with the input class.
  12446. * @returns the input friendly name
  12447. */
  12448. ArcRotateCameraMouseWheelInput.prototype.getSimpleName = function () {
  12449. return "mousewheel";
  12450. };
  12451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12453. ], ArcRotateCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  12454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12456. ], ArcRotateCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  12457. return ArcRotateCameraMouseWheelInput;
  12458. }());
  12459. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["ArcRotateCameraMouseWheelInput"] = ArcRotateCameraMouseWheelInput;
  12460. /***/ }),
  12461. /***/ "./Cameras/Inputs/arcRotateCameraPointersInput.ts":
  12462. /*!********************************************************!*\
  12463. !*** ./Cameras/Inputs/arcRotateCameraPointersInput.ts ***!
  12464. \********************************************************/
  12465. /*! exports provided: ArcRotateCameraPointersInput */
  12466. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12467. "use strict";
  12468. __webpack_require__.r(__webpack_exports__);
  12469. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return ArcRotateCameraPointersInput; });
  12470. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12471. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12472. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  12473. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12474. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  12475. /**
  12476. * Manage the pointers inputs to control an arc rotate camera.
  12477. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12478. */
  12479. var ArcRotateCameraPointersInput = /** @class */ (function () {
  12480. function ArcRotateCameraPointersInput() {
  12481. /**
  12482. * Defines the buttons associated with the input to handle camera move.
  12483. */
  12484. this.buttons = [0, 1, 2];
  12485. /**
  12486. * Defines the pointer angular sensibility along the X axis or how fast is the camera rotating.
  12487. */
  12488. this.angularSensibilityX = 1000.0;
  12489. /**
  12490. * Defines the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  12491. */
  12492. this.angularSensibilityY = 1000.0;
  12493. /**
  12494. * Defines the pointer pinch precision or how fast is the camera zooming.
  12495. */
  12496. this.pinchPrecision = 12.0;
  12497. /**
  12498. * pinchDeltaPercentage will be used instead of pinchPrecision if different from 0.
  12499. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  12500. */
  12501. this.pinchDeltaPercentage = 0;
  12502. /**
  12503. * Defines the pointer panning sensibility or how fast is the camera moving.
  12504. */
  12505. this.panningSensibility = 1000.0;
  12506. /**
  12507. * Defines whether panning (2 fingers swipe) is enabled through multitouch.
  12508. */
  12509. this.multiTouchPanning = true;
  12510. /**
  12511. * Defines whether panning is enabled for both pan (2 fingers swipe) and zoom (pinch) through multitouch.
  12512. */
  12513. this.multiTouchPanAndZoom = true;
  12514. /**
  12515. * Revers pinch action direction.
  12516. */
  12517. this.pinchInwards = true;
  12518. this._isPanClick = false;
  12519. }
  12520. /**
  12521. * Attach the input controls to a specific dom element to get the input from.
  12522. * @param element Defines the element the controls should be listened from
  12523. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12524. */
  12525. ArcRotateCameraPointersInput.prototype.attachControl = function (element, noPreventDefault) {
  12526. var _this = this;
  12527. var engine = this.camera.getEngine();
  12528. var cacheSoloPointer; // cache pointer object for better perf on camera rotation
  12529. var pointA = null;
  12530. var pointB = null;
  12531. var previousPinchSquaredDistance = 0;
  12532. var initialDistance = 0;
  12533. var twoFingerActivityCount = 0;
  12534. var previousMultiTouchPanPosition = { x: 0, y: 0, isPaning: false, isPinching: false };
  12535. this._pointerInput = function (p, s) {
  12536. var evt = p.event;
  12537. var isTouch = p.event.pointerType === "touch";
  12538. if (engine.isInVRExclusivePointerMode) {
  12539. return;
  12540. }
  12541. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  12542. return;
  12543. }
  12544. var srcElement = (evt.srcElement || evt.target);
  12545. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN && srcElement) {
  12546. try {
  12547. srcElement.setPointerCapture(evt.pointerId);
  12548. }
  12549. catch (e) {
  12550. //Nothing to do with the error. Execution will continue.
  12551. }
  12552. // Manage panning with pan button click
  12553. _this._isPanClick = evt.button === _this.camera._panningMouseButton;
  12554. // manage pointers
  12555. cacheSoloPointer = { x: evt.clientX, y: evt.clientY, pointerId: evt.pointerId, type: evt.pointerType };
  12556. if (pointA === null) {
  12557. pointA = cacheSoloPointer;
  12558. }
  12559. else if (pointB === null) {
  12560. pointB = cacheSoloPointer;
  12561. }
  12562. if (!noPreventDefault) {
  12563. evt.preventDefault();
  12564. element.focus();
  12565. }
  12566. }
  12567. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP) {
  12568. if (_this.camera.useInputToRestoreState) {
  12569. _this.camera.restoreState();
  12570. }
  12571. }
  12572. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP && srcElement) {
  12573. try {
  12574. srcElement.releasePointerCapture(evt.pointerId);
  12575. }
  12576. catch (e) {
  12577. //Nothing to do with the error.
  12578. }
  12579. cacheSoloPointer = null;
  12580. previousPinchSquaredDistance = 0;
  12581. previousMultiTouchPanPosition.isPaning = false;
  12582. previousMultiTouchPanPosition.isPinching = false;
  12583. twoFingerActivityCount = 0;
  12584. initialDistance = 0;
  12585. if (!isTouch) {
  12586. pointB = null; // Mouse and pen are mono pointer
  12587. }
  12588. //would be better to use pointers.remove(evt.pointerId) for multitouch gestures,
  12589. //but emptying completly pointers collection is required to fix a bug on iPhone :
  12590. //when changing orientation while pinching camera, one pointer stay pressed forever if we don't release all pointers
  12591. //will be ok to put back pointers.remove(evt.pointerId); when iPhone bug corrected
  12592. if (engine._badOS) {
  12593. pointA = pointB = null;
  12594. }
  12595. else {
  12596. //only remove the impacted pointer in case of multitouch allowing on most
  12597. //platforms switching from rotate to zoom and pan seamlessly.
  12598. if (pointB && pointA && pointA.pointerId == evt.pointerId) {
  12599. pointA = pointB;
  12600. pointB = null;
  12601. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12602. }
  12603. else if (pointA && pointB && pointB.pointerId == evt.pointerId) {
  12604. pointB = null;
  12605. cacheSoloPointer = { x: pointA.x, y: pointA.y, pointerId: pointA.pointerId, type: evt.pointerType };
  12606. }
  12607. else {
  12608. pointA = pointB = null;
  12609. }
  12610. }
  12611. if (!noPreventDefault) {
  12612. evt.preventDefault();
  12613. }
  12614. }
  12615. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE) {
  12616. if (!noPreventDefault) {
  12617. evt.preventDefault();
  12618. }
  12619. // One button down
  12620. if (pointA && pointB === null && cacheSoloPointer) {
  12621. if (_this.panningSensibility !== 0 &&
  12622. ((evt.ctrlKey && _this.camera._useCtrlForPanning) || _this._isPanClick)) {
  12623. _this.camera.inertialPanningX += -(evt.clientX - cacheSoloPointer.x) / _this.panningSensibility;
  12624. _this.camera.inertialPanningY += (evt.clientY - cacheSoloPointer.y) / _this.panningSensibility;
  12625. }
  12626. else {
  12627. var offsetX = evt.clientX - cacheSoloPointer.x;
  12628. var offsetY = evt.clientY - cacheSoloPointer.y;
  12629. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12630. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12631. }
  12632. cacheSoloPointer.x = evt.clientX;
  12633. cacheSoloPointer.y = evt.clientY;
  12634. }
  12635. // Two buttons down: pinch/pan
  12636. else if (pointA && pointB) {
  12637. //if (noPreventDefault) { evt.preventDefault(); } //if pinch gesture, could be useful to force preventDefault to avoid html page scroll/zoom in some mobile browsers
  12638. var ed = (pointA.pointerId === evt.pointerId) ? pointA : pointB;
  12639. ed.x = evt.clientX;
  12640. ed.y = evt.clientY;
  12641. var direction = _this.pinchInwards ? 1 : -1;
  12642. var distX = pointA.x - pointB.x;
  12643. var distY = pointA.y - pointB.y;
  12644. var pinchSquaredDistance = (distX * distX) + (distY * distY);
  12645. var pinchDistance = Math.sqrt(pinchSquaredDistance);
  12646. if (previousPinchSquaredDistance === 0) {
  12647. initialDistance = pinchDistance;
  12648. previousPinchSquaredDistance = pinchSquaredDistance;
  12649. previousMultiTouchPanPosition.x = (pointA.x + pointB.x) / 2;
  12650. previousMultiTouchPanPosition.y = (pointA.y + pointB.y) / 2;
  12651. return;
  12652. }
  12653. if (_this.multiTouchPanAndZoom) {
  12654. if (_this.pinchDeltaPercentage) {
  12655. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12656. }
  12657. else {
  12658. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12659. (_this.pinchPrecision *
  12660. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12661. direction);
  12662. }
  12663. if (_this.panningSensibility !== 0) {
  12664. var pointersCenterX = (pointA.x + pointB.x) / 2;
  12665. var pointersCenterY = (pointA.y + pointB.y) / 2;
  12666. var pointersCenterDistX = pointersCenterX - previousMultiTouchPanPosition.x;
  12667. var pointersCenterDistY = pointersCenterY - previousMultiTouchPanPosition.y;
  12668. previousMultiTouchPanPosition.x = pointersCenterX;
  12669. previousMultiTouchPanPosition.y = pointersCenterY;
  12670. _this.camera.inertialPanningX += -(pointersCenterDistX) / (_this.panningSensibility);
  12671. _this.camera.inertialPanningY += (pointersCenterDistY) / (_this.panningSensibility);
  12672. }
  12673. }
  12674. else {
  12675. twoFingerActivityCount++;
  12676. if (previousMultiTouchPanPosition.isPinching || (twoFingerActivityCount < 20 && Math.abs(pinchDistance - initialDistance) > _this.camera.pinchToPanMaxDistance)) {
  12677. if (_this.pinchDeltaPercentage) {
  12678. _this.camera.inertialRadiusOffset += ((pinchSquaredDistance - previousPinchSquaredDistance) * 0.001) * _this.camera.radius * _this.pinchDeltaPercentage;
  12679. }
  12680. else {
  12681. _this.camera.inertialRadiusOffset += (pinchSquaredDistance - previousPinchSquaredDistance) /
  12682. (_this.pinchPrecision *
  12683. ((_this.angularSensibilityX + _this.angularSensibilityY) / 2) *
  12684. direction);
  12685. }
  12686. previousMultiTouchPanPosition.isPaning = false;
  12687. previousMultiTouchPanPosition.isPinching = true;
  12688. }
  12689. else {
  12690. if (cacheSoloPointer && cacheSoloPointer.pointerId === ed.pointerId && _this.panningSensibility !== 0 && _this.multiTouchPanning) {
  12691. if (!previousMultiTouchPanPosition.isPaning) {
  12692. previousMultiTouchPanPosition.isPaning = true;
  12693. previousMultiTouchPanPosition.isPinching = false;
  12694. previousMultiTouchPanPosition.x = ed.x;
  12695. previousMultiTouchPanPosition.y = ed.y;
  12696. return;
  12697. }
  12698. _this.camera.inertialPanningX += -(ed.x - previousMultiTouchPanPosition.x) / (_this.panningSensibility);
  12699. _this.camera.inertialPanningY += (ed.y - previousMultiTouchPanPosition.y) / (_this.panningSensibility);
  12700. }
  12701. }
  12702. if (cacheSoloPointer && cacheSoloPointer.pointerId === evt.pointerId) {
  12703. previousMultiTouchPanPosition.x = ed.x;
  12704. previousMultiTouchPanPosition.y = ed.y;
  12705. }
  12706. }
  12707. previousPinchSquaredDistance = pinchSquaredDistance;
  12708. }
  12709. }
  12710. };
  12711. this._observer = this.camera.getScene().onPointerObservable.add(this._pointerInput, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERMOVE | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_4__["PointerEventTypes"].POINTERDOUBLETAP);
  12712. this._onContextMenu = function (evt) {
  12713. evt.preventDefault();
  12714. };
  12715. if (!this.camera._useCtrlForPanning) {
  12716. element.addEventListener("contextmenu", this._onContextMenu, false);
  12717. }
  12718. this._onLostFocus = function () {
  12719. //this._keys = [];
  12720. pointA = pointB = null;
  12721. previousPinchSquaredDistance = 0;
  12722. previousMultiTouchPanPosition.isPaning = false;
  12723. previousMultiTouchPanPosition.isPinching = false;
  12724. twoFingerActivityCount = 0;
  12725. cacheSoloPointer = null;
  12726. initialDistance = 0;
  12727. };
  12728. this._onMouseMove = function (evt) {
  12729. if (!engine.isPointerLock) {
  12730. return;
  12731. }
  12732. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  12733. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  12734. _this.camera.inertialAlphaOffset -= offsetX / _this.angularSensibilityX;
  12735. _this.camera.inertialBetaOffset -= offsetY / _this.angularSensibilityY;
  12736. if (!noPreventDefault) {
  12737. evt.preventDefault();
  12738. }
  12739. };
  12740. this._onGestureStart = function (e) {
  12741. if (window.MSGesture === undefined) {
  12742. return;
  12743. }
  12744. if (!_this._MSGestureHandler) {
  12745. _this._MSGestureHandler = new MSGesture();
  12746. _this._MSGestureHandler.target = element;
  12747. }
  12748. _this._MSGestureHandler.addPointer(e.pointerId);
  12749. };
  12750. this._onGesture = function (e) {
  12751. _this.camera.radius *= e.scale;
  12752. if (e.preventDefault) {
  12753. if (!noPreventDefault) {
  12754. e.stopPropagation();
  12755. e.preventDefault();
  12756. }
  12757. }
  12758. };
  12759. element.addEventListener("mousemove", this._onMouseMove, false);
  12760. element.addEventListener("MSPointerDown", this._onGestureStart, false);
  12761. element.addEventListener("MSGestureChange", this._onGesture, false);
  12762. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RegisterTopRootEvents([
  12763. { name: "blur", handler: this._onLostFocus }
  12764. ]);
  12765. };
  12766. /**
  12767. * Detach the current controls from the specified dom element.
  12768. * @param element Defines the element to stop listening the inputs from
  12769. */
  12770. ArcRotateCameraPointersInput.prototype.detachControl = function (element) {
  12771. if (this._onLostFocus) {
  12772. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].UnregisterTopRootEvents([
  12773. { name: "blur", handler: this._onLostFocus }
  12774. ]);
  12775. }
  12776. if (element && this._observer) {
  12777. this.camera.getScene().onPointerObservable.remove(this._observer);
  12778. this._observer = null;
  12779. if (this._onContextMenu) {
  12780. element.removeEventListener("contextmenu", this._onContextMenu);
  12781. }
  12782. if (this._onMouseMove) {
  12783. element.removeEventListener("mousemove", this._onMouseMove);
  12784. }
  12785. if (this._onGestureStart) {
  12786. element.removeEventListener("MSPointerDown", this._onGestureStart);
  12787. }
  12788. if (this._onGesture) {
  12789. element.removeEventListener("MSGestureChange", this._onGesture);
  12790. }
  12791. this._isPanClick = false;
  12792. this.pinchInwards = true;
  12793. this._onMouseMove = null;
  12794. this._onGestureStart = null;
  12795. this._onGesture = null;
  12796. this._MSGestureHandler = null;
  12797. this._onLostFocus = null;
  12798. this._onContextMenu = null;
  12799. }
  12800. };
  12801. /**
  12802. * Gets the class name of the current intput.
  12803. * @returns the class name
  12804. */
  12805. ArcRotateCameraPointersInput.prototype.getClassName = function () {
  12806. return "ArcRotateCameraPointersInput";
  12807. };
  12808. /**
  12809. * Get the friendly name associated with the input class.
  12810. * @returns the input friendly name
  12811. */
  12812. ArcRotateCameraPointersInput.prototype.getSimpleName = function () {
  12813. return "pointers";
  12814. };
  12815. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12816. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12817. ], ArcRotateCameraPointersInput.prototype, "buttons", void 0);
  12818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12820. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityX", void 0);
  12821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12823. ], ArcRotateCameraPointersInput.prototype, "angularSensibilityY", void 0);
  12824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12826. ], ArcRotateCameraPointersInput.prototype, "pinchPrecision", void 0);
  12827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12829. ], ArcRotateCameraPointersInput.prototype, "pinchDeltaPercentage", void 0);
  12830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12832. ], ArcRotateCameraPointersInput.prototype, "panningSensibility", void 0);
  12833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12835. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanning", void 0);
  12836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  12837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  12838. ], ArcRotateCameraPointersInput.prototype, "multiTouchPanAndZoom", void 0);
  12839. return ArcRotateCameraPointersInput;
  12840. }());
  12841. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["CameraInputTypes"]["ArcRotateCameraPointersInput"] = ArcRotateCameraPointersInput;
  12842. /***/ }),
  12843. /***/ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts":
  12844. /*!*******************************************************************!*\
  12845. !*** ./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts ***!
  12846. \*******************************************************************/
  12847. /*! exports provided: ArcRotateCameraVRDeviceOrientationInput */
  12848. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12849. "use strict";
  12850. __webpack_require__.r(__webpack_exports__);
  12851. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return ArcRotateCameraVRDeviceOrientationInput; });
  12852. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12853. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  12854. /**
  12855. * Add orientation input support to the input manager.
  12856. * @returns the current input manager
  12857. */
  12858. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraInputsManager"].prototype.addVRDeviceOrientation = function () {
  12859. this.add(new ArcRotateCameraVRDeviceOrientationInput());
  12860. return this;
  12861. };
  12862. /**
  12863. * Manage the device orientation inputs (gyroscope) to control an arc rotate camera.
  12864. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12865. */
  12866. var ArcRotateCameraVRDeviceOrientationInput = /** @class */ (function () {
  12867. /**
  12868. * Instantiate a new ArcRotateCameraVRDeviceOrientationInput.
  12869. */
  12870. function ArcRotateCameraVRDeviceOrientationInput() {
  12871. /**
  12872. * Defines a correction factor applied on the alpha value retrieved from the orientation events.
  12873. */
  12874. this.alphaCorrection = 1;
  12875. /**
  12876. * Defines a correction factor applied on the gamma value retrieved from the orientation events.
  12877. */
  12878. this.gammaCorrection = 1;
  12879. this._alpha = 0;
  12880. this._gamma = 0;
  12881. this._dirty = false;
  12882. this._deviceOrientationHandler = this._onOrientationEvent.bind(this);
  12883. }
  12884. /**
  12885. * Attach the input controls to a specific dom element to get the input from.
  12886. * @param element Defines the element the controls should be listened from
  12887. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12888. */
  12889. ArcRotateCameraVRDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  12890. this.camera.attachControl(element, noPreventDefault);
  12891. window.addEventListener("deviceorientation", this._deviceOrientationHandler);
  12892. };
  12893. /** @hidden */
  12894. ArcRotateCameraVRDeviceOrientationInput.prototype._onOrientationEvent = function (evt) {
  12895. if (evt.alpha !== null) {
  12896. this._alpha = (+evt.alpha | 0) * this.alphaCorrection;
  12897. }
  12898. if (evt.gamma !== null) {
  12899. this._gamma = (+evt.gamma | 0) * this.gammaCorrection;
  12900. }
  12901. this._dirty = true;
  12902. };
  12903. /**
  12904. * Update the current camera state depending on the inputs that have been used this frame.
  12905. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  12906. */
  12907. ArcRotateCameraVRDeviceOrientationInput.prototype.checkInputs = function () {
  12908. if (this._dirty) {
  12909. this._dirty = false;
  12910. if (this._gamma < 0) {
  12911. this._gamma = 180 + this._gamma;
  12912. }
  12913. this.camera.alpha = (-this._alpha / 180.0 * Math.PI) % Math.PI * 2;
  12914. this.camera.beta = (this._gamma / 180.0 * Math.PI);
  12915. }
  12916. };
  12917. /**
  12918. * Detach the current controls from the specified dom element.
  12919. * @param element Defines the element to stop listening the inputs from
  12920. */
  12921. ArcRotateCameraVRDeviceOrientationInput.prototype.detachControl = function (element) {
  12922. window.removeEventListener("deviceorientation", this._deviceOrientationHandler);
  12923. };
  12924. /**
  12925. * Gets the class name of the current intput.
  12926. * @returns the class name
  12927. */
  12928. ArcRotateCameraVRDeviceOrientationInput.prototype.getClassName = function () {
  12929. return "ArcRotateCameraVRDeviceOrientationInput";
  12930. };
  12931. /**
  12932. * Get the friendly name associated with the input class.
  12933. * @returns the input friendly name
  12934. */
  12935. ArcRotateCameraVRDeviceOrientationInput.prototype.getSimpleName = function () {
  12936. return "VRDeviceOrientation";
  12937. };
  12938. return ArcRotateCameraVRDeviceOrientationInput;
  12939. }());
  12940. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["ArcRotateCameraVRDeviceOrientationInput"] = ArcRotateCameraVRDeviceOrientationInput;
  12941. /***/ }),
  12942. /***/ "./Cameras/Inputs/flyCameraKeyboardInput.ts":
  12943. /*!**************************************************!*\
  12944. !*** ./Cameras/Inputs/flyCameraKeyboardInput.ts ***!
  12945. \**************************************************/
  12946. /*! exports provided: FlyCameraKeyboardInput */
  12947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  12948. "use strict";
  12949. __webpack_require__.r(__webpack_exports__);
  12950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return FlyCameraKeyboardInput; });
  12951. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  12952. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  12953. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  12954. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  12955. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  12956. /**
  12957. * Listen to keyboard events to control the camera.
  12958. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  12959. */
  12960. var FlyCameraKeyboardInput = /** @class */ (function () {
  12961. function FlyCameraKeyboardInput() {
  12962. /**
  12963. * The list of keyboard keys used to control the forward move of the camera.
  12964. */
  12965. this.keysForward = [87];
  12966. /**
  12967. * The list of keyboard keys used to control the backward move of the camera.
  12968. */
  12969. this.keysBackward = [83];
  12970. /**
  12971. * The list of keyboard keys used to control the forward move of the camera.
  12972. */
  12973. this.keysUp = [69];
  12974. /**
  12975. * The list of keyboard keys used to control the backward move of the camera.
  12976. */
  12977. this.keysDown = [81];
  12978. /**
  12979. * The list of keyboard keys used to control the right strafe move of the camera.
  12980. */
  12981. this.keysRight = [68];
  12982. /**
  12983. * The list of keyboard keys used to control the left strafe move of the camera.
  12984. */
  12985. this.keysLeft = [65];
  12986. this._keys = new Array();
  12987. }
  12988. /**
  12989. * Attach the input controls to a specific dom element to get the input from.
  12990. * @param element Defines the element the controls should be listened from
  12991. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  12992. */
  12993. FlyCameraKeyboardInput.prototype.attachControl = function (element, noPreventDefault) {
  12994. var _this = this;
  12995. if (this._onCanvasBlurObserver) {
  12996. return;
  12997. }
  12998. this._scene = this.camera.getScene();
  12999. this._engine = this._scene.getEngine();
  13000. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13001. _this._keys = [];
  13002. });
  13003. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13004. var evt = info.event;
  13005. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13006. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13007. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13008. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13009. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13010. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13011. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13012. var index = _this._keys.indexOf(evt.keyCode);
  13013. if (index === -1) {
  13014. _this._keys.push(evt.keyCode);
  13015. }
  13016. if (!noPreventDefault) {
  13017. evt.preventDefault();
  13018. }
  13019. }
  13020. }
  13021. else {
  13022. if (_this.keysForward.indexOf(evt.keyCode) !== -1 ||
  13023. _this.keysBackward.indexOf(evt.keyCode) !== -1 ||
  13024. _this.keysUp.indexOf(evt.keyCode) !== -1 ||
  13025. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  13026. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  13027. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  13028. var index = _this._keys.indexOf(evt.keyCode);
  13029. if (index >= 0) {
  13030. _this._keys.splice(index, 1);
  13031. }
  13032. if (!noPreventDefault) {
  13033. evt.preventDefault();
  13034. }
  13035. }
  13036. }
  13037. });
  13038. };
  13039. /**
  13040. * Detach the current controls from the specified dom element.
  13041. * @param element Defines the element to stop listening the inputs from
  13042. */
  13043. FlyCameraKeyboardInput.prototype.detachControl = function (element) {
  13044. if (this._scene) {
  13045. if (this._onKeyboardObserver) {
  13046. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13047. }
  13048. if (this._onCanvasBlurObserver) {
  13049. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13050. }
  13051. this._onKeyboardObserver = null;
  13052. this._onCanvasBlurObserver = null;
  13053. }
  13054. this._keys = [];
  13055. };
  13056. /**
  13057. * Gets the class name of the current intput.
  13058. * @returns the class name
  13059. */
  13060. FlyCameraKeyboardInput.prototype.getClassName = function () {
  13061. return "FlyCameraKeyboardInput";
  13062. };
  13063. /** @hidden */
  13064. FlyCameraKeyboardInput.prototype._onLostFocus = function (e) {
  13065. this._keys = [];
  13066. };
  13067. /**
  13068. * Get the friendly name associated with the input class.
  13069. * @returns the input friendly name
  13070. */
  13071. FlyCameraKeyboardInput.prototype.getSimpleName = function () {
  13072. return "keyboard";
  13073. };
  13074. /**
  13075. * Update the current camera state depending on the inputs that have been used this frame.
  13076. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13077. */
  13078. FlyCameraKeyboardInput.prototype.checkInputs = function () {
  13079. if (this._onKeyboardObserver) {
  13080. var camera = this.camera;
  13081. // Keyboard
  13082. for (var index = 0; index < this._keys.length; index++) {
  13083. var keyCode = this._keys[index];
  13084. var speed = camera._computeLocalCameraSpeed();
  13085. if (this.keysForward.indexOf(keyCode) !== -1) {
  13086. camera._localDirection.copyFromFloats(0, 0, speed);
  13087. }
  13088. else if (this.keysBackward.indexOf(keyCode) !== -1) {
  13089. camera._localDirection.copyFromFloats(0, 0, -speed);
  13090. }
  13091. else if (this.keysUp.indexOf(keyCode) !== -1) {
  13092. camera._localDirection.copyFromFloats(0, speed, 0);
  13093. }
  13094. else if (this.keysDown.indexOf(keyCode) !== -1) {
  13095. camera._localDirection.copyFromFloats(0, -speed, 0);
  13096. }
  13097. else if (this.keysRight.indexOf(keyCode) !== -1) {
  13098. camera._localDirection.copyFromFloats(speed, 0, 0);
  13099. }
  13100. else if (this.keysLeft.indexOf(keyCode) !== -1) {
  13101. camera._localDirection.copyFromFloats(-speed, 0, 0);
  13102. }
  13103. if (camera.getScene().useRightHandedSystem) {
  13104. camera._localDirection.z *= -1;
  13105. }
  13106. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  13107. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  13108. camera.cameraDirection.addInPlace(camera._transformedDirection);
  13109. }
  13110. }
  13111. };
  13112. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13113. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13114. ], FlyCameraKeyboardInput.prototype, "keysForward", void 0);
  13115. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13116. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13117. ], FlyCameraKeyboardInput.prototype, "keysBackward", void 0);
  13118. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13119. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13120. ], FlyCameraKeyboardInput.prototype, "keysUp", void 0);
  13121. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13122. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13123. ], FlyCameraKeyboardInput.prototype, "keysDown", void 0);
  13124. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13125. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13126. ], FlyCameraKeyboardInput.prototype, "keysRight", void 0);
  13127. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13128. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13129. ], FlyCameraKeyboardInput.prototype, "keysLeft", void 0);
  13130. return FlyCameraKeyboardInput;
  13131. }());
  13132. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraKeyboardInput"] = FlyCameraKeyboardInput;
  13133. /***/ }),
  13134. /***/ "./Cameras/Inputs/flyCameraMouseInput.ts":
  13135. /*!***********************************************!*\
  13136. !*** ./Cameras/Inputs/flyCameraMouseInput.ts ***!
  13137. \***********************************************/
  13138. /*! exports provided: FlyCameraMouseInput */
  13139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13140. "use strict";
  13141. __webpack_require__.r(__webpack_exports__);
  13142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return FlyCameraMouseInput; });
  13143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13144. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13145. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13146. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13147. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13148. /**
  13149. * Listen to mouse events to control the camera.
  13150. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13151. */
  13152. var FlyCameraMouseInput = /** @class */ (function () {
  13153. /**
  13154. * Listen to mouse events to control the camera.
  13155. * @param touchEnabled Define if touch is enabled. (Default is true.)
  13156. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13157. */
  13158. function FlyCameraMouseInput(touchEnabled) {
  13159. if (touchEnabled === void 0) { touchEnabled = true; }
  13160. /**
  13161. * Defines the buttons associated with the input to handle camera rotation.
  13162. */
  13163. this.buttons = [0, 1, 2];
  13164. /**
  13165. * Assign buttons for Yaw control.
  13166. */
  13167. this.buttonsYaw = [-1, 0, 1];
  13168. /**
  13169. * Assign buttons for Pitch control.
  13170. */
  13171. this.buttonsPitch = [-1, 0, 1];
  13172. /**
  13173. * Assign buttons for Roll control.
  13174. */
  13175. this.buttonsRoll = [2];
  13176. /**
  13177. * Detect if any button is being pressed while mouse is moved.
  13178. * -1 = Mouse locked.
  13179. * 0 = Left button.
  13180. * 1 = Middle Button.
  13181. * 2 = Right Button.
  13182. */
  13183. this.activeButton = -1;
  13184. /**
  13185. * Defines the pointer's angular sensibility, to control the camera rotation speed.
  13186. * Higher values reduce its sensitivity.
  13187. */
  13188. this.angularSensibility = 1000.0;
  13189. this.previousPosition = null;
  13190. }
  13191. /**
  13192. * Attach the mouse control to the HTML DOM element.
  13193. * @param element Defines the element that listens to the input events.
  13194. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault().
  13195. */
  13196. FlyCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  13197. var _this = this;
  13198. this.element = element;
  13199. this.noPreventDefault = noPreventDefault;
  13200. this._observer = this.camera.getScene().onPointerObservable.add(function (p, s) {
  13201. _this._pointerInput(p, s);
  13202. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP | _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE);
  13203. // Correct Roll by rate, if enabled.
  13204. this._rollObserver = this.camera.getScene().onBeforeRenderObservable.add(function () {
  13205. if (_this.camera.rollCorrect) {
  13206. _this.camera.restoreRoll(_this.camera.rollCorrect);
  13207. }
  13208. });
  13209. // Helper function to keep 'this'.
  13210. this._mousemoveCallback = function (e) {
  13211. _this._onMouseMove(e);
  13212. };
  13213. element.addEventListener("mousemove", this._mousemoveCallback, false);
  13214. };
  13215. /**
  13216. * Detach the current controls from the specified dom element.
  13217. * @param element Defines the element to stop listening the inputs from
  13218. */
  13219. FlyCameraMouseInput.prototype.detachControl = function (element) {
  13220. if (this._observer && element) {
  13221. this.camera.getScene().onPointerObservable.remove(this._observer);
  13222. this.camera.getScene().onBeforeRenderObservable.remove(this._rollObserver);
  13223. if (this._mousemoveCallback) {
  13224. element.removeEventListener("mousemove", this._mousemoveCallback);
  13225. }
  13226. this._observer = null;
  13227. this._rollObserver = null;
  13228. this.previousPosition = null;
  13229. this.noPreventDefault = undefined;
  13230. }
  13231. };
  13232. /**
  13233. * Gets the class name of the current input.
  13234. * @returns the class name.
  13235. */
  13236. FlyCameraMouseInput.prototype.getClassName = function () {
  13237. return "FlyCameraMouseInput";
  13238. };
  13239. /**
  13240. * Get the friendly name associated with the input class.
  13241. * @returns the input's friendly name.
  13242. */
  13243. FlyCameraMouseInput.prototype.getSimpleName = function () {
  13244. return "mouse";
  13245. };
  13246. // Track mouse movement, when the pointer is not locked.
  13247. FlyCameraMouseInput.prototype._pointerInput = function (p, s) {
  13248. var e = p.event;
  13249. var camera = this.camera;
  13250. var engine = camera.getEngine();
  13251. if (engine.isInVRExclusivePointerMode) {
  13252. return;
  13253. }
  13254. if (!this.touchEnabled && e.pointerType === "touch") {
  13255. return;
  13256. }
  13257. // Mouse is moved but an unknown mouse button is pressed.
  13258. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && this.buttons.indexOf(e.button) === -1) {
  13259. return;
  13260. }
  13261. var srcElement = (e.srcElement || e.target);
  13262. // Mouse down.
  13263. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  13264. try {
  13265. srcElement.setPointerCapture(e.pointerId);
  13266. }
  13267. catch (e) {
  13268. // Nothing to do with the error. Execution continues.
  13269. }
  13270. this.previousPosition = {
  13271. x: e.clientX,
  13272. y: e.clientY
  13273. };
  13274. this.activeButton = e.button;
  13275. if (!this.noPreventDefault) {
  13276. e.preventDefault();
  13277. this.element.focus();
  13278. }
  13279. }
  13280. else
  13281. // Mouse up.
  13282. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  13283. try {
  13284. srcElement.releasePointerCapture(e.pointerId);
  13285. }
  13286. catch (e) {
  13287. // Nothing to do with the error. Execution continues.
  13288. }
  13289. this.activeButton = -1;
  13290. this.previousPosition = null;
  13291. if (!this.noPreventDefault) {
  13292. e.preventDefault();
  13293. }
  13294. }
  13295. else
  13296. // Mouse move.
  13297. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  13298. if (!this.previousPosition || engine.isPointerLock) {
  13299. return;
  13300. }
  13301. var offsetX = e.clientX - this.previousPosition.x;
  13302. var offsetY = e.clientY - this.previousPosition.y;
  13303. this.rotateCamera(offsetX, offsetY);
  13304. this.previousPosition = {
  13305. x: e.clientX,
  13306. y: e.clientY
  13307. };
  13308. if (!this.noPreventDefault) {
  13309. e.preventDefault();
  13310. }
  13311. }
  13312. };
  13313. // Track mouse movement, when pointer is locked.
  13314. FlyCameraMouseInput.prototype._onMouseMove = function (e) {
  13315. var camera = this.camera;
  13316. var engine = camera.getEngine();
  13317. if (!engine.isPointerLock || engine.isInVRExclusivePointerMode) {
  13318. return;
  13319. }
  13320. var offsetX = e.movementX || e.mozMovementX || e.webkitMovementX || e.msMovementX || 0;
  13321. var offsetY = e.movementY || e.mozMovementY || e.webkitMovementY || e.msMovementY || 0;
  13322. this.rotateCamera(offsetX, offsetY);
  13323. this.previousPosition = null;
  13324. if (!this.noPreventDefault) {
  13325. e.preventDefault();
  13326. }
  13327. };
  13328. /**
  13329. * Rotate camera by mouse offset.
  13330. */
  13331. FlyCameraMouseInput.prototype.rotateCamera = function (offsetX, offsetY) {
  13332. var _this = this;
  13333. var camera = this.camera;
  13334. var scene = this.camera.getScene();
  13335. if (scene.useRightHandedSystem) {
  13336. offsetX *= -1;
  13337. }
  13338. if (camera.parent && camera.parent._getWorldMatrixDeterminant() < 0) {
  13339. offsetX *= -1;
  13340. }
  13341. var x = offsetX / this.angularSensibility;
  13342. var y = offsetY / this.angularSensibility;
  13343. // Initialize to current rotation.
  13344. var currentRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, camera.rotation.z);
  13345. var rotationChange;
  13346. // Pitch.
  13347. if (this.buttonsPitch.some(function (v) { return v === _this.activeButton; })) {
  13348. // Apply change in Radians to vector Angle.
  13349. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].X, y);
  13350. // Apply Pitch to quaternion.
  13351. currentRotation.multiplyInPlace(rotationChange);
  13352. }
  13353. // Yaw.
  13354. if (this.buttonsYaw.some(function (v) { return v === _this.activeButton; })) {
  13355. // Apply change in Radians to vector Angle.
  13356. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Y, x);
  13357. // Apply Yaw to quaternion.
  13358. currentRotation.multiplyInPlace(rotationChange);
  13359. // Add Roll, if banked turning is enabled, within Roll limit.
  13360. var limit = (camera.bankedTurnLimit) + camera._trackRoll; // Defaults to 90° plus manual roll.
  13361. if (camera.bankedTurn && -limit < camera.rotation.z && camera.rotation.z < limit) {
  13362. var bankingDelta = camera.bankedTurnMultiplier * -x;
  13363. // Apply change in Radians to vector Angle.
  13364. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, bankingDelta);
  13365. // Apply Yaw to quaternion.
  13366. currentRotation.multiplyInPlace(rotationChange);
  13367. }
  13368. }
  13369. // Roll.
  13370. if (this.buttonsRoll.some(function (v) { return v === _this.activeButton; })) {
  13371. // Apply change in Radians to vector Angle.
  13372. rotationChange = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].RotationAxis(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Axis"].Z, -x);
  13373. // Track Rolling.
  13374. camera._trackRoll -= x;
  13375. // Apply Pitch to quaternion.
  13376. currentRotation.multiplyInPlace(rotationChange);
  13377. }
  13378. // Apply rotationQuaternion to Euler camera.rotation.
  13379. currentRotation.toEulerAnglesToRef(camera.rotation);
  13380. };
  13381. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13382. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13383. ], FlyCameraMouseInput.prototype, "buttons", void 0);
  13384. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13385. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13386. ], FlyCameraMouseInput.prototype, "angularSensibility", void 0);
  13387. return FlyCameraMouseInput;
  13388. }());
  13389. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FlyCameraMouseInput"] = FlyCameraMouseInput;
  13390. /***/ }),
  13391. /***/ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts":
  13392. /*!*********************************************************!*\
  13393. !*** ./Cameras/Inputs/followCameraKeyboardMoveInput.ts ***!
  13394. \*********************************************************/
  13395. /*! exports provided: FollowCameraKeyboardMoveInput */
  13396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13397. "use strict";
  13398. __webpack_require__.r(__webpack_exports__);
  13399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraKeyboardMoveInput", function() { return FollowCameraKeyboardMoveInput; });
  13400. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13401. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13402. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13403. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  13404. /**
  13405. * Manage the keyboard inputs to control the movement of a follow camera.
  13406. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13407. */
  13408. var FollowCameraKeyboardMoveInput = /** @class */ (function () {
  13409. function FollowCameraKeyboardMoveInput() {
  13410. /**
  13411. * Defines the list of key codes associated with the up action (increase heightOffset)
  13412. */
  13413. this.keysHeightOffsetIncr = [38];
  13414. /**
  13415. * Defines the list of key codes associated with the down action (decrease heightOffset)
  13416. */
  13417. this.keysHeightOffsetDecr = [40];
  13418. /**
  13419. * Defines whether the Alt modifier key is required to move up/down (alter heightOffset)
  13420. */
  13421. this.keysHeightOffsetModifierAlt = false;
  13422. /**
  13423. * Defines whether the Ctrl modifier key is required to move up/down (alter heightOffset)
  13424. */
  13425. this.keysHeightOffsetModifierCtrl = false;
  13426. /**
  13427. * Defines whether the Shift modifier key is required to move up/down (alter heightOffset)
  13428. */
  13429. this.keysHeightOffsetModifierShift = false;
  13430. /**
  13431. * Defines the list of key codes associated with the left action (increase rotationOffset)
  13432. */
  13433. this.keysRotationOffsetIncr = [37];
  13434. /**
  13435. * Defines the list of key codes associated with the right action (decrease rotationOffset)
  13436. */
  13437. this.keysRotationOffsetDecr = [39];
  13438. /**
  13439. * Defines whether the Alt modifier key is required to move left/right (alter rotationOffset)
  13440. */
  13441. this.keysRotationOffsetModifierAlt = false;
  13442. /**
  13443. * Defines whether the Ctrl modifier key is required to move left/right (alter rotationOffset)
  13444. */
  13445. this.keysRotationOffsetModifierCtrl = false;
  13446. /**
  13447. * Defines whether the Shift modifier key is required to move left/right (alter rotationOffset)
  13448. */
  13449. this.keysRotationOffsetModifierShift = false;
  13450. /**
  13451. * Defines the list of key codes associated with the zoom-in action (decrease radius)
  13452. */
  13453. this.keysRadiusIncr = [40];
  13454. /**
  13455. * Defines the list of key codes associated with the zoom-out action (increase radius)
  13456. */
  13457. this.keysRadiusDecr = [38];
  13458. /**
  13459. * Defines whether the Alt modifier key is required to zoom in/out (alter radius value)
  13460. */
  13461. this.keysRadiusModifierAlt = true;
  13462. /**
  13463. * Defines whether the Ctrl modifier key is required to zoom in/out (alter radius value)
  13464. */
  13465. this.keysRadiusModifierCtrl = false;
  13466. /**
  13467. * Defines whether the Shift modifier key is required to zoom in/out (alter radius value)
  13468. */
  13469. this.keysRadiusModifierShift = false;
  13470. /**
  13471. * Defines the rate of change of heightOffset.
  13472. */
  13473. this.heightSensibility = 1;
  13474. /**
  13475. * Defines the rate of change of rotationOffset.
  13476. */
  13477. this.rotationSensibility = 1;
  13478. /**
  13479. * Defines the rate of change of radius.
  13480. */
  13481. this.radiusSensibility = 1;
  13482. this._keys = new Array();
  13483. }
  13484. /**
  13485. * Attach the input controls to a specific dom element to get the input from.
  13486. * @param element Defines the element the controls should be listened from
  13487. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13488. */
  13489. FollowCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  13490. var _this = this;
  13491. if (this._onCanvasBlurObserver) {
  13492. return;
  13493. }
  13494. this._scene = this.camera.getScene();
  13495. this._engine = this._scene.getEngine();
  13496. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  13497. _this._keys = [];
  13498. });
  13499. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  13500. var evt = info.event;
  13501. if (!evt.metaKey) {
  13502. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  13503. _this._ctrlPressed = evt.ctrlKey;
  13504. _this._altPressed = evt.altKey;
  13505. _this._shiftPressed = evt.shiftKey;
  13506. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13507. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13508. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13509. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13510. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13511. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13512. var index = _this._keys.indexOf(evt.keyCode);
  13513. if (index === -1) {
  13514. _this._keys.push(evt.keyCode);
  13515. }
  13516. if (evt.preventDefault) {
  13517. if (!noPreventDefault) {
  13518. evt.preventDefault();
  13519. }
  13520. }
  13521. }
  13522. }
  13523. else {
  13524. if (_this.keysHeightOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13525. _this.keysHeightOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13526. _this.keysRotationOffsetIncr.indexOf(evt.keyCode) !== -1 ||
  13527. _this.keysRotationOffsetDecr.indexOf(evt.keyCode) !== -1 ||
  13528. _this.keysRadiusIncr.indexOf(evt.keyCode) !== -1 ||
  13529. _this.keysRadiusDecr.indexOf(evt.keyCode) !== -1) {
  13530. var index = _this._keys.indexOf(evt.keyCode);
  13531. if (index >= 0) {
  13532. _this._keys.splice(index, 1);
  13533. }
  13534. if (evt.preventDefault) {
  13535. if (!noPreventDefault) {
  13536. evt.preventDefault();
  13537. }
  13538. }
  13539. }
  13540. }
  13541. }
  13542. });
  13543. };
  13544. /**
  13545. * Detach the current controls from the specified dom element.
  13546. * @param element Defines the element to stop listening the inputs from
  13547. */
  13548. FollowCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  13549. if (this._scene) {
  13550. if (this._onKeyboardObserver) {
  13551. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  13552. }
  13553. if (this._onCanvasBlurObserver) {
  13554. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  13555. }
  13556. this._onKeyboardObserver = null;
  13557. this._onCanvasBlurObserver = null;
  13558. }
  13559. this._keys = [];
  13560. };
  13561. /**
  13562. * Update the current camera state depending on the inputs that have been used this frame.
  13563. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13564. */
  13565. FollowCameraKeyboardMoveInput.prototype.checkInputs = function () {
  13566. var _this = this;
  13567. if (this._onKeyboardObserver) {
  13568. this._keys.forEach(function (keyCode) {
  13569. if (_this.keysHeightOffsetIncr.indexOf(keyCode) !== -1 &&
  13570. _this._modifierHeightOffset()) {
  13571. _this.camera.heightOffset += _this.heightSensibility;
  13572. }
  13573. else if (_this.keysHeightOffsetDecr.indexOf(keyCode) !== -1 &&
  13574. _this._modifierHeightOffset()) {
  13575. _this.camera.heightOffset -= _this.heightSensibility;
  13576. }
  13577. else if (_this.keysRotationOffsetIncr.indexOf(keyCode) !== -1 &&
  13578. _this._modifierRotationOffset()) {
  13579. _this.camera.rotationOffset += _this.rotationSensibility;
  13580. _this.camera.rotationOffset %= 360;
  13581. }
  13582. else if (_this.keysRotationOffsetDecr.indexOf(keyCode) !== -1 &&
  13583. _this._modifierRotationOffset()) {
  13584. _this.camera.rotationOffset -= _this.rotationSensibility;
  13585. _this.camera.rotationOffset %= 360;
  13586. }
  13587. else if (_this.keysRadiusIncr.indexOf(keyCode) !== -1 &&
  13588. _this._modifierRadius()) {
  13589. _this.camera.radius += _this.radiusSensibility;
  13590. }
  13591. else if (_this.keysRadiusDecr.indexOf(keyCode) !== -1 &&
  13592. _this._modifierRadius()) {
  13593. _this.camera.radius -= _this.radiusSensibility;
  13594. }
  13595. });
  13596. }
  13597. };
  13598. /**
  13599. * Gets the class name of the current input.
  13600. * @returns the class name
  13601. */
  13602. FollowCameraKeyboardMoveInput.prototype.getClassName = function () {
  13603. return "FollowCameraKeyboardMoveInput";
  13604. };
  13605. /**
  13606. * Get the friendly name associated with the input class.
  13607. * @returns the input friendly name
  13608. */
  13609. FollowCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  13610. return "keyboard";
  13611. };
  13612. /**
  13613. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13614. * allow modification of the heightOffset value.
  13615. */
  13616. FollowCameraKeyboardMoveInput.prototype._modifierHeightOffset = function () {
  13617. return (this.keysHeightOffsetModifierAlt === this._altPressed &&
  13618. this.keysHeightOffsetModifierCtrl === this._ctrlPressed &&
  13619. this.keysHeightOffsetModifierShift === this._shiftPressed);
  13620. };
  13621. /**
  13622. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13623. * allow modification of the rotationOffset value.
  13624. */
  13625. FollowCameraKeyboardMoveInput.prototype._modifierRotationOffset = function () {
  13626. return (this.keysRotationOffsetModifierAlt === this._altPressed &&
  13627. this.keysRotationOffsetModifierCtrl === this._ctrlPressed &&
  13628. this.keysRotationOffsetModifierShift === this._shiftPressed);
  13629. };
  13630. /**
  13631. * Check if the pressed modifier keys (Alt/Ctrl/Shift) match those configured to
  13632. * allow modification of the radius value.
  13633. */
  13634. FollowCameraKeyboardMoveInput.prototype._modifierRadius = function () {
  13635. return (this.keysRadiusModifierAlt === this._altPressed &&
  13636. this.keysRadiusModifierCtrl === this._ctrlPressed &&
  13637. this.keysRadiusModifierShift === this._shiftPressed);
  13638. };
  13639. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13640. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13641. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetIncr", void 0);
  13642. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13643. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13644. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetDecr", void 0);
  13645. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13647. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierAlt", void 0);
  13648. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13649. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13650. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierCtrl", void 0);
  13651. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13652. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13653. ], FollowCameraKeyboardMoveInput.prototype, "keysHeightOffsetModifierShift", void 0);
  13654. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13655. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13656. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetIncr", void 0);
  13657. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13658. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13659. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetDecr", void 0);
  13660. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13661. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13662. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierAlt", void 0);
  13663. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13664. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13665. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierCtrl", void 0);
  13666. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13667. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13668. ], FollowCameraKeyboardMoveInput.prototype, "keysRotationOffsetModifierShift", void 0);
  13669. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13670. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13671. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusIncr", void 0);
  13672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13674. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusDecr", void 0);
  13675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13677. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierAlt", void 0);
  13678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13680. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierCtrl", void 0);
  13681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13683. ], FollowCameraKeyboardMoveInput.prototype, "keysRadiusModifierShift", void 0);
  13684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13686. ], FollowCameraKeyboardMoveInput.prototype, "heightSensibility", void 0);
  13687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13689. ], FollowCameraKeyboardMoveInput.prototype, "rotationSensibility", void 0);
  13690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  13692. ], FollowCameraKeyboardMoveInput.prototype, "radiusSensibility", void 0);
  13693. return FollowCameraKeyboardMoveInput;
  13694. }());
  13695. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FollowCameraKeyboardMoveInput"] = FollowCameraKeyboardMoveInput;
  13696. /***/ }),
  13697. /***/ "./Cameras/Inputs/followCameraMouseWheelInput.ts":
  13698. /*!*******************************************************!*\
  13699. !*** ./Cameras/Inputs/followCameraMouseWheelInput.ts ***!
  13700. \*******************************************************/
  13701. /*! exports provided: FollowCameraMouseWheelInput */
  13702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13703. "use strict";
  13704. __webpack_require__.r(__webpack_exports__);
  13705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraMouseWheelInput", function() { return FollowCameraMouseWheelInput; });
  13706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13707. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13708. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13709. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  13710. /**
  13711. * Manage the mouse wheel inputs to control a follow camera.
  13712. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13713. */
  13714. var FollowCameraMouseWheelInput = /** @class */ (function () {
  13715. function FollowCameraMouseWheelInput() {
  13716. /**
  13717. * Moue wheel controls zoom. (Moue wheel modifies camera.radius value.)
  13718. */
  13719. this.axisControlRadius = true;
  13720. /**
  13721. * Moue wheel controls height. (Moue wheel modifies camera.heightOffset value.)
  13722. */
  13723. this.axisControlHeight = false;
  13724. /**
  13725. * Moue wheel controls angle. (Moue wheel modifies camera.rotationOffset value.)
  13726. */
  13727. this.axisControlRotation = false;
  13728. /**
  13729. * Gets or Set the mouse wheel precision or how fast is the camera moves in
  13730. * relation to mouseWheel events.
  13731. */
  13732. this.wheelPrecision = 3.0;
  13733. /**
  13734. * wheelDeltaPercentage will be used instead of wheelPrecision if different from 0.
  13735. * It defines the percentage of current camera.radius to use as delta when wheel is used.
  13736. */
  13737. this.wheelDeltaPercentage = 0;
  13738. }
  13739. /**
  13740. * Attach the input controls to a specific dom element to get the input from.
  13741. * @param element Defines the element the controls should be listened from
  13742. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13743. */
  13744. FollowCameraMouseWheelInput.prototype.attachControl = function (element, noPreventDefault) {
  13745. var _this = this;
  13746. this._wheel = function (p, s) {
  13747. // sanity check - this should be a PointerWheel event.
  13748. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL) {
  13749. return;
  13750. }
  13751. var event = p.event;
  13752. var delta = 0;
  13753. // Chrome, Safari: event.deltaY
  13754. // IE: event.wheelDelta
  13755. // Firefox: event.detail (inverted)
  13756. var wheelDelta = Math.max(-1, Math.min(1, (event.deltaY || event.wheelDelta || -event.detail)));
  13757. if (_this.wheelDeltaPercentage) {
  13758. console.assert((_this.axisControlRadius +
  13759. _this.axisControlHeight +
  13760. _this.axisControlRotation) <= 1, "wheelDeltaPercentage only usable when mouse wheel " +
  13761. "controlls ONE axis. " +
  13762. "Currently enabled: " +
  13763. "axisControlRadius: " + _this.axisControlRadius +
  13764. ", axisControlHeightOffset: " + _this.axisControlHeight +
  13765. ", axisControlRotationOffset: " + _this.axisControlRotation);
  13766. if (_this.axisControlRadius) {
  13767. delta =
  13768. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13769. _this.camera.radius;
  13770. }
  13771. else if (_this.axisControlHeight) {
  13772. delta =
  13773. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13774. _this.camera.heightOffset;
  13775. }
  13776. else if (_this.axisControlRotation) {
  13777. delta =
  13778. wheelDelta * 0.01 * _this.wheelDeltaPercentage *
  13779. _this.camera.rotationOffset;
  13780. }
  13781. }
  13782. else {
  13783. delta = wheelDelta * _this.wheelPrecision;
  13784. }
  13785. if (delta) {
  13786. if (_this.axisControlRadius) {
  13787. _this.camera.radius += delta;
  13788. }
  13789. else if (_this.axisControlHeight) {
  13790. _this.camera.heightOffset -= delta;
  13791. }
  13792. else if (_this.axisControlRotation) {
  13793. _this.camera.rotationOffset -= delta;
  13794. }
  13795. }
  13796. if (event.preventDefault) {
  13797. if (!noPreventDefault) {
  13798. event.preventDefault();
  13799. }
  13800. }
  13801. };
  13802. this._observer = this.camera.getScene().onPointerObservable.add(this._wheel, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERWHEEL);
  13803. };
  13804. /**
  13805. * Detach the current controls from the specified dom element.
  13806. * @param element Defines the element to stop listening the inputs from
  13807. */
  13808. FollowCameraMouseWheelInput.prototype.detachControl = function (element) {
  13809. if (this._observer && element) {
  13810. this.camera.getScene().onPointerObservable.remove(this._observer);
  13811. this._observer = null;
  13812. this._wheel = null;
  13813. }
  13814. };
  13815. /**
  13816. * Gets the class name of the current intput.
  13817. * @returns the class name
  13818. */
  13819. FollowCameraMouseWheelInput.prototype.getClassName = function () {
  13820. return "ArcRotateCameraMouseWheelInput";
  13821. };
  13822. /**
  13823. * Get the friendly name associated with the input class.
  13824. * @returns the input friendly name
  13825. */
  13826. FollowCameraMouseWheelInput.prototype.getSimpleName = function () {
  13827. return "mousewheel";
  13828. };
  13829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13831. ], FollowCameraMouseWheelInput.prototype, "axisControlRadius", void 0);
  13832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13834. ], FollowCameraMouseWheelInput.prototype, "axisControlHeight", void 0);
  13835. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13836. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13837. ], FollowCameraMouseWheelInput.prototype, "axisControlRotation", void 0);
  13838. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13839. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13840. ], FollowCameraMouseWheelInput.prototype, "wheelPrecision", void 0);
  13841. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  13842. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  13843. ], FollowCameraMouseWheelInput.prototype, "wheelDeltaPercentage", void 0);
  13844. return FollowCameraMouseWheelInput;
  13845. }());
  13846. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FollowCameraMouseWheelInput"] = FollowCameraMouseWheelInput;
  13847. /***/ }),
  13848. /***/ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts":
  13849. /*!************************************************************!*\
  13850. !*** ./Cameras/Inputs/freeCameraDeviceOrientationInput.ts ***!
  13851. \************************************************************/
  13852. /*! exports provided: FreeCameraDeviceOrientationInput */
  13853. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13854. "use strict";
  13855. __webpack_require__.r(__webpack_exports__);
  13856. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return FreeCameraDeviceOrientationInput; });
  13857. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13858. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13859. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  13860. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  13861. /**
  13862. * Add orientation input support to the input manager.
  13863. * @returns the current input manager
  13864. */
  13865. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addDeviceOrientation = function () {
  13866. this.add(new FreeCameraDeviceOrientationInput());
  13867. return this;
  13868. };
  13869. /**
  13870. * Takes information about the orientation of the device as reported by the deviceorientation event to orient the camera.
  13871. * Screen rotation is taken into account.
  13872. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13873. */
  13874. var FreeCameraDeviceOrientationInput = /** @class */ (function () {
  13875. /**
  13876. * Instantiates a new input
  13877. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13878. */
  13879. function FreeCameraDeviceOrientationInput() {
  13880. var _this = this;
  13881. this._screenOrientationAngle = 0;
  13882. this._screenQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13883. this._alpha = 0;
  13884. this._beta = 0;
  13885. this._gamma = 0;
  13886. this._orientationChanged = function () {
  13887. _this._screenOrientationAngle = (window.orientation !== undefined ? +window.orientation : (window.screen.orientation && (window.screen.orientation)['angle'] ? (window.screen.orientation).angle : 0));
  13888. _this._screenOrientationAngle = -_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(_this._screenOrientationAngle / 2);
  13889. _this._screenQuaternion.copyFromFloats(0, Math.sin(_this._screenOrientationAngle), 0, Math.cos(_this._screenOrientationAngle));
  13890. };
  13891. this._deviceOrientation = function (evt) {
  13892. _this._alpha = evt.alpha !== null ? evt.alpha : 0;
  13893. _this._beta = evt.beta !== null ? evt.beta : 0;
  13894. _this._gamma = evt.gamma !== null ? evt.gamma : 0;
  13895. };
  13896. this._constantTranform = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-Math.sqrt(0.5), 0, 0, Math.sqrt(0.5));
  13897. this._orientationChanged();
  13898. }
  13899. Object.defineProperty(FreeCameraDeviceOrientationInput.prototype, "camera", {
  13900. /**
  13901. * Define the camera controlled by the input.
  13902. */
  13903. get: function () {
  13904. return this._camera;
  13905. },
  13906. set: function (camera) {
  13907. this._camera = camera;
  13908. if (this._camera != null && !this._camera.rotationQuaternion) {
  13909. this._camera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  13910. }
  13911. },
  13912. enumerable: true,
  13913. configurable: true
  13914. });
  13915. /**
  13916. * Attach the input controls to a specific dom element to get the input from.
  13917. * @param element Defines the element the controls should be listened from
  13918. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  13919. */
  13920. FreeCameraDeviceOrientationInput.prototype.attachControl = function (element, noPreventDefault) {
  13921. window.addEventListener("orientationchange", this._orientationChanged);
  13922. window.addEventListener("deviceorientation", this._deviceOrientation);
  13923. //In certain cases, the attach control is called AFTER orientation was changed,
  13924. //So this is needed.
  13925. this._orientationChanged();
  13926. };
  13927. /**
  13928. * Detach the current controls from the specified dom element.
  13929. * @param element Defines the element to stop listening the inputs from
  13930. */
  13931. FreeCameraDeviceOrientationInput.prototype.detachControl = function (element) {
  13932. window.removeEventListener("orientationchange", this._orientationChanged);
  13933. window.removeEventListener("deviceorientation", this._deviceOrientation);
  13934. };
  13935. /**
  13936. * Update the current camera state depending on the inputs that have been used this frame.
  13937. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  13938. */
  13939. FreeCameraDeviceOrientationInput.prototype.checkInputs = function () {
  13940. //if no device orientation provided, don't update the rotation.
  13941. //Only testing against alpha under the assumption thatnorientation will never be so exact when set.
  13942. if (!this._alpha) {
  13943. return;
  13944. }
  13945. _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);
  13946. this._camera.rotationQuaternion.multiplyInPlace(this._screenQuaternion);
  13947. this._camera.rotationQuaternion.multiplyInPlace(this._constantTranform);
  13948. //Mirror on XY Plane
  13949. this._camera.rotationQuaternion.z *= -1;
  13950. this._camera.rotationQuaternion.w *= -1;
  13951. };
  13952. /**
  13953. * Gets the class name of the current intput.
  13954. * @returns the class name
  13955. */
  13956. FreeCameraDeviceOrientationInput.prototype.getClassName = function () {
  13957. return "FreeCameraDeviceOrientationInput";
  13958. };
  13959. /**
  13960. * Get the friendly name associated with the input class.
  13961. * @returns the input friendly name
  13962. */
  13963. FreeCameraDeviceOrientationInput.prototype.getSimpleName = function () {
  13964. return "deviceOrientation";
  13965. };
  13966. return FreeCameraDeviceOrientationInput;
  13967. }());
  13968. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]["FreeCameraDeviceOrientationInput"] = FreeCameraDeviceOrientationInput;
  13969. /***/ }),
  13970. /***/ "./Cameras/Inputs/freeCameraGamepadInput.ts":
  13971. /*!**************************************************!*\
  13972. !*** ./Cameras/Inputs/freeCameraGamepadInput.ts ***!
  13973. \**************************************************/
  13974. /*! exports provided: FreeCameraGamepadInput */
  13975. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  13976. "use strict";
  13977. __webpack_require__.r(__webpack_exports__);
  13978. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return FreeCameraGamepadInput; });
  13979. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  13980. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  13981. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  13982. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  13983. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  13984. /**
  13985. * Manage the gamepad inputs to control a free camera.
  13986. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  13987. */
  13988. var FreeCameraGamepadInput = /** @class */ (function () {
  13989. function FreeCameraGamepadInput() {
  13990. /**
  13991. * Defines the gamepad rotation sensiblity.
  13992. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  13993. */
  13994. this.gamepadAngularSensibility = 200;
  13995. /**
  13996. * Defines the gamepad move sensiblity.
  13997. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  13998. */
  13999. this.gamepadMoveSensibility = 40;
  14000. this._cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  14001. this._deltaTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14002. this._vector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  14003. this._vector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  14004. }
  14005. /**
  14006. * Attach the input controls to a specific dom element to get the input from.
  14007. * @param element Defines the element the controls should be listened from
  14008. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14009. */
  14010. FreeCameraGamepadInput.prototype.attachControl = function (element, noPreventDefault) {
  14011. var _this = this;
  14012. var manager = this.camera.getScene().gamepadManager;
  14013. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  14014. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].POSE_ENABLED) {
  14015. // prioritize XBOX gamepads.
  14016. if (!_this.gamepad || gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX) {
  14017. _this.gamepad = gamepad;
  14018. }
  14019. }
  14020. });
  14021. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  14022. if (_this.gamepad === gamepad) {
  14023. _this.gamepad = null;
  14024. }
  14025. });
  14026. this.gamepad = manager.getGamepadByType(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_4__["Gamepad"].XBOX);
  14027. };
  14028. /**
  14029. * Detach the current controls from the specified dom element.
  14030. * @param element Defines the element to stop listening the inputs from
  14031. */
  14032. FreeCameraGamepadInput.prototype.detachControl = function (element) {
  14033. this.camera.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  14034. this.camera.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  14035. this.gamepad = null;
  14036. };
  14037. /**
  14038. * Update the current camera state depending on the inputs that have been used this frame.
  14039. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14040. */
  14041. FreeCameraGamepadInput.prototype.checkInputs = function () {
  14042. if (this.gamepad && this.gamepad.leftStick) {
  14043. var camera = this.camera;
  14044. var LSValues = this.gamepad.leftStick;
  14045. var normalizedLX = LSValues.x / this.gamepadMoveSensibility;
  14046. var normalizedLY = LSValues.y / this.gamepadMoveSensibility;
  14047. LSValues.x = Math.abs(normalizedLX) > 0.005 ? 0 + normalizedLX : 0;
  14048. LSValues.y = Math.abs(normalizedLY) > 0.005 ? 0 + normalizedLY : 0;
  14049. var RSValues = this.gamepad.rightStick;
  14050. if (RSValues) {
  14051. var normalizedRX = RSValues.x / this.gamepadAngularSensibility;
  14052. var normalizedRY = RSValues.y / this.gamepadAngularSensibility;
  14053. RSValues.x = Math.abs(normalizedRX) > 0.001 ? 0 + normalizedRX : 0;
  14054. RSValues.y = Math.abs(normalizedRY) > 0.001 ? 0 + normalizedRY : 0;
  14055. }
  14056. else {
  14057. RSValues = { x: 0, y: 0 };
  14058. }
  14059. if (!camera.rotationQuaternion) {
  14060. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, this._cameraTransform);
  14061. }
  14062. else {
  14063. camera.rotationQuaternion.toRotationMatrix(this._cameraTransform);
  14064. }
  14065. var speed = camera._computeLocalCameraSpeed() * 50.0;
  14066. this._vector3.copyFromFloats(LSValues.x * speed, 0, -LSValues.y * speed);
  14067. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._vector3, this._cameraTransform, this._deltaTransform);
  14068. camera.cameraDirection.addInPlace(this._deltaTransform);
  14069. this._vector2.copyFromFloats(RSValues.y, RSValues.x);
  14070. camera.cameraRotation.addInPlace(this._vector2);
  14071. }
  14072. };
  14073. /**
  14074. * Gets the class name of the current intput.
  14075. * @returns the class name
  14076. */
  14077. FreeCameraGamepadInput.prototype.getClassName = function () {
  14078. return "FreeCameraGamepadInput";
  14079. };
  14080. /**
  14081. * Get the friendly name associated with the input class.
  14082. * @returns the input friendly name
  14083. */
  14084. FreeCameraGamepadInput.prototype.getSimpleName = function () {
  14085. return "gamepad";
  14086. };
  14087. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14088. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14089. ], FreeCameraGamepadInput.prototype, "gamepadAngularSensibility", void 0);
  14090. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14091. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14092. ], FreeCameraGamepadInput.prototype, "gamepadMoveSensibility", void 0);
  14093. return FreeCameraGamepadInput;
  14094. }());
  14095. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraGamepadInput"] = FreeCameraGamepadInput;
  14096. /***/ }),
  14097. /***/ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts":
  14098. /*!*******************************************************!*\
  14099. !*** ./Cameras/Inputs/freeCameraKeyboardMoveInput.ts ***!
  14100. \*******************************************************/
  14101. /*! exports provided: FreeCameraKeyboardMoveInput */
  14102. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14103. "use strict";
  14104. __webpack_require__.r(__webpack_exports__);
  14105. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return FreeCameraKeyboardMoveInput; });
  14106. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14107. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14108. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14109. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  14110. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14111. /**
  14112. * Manage the keyboard inputs to control the movement of a free camera.
  14113. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14114. */
  14115. var FreeCameraKeyboardMoveInput = /** @class */ (function () {
  14116. function FreeCameraKeyboardMoveInput() {
  14117. /**
  14118. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  14119. */
  14120. this.keysUp = [38];
  14121. /**
  14122. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  14123. */
  14124. this.keysDown = [40];
  14125. /**
  14126. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  14127. */
  14128. this.keysLeft = [37];
  14129. /**
  14130. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  14131. */
  14132. this.keysRight = [39];
  14133. this._keys = new Array();
  14134. }
  14135. /**
  14136. * Attach the input controls to a specific dom element to get the input from.
  14137. * @param element Defines the element the controls should be listened from
  14138. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14139. */
  14140. FreeCameraKeyboardMoveInput.prototype.attachControl = function (element, noPreventDefault) {
  14141. var _this = this;
  14142. if (this._onCanvasBlurObserver) {
  14143. return;
  14144. }
  14145. this._scene = this.camera.getScene();
  14146. this._engine = this._scene.getEngine();
  14147. this._onCanvasBlurObserver = this._engine.onCanvasBlurObservable.add(function () {
  14148. _this._keys = [];
  14149. });
  14150. this._onKeyboardObserver = this._scene.onKeyboardObservable.add(function (info) {
  14151. var evt = info.event;
  14152. if (!evt.metaKey) {
  14153. if (info.type === _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_3__["KeyboardEventTypes"].KEYDOWN) {
  14154. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14155. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14156. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14157. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14158. var index = _this._keys.indexOf(evt.keyCode);
  14159. if (index === -1) {
  14160. _this._keys.push(evt.keyCode);
  14161. }
  14162. if (!noPreventDefault) {
  14163. evt.preventDefault();
  14164. }
  14165. }
  14166. }
  14167. else {
  14168. if (_this.keysUp.indexOf(evt.keyCode) !== -1 ||
  14169. _this.keysDown.indexOf(evt.keyCode) !== -1 ||
  14170. _this.keysLeft.indexOf(evt.keyCode) !== -1 ||
  14171. _this.keysRight.indexOf(evt.keyCode) !== -1) {
  14172. var index = _this._keys.indexOf(evt.keyCode);
  14173. if (index >= 0) {
  14174. _this._keys.splice(index, 1);
  14175. }
  14176. if (!noPreventDefault) {
  14177. evt.preventDefault();
  14178. }
  14179. }
  14180. }
  14181. }
  14182. });
  14183. };
  14184. /**
  14185. * Detach the current controls from the specified dom element.
  14186. * @param element Defines the element to stop listening the inputs from
  14187. */
  14188. FreeCameraKeyboardMoveInput.prototype.detachControl = function (element) {
  14189. if (this._scene) {
  14190. if (this._onKeyboardObserver) {
  14191. this._scene.onKeyboardObservable.remove(this._onKeyboardObserver);
  14192. }
  14193. if (this._onCanvasBlurObserver) {
  14194. this._engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  14195. }
  14196. this._onKeyboardObserver = null;
  14197. this._onCanvasBlurObserver = null;
  14198. }
  14199. this._keys = [];
  14200. };
  14201. /**
  14202. * Update the current camera state depending on the inputs that have been used this frame.
  14203. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14204. */
  14205. FreeCameraKeyboardMoveInput.prototype.checkInputs = function () {
  14206. if (this._onKeyboardObserver) {
  14207. var camera = this.camera;
  14208. // Keyboard
  14209. for (var index = 0; index < this._keys.length; index++) {
  14210. var keyCode = this._keys[index];
  14211. var speed = camera._computeLocalCameraSpeed();
  14212. if (this.keysLeft.indexOf(keyCode) !== -1) {
  14213. camera._localDirection.copyFromFloats(-speed, 0, 0);
  14214. }
  14215. else if (this.keysUp.indexOf(keyCode) !== -1) {
  14216. camera._localDirection.copyFromFloats(0, 0, speed);
  14217. }
  14218. else if (this.keysRight.indexOf(keyCode) !== -1) {
  14219. camera._localDirection.copyFromFloats(speed, 0, 0);
  14220. }
  14221. else if (this.keysDown.indexOf(keyCode) !== -1) {
  14222. camera._localDirection.copyFromFloats(0, 0, -speed);
  14223. }
  14224. if (camera.getScene().useRightHandedSystem) {
  14225. camera._localDirection.z *= -1;
  14226. }
  14227. camera.getViewMatrix().invertToRef(camera._cameraTransformMatrix);
  14228. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformNormalToRef(camera._localDirection, camera._cameraTransformMatrix, camera._transformedDirection);
  14229. camera.cameraDirection.addInPlace(camera._transformedDirection);
  14230. }
  14231. }
  14232. };
  14233. /**
  14234. * Gets the class name of the current intput.
  14235. * @returns the class name
  14236. */
  14237. FreeCameraKeyboardMoveInput.prototype.getClassName = function () {
  14238. return "FreeCameraKeyboardMoveInput";
  14239. };
  14240. /** @hidden */
  14241. FreeCameraKeyboardMoveInput.prototype._onLostFocus = function () {
  14242. this._keys = [];
  14243. };
  14244. /**
  14245. * Get the friendly name associated with the input class.
  14246. * @returns the input friendly name
  14247. */
  14248. FreeCameraKeyboardMoveInput.prototype.getSimpleName = function () {
  14249. return "keyboard";
  14250. };
  14251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14253. ], FreeCameraKeyboardMoveInput.prototype, "keysUp", void 0);
  14254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14256. ], FreeCameraKeyboardMoveInput.prototype, "keysDown", void 0);
  14257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14259. ], FreeCameraKeyboardMoveInput.prototype, "keysLeft", void 0);
  14260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14262. ], FreeCameraKeyboardMoveInput.prototype, "keysRight", void 0);
  14263. return FreeCameraKeyboardMoveInput;
  14264. }());
  14265. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraKeyboardMoveInput"] = FreeCameraKeyboardMoveInput;
  14266. /***/ }),
  14267. /***/ "./Cameras/Inputs/freeCameraMouseInput.ts":
  14268. /*!************************************************!*\
  14269. !*** ./Cameras/Inputs/freeCameraMouseInput.ts ***!
  14270. \************************************************/
  14271. /*! exports provided: FreeCameraMouseInput */
  14272. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14273. "use strict";
  14274. __webpack_require__.r(__webpack_exports__);
  14275. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return FreeCameraMouseInput; });
  14276. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14277. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14278. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14279. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14280. /**
  14281. * Manage the mouse inputs to control the movement of a free camera.
  14282. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14283. */
  14284. var FreeCameraMouseInput = /** @class */ (function () {
  14285. /**
  14286. * Manage the mouse inputs to control the movement of a free camera.
  14287. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14288. * @param touchEnabled Defines if touch is enabled or not
  14289. */
  14290. function FreeCameraMouseInput(
  14291. /**
  14292. * Define if touch is enabled in the mouse input
  14293. */
  14294. touchEnabled) {
  14295. if (touchEnabled === void 0) { touchEnabled = true; }
  14296. this.touchEnabled = touchEnabled;
  14297. /**
  14298. * Defines the buttons associated with the input to handle camera move.
  14299. */
  14300. this.buttons = [0, 1, 2];
  14301. /**
  14302. * Defines the pointer angular sensibility along the X and Y axis or how fast is the camera rotating.
  14303. */
  14304. this.angularSensibility = 2000.0;
  14305. this.previousPosition = null;
  14306. }
  14307. /**
  14308. * Attach the input controls to a specific dom element to get the input from.
  14309. * @param element Defines the element the controls should be listened from
  14310. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14311. */
  14312. FreeCameraMouseInput.prototype.attachControl = function (element, noPreventDefault) {
  14313. var _this = this;
  14314. var engine = this.camera.getEngine();
  14315. if (!this._pointerInput) {
  14316. this._pointerInput = function (p) {
  14317. var evt = p.event;
  14318. if (engine.isInVRExclusivePointerMode) {
  14319. return;
  14320. }
  14321. if (!_this.touchEnabled && evt.pointerType === "touch") {
  14322. return;
  14323. }
  14324. if (p.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE && _this.buttons.indexOf(evt.button) === -1) {
  14325. return;
  14326. }
  14327. var srcElement = (evt.srcElement || evt.target);
  14328. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN && srcElement) {
  14329. try {
  14330. srcElement.setPointerCapture(evt.pointerId);
  14331. }
  14332. catch (e) {
  14333. //Nothing to do with the error. Execution will continue.
  14334. }
  14335. _this.previousPosition = {
  14336. x: evt.clientX,
  14337. y: evt.clientY
  14338. };
  14339. if (!noPreventDefault) {
  14340. evt.preventDefault();
  14341. element.focus();
  14342. }
  14343. }
  14344. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP && srcElement) {
  14345. try {
  14346. srcElement.releasePointerCapture(evt.pointerId);
  14347. }
  14348. catch (e) {
  14349. //Nothing to do with the error.
  14350. }
  14351. _this.previousPosition = null;
  14352. if (!noPreventDefault) {
  14353. evt.preventDefault();
  14354. }
  14355. }
  14356. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14357. if (!_this.previousPosition || engine.isPointerLock) {
  14358. return;
  14359. }
  14360. var offsetX = evt.clientX - _this.previousPosition.x;
  14361. if (_this.camera.getScene().useRightHandedSystem) {
  14362. offsetX *= -1;
  14363. }
  14364. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14365. offsetX *= -1;
  14366. }
  14367. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14368. var offsetY = evt.clientY - _this.previousPosition.y;
  14369. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14370. _this.previousPosition = {
  14371. x: evt.clientX,
  14372. y: evt.clientY
  14373. };
  14374. if (!noPreventDefault) {
  14375. evt.preventDefault();
  14376. }
  14377. }
  14378. };
  14379. }
  14380. this._onMouseMove = function (evt) {
  14381. if (!engine.isPointerLock) {
  14382. return;
  14383. }
  14384. if (engine.isInVRExclusivePointerMode) {
  14385. return;
  14386. }
  14387. var offsetX = evt.movementX || evt.mozMovementX || evt.webkitMovementX || evt.msMovementX || 0;
  14388. if (_this.camera.getScene().useRightHandedSystem) {
  14389. offsetX *= -1;
  14390. }
  14391. if (_this.camera.parent && _this.camera.parent._getWorldMatrixDeterminant() < 0) {
  14392. offsetX *= -1;
  14393. }
  14394. _this.camera.cameraRotation.y += offsetX / _this.angularSensibility;
  14395. var offsetY = evt.movementY || evt.mozMovementY || evt.webkitMovementY || evt.msMovementY || 0;
  14396. _this.camera.cameraRotation.x += offsetY / _this.angularSensibility;
  14397. _this.previousPosition = null;
  14398. if (!noPreventDefault) {
  14399. evt.preventDefault();
  14400. }
  14401. };
  14402. 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);
  14403. element.addEventListener("mousemove", this._onMouseMove, false);
  14404. };
  14405. /**
  14406. * Detach the current controls from the specified dom element.
  14407. * @param element Defines the element to stop listening the inputs from
  14408. */
  14409. FreeCameraMouseInput.prototype.detachControl = function (element) {
  14410. if (this._observer && element) {
  14411. this.camera.getScene().onPointerObservable.remove(this._observer);
  14412. if (this._onMouseMove) {
  14413. element.removeEventListener("mousemove", this._onMouseMove);
  14414. }
  14415. this._observer = null;
  14416. this._onMouseMove = null;
  14417. this.previousPosition = null;
  14418. }
  14419. };
  14420. /**
  14421. * Gets the class name of the current intput.
  14422. * @returns the class name
  14423. */
  14424. FreeCameraMouseInput.prototype.getClassName = function () {
  14425. return "FreeCameraMouseInput";
  14426. };
  14427. /**
  14428. * Get the friendly name associated with the input class.
  14429. * @returns the input friendly name
  14430. */
  14431. FreeCameraMouseInput.prototype.getSimpleName = function () {
  14432. return "mouse";
  14433. };
  14434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14436. ], FreeCameraMouseInput.prototype, "buttons", void 0);
  14437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14439. ], FreeCameraMouseInput.prototype, "angularSensibility", void 0);
  14440. return FreeCameraMouseInput;
  14441. }());
  14442. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraMouseInput"] = FreeCameraMouseInput;
  14443. /***/ }),
  14444. /***/ "./Cameras/Inputs/freeCameraTouchInput.ts":
  14445. /*!************************************************!*\
  14446. !*** ./Cameras/Inputs/freeCameraTouchInput.ts ***!
  14447. \************************************************/
  14448. /*! exports provided: FreeCameraTouchInput */
  14449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14450. "use strict";
  14451. __webpack_require__.r(__webpack_exports__);
  14452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return FreeCameraTouchInput; });
  14453. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14454. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  14455. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14456. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  14457. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14458. /**
  14459. * Manage the touch inputs to control the movement of a free camera.
  14460. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14461. */
  14462. var FreeCameraTouchInput = /** @class */ (function () {
  14463. function FreeCameraTouchInput() {
  14464. /**
  14465. * Defines the touch sensibility for rotation.
  14466. * The higher the faster.
  14467. */
  14468. this.touchAngularSensibility = 200000.0;
  14469. /**
  14470. * Defines the touch sensibility for move.
  14471. * The higher the faster.
  14472. */
  14473. this.touchMoveSensibility = 250.0;
  14474. this._offsetX = null;
  14475. this._offsetY = null;
  14476. this._pointerPressed = new Array();
  14477. }
  14478. /**
  14479. * Attach the input controls to a specific dom element to get the input from.
  14480. * @param element Defines the element the controls should be listened from
  14481. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14482. */
  14483. FreeCameraTouchInput.prototype.attachControl = function (element, noPreventDefault) {
  14484. var _this = this;
  14485. var previousPosition = null;
  14486. if (this._pointerInput === undefined) {
  14487. this._onLostFocus = function () {
  14488. _this._offsetX = null;
  14489. _this._offsetY = null;
  14490. };
  14491. this._pointerInput = function (p) {
  14492. var evt = p.event;
  14493. if (evt.pointerType === "mouse") {
  14494. return;
  14495. }
  14496. if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERDOWN) {
  14497. if (!noPreventDefault) {
  14498. evt.preventDefault();
  14499. }
  14500. _this._pointerPressed.push(evt.pointerId);
  14501. if (_this._pointerPressed.length !== 1) {
  14502. return;
  14503. }
  14504. previousPosition = {
  14505. x: evt.clientX,
  14506. y: evt.clientY
  14507. };
  14508. }
  14509. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERUP) {
  14510. if (!noPreventDefault) {
  14511. evt.preventDefault();
  14512. }
  14513. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14514. if (index === -1) {
  14515. return;
  14516. }
  14517. _this._pointerPressed.splice(index, 1);
  14518. if (index != 0) {
  14519. return;
  14520. }
  14521. previousPosition = null;
  14522. _this._offsetX = null;
  14523. _this._offsetY = null;
  14524. }
  14525. else if (p.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_3__["PointerEventTypes"].POINTERMOVE) {
  14526. if (!noPreventDefault) {
  14527. evt.preventDefault();
  14528. }
  14529. if (!previousPosition) {
  14530. return;
  14531. }
  14532. var index = _this._pointerPressed.indexOf(evt.pointerId);
  14533. if (index != 0) {
  14534. return;
  14535. }
  14536. _this._offsetX = evt.clientX - previousPosition.x;
  14537. _this._offsetY = -(evt.clientY - previousPosition.y);
  14538. }
  14539. };
  14540. }
  14541. 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);
  14542. if (this._onLostFocus) {
  14543. element.addEventListener("blur", this._onLostFocus);
  14544. }
  14545. };
  14546. /**
  14547. * Detach the current controls from the specified dom element.
  14548. * @param element Defines the element to stop listening the inputs from
  14549. */
  14550. FreeCameraTouchInput.prototype.detachControl = function (element) {
  14551. if (this._pointerInput && element) {
  14552. if (this._observer) {
  14553. this.camera.getScene().onPointerObservable.remove(this._observer);
  14554. this._observer = null;
  14555. }
  14556. if (this._onLostFocus) {
  14557. element.removeEventListener("blur", this._onLostFocus);
  14558. this._onLostFocus = null;
  14559. }
  14560. this._pointerPressed = [];
  14561. this._offsetX = null;
  14562. this._offsetY = null;
  14563. }
  14564. };
  14565. /**
  14566. * Update the current camera state depending on the inputs that have been used this frame.
  14567. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14568. */
  14569. FreeCameraTouchInput.prototype.checkInputs = function () {
  14570. if (this._offsetX && this._offsetY) {
  14571. var camera = this.camera;
  14572. camera.cameraRotation.y += this._offsetX / this.touchAngularSensibility;
  14573. if (this._pointerPressed.length > 1) {
  14574. camera.cameraRotation.x += -this._offsetY / this.touchAngularSensibility;
  14575. }
  14576. else {
  14577. var speed = camera._computeLocalCameraSpeed();
  14578. var direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 0, speed * this._offsetY / this.touchMoveSensibility);
  14579. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(camera.rotation.y, camera.rotation.x, 0, camera._cameraRotationMatrix);
  14580. camera.cameraDirection.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinates(direction, camera._cameraRotationMatrix));
  14581. }
  14582. }
  14583. };
  14584. /**
  14585. * Gets the class name of the current intput.
  14586. * @returns the class name
  14587. */
  14588. FreeCameraTouchInput.prototype.getClassName = function () {
  14589. return "FreeCameraTouchInput";
  14590. };
  14591. /**
  14592. * Get the friendly name associated with the input class.
  14593. * @returns the input friendly name
  14594. */
  14595. FreeCameraTouchInput.prototype.getSimpleName = function () {
  14596. return "touch";
  14597. };
  14598. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14599. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14600. ], FreeCameraTouchInput.prototype, "touchAngularSensibility", void 0);
  14601. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  14602. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  14603. ], FreeCameraTouchInput.prototype, "touchMoveSensibility", void 0);
  14604. return FreeCameraTouchInput;
  14605. }());
  14606. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_2__["CameraInputTypes"]["FreeCameraTouchInput"] = FreeCameraTouchInput;
  14607. /***/ }),
  14608. /***/ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts":
  14609. /*!**********************************************************!*\
  14610. !*** ./Cameras/Inputs/freeCameraVirtualJoystickInput.ts ***!
  14611. \**********************************************************/
  14612. /*! exports provided: FreeCameraVirtualJoystickInput */
  14613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14614. "use strict";
  14615. __webpack_require__.r(__webpack_exports__);
  14616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return FreeCameraVirtualJoystickInput; });
  14617. /* harmony import */ var _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/virtualJoystick */ "./Misc/virtualJoystick.ts");
  14618. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  14619. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14620. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  14621. /**
  14622. * Add virtual joystick input support to the input manager.
  14623. * @returns the current input manager
  14624. */
  14625. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addVirtualJoystick = function () {
  14626. this.add(new FreeCameraVirtualJoystickInput());
  14627. return this;
  14628. };
  14629. /**
  14630. * Manage the Virtual Joystick inputs to control the movement of a free camera.
  14631. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  14632. */
  14633. var FreeCameraVirtualJoystickInput = /** @class */ (function () {
  14634. function FreeCameraVirtualJoystickInput() {
  14635. }
  14636. /**
  14637. * Gets the left stick of the virtual joystick.
  14638. * @returns The virtual Joystick
  14639. */
  14640. FreeCameraVirtualJoystickInput.prototype.getLeftJoystick = function () {
  14641. return this._leftjoystick;
  14642. };
  14643. /**
  14644. * Gets the right stick of the virtual joystick.
  14645. * @returns The virtual Joystick
  14646. */
  14647. FreeCameraVirtualJoystickInput.prototype.getRightJoystick = function () {
  14648. return this._rightjoystick;
  14649. };
  14650. /**
  14651. * Update the current camera state depending on the inputs that have been used this frame.
  14652. * This is a dynamically created lambda to avoid the performance penalty of looping for inputs in the render loop.
  14653. */
  14654. FreeCameraVirtualJoystickInput.prototype.checkInputs = function () {
  14655. if (this._leftjoystick) {
  14656. var camera = this.camera;
  14657. var speed = camera._computeLocalCameraSpeed() * 50;
  14658. var cameraTransform = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].RotationYawPitchRoll(camera.rotation.y, camera.rotation.x, 0);
  14659. 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);
  14660. camera.cameraDirection = camera.cameraDirection.add(deltaTransform);
  14661. camera.cameraRotation = camera.cameraRotation.addVector3(this._rightjoystick.deltaPosition);
  14662. if (!this._leftjoystick.pressed) {
  14663. this._leftjoystick.deltaPosition = this._leftjoystick.deltaPosition.scale(0.9);
  14664. }
  14665. if (!this._rightjoystick.pressed) {
  14666. this._rightjoystick.deltaPosition = this._rightjoystick.deltaPosition.scale(0.9);
  14667. }
  14668. }
  14669. };
  14670. /**
  14671. * Attach the input controls to a specific dom element to get the input from.
  14672. * @param element Defines the element the controls should be listened from
  14673. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  14674. */
  14675. FreeCameraVirtualJoystickInput.prototype.attachControl = function (element, noPreventDefault) {
  14676. this._leftjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](true);
  14677. this._leftjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Z);
  14678. this._leftjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14679. this._leftjoystick.setJoystickSensibility(0.15);
  14680. this._rightjoystick = new _Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"](false);
  14681. this._rightjoystick.setAxisForUpDown(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].X);
  14682. this._rightjoystick.setAxisForLeftRight(_Misc_virtualJoystick__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"].Y);
  14683. this._rightjoystick.reverseUpDown = true;
  14684. this._rightjoystick.setJoystickSensibility(0.05);
  14685. this._rightjoystick.setJoystickColor("yellow");
  14686. };
  14687. /**
  14688. * Detach the current controls from the specified dom element.
  14689. * @param element Defines the element to stop listening the inputs from
  14690. */
  14691. FreeCameraVirtualJoystickInput.prototype.detachControl = function (element) {
  14692. this._leftjoystick.releaseCanvas();
  14693. this._rightjoystick.releaseCanvas();
  14694. };
  14695. /**
  14696. * Gets the class name of the current intput.
  14697. * @returns the class name
  14698. */
  14699. FreeCameraVirtualJoystickInput.prototype.getClassName = function () {
  14700. return "FreeCameraVirtualJoystickInput";
  14701. };
  14702. /**
  14703. * Get the friendly name associated with the input class.
  14704. * @returns the input friendly name
  14705. */
  14706. FreeCameraVirtualJoystickInput.prototype.getSimpleName = function () {
  14707. return "virtualJoystick";
  14708. };
  14709. return FreeCameraVirtualJoystickInput;
  14710. }());
  14711. _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]["FreeCameraVirtualJoystickInput"] = FreeCameraVirtualJoystickInput;
  14712. /***/ }),
  14713. /***/ "./Cameras/Inputs/index.ts":
  14714. /*!*********************************!*\
  14715. !*** ./Cameras/Inputs/index.ts ***!
  14716. \*********************************/
  14717. /*! exports provided: ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput */
  14718. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14719. "use strict";
  14720. __webpack_require__.r(__webpack_exports__);
  14721. /* harmony import */ var _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  14722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  14723. /* harmony import */ var _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  14724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraKeyboardMoveInput"]; });
  14725. /* harmony import */ var _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  14726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraMouseWheelInput"]; });
  14727. /* harmony import */ var _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  14728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraPointersInput"]; });
  14729. /* harmony import */ var _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  14730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__["ArcRotateCameraVRDeviceOrientationInput"]; });
  14731. /* harmony import */ var _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  14732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_5__["FlyCameraKeyboardInput"]; });
  14733. /* harmony import */ var _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  14734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_6__["FlyCameraMouseInput"]; });
  14735. /* harmony import */ var _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  14736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  14737. /* harmony import */ var _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  14738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_8__["FreeCameraGamepadInput"]; });
  14739. /* harmony import */ var _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  14740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_9__["FreeCameraKeyboardMoveInput"]; });
  14741. /* harmony import */ var _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  14742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_10__["FreeCameraMouseInput"]; });
  14743. /* harmony import */ var _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  14744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_11__["FreeCameraTouchInput"]; });
  14745. /* harmony import */ var _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  14746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_12__["FreeCameraVirtualJoystickInput"]; });
  14747. /***/ }),
  14748. /***/ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts":
  14749. /*!*********************************************************!*\
  14750. !*** ./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts ***!
  14751. \*********************************************************/
  14752. /*! no exports provided */
  14753. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14754. "use strict";
  14755. __webpack_require__.r(__webpack_exports__);
  14756. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14757. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14758. /* harmony import */ var _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  14759. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicAnaglyphRigMode = function (camera) {
  14760. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14761. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_2__["AnaglyphPostProcess"](camera.name + "_anaglyph", 1.0, camera._rigCameras);
  14762. };
  14763. /***/ }),
  14764. /***/ "./Cameras/RigModes/stereoscopicRigMode.ts":
  14765. /*!*************************************************!*\
  14766. !*** ./Cameras/RigModes/stereoscopicRigMode.ts ***!
  14767. \*************************************************/
  14768. /*! no exports provided */
  14769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14770. "use strict";
  14771. __webpack_require__.r(__webpack_exports__);
  14772. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14773. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  14774. /* harmony import */ var _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  14775. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setStereoscopicRigMode = function (camera) {
  14776. 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;
  14777. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_1__["PassPostProcess"](camera.name + "_passthru", 1.0, camera._rigCameras[0]);
  14778. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_2__["StereoscopicInterlacePostProcess"](camera.name + "_stereoInterlace", camera._rigCameras, isStereoscopicHoriz);
  14779. };
  14780. /***/ }),
  14781. /***/ "./Cameras/RigModes/vrRigMode.ts":
  14782. /*!***************************************!*\
  14783. !*** ./Cameras/RigModes/vrRigMode.ts ***!
  14784. \***************************************/
  14785. /*! no exports provided */
  14786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14787. "use strict";
  14788. __webpack_require__.r(__webpack_exports__);
  14789. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14790. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14791. /* harmony import */ var _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../PostProcesses/vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  14792. /* harmony import */ var _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../VR/vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  14793. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setVRRigMode = function (camera, rigParams) {
  14794. var metrics = rigParams.vrCameraMetrics || _VR_vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault();
  14795. camera._rigCameras[0]._cameraRigParams.vrMetrics = metrics;
  14796. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14797. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14798. camera._rigCameras[0]._cameraRigParams.vrHMatrix = metrics.leftHMatrix;
  14799. camera._rigCameras[0]._cameraRigParams.vrPreViewMatrix = metrics.leftPreViewMatrix;
  14800. camera._rigCameras[0].getProjectionMatrix = camera._rigCameras[0]._getVRProjectionMatrix;
  14801. camera._rigCameras[1]._cameraRigParams.vrMetrics = metrics;
  14802. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14803. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14804. camera._rigCameras[1]._cameraRigParams.vrHMatrix = metrics.rightHMatrix;
  14805. camera._rigCameras[1]._cameraRigParams.vrPreViewMatrix = metrics.rightPreViewMatrix;
  14806. camera._rigCameras[1].getProjectionMatrix = camera._rigCameras[1]._getVRProjectionMatrix;
  14807. if (metrics.compensateDistortion) {
  14808. camera._rigCameras[0]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Left", camera._rigCameras[0], false, metrics);
  14809. camera._rigCameras[1]._rigPostProcess = new _PostProcesses_vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_2__["VRDistortionCorrectionPostProcess"]("VR_Distort_Compensation_Right", camera._rigCameras[1], true, metrics);
  14810. }
  14811. };
  14812. /***/ }),
  14813. /***/ "./Cameras/RigModes/webVRRigMode.ts":
  14814. /*!******************************************!*\
  14815. !*** ./Cameras/RigModes/webVRRigMode.ts ***!
  14816. \******************************************/
  14817. /*! no exports provided */
  14818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14819. "use strict";
  14820. __webpack_require__.r(__webpack_exports__);
  14821. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../camera */ "./Cameras/camera.ts");
  14822. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14823. _camera__WEBPACK_IMPORTED_MODULE_0__["Camera"]._setWebVRRigMode = function (camera, rigParams) {
  14824. if (rigParams.vrDisplay) {
  14825. var leftEye = rigParams.vrDisplay.getEyeParameters('left');
  14826. var rightEye = rigParams.vrDisplay.getEyeParameters('right');
  14827. //Left eye
  14828. camera._rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  14829. camera._rigCameras[0].setCameraRigParameter("left", true);
  14830. //leaving this for future reference
  14831. camera._rigCameras[0].setCameraRigParameter("specs", rigParams.specs);
  14832. camera._rigCameras[0].setCameraRigParameter("eyeParameters", leftEye);
  14833. camera._rigCameras[0].setCameraRigParameter("frameData", rigParams.frameData);
  14834. camera._rigCameras[0].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14835. camera._rigCameras[0]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14836. camera._rigCameras[0].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14837. camera._rigCameras[0].parent = camera;
  14838. camera._rigCameras[0]._getViewMatrix = camera._getWebVRViewMatrix;
  14839. //Right eye
  14840. camera._rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  14841. camera._rigCameras[1].setCameraRigParameter('eyeParameters', rightEye);
  14842. camera._rigCameras[1].setCameraRigParameter("specs", rigParams.specs);
  14843. camera._rigCameras[1].setCameraRigParameter("frameData", rigParams.frameData);
  14844. camera._rigCameras[1].setCameraRigParameter("parentCamera", rigParams.parentCamera);
  14845. camera._rigCameras[1]._cameraRigParams.vrWorkMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  14846. camera._rigCameras[1].getProjectionMatrix = camera._getWebVRProjectionMatrix;
  14847. camera._rigCameras[1].parent = camera;
  14848. camera._rigCameras[1]._getViewMatrix = camera._getWebVRViewMatrix;
  14849. if (_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].UseAlternateWebVRRendering) {
  14850. camera._rigCameras[1]._skipRendering = true;
  14851. camera._rigCameras[0]._alternateCamera = camera._rigCameras[1];
  14852. }
  14853. }
  14854. };
  14855. /***/ }),
  14856. /***/ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts":
  14857. /*!*********************************************************!*\
  14858. !*** ./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts ***!
  14859. \*********************************************************/
  14860. /*! exports provided: AnaglyphArcRotateCamera */
  14861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14862. "use strict";
  14863. __webpack_require__.r(__webpack_exports__);
  14864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return AnaglyphArcRotateCamera; });
  14865. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14866. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14867. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  14868. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14869. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14870. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14871. // Side effect import to define the stereoscopic mode.
  14872. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphArcRotateCamera", function (name, scene, options) {
  14873. return function () { return new AnaglyphArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14874. });
  14875. /**
  14876. * Camera used to simulate anaglyphic rendering (based on ArcRotateCamera)
  14877. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14878. */
  14879. var AnaglyphArcRotateCamera = /** @class */ (function (_super) {
  14880. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphArcRotateCamera, _super);
  14881. /**
  14882. * Creates a new AnaglyphArcRotateCamera
  14883. * @param name defines camera name
  14884. * @param alpha defines alpha angle (in radians)
  14885. * @param beta defines beta angle (in radians)
  14886. * @param radius defines radius
  14887. * @param target defines camera target
  14888. * @param interaxialDistance defines distance between each color axis
  14889. * @param scene defines the hosting scene
  14890. */
  14891. function AnaglyphArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, scene) {
  14892. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  14893. _this.interaxialDistance = interaxialDistance;
  14894. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14895. return _this;
  14896. }
  14897. /**
  14898. * Gets camera class name
  14899. * @returns AnaglyphArcRotateCamera
  14900. */
  14901. AnaglyphArcRotateCamera.prototype.getClassName = function () {
  14902. return "AnaglyphArcRotateCamera";
  14903. };
  14904. return AnaglyphArcRotateCamera;
  14905. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  14906. /***/ }),
  14907. /***/ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts":
  14908. /*!****************************************************!*\
  14909. !*** ./Cameras/Stereoscopic/anaglyphFreeCamera.ts ***!
  14910. \****************************************************/
  14911. /*! exports provided: AnaglyphFreeCamera */
  14912. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14913. "use strict";
  14914. __webpack_require__.r(__webpack_exports__);
  14915. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return AnaglyphFreeCamera; });
  14916. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14917. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14918. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  14919. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14920. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14921. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14922. // Side effect import to define the stereoscopic mode.
  14923. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphFreeCamera", function (name, scene, options) {
  14924. return function () { return new AnaglyphFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14925. });
  14926. /**
  14927. * Camera used to simulate anaglyphic rendering (based on FreeCamera)
  14928. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14929. */
  14930. var AnaglyphFreeCamera = /** @class */ (function (_super) {
  14931. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphFreeCamera, _super);
  14932. /**
  14933. * Creates a new AnaglyphFreeCamera
  14934. * @param name defines camera name
  14935. * @param position defines initial position
  14936. * @param interaxialDistance defines distance between each color axis
  14937. * @param scene defines the hosting scene
  14938. */
  14939. function AnaglyphFreeCamera(name, position, interaxialDistance, scene) {
  14940. var _this = _super.call(this, name, position, scene) || this;
  14941. _this.interaxialDistance = interaxialDistance;
  14942. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14943. return _this;
  14944. }
  14945. /**
  14946. * Gets camera class name
  14947. * @returns AnaglyphFreeCamera
  14948. */
  14949. AnaglyphFreeCamera.prototype.getClassName = function () {
  14950. return "AnaglyphFreeCamera";
  14951. };
  14952. return AnaglyphFreeCamera;
  14953. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  14954. /***/ }),
  14955. /***/ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts":
  14956. /*!*******************************************************!*\
  14957. !*** ./Cameras/Stereoscopic/anaglyphGamepadCamera.ts ***!
  14958. \*******************************************************/
  14959. /*! exports provided: AnaglyphGamepadCamera */
  14960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  14961. "use strict";
  14962. __webpack_require__.r(__webpack_exports__);
  14963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return AnaglyphGamepadCamera; });
  14964. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  14965. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  14966. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  14967. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  14968. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  14969. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  14970. // Side effect import to define the stereoscopic mode.
  14971. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphGamepadCamera", function (name, scene, options) {
  14972. return function () { return new AnaglyphGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  14973. });
  14974. /**
  14975. * Camera used to simulate anaglyphic rendering (based on GamepadCamera)
  14976. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  14977. */
  14978. var AnaglyphGamepadCamera = /** @class */ (function (_super) {
  14979. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphGamepadCamera, _super);
  14980. /**
  14981. * Creates a new AnaglyphGamepadCamera
  14982. * @param name defines camera name
  14983. * @param position defines initial position
  14984. * @param interaxialDistance defines distance between each color axis
  14985. * @param scene defines the hosting scene
  14986. */
  14987. function AnaglyphGamepadCamera(name, position, interaxialDistance, scene) {
  14988. var _this = _super.call(this, name, position, scene) || this;
  14989. _this.interaxialDistance = interaxialDistance;
  14990. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  14991. return _this;
  14992. }
  14993. /**
  14994. * Gets camera class name
  14995. * @returns AnaglyphGamepadCamera
  14996. */
  14997. AnaglyphGamepadCamera.prototype.getClassName = function () {
  14998. return "AnaglyphGamepadCamera";
  14999. };
  15000. return AnaglyphGamepadCamera;
  15001. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15002. /***/ }),
  15003. /***/ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts":
  15004. /*!*********************************************************!*\
  15005. !*** ./Cameras/Stereoscopic/anaglyphUniversalCamera.ts ***!
  15006. \*********************************************************/
  15007. /*! exports provided: AnaglyphUniversalCamera */
  15008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15009. "use strict";
  15010. __webpack_require__.r(__webpack_exports__);
  15011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return AnaglyphUniversalCamera; });
  15012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15013. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15014. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15015. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15016. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15017. /* harmony import */ var _RigModes_stereoscopicAnaglyphRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicAnaglyphRigMode */ "./Cameras/RigModes/stereoscopicAnaglyphRigMode.ts");
  15018. // Side effect import to define the stereoscopic mode.
  15019. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("AnaglyphUniversalCamera", function (name, scene, options) {
  15020. return function () { return new AnaglyphUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, scene); };
  15021. });
  15022. /**
  15023. * Camera used to simulate anaglyphic rendering (based on UniversalCamera)
  15024. * @see http://doc.babylonjs.com/features/cameras#anaglyph-cameras
  15025. */
  15026. var AnaglyphUniversalCamera = /** @class */ (function (_super) {
  15027. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphUniversalCamera, _super);
  15028. /**
  15029. * Creates a new AnaglyphUniversalCamera
  15030. * @param name defines camera name
  15031. * @param position defines initial position
  15032. * @param interaxialDistance defines distance between each color axis
  15033. * @param scene defines the hosting scene
  15034. */
  15035. function AnaglyphUniversalCamera(name, position, interaxialDistance, scene) {
  15036. var _this = _super.call(this, name, position, scene) || this;
  15037. _this.interaxialDistance = interaxialDistance;
  15038. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH, { interaxialDistance: interaxialDistance });
  15039. return _this;
  15040. }
  15041. /**
  15042. * Gets camera class name
  15043. * @returns AnaglyphUniversalCamera
  15044. */
  15045. AnaglyphUniversalCamera.prototype.getClassName = function () {
  15046. return "AnaglyphUniversalCamera";
  15047. };
  15048. return AnaglyphUniversalCamera;
  15049. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15050. /***/ }),
  15051. /***/ "./Cameras/Stereoscopic/index.ts":
  15052. /*!***************************************!*\
  15053. !*** ./Cameras/Stereoscopic/index.ts ***!
  15054. \***************************************/
  15055. /*! exports provided: AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera */
  15056. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15057. "use strict";
  15058. __webpack_require__.r(__webpack_exports__);
  15059. /* harmony import */ var _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphArcRotateCamera */ "./Cameras/Stereoscopic/anaglyphArcRotateCamera.ts");
  15060. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _anaglyphArcRotateCamera__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  15061. /* harmony import */ var _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./anaglyphFreeCamera */ "./Cameras/Stereoscopic/anaglyphFreeCamera.ts");
  15062. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _anaglyphFreeCamera__WEBPACK_IMPORTED_MODULE_1__["AnaglyphFreeCamera"]; });
  15063. /* harmony import */ var _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./anaglyphGamepadCamera */ "./Cameras/Stereoscopic/anaglyphGamepadCamera.ts");
  15064. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _anaglyphGamepadCamera__WEBPACK_IMPORTED_MODULE_2__["AnaglyphGamepadCamera"]; });
  15065. /* harmony import */ var _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./anaglyphUniversalCamera */ "./Cameras/Stereoscopic/anaglyphUniversalCamera.ts");
  15066. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _anaglyphUniversalCamera__WEBPACK_IMPORTED_MODULE_3__["AnaglyphUniversalCamera"]; });
  15067. /* harmony import */ var _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./stereoscopicArcRotateCamera */ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts");
  15068. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _stereoscopicArcRotateCamera__WEBPACK_IMPORTED_MODULE_4__["StereoscopicArcRotateCamera"]; });
  15069. /* harmony import */ var _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./stereoscopicFreeCamera */ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts");
  15070. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _stereoscopicFreeCamera__WEBPACK_IMPORTED_MODULE_5__["StereoscopicFreeCamera"]; });
  15071. /* harmony import */ var _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./stereoscopicGamepadCamera */ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts");
  15072. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _stereoscopicGamepadCamera__WEBPACK_IMPORTED_MODULE_6__["StereoscopicGamepadCamera"]; });
  15073. /* harmony import */ var _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./stereoscopicUniversalCamera */ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts");
  15074. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _stereoscopicUniversalCamera__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  15075. /***/ }),
  15076. /***/ "./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts":
  15077. /*!*************************************************************!*\
  15078. !*** ./Cameras/Stereoscopic/stereoscopicArcRotateCamera.ts ***!
  15079. \*************************************************************/
  15080. /*! exports provided: StereoscopicArcRotateCamera */
  15081. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15082. "use strict";
  15083. __webpack_require__.r(__webpack_exports__);
  15084. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return StereoscopicArcRotateCamera; });
  15085. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15086. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15087. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15088. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15089. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15090. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15091. // Side effect import to define the stereoscopic mode.
  15092. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicArcRotateCamera", function (name, scene, options) {
  15093. return function () { return new StereoscopicArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15094. });
  15095. /**
  15096. * Camera used to simulate stereoscopic rendering (based on ArcRotateCamera)
  15097. * @see http://doc.babylonjs.com/features/cameras
  15098. */
  15099. var StereoscopicArcRotateCamera = /** @class */ (function (_super) {
  15100. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicArcRotateCamera, _super);
  15101. /**
  15102. * Creates a new StereoscopicArcRotateCamera
  15103. * @param name defines camera name
  15104. * @param alpha defines alpha angle (in radians)
  15105. * @param beta defines beta angle (in radians)
  15106. * @param radius defines radius
  15107. * @param target defines camera target
  15108. * @param interaxialDistance defines distance between each color axis
  15109. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15110. * @param scene defines the hosting scene
  15111. */
  15112. function StereoscopicArcRotateCamera(name, alpha, beta, radius, target, interaxialDistance, isStereoscopicSideBySide, scene) {
  15113. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15114. _this.interaxialDistance = interaxialDistance;
  15115. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15116. _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 });
  15117. return _this;
  15118. }
  15119. /**
  15120. * Gets camera class name
  15121. * @returns StereoscopicArcRotateCamera
  15122. */
  15123. StereoscopicArcRotateCamera.prototype.getClassName = function () {
  15124. return "StereoscopicArcRotateCamera";
  15125. };
  15126. return StereoscopicArcRotateCamera;
  15127. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15128. /***/ }),
  15129. /***/ "./Cameras/Stereoscopic/stereoscopicFreeCamera.ts":
  15130. /*!********************************************************!*\
  15131. !*** ./Cameras/Stereoscopic/stereoscopicFreeCamera.ts ***!
  15132. \********************************************************/
  15133. /*! exports provided: StereoscopicFreeCamera */
  15134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15135. "use strict";
  15136. __webpack_require__.r(__webpack_exports__);
  15137. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return StereoscopicFreeCamera; });
  15138. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15139. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15140. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15141. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15142. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15143. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15144. // Side effect import to define the stereoscopic mode.
  15145. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15146. return function () { return new StereoscopicFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15147. });
  15148. /**
  15149. * Camera used to simulate stereoscopic rendering (based on FreeCamera)
  15150. * @see http://doc.babylonjs.com/features/cameras
  15151. */
  15152. var StereoscopicFreeCamera = /** @class */ (function (_super) {
  15153. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicFreeCamera, _super);
  15154. /**
  15155. * Creates a new StereoscopicFreeCamera
  15156. * @param name defines camera name
  15157. * @param position defines initial position
  15158. * @param interaxialDistance defines distance between each color axis
  15159. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15160. * @param scene defines the hosting scene
  15161. */
  15162. function StereoscopicFreeCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15163. var _this = _super.call(this, name, position, scene) || this;
  15164. _this.interaxialDistance = interaxialDistance;
  15165. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15166. _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 });
  15167. return _this;
  15168. }
  15169. /**
  15170. * Gets camera class name
  15171. * @returns StereoscopicFreeCamera
  15172. */
  15173. StereoscopicFreeCamera.prototype.getClassName = function () {
  15174. return "StereoscopicFreeCamera";
  15175. };
  15176. return StereoscopicFreeCamera;
  15177. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  15178. /***/ }),
  15179. /***/ "./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts":
  15180. /*!***********************************************************!*\
  15181. !*** ./Cameras/Stereoscopic/stereoscopicGamepadCamera.ts ***!
  15182. \***********************************************************/
  15183. /*! exports provided: StereoscopicGamepadCamera */
  15184. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15185. "use strict";
  15186. __webpack_require__.r(__webpack_exports__);
  15187. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return StereoscopicGamepadCamera; });
  15188. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15189. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15190. /* harmony import */ var _Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/gamepadCamera */ "./Cameras/gamepadCamera.ts");
  15191. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15192. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15193. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15194. // Side effect import to define the stereoscopic mode.
  15195. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicGamepadCamera", function (name, scene, options) {
  15196. return function () { return new StereoscopicGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15197. });
  15198. /**
  15199. * Camera used to simulate stereoscopic rendering (based on GamepadCamera)
  15200. * @see http://doc.babylonjs.com/features/cameras
  15201. */
  15202. var StereoscopicGamepadCamera = /** @class */ (function (_super) {
  15203. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicGamepadCamera, _super);
  15204. /**
  15205. * Creates a new StereoscopicGamepadCamera
  15206. * @param name defines camera name
  15207. * @param position defines initial position
  15208. * @param interaxialDistance defines distance between each color axis
  15209. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15210. * @param scene defines the hosting scene
  15211. */
  15212. function StereoscopicGamepadCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15213. var _this = _super.call(this, name, position, scene) || this;
  15214. _this.interaxialDistance = interaxialDistance;
  15215. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15216. _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 });
  15217. return _this;
  15218. }
  15219. /**
  15220. * Gets camera class name
  15221. * @returns StereoscopicGamepadCamera
  15222. */
  15223. StereoscopicGamepadCamera.prototype.getClassName = function () {
  15224. return "StereoscopicGamepadCamera";
  15225. };
  15226. return StereoscopicGamepadCamera;
  15227. }(_Cameras_gamepadCamera__WEBPACK_IMPORTED_MODULE_2__["GamepadCamera"]));
  15228. /***/ }),
  15229. /***/ "./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts":
  15230. /*!*************************************************************!*\
  15231. !*** ./Cameras/Stereoscopic/stereoscopicUniversalCamera.ts ***!
  15232. \*************************************************************/
  15233. /*! exports provided: StereoscopicUniversalCamera */
  15234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15235. "use strict";
  15236. __webpack_require__.r(__webpack_exports__);
  15237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return StereoscopicUniversalCamera; });
  15238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15239. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15240. /* harmony import */ var _Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/universalCamera */ "./Cameras/universalCamera.ts");
  15241. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15242. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15243. /* harmony import */ var _RigModes_stereoscopicRigMode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../RigModes/stereoscopicRigMode */ "./Cameras/RigModes/stereoscopicRigMode.ts");
  15244. // Side effect import to define the stereoscopic mode.
  15245. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("StereoscopicFreeCamera", function (name, scene, options) {
  15246. return function () { return new StereoscopicUniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), options.interaxial_distance, options.isStereoscopicSideBySide, scene); };
  15247. });
  15248. /**
  15249. * Camera used to simulate stereoscopic rendering (based on UniversalCamera)
  15250. * @see http://doc.babylonjs.com/features/cameras
  15251. */
  15252. var StereoscopicUniversalCamera = /** @class */ (function (_super) {
  15253. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicUniversalCamera, _super);
  15254. /**
  15255. * Creates a new StereoscopicUniversalCamera
  15256. * @param name defines camera name
  15257. * @param position defines initial position
  15258. * @param interaxialDistance defines distance between each color axis
  15259. * @param isStereoscopicSideBySide defines is stereoscopic is done side by side or over under
  15260. * @param scene defines the hosting scene
  15261. */
  15262. function StereoscopicUniversalCamera(name, position, interaxialDistance, isStereoscopicSideBySide, scene) {
  15263. var _this = _super.call(this, name, position, scene) || this;
  15264. _this.interaxialDistance = interaxialDistance;
  15265. _this.isStereoscopicSideBySide = isStereoscopicSideBySide;
  15266. _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 });
  15267. return _this;
  15268. }
  15269. /**
  15270. * Gets camera class name
  15271. * @returns StereoscopicUniversalCamera
  15272. */
  15273. StereoscopicUniversalCamera.prototype.getClassName = function () {
  15274. return "StereoscopicUniversalCamera";
  15275. };
  15276. return StereoscopicUniversalCamera;
  15277. }(_Cameras_universalCamera__WEBPACK_IMPORTED_MODULE_2__["UniversalCamera"]));
  15278. /***/ }),
  15279. /***/ "./Cameras/VR/index.ts":
  15280. /*!*****************************!*\
  15281. !*** ./Cameras/VR/index.ts ***!
  15282. \*****************************/
  15283. /*! exports provided: VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera */
  15284. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15285. "use strict";
  15286. __webpack_require__.r(__webpack_exports__);
  15287. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  15289. /* harmony import */ var _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationArcRotateCamera */ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts");
  15290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _vrDeviceOrientationArcRotateCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationArcRotateCamera"]; });
  15291. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_2__["VRDeviceOrientationFreeCamera"]; });
  15293. /* harmony import */ var _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrDeviceOrientationGamepadCamera */ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts");
  15294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _vrDeviceOrientationGamepadCamera__WEBPACK_IMPORTED_MODULE_3__["VRDeviceOrientationGamepadCamera"]; });
  15295. /* harmony import */ var _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  15296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _vrExperienceHelper__WEBPACK_IMPORTED_MODULE_4__["VRExperienceHelper"]; });
  15297. /* harmony import */ var _webVRCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _webVRCamera__WEBPACK_IMPORTED_MODULE_5__["WebVRFreeCamera"]; });
  15299. /***/ }),
  15300. /***/ "./Cameras/VR/vrCameraMetrics.ts":
  15301. /*!***************************************!*\
  15302. !*** ./Cameras/VR/vrCameraMetrics.ts ***!
  15303. \***************************************/
  15304. /*! exports provided: VRCameraMetrics */
  15305. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15306. "use strict";
  15307. __webpack_require__.r(__webpack_exports__);
  15308. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return VRCameraMetrics; });
  15309. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15310. /**
  15311. * This represents all the required metrics to create a VR camera.
  15312. * @see http://doc.babylonjs.com/babylon101/cameras#device-orientation-camera
  15313. */
  15314. var VRCameraMetrics = /** @class */ (function () {
  15315. function VRCameraMetrics() {
  15316. /**
  15317. * Define if the current vr camera should compensate the distortion of the lense or not.
  15318. */
  15319. this.compensateDistortion = true;
  15320. }
  15321. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatio", {
  15322. /**
  15323. * Gets the rendering aspect ratio based on the provided resolutions.
  15324. */
  15325. get: function () {
  15326. return this.hResolution / (2 * this.vResolution);
  15327. },
  15328. enumerable: true,
  15329. configurable: true
  15330. });
  15331. Object.defineProperty(VRCameraMetrics.prototype, "aspectRatioFov", {
  15332. /**
  15333. * Gets the aspect ratio based on the FOV, scale factors, and real screen sizes.
  15334. */
  15335. get: function () {
  15336. return (2 * Math.atan((this.postProcessScaleFactor * this.vScreenSize) / (2 * this.eyeToScreenDistance)));
  15337. },
  15338. enumerable: true,
  15339. configurable: true
  15340. });
  15341. Object.defineProperty(VRCameraMetrics.prototype, "leftHMatrix", {
  15342. /**
  15343. * @hidden
  15344. */
  15345. get: function () {
  15346. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15347. var h = (4 * meters) / this.hScreenSize;
  15348. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(h, 0, 0);
  15349. },
  15350. enumerable: true,
  15351. configurable: true
  15352. });
  15353. Object.defineProperty(VRCameraMetrics.prototype, "rightHMatrix", {
  15354. /**
  15355. * @hidden
  15356. */
  15357. get: function () {
  15358. var meters = (this.hScreenSize / 4) - (this.lensSeparationDistance / 2);
  15359. var h = (4 * meters) / this.hScreenSize;
  15360. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-h, 0, 0);
  15361. },
  15362. enumerable: true,
  15363. configurable: true
  15364. });
  15365. Object.defineProperty(VRCameraMetrics.prototype, "leftPreViewMatrix", {
  15366. /**
  15367. * @hidden
  15368. */
  15369. get: function () {
  15370. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(0.5 * this.interpupillaryDistance, 0, 0);
  15371. },
  15372. enumerable: true,
  15373. configurable: true
  15374. });
  15375. Object.defineProperty(VRCameraMetrics.prototype, "rightPreViewMatrix", {
  15376. /**
  15377. * @hidden
  15378. */
  15379. get: function () {
  15380. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Translation(-0.5 * this.interpupillaryDistance, 0, 0);
  15381. },
  15382. enumerable: true,
  15383. configurable: true
  15384. });
  15385. /**
  15386. * Get the default VRMetrics based on the most generic setup.
  15387. * @returns the default vr metrics
  15388. */
  15389. VRCameraMetrics.GetDefault = function () {
  15390. var result = new VRCameraMetrics();
  15391. result.hResolution = 1280;
  15392. result.vResolution = 800;
  15393. result.hScreenSize = 0.149759993;
  15394. result.vScreenSize = 0.0935999975;
  15395. result.vScreenCenter = 0.0467999987;
  15396. result.eyeToScreenDistance = 0.0410000011;
  15397. result.lensSeparationDistance = 0.0635000020;
  15398. result.interpupillaryDistance = 0.0640000030;
  15399. result.distortionK = [1.0, 0.219999999, 0.239999995, 0.0];
  15400. result.chromaAbCorrection = [0.995999992, -0.00400000019, 1.01400006, 0.0];
  15401. result.postProcessScaleFactor = 1.714605507808412;
  15402. result.lensCenterOffset = 0.151976421;
  15403. return result;
  15404. };
  15405. return VRCameraMetrics;
  15406. }());
  15407. /***/ }),
  15408. /***/ "./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts":
  15409. /*!**********************************************************!*\
  15410. !*** ./Cameras/VR/vrDeviceOrientationArcRotateCamera.ts ***!
  15411. \**********************************************************/
  15412. /*! exports provided: VRDeviceOrientationArcRotateCamera */
  15413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15414. "use strict";
  15415. __webpack_require__.r(__webpack_exports__);
  15416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return VRDeviceOrientationArcRotateCamera; });
  15417. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15418. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15419. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  15420. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15421. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15422. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15423. /* harmony import */ var _Inputs_arcRotateCameraVRDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Inputs/arcRotateCameraVRDeviceOrientationInput */ "./Cameras/Inputs/arcRotateCameraVRDeviceOrientationInput.ts");
  15424. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15425. // Side effect import to define the stereoscopic mode.
  15426. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15427. return function () { return new VRDeviceOrientationArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15428. });
  15429. /**
  15430. * Camera used to simulate VR rendering (based on ArcRotateCamera)
  15431. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15432. */
  15433. var VRDeviceOrientationArcRotateCamera = /** @class */ (function (_super) {
  15434. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationArcRotateCamera, _super);
  15435. /**
  15436. * Creates a new VRDeviceOrientationArcRotateCamera
  15437. * @param name defines camera name
  15438. * @param alpha defines the camera rotation along the logitudinal axis
  15439. * @param beta defines the camera rotation along the latitudinal axis
  15440. * @param radius defines the camera distance from its target
  15441. * @param target defines the camera target
  15442. * @param scene defines the scene the camera belongs to
  15443. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15444. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15445. */
  15446. function VRDeviceOrientationArcRotateCamera(name, alpha, beta, radius, target, scene, compensateDistortion, vrCameraMetrics) {
  15447. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15448. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15449. var _this = _super.call(this, name, alpha, beta, radius, target, scene) || this;
  15450. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15451. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15452. _this.inputs.addVRDeviceOrientation();
  15453. return _this;
  15454. }
  15455. /**
  15456. * Gets camera class name
  15457. * @returns VRDeviceOrientationArcRotateCamera
  15458. */
  15459. VRDeviceOrientationArcRotateCamera.prototype.getClassName = function () {
  15460. return "VRDeviceOrientationArcRotateCamera";
  15461. };
  15462. return VRDeviceOrientationArcRotateCamera;
  15463. }(_Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"]));
  15464. /***/ }),
  15465. /***/ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts":
  15466. /*!*****************************************************!*\
  15467. !*** ./Cameras/VR/vrDeviceOrientationFreeCamera.ts ***!
  15468. \*****************************************************/
  15469. /*! exports provided: VRDeviceOrientationFreeCamera */
  15470. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15471. "use strict";
  15472. __webpack_require__.r(__webpack_exports__);
  15473. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return VRDeviceOrientationFreeCamera; });
  15474. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15475. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  15476. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15477. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15478. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15479. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15480. /* harmony import */ var _RigModes_vrRigMode__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../RigModes/vrRigMode */ "./Cameras/RigModes/vrRigMode.ts");
  15481. // Side effect import to define the stereoscopic mode.
  15482. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("VRDeviceOrientationFreeCamera", function (name, scene) {
  15483. return function () { return new VRDeviceOrientationFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  15484. });
  15485. /**
  15486. * Camera used to simulate VR rendering (based on FreeCamera)
  15487. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15488. */
  15489. var VRDeviceOrientationFreeCamera = /** @class */ (function (_super) {
  15490. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationFreeCamera, _super);
  15491. /**
  15492. * Creates a new VRDeviceOrientationFreeCamera
  15493. * @param name defines camera name
  15494. * @param position defines the start position of the camera
  15495. * @param scene defines the scene the camera belongs to
  15496. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15497. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15498. */
  15499. function VRDeviceOrientationFreeCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15500. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15501. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_3__["VRCameraMetrics"].GetDefault(); }
  15502. var _this = _super.call(this, name, position, scene) || this;
  15503. vrCameraMetrics.compensateDistortion = compensateDistortion;
  15504. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].RIG_MODE_VR, { vrCameraMetrics: vrCameraMetrics });
  15505. return _this;
  15506. }
  15507. /**
  15508. * Gets camera class name
  15509. * @returns VRDeviceOrientationFreeCamera
  15510. */
  15511. VRDeviceOrientationFreeCamera.prototype.getClassName = function () {
  15512. return "VRDeviceOrientationFreeCamera";
  15513. };
  15514. return VRDeviceOrientationFreeCamera;
  15515. }(_Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_2__["DeviceOrientationCamera"]));
  15516. /***/ }),
  15517. /***/ "./Cameras/VR/vrDeviceOrientationGamepadCamera.ts":
  15518. /*!********************************************************!*\
  15519. !*** ./Cameras/VR/vrDeviceOrientationGamepadCamera.ts ***!
  15520. \********************************************************/
  15521. /*! exports provided: VRDeviceOrientationGamepadCamera */
  15522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15523. "use strict";
  15524. __webpack_require__.r(__webpack_exports__);
  15525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return VRDeviceOrientationGamepadCamera; });
  15526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15527. /* harmony import */ var _vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15528. /* harmony import */ var _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./vrCameraMetrics */ "./Cameras/VR/vrCameraMetrics.ts");
  15529. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15530. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../node */ "./node.ts");
  15531. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("VRDeviceOrientationGamepadCamera", function (name, scene) {
  15532. return function () { return new VRDeviceOrientationGamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  15533. });
  15534. /**
  15535. * Camera used to simulate VR rendering (based on VRDeviceOrientationFreeCamera)
  15536. * @see http://doc.babylonjs.com/babylon101/cameras#vr-device-orientation-cameras
  15537. */
  15538. var VRDeviceOrientationGamepadCamera = /** @class */ (function (_super) {
  15539. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDeviceOrientationGamepadCamera, _super);
  15540. /**
  15541. * Creates a new VRDeviceOrientationGamepadCamera
  15542. * @param name defines camera name
  15543. * @param position defines the start position of the camera
  15544. * @param scene defines the scene the camera belongs to
  15545. * @param compensateDistortion defines if the camera needs to compensate the lens distorsion
  15546. * @param vrCameraMetrics defines the vr metrics associated to the camera
  15547. */
  15548. function VRDeviceOrientationGamepadCamera(name, position, scene, compensateDistortion, vrCameraMetrics) {
  15549. if (compensateDistortion === void 0) { compensateDistortion = true; }
  15550. if (vrCameraMetrics === void 0) { vrCameraMetrics = _vrCameraMetrics__WEBPACK_IMPORTED_MODULE_2__["VRCameraMetrics"].GetDefault(); }
  15551. var _this = _super.call(this, name, position, scene, compensateDistortion, vrCameraMetrics) || this;
  15552. _this.inputs.addGamepad();
  15553. return _this;
  15554. }
  15555. /**
  15556. * Gets camera class name
  15557. * @returns VRDeviceOrientationGamepadCamera
  15558. */
  15559. VRDeviceOrientationGamepadCamera.prototype.getClassName = function () {
  15560. return "VRDeviceOrientationGamepadCamera";
  15561. };
  15562. return VRDeviceOrientationGamepadCamera;
  15563. }(_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_1__["VRDeviceOrientationFreeCamera"]));
  15564. /***/ }),
  15565. /***/ "./Cameras/VR/vrExperienceHelper.ts":
  15566. /*!******************************************!*\
  15567. !*** ./Cameras/VR/vrExperienceHelper.ts ***!
  15568. \******************************************/
  15569. /*! exports provided: VRExperienceHelper */
  15570. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  15571. "use strict";
  15572. __webpack_require__.r(__webpack_exports__);
  15573. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return VRExperienceHelper; });
  15574. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  15575. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  15576. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  15577. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  15578. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  15579. /* harmony import */ var _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Cameras/deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  15580. /* harmony import */ var _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Cameras/VR/vrDeviceOrientationFreeCamera */ "./Cameras/VR/vrDeviceOrientationFreeCamera.ts");
  15581. /* harmony import */ var _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Cameras/VR/webVRCamera */ "./Cameras/VR/webVRCamera.ts");
  15582. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Events/pointerEvents */ "./Events/pointerEvents.ts");
  15583. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  15584. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  15585. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  15586. /* harmony import */ var _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Gamepads/Controllers/webVRController */ "./Gamepads/Controllers/webVRController.ts");
  15587. /* harmony import */ var _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Gamepads/xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  15588. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  15589. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  15590. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  15591. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  15592. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  15593. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  15594. /* harmony import */ var _Animations_easing__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Animations/easing */ "./Animations/easing.ts");
  15595. /* harmony import */ var _Animations_animation__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Animations/animation */ "./Animations/animation.ts");
  15596. /* harmony import */ var _Meshes_Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Meshes/Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  15597. /* harmony import */ var _Meshes_Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../../Meshes/Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  15598. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  15599. /* harmony import */ var _Gamepads_gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../../Gamepads/gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  15600. /* harmony import */ var _Animations_animatable__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../../Animations/animatable */ "./Animations/animatable.ts");
  15601. var VRExperienceHelperGazer = /** @class */ (function () {
  15602. function VRExperienceHelperGazer(scene, gazeTrackerToClone) {
  15603. if (gazeTrackerToClone === void 0) { gazeTrackerToClone = null; }
  15604. this.scene = scene;
  15605. /** @hidden */
  15606. this._pointerDownOnMeshAsked = false;
  15607. /** @hidden */
  15608. this._isActionableMesh = false;
  15609. /** @hidden */
  15610. this._teleportationRequestInitiated = false;
  15611. /** @hidden */
  15612. this._teleportationBackRequestInitiated = false;
  15613. /** @hidden */
  15614. this._rotationRightAsked = false;
  15615. /** @hidden */
  15616. this._rotationLeftAsked = false;
  15617. /** @hidden */
  15618. this._dpadPressed = true;
  15619. /** @hidden */
  15620. this._activePointer = false;
  15621. this._id = VRExperienceHelperGazer._idCounter++;
  15622. // Gaze tracker
  15623. if (!gazeTrackerToClone) {
  15624. this._gazeTracker = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("gazeTracker", 0.0035, 0.0025, 20, scene, false);
  15625. this._gazeTracker.bakeCurrentTransformIntoVertices();
  15626. this._gazeTracker.isPickable = false;
  15627. this._gazeTracker.isVisible = false;
  15628. var targetMat = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("targetMat", scene);
  15629. targetMat.specularColor = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"].Black();
  15630. targetMat.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15631. targetMat.backFaceCulling = false;
  15632. this._gazeTracker.material = targetMat;
  15633. }
  15634. else {
  15635. this._gazeTracker = gazeTrackerToClone.clone("gazeTracker");
  15636. }
  15637. }
  15638. /** @hidden */
  15639. VRExperienceHelperGazer.prototype._getForwardRay = function (length) {
  15640. 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));
  15641. };
  15642. /** @hidden */
  15643. VRExperienceHelperGazer.prototype._selectionPointerDown = function () {
  15644. this._pointerDownOnMeshAsked = true;
  15645. if (this._currentHit) {
  15646. this.scene.simulatePointerDown(this._currentHit, { pointerId: this._id });
  15647. }
  15648. };
  15649. /** @hidden */
  15650. VRExperienceHelperGazer.prototype._selectionPointerUp = function () {
  15651. if (this._currentHit) {
  15652. this.scene.simulatePointerUp(this._currentHit, { pointerId: this._id });
  15653. }
  15654. this._pointerDownOnMeshAsked = false;
  15655. };
  15656. /** @hidden */
  15657. VRExperienceHelperGazer.prototype._activatePointer = function () {
  15658. this._activePointer = true;
  15659. };
  15660. /** @hidden */
  15661. VRExperienceHelperGazer.prototype._deactivatePointer = function () {
  15662. this._activePointer = false;
  15663. };
  15664. /** @hidden */
  15665. VRExperienceHelperGazer.prototype._updatePointerDistance = function (distance) {
  15666. if (distance === void 0) { distance = 100; }
  15667. };
  15668. VRExperienceHelperGazer.prototype.dispose = function () {
  15669. this._interactionsEnabled = false;
  15670. this._teleportationEnabled = false;
  15671. if (this._gazeTracker) {
  15672. this._gazeTracker.dispose();
  15673. }
  15674. };
  15675. VRExperienceHelperGazer._idCounter = 0;
  15676. return VRExperienceHelperGazer;
  15677. }());
  15678. var VRExperienceHelperControllerGazer = /** @class */ (function (_super) {
  15679. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperControllerGazer, _super);
  15680. function VRExperienceHelperControllerGazer(webVRController, scene, gazeTrackerToClone) {
  15681. var _this = _super.call(this, scene, gazeTrackerToClone) || this;
  15682. _this.webVRController = webVRController;
  15683. // Laser pointer
  15684. _this._laserPointer = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateCylinder("laserPointer", 1, 0.004, 0.0002, 20, 1, scene, false);
  15685. var laserPointerMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("laserPointerMat", scene);
  15686. laserPointerMaterial.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7);
  15687. laserPointerMaterial.alpha = 0.6;
  15688. _this._laserPointer.material = laserPointerMaterial;
  15689. _this._laserPointer.rotation.x = Math.PI / 2;
  15690. _this._laserPointer.position.z = -0.5;
  15691. _this._laserPointer.isVisible = false;
  15692. _this._laserPointer.isPickable = false;
  15693. if (!webVRController.mesh) {
  15694. // Create an empty mesh that is used prior to loading the high quality model
  15695. var preloadMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"]("preloadControllerMesh", scene);
  15696. var preloadPointerPose = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"](_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE, scene);
  15697. preloadPointerPose.rotation.x = -0.7;
  15698. preloadMesh.addChild(preloadPointerPose);
  15699. webVRController.attachToMesh(preloadMesh);
  15700. }
  15701. _this._setLaserPointerParent(webVRController.mesh);
  15702. _this._meshAttachedObserver = webVRController._meshAttachedObservable.add(function (mesh) {
  15703. _this._setLaserPointerParent(mesh);
  15704. });
  15705. return _this;
  15706. }
  15707. VRExperienceHelperControllerGazer.prototype._getForwardRay = function (length) {
  15708. return this.webVRController.getForwardRay(length);
  15709. };
  15710. /** @hidden */
  15711. VRExperienceHelperControllerGazer.prototype._activatePointer = function () {
  15712. _super.prototype._activatePointer.call(this);
  15713. this._laserPointer.isVisible = true;
  15714. };
  15715. /** @hidden */
  15716. VRExperienceHelperControllerGazer.prototype._deactivatePointer = function () {
  15717. _super.prototype._deactivatePointer.call(this);
  15718. this._laserPointer.isVisible = false;
  15719. };
  15720. /** @hidden */
  15721. VRExperienceHelperControllerGazer.prototype._setLaserPointerColor = function (color) {
  15722. this._laserPointer.material.emissiveColor = color;
  15723. };
  15724. /** @hidden */
  15725. VRExperienceHelperControllerGazer.prototype._setLaserPointerParent = function (mesh) {
  15726. var makeNotPick = function (root) {
  15727. root.isPickable = false;
  15728. root.getChildMeshes().forEach(function (c) {
  15729. makeNotPick(c);
  15730. });
  15731. };
  15732. makeNotPick(mesh);
  15733. var meshChildren = mesh.getChildren(undefined, false);
  15734. var laserParent = mesh;
  15735. this.webVRController._pointingPoseNode = null;
  15736. for (var i = 0; i < meshChildren.length; i++) {
  15737. if (meshChildren[i].name && meshChildren[i].name.indexOf(_Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledController"].POINTING_POSE) >= 0) {
  15738. laserParent = meshChildren[i];
  15739. this.webVRController._pointingPoseNode = laserParent;
  15740. break;
  15741. }
  15742. }
  15743. this._laserPointer.parent = laserParent;
  15744. };
  15745. VRExperienceHelperControllerGazer.prototype._updatePointerDistance = function (distance) {
  15746. if (distance === void 0) { distance = 100; }
  15747. this._laserPointer.scaling.y = distance;
  15748. this._laserPointer.position.z = -distance / 2;
  15749. };
  15750. VRExperienceHelperControllerGazer.prototype.dispose = function () {
  15751. _super.prototype.dispose.call(this);
  15752. this._laserPointer.dispose();
  15753. if (this._meshAttachedObserver) {
  15754. this.webVRController._meshAttachedObservable.remove(this._meshAttachedObserver);
  15755. }
  15756. };
  15757. return VRExperienceHelperControllerGazer;
  15758. }(VRExperienceHelperGazer));
  15759. var VRExperienceHelperCameraGazer = /** @class */ (function (_super) {
  15760. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRExperienceHelperCameraGazer, _super);
  15761. function VRExperienceHelperCameraGazer(getCamera, scene) {
  15762. var _this = _super.call(this, scene) || this;
  15763. _this.getCamera = getCamera;
  15764. return _this;
  15765. }
  15766. VRExperienceHelperCameraGazer.prototype._getForwardRay = function (length) {
  15767. var camera = this.getCamera();
  15768. if (camera) {
  15769. return camera.getForwardRay(length);
  15770. }
  15771. else {
  15772. 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());
  15773. }
  15774. };
  15775. return VRExperienceHelperCameraGazer;
  15776. }(VRExperienceHelperGazer));
  15777. /**
  15778. * Helps to quickly add VR support to an existing scene.
  15779. * See http://doc.babylonjs.com/how_to/webvr_helper
  15780. */
  15781. var VRExperienceHelper = /** @class */ (function () {
  15782. /**
  15783. * Instantiates a VRExperienceHelper.
  15784. * Helps to quickly add VR support to an existing scene.
  15785. * @param scene The scene the VRExperienceHelper belongs to.
  15786. * @param webVROptions Options to modify the vr experience helper's behavior.
  15787. */
  15788. function VRExperienceHelper(scene,
  15789. /** Options to modify the vr experience helper's behavior. */
  15790. webVROptions) {
  15791. if (webVROptions === void 0) { webVROptions = {}; }
  15792. var _this = this;
  15793. this.webVROptions = webVROptions;
  15794. // Can the system support WebVR, even if a headset isn't plugged in?
  15795. this._webVRsupported = false;
  15796. // If WebVR is supported, is a headset plugged in and are we ready to present?
  15797. this._webVRready = false;
  15798. // Are we waiting for the requestPresent callback to complete?
  15799. this._webVRrequesting = false;
  15800. // Are we presenting to the headset right now? (this is the vrDevice state)
  15801. this._webVRpresenting = false;
  15802. // Are we presenting in the fullscreen fallback?
  15803. this._fullscreenVRpresenting = false;
  15804. /**
  15805. * Observable raised when entering VR.
  15806. */
  15807. this.onEnteringVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15808. /**
  15809. * Observable raised when exiting VR.
  15810. */
  15811. this.onExitingVRObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15812. /**
  15813. * Observable raised when controller mesh is loaded.
  15814. */
  15815. this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15816. this._useCustomVRButton = false;
  15817. this._teleportationRequested = false;
  15818. this._teleportActive = false;
  15819. this._floorMeshesCollection = [];
  15820. this._rotationAllowed = true;
  15821. this._teleportBackwardsVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, -1, -1);
  15822. this._isDefaultTeleportationTarget = true;
  15823. this._teleportationFillColor = "#444444";
  15824. this._teleportationBorderColor = "#FFFFFF";
  15825. this._rotationAngle = 0;
  15826. this._haloCenter = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, 0, 0);
  15827. this._padSensibilityUp = 0.65;
  15828. this._padSensibilityDown = 0.35;
  15829. this._leftController = null;
  15830. this._rightController = null;
  15831. /**
  15832. * Observable raised when a new mesh is selected based on meshSelectionPredicate
  15833. */
  15834. this.onNewMeshSelected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15835. /**
  15836. * Observable raised when a new mesh is picked based on meshSelectionPredicate
  15837. */
  15838. this.onNewMeshPicked = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15839. /**
  15840. * Observable raised before camera teleportation
  15841. */
  15842. this.onBeforeCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15843. /**
  15844. * Observable raised after camera teleportation
  15845. */
  15846. this.onAfterCameraTeleport = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15847. /**
  15848. * Observable raised when current selected mesh gets unselected
  15849. */
  15850. this.onSelectedMeshUnselected = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  15851. /**
  15852. * Set teleportation enabled. If set to false camera teleportation will be disabled but camera rotation will be kept.
  15853. */
  15854. this.teleportationEnabled = true;
  15855. this._teleportationInitialized = false;
  15856. this._interactionsEnabled = false;
  15857. this._interactionsRequested = false;
  15858. this._displayGaze = true;
  15859. this._displayLaserPointer = true;
  15860. /**
  15861. * If the gaze trackers scale should be updated to be constant size when pointing at near/far meshes
  15862. */
  15863. this.updateGazeTrackerScale = true;
  15864. /**
  15865. * If the gaze trackers color should be updated when selecting meshes
  15866. */
  15867. this.updateGazeTrackerColor = true;
  15868. /**
  15869. * Defines wether or not Pointer lock should be requested when switching to
  15870. * full screen.
  15871. */
  15872. this.requestPointerLockOnFullScreen = true;
  15873. this._onResize = function () {
  15874. _this.moveButtonToBottomRight();
  15875. if (_this._fullscreenVRpresenting && _this._webVRready) {
  15876. _this.exitVR();
  15877. }
  15878. };
  15879. this._onFullscreenChange = function () {
  15880. if (document.fullscreen !== undefined) {
  15881. _this._fullscreenVRpresenting = document.fullscreen;
  15882. }
  15883. else if (document.mozFullScreen !== undefined) {
  15884. _this._fullscreenVRpresenting = document.mozFullScreen;
  15885. }
  15886. else if (document.webkitIsFullScreen !== undefined) {
  15887. _this._fullscreenVRpresenting = document.webkitIsFullScreen;
  15888. }
  15889. else if (document.msIsFullScreen !== undefined) {
  15890. _this._fullscreenVRpresenting = document.msIsFullScreen;
  15891. }
  15892. else if (document.msFullscreenElement !== undefined) {
  15893. _this._fullscreenVRpresenting = document.msFullscreenElement;
  15894. }
  15895. if (!_this._fullscreenVRpresenting && _this._canvas) {
  15896. _this.exitVR();
  15897. if (!_this._useCustomVRButton) {
  15898. _this._btnVR.style.top = _this._canvas.offsetTop + _this._canvas.offsetHeight - 70 + "px";
  15899. _this._btnVR.style.left = _this._canvas.offsetLeft + _this._canvas.offsetWidth - 100 + "px";
  15900. }
  15901. }
  15902. };
  15903. this._cachedAngularSensibility = { angularSensibilityX: null, angularSensibilityY: null, angularSensibility: null };
  15904. this.beforeRender = function () {
  15905. if (_this._leftController && _this._leftController._activePointer) {
  15906. _this._castRayAndSelectObject(_this._leftController);
  15907. }
  15908. if (_this._rightController && _this._rightController._activePointer) {
  15909. _this._castRayAndSelectObject(_this._rightController);
  15910. }
  15911. if (_this._noControllerIsActive) {
  15912. _this._castRayAndSelectObject(_this._cameraGazer);
  15913. }
  15914. else {
  15915. _this._cameraGazer._gazeTracker.isVisible = false;
  15916. }
  15917. };
  15918. this._onNewGamepadConnected = function (gamepad) {
  15919. if (gamepad.type !== _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].POSE_ENABLED) {
  15920. if (gamepad.leftStick) {
  15921. gamepad.onleftstickchanged(function (stickValues) {
  15922. if (_this._teleportationInitialized && _this.teleportationEnabled) {
  15923. // Listening to classic/xbox gamepad only if no VR controller is active
  15924. if ((!_this._leftController && !_this._rightController) ||
  15925. ((_this._leftController && !_this._leftController._activePointer) &&
  15926. (_this._rightController && !_this._rightController._activePointer))) {
  15927. _this._checkTeleportWithRay(stickValues, _this._cameraGazer);
  15928. _this._checkTeleportBackwards(stickValues, _this._cameraGazer);
  15929. }
  15930. }
  15931. });
  15932. }
  15933. if (gamepad.rightStick) {
  15934. gamepad.onrightstickchanged(function (stickValues) {
  15935. if (_this._teleportationInitialized) {
  15936. _this._checkRotate(stickValues, _this._cameraGazer);
  15937. }
  15938. });
  15939. }
  15940. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_10__["Gamepad"].XBOX) {
  15941. gamepad.onbuttondown(function (buttonPressed) {
  15942. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15943. _this._cameraGazer._selectionPointerDown();
  15944. }
  15945. });
  15946. gamepad.onbuttonup(function (buttonPressed) {
  15947. if (_this._interactionsEnabled && buttonPressed === _Gamepads_xboxGamepad__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"].A) {
  15948. _this._cameraGazer._selectionPointerUp();
  15949. }
  15950. });
  15951. }
  15952. }
  15953. else {
  15954. var webVRController = gamepad;
  15955. var controller = new VRExperienceHelperControllerGazer(webVRController, _this._scene, _this._cameraGazer._gazeTracker);
  15956. if (webVRController.hand === "right" || (_this._leftController && _this._leftController.webVRController != webVRController)) {
  15957. _this._rightController = controller;
  15958. }
  15959. else {
  15960. _this._leftController = controller;
  15961. }
  15962. _this._tryEnableInteractionOnController(controller);
  15963. }
  15964. };
  15965. // 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
  15966. this._tryEnableInteractionOnController = function (controller) {
  15967. if (_this._interactionsRequested && !controller._interactionsEnabled) {
  15968. _this._enableInteractionOnController(controller);
  15969. }
  15970. if (_this._teleportationRequested && !controller._teleportationEnabled) {
  15971. _this._enableTeleportationOnController(controller);
  15972. }
  15973. };
  15974. this._onNewGamepadDisconnected = function (gamepad) {
  15975. if (gamepad instanceof _Gamepads_Controllers_webVRController__WEBPACK_IMPORTED_MODULE_12__["WebVRController"]) {
  15976. if (gamepad.hand === "left" && _this._leftController != null) {
  15977. _this._leftController.dispose();
  15978. _this._leftController = null;
  15979. }
  15980. if (gamepad.hand === "right" && _this._rightController != null) {
  15981. _this._rightController.dispose();
  15982. _this._rightController = null;
  15983. }
  15984. }
  15985. };
  15986. this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Zero();
  15987. this._workingQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].Identity();
  15988. this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].Identity();
  15989. this._scene = scene;
  15990. this._canvas = scene.getEngine().getRenderingCanvas();
  15991. // Parse options
  15992. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera === undefined) {
  15993. webVROptions.createFallbackVRDeviceOrientationFreeCamera = true;
  15994. }
  15995. if (webVROptions.createDeviceOrientationCamera === undefined) {
  15996. webVROptions.createDeviceOrientationCamera = true;
  15997. }
  15998. if (webVROptions.laserToggle === undefined) {
  15999. webVROptions.laserToggle = true;
  16000. }
  16001. if (webVROptions.defaultHeight === undefined) {
  16002. webVROptions.defaultHeight = 1.7;
  16003. }
  16004. if (webVROptions.useCustomVRButton) {
  16005. this._useCustomVRButton = true;
  16006. if (webVROptions.customVRButton) {
  16007. this._btnVR = webVROptions.customVRButton;
  16008. }
  16009. }
  16010. if (webVROptions.rayLength) {
  16011. this._rayLength = webVROptions.rayLength;
  16012. }
  16013. this._defaultHeight = webVROptions.defaultHeight;
  16014. if (webVROptions.positionScale) {
  16015. this._rayLength *= webVROptions.positionScale;
  16016. this._defaultHeight *= webVROptions.positionScale;
  16017. }
  16018. this._hasEnteredVR = false;
  16019. // Set position
  16020. if (this._scene.activeCamera) {
  16021. this._position = this._scene.activeCamera.position.clone();
  16022. }
  16023. else {
  16024. this._position = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"](0, this._defaultHeight, 0);
  16025. }
  16026. // Set non-vr camera
  16027. if (webVROptions.createDeviceOrientationCamera || !this._scene.activeCamera) {
  16028. this._deviceOrientationCamera = new _Cameras_deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_5__["DeviceOrientationCamera"]("deviceOrientationVRHelper", this._position.clone(), scene);
  16029. // Copy data from existing camera
  16030. if (this._scene.activeCamera) {
  16031. this._deviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16032. this._deviceOrientationCamera.maxZ = this._scene.activeCamera.maxZ;
  16033. // Set rotation from previous camera
  16034. if (this._scene.activeCamera instanceof _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"] && this._scene.activeCamera.rotation) {
  16035. var targetCamera = this._scene.activeCamera;
  16036. if (targetCamera.rotationQuaternion) {
  16037. this._deviceOrientationCamera.rotationQuaternion.copyFrom(targetCamera.rotationQuaternion);
  16038. }
  16039. else {
  16040. this._deviceOrientationCamera.rotationQuaternion.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRoll(targetCamera.rotation.y, targetCamera.rotation.x, targetCamera.rotation.z));
  16041. }
  16042. this._deviceOrientationCamera.rotation = targetCamera.rotation.clone();
  16043. }
  16044. }
  16045. this._scene.activeCamera = this._deviceOrientationCamera;
  16046. if (this._canvas) {
  16047. this._scene.activeCamera.attachControl(this._canvas);
  16048. }
  16049. }
  16050. else {
  16051. this._existingCamera = this._scene.activeCamera;
  16052. }
  16053. // Create VR cameras
  16054. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16055. this._vrDeviceOrientationCamera = new _Cameras_VR_vrDeviceOrientationFreeCamera__WEBPACK_IMPORTED_MODULE_6__["VRDeviceOrientationFreeCamera"]("VRDeviceOrientationVRHelper", this._position, this._scene, true, webVROptions.vrDeviceOrientationCameraMetrics);
  16056. this._vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16057. }
  16058. this._webVRCamera = new _Cameras_VR_webVRCamera__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]("WebVRHelper", this._position, this._scene, webVROptions);
  16059. this._webVRCamera.useStandingMatrix();
  16060. this._cameraGazer = new VRExperienceHelperCameraGazer(function () { return _this.currentVRCamera; }, scene);
  16061. // Create default button
  16062. if (!this._useCustomVRButton) {
  16063. this._btnVR = document.createElement("BUTTON");
  16064. this._btnVR.className = "babylonVRicon";
  16065. this._btnVR.id = "babylonVRiconbtn";
  16066. this._btnVR.title = "Click to switch to VR";
  16067. 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) }";
  16068. css += ".babylonVRicon.vrdisplaypresenting { display: none; }";
  16069. // TODO: Add user feedback so that they know what state the VRDisplay is in (disconnected, connected, entering-VR)
  16070. // css += ".babylonVRicon.vrdisplaysupported { }";
  16071. // css += ".babylonVRicon.vrdisplayready { }";
  16072. // css += ".babylonVRicon.vrdisplayrequesting { }";
  16073. var style = document.createElement('style');
  16074. style.appendChild(document.createTextNode(css));
  16075. document.getElementsByTagName('head')[0].appendChild(style);
  16076. this.moveButtonToBottomRight();
  16077. }
  16078. // VR button click event
  16079. if (this._btnVR) {
  16080. this._btnVR.addEventListener("click", function () {
  16081. if (!_this.isInVRMode) {
  16082. _this.enterVR();
  16083. }
  16084. else {
  16085. _this.exitVR();
  16086. }
  16087. });
  16088. }
  16089. // Window events
  16090. window.addEventListener("resize", this._onResize);
  16091. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  16092. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  16093. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  16094. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  16095. document.onmsfullscreenchange = this._onFullscreenChange;
  16096. // Display vr button when headset is connected
  16097. if (webVROptions.createFallbackVRDeviceOrientationFreeCamera) {
  16098. this.displayVRButton();
  16099. }
  16100. else {
  16101. this._scene.getEngine().onVRDisplayChangedObservable.add(function (e) {
  16102. if (e.vrDisplay) {
  16103. _this.displayVRButton();
  16104. }
  16105. });
  16106. }
  16107. // Exiting VR mode using 'ESC' key on desktop
  16108. this._onKeyDown = function (event) {
  16109. if (event.keyCode === 27 && _this.isInVRMode) {
  16110. _this.exitVR();
  16111. }
  16112. };
  16113. document.addEventListener("keydown", this._onKeyDown);
  16114. // Exiting VR mode double tapping the touch screen
  16115. this._scene.onPrePointerObservable.add(function () {
  16116. if (_this.isInVRMode) {
  16117. _this.exitVR();
  16118. if (_this._fullscreenVRpresenting) {
  16119. _this._scene.getEngine().exitFullscreen();
  16120. }
  16121. }
  16122. }, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_8__["PointerEventTypes"].POINTERDOUBLETAP, false);
  16123. // Listen for WebVR display changes
  16124. this._onVRDisplayChanged = function (eventArgs) { return _this.onVRDisplayChanged(eventArgs); };
  16125. this._onVrDisplayPresentChange = function () { return _this.onVrDisplayPresentChange(); };
  16126. this._onVRRequestPresentStart = function () {
  16127. _this._webVRrequesting = true;
  16128. _this.updateButtonVisibility();
  16129. };
  16130. this._onVRRequestPresentComplete = function () {
  16131. _this._webVRrequesting = false;
  16132. _this.updateButtonVisibility();
  16133. };
  16134. scene.getEngine().onVRDisplayChangedObservable.add(this._onVRDisplayChanged);
  16135. scene.getEngine().onVRRequestPresentStart.add(this._onVRRequestPresentStart);
  16136. scene.getEngine().onVRRequestPresentComplete.add(this._onVRRequestPresentComplete);
  16137. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  16138. scene.onDisposeObservable.add(function () {
  16139. _this.dispose();
  16140. });
  16141. // Gamepad connection events
  16142. this._webVRCamera.onControllerMeshLoadedObservable.add(function (webVRController) { return _this._onDefaultMeshLoaded(webVRController); });
  16143. this._scene.gamepadManager.onGamepadConnectedObservable.add(this._onNewGamepadConnected);
  16144. this._scene.gamepadManager.onGamepadDisconnectedObservable.add(this._onNewGamepadDisconnected);
  16145. this.updateButtonVisibility();
  16146. //create easing functions
  16147. this._circleEase = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["CircleEase"]();
  16148. this._circleEase.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16149. if (this.webVROptions.floorMeshes) {
  16150. this.enableTeleportation({ floorMeshes: this.webVROptions.floorMeshes });
  16151. }
  16152. }
  16153. Object.defineProperty(VRExperienceHelper.prototype, "onEnteringVR", {
  16154. /** Return this.onEnteringVRObservable
  16155. * Note: This one is for backward compatibility. Please use onEnteringVRObservable directly
  16156. */
  16157. get: function () {
  16158. return this.onEnteringVRObservable;
  16159. },
  16160. enumerable: true,
  16161. configurable: true
  16162. });
  16163. Object.defineProperty(VRExperienceHelper.prototype, "onExitingVR", {
  16164. /** Return this.onExitingVRObservable
  16165. * Note: This one is for backward compatibility. Please use onExitingVRObservable directly
  16166. */
  16167. get: function () {
  16168. return this.onExitingVRObservable;
  16169. },
  16170. enumerable: true,
  16171. configurable: true
  16172. });
  16173. Object.defineProperty(VRExperienceHelper.prototype, "onControllerMeshLoaded", {
  16174. /** Return this.onControllerMeshLoadedObservable
  16175. * Note: This one is for backward compatibility. Please use onControllerMeshLoadedObservable directly
  16176. */
  16177. get: function () {
  16178. return this.onControllerMeshLoadedObservable;
  16179. },
  16180. enumerable: true,
  16181. configurable: true
  16182. });
  16183. Object.defineProperty(VRExperienceHelper.prototype, "teleportationTarget", {
  16184. /**
  16185. * The mesh used to display where the user is going to teleport.
  16186. */
  16187. get: function () {
  16188. return this._teleportationTarget;
  16189. },
  16190. /**
  16191. * Sets the mesh to be used to display where the user is going to teleport.
  16192. */
  16193. set: function (value) {
  16194. if (value) {
  16195. value.name = "teleportationTarget";
  16196. this._isDefaultTeleportationTarget = false;
  16197. this._teleportationTarget = value;
  16198. }
  16199. },
  16200. enumerable: true,
  16201. configurable: true
  16202. });
  16203. Object.defineProperty(VRExperienceHelper.prototype, "gazeTrackerMesh", {
  16204. /**
  16205. * 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
  16206. * when set bakeCurrentTransformIntoVertices will be called on the mesh.
  16207. * See http://doc.babylonjs.com/resources/baking_transformations
  16208. */
  16209. get: function () {
  16210. return this._cameraGazer._gazeTracker;
  16211. },
  16212. set: function (value) {
  16213. if (value) {
  16214. // Dispose of existing meshes
  16215. if (this._cameraGazer._gazeTracker) {
  16216. this._cameraGazer._gazeTracker.dispose();
  16217. }
  16218. if (this._leftController && this._leftController._gazeTracker) {
  16219. this._leftController._gazeTracker.dispose();
  16220. }
  16221. if (this._rightController && this._rightController._gazeTracker) {
  16222. this._rightController._gazeTracker.dispose();
  16223. }
  16224. // Set and create gaze trackers on head and controllers
  16225. this._cameraGazer._gazeTracker = value;
  16226. this._cameraGazer._gazeTracker.bakeCurrentTransformIntoVertices();
  16227. this._cameraGazer._gazeTracker.isPickable = false;
  16228. this._cameraGazer._gazeTracker.isVisible = false;
  16229. this._cameraGazer._gazeTracker.name = "gazeTracker";
  16230. if (this._leftController) {
  16231. this._leftController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16232. }
  16233. if (this._rightController) {
  16234. this._rightController._gazeTracker = this._cameraGazer._gazeTracker.clone("gazeTracker");
  16235. }
  16236. }
  16237. },
  16238. enumerable: true,
  16239. configurable: true
  16240. });
  16241. Object.defineProperty(VRExperienceHelper.prototype, "leftControllerGazeTrackerMesh", {
  16242. /**
  16243. * The gaze tracking mesh corresponding to the left controller
  16244. */
  16245. get: function () {
  16246. if (this._leftController) {
  16247. return this._leftController._gazeTracker;
  16248. }
  16249. return null;
  16250. },
  16251. enumerable: true,
  16252. configurable: true
  16253. });
  16254. Object.defineProperty(VRExperienceHelper.prototype, "rightControllerGazeTrackerMesh", {
  16255. /**
  16256. * The gaze tracking mesh corresponding to the right controller
  16257. */
  16258. get: function () {
  16259. if (this._rightController) {
  16260. return this._rightController._gazeTracker;
  16261. }
  16262. return null;
  16263. },
  16264. enumerable: true,
  16265. configurable: true
  16266. });
  16267. Object.defineProperty(VRExperienceHelper.prototype, "displayGaze", {
  16268. /**
  16269. * If the ray of the gaze should be displayed.
  16270. */
  16271. get: function () {
  16272. return this._displayGaze;
  16273. },
  16274. /**
  16275. * Sets if the ray of the gaze should be displayed.
  16276. */
  16277. set: function (value) {
  16278. this._displayGaze = value;
  16279. if (!value) {
  16280. this._cameraGazer._gazeTracker.isVisible = false;
  16281. if (this._leftController) {
  16282. this._leftController._gazeTracker.isVisible = false;
  16283. }
  16284. if (this._rightController) {
  16285. this._rightController._gazeTracker.isVisible = false;
  16286. }
  16287. }
  16288. },
  16289. enumerable: true,
  16290. configurable: true
  16291. });
  16292. Object.defineProperty(VRExperienceHelper.prototype, "displayLaserPointer", {
  16293. /**
  16294. * If the ray of the LaserPointer should be displayed.
  16295. */
  16296. get: function () {
  16297. return this._displayLaserPointer;
  16298. },
  16299. /**
  16300. * Sets if the ray of the LaserPointer should be displayed.
  16301. */
  16302. set: function (value) {
  16303. this._displayLaserPointer = value;
  16304. if (!value) {
  16305. if (this._rightController) {
  16306. this._rightController._deactivatePointer();
  16307. this._rightController._gazeTracker.isVisible = false;
  16308. }
  16309. if (this._leftController) {
  16310. this._leftController._deactivatePointer();
  16311. this._leftController._gazeTracker.isVisible = false;
  16312. }
  16313. }
  16314. else {
  16315. if (this._rightController) {
  16316. this._rightController._activatePointer();
  16317. }
  16318. if (this._leftController) {
  16319. this._leftController._activatePointer();
  16320. }
  16321. }
  16322. },
  16323. enumerable: true,
  16324. configurable: true
  16325. });
  16326. Object.defineProperty(VRExperienceHelper.prototype, "deviceOrientationCamera", {
  16327. /**
  16328. * The deviceOrientationCamera used as the camera when not in VR.
  16329. */
  16330. get: function () {
  16331. return this._deviceOrientationCamera;
  16332. },
  16333. enumerable: true,
  16334. configurable: true
  16335. });
  16336. Object.defineProperty(VRExperienceHelper.prototype, "currentVRCamera", {
  16337. /**
  16338. * Based on the current WebVR support, returns the current VR camera used.
  16339. */
  16340. get: function () {
  16341. if (this._webVRready) {
  16342. return this._webVRCamera;
  16343. }
  16344. else {
  16345. return this._scene.activeCamera;
  16346. }
  16347. },
  16348. enumerable: true,
  16349. configurable: true
  16350. });
  16351. Object.defineProperty(VRExperienceHelper.prototype, "webVRCamera", {
  16352. /**
  16353. * The webVRCamera which is used when in VR.
  16354. */
  16355. get: function () {
  16356. return this._webVRCamera;
  16357. },
  16358. enumerable: true,
  16359. configurable: true
  16360. });
  16361. Object.defineProperty(VRExperienceHelper.prototype, "vrDeviceOrientationCamera", {
  16362. /**
  16363. * The deviceOrientationCamera that is used as a fallback when vr device is not connected.
  16364. */
  16365. get: function () {
  16366. return this._vrDeviceOrientationCamera;
  16367. },
  16368. enumerable: true,
  16369. configurable: true
  16370. });
  16371. Object.defineProperty(VRExperienceHelper.prototype, "_teleportationRequestInitiated", {
  16372. get: function () {
  16373. var result = this._cameraGazer._teleportationRequestInitiated
  16374. || (this._leftController !== null && this._leftController._teleportationRequestInitiated)
  16375. || (this._rightController !== null && this._rightController._teleportationRequestInitiated);
  16376. return result;
  16377. },
  16378. enumerable: true,
  16379. configurable: true
  16380. });
  16381. // Raised when one of the controller has loaded successfully its associated default mesh
  16382. VRExperienceHelper.prototype._onDefaultMeshLoaded = function (webVRController) {
  16383. if (this._leftController && this._leftController.webVRController == webVRController) {
  16384. if (webVRController.mesh) {
  16385. this._leftController._setLaserPointerParent(webVRController.mesh);
  16386. }
  16387. }
  16388. if (this._rightController && this._rightController.webVRController == webVRController) {
  16389. if (webVRController.mesh) {
  16390. this._rightController._setLaserPointerParent(webVRController.mesh);
  16391. }
  16392. }
  16393. try {
  16394. this.onControllerMeshLoadedObservable.notifyObservers(webVRController);
  16395. }
  16396. catch (err) {
  16397. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onControllerMeshLoaded: " + err);
  16398. }
  16399. };
  16400. Object.defineProperty(VRExperienceHelper.prototype, "isInVRMode", {
  16401. /**
  16402. * Gets a value indicating if we are currently in VR mode.
  16403. */
  16404. get: function () {
  16405. return this._webVRpresenting || this._fullscreenVRpresenting;
  16406. },
  16407. enumerable: true,
  16408. configurable: true
  16409. });
  16410. VRExperienceHelper.prototype.onVrDisplayPresentChange = function () {
  16411. var vrDisplay = this._scene.getEngine().getVRDevice();
  16412. if (vrDisplay) {
  16413. var wasPresenting = this._webVRpresenting;
  16414. this._webVRpresenting = vrDisplay.isPresenting;
  16415. if (wasPresenting && !this._webVRpresenting) {
  16416. this.exitVR();
  16417. }
  16418. }
  16419. else {
  16420. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Detected VRDisplayPresentChange on an unknown VRDisplay. Did you can enterVR on the vrExperienceHelper?');
  16421. }
  16422. this.updateButtonVisibility();
  16423. };
  16424. VRExperienceHelper.prototype.onVRDisplayChanged = function (eventArgs) {
  16425. this._webVRsupported = eventArgs.vrSupported;
  16426. this._webVRready = !!eventArgs.vrDisplay;
  16427. this._webVRpresenting = eventArgs.vrDisplay && eventArgs.vrDisplay.isPresenting;
  16428. this.updateButtonVisibility();
  16429. };
  16430. VRExperienceHelper.prototype.moveButtonToBottomRight = function () {
  16431. if (this._canvas && !this._useCustomVRButton) {
  16432. this._btnVR.style.top = this._canvas.offsetTop + this._canvas.offsetHeight - 70 + "px";
  16433. this._btnVR.style.left = this._canvas.offsetLeft + this._canvas.offsetWidth - 100 + "px";
  16434. }
  16435. };
  16436. VRExperienceHelper.prototype.displayVRButton = function () {
  16437. if (!this._useCustomVRButton && !this._btnVRDisplayed) {
  16438. document.body.appendChild(this._btnVR);
  16439. this._btnVRDisplayed = true;
  16440. }
  16441. };
  16442. VRExperienceHelper.prototype.updateButtonVisibility = function () {
  16443. if (!this._btnVR || this._useCustomVRButton) {
  16444. return;
  16445. }
  16446. this._btnVR.className = "babylonVRicon";
  16447. if (this.isInVRMode) {
  16448. this._btnVR.className += " vrdisplaypresenting";
  16449. }
  16450. else {
  16451. if (this._webVRready) {
  16452. this._btnVR.className += " vrdisplayready";
  16453. }
  16454. if (this._webVRsupported) {
  16455. this._btnVR.className += " vrdisplaysupported";
  16456. }
  16457. if (this._webVRrequesting) {
  16458. this._btnVR.className += " vrdisplayrequesting";
  16459. }
  16460. }
  16461. };
  16462. /**
  16463. * Attempt to enter VR. If a headset is connected and ready, will request present on that.
  16464. * Otherwise, will use the fullscreen API.
  16465. */
  16466. VRExperienceHelper.prototype.enterVR = function () {
  16467. if (this.onEnteringVRObservable) {
  16468. try {
  16469. this.onEnteringVRObservable.notifyObservers(this);
  16470. }
  16471. catch (err) {
  16472. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onEnteringVR: " + err);
  16473. }
  16474. }
  16475. if (this._scene.activeCamera) {
  16476. this._position = this._scene.activeCamera.position.clone();
  16477. if (this.vrDeviceOrientationCamera) {
  16478. this.vrDeviceOrientationCamera.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles();
  16479. this.vrDeviceOrientationCamera.angularSensibility = 2000;
  16480. }
  16481. if (this.webVRCamera) {
  16482. var currentYRotation = this.webVRCamera.deviceRotationQuaternion.toEulerAngles().y;
  16483. var desiredYRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this._scene.activeCamera.getWorldMatrix().getRotationMatrix()).toEulerAngles().y;
  16484. var delta = desiredYRotation - currentYRotation;
  16485. var currentGlobalRotation = this.webVRCamera.rotationQuaternion.toEulerAngles().y;
  16486. this.webVRCamera.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromEulerAngles(0, currentGlobalRotation + delta, 0);
  16487. }
  16488. // make sure that we return to the last active camera
  16489. this._existingCamera = this._scene.activeCamera;
  16490. // Remove and cache angular sensability to avoid camera rotation when in VR
  16491. if (this._existingCamera.angularSensibilityX) {
  16492. this._cachedAngularSensibility.angularSensibilityX = this._existingCamera.angularSensibilityX;
  16493. this._existingCamera.angularSensibilityX = Number.MAX_VALUE;
  16494. }
  16495. if (this._existingCamera.angularSensibilityY) {
  16496. this._cachedAngularSensibility.angularSensibilityY = this._existingCamera.angularSensibilityY;
  16497. this._existingCamera.angularSensibilityY = Number.MAX_VALUE;
  16498. }
  16499. if (this._existingCamera.angularSensibility) {
  16500. this._cachedAngularSensibility.angularSensibility = this._existingCamera.angularSensibility;
  16501. this._existingCamera.angularSensibility = Number.MAX_VALUE;
  16502. }
  16503. }
  16504. if (this._webVRrequesting) {
  16505. return;
  16506. }
  16507. // If WebVR is supported and a headset is connected
  16508. if (this._webVRready) {
  16509. if (!this._webVRpresenting) {
  16510. this._webVRCamera.position = this._position;
  16511. this._scene.activeCamera = this._webVRCamera;
  16512. }
  16513. }
  16514. else if (this._vrDeviceOrientationCamera) {
  16515. this._vrDeviceOrientationCamera.position = this._position;
  16516. if (this._scene.activeCamera) {
  16517. this._vrDeviceOrientationCamera.minZ = this._scene.activeCamera.minZ;
  16518. }
  16519. this._scene.activeCamera = this._vrDeviceOrientationCamera;
  16520. this._scene.getEngine().enterFullscreen(this.requestPointerLockOnFullScreen);
  16521. this.updateButtonVisibility();
  16522. }
  16523. if (this._scene.activeCamera && this._canvas) {
  16524. this._scene.activeCamera.attachControl(this._canvas);
  16525. }
  16526. if (this._interactionsEnabled) {
  16527. this._scene.registerBeforeRender(this.beforeRender);
  16528. }
  16529. if (this._displayLaserPointer) {
  16530. [this._leftController, this._rightController].forEach(function (controller) {
  16531. if (controller) {
  16532. controller._activatePointer();
  16533. }
  16534. });
  16535. }
  16536. this._hasEnteredVR = true;
  16537. };
  16538. /**
  16539. * Attempt to exit VR, or fullscreen.
  16540. */
  16541. VRExperienceHelper.prototype.exitVR = function () {
  16542. if (this._hasEnteredVR) {
  16543. if (this.onExitingVRObservable) {
  16544. try {
  16545. this.onExitingVRObservable.notifyObservers(this);
  16546. }
  16547. catch (err) {
  16548. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onExitingVR: " + err);
  16549. }
  16550. }
  16551. if (this._webVRpresenting) {
  16552. this._scene.getEngine().disableVR();
  16553. }
  16554. if (this._scene.activeCamera) {
  16555. this._position = this._scene.activeCamera.position.clone();
  16556. }
  16557. if (this.vrDeviceOrientationCamera) {
  16558. this.vrDeviceOrientationCamera.angularSensibility = Number.MAX_VALUE;
  16559. }
  16560. if (this._deviceOrientationCamera) {
  16561. this._deviceOrientationCamera.position = this._position;
  16562. this._scene.activeCamera = this._deviceOrientationCamera;
  16563. if (this._canvas) {
  16564. this._scene.activeCamera.attachControl(this._canvas);
  16565. }
  16566. // Restore angular sensibility
  16567. if (this._cachedAngularSensibility.angularSensibilityX) {
  16568. this._deviceOrientationCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16569. this._cachedAngularSensibility.angularSensibilityX = null;
  16570. }
  16571. if (this._cachedAngularSensibility.angularSensibilityY) {
  16572. this._deviceOrientationCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16573. this._cachedAngularSensibility.angularSensibilityY = null;
  16574. }
  16575. if (this._cachedAngularSensibility.angularSensibility) {
  16576. this._deviceOrientationCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16577. this._cachedAngularSensibility.angularSensibility = null;
  16578. }
  16579. }
  16580. else if (this._existingCamera) {
  16581. this._existingCamera.position = this._position;
  16582. this._scene.activeCamera = this._existingCamera;
  16583. // Restore angular sensibility
  16584. if (this._cachedAngularSensibility.angularSensibilityX) {
  16585. this._existingCamera.angularSensibilityX = this._cachedAngularSensibility.angularSensibilityX;
  16586. this._cachedAngularSensibility.angularSensibilityX = null;
  16587. }
  16588. if (this._cachedAngularSensibility.angularSensibilityY) {
  16589. this._existingCamera.angularSensibilityY = this._cachedAngularSensibility.angularSensibilityY;
  16590. this._cachedAngularSensibility.angularSensibilityY = null;
  16591. }
  16592. if (this._cachedAngularSensibility.angularSensibility) {
  16593. this._existingCamera.angularSensibility = this._cachedAngularSensibility.angularSensibility;
  16594. this._cachedAngularSensibility.angularSensibility = null;
  16595. }
  16596. }
  16597. this.updateButtonVisibility();
  16598. if (this._interactionsEnabled) {
  16599. this._scene.unregisterBeforeRender(this.beforeRender);
  16600. this._cameraGazer._gazeTracker.isVisible = false;
  16601. if (this._leftController) {
  16602. this._leftController._gazeTracker.isVisible = false;
  16603. }
  16604. if (this._rightController) {
  16605. this._rightController._gazeTracker.isVisible = false;
  16606. }
  16607. }
  16608. // resize to update width and height when exiting vr exits fullscreen
  16609. this._scene.getEngine().resize();
  16610. [this._leftController, this._rightController].forEach(function (controller) {
  16611. if (controller) {
  16612. controller._deactivatePointer();
  16613. }
  16614. });
  16615. this._hasEnteredVR = false;
  16616. }
  16617. };
  16618. Object.defineProperty(VRExperienceHelper.prototype, "position", {
  16619. /**
  16620. * The position of the vr experience helper.
  16621. */
  16622. get: function () {
  16623. return this._position;
  16624. },
  16625. /**
  16626. * Sets the position of the vr experience helper.
  16627. */
  16628. set: function (value) {
  16629. this._position = value;
  16630. if (this._scene.activeCamera) {
  16631. this._scene.activeCamera.position = value;
  16632. }
  16633. },
  16634. enumerable: true,
  16635. configurable: true
  16636. });
  16637. /**
  16638. * Enables controllers and user interactions such as selecting and object or clicking on an object.
  16639. */
  16640. VRExperienceHelper.prototype.enableInteractions = function () {
  16641. var _this = this;
  16642. if (!this._interactionsEnabled) {
  16643. this._interactionsRequested = true;
  16644. if (this._leftController) {
  16645. this._enableInteractionOnController(this._leftController);
  16646. }
  16647. if (this._rightController) {
  16648. this._enableInteractionOnController(this._rightController);
  16649. }
  16650. this.raySelectionPredicate = function (mesh) {
  16651. return mesh.isVisible && (mesh.isPickable || mesh.name === _this._floorMeshName);
  16652. };
  16653. this.meshSelectionPredicate = function () {
  16654. return true;
  16655. };
  16656. this._raySelectionPredicate = function (mesh) {
  16657. if (_this._isTeleportationFloor(mesh) || (mesh.name.indexOf("gazeTracker") === -1
  16658. && mesh.name.indexOf("teleportationTarget") === -1
  16659. && mesh.name.indexOf("torusTeleportation") === -1)) {
  16660. return _this.raySelectionPredicate(mesh);
  16661. }
  16662. return false;
  16663. };
  16664. this._interactionsEnabled = true;
  16665. }
  16666. };
  16667. Object.defineProperty(VRExperienceHelper.prototype, "_noControllerIsActive", {
  16668. get: function () {
  16669. return !(this._leftController && this._leftController._activePointer) && !(this._rightController && this._rightController._activePointer);
  16670. },
  16671. enumerable: true,
  16672. configurable: true
  16673. });
  16674. VRExperienceHelper.prototype._isTeleportationFloor = function (mesh) {
  16675. for (var i = 0; i < this._floorMeshesCollection.length; i++) {
  16676. if (this._floorMeshesCollection[i].id === mesh.id) {
  16677. return true;
  16678. }
  16679. }
  16680. if (this._floorMeshName && mesh.name === this._floorMeshName) {
  16681. return true;
  16682. }
  16683. return false;
  16684. };
  16685. /**
  16686. * Adds a floor mesh to be used for teleportation.
  16687. * @param floorMesh the mesh to be used for teleportation.
  16688. */
  16689. VRExperienceHelper.prototype.addFloorMesh = function (floorMesh) {
  16690. if (!this._floorMeshesCollection) {
  16691. return;
  16692. }
  16693. if (this._floorMeshesCollection.indexOf(floorMesh) > -1) {
  16694. return;
  16695. }
  16696. this._floorMeshesCollection.push(floorMesh);
  16697. };
  16698. /**
  16699. * Removes a floor mesh from being used for teleportation.
  16700. * @param floorMesh the mesh to be removed.
  16701. */
  16702. VRExperienceHelper.prototype.removeFloorMesh = function (floorMesh) {
  16703. if (!this._floorMeshesCollection) {
  16704. return;
  16705. }
  16706. var meshIndex = this._floorMeshesCollection.indexOf(floorMesh);
  16707. if (meshIndex !== -1) {
  16708. this._floorMeshesCollection.splice(meshIndex, 1);
  16709. }
  16710. };
  16711. /**
  16712. * Enables interactions and teleportation using the VR controllers and gaze.
  16713. * @param vrTeleportationOptions options to modify teleportation behavior.
  16714. */
  16715. VRExperienceHelper.prototype.enableTeleportation = function (vrTeleportationOptions) {
  16716. if (vrTeleportationOptions === void 0) { vrTeleportationOptions = {}; }
  16717. if (!this._teleportationInitialized) {
  16718. this._teleportationRequested = true;
  16719. this.enableInteractions();
  16720. if (vrTeleportationOptions.floorMeshName) {
  16721. this._floorMeshName = vrTeleportationOptions.floorMeshName;
  16722. }
  16723. if (vrTeleportationOptions.floorMeshes) {
  16724. this._floorMeshesCollection = vrTeleportationOptions.floorMeshes;
  16725. }
  16726. if (this._leftController != null) {
  16727. this._enableTeleportationOnController(this._leftController);
  16728. }
  16729. if (this._rightController != null) {
  16730. this._enableTeleportationOnController(this._rightController);
  16731. }
  16732. // Creates an image processing post process for the vignette not relying
  16733. // on the main scene configuration for image processing to reduce setup and spaces
  16734. // (gamma/linear) conflicts.
  16735. var imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_16__["ImageProcessingConfiguration"]();
  16736. imageProcessingConfiguration.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color4"](0, 0, 0, 0);
  16737. imageProcessingConfiguration.vignetteEnabled = true;
  16738. this._postProcessMove = new _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_19__["ImageProcessingPostProcess"]("postProcessMove", 1.0, this._webVRCamera, undefined, undefined, undefined, undefined, imageProcessingConfiguration);
  16739. this._webVRCamera.detachPostProcess(this._postProcessMove);
  16740. this._teleportationInitialized = true;
  16741. if (this._isDefaultTeleportationTarget) {
  16742. this._createTeleportationCircles();
  16743. this._teleportationTarget.scaling.scaleInPlace(this._webVRCamera.deviceScaleFactor);
  16744. }
  16745. }
  16746. };
  16747. VRExperienceHelper.prototype._enableInteractionOnController = function (controller) {
  16748. var _this = this;
  16749. var controllerMesh = controller.webVRController.mesh;
  16750. if (controllerMesh) {
  16751. controller._interactionsEnabled = true;
  16752. if (this.isInVRMode && this._displayLaserPointer) {
  16753. controller._activatePointer();
  16754. }
  16755. if (this.webVROptions.laserToggle) {
  16756. controller.webVRController.onMainButtonStateChangedObservable.add(function (stateObject) {
  16757. // Enabling / disabling laserPointer
  16758. if (_this._displayLaserPointer && stateObject.value === 1) {
  16759. if (controller._activePointer) {
  16760. controller._deactivatePointer();
  16761. }
  16762. else {
  16763. controller._activatePointer();
  16764. }
  16765. if (_this.displayGaze) {
  16766. controller._gazeTracker.isVisible = controller._activePointer;
  16767. }
  16768. }
  16769. });
  16770. }
  16771. controller.webVRController.onTriggerStateChangedObservable.add(function (stateObject) {
  16772. var gazer = controller;
  16773. if (_this._noControllerIsActive) {
  16774. gazer = _this._cameraGazer;
  16775. }
  16776. if (!gazer._pointerDownOnMeshAsked) {
  16777. if (stateObject.value > _this._padSensibilityUp) {
  16778. gazer._selectionPointerDown();
  16779. }
  16780. }
  16781. else if (stateObject.value < _this._padSensibilityDown) {
  16782. gazer._selectionPointerUp();
  16783. }
  16784. });
  16785. }
  16786. };
  16787. VRExperienceHelper.prototype._checkTeleportWithRay = function (stateObject, gazer) {
  16788. // Dont teleport if another gaze already requested teleportation
  16789. if (this._teleportationRequestInitiated && !gazer._teleportationRequestInitiated) {
  16790. return;
  16791. }
  16792. if (!gazer._teleportationRequestInitiated) {
  16793. if (stateObject.y < -this._padSensibilityUp && gazer._dpadPressed) {
  16794. gazer._activatePointer();
  16795. gazer._teleportationRequestInitiated = true;
  16796. }
  16797. }
  16798. else {
  16799. // Listening to the proper controller values changes to confirm teleportation
  16800. if (Math.sqrt(stateObject.y * stateObject.y + stateObject.x * stateObject.x) < this._padSensibilityDown) {
  16801. if (this._teleportActive) {
  16802. this.teleportCamera(this._haloCenter);
  16803. }
  16804. gazer._teleportationRequestInitiated = false;
  16805. }
  16806. }
  16807. };
  16808. VRExperienceHelper.prototype._checkRotate = function (stateObject, gazer) {
  16809. // Only rotate when user is not currently selecting a teleportation location
  16810. if (gazer._teleportationRequestInitiated) {
  16811. return;
  16812. }
  16813. if (!gazer._rotationLeftAsked) {
  16814. if (stateObject.x < -this._padSensibilityUp && gazer._dpadPressed) {
  16815. gazer._rotationLeftAsked = true;
  16816. if (this._rotationAllowed) {
  16817. this._rotateCamera(false);
  16818. }
  16819. }
  16820. }
  16821. else {
  16822. if (stateObject.x > -this._padSensibilityDown) {
  16823. gazer._rotationLeftAsked = false;
  16824. }
  16825. }
  16826. if (!gazer._rotationRightAsked) {
  16827. if (stateObject.x > this._padSensibilityUp && gazer._dpadPressed) {
  16828. gazer._rotationRightAsked = true;
  16829. if (this._rotationAllowed) {
  16830. this._rotateCamera(true);
  16831. }
  16832. }
  16833. }
  16834. else {
  16835. if (stateObject.x < this._padSensibilityDown) {
  16836. gazer._rotationRightAsked = false;
  16837. }
  16838. }
  16839. };
  16840. VRExperienceHelper.prototype._checkTeleportBackwards = function (stateObject, gazer) {
  16841. // Only teleport backwards when user is not currently selecting a teleportation location
  16842. if (gazer._teleportationRequestInitiated) {
  16843. return;
  16844. }
  16845. // Teleport backwards
  16846. if (stateObject.y > this._padSensibilityUp && gazer._dpadPressed) {
  16847. if (!gazer._teleportationBackRequestInitiated) {
  16848. if (!this.currentVRCamera) {
  16849. return;
  16850. }
  16851. // Get rotation and position of the current camera
  16852. var rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(this.currentVRCamera.getWorldMatrix().getRotationMatrix());
  16853. var position = this.currentVRCamera.position;
  16854. // If the camera has device position, use that instead
  16855. if (this.currentVRCamera.devicePosition && this.currentVRCamera.deviceRotationQuaternion) {
  16856. rotation = this.currentVRCamera.deviceRotationQuaternion;
  16857. position = this.currentVRCamera.devicePosition;
  16858. }
  16859. // Get matrix with only the y rotation of the device rotation
  16860. rotation.toEulerAnglesToRef(this._workingVector);
  16861. this._workingVector.z = 0;
  16862. this._workingVector.x = 0;
  16863. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].RotationYawPitchRollToRef(this._workingVector.y, this._workingVector.x, this._workingVector.z, this._workingQuaternion);
  16864. this._workingQuaternion.toRotationMatrix(this._workingMatrix);
  16865. // Rotate backwards ray by device rotation to cast at the ground behind the user
  16866. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].TransformCoordinatesToRef(this._teleportBackwardsVector, this._workingMatrix, this._workingVector);
  16867. // Teleport if ray hit the ground and is not to far away eg. backwards off a cliff
  16868. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_15__["Ray"](position, this._workingVector);
  16869. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  16870. if (hit && hit.pickedPoint && hit.pickedMesh && this._isTeleportationFloor(hit.pickedMesh) && hit.distance < 5) {
  16871. this.teleportCamera(hit.pickedPoint);
  16872. }
  16873. gazer._teleportationBackRequestInitiated = true;
  16874. }
  16875. }
  16876. else {
  16877. gazer._teleportationBackRequestInitiated = false;
  16878. }
  16879. };
  16880. VRExperienceHelper.prototype._enableTeleportationOnController = function (controller) {
  16881. var _this = this;
  16882. var controllerMesh = controller.webVRController.mesh;
  16883. if (controllerMesh) {
  16884. if (!controller._interactionsEnabled) {
  16885. this._enableInteractionOnController(controller);
  16886. }
  16887. controller._interactionsEnabled = true;
  16888. controller._teleportationEnabled = true;
  16889. if (controller.webVRController.controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_11__["PoseEnabledControllerType"].VIVE) {
  16890. controller._dpadPressed = false;
  16891. controller.webVRController.onPadStateChangedObservable.add(function (stateObject) {
  16892. controller._dpadPressed = stateObject.pressed;
  16893. if (!controller._dpadPressed) {
  16894. controller._rotationLeftAsked = false;
  16895. controller._rotationRightAsked = false;
  16896. controller._teleportationBackRequestInitiated = false;
  16897. }
  16898. });
  16899. }
  16900. controller.webVRController.onPadValuesChangedObservable.add(function (stateObject) {
  16901. if (_this.teleportationEnabled) {
  16902. _this._checkTeleportBackwards(stateObject, controller);
  16903. _this._checkTeleportWithRay(stateObject, controller);
  16904. }
  16905. _this._checkRotate(stateObject, controller);
  16906. });
  16907. }
  16908. };
  16909. VRExperienceHelper.prototype._createTeleportationCircles = function () {
  16910. this._teleportationTarget = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateGround("teleportationTarget", 2, 2, 2, this._scene);
  16911. this._teleportationTarget.isPickable = false;
  16912. var length = 512;
  16913. var dynamicTexture = new _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_18__["DynamicTexture"]("DynamicTexture", length, this._scene, true);
  16914. dynamicTexture.hasAlpha = true;
  16915. var context = dynamicTexture.getContext();
  16916. var centerX = length / 2;
  16917. var centerY = length / 2;
  16918. var radius = 200;
  16919. context.beginPath();
  16920. context.arc(centerX, centerY, radius, 0, 2 * Math.PI, false);
  16921. context.fillStyle = this._teleportationFillColor;
  16922. context.fill();
  16923. context.lineWidth = 10;
  16924. context.strokeStyle = this._teleportationBorderColor;
  16925. context.stroke();
  16926. context.closePath();
  16927. dynamicTexture.update();
  16928. var teleportationCircleMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_17__["StandardMaterial"]("TextPlaneMaterial", this._scene);
  16929. teleportationCircleMaterial.diffuseTexture = dynamicTexture;
  16930. this._teleportationTarget.material = teleportationCircleMaterial;
  16931. var torus = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_14__["Mesh"].CreateTorus("torusTeleportation", 0.75, 0.1, 25, this._scene, false);
  16932. torus.isPickable = false;
  16933. torus.parent = this._teleportationTarget;
  16934. 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);
  16935. var keys = [];
  16936. keys.push({
  16937. frame: 0,
  16938. value: 0
  16939. });
  16940. keys.push({
  16941. frame: 30,
  16942. value: 0.4
  16943. });
  16944. keys.push({
  16945. frame: 60,
  16946. value: 0
  16947. });
  16948. animationInnerCircle.setKeys(keys);
  16949. var easingFunction = new _Animations_easing__WEBPACK_IMPORTED_MODULE_20__["SineEase"]();
  16950. easingFunction.setEasingMode(_Animations_easing__WEBPACK_IMPORTED_MODULE_20__["EasingFunction"].EASINGMODE_EASEINOUT);
  16951. animationInnerCircle.setEasingFunction(easingFunction);
  16952. torus.animations = [];
  16953. torus.animations.push(animationInnerCircle);
  16954. this._scene.beginAnimation(torus, 0, 60, true);
  16955. this._hideTeleportationTarget();
  16956. };
  16957. VRExperienceHelper.prototype._displayTeleportationTarget = function () {
  16958. this._teleportActive = true;
  16959. if (this._teleportationInitialized) {
  16960. this._teleportationTarget.isVisible = true;
  16961. if (this._isDefaultTeleportationTarget) {
  16962. this._teleportationTarget.getChildren()[0].isVisible = true;
  16963. }
  16964. }
  16965. };
  16966. VRExperienceHelper.prototype._hideTeleportationTarget = function () {
  16967. this._teleportActive = false;
  16968. if (this._teleportationInitialized) {
  16969. this._teleportationTarget.isVisible = false;
  16970. if (this._isDefaultTeleportationTarget) {
  16971. this._teleportationTarget.getChildren()[0].isVisible = false;
  16972. }
  16973. }
  16974. };
  16975. VRExperienceHelper.prototype._rotateCamera = function (right) {
  16976. var _this = this;
  16977. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  16978. return;
  16979. }
  16980. if (right) {
  16981. this._rotationAngle++;
  16982. }
  16983. else {
  16984. this._rotationAngle--;
  16985. }
  16986. this.currentVRCamera.animations = [];
  16987. var target = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Quaternion"].FromRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Matrix"].RotationY(Math.PI / 4 * this._rotationAngle));
  16988. 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);
  16989. var animationRotationKeys = [];
  16990. animationRotationKeys.push({
  16991. frame: 0,
  16992. value: this.currentVRCamera.rotationQuaternion
  16993. });
  16994. animationRotationKeys.push({
  16995. frame: 6,
  16996. value: target
  16997. });
  16998. animationRotation.setKeys(animationRotationKeys);
  16999. animationRotation.setEasingFunction(this._circleEase);
  17000. this.currentVRCamera.animations.push(animationRotation);
  17001. this._postProcessMove.animations = [];
  17002. 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);
  17003. var vignetteWeightKeys = [];
  17004. vignetteWeightKeys.push({
  17005. frame: 0,
  17006. value: 0
  17007. });
  17008. vignetteWeightKeys.push({
  17009. frame: 3,
  17010. value: 4
  17011. });
  17012. vignetteWeightKeys.push({
  17013. frame: 6,
  17014. value: 0
  17015. });
  17016. animationPP.setKeys(vignetteWeightKeys);
  17017. animationPP.setEasingFunction(this._circleEase);
  17018. this._postProcessMove.animations.push(animationPP);
  17019. 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);
  17020. var vignetteStretchKeys = [];
  17021. vignetteStretchKeys.push({
  17022. frame: 0,
  17023. value: 0
  17024. });
  17025. vignetteStretchKeys.push({
  17026. frame: 3,
  17027. value: 10
  17028. });
  17029. vignetteStretchKeys.push({
  17030. frame: 6,
  17031. value: 0
  17032. });
  17033. animationPP2.setKeys(vignetteStretchKeys);
  17034. animationPP2.setEasingFunction(this._circleEase);
  17035. this._postProcessMove.animations.push(animationPP2);
  17036. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17037. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17038. this._postProcessMove.samples = 4;
  17039. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17040. this._scene.beginAnimation(this._postProcessMove, 0, 6, false, 1, function () {
  17041. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17042. });
  17043. this._scene.beginAnimation(this.currentVRCamera, 0, 6, false, 1);
  17044. };
  17045. VRExperienceHelper.prototype._moveTeleportationSelectorTo = function (hit, gazer, ray) {
  17046. if (hit.pickedPoint) {
  17047. if (gazer._teleportationRequestInitiated) {
  17048. this._displayTeleportationTarget();
  17049. this._haloCenter.copyFrom(hit.pickedPoint);
  17050. this._teleportationTarget.position.copyFrom(hit.pickedPoint);
  17051. }
  17052. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(true, false), ray);
  17053. if (pickNormal) {
  17054. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17055. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17056. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, this._teleportationTarget.rotation);
  17057. }
  17058. this._teleportationTarget.position.y += 0.1;
  17059. }
  17060. };
  17061. /**
  17062. * Teleports the users feet to the desired location
  17063. * @param location The location where the user's feet should be placed
  17064. */
  17065. VRExperienceHelper.prototype.teleportCamera = function (location) {
  17066. var _this = this;
  17067. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17068. return;
  17069. }
  17070. // Teleport the hmd to where the user is looking by moving the anchor to where they are looking minus the
  17071. // offset of the headset from the anchor.
  17072. if (this.webVRCamera.leftCamera) {
  17073. this._workingVector.copyFrom(this.webVRCamera.leftCamera.globalPosition);
  17074. this._workingVector.subtractInPlace(this.webVRCamera.position);
  17075. location.subtractToRef(this._workingVector, this._workingVector);
  17076. }
  17077. else {
  17078. this._workingVector.copyFrom(location);
  17079. }
  17080. // Add height to account for user's height offset
  17081. if (this.isInVRMode) {
  17082. this._workingVector.y += this.webVRCamera.deviceDistanceToRoomGround() * this._webVRCamera.deviceScaleFactor;
  17083. }
  17084. else {
  17085. this._workingVector.y += this._defaultHeight;
  17086. }
  17087. this.onBeforeCameraTeleport.notifyObservers(this._workingVector);
  17088. // Create animation from the camera's position to the new location
  17089. this.currentVRCamera.animations = [];
  17090. 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);
  17091. var animationCameraTeleportationKeys = [{
  17092. frame: 0,
  17093. value: this.currentVRCamera.position
  17094. },
  17095. {
  17096. frame: 11,
  17097. value: this._workingVector
  17098. }
  17099. ];
  17100. animationCameraTeleportation.setKeys(animationCameraTeleportationKeys);
  17101. animationCameraTeleportation.setEasingFunction(this._circleEase);
  17102. this.currentVRCamera.animations.push(animationCameraTeleportation);
  17103. this._postProcessMove.animations = [];
  17104. 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);
  17105. var vignetteWeightKeys = [];
  17106. vignetteWeightKeys.push({
  17107. frame: 0,
  17108. value: 0
  17109. });
  17110. vignetteWeightKeys.push({
  17111. frame: 5,
  17112. value: 8
  17113. });
  17114. vignetteWeightKeys.push({
  17115. frame: 11,
  17116. value: 0
  17117. });
  17118. animationPP.setKeys(vignetteWeightKeys);
  17119. this._postProcessMove.animations.push(animationPP);
  17120. 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);
  17121. var vignetteStretchKeys = [];
  17122. vignetteStretchKeys.push({
  17123. frame: 0,
  17124. value: 0
  17125. });
  17126. vignetteStretchKeys.push({
  17127. frame: 5,
  17128. value: 10
  17129. });
  17130. vignetteStretchKeys.push({
  17131. frame: 11,
  17132. value: 0
  17133. });
  17134. animationPP2.setKeys(vignetteStretchKeys);
  17135. this._postProcessMove.animations.push(animationPP2);
  17136. this._postProcessMove.imageProcessingConfiguration.vignetteWeight = 0;
  17137. this._postProcessMove.imageProcessingConfiguration.vignetteStretch = 0;
  17138. this._webVRCamera.attachPostProcess(this._postProcessMove);
  17139. this._scene.beginAnimation(this._postProcessMove, 0, 11, false, 1, function () {
  17140. _this._webVRCamera.detachPostProcess(_this._postProcessMove);
  17141. });
  17142. this._scene.beginAnimation(this.currentVRCamera, 0, 11, false, 1, function () {
  17143. _this.onAfterCameraTeleport.notifyObservers(_this._workingVector);
  17144. });
  17145. this._hideTeleportationTarget();
  17146. };
  17147. VRExperienceHelper.prototype._convertNormalToDirectionOfRay = function (normal, ray) {
  17148. if (normal) {
  17149. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Dot(normal, ray.direction));
  17150. if (angle < Math.PI / 2) {
  17151. normal.scaleInPlace(-1);
  17152. }
  17153. }
  17154. return normal;
  17155. };
  17156. VRExperienceHelper.prototype._castRayAndSelectObject = function (gazer) {
  17157. if (!(this.currentVRCamera instanceof _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"])) {
  17158. return;
  17159. }
  17160. var ray = gazer._getForwardRay(this._rayLength);
  17161. var hit = this._scene.pickWithRay(ray, this._raySelectionPredicate);
  17162. if (hit) {
  17163. // Populate the contrllers mesh that can be used for drag/drop
  17164. if (gazer._laserPointer) {
  17165. hit.originMesh = gazer._laserPointer.parent;
  17166. }
  17167. this._scene.simulatePointerMove(hit, { pointerId: gazer._id });
  17168. }
  17169. gazer._currentHit = hit;
  17170. // Moving the gazeTracker on the mesh face targetted
  17171. if (hit && hit.pickedPoint) {
  17172. if (this._displayGaze) {
  17173. var multiplier = 1;
  17174. gazer._gazeTracker.isVisible = true;
  17175. if (gazer._isActionableMesh) {
  17176. multiplier = 3;
  17177. }
  17178. if (this.updateGazeTrackerScale) {
  17179. gazer._gazeTracker.scaling.x = hit.distance * multiplier;
  17180. gazer._gazeTracker.scaling.y = hit.distance * multiplier;
  17181. gazer._gazeTracker.scaling.z = hit.distance * multiplier;
  17182. }
  17183. var pickNormal = this._convertNormalToDirectionOfRay(hit.getNormal(), ray);
  17184. // To avoid z-fighting
  17185. var deltaFighting = 0.002;
  17186. if (pickNormal) {
  17187. var axis1 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(_Maths_math__WEBPACK_IMPORTED_MODULE_9__["Axis"].Y, pickNormal);
  17188. var axis2 = _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].Cross(pickNormal, axis1);
  17189. _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Vector3"].RotationFromAxisToRef(axis2, pickNormal, axis1, gazer._gazeTracker.rotation);
  17190. }
  17191. gazer._gazeTracker.position.copyFrom(hit.pickedPoint);
  17192. if (gazer._gazeTracker.position.x < 0) {
  17193. gazer._gazeTracker.position.x += deltaFighting;
  17194. }
  17195. else {
  17196. gazer._gazeTracker.position.x -= deltaFighting;
  17197. }
  17198. if (gazer._gazeTracker.position.y < 0) {
  17199. gazer._gazeTracker.position.y += deltaFighting;
  17200. }
  17201. else {
  17202. gazer._gazeTracker.position.y -= deltaFighting;
  17203. }
  17204. if (gazer._gazeTracker.position.z < 0) {
  17205. gazer._gazeTracker.position.z += deltaFighting;
  17206. }
  17207. else {
  17208. gazer._gazeTracker.position.z -= deltaFighting;
  17209. }
  17210. }
  17211. // Changing the size of the laser pointer based on the distance from the targetted point
  17212. gazer._updatePointerDistance(hit.distance);
  17213. }
  17214. else {
  17215. gazer._updatePointerDistance();
  17216. gazer._gazeTracker.isVisible = false;
  17217. }
  17218. if (hit && hit.pickedMesh) {
  17219. // The object selected is the floor, we're in a teleportation scenario
  17220. if (this._teleportationInitialized && this._isTeleportationFloor(hit.pickedMesh) && hit.pickedPoint) {
  17221. // Moving the teleportation area to this targetted point
  17222. //Raise onSelectedMeshUnselected observable if ray collided floor mesh/meshes and a non floor mesh was previously selected
  17223. if (gazer._currentMeshSelected && !this._isTeleportationFloor(gazer._currentMeshSelected)) {
  17224. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17225. }
  17226. gazer._currentMeshSelected = null;
  17227. if (gazer._teleportationRequestInitiated) {
  17228. this._moveTeleportationSelectorTo(hit, gazer, ray);
  17229. }
  17230. return;
  17231. }
  17232. // If not, we're in a selection scenario
  17233. //this._teleportationAllowed = false;
  17234. if (hit.pickedMesh !== gazer._currentMeshSelected) {
  17235. if (this.meshSelectionPredicate(hit.pickedMesh)) {
  17236. this.onNewMeshPicked.notifyObservers(hit);
  17237. gazer._currentMeshSelected = hit.pickedMesh;
  17238. if (hit.pickedMesh.isPickable && hit.pickedMesh.actionManager) {
  17239. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0, 0, 1));
  17240. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.2, 0.2, 1));
  17241. gazer._isActionableMesh = true;
  17242. }
  17243. else {
  17244. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17245. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17246. gazer._isActionableMesh = false;
  17247. }
  17248. try {
  17249. this.onNewMeshSelected.notifyObservers(hit.pickedMesh);
  17250. }
  17251. catch (err) {
  17252. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Error in your custom logic onNewMeshSelected: " + err);
  17253. }
  17254. }
  17255. else {
  17256. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17257. gazer._currentMeshSelected = null;
  17258. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17259. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17260. }
  17261. }
  17262. }
  17263. else {
  17264. this._notifySelectedMeshUnselected(gazer._currentMeshSelected);
  17265. gazer._currentMeshSelected = null;
  17266. //this._teleportationAllowed = false;
  17267. this.changeGazeColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17268. this.changeLaserColor(new _Maths_math__WEBPACK_IMPORTED_MODULE_9__["Color3"](0.7, 0.7, 0.7));
  17269. }
  17270. };
  17271. VRExperienceHelper.prototype._notifySelectedMeshUnselected = function (mesh) {
  17272. if (mesh) {
  17273. this.onSelectedMeshUnselected.notifyObservers(mesh);
  17274. }
  17275. };
  17276. /**
  17277. * Sets the color of the laser ray from the vr controllers.
  17278. * @param color new color for the ray.
  17279. */
  17280. VRExperienceHelper.prototype.changeLaserColor = function (color) {
  17281. if (this._leftController) {
  17282. this._leftController._setLaserPointerColor(color);
  17283. }
  17284. if (this._rightController) {
  17285. this._rightController._setLaserPointerColor(color);
  17286. }
  17287. };
  17288. /**
  17289. * Sets the color of the ray from the vr headsets gaze.
  17290. * @param color new color for the ray.
  17291. */
  17292. VRExperienceHelper.prototype.changeGazeColor = function (color) {
  17293. if (!this.updateGazeTrackerColor) {
  17294. return;
  17295. }
  17296. if (!this._cameraGazer._gazeTracker.material) {
  17297. return;
  17298. }
  17299. this._cameraGazer._gazeTracker.material.emissiveColor = color;
  17300. if (this._leftController) {
  17301. this._leftController._gazeTracker.material.emissiveColor = color;
  17302. }
  17303. if (this._rightController) {
  17304. this._rightController._gazeTracker.material.emissiveColor = color;
  17305. }
  17306. };
  17307. /**
  17308. * Exits VR and disposes of the vr experience helper
  17309. */
  17310. VRExperienceHelper.prototype.dispose = function () {
  17311. if (this.isInVRMode) {
  17312. this.exitVR();
  17313. }
  17314. if (this._postProcessMove) {
  17315. this._postProcessMove.dispose();
  17316. }
  17317. if (this._webVRCamera) {
  17318. this._webVRCamera.dispose();
  17319. }
  17320. if (this._vrDeviceOrientationCamera) {
  17321. this._vrDeviceOrientationCamera.dispose();
  17322. }
  17323. if (!this._useCustomVRButton && this._btnVR.parentNode) {
  17324. document.body.removeChild(this._btnVR);
  17325. }
  17326. if (this._deviceOrientationCamera && (this._scene.activeCamera != this._deviceOrientationCamera)) {
  17327. this._deviceOrientationCamera.dispose();
  17328. }
  17329. if (this._cameraGazer) {
  17330. this._cameraGazer.dispose();
  17331. }
  17332. if (this._leftController) {
  17333. this._leftController.dispose();
  17334. }
  17335. if (this._rightController) {
  17336. this._rightController.dispose();
  17337. }
  17338. if (this._teleportationTarget) {
  17339. this._teleportationTarget.dispose();
  17340. }
  17341. this._floorMeshesCollection = [];
  17342. document.removeEventListener("keydown", this._onKeyDown);
  17343. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17344. window.removeEventListener("resize", this._onResize);
  17345. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  17346. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  17347. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  17348. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  17349. document.onmsfullscreenchange = null;
  17350. this._scene.getEngine().onVRDisplayChangedObservable.removeCallback(this._onVRDisplayChanged);
  17351. this._scene.getEngine().onVRRequestPresentStart.removeCallback(this._onVRRequestPresentStart);
  17352. this._scene.getEngine().onVRRequestPresentComplete.removeCallback(this._onVRRequestPresentComplete);
  17353. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  17354. this._scene.gamepadManager.onGamepadConnectedObservable.removeCallback(this._onNewGamepadConnected);
  17355. this._scene.gamepadManager.onGamepadDisconnectedObservable.removeCallback(this._onNewGamepadDisconnected);
  17356. this._scene.unregisterBeforeRender(this.beforeRender);
  17357. };
  17358. /**
  17359. * Gets the name of the VRExperienceHelper class
  17360. * @returns "VRExperienceHelper"
  17361. */
  17362. VRExperienceHelper.prototype.getClassName = function () {
  17363. return "VRExperienceHelper";
  17364. };
  17365. return VRExperienceHelper;
  17366. }());
  17367. /***/ }),
  17368. /***/ "./Cameras/VR/webVRCamera.ts":
  17369. /*!***********************************!*\
  17370. !*** ./Cameras/VR/webVRCamera.ts ***!
  17371. \***********************************/
  17372. /*! exports provided: WebVRFreeCamera */
  17373. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17374. "use strict";
  17375. __webpack_require__.r(__webpack_exports__);
  17376. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return WebVRFreeCamera; });
  17377. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  17378. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  17379. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  17380. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  17381. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  17382. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  17383. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  17384. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../node */ "./node.ts");
  17385. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  17386. /* harmony import */ var _RigModes_webVRRigMode__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../RigModes/webVRRigMode */ "./Cameras/RigModes/webVRRigMode.ts");
  17387. // Side effect import to define the stereoscopic mode.
  17388. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRFreeCamera", function (name, scene) {
  17389. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17390. });
  17391. _node__WEBPACK_IMPORTED_MODULE_7__["Node"].AddNodeConstructor("WebVRGamepadCamera", function (name, scene) {
  17392. return function () { return new WebVRFreeCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  17393. });
  17394. /**
  17395. * This represents a WebVR camera.
  17396. * The WebVR camera is Babylon's simple interface to interaction with Windows Mixed Reality, HTC Vive and Oculus Rift.
  17397. * @example http://doc.babylonjs.com/how_to/webvr_camera
  17398. */
  17399. var WebVRFreeCamera = /** @class */ (function (_super) {
  17400. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRFreeCamera, _super);
  17401. /**
  17402. * Instantiates a WebVRFreeCamera.
  17403. * @param name The name of the WebVRFreeCamera
  17404. * @param position The starting anchor position for the camera
  17405. * @param scene The scene the camera belongs to
  17406. * @param webVROptions a set of customizable options for the webVRCamera
  17407. */
  17408. function WebVRFreeCamera(name, position, scene, webVROptions) {
  17409. if (webVROptions === void 0) { webVROptions = {}; }
  17410. var _this = _super.call(this, name, position, scene) || this;
  17411. _this.webVROptions = webVROptions;
  17412. /**
  17413. * @hidden
  17414. * The vrDisplay tied to the camera. See https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay
  17415. */
  17416. _this._vrDevice = null;
  17417. /**
  17418. * The rawPose of the vrDevice.
  17419. */
  17420. _this.rawPose = null;
  17421. _this._specsVersion = "1.1";
  17422. _this._attached = false;
  17423. _this._descendants = [];
  17424. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  17425. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17426. /** @hidden */
  17427. _this._deviceRoomRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17428. _this._standingMatrix = null;
  17429. /**
  17430. * Represents device position in babylon space.
  17431. */
  17432. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17433. /**
  17434. * Represents device rotation in babylon space.
  17435. */
  17436. _this.deviceRotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].Identity();
  17437. /**
  17438. * The scale of the device to be used when translating from device space to babylon space.
  17439. */
  17440. _this.deviceScaleFactor = 1;
  17441. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17442. _this._worldToDevice = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17443. /**
  17444. * References to the webVR controllers for the vrDevice.
  17445. */
  17446. _this.controllers = [];
  17447. /**
  17448. * Emits an event when a controller is attached.
  17449. */
  17450. _this.onControllersAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17451. /**
  17452. * Emits an event when a controller's mesh has been loaded;
  17453. */
  17454. _this.onControllerMeshLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17455. /**
  17456. * Emits an event when the HMD's pose has been updated.
  17457. */
  17458. _this.onPoseUpdatedFromDeviceObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  17459. _this._poseSet = false;
  17460. /**
  17461. * If the rig cameras be used as parent instead of this camera.
  17462. */
  17463. _this.rigParenting = true;
  17464. _this._defaultHeight = undefined;
  17465. _this._htmlElementAttached = null;
  17466. _this._detachIfAttached = function () {
  17467. var vrDisplay = _this.getEngine().getVRDevice();
  17468. if (vrDisplay && !vrDisplay.isPresenting && _this._htmlElementAttached) {
  17469. _this.detachControl(_this._htmlElementAttached);
  17470. }
  17471. };
  17472. _this._workingVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17473. _this._oneVector = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].One();
  17474. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17475. _this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17476. _this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  17477. if (webVROptions.defaultHeight) {
  17478. _this._defaultHeight = webVROptions.defaultHeight;
  17479. _this.position.y = _this._defaultHeight;
  17480. }
  17481. _this.minZ = 0.1;
  17482. //legacy support - the compensation boolean was removed.
  17483. if (arguments.length === 5) {
  17484. _this.webVROptions = arguments[4];
  17485. }
  17486. // default webVR options
  17487. if (_this.webVROptions.trackPosition == undefined) {
  17488. _this.webVROptions.trackPosition = true;
  17489. }
  17490. if (_this.webVROptions.controllerMeshes == undefined) {
  17491. _this.webVROptions.controllerMeshes = true;
  17492. }
  17493. if (_this.webVROptions.defaultLightingOnControllers == undefined) {
  17494. _this.webVROptions.defaultLightingOnControllers = true;
  17495. }
  17496. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"]();
  17497. if (_this.webVROptions && _this.webVROptions.positionScale) {
  17498. _this.deviceScaleFactor = _this.webVROptions.positionScale;
  17499. }
  17500. //enable VR
  17501. var engine = _this.getEngine();
  17502. _this._onVREnabled = function (success) { if (success) {
  17503. _this.initControllers();
  17504. } };
  17505. engine.onVRRequestPresentComplete.add(_this._onVREnabled);
  17506. engine.initWebVR().add(function (event) {
  17507. if (!event.vrDisplay || _this._vrDevice === event.vrDisplay) {
  17508. return;
  17509. }
  17510. _this._vrDevice = event.vrDisplay;
  17511. //reset the rig parameters.
  17512. _this.setCameraRigMode(_Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].RIG_MODE_WEBVR, { parentCamera: _this, vrDisplay: _this._vrDevice, frameData: _this._frameData, specs: _this._specsVersion });
  17513. if (_this._attached) {
  17514. _this.getEngine().enableVR();
  17515. }
  17516. });
  17517. if (typeof (VRFrameData) !== "undefined") {
  17518. _this._frameData = new VRFrameData();
  17519. }
  17520. /**
  17521. * The idea behind the following lines:
  17522. * objects that have the camera as parent should actually have the rig cameras as a parent.
  17523. * BUT, each of those cameras has a different view matrix, which means that if we set the parent to the first rig camera,
  17524. * the second will not show it correctly.
  17525. *
  17526. * To solve this - each object that has the camera as parent will be added to a protected array.
  17527. * When the rig camera renders, it will take this array and set all of those to be its children.
  17528. * This way, the right camera will be used as a parent, and the mesh will be rendered correctly.
  17529. * Amazing!
  17530. */
  17531. scene.onBeforeCameraRenderObservable.add(function (camera) {
  17532. if (camera.parent === _this && _this.rigParenting) {
  17533. _this._descendants = _this.getDescendants(true, function (n) {
  17534. // don't take the cameras or the controllers!
  17535. var isController = _this.controllers.some(function (controller) { return controller._mesh === n; });
  17536. var isRigCamera = _this._rigCameras.indexOf(n) !== -1;
  17537. return !isController && !isRigCamera;
  17538. });
  17539. _this._descendants.forEach(function (node) {
  17540. node.parent = camera;
  17541. });
  17542. }
  17543. });
  17544. scene.onAfterCameraRenderObservable.add(function (camera) {
  17545. if (camera.parent === _this && _this.rigParenting) {
  17546. _this._descendants.forEach(function (node) {
  17547. node.parent = _this;
  17548. });
  17549. }
  17550. });
  17551. return _this;
  17552. }
  17553. /**
  17554. * Gets the device distance from the ground in meters.
  17555. * @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.
  17556. */
  17557. WebVRFreeCamera.prototype.deviceDistanceToRoomGround = function () {
  17558. if (this._standingMatrix) {
  17559. // Add standing matrix offset to get real offset from ground in room
  17560. this._standingMatrix.getTranslationToRef(this._workingVector);
  17561. return this._deviceRoomPosition.y + this._workingVector.y;
  17562. }
  17563. //If VRDisplay does not inform stage parameters and no default height is set we fallback to zero.
  17564. return this._defaultHeight || 0;
  17565. };
  17566. /**
  17567. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17568. * @param callback will be called when the standing matrix is set. Callback parameter is if the standing matrix is supported.
  17569. */
  17570. WebVRFreeCamera.prototype.useStandingMatrix = function (callback) {
  17571. var _this = this;
  17572. if (callback === void 0) { callback = function (bool) { }; }
  17573. // Use standing matrix if available
  17574. this.getEngine().initWebVRAsync().then(function (result) {
  17575. if (!result.vrDisplay || !result.vrDisplay.stageParameters || !result.vrDisplay.stageParameters.sittingToStandingTransform || !_this.webVROptions.trackPosition) {
  17576. callback(false);
  17577. }
  17578. else {
  17579. _this._standingMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  17580. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromFloat32ArrayToRefScaled(result.vrDisplay.stageParameters.sittingToStandingTransform, 0, 1, _this._standingMatrix);
  17581. if (!_this.getScene().useRightHandedSystem) {
  17582. if (_this._standingMatrix) {
  17583. _this._standingMatrix.toggleModelMatrixHandInPlace();
  17584. }
  17585. }
  17586. callback(true);
  17587. }
  17588. });
  17589. };
  17590. /**
  17591. * Enables the standing matrix when supported. This can be used to position the user's view the correct height from the ground.
  17592. * @returns A promise with a boolean set to if the standing matrix is supported.
  17593. */
  17594. WebVRFreeCamera.prototype.useStandingMatrixAsync = function () {
  17595. var _this = this;
  17596. return new Promise(function (res) {
  17597. _this.useStandingMatrix(function (supported) {
  17598. res(supported);
  17599. });
  17600. });
  17601. };
  17602. /**
  17603. * Disposes the camera
  17604. */
  17605. WebVRFreeCamera.prototype.dispose = function () {
  17606. this._detachIfAttached();
  17607. this.getEngine().onVRRequestPresentComplete.removeCallback(this._onVREnabled);
  17608. if (this._updateCacheWhenTrackingDisabledObserver) {
  17609. this._scene.onBeforeRenderObservable.remove(this._updateCacheWhenTrackingDisabledObserver);
  17610. }
  17611. _super.prototype.dispose.call(this);
  17612. };
  17613. /**
  17614. * Gets a vrController by name.
  17615. * @param name The name of the controller to retreive
  17616. * @returns the controller matching the name specified or null if not found
  17617. */
  17618. WebVRFreeCamera.prototype.getControllerByName = function (name) {
  17619. for (var _i = 0, _a = this.controllers; _i < _a.length; _i++) {
  17620. var gp = _a[_i];
  17621. if (gp.hand === name) {
  17622. return gp;
  17623. }
  17624. }
  17625. return null;
  17626. };
  17627. Object.defineProperty(WebVRFreeCamera.prototype, "leftController", {
  17628. /**
  17629. * The controller corrisponding to the users left hand.
  17630. */
  17631. get: function () {
  17632. if (!this._leftController) {
  17633. this._leftController = this.getControllerByName("left");
  17634. }
  17635. return this._leftController;
  17636. },
  17637. enumerable: true,
  17638. configurable: true
  17639. });
  17640. Object.defineProperty(WebVRFreeCamera.prototype, "rightController", {
  17641. /**
  17642. * The controller corrisponding to the users right hand.
  17643. */
  17644. get: function () {
  17645. if (!this._rightController) {
  17646. this._rightController = this.getControllerByName("right");
  17647. }
  17648. return this._rightController;
  17649. },
  17650. enumerable: true,
  17651. configurable: true
  17652. });
  17653. /**
  17654. * Casts a ray forward from the vrCamera's gaze.
  17655. * @param length Length of the ray (default: 100)
  17656. * @returns the ray corrisponding to the gaze
  17657. */
  17658. WebVRFreeCamera.prototype.getForwardRay = function (length) {
  17659. if (length === void 0) { length = 100; }
  17660. if (this.leftCamera) {
  17661. // Use left eye to avoid computation to compute center on every call
  17662. return _super.prototype.getForwardRay.call(this, length, this.leftCamera.getWorldMatrix(), this.leftCamera.globalPosition); // Need the actual rendered camera
  17663. }
  17664. else {
  17665. return _super.prototype.getForwardRay.call(this, length);
  17666. }
  17667. };
  17668. /**
  17669. * @hidden
  17670. * Updates the camera based on device's frame data
  17671. */
  17672. WebVRFreeCamera.prototype._checkInputs = function () {
  17673. if (this._vrDevice && this._vrDevice.isPresenting) {
  17674. this._vrDevice.getFrameData(this._frameData);
  17675. this.updateFromDevice(this._frameData.pose);
  17676. }
  17677. _super.prototype._checkInputs.call(this);
  17678. };
  17679. /**
  17680. * Updates the poseControlled values based on the input device pose.
  17681. * @param poseData Pose coming from the device
  17682. */
  17683. WebVRFreeCamera.prototype.updateFromDevice = function (poseData) {
  17684. if (poseData && poseData.orientation) {
  17685. this.rawPose = poseData;
  17686. this._deviceRoomRotationQuaternion.copyFromFloats(poseData.orientation[0], poseData.orientation[1], -poseData.orientation[2], -poseData.orientation[3]);
  17687. if (this.getScene().useRightHandedSystem) {
  17688. this._deviceRoomRotationQuaternion.z *= -1;
  17689. this._deviceRoomRotationQuaternion.w *= -1;
  17690. }
  17691. if (this.webVROptions.trackPosition && this.rawPose.position) {
  17692. this._deviceRoomPosition.copyFromFloats(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2]);
  17693. if (this.getScene().useRightHandedSystem) {
  17694. this._deviceRoomPosition.z *= -1;
  17695. }
  17696. }
  17697. this._poseSet = true;
  17698. }
  17699. };
  17700. /**
  17701. * WebVR's attach control will start broadcasting frames to the device.
  17702. * Note that in certain browsers (chrome for example) this function must be called
  17703. * within a user-interaction callback. Example:
  17704. * <pre> scene.onPointerDown = function() { camera.attachControl(canvas); }</pre>
  17705. *
  17706. * @param element html element to attach the vrDevice to
  17707. * @param noPreventDefault prevent the default html element operation when attaching the vrDevice
  17708. */
  17709. WebVRFreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  17710. _super.prototype.attachControl.call(this, element, noPreventDefault);
  17711. this._attached = true;
  17712. this._htmlElementAttached = element;
  17713. noPreventDefault = _Cameras_camera__WEBPACK_IMPORTED_MODULE_3__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  17714. if (this._vrDevice) {
  17715. this.getEngine().enableVR();
  17716. }
  17717. window.addEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17718. };
  17719. /**
  17720. * Detaches the camera from the html element and disables VR
  17721. *
  17722. * @param element html element to detach from
  17723. */
  17724. WebVRFreeCamera.prototype.detachControl = function (element) {
  17725. this.getScene().gamepadManager.onGamepadConnectedObservable.remove(this._onGamepadConnectedObserver);
  17726. this.getScene().gamepadManager.onGamepadDisconnectedObservable.remove(this._onGamepadDisconnectedObserver);
  17727. _super.prototype.detachControl.call(this, element);
  17728. this._attached = false;
  17729. this.getEngine().disableVR();
  17730. window.removeEventListener('vrdisplaypresentchange', this._detachIfAttached);
  17731. };
  17732. /**
  17733. * @returns the name of this class
  17734. */
  17735. WebVRFreeCamera.prototype.getClassName = function () {
  17736. return "WebVRFreeCamera";
  17737. };
  17738. /**
  17739. * Calls resetPose on the vrDisplay
  17740. * See: https://developer.mozilla.org/en-US/docs/Web/API/VRDisplay/resetPose
  17741. */
  17742. WebVRFreeCamera.prototype.resetToCurrentRotation = function () {
  17743. //uses the vrDisplay's "resetPose()".
  17744. //pitch and roll won't be affected.
  17745. this._vrDevice.resetPose();
  17746. };
  17747. /**
  17748. * @hidden
  17749. * Updates the rig cameras (left and right eye)
  17750. */
  17751. WebVRFreeCamera.prototype._updateRigCameras = function () {
  17752. var camLeft = this._rigCameras[0];
  17753. var camRight = this._rigCameras[1];
  17754. camLeft.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17755. camRight.rotationQuaternion.copyFrom(this._deviceRoomRotationQuaternion);
  17756. camLeft.position.copyFrom(this._deviceRoomPosition);
  17757. camRight.position.copyFrom(this._deviceRoomPosition);
  17758. };
  17759. // Remove translation from 6dof headset if trackposition is set to false
  17760. WebVRFreeCamera.prototype._correctPositionIfNotTrackPosition = function (matrix, isViewMatrix) {
  17761. if (isViewMatrix === void 0) { isViewMatrix = false; }
  17762. if (this.rawPose && this.rawPose.position && !this.webVROptions.trackPosition) {
  17763. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].TranslationToRef(this.rawPose.position[0], this.rawPose.position[1], -this.rawPose.position[2], this._tmpMatrix);
  17764. if (!isViewMatrix) {
  17765. this._tmpMatrix.invert();
  17766. }
  17767. this._tmpMatrix.multiplyToRef(matrix, matrix);
  17768. }
  17769. };
  17770. /**
  17771. * @hidden
  17772. * Updates the cached values of the camera
  17773. * @param ignoreParentClass ignores updating the parent class's cache (default: false)
  17774. */
  17775. WebVRFreeCamera.prototype._updateCache = function (ignoreParentClass) {
  17776. var _this = this;
  17777. if (!this.rotationQuaternion.equals(this._cache.rotationQuaternion) || !this.position.equals(this._cache.position)) {
  17778. // Update to ensure devicePosition is up to date with most recent _deviceRoomPosition
  17779. if (!this.updateCacheCalled) {
  17780. // make sure it is only called once per loop. this.update() might cause an infinite loop.
  17781. this.updateCacheCalled = true;
  17782. this.update();
  17783. }
  17784. // Set working vector to the device position in room space rotated by the new rotation
  17785. this.rotationQuaternion.toRotationMatrix(this._workingMatrix);
  17786. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._workingMatrix, this._workingVector);
  17787. // Subtract this vector from the current device position in world to get the translation for the device world matrix
  17788. this.devicePosition.subtractToRef(this._workingVector, this._workingVector);
  17789. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].ComposeToRef(this._oneVector, this.rotationQuaternion, this._workingVector, this._deviceToWorld);
  17790. // Add translation from anchor position
  17791. this._deviceToWorld.getTranslationToRef(this._workingVector);
  17792. this._workingVector.addInPlace(this.position);
  17793. this._workingVector.subtractInPlace(this._cache.position);
  17794. this._deviceToWorld.setTranslation(this._workingVector);
  17795. // Set an inverted matrix to be used when updating the camera
  17796. this._deviceToWorld.invertToRef(this._worldToDevice);
  17797. // Update the gamepad to ensure the mesh is updated on the same frame as camera
  17798. this.controllers.forEach(function (controller) {
  17799. controller._deviceToWorld.copyFrom(_this._deviceToWorld);
  17800. _this._correctPositionIfNotTrackPosition(controller._deviceToWorld);
  17801. controller.update();
  17802. });
  17803. }
  17804. if (!ignoreParentClass) {
  17805. _super.prototype._updateCache.call(this);
  17806. }
  17807. this.updateCacheCalled = false;
  17808. };
  17809. /**
  17810. * @hidden
  17811. * Get current device position in babylon world
  17812. */
  17813. WebVRFreeCamera.prototype._computeDevicePosition = function () {
  17814. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._deviceRoomPosition, this._deviceToWorld, this.devicePosition);
  17815. };
  17816. /**
  17817. * Updates the current device position and rotation in the babylon world
  17818. */
  17819. WebVRFreeCamera.prototype.update = function () {
  17820. this._computeDevicePosition();
  17821. // Get current device rotation in babylon world
  17822. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromQuaternionToRef(this._deviceRoomRotationQuaternion, this._workingMatrix);
  17823. this._workingMatrix.multiplyToRef(this._deviceToWorld, this._workingMatrix);
  17824. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  17825. if (this._poseSet) {
  17826. this.onPoseUpdatedFromDeviceObservable.notifyObservers(null);
  17827. }
  17828. _super.prototype.update.call(this);
  17829. };
  17830. /**
  17831. * @hidden
  17832. * Gets the view matrix of this camera (Always set to identity as left and right eye cameras contain the actual view matrix)
  17833. * @returns an identity matrix
  17834. */
  17835. WebVRFreeCamera.prototype._getViewMatrix = function () {
  17836. return _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17837. };
  17838. /**
  17839. * This function is called by the two RIG cameras.
  17840. * 'this' is the left or right camera (and NOT (!!!) the WebVRFreeCamera instance)
  17841. * @hidden
  17842. */
  17843. WebVRFreeCamera.prototype._getWebVRViewMatrix = function () {
  17844. // Update the parent camera prior to using a child camera to avoid desynchronization
  17845. var parentCamera = this._cameraRigParams["parentCamera"];
  17846. parentCamera._updateCache();
  17847. //WebVR 1.1
  17848. var viewArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftViewMatrix : this._cameraRigParams["frameData"].rightViewMatrix;
  17849. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(viewArray, 0, this._webvrViewMatrix);
  17850. if (!this.getScene().useRightHandedSystem) {
  17851. this._webvrViewMatrix.toggleModelMatrixHandInPlace();
  17852. }
  17853. // update the camera rotation matrix
  17854. this._webvrViewMatrix.getRotationMatrixToRef(this._cameraRotationMatrix);
  17855. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  17856. // Computing target and final matrix
  17857. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  17858. // should the view matrix be updated with scale and position offset?
  17859. if (parentCamera.deviceScaleFactor !== 1) {
  17860. this._webvrViewMatrix.invert();
  17861. // scale the position, if set
  17862. if (parentCamera.deviceScaleFactor) {
  17863. this._webvrViewMatrix.multiplyAtIndex(12, parentCamera.deviceScaleFactor);
  17864. this._webvrViewMatrix.multiplyAtIndex(13, parentCamera.deviceScaleFactor);
  17865. this._webvrViewMatrix.multiplyAtIndex(14, parentCamera.deviceScaleFactor);
  17866. }
  17867. this._webvrViewMatrix.invert();
  17868. }
  17869. // Remove translation from 6dof headset if trackposition is set to false
  17870. parentCamera._correctPositionIfNotTrackPosition(this._webvrViewMatrix, true);
  17871. parentCamera._worldToDevice.multiplyToRef(this._webvrViewMatrix, this._webvrViewMatrix);
  17872. // Compute global position
  17873. this._workingMatrix = this._workingMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Identity();
  17874. this._webvrViewMatrix.invertToRef(this._workingMatrix);
  17875. this._workingMatrix.multiplyToRef(parentCamera.getWorldMatrix(), this._workingMatrix);
  17876. this._workingMatrix.getTranslationToRef(this._globalPosition);
  17877. this._markSyncedWithParent();
  17878. return this._webvrViewMatrix;
  17879. };
  17880. /** @hidden */
  17881. WebVRFreeCamera.prototype._getWebVRProjectionMatrix = function () {
  17882. var parentCamera = this.parent;
  17883. parentCamera._vrDevice.depthNear = parentCamera.minZ;
  17884. parentCamera._vrDevice.depthFar = parentCamera.maxZ;
  17885. var projectionArray = this._cameraRigParams["left"] ? this._cameraRigParams["frameData"].leftProjectionMatrix : this._cameraRigParams["frameData"].rightProjectionMatrix;
  17886. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].FromArrayToRef(projectionArray, 0, this._projectionMatrix);
  17887. //babylon compatible matrix
  17888. if (!this.getScene().useRightHandedSystem) {
  17889. this._projectionMatrix.toggleProjectionMatrixHandInPlace();
  17890. }
  17891. return this._projectionMatrix;
  17892. };
  17893. /**
  17894. * Initializes the controllers and their meshes
  17895. */
  17896. WebVRFreeCamera.prototype.initControllers = function () {
  17897. var _this = this;
  17898. this.controllers = [];
  17899. var manager = this.getScene().gamepadManager;
  17900. this._onGamepadDisconnectedObserver = manager.onGamepadDisconnectedObservable.add(function (gamepad) {
  17901. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17902. var webVrController = gamepad;
  17903. if (webVrController.defaultModel) {
  17904. webVrController.defaultModel.setEnabled(false);
  17905. }
  17906. if (webVrController.hand === "right") {
  17907. _this._rightController = null;
  17908. }
  17909. if (webVrController.hand === "left") {
  17910. _this._leftController = null;
  17911. }
  17912. var controllerIndex = _this.controllers.indexOf(webVrController);
  17913. if (controllerIndex !== -1) {
  17914. _this.controllers.splice(controllerIndex, 1);
  17915. }
  17916. }
  17917. });
  17918. this._onGamepadConnectedObserver = manager.onGamepadConnectedObservable.add(function (gamepad) {
  17919. if (gamepad.type === _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED) {
  17920. var webVrController_1 = gamepad;
  17921. if (!_this.webVROptions.trackPosition) {
  17922. webVrController_1._disableTrackPosition(new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](webVrController_1.hand == "left" ? -0.15 : 0.15, -0.5, 0.25));
  17923. // Cache must be updated before rendering controllers to avoid them being one frame behind
  17924. if (!_this._updateCacheWhenTrackingDisabledObserver) {
  17925. _this._updateCacheWhenTrackingDisabledObserver = _this._scene.onBeforeRenderObservable.add(function () {
  17926. _this._updateCache();
  17927. });
  17928. }
  17929. }
  17930. webVrController_1.deviceScaleFactor = _this.deviceScaleFactor;
  17931. webVrController_1._deviceToWorld.copyFrom(_this._deviceToWorld);
  17932. _this._correctPositionIfNotTrackPosition(webVrController_1._deviceToWorld);
  17933. if (_this.webVROptions.controllerMeshes) {
  17934. if (webVrController_1.defaultModel) {
  17935. webVrController_1.defaultModel.setEnabled(true);
  17936. }
  17937. else {
  17938. // Load the meshes
  17939. webVrController_1.initControllerMesh(_this.getScene(), function (loadedMesh) {
  17940. loadedMesh.scaling.scaleInPlace(_this.deviceScaleFactor);
  17941. _this.onControllerMeshLoadedObservable.notifyObservers(webVrController_1);
  17942. if (_this.webVROptions.defaultLightingOnControllers) {
  17943. if (!_this._lightOnControllers) {
  17944. _this._lightOnControllers = new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_8__["HemisphericLight"]("vrControllersLight", new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](0, 1, 0), _this.getScene());
  17945. }
  17946. var activateLightOnSubMeshes_1 = function (mesh, light) {
  17947. var children = mesh.getChildren();
  17948. if (children && children.length !== 0) {
  17949. children.forEach(function (mesh) {
  17950. light.includedOnlyMeshes.push(mesh);
  17951. activateLightOnSubMeshes_1(mesh, light);
  17952. });
  17953. }
  17954. };
  17955. _this._lightOnControllers.includedOnlyMeshes.push(loadedMesh);
  17956. activateLightOnSubMeshes_1(loadedMesh, _this._lightOnControllers);
  17957. }
  17958. });
  17959. }
  17960. }
  17961. webVrController_1.attachToPoseControlledCamera(_this);
  17962. // since this is async - sanity check. Is the controller already stored?
  17963. if (_this.controllers.indexOf(webVrController_1) === -1) {
  17964. //add to the controllers array
  17965. _this.controllers.push(webVrController_1);
  17966. // Forced to add some control code for Vive as it doesn't always fill properly the "hand" property
  17967. // Sometimes, both controllers are set correctly (left and right), sometimes none, sometimes only one of them...
  17968. // So we're overriding setting left & right manually to be sure
  17969. var firstViveWandDetected = false;
  17970. for (var i = 0; i < _this.controllers.length; i++) {
  17971. if (_this.controllers[i].controllerType === _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_6__["PoseEnabledControllerType"].VIVE) {
  17972. if (!firstViveWandDetected) {
  17973. firstViveWandDetected = true;
  17974. _this.controllers[i].hand = "left";
  17975. }
  17976. else {
  17977. _this.controllers[i].hand = "right";
  17978. }
  17979. }
  17980. }
  17981. //did we find enough controllers? Great! let the developer know.
  17982. if (_this.controllers.length >= 2) {
  17983. _this.onControllersAttachedObservable.notifyObservers(_this.controllers);
  17984. }
  17985. }
  17986. }
  17987. });
  17988. };
  17989. return WebVRFreeCamera;
  17990. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_2__["FreeCamera"]));
  17991. /***/ }),
  17992. /***/ "./Cameras/XR/index.ts":
  17993. /*!*****************************!*\
  17994. !*** ./Cameras/XR/index.ts ***!
  17995. \*****************************/
  17996. /*! exports provided: WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  17997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  17998. "use strict";
  17999. __webpack_require__.r(__webpack_exports__);
  18000. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18001. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _webXRCamera__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  18002. /* harmony import */ var _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  18003. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIButton"]; });
  18004. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUIOptions"]; });
  18005. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _webXREnterExitUI__WEBPACK_IMPORTED_MODULE_1__["WebXREnterExitUI"]; });
  18006. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18007. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"]; });
  18008. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRExperienceHelper"]; });
  18009. /* harmony import */ var _webXRInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRInput */ "./Cameras/XR/webXRInput.ts");
  18010. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRController"]; });
  18011. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _webXRInput__WEBPACK_IMPORTED_MODULE_3__["WebXRInput"]; });
  18012. /* harmony import */ var _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  18013. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_4__["WebXRManagedOutputCanvas"]; });
  18014. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18015. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _webXRSessionManager__WEBPACK_IMPORTED_MODULE_5__["WebXRSessionManager"]; });
  18016. /***/ }),
  18017. /***/ "./Cameras/XR/webXRCamera.ts":
  18018. /*!***********************************!*\
  18019. !*** ./Cameras/XR/webXRCamera.ts ***!
  18020. \***********************************/
  18021. /*! exports provided: WebXRCamera */
  18022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18023. "use strict";
  18024. __webpack_require__.r(__webpack_exports__);
  18025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return WebXRCamera; });
  18026. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18027. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18028. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  18029. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  18030. /* harmony import */ var _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Cameras/targetCamera */ "./Cameras/targetCamera.ts");
  18031. /**
  18032. * WebXR Camera which holds the views for the xrSession
  18033. * @see https://doc.babylonjs.com/how_to/webxr
  18034. */
  18035. var WebXRCamera = /** @class */ (function (_super) {
  18036. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebXRCamera, _super);
  18037. /**
  18038. * Creates a new webXRCamera, this should only be set at the camera after it has been updated by the xrSessionManager
  18039. * @param name the name of the camera
  18040. * @param scene the scene to add the camera to
  18041. */
  18042. function WebXRCamera(name, scene) {
  18043. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), scene) || this;
  18044. // Initial camera configuration
  18045. _this.minZ = 0;
  18046. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18047. _this.cameraRigMode = _Cameras_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_CUSTOM;
  18048. _this.updateUpVectorFromRotation = true;
  18049. _this._updateNumberOfRigCameras(1);
  18050. return _this;
  18051. }
  18052. WebXRCamera.prototype._updateNumberOfRigCameras = function (viewCount) {
  18053. if (viewCount === void 0) { viewCount = 1; }
  18054. while (this.rigCameras.length < viewCount) {
  18055. var newCamera = new _Cameras_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]("view: " + this.rigCameras.length, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), this.getScene());
  18056. newCamera.minZ = 0;
  18057. newCamera.parent = this;
  18058. newCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  18059. newCamera.updateUpVectorFromRotation = true;
  18060. this.rigCameras.push(newCamera);
  18061. }
  18062. while (this.rigCameras.length > viewCount) {
  18063. var removedCamera = this.rigCameras.pop();
  18064. if (removedCamera) {
  18065. removedCamera.dispose();
  18066. }
  18067. }
  18068. };
  18069. /** @hidden */
  18070. WebXRCamera.prototype._updateForDualEyeDebugging = function (pupilDistance) {
  18071. if (pupilDistance === void 0) { pupilDistance = 0.01; }
  18072. // Create initial camera rigs
  18073. this._updateNumberOfRigCameras(2);
  18074. this.rigCameras[0].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0, 0, 0.5, 1.0);
  18075. this.rigCameras[0].position.x = -pupilDistance / 2;
  18076. this.rigCameras[0].outputRenderTarget = null;
  18077. this.rigCameras[1].viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Viewport"](0.5, 0, 0.5, 1.0);
  18078. this.rigCameras[1].position.x = pupilDistance / 2;
  18079. this.rigCameras[1].outputRenderTarget = null;
  18080. };
  18081. /**
  18082. * Updates the cameras position from the current pose information of the XR session
  18083. * @param xrSessionManager the session containing pose information
  18084. * @returns true if the camera has been updated, false if the session did not contain pose or frame data
  18085. */
  18086. WebXRCamera.prototype.updateFromXRSessionManager = function (xrSessionManager) {
  18087. var _this = this;
  18088. // Ensure all frame data is available
  18089. if (!xrSessionManager._currentXRFrame || !xrSessionManager._currentXRFrame.getDevicePose) {
  18090. return false;
  18091. }
  18092. var pose = xrSessionManager._currentXRFrame.getDevicePose(xrSessionManager._frameOfReference);
  18093. if (!pose || !pose.poseModelMatrix) {
  18094. return false;
  18095. }
  18096. // Update the parent cameras matrix
  18097. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.poseModelMatrix, 0, 1, WebXRCamera._TmpMatrix);
  18098. if (!this._scene.useRightHandedSystem) {
  18099. WebXRCamera._TmpMatrix.toggleModelMatrixHandInPlace();
  18100. }
  18101. WebXRCamera._TmpMatrix.getTranslationToRef(this.position);
  18102. WebXRCamera._TmpMatrix.getRotationMatrixToRef(WebXRCamera._TmpMatrix);
  18103. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromRotationMatrixToRef(WebXRCamera._TmpMatrix, this.rotationQuaternion);
  18104. this.computeWorldMatrix();
  18105. // Update camera rigs
  18106. this._updateNumberOfRigCameras(xrSessionManager._currentXRFrame.views.length);
  18107. xrSessionManager._currentXRFrame.views.forEach(function (view, i) {
  18108. // Update view/projection matrix
  18109. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(pose.getViewMatrix(view), 0, 1, _this.rigCameras[i]._computedViewMatrix);
  18110. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].FromFloat32ArrayToRefScaled(view.projectionMatrix, 0, 1, _this.rigCameras[i]._projectionMatrix);
  18111. if (!_this._scene.useRightHandedSystem) {
  18112. _this.rigCameras[i]._computedViewMatrix.toggleModelMatrixHandInPlace();
  18113. _this.rigCameras[i]._projectionMatrix.toggleProjectionMatrixHandInPlace();
  18114. }
  18115. // Update viewport
  18116. var viewport = xrSessionManager._xrSession.baseLayer.getViewport(view);
  18117. var width = xrSessionManager._xrSession.baseLayer.framebufferWidth;
  18118. var height = xrSessionManager._xrSession.baseLayer.framebufferHeight;
  18119. _this.rigCameras[i].viewport.width = viewport.width / width;
  18120. _this.rigCameras[i].viewport.height = viewport.height / height;
  18121. _this.rigCameras[i].viewport.x = viewport.x / width;
  18122. _this.rigCameras[i].viewport.y = viewport.y / height;
  18123. // Set cameras to render to the session's render target
  18124. _this.rigCameras[i].outputRenderTarget = xrSessionManager._sessionRenderTargetTexture;
  18125. });
  18126. return true;
  18127. };
  18128. WebXRCamera._TmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  18129. return WebXRCamera;
  18130. }(_Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_3__["FreeCamera"]));
  18131. /***/ }),
  18132. /***/ "./Cameras/XR/webXREnterExitUI.ts":
  18133. /*!****************************************!*\
  18134. !*** ./Cameras/XR/webXREnterExitUI.ts ***!
  18135. \****************************************/
  18136. /*! exports provided: WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI */
  18137. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18138. "use strict";
  18139. __webpack_require__.r(__webpack_exports__);
  18140. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return WebXREnterExitUIButton; });
  18141. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return WebXREnterExitUIOptions; });
  18142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return WebXREnterExitUI; });
  18143. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18144. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18145. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18146. /**
  18147. * Button which can be used to enter a different mode of XR
  18148. */
  18149. var WebXREnterExitUIButton = /** @class */ (function () {
  18150. /**
  18151. * Creates a WebXREnterExitUIButton
  18152. * @param element button element
  18153. * @param initializationOptions XR initialization options for the button
  18154. */
  18155. function WebXREnterExitUIButton(
  18156. /** button element */
  18157. element,
  18158. /** XR initialization options for the button */
  18159. initializationOptions) {
  18160. this.element = element;
  18161. this.initializationOptions = initializationOptions;
  18162. }
  18163. /**
  18164. * Overwritable function which can be used to update the button's visuals when the state changes
  18165. * @param activeButton the current active button in the UI
  18166. */
  18167. WebXREnterExitUIButton.prototype.update = function (activeButton) {
  18168. };
  18169. return WebXREnterExitUIButton;
  18170. }());
  18171. /**
  18172. * Options to create the webXR UI
  18173. */
  18174. var WebXREnterExitUIOptions = /** @class */ (function () {
  18175. function WebXREnterExitUIOptions() {
  18176. }
  18177. return WebXREnterExitUIOptions;
  18178. }());
  18179. /**
  18180. * UI to allow the user to enter/exit XR mode
  18181. */
  18182. var WebXREnterExitUI = /** @class */ (function () {
  18183. function WebXREnterExitUI(scene, options) {
  18184. var _this = this;
  18185. this.scene = scene;
  18186. this._buttons = [];
  18187. this._activeButton = null;
  18188. /**
  18189. * Fired every time the active button is changed.
  18190. *
  18191. * When xr is entered via a button that launches xr that button will be the callback parameter
  18192. *
  18193. * When exiting xr the callback parameter will be null)
  18194. */
  18195. this.activeButtonChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18196. this._overlay = document.createElement("div");
  18197. this._overlay.style.cssText = "z-index:11;position: absolute; right: 20px;bottom: 50px;";
  18198. if (options.customButtons) {
  18199. this._buttons = options.customButtons;
  18200. }
  18201. else {
  18202. var hmdBtn = document.createElement("button");
  18203. 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;";
  18204. hmdBtn.innerText = "HMD";
  18205. this._buttons.push(new WebXREnterExitUIButton(hmdBtn, { immersive: true, outputContext: options.outputCanvasContext }));
  18206. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18207. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18208. this.element.innerText = activeButton === this ? "EXIT" : "HMD";
  18209. };
  18210. var windowBtn = document.createElement("button");
  18211. windowBtn.style.cssText = hmdBtn.style.cssText;
  18212. windowBtn.innerText = "Window";
  18213. this._buttons.push(new WebXREnterExitUIButton(windowBtn, { immersive: false, environmentIntegration: true, outputContext: options.outputCanvasContext }));
  18214. this._buttons[this._buttons.length - 1].update = function (activeButton) {
  18215. this.element.style.display = (activeButton === null || activeButton === this) ? "" : "none";
  18216. this.element.innerText = activeButton === this ? "EXIT" : "Window";
  18217. };
  18218. this._updateButtons(null);
  18219. }
  18220. var renderCanvas = scene.getEngine().getRenderingCanvas();
  18221. if (renderCanvas && renderCanvas.parentNode) {
  18222. renderCanvas.parentNode.appendChild(this._overlay);
  18223. scene.onDisposeObservable.addOnce(function () {
  18224. _this.dispose();
  18225. });
  18226. }
  18227. }
  18228. /**
  18229. * Creates UI to allow the user to enter/exit XR mode
  18230. * @param scene the scene to add the ui to
  18231. * @param helper the xr experience helper to enter/exit xr with
  18232. * @param options options to configure the UI
  18233. * @returns the created ui
  18234. */
  18235. WebXREnterExitUI.CreateAsync = function (scene, helper, options) {
  18236. var _this = this;
  18237. var ui = new WebXREnterExitUI(scene, options);
  18238. var supportedPromises = ui._buttons.map(function (btn) {
  18239. return helper.supportsSessionAsync(btn.initializationOptions);
  18240. });
  18241. helper.onStateChangedObservable.add(function (state) {
  18242. if (state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR) {
  18243. ui._updateButtons(null);
  18244. }
  18245. });
  18246. return Promise.all(supportedPromises).then(function (results) {
  18247. results.forEach(function (supported, i) {
  18248. if (supported) {
  18249. ui._overlay.appendChild(ui._buttons[i].element);
  18250. ui._buttons[i].element.onclick = function () { return tslib__WEBPACK_IMPORTED_MODULE_0__["__awaiter"](_this, void 0, void 0, function () {
  18251. return tslib__WEBPACK_IMPORTED_MODULE_0__["__generator"](this, function (_a) {
  18252. switch (_a.label) {
  18253. case 0:
  18254. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].IN_XR)) return [3 /*break*/, 2];
  18255. ui._updateButtons(null);
  18256. return [4 /*yield*/, helper.exitXRAsync()];
  18257. case 1:
  18258. _a.sent();
  18259. return [2 /*return*/];
  18260. case 2:
  18261. if (!(helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_2__["WebXRState"].NOT_IN_XR)) return [3 /*break*/, 4];
  18262. ui._updateButtons(ui._buttons[i]);
  18263. return [4 /*yield*/, helper.enterXRAsync(ui._buttons[i].initializationOptions, "eye-level")];
  18264. case 3:
  18265. _a.sent();
  18266. _a.label = 4;
  18267. case 4: return [2 /*return*/];
  18268. }
  18269. });
  18270. }); };
  18271. }
  18272. });
  18273. return ui;
  18274. });
  18275. };
  18276. WebXREnterExitUI.prototype._updateButtons = function (activeButton) {
  18277. var _this = this;
  18278. this._activeButton = activeButton;
  18279. this._buttons.forEach(function (b) {
  18280. b.update(_this._activeButton);
  18281. });
  18282. this.activeButtonChangedObservable.notifyObservers(this._activeButton);
  18283. };
  18284. /**
  18285. * Disposes of the object
  18286. */
  18287. WebXREnterExitUI.prototype.dispose = function () {
  18288. var renderCanvas = this.scene.getEngine().getRenderingCanvas();
  18289. if (renderCanvas && renderCanvas.parentNode && renderCanvas.parentNode.contains(this._overlay)) {
  18290. renderCanvas.parentNode.removeChild(this._overlay);
  18291. }
  18292. this.activeButtonChangedObservable.clear();
  18293. };
  18294. return WebXREnterExitUI;
  18295. }());
  18296. /***/ }),
  18297. /***/ "./Cameras/XR/webXRExperienceHelper.ts":
  18298. /*!*********************************************!*\
  18299. !*** ./Cameras/XR/webXRExperienceHelper.ts ***!
  18300. \*********************************************/
  18301. /*! exports provided: WebXRState, WebXRExperienceHelper */
  18302. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18303. "use strict";
  18304. __webpack_require__.r(__webpack_exports__);
  18305. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return WebXRState; });
  18306. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return WebXRExperienceHelper; });
  18307. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18308. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18309. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18310. /* harmony import */ var _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webXRSessionManager */ "./Cameras/XR/webXRSessionManager.ts");
  18311. /* harmony import */ var _webXRCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webXRCamera */ "./Cameras/XR/webXRCamera.ts");
  18312. /**
  18313. * States of the webXR experience
  18314. */
  18315. var WebXRState;
  18316. (function (WebXRState) {
  18317. /**
  18318. * Transitioning to being in XR mode
  18319. */
  18320. WebXRState[WebXRState["ENTERING_XR"] = 0] = "ENTERING_XR";
  18321. /**
  18322. * Transitioning to non XR mode
  18323. */
  18324. WebXRState[WebXRState["EXITING_XR"] = 1] = "EXITING_XR";
  18325. /**
  18326. * In XR mode and presenting
  18327. */
  18328. WebXRState[WebXRState["IN_XR"] = 2] = "IN_XR";
  18329. /**
  18330. * Not entered XR mode
  18331. */
  18332. WebXRState[WebXRState["NOT_IN_XR"] = 3] = "NOT_IN_XR";
  18333. })(WebXRState || (WebXRState = {}));
  18334. /**
  18335. * Helper class used to enable XR
  18336. * @see https://doc.babylonjs.com/how_to/webxr
  18337. */
  18338. var WebXRExperienceHelper = /** @class */ (function () {
  18339. /**
  18340. * Creates a WebXRExperienceHelper
  18341. * @param scene The scene the helper should be created in
  18342. */
  18343. function WebXRExperienceHelper(scene) {
  18344. this.scene = scene;
  18345. /**
  18346. * The current state of the XR experience (eg. transitioning, in XR or not in XR)
  18347. */
  18348. this.state = WebXRState.NOT_IN_XR;
  18349. /**
  18350. * Fires when the state of the experience helper has changed
  18351. */
  18352. this.onStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  18353. this._nonVRCamera = null;
  18354. this._originalSceneAutoClear = true;
  18355. this._supported = false;
  18356. this.camera = new _webXRCamera__WEBPACK_IMPORTED_MODULE_4__["WebXRCamera"]("", scene);
  18357. this._sessionManager = new _webXRSessionManager__WEBPACK_IMPORTED_MODULE_3__["WebXRSessionManager"](scene);
  18358. this.container = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", scene);
  18359. this.camera.parent = this.container;
  18360. }
  18361. WebXRExperienceHelper.prototype._setState = function (val) {
  18362. this.state = val;
  18363. this.onStateChangedObservable.notifyObservers(this.state);
  18364. };
  18365. /**
  18366. * Creates the experience helper
  18367. * @param scene the scene to attach the experience helper to
  18368. * @returns a promise for the experience helper
  18369. */
  18370. WebXRExperienceHelper.CreateAsync = function (scene) {
  18371. var helper = new WebXRExperienceHelper(scene);
  18372. return helper._sessionManager.initializeAsync().then(function () {
  18373. helper._supported = true;
  18374. return helper;
  18375. }).catch(function () {
  18376. return helper;
  18377. });
  18378. };
  18379. /**
  18380. * Exits XR mode and returns the scene to its original state
  18381. * @returns promise that resolves after xr mode has exited
  18382. */
  18383. WebXRExperienceHelper.prototype.exitXRAsync = function () {
  18384. this._setState(WebXRState.EXITING_XR);
  18385. return this._sessionManager.exitXRAsync();
  18386. };
  18387. /**
  18388. * Enters XR mode (This must be done within a user interaction in most browsers eg. button click)
  18389. * @param sessionCreationOptions options for the XR session
  18390. * @param frameOfReference frame of reference of the XR session
  18391. * @returns promise that resolves after xr mode has entered
  18392. */
  18393. WebXRExperienceHelper.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReference) {
  18394. var _this = this;
  18395. if (!this._supported) {
  18396. throw "XR session not supported by this browser";
  18397. }
  18398. this._setState(WebXRState.ENTERING_XR);
  18399. return this._sessionManager.enterXRAsync(sessionCreationOptions, frameOfReference).then(function () {
  18400. // Cache pre xr scene settings
  18401. _this._originalSceneAutoClear = _this.scene.autoClear;
  18402. _this._nonVRCamera = _this.scene.activeCamera;
  18403. // Overwrite current scene settings
  18404. _this.scene.autoClear = false;
  18405. _this.scene.activeCamera = _this.camera;
  18406. _this._sessionManager.onXRFrameObservable.add(function () {
  18407. _this.camera.updateFromXRSessionManager(_this._sessionManager);
  18408. });
  18409. _this._sessionManager.onXRSessionEnded.addOnce(function () {
  18410. // Reset camera rigs output render target to ensure sessions render target is not drawn after it ends
  18411. _this.camera.rigCameras.forEach(function (c) {
  18412. c.outputRenderTarget = null;
  18413. });
  18414. // Restore scene settings
  18415. _this.scene.autoClear = _this._originalSceneAutoClear;
  18416. _this.scene.activeCamera = _this._nonVRCamera;
  18417. _this._sessionManager.onXRFrameObservable.clear();
  18418. _this._setState(WebXRState.NOT_IN_XR);
  18419. });
  18420. _this._setState(WebXRState.IN_XR);
  18421. });
  18422. };
  18423. /**
  18424. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18425. * @param ray ray to cast into the environment
  18426. * @returns Promise which resolves with a collision point in the environment if it exists
  18427. */
  18428. WebXRExperienceHelper.prototype.environmentPointHitTestAsync = function (ray) {
  18429. return this._sessionManager.environmentPointHitTestAsync(ray);
  18430. };
  18431. /**
  18432. * Updates the global position of the camera by moving the camera's container
  18433. * This should be used instead of modifying the camera's position as it will be overwritten by an xrSessions's update frame
  18434. * @param position The desired global position of the camera
  18435. */
  18436. WebXRExperienceHelper.prototype.setPositionOfCameraUsingContainer = function (position) {
  18437. this.camera.globalPosition.subtractToRef(position, WebXRExperienceHelper._TmpVector);
  18438. this.container.position.subtractInPlace(WebXRExperienceHelper._TmpVector);
  18439. };
  18440. /**
  18441. * Rotates the xr camera by rotating the camera's container around the camera's position
  18442. * This should be used instead of modifying the camera's rotation as it will be overwritten by an xrSessions's update frame
  18443. * @param rotation the desired quaternion rotation to apply to the camera
  18444. */
  18445. WebXRExperienceHelper.prototype.rotateCameraByQuaternionUsingContainer = function (rotation) {
  18446. if (!this.container.rotationQuaternion) {
  18447. this.container.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromEulerVector(this.container.rotation);
  18448. }
  18449. this.container.rotationQuaternion.multiplyInPlace(rotation);
  18450. this.container.position.rotateByQuaternionAroundPointToRef(rotation, this.camera.globalPosition, this.container.position);
  18451. };
  18452. /**
  18453. * Checks if the creation options are supported by the xr session
  18454. * @param options creation options
  18455. * @returns true if supported
  18456. */
  18457. WebXRExperienceHelper.prototype.supportsSessionAsync = function (options) {
  18458. if (!this._supported) {
  18459. return Promise.resolve(false);
  18460. }
  18461. return this._sessionManager.supportsSessionAsync(options);
  18462. };
  18463. /**
  18464. * Disposes of the experience helper
  18465. */
  18466. WebXRExperienceHelper.prototype.dispose = function () {
  18467. this.camera.dispose();
  18468. this.container.dispose();
  18469. this.onStateChangedObservable.clear();
  18470. this._sessionManager.dispose();
  18471. };
  18472. WebXRExperienceHelper._TmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]();
  18473. return WebXRExperienceHelper;
  18474. }());
  18475. /***/ }),
  18476. /***/ "./Cameras/XR/webXRInput.ts":
  18477. /*!**********************************!*\
  18478. !*** ./Cameras/XR/webXRInput.ts ***!
  18479. \**********************************/
  18480. /*! exports provided: WebXRController, WebXRInput */
  18481. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18482. "use strict";
  18483. __webpack_require__.r(__webpack_exports__);
  18484. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return WebXRController; });
  18485. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return WebXRInput; });
  18486. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18487. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  18488. /**
  18489. * Represents an XR input
  18490. */
  18491. var WebXRController = /** @class */ (function () {
  18492. /**
  18493. * Creates the controller
  18494. * @see https://doc.babylonjs.com/how_to/webxr
  18495. * @param scene the scene which the controller should be associated to
  18496. */
  18497. function WebXRController(scene) {
  18498. this.pointer = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerPointer", scene);
  18499. }
  18500. /**
  18501. * Disposes of the object
  18502. */
  18503. WebXRController.prototype.dispose = function () {
  18504. if (this.grip) {
  18505. this.grip.dispose();
  18506. }
  18507. this.pointer.dispose();
  18508. };
  18509. return WebXRController;
  18510. }());
  18511. /**
  18512. * XR input used to track XR inputs such as controllers/rays
  18513. */
  18514. var WebXRInput = /** @class */ (function () {
  18515. /**
  18516. * Initializes the WebXRInput
  18517. * @param helper experience helper which the input should be created for
  18518. */
  18519. function WebXRInput(helper) {
  18520. var _this = this;
  18521. this.helper = helper;
  18522. /**
  18523. * XR controllers being tracked
  18524. */
  18525. this.controllers = [];
  18526. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  18527. this._frameObserver = helper._sessionManager.onXRFrameObservable.add(function () {
  18528. if (!helper._sessionManager._currentXRFrame || !helper._sessionManager._currentXRFrame.getDevicePose) {
  18529. return;
  18530. }
  18531. var xrFrame = helper._sessionManager._currentXRFrame;
  18532. var inputSources = helper._sessionManager._xrSession.getInputSources();
  18533. inputSources.forEach(function (input, i) {
  18534. var inputPose = xrFrame.getInputPose(input, helper._sessionManager._frameOfReference);
  18535. if (inputPose) {
  18536. if (_this.controllers.length <= i) {
  18537. _this.controllers.push(new WebXRController(helper.container.getScene()));
  18538. }
  18539. var controller = _this.controllers[i];
  18540. // Manage the grip if it exists
  18541. if (inputPose.gripMatrix) {
  18542. if (!controller.grip) {
  18543. controller.grip = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("controllerGrip", helper.container.getScene());
  18544. }
  18545. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.gripMatrix, 0, 1, _this._tmpMatrix);
  18546. if (!controller.grip.getScene().useRightHandedSystem) {
  18547. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18548. }
  18549. if (!controller.grip.rotationQuaternion) {
  18550. controller.grip.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18551. }
  18552. _this._tmpMatrix.decompose(controller.grip.scaling, controller.grip.rotationQuaternion, controller.grip.position);
  18553. }
  18554. // Manager pointer of controller
  18555. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].FromFloat32ArrayToRefScaled(inputPose.targetRay.transformMatrix, 0, 1, _this._tmpMatrix);
  18556. if (!controller.pointer.getScene().useRightHandedSystem) {
  18557. _this._tmpMatrix.toggleModelMatrixHandInPlace();
  18558. }
  18559. if (!controller.pointer.rotationQuaternion) {
  18560. controller.pointer.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  18561. }
  18562. _this._tmpMatrix.decompose(controller.pointer.scaling, controller.pointer.rotationQuaternion, controller.pointer.position);
  18563. }
  18564. });
  18565. });
  18566. }
  18567. /**
  18568. * Disposes of the object
  18569. */
  18570. WebXRInput.prototype.dispose = function () {
  18571. this.controllers.forEach(function (c) {
  18572. c.dispose();
  18573. });
  18574. this.helper._sessionManager.onXRFrameObservable.remove(this._frameObserver);
  18575. };
  18576. return WebXRInput;
  18577. }());
  18578. /***/ }),
  18579. /***/ "./Cameras/XR/webXRManagedOutputCanvas.ts":
  18580. /*!************************************************!*\
  18581. !*** ./Cameras/XR/webXRManagedOutputCanvas.ts ***!
  18582. \************************************************/
  18583. /*! exports provided: WebXRManagedOutputCanvas */
  18584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18585. "use strict";
  18586. __webpack_require__.r(__webpack_exports__);
  18587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return WebXRManagedOutputCanvas; });
  18588. /* harmony import */ var _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  18589. /**
  18590. * Creates a canvas that is added/removed from the webpage when entering/exiting XR
  18591. */
  18592. var WebXRManagedOutputCanvas = /** @class */ (function () {
  18593. /**
  18594. * Initializes the canvas to be added/removed upon entering/exiting xr
  18595. * @param helper the xr experience helper used to trigger adding/removing of the canvas
  18596. * @param canvas The canvas to be added/removed (If not specified a full screen canvas will be created)
  18597. */
  18598. function WebXRManagedOutputCanvas(helper, canvas) {
  18599. var _this = this;
  18600. this._canvas = null;
  18601. /**
  18602. * xrpresent context of the canvas which can be used to display/mirror xr content
  18603. */
  18604. this.canvasContext = null;
  18605. if (!canvas) {
  18606. canvas = document.createElement('canvas');
  18607. canvas.style.cssText = "position:absolute; bottom:0px;right:0px;z-index:10;width:100%;height:100%;background-color: #000000;";
  18608. }
  18609. this._setManagedOutputCanvas(canvas);
  18610. helper.onStateChangedObservable.add(function (stateInfo) {
  18611. if (stateInfo == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].ENTERING_XR) {
  18612. // 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
  18613. _this._addCanvas();
  18614. }
  18615. else if (helper.state == _webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_0__["WebXRState"].NOT_IN_XR) {
  18616. _this._removeCanvas();
  18617. }
  18618. });
  18619. }
  18620. /**
  18621. * Disposes of the object
  18622. */
  18623. WebXRManagedOutputCanvas.prototype.dispose = function () {
  18624. this._removeCanvas();
  18625. this._setManagedOutputCanvas(null);
  18626. };
  18627. WebXRManagedOutputCanvas.prototype._setManagedOutputCanvas = function (canvas) {
  18628. this._removeCanvas();
  18629. if (!canvas) {
  18630. this._canvas = null;
  18631. this.canvasContext = null;
  18632. }
  18633. else {
  18634. this._canvas = canvas;
  18635. this.canvasContext = this._canvas.getContext('xrpresent');
  18636. }
  18637. };
  18638. WebXRManagedOutputCanvas.prototype._addCanvas = function () {
  18639. if (this._canvas) {
  18640. document.body.appendChild(this._canvas);
  18641. }
  18642. };
  18643. WebXRManagedOutputCanvas.prototype._removeCanvas = function () {
  18644. if (this._canvas && document.body.contains(this._canvas)) {
  18645. document.body.removeChild(this._canvas);
  18646. }
  18647. };
  18648. return WebXRManagedOutputCanvas;
  18649. }());
  18650. /***/ }),
  18651. /***/ "./Cameras/XR/webXRSessionManager.ts":
  18652. /*!*******************************************!*\
  18653. !*** ./Cameras/XR/webXRSessionManager.ts ***!
  18654. \*******************************************/
  18655. /*! exports provided: WebXRSessionManager */
  18656. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18657. "use strict";
  18658. __webpack_require__.r(__webpack_exports__);
  18659. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return WebXRSessionManager; });
  18660. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  18661. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  18662. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  18663. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  18664. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  18665. /**
  18666. * Manages an XRSession
  18667. * @see https://doc.babylonjs.com/how_to/webxr
  18668. */
  18669. var WebXRSessionManager = /** @class */ (function () {
  18670. /**
  18671. * Constructs a WebXRSessionManager, this must be initialized within a user action before usage
  18672. * @param scene The scene which the session should be created for
  18673. */
  18674. function WebXRSessionManager(scene) {
  18675. this.scene = scene;
  18676. /**
  18677. * Fires every time a new xrFrame arrives which can be used to update the camera
  18678. */
  18679. this.onXRFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18680. /**
  18681. * Fires when the xr session is ended either by the device or manually done
  18682. */
  18683. this.onXRSessionEnded = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  18684. /** @hidden */
  18685. this._sessionRenderTargetTexture = null;
  18686. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  18687. }
  18688. /**
  18689. * Initializes the manager
  18690. * After initialization enterXR can be called to start an XR session
  18691. * @returns Promise which resolves after it is initialized
  18692. */
  18693. WebXRSessionManager.prototype.initializeAsync = function () {
  18694. var _this = this;
  18695. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("The WebXR APIs are still under development and are subject to change in the future.");
  18696. // Check if the browser supports webXR
  18697. this._xrNavigator = navigator;
  18698. if (!this._xrNavigator.xr) {
  18699. return Promise.reject("webXR not supported by this browser");
  18700. }
  18701. // Request the webXR device
  18702. return this._xrNavigator.xr.requestDevice().then(function (device) {
  18703. _this._xrDevice = device;
  18704. return _this.scene.getEngine()._gl.setCompatibleXRDevice(_this._xrDevice);
  18705. });
  18706. };
  18707. /**
  18708. * Enters XR with the desired XR session options, this must be done with a user action (eg. button click event)
  18709. * @param sessionCreationOptions xr options to create the session with
  18710. * @param frameOfReferenceType option to configure how the xr pose is expressed
  18711. * @returns Promise which resolves after it enters XR
  18712. */
  18713. WebXRSessionManager.prototype.enterXRAsync = function (sessionCreationOptions, frameOfReferenceType) {
  18714. var _this = this;
  18715. // initialize session
  18716. return this._xrDevice.requestSession(sessionCreationOptions).then(function (session) {
  18717. _this._xrSession = session;
  18718. // handle when the session is ended (By calling session.end or device ends its own session eg. pressing home button on phone)
  18719. _this._xrSession.addEventListener("end", function () {
  18720. // Remove render target texture and notify frame obervers
  18721. _this._sessionRenderTargetTexture = null;
  18722. // Restore frame buffer to avoid clear on xr framebuffer after session end
  18723. _this.scene.getEngine().restoreDefaultFramebuffer();
  18724. // Need to restart render loop as after the session is ended the last request for new frame will never call callback
  18725. _this.scene.getEngine().customAnimationFrameRequester = null;
  18726. _this.onXRSessionEnded.notifyObservers(null);
  18727. _this.scene.getEngine()._renderLoop();
  18728. }, { once: true });
  18729. _this._xrSession.baseLayer = new XRWebGLLayer(_this._xrSession, _this.scene.getEngine()._gl);
  18730. return _this._xrSession.requestFrameOfReference(frameOfReferenceType);
  18731. }).then(function (frameOfRef) {
  18732. _this._frameOfReference = frameOfRef;
  18733. // Tell the engine's render loop to be driven by the xr session's refresh rate and provide xr pose information
  18734. _this.scene.getEngine().customAnimationFrameRequester = {
  18735. requestAnimationFrame: _this._xrSession.requestAnimationFrame.bind(_this._xrSession),
  18736. renderFunction: function (timestamp, xrFrame) {
  18737. // Store the XR frame in the manager to be consumed by the XR camera to update pose
  18738. _this._currentXRFrame = xrFrame;
  18739. _this.onXRFrameObservable.notifyObservers(null);
  18740. _this.scene.getEngine()._renderLoop();
  18741. }
  18742. };
  18743. // Create render target texture from xr's webgl render target
  18744. _this._sessionRenderTargetTexture = WebXRSessionManager._CreateRenderTargetTextureFromSession(_this._xrSession, _this.scene);
  18745. // Stop window's animation frame and trigger sessions animation frame
  18746. window.cancelAnimationFrame(_this.scene.getEngine()._frameHandler);
  18747. _this.scene.getEngine()._renderLoop();
  18748. });
  18749. };
  18750. /**
  18751. * Stops the xrSession and restores the renderloop
  18752. * @returns Promise which resolves after it exits XR
  18753. */
  18754. WebXRSessionManager.prototype.exitXRAsync = function () {
  18755. return this._xrSession.end();
  18756. };
  18757. /**
  18758. * Fires a ray and returns the closest hit in the xr sessions enviornment, useful to place objects in AR
  18759. * @param ray ray to cast into the environment
  18760. * @returns Promise which resolves with a collision point in the environment if it exists
  18761. */
  18762. WebXRSessionManager.prototype.environmentPointHitTestAsync = function (ray) {
  18763. var _this = this;
  18764. return new Promise(function (res) {
  18765. // Compute left handed inputs to request hit test
  18766. var origin = new Float32Array([ray.origin.x, ray.origin.y, ray.origin.z]);
  18767. var direction = new Float32Array([ray.direction.x, ray.direction.y, ray.direction.z]);
  18768. if (!_this.scene.useRightHandedSystem) {
  18769. origin[2] *= -1;
  18770. direction[2] *= -1;
  18771. }
  18772. // Fire hittest
  18773. _this._xrSession.requestHitTest(origin, direction, _this._frameOfReference)
  18774. .then(function (hits) {
  18775. if (hits.length > 0) {
  18776. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromFloat32ArrayToRefScaled(hits[0].hitMatrix, 0, 1.0, _this._tmpMatrix);
  18777. var hitPoint = _this._tmpMatrix.getTranslation();
  18778. if (!_this.scene.useRightHandedSystem) {
  18779. hitPoint.z *= -1;
  18780. }
  18781. res(hitPoint);
  18782. }
  18783. else {
  18784. res(null);
  18785. }
  18786. }).catch(function () {
  18787. res(null);
  18788. });
  18789. });
  18790. };
  18791. /**
  18792. * Checks if a session would be supported for the creation options specified
  18793. * @param options creation options to check if they are supported
  18794. * @returns true if supported
  18795. */
  18796. WebXRSessionManager.prototype.supportsSessionAsync = function (options) {
  18797. return this._xrDevice.supportsSession(options).then(function () {
  18798. return true;
  18799. }).catch(function () {
  18800. return false;
  18801. });
  18802. };
  18803. /**
  18804. * @hidden
  18805. * Converts the render layer of xrSession to a render target
  18806. * @param session session to create render target for
  18807. * @param scene scene the new render target should be created for
  18808. */
  18809. WebXRSessionManager._CreateRenderTargetTextureFromSession = function (session, scene) {
  18810. // Create internal texture
  18811. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"](scene.getEngine(), _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_UNKNOWN, true);
  18812. internalTexture.width = session.baseLayer.framebufferWidth;
  18813. internalTexture.height = session.baseLayer.framebufferHeight;
  18814. internalTexture._framebuffer = session.baseLayer.framebuffer;
  18815. // Create render target texture from the internal texture
  18816. 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);
  18817. renderTargetTexture._texture = internalTexture;
  18818. return renderTargetTexture;
  18819. };
  18820. /**
  18821. * Disposes of the session manager
  18822. */
  18823. WebXRSessionManager.prototype.dispose = function () {
  18824. this.onXRFrameObservable.clear();
  18825. this.onXRSessionEnded.clear();
  18826. };
  18827. return WebXRSessionManager;
  18828. }());
  18829. /***/ }),
  18830. /***/ "./Cameras/arcRotateCamera.ts":
  18831. /*!************************************!*\
  18832. !*** ./Cameras/arcRotateCamera.ts ***!
  18833. \************************************/
  18834. /*! exports provided: ArcRotateCamera */
  18835. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  18836. "use strict";
  18837. __webpack_require__.r(__webpack_exports__);
  18838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return ArcRotateCamera; });
  18839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  18840. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  18841. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  18842. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  18843. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  18844. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  18845. /* harmony import */ var _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Cameras/autoRotationBehavior */ "./Behaviors/Cameras/autoRotationBehavior.ts");
  18846. /* harmony import */ var _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Cameras/bouncingBehavior */ "./Behaviors/Cameras/bouncingBehavior.ts");
  18847. /* harmony import */ var _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Behaviors/Cameras/framingBehavior */ "./Behaviors/Cameras/framingBehavior.ts");
  18848. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  18849. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  18850. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  18851. _node__WEBPACK_IMPORTED_MODULE_4__["Node"].AddNodeConstructor("ArcRotateCamera", function (name, scene) {
  18852. return function () { return new ArcRotateCamera(name, 0, 0, 1.0, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  18853. });
  18854. /**
  18855. * This represents an orbital type of camera.
  18856. *
  18857. * 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.
  18858. * 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.
  18859. * @see http://doc.babylonjs.com/babylon101/cameras#arc-rotate-camera
  18860. */
  18861. var ArcRotateCamera = /** @class */ (function (_super) {
  18862. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCamera, _super);
  18863. /**
  18864. * Instantiates a new ArcRotateCamera in a given scene
  18865. * @param name Defines the name of the camera
  18866. * @param alpha Defines the camera rotation along the logitudinal axis
  18867. * @param beta Defines the camera rotation along the latitudinal axis
  18868. * @param radius Defines the camera distance from its target
  18869. * @param target Defines the camera target
  18870. * @param scene Defines the scene the camera belongs to
  18871. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  18872. */
  18873. function ArcRotateCamera(name, alpha, beta, radius, target, scene, setActiveOnSceneIfNoneActive) {
  18874. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  18875. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene, setActiveOnSceneIfNoneActive) || this;
  18876. /**
  18877. * Current inertia value on the longitudinal axis.
  18878. * The bigger this number the longer it will take for the camera to stop.
  18879. */
  18880. _this.inertialAlphaOffset = 0;
  18881. /**
  18882. * Current inertia value on the latitudinal axis.
  18883. * The bigger this number the longer it will take for the camera to stop.
  18884. */
  18885. _this.inertialBetaOffset = 0;
  18886. /**
  18887. * Current inertia value on the radius axis.
  18888. * The bigger this number the longer it will take for the camera to stop.
  18889. */
  18890. _this.inertialRadiusOffset = 0;
  18891. /**
  18892. * Minimum allowed angle on the longitudinal axis.
  18893. * This can help limiting how the Camera is able to move in the scene.
  18894. */
  18895. _this.lowerAlphaLimit = null;
  18896. /**
  18897. * Maximum allowed angle on the longitudinal axis.
  18898. * This can help limiting how the Camera is able to move in the scene.
  18899. */
  18900. _this.upperAlphaLimit = null;
  18901. /**
  18902. * Minimum allowed angle on the latitudinal axis.
  18903. * This can help limiting how the Camera is able to move in the scene.
  18904. */
  18905. _this.lowerBetaLimit = 0.01;
  18906. /**
  18907. * Maximum allowed angle on the latitudinal axis.
  18908. * This can help limiting how the Camera is able to move in the scene.
  18909. */
  18910. _this.upperBetaLimit = Math.PI - 0.01;
  18911. /**
  18912. * Minimum allowed distance of the camera to the target (The camera can not get closer).
  18913. * This can help limiting how the Camera is able to move in the scene.
  18914. */
  18915. _this.lowerRadiusLimit = null;
  18916. /**
  18917. * Maximum allowed distance of the camera to the target (The camera can not get further).
  18918. * This can help limiting how the Camera is able to move in the scene.
  18919. */
  18920. _this.upperRadiusLimit = null;
  18921. /**
  18922. * Defines the current inertia value used during panning of the camera along the X axis.
  18923. */
  18924. _this.inertialPanningX = 0;
  18925. /**
  18926. * Defines the current inertia value used during panning of the camera along the Y axis.
  18927. */
  18928. _this.inertialPanningY = 0;
  18929. /**
  18930. * Defines the distance used to consider the camera in pan mode vs pinch/zoom.
  18931. * Basically if your fingers moves away from more than this distance you will be considered
  18932. * in pinch mode.
  18933. */
  18934. _this.pinchToPanMaxDistance = 20;
  18935. /**
  18936. * Defines the maximum distance the camera can pan.
  18937. * This could help keeping the cammera always in your scene.
  18938. */
  18939. _this.panningDistanceLimit = null;
  18940. /**
  18941. * Defines the target of the camera before paning.
  18942. */
  18943. _this.panningOriginTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18944. /**
  18945. * Defines the value of the inertia used during panning.
  18946. * 0 would mean stop inertia and one would mean no decelleration at all.
  18947. */
  18948. _this.panningInertia = 0.9;
  18949. //-- end properties for backward compatibility for inputs
  18950. /**
  18951. * Defines how much the radius should be scaled while zomming on a particular mesh (through the zoomOn function)
  18952. */
  18953. _this.zoomOnFactor = 1;
  18954. /**
  18955. * Defines a screen offset for the camera position.
  18956. */
  18957. _this.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  18958. /**
  18959. * Allows the camera to be completely reversed.
  18960. * If false the camera can not arrive upside down.
  18961. */
  18962. _this.allowUpsideDown = true;
  18963. /**
  18964. * Define if double tap/click is used to restore the previously saved state of the camera.
  18965. */
  18966. _this.useInputToRestoreState = true;
  18967. /** @hidden */
  18968. _this._viewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  18969. /**
  18970. * Defines the allowed panning axis.
  18971. */
  18972. _this.panningAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 0);
  18973. /**
  18974. * Observable triggered when the mesh target has been changed on the camera.
  18975. */
  18976. _this.onMeshTargetChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  18977. /**
  18978. * Defines whether the camera should check collision with the objects oh the scene.
  18979. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#how-can-i-do-this
  18980. */
  18981. _this.checkCollisions = false;
  18982. /**
  18983. * Defines the collision radius of the camera.
  18984. * This simulates a sphere around the camera.
  18985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  18986. */
  18987. _this.collisionRadius = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 0.5, 0.5);
  18988. _this._previousPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18989. _this._collisionVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18990. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18991. _this._computationVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  18992. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  18993. if (collidedMesh === void 0) { collidedMesh = null; }
  18994. if (!collidedMesh) {
  18995. _this._previousPosition.copyFrom(_this.position);
  18996. }
  18997. else {
  18998. _this.setPosition(newPosition);
  18999. if (_this.onCollide) {
  19000. _this.onCollide(collidedMesh);
  19001. }
  19002. }
  19003. // Recompute because of constraints
  19004. var cosa = Math.cos(_this.alpha);
  19005. var sina = Math.sin(_this.alpha);
  19006. var cosb = Math.cos(_this.beta);
  19007. var sinb = Math.sin(_this.beta);
  19008. if (sinb === 0) {
  19009. sinb = 0.0001;
  19010. }
  19011. var target = _this._getTargetPosition();
  19012. _this._computationVector.copyFromFloats(_this.radius * cosa * sinb, _this.radius * cosb, _this.radius * sina * sinb);
  19013. target.addToRef(_this._computationVector, _this._newPosition);
  19014. _this.position.copyFrom(_this._newPosition);
  19015. var up = _this.upVector;
  19016. if (_this.allowUpsideDown && _this.beta < 0) {
  19017. up = up.clone();
  19018. up = up.negate();
  19019. }
  19020. _this._computeViewMatrix(_this.position, target, up);
  19021. _this._viewMatrix.addAtIndex(12, _this.targetScreenOffset.x);
  19022. _this._viewMatrix.addAtIndex(13, _this.targetScreenOffset.y);
  19023. _this._collisionTriggered = false;
  19024. };
  19025. _this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19026. if (target) {
  19027. _this.setTarget(target);
  19028. }
  19029. _this.alpha = alpha;
  19030. _this.beta = beta;
  19031. _this.radius = radius;
  19032. _this.getViewMatrix();
  19033. _this.inputs = new _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["ArcRotateCameraInputsManager"](_this);
  19034. _this.inputs.addKeyboard().addMouseWheel().addPointers();
  19035. return _this;
  19036. }
  19037. Object.defineProperty(ArcRotateCamera.prototype, "target", {
  19038. /**
  19039. * Defines the target point of the camera.
  19040. * The camera looks towards it form the radius distance.
  19041. */
  19042. get: function () {
  19043. return this._target;
  19044. },
  19045. set: function (value) {
  19046. this.setTarget(value);
  19047. },
  19048. enumerable: true,
  19049. configurable: true
  19050. });
  19051. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityX", {
  19052. //-- begin properties for backward compatibility for inputs
  19053. /**
  19054. * Gets or Set the pointer angular sensibility along the X axis or how fast is the camera rotating.
  19055. */
  19056. get: function () {
  19057. var pointers = this.inputs.attached["pointers"];
  19058. if (pointers) {
  19059. return pointers.angularSensibilityX;
  19060. }
  19061. return 0;
  19062. },
  19063. set: function (value) {
  19064. var pointers = this.inputs.attached["pointers"];
  19065. if (pointers) {
  19066. pointers.angularSensibilityX = value;
  19067. }
  19068. },
  19069. enumerable: true,
  19070. configurable: true
  19071. });
  19072. Object.defineProperty(ArcRotateCamera.prototype, "angularSensibilityY", {
  19073. /**
  19074. * Gets or Set the pointer angular sensibility along the Y axis or how fast is the camera rotating.
  19075. */
  19076. get: function () {
  19077. var pointers = this.inputs.attached["pointers"];
  19078. if (pointers) {
  19079. return pointers.angularSensibilityY;
  19080. }
  19081. return 0;
  19082. },
  19083. set: function (value) {
  19084. var pointers = this.inputs.attached["pointers"];
  19085. if (pointers) {
  19086. pointers.angularSensibilityY = value;
  19087. }
  19088. },
  19089. enumerable: true,
  19090. configurable: true
  19091. });
  19092. Object.defineProperty(ArcRotateCamera.prototype, "pinchPrecision", {
  19093. /**
  19094. * Gets or Set the pointer pinch precision or how fast is the camera zooming.
  19095. */
  19096. get: function () {
  19097. var pointers = this.inputs.attached["pointers"];
  19098. if (pointers) {
  19099. return pointers.pinchPrecision;
  19100. }
  19101. return 0;
  19102. },
  19103. set: function (value) {
  19104. var pointers = this.inputs.attached["pointers"];
  19105. if (pointers) {
  19106. pointers.pinchPrecision = value;
  19107. }
  19108. },
  19109. enumerable: true,
  19110. configurable: true
  19111. });
  19112. Object.defineProperty(ArcRotateCamera.prototype, "pinchDeltaPercentage", {
  19113. /**
  19114. * Gets or Set the pointer pinch delta percentage or how fast is the camera zooming.
  19115. * It will be used instead of pinchDeltaPrecision if different from 0.
  19116. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19117. */
  19118. get: function () {
  19119. var pointers = this.inputs.attached["pointers"];
  19120. if (pointers) {
  19121. return pointers.pinchDeltaPercentage;
  19122. }
  19123. return 0;
  19124. },
  19125. set: function (value) {
  19126. var pointers = this.inputs.attached["pointers"];
  19127. if (pointers) {
  19128. pointers.pinchDeltaPercentage = value;
  19129. }
  19130. },
  19131. enumerable: true,
  19132. configurable: true
  19133. });
  19134. Object.defineProperty(ArcRotateCamera.prototype, "panningSensibility", {
  19135. /**
  19136. * Gets or Set the pointer panning sensibility or how fast is the camera moving.
  19137. */
  19138. get: function () {
  19139. var pointers = this.inputs.attached["pointers"];
  19140. if (pointers) {
  19141. return pointers.panningSensibility;
  19142. }
  19143. return 0;
  19144. },
  19145. set: function (value) {
  19146. var pointers = this.inputs.attached["pointers"];
  19147. if (pointers) {
  19148. pointers.panningSensibility = value;
  19149. }
  19150. },
  19151. enumerable: true,
  19152. configurable: true
  19153. });
  19154. Object.defineProperty(ArcRotateCamera.prototype, "keysUp", {
  19155. /**
  19156. * Gets or Set the list of keyboard keys used to control beta angle in a positive direction.
  19157. */
  19158. get: function () {
  19159. var keyboard = this.inputs.attached["keyboard"];
  19160. if (keyboard) {
  19161. return keyboard.keysUp;
  19162. }
  19163. return [];
  19164. },
  19165. set: function (value) {
  19166. var keyboard = this.inputs.attached["keyboard"];
  19167. if (keyboard) {
  19168. keyboard.keysUp = value;
  19169. }
  19170. },
  19171. enumerable: true,
  19172. configurable: true
  19173. });
  19174. Object.defineProperty(ArcRotateCamera.prototype, "keysDown", {
  19175. /**
  19176. * Gets or Set the list of keyboard keys used to control beta angle in a negative direction.
  19177. */
  19178. get: function () {
  19179. var keyboard = this.inputs.attached["keyboard"];
  19180. if (keyboard) {
  19181. return keyboard.keysDown;
  19182. }
  19183. return [];
  19184. },
  19185. set: function (value) {
  19186. var keyboard = this.inputs.attached["keyboard"];
  19187. if (keyboard) {
  19188. keyboard.keysDown = value;
  19189. }
  19190. },
  19191. enumerable: true,
  19192. configurable: true
  19193. });
  19194. Object.defineProperty(ArcRotateCamera.prototype, "keysLeft", {
  19195. /**
  19196. * Gets or Set the list of keyboard keys used to control alpha angle in a negative direction.
  19197. */
  19198. get: function () {
  19199. var keyboard = this.inputs.attached["keyboard"];
  19200. if (keyboard) {
  19201. return keyboard.keysLeft;
  19202. }
  19203. return [];
  19204. },
  19205. set: function (value) {
  19206. var keyboard = this.inputs.attached["keyboard"];
  19207. if (keyboard) {
  19208. keyboard.keysLeft = value;
  19209. }
  19210. },
  19211. enumerable: true,
  19212. configurable: true
  19213. });
  19214. Object.defineProperty(ArcRotateCamera.prototype, "keysRight", {
  19215. /**
  19216. * Gets or Set the list of keyboard keys used to control alpha angle in a positive direction.
  19217. */
  19218. get: function () {
  19219. var keyboard = this.inputs.attached["keyboard"];
  19220. if (keyboard) {
  19221. return keyboard.keysRight;
  19222. }
  19223. return [];
  19224. },
  19225. set: function (value) {
  19226. var keyboard = this.inputs.attached["keyboard"];
  19227. if (keyboard) {
  19228. keyboard.keysRight = value;
  19229. }
  19230. },
  19231. enumerable: true,
  19232. configurable: true
  19233. });
  19234. Object.defineProperty(ArcRotateCamera.prototype, "wheelPrecision", {
  19235. /**
  19236. * Gets or Set the mouse wheel precision or how fast is the camera zooming.
  19237. */
  19238. get: function () {
  19239. var mousewheel = this.inputs.attached["mousewheel"];
  19240. if (mousewheel) {
  19241. return mousewheel.wheelPrecision;
  19242. }
  19243. return 0;
  19244. },
  19245. set: function (value) {
  19246. var mousewheel = this.inputs.attached["mousewheel"];
  19247. if (mousewheel) {
  19248. mousewheel.wheelPrecision = value;
  19249. }
  19250. },
  19251. enumerable: true,
  19252. configurable: true
  19253. });
  19254. Object.defineProperty(ArcRotateCamera.prototype, "wheelDeltaPercentage", {
  19255. /**
  19256. * Gets or Set the mouse wheel delta percentage or how fast is the camera zooming.
  19257. * It will be used instead of pinchDeltaPrecision if different from 0.
  19258. * It defines the percentage of current camera.radius to use as delta when pinch zoom is used.
  19259. */
  19260. get: function () {
  19261. var mousewheel = this.inputs.attached["mousewheel"];
  19262. if (mousewheel) {
  19263. return mousewheel.wheelDeltaPercentage;
  19264. }
  19265. return 0;
  19266. },
  19267. set: function (value) {
  19268. var mousewheel = this.inputs.attached["mousewheel"];
  19269. if (mousewheel) {
  19270. mousewheel.wheelDeltaPercentage = value;
  19271. }
  19272. },
  19273. enumerable: true,
  19274. configurable: true
  19275. });
  19276. Object.defineProperty(ArcRotateCamera.prototype, "bouncingBehavior", {
  19277. /**
  19278. * Gets the bouncing behavior of the camera if it has been enabled.
  19279. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19280. */
  19281. get: function () {
  19282. return this._bouncingBehavior;
  19283. },
  19284. enumerable: true,
  19285. configurable: true
  19286. });
  19287. Object.defineProperty(ArcRotateCamera.prototype, "useBouncingBehavior", {
  19288. /**
  19289. * Defines if the bouncing behavior of the camera is enabled on the camera.
  19290. * @see http://doc.babylonjs.com/how_to/camera_behaviors#bouncing-behavior
  19291. */
  19292. get: function () {
  19293. return this._bouncingBehavior != null;
  19294. },
  19295. set: function (value) {
  19296. if (value === this.useBouncingBehavior) {
  19297. return;
  19298. }
  19299. if (value) {
  19300. this._bouncingBehavior = new _Behaviors_Cameras_bouncingBehavior__WEBPACK_IMPORTED_MODULE_7__["BouncingBehavior"]();
  19301. this.addBehavior(this._bouncingBehavior);
  19302. }
  19303. else if (this._bouncingBehavior) {
  19304. this.removeBehavior(this._bouncingBehavior);
  19305. this._bouncingBehavior = null;
  19306. }
  19307. },
  19308. enumerable: true,
  19309. configurable: true
  19310. });
  19311. Object.defineProperty(ArcRotateCamera.prototype, "framingBehavior", {
  19312. /**
  19313. * Gets the framing behavior of the camera if it has been enabled.
  19314. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19315. */
  19316. get: function () {
  19317. return this._framingBehavior;
  19318. },
  19319. enumerable: true,
  19320. configurable: true
  19321. });
  19322. Object.defineProperty(ArcRotateCamera.prototype, "useFramingBehavior", {
  19323. /**
  19324. * Defines if the framing behavior of the camera is enabled on the camera.
  19325. * @see http://doc.babylonjs.com/how_to/camera_behaviors#framing-behavior
  19326. */
  19327. get: function () {
  19328. return this._framingBehavior != null;
  19329. },
  19330. set: function (value) {
  19331. if (value === this.useFramingBehavior) {
  19332. return;
  19333. }
  19334. if (value) {
  19335. this._framingBehavior = new _Behaviors_Cameras_framingBehavior__WEBPACK_IMPORTED_MODULE_8__["FramingBehavior"]();
  19336. this.addBehavior(this._framingBehavior);
  19337. }
  19338. else if (this._framingBehavior) {
  19339. this.removeBehavior(this._framingBehavior);
  19340. this._framingBehavior = null;
  19341. }
  19342. },
  19343. enumerable: true,
  19344. configurable: true
  19345. });
  19346. Object.defineProperty(ArcRotateCamera.prototype, "autoRotationBehavior", {
  19347. /**
  19348. * Gets the auto rotation behavior of the camera if it has been enabled.
  19349. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19350. */
  19351. get: function () {
  19352. return this._autoRotationBehavior;
  19353. },
  19354. enumerable: true,
  19355. configurable: true
  19356. });
  19357. Object.defineProperty(ArcRotateCamera.prototype, "useAutoRotationBehavior", {
  19358. /**
  19359. * Defines if the auto rotation behavior of the camera is enabled on the camera.
  19360. * @see http://doc.babylonjs.com/how_to/camera_behaviors#autorotation-behavior
  19361. */
  19362. get: function () {
  19363. return this._autoRotationBehavior != null;
  19364. },
  19365. set: function (value) {
  19366. if (value === this.useAutoRotationBehavior) {
  19367. return;
  19368. }
  19369. if (value) {
  19370. this._autoRotationBehavior = new _Behaviors_Cameras_autoRotationBehavior__WEBPACK_IMPORTED_MODULE_6__["AutoRotationBehavior"]();
  19371. this.addBehavior(this._autoRotationBehavior);
  19372. }
  19373. else if (this._autoRotationBehavior) {
  19374. this.removeBehavior(this._autoRotationBehavior);
  19375. this._autoRotationBehavior = null;
  19376. }
  19377. },
  19378. enumerable: true,
  19379. configurable: true
  19380. });
  19381. // Cache
  19382. /** @hidden */
  19383. ArcRotateCamera.prototype._initCache = function () {
  19384. _super.prototype._initCache.call(this);
  19385. this._cache._target = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  19386. this._cache.alpha = undefined;
  19387. this._cache.beta = undefined;
  19388. this._cache.radius = undefined;
  19389. this._cache.targetScreenOffset = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  19390. };
  19391. /** @hidden */
  19392. ArcRotateCamera.prototype._updateCache = function (ignoreParentClass) {
  19393. if (!ignoreParentClass) {
  19394. _super.prototype._updateCache.call(this);
  19395. }
  19396. this._cache._target.copyFrom(this._getTargetPosition());
  19397. this._cache.alpha = this.alpha;
  19398. this._cache.beta = this.beta;
  19399. this._cache.radius = this.radius;
  19400. this._cache.targetScreenOffset.copyFrom(this.targetScreenOffset);
  19401. };
  19402. ArcRotateCamera.prototype._getTargetPosition = function () {
  19403. if (this._targetHost && this._targetHost.getAbsolutePosition) {
  19404. var pos = this._targetHost.absolutePosition;
  19405. if (this._targetBoundingCenter) {
  19406. pos.addToRef(this._targetBoundingCenter, this._target);
  19407. }
  19408. else {
  19409. this._target.copyFrom(pos);
  19410. }
  19411. }
  19412. var lockedTargetPosition = this._getLockedTargetPosition();
  19413. if (lockedTargetPosition) {
  19414. return lockedTargetPosition;
  19415. }
  19416. return this._target;
  19417. };
  19418. /**
  19419. * Stores the current state of the camera (alpha, beta, radius and target)
  19420. * @returns the camera itself
  19421. */
  19422. ArcRotateCamera.prototype.storeState = function () {
  19423. this._storedAlpha = this.alpha;
  19424. this._storedBeta = this.beta;
  19425. this._storedRadius = this.radius;
  19426. this._storedTarget = this._getTargetPosition().clone();
  19427. return _super.prototype.storeState.call(this);
  19428. };
  19429. /**
  19430. * @hidden
  19431. * Restored camera state. You must call storeState() first
  19432. */
  19433. ArcRotateCamera.prototype._restoreStateValues = function () {
  19434. if (!_super.prototype._restoreStateValues.call(this)) {
  19435. return false;
  19436. }
  19437. this.alpha = this._storedAlpha;
  19438. this.beta = this._storedBeta;
  19439. this.radius = this._storedRadius;
  19440. this.setTarget(this._storedTarget.clone());
  19441. this.inertialAlphaOffset = 0;
  19442. this.inertialBetaOffset = 0;
  19443. this.inertialRadiusOffset = 0;
  19444. this.inertialPanningX = 0;
  19445. this.inertialPanningY = 0;
  19446. return true;
  19447. };
  19448. // Synchronized
  19449. /** @hidden */
  19450. ArcRotateCamera.prototype._isSynchronizedViewMatrix = function () {
  19451. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  19452. return false;
  19453. }
  19454. return this._cache._target.equals(this._getTargetPosition())
  19455. && this._cache.alpha === this.alpha
  19456. && this._cache.beta === this.beta
  19457. && this._cache.radius === this.radius
  19458. && this._cache.targetScreenOffset.equals(this.targetScreenOffset);
  19459. };
  19460. /**
  19461. * Attached controls to the current camera.
  19462. * @param element Defines the element the controls should be listened from
  19463. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  19464. * @param useCtrlForPanning Defines whether ctrl is used for paning within the controls
  19465. * @param panningMouseButton Defines whether panning is allowed through mouse click button
  19466. */
  19467. ArcRotateCamera.prototype.attachControl = function (element, noPreventDefault, useCtrlForPanning, panningMouseButton) {
  19468. var _this = this;
  19469. if (useCtrlForPanning === void 0) { useCtrlForPanning = true; }
  19470. if (panningMouseButton === void 0) { panningMouseButton = 2; }
  19471. this._useCtrlForPanning = useCtrlForPanning;
  19472. this._panningMouseButton = panningMouseButton;
  19473. this.inputs.attachElement(element, noPreventDefault);
  19474. this._reset = function () {
  19475. _this.inertialAlphaOffset = 0;
  19476. _this.inertialBetaOffset = 0;
  19477. _this.inertialRadiusOffset = 0;
  19478. _this.inertialPanningX = 0;
  19479. _this.inertialPanningY = 0;
  19480. };
  19481. };
  19482. /**
  19483. * Detach the current controls from the camera.
  19484. * The camera will stop reacting to inputs.
  19485. * @param element Defines the element to stop listening the inputs from
  19486. */
  19487. ArcRotateCamera.prototype.detachControl = function (element) {
  19488. this.inputs.detachElement(element);
  19489. if (this._reset) {
  19490. this._reset();
  19491. }
  19492. };
  19493. /** @hidden */
  19494. ArcRotateCamera.prototype._checkInputs = function () {
  19495. //if (async) collision inspection was triggered, don't update the camera's position - until the collision callback was called.
  19496. if (this._collisionTriggered) {
  19497. return;
  19498. }
  19499. this.inputs.checkInputs();
  19500. // Inertia
  19501. if (this.inertialAlphaOffset !== 0 || this.inertialBetaOffset !== 0 || this.inertialRadiusOffset !== 0) {
  19502. var inertialAlphaOffset = this.inertialAlphaOffset;
  19503. if (this.beta <= 0) {
  19504. inertialAlphaOffset *= -1;
  19505. }
  19506. if (this.getScene().useRightHandedSystem) {
  19507. inertialAlphaOffset *= -1;
  19508. }
  19509. if (this.parent && this.parent._getWorldMatrixDeterminant() < 0) {
  19510. inertialAlphaOffset *= -1;
  19511. }
  19512. this.alpha += inertialAlphaOffset;
  19513. this.beta += this.inertialBetaOffset;
  19514. this.radius -= this.inertialRadiusOffset;
  19515. this.inertialAlphaOffset *= this.inertia;
  19516. this.inertialBetaOffset *= this.inertia;
  19517. this.inertialRadiusOffset *= this.inertia;
  19518. if (Math.abs(this.inertialAlphaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19519. this.inertialAlphaOffset = 0;
  19520. }
  19521. if (Math.abs(this.inertialBetaOffset) < _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19522. this.inertialBetaOffset = 0;
  19523. }
  19524. if (Math.abs(this.inertialRadiusOffset) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19525. this.inertialRadiusOffset = 0;
  19526. }
  19527. }
  19528. // Panning inertia
  19529. if (this.inertialPanningX !== 0 || this.inertialPanningY !== 0) {
  19530. if (!this._localDirection) {
  19531. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19532. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  19533. }
  19534. this._localDirection.copyFromFloats(this.inertialPanningX, this.inertialPanningY, this.inertialPanningY);
  19535. this._localDirection.multiplyInPlace(this.panningAxis);
  19536. this._viewMatrix.invertToRef(this._cameraTransformMatrix);
  19537. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._localDirection, this._cameraTransformMatrix, this._transformedDirection);
  19538. //Eliminate y if map panning is enabled (panningAxis == 1,0,1)
  19539. if (!this.panningAxis.y) {
  19540. this._transformedDirection.y = 0;
  19541. }
  19542. if (!this._targetHost) {
  19543. if (this.panningDistanceLimit) {
  19544. this._transformedDirection.addInPlace(this._target);
  19545. var distanceSquared = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].DistanceSquared(this._transformedDirection, this.panningOriginTarget);
  19546. if (distanceSquared <= (this.panningDistanceLimit * this.panningDistanceLimit)) {
  19547. this._target.copyFrom(this._transformedDirection);
  19548. }
  19549. }
  19550. else {
  19551. this._target.addInPlace(this._transformedDirection);
  19552. }
  19553. }
  19554. this.inertialPanningX *= this.panningInertia;
  19555. this.inertialPanningY *= this.panningInertia;
  19556. if (Math.abs(this.inertialPanningX) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19557. this.inertialPanningX = 0;
  19558. }
  19559. if (Math.abs(this.inertialPanningY) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  19560. this.inertialPanningY = 0;
  19561. }
  19562. }
  19563. // Limits
  19564. this._checkLimits();
  19565. _super.prototype._checkInputs.call(this);
  19566. };
  19567. ArcRotateCamera.prototype._checkLimits = function () {
  19568. if (this.lowerBetaLimit === null || this.lowerBetaLimit === undefined) {
  19569. if (this.allowUpsideDown && this.beta > Math.PI) {
  19570. this.beta = this.beta - (2 * Math.PI);
  19571. }
  19572. }
  19573. else {
  19574. if (this.beta < this.lowerBetaLimit) {
  19575. this.beta = this.lowerBetaLimit;
  19576. }
  19577. }
  19578. if (this.upperBetaLimit === null || this.upperBetaLimit === undefined) {
  19579. if (this.allowUpsideDown && this.beta < -Math.PI) {
  19580. this.beta = this.beta + (2 * Math.PI);
  19581. }
  19582. }
  19583. else {
  19584. if (this.beta > this.upperBetaLimit) {
  19585. this.beta = this.upperBetaLimit;
  19586. }
  19587. }
  19588. if (this.lowerAlphaLimit !== null && this.alpha < this.lowerAlphaLimit) {
  19589. this.alpha = this.lowerAlphaLimit;
  19590. }
  19591. if (this.upperAlphaLimit !== null && this.alpha > this.upperAlphaLimit) {
  19592. this.alpha = this.upperAlphaLimit;
  19593. }
  19594. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  19595. this.radius = this.lowerRadiusLimit;
  19596. this.inertialRadiusOffset = 0;
  19597. }
  19598. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  19599. this.radius = this.upperRadiusLimit;
  19600. this.inertialRadiusOffset = 0;
  19601. }
  19602. };
  19603. /**
  19604. * Rebuilds angles (alpha, beta) and radius from the give position and target
  19605. * @param updateView defines a boolean forcing the camera to update its position with a view matrix computation first (default is true)
  19606. */
  19607. ArcRotateCamera.prototype.rebuildAnglesAndRadius = function (updateView) {
  19608. if (updateView === void 0) { updateView = true; }
  19609. if (updateView) {
  19610. this.getViewMatrix(); // Force position update
  19611. }
  19612. this.position.subtractToRef(this._getTargetPosition(), this._computationVector);
  19613. this.radius = this._computationVector.length();
  19614. if (this.radius === 0) {
  19615. this.radius = 0.0001; // Just to avoid division by zero
  19616. }
  19617. // Alpha
  19618. this.alpha = Math.acos(this._computationVector.x / Math.sqrt(Math.pow(this._computationVector.x, 2) + Math.pow(this._computationVector.z, 2)));
  19619. if (this._computationVector.z < 0) {
  19620. this.alpha = 2 * Math.PI - this.alpha;
  19621. }
  19622. // Beta
  19623. this.beta = Math.acos(this._computationVector.y / this.radius);
  19624. this._checkLimits();
  19625. };
  19626. /**
  19627. * Use a position to define the current camera related information like aplha, beta and radius
  19628. * @param position Defines the position to set the camera at
  19629. */
  19630. ArcRotateCamera.prototype.setPosition = function (position) {
  19631. if (this.position.equals(position)) {
  19632. return;
  19633. }
  19634. this.position.copyFrom(position);
  19635. this.rebuildAnglesAndRadius(false);
  19636. };
  19637. /**
  19638. * Defines the target the camera should look at.
  19639. * This will automatically adapt alpha beta and radius to fit within the new target.
  19640. * @param target Defines the new target as a Vector or a mesh
  19641. * @param toBoundingCenter In case of a mesh target, defines wether to target the mesh position or its bounding information center
  19642. * @param allowSamePosition If false, prevents reapplying the new computed position if it is identical to the current one (optim)
  19643. */
  19644. ArcRotateCamera.prototype.setTarget = function (target, toBoundingCenter, allowSamePosition) {
  19645. if (toBoundingCenter === void 0) { toBoundingCenter = false; }
  19646. if (allowSamePosition === void 0) { allowSamePosition = false; }
  19647. if (target.getBoundingInfo) {
  19648. if (toBoundingCenter) {
  19649. this._targetBoundingCenter = target.getBoundingInfo().boundingBox.centerWorld.clone();
  19650. }
  19651. else {
  19652. this._targetBoundingCenter = null;
  19653. }
  19654. this._targetHost = target;
  19655. this._target = this._getTargetPosition();
  19656. this.onMeshTargetChangedObservable.notifyObservers(this._targetHost);
  19657. }
  19658. else {
  19659. var newTarget = target;
  19660. var currentTarget = this._getTargetPosition();
  19661. if (currentTarget && !allowSamePosition && currentTarget.equals(newTarget)) {
  19662. return;
  19663. }
  19664. this._targetHost = null;
  19665. this._target = newTarget;
  19666. this._targetBoundingCenter = null;
  19667. this.onMeshTargetChangedObservable.notifyObservers(null);
  19668. }
  19669. this.rebuildAnglesAndRadius();
  19670. };
  19671. /** @hidden */
  19672. ArcRotateCamera.prototype._getViewMatrix = function () {
  19673. // Compute
  19674. var cosa = Math.cos(this.alpha);
  19675. var sina = Math.sin(this.alpha);
  19676. var cosb = Math.cos(this.beta);
  19677. var sinb = Math.sin(this.beta);
  19678. if (sinb === 0) {
  19679. sinb = 0.0001;
  19680. }
  19681. var target = this._getTargetPosition();
  19682. this._computationVector.copyFromFloats(this.radius * cosa * sinb, this.radius * cosb, this.radius * sina * sinb);
  19683. // Rotate according to up vector
  19684. if (this.upVector.x !== 0 || this.upVector.y !== 1.0 || this.upVector.z !== 0) {
  19685. if (!this._tempAxisVector) {
  19686. this._tempAxisVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  19687. this._tempAxisRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  19688. }
  19689. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), this.upVector, this._tempAxisVector);
  19690. this._tempAxisVector.normalize();
  19691. var angle = Math.acos(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].UpReadOnly, this.upVector));
  19692. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(this._tempAxisVector, angle, this._tempAxisRotationMatrix);
  19693. this._tempAxisVector.copyFrom(this._computationVector);
  19694. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._tempAxisVector, this._tempAxisRotationMatrix, this._computationVector);
  19695. }
  19696. target.addToRef(this._computationVector, this._newPosition);
  19697. if (this.getScene().collisionsEnabled && this.checkCollisions) {
  19698. var coordinator = this.getScene().collisionCoordinator;
  19699. if (!this._collider) {
  19700. this._collider = coordinator.createCollider();
  19701. }
  19702. this._collider._radius = this.collisionRadius;
  19703. this._newPosition.subtractToRef(this.position, this._collisionVelocity);
  19704. this._collisionTriggered = true;
  19705. coordinator.getNewPosition(this.position, this._collisionVelocity, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  19706. }
  19707. else {
  19708. this.position.copyFrom(this._newPosition);
  19709. var up = this.upVector;
  19710. if (this.allowUpsideDown && sinb < 0) {
  19711. up = up.clone();
  19712. up = up.negate();
  19713. }
  19714. this._computeViewMatrix(this.position, target, up);
  19715. this._viewMatrix.addAtIndex(12, this.targetScreenOffset.x);
  19716. this._viewMatrix.addAtIndex(13, this.targetScreenOffset.y);
  19717. }
  19718. this._currentTarget = target;
  19719. return this._viewMatrix;
  19720. };
  19721. /**
  19722. * Zooms on a mesh to be at the min distance where we could see it fully in the current viewport.
  19723. * @param meshes Defines the mesh to zoom on
  19724. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  19725. */
  19726. ArcRotateCamera.prototype.zoomOn = function (meshes, doNotUpdateMaxZ) {
  19727. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19728. meshes = meshes || this.getScene().meshes;
  19729. var minMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19730. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(minMaxVector.min, minMaxVector.max);
  19731. this.radius = distance * this.zoomOnFactor;
  19732. this.focusOn({ min: minMaxVector.min, max: minMaxVector.max, distance: distance }, doNotUpdateMaxZ);
  19733. };
  19734. /**
  19735. * Focus on a mesh or a bounding box. This adapts the target and maxRadius if necessary but does not update the current radius.
  19736. * The target will be changed but the radius
  19737. * @param meshesOrMinMaxVectorAndDistance Defines the mesh or bounding info to focus on
  19738. * @param doNotUpdateMaxZ Defines whether or not maxZ should be updated whilst zooming on the mesh (this can happen if the mesh is big and the maxradius pretty small for instance)
  19739. */
  19740. ArcRotateCamera.prototype.focusOn = function (meshesOrMinMaxVectorAndDistance, doNotUpdateMaxZ) {
  19741. if (doNotUpdateMaxZ === void 0) { doNotUpdateMaxZ = false; }
  19742. var meshesOrMinMaxVector;
  19743. var distance;
  19744. if (meshesOrMinMaxVectorAndDistance.min === undefined) { // meshes
  19745. var meshes = meshesOrMinMaxVectorAndDistance || this.getScene().meshes;
  19746. meshesOrMinMaxVector = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].MinMax(meshes);
  19747. distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(meshesOrMinMaxVector.min, meshesOrMinMaxVector.max);
  19748. }
  19749. else { //minMaxVector and distance
  19750. var minMaxVectorAndDistance = meshesOrMinMaxVectorAndDistance;
  19751. meshesOrMinMaxVector = minMaxVectorAndDistance;
  19752. distance = minMaxVectorAndDistance.distance;
  19753. }
  19754. this._target = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].Center(meshesOrMinMaxVector);
  19755. if (!doNotUpdateMaxZ) {
  19756. this.maxZ = distance * 2;
  19757. }
  19758. };
  19759. /**
  19760. * @override
  19761. * Override Camera.createRigCamera
  19762. */
  19763. ArcRotateCamera.prototype.createRigCamera = function (name, cameraIndex) {
  19764. var alphaShift = 0;
  19765. switch (this.cameraRigMode) {
  19766. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19767. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19768. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19769. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19770. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? 1 : -1);
  19771. break;
  19772. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19773. alphaShift = this._cameraRigParams.stereoHalfAngle * (cameraIndex === 0 ? -1 : 1);
  19774. break;
  19775. }
  19776. var rigCam = new ArcRotateCamera(name, this.alpha + alphaShift, this.beta, this.radius, this._target, this.getScene());
  19777. rigCam._cameraRigParams = {};
  19778. return rigCam;
  19779. };
  19780. /**
  19781. * @hidden
  19782. * @override
  19783. * Override Camera._updateRigCameras
  19784. */
  19785. ArcRotateCamera.prototype._updateRigCameras = function () {
  19786. var camLeft = this._rigCameras[0];
  19787. var camRight = this._rigCameras[1];
  19788. camLeft.beta = camRight.beta = this.beta;
  19789. switch (this.cameraRigMode) {
  19790. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  19791. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  19792. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  19793. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_VR:
  19794. camLeft.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19795. camRight.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19796. break;
  19797. case _camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  19798. camLeft.alpha = this.alpha + this._cameraRigParams.stereoHalfAngle;
  19799. camRight.alpha = this.alpha - this._cameraRigParams.stereoHalfAngle;
  19800. break;
  19801. }
  19802. _super.prototype._updateRigCameras.call(this);
  19803. };
  19804. /**
  19805. * Destroy the camera and release the current resources hold by it.
  19806. */
  19807. ArcRotateCamera.prototype.dispose = function () {
  19808. this.inputs.clear();
  19809. _super.prototype.dispose.call(this);
  19810. };
  19811. /**
  19812. * Gets the current object class name.
  19813. * @return the class name
  19814. */
  19815. ArcRotateCamera.prototype.getClassName = function () {
  19816. return "ArcRotateCamera";
  19817. };
  19818. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19819. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19820. ], ArcRotateCamera.prototype, "alpha", void 0);
  19821. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19822. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19823. ], ArcRotateCamera.prototype, "beta", void 0);
  19824. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19825. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19826. ], ArcRotateCamera.prototype, "radius", void 0);
  19827. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19828. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("target")
  19829. ], ArcRotateCamera.prototype, "_target", void 0);
  19830. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19831. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19832. ], ArcRotateCamera.prototype, "inertialAlphaOffset", void 0);
  19833. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19834. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19835. ], ArcRotateCamera.prototype, "inertialBetaOffset", void 0);
  19836. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19837. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19838. ], ArcRotateCamera.prototype, "inertialRadiusOffset", void 0);
  19839. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19840. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19841. ], ArcRotateCamera.prototype, "lowerAlphaLimit", void 0);
  19842. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19843. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19844. ], ArcRotateCamera.prototype, "upperAlphaLimit", void 0);
  19845. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19846. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19847. ], ArcRotateCamera.prototype, "lowerBetaLimit", void 0);
  19848. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19849. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19850. ], ArcRotateCamera.prototype, "upperBetaLimit", void 0);
  19851. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19852. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19853. ], ArcRotateCamera.prototype, "lowerRadiusLimit", void 0);
  19854. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19855. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19856. ], ArcRotateCamera.prototype, "upperRadiusLimit", void 0);
  19857. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19858. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19859. ], ArcRotateCamera.prototype, "inertialPanningX", void 0);
  19860. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19861. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19862. ], ArcRotateCamera.prototype, "inertialPanningY", void 0);
  19863. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19864. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19865. ], ArcRotateCamera.prototype, "pinchToPanMaxDistance", void 0);
  19866. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19867. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19868. ], ArcRotateCamera.prototype, "panningDistanceLimit", void 0);
  19869. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19870. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  19871. ], ArcRotateCamera.prototype, "panningOriginTarget", void 0);
  19872. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19873. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19874. ], ArcRotateCamera.prototype, "panningInertia", void 0);
  19875. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19876. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19877. ], ArcRotateCamera.prototype, "zoomOnFactor", void 0);
  19878. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19879. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19880. ], ArcRotateCamera.prototype, "targetScreenOffset", void 0);
  19881. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19882. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19883. ], ArcRotateCamera.prototype, "allowUpsideDown", void 0);
  19884. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  19885. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  19886. ], ArcRotateCamera.prototype, "useInputToRestoreState", void 0);
  19887. return ArcRotateCamera;
  19888. }(_targetCamera__WEBPACK_IMPORTED_MODULE_10__["TargetCamera"]));
  19889. /***/ }),
  19890. /***/ "./Cameras/arcRotateCameraInputsManager.ts":
  19891. /*!*************************************************!*\
  19892. !*** ./Cameras/arcRotateCameraInputsManager.ts ***!
  19893. \*************************************************/
  19894. /*! exports provided: ArcRotateCameraInputsManager */
  19895. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19896. "use strict";
  19897. __webpack_require__.r(__webpack_exports__);
  19898. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return ArcRotateCameraInputsManager; });
  19899. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19900. /* harmony import */ var _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraPointersInput */ "./Cameras/Inputs/arcRotateCameraPointersInput.ts");
  19901. /* harmony import */ var _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraKeyboardMoveInput */ "./Cameras/Inputs/arcRotateCameraKeyboardMoveInput.ts");
  19902. /* harmony import */ var _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraMouseWheelInput */ "./Cameras/Inputs/arcRotateCameraMouseWheelInput.ts");
  19903. /* harmony import */ var _Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  19904. /**
  19905. * Default Inputs manager for the ArcRotateCamera.
  19906. * It groups all the default supported inputs for ease of use.
  19907. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  19908. */
  19909. var ArcRotateCameraInputsManager = /** @class */ (function (_super) {
  19910. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcRotateCameraInputsManager, _super);
  19911. /**
  19912. * Instantiates a new ArcRotateCameraInputsManager.
  19913. * @param camera Defines the camera the inputs belong to
  19914. */
  19915. function ArcRotateCameraInputsManager(camera) {
  19916. return _super.call(this, camera) || this;
  19917. }
  19918. /**
  19919. * Add mouse wheel input support to the input manager.
  19920. * @returns the current input manager
  19921. */
  19922. ArcRotateCameraInputsManager.prototype.addMouseWheel = function () {
  19923. this.add(new _Cameras_Inputs_arcRotateCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["ArcRotateCameraMouseWheelInput"]());
  19924. return this;
  19925. };
  19926. /**
  19927. * Add pointers input support to the input manager.
  19928. * @returns the current input manager
  19929. */
  19930. ArcRotateCameraInputsManager.prototype.addPointers = function () {
  19931. this.add(new _Cameras_Inputs_arcRotateCameraPointersInput__WEBPACK_IMPORTED_MODULE_1__["ArcRotateCameraPointersInput"]());
  19932. return this;
  19933. };
  19934. /**
  19935. * Add keyboard input support to the input manager.
  19936. * @returns the current input manager
  19937. */
  19938. ArcRotateCameraInputsManager.prototype.addKeyboard = function () {
  19939. this.add(new _Cameras_Inputs_arcRotateCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCameraKeyboardMoveInput"]());
  19940. return this;
  19941. };
  19942. return ArcRotateCameraInputsManager;
  19943. }(_Cameras_cameraInputsManager__WEBPACK_IMPORTED_MODULE_4__["CameraInputsManager"]));
  19944. /***/ }),
  19945. /***/ "./Cameras/camera.ts":
  19946. /*!***************************!*\
  19947. !*** ./Cameras/camera.ts ***!
  19948. \***************************/
  19949. /*! exports provided: Camera */
  19950. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  19951. "use strict";
  19952. __webpack_require__.r(__webpack_exports__);
  19953. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return Camera; });
  19954. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  19955. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  19956. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  19957. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  19958. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  19959. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  19960. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  19961. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  19962. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  19963. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  19964. /**
  19965. * This is the base class of all the camera used in the application.
  19966. * @see http://doc.babylonjs.com/features/cameras
  19967. */
  19968. var Camera = /** @class */ (function (_super) {
  19969. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Camera, _super);
  19970. /**
  19971. * Instantiates a new camera object.
  19972. * This should not be used directly but through the inherited cameras: ArcRotate, Free...
  19973. * @see http://doc.babylonjs.com/features/cameras
  19974. * @param name Defines the name of the camera in the scene
  19975. * @param position Defines the position of the camera
  19976. * @param scene Defines the scene the camera belongs too
  19977. * @param setActiveOnSceneIfNoneActive Defines if the camera should be set as active after creation if no other camera have been defined in the scene
  19978. */
  19979. function Camera(name, position, scene, setActiveOnSceneIfNoneActive) {
  19980. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  19981. var _this = _super.call(this, name, scene) || this;
  19982. /**
  19983. * The vector the camera should consider as up.
  19984. * (default is Vector3(0, 1, 0) aka Vector3.Up())
  19985. */
  19986. _this.upVector = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Up();
  19987. /**
  19988. * Define the current limit on the left side for an orthographic camera
  19989. * In scene unit
  19990. */
  19991. _this.orthoLeft = null;
  19992. /**
  19993. * Define the current limit on the right side for an orthographic camera
  19994. * In scene unit
  19995. */
  19996. _this.orthoRight = null;
  19997. /**
  19998. * Define the current limit on the bottom side for an orthographic camera
  19999. * In scene unit
  20000. */
  20001. _this.orthoBottom = null;
  20002. /**
  20003. * Define the current limit on the top side for an orthographic camera
  20004. * In scene unit
  20005. */
  20006. _this.orthoTop = null;
  20007. /**
  20008. * Field Of View is set in Radians. (default is 0.8)
  20009. */
  20010. _this.fov = 0.8;
  20011. /**
  20012. * Define the minimum distance the camera can see from.
  20013. * This is important to note that the depth buffer are not infinite and the closer it starts
  20014. * the more your scene might encounter depth fighting issue.
  20015. */
  20016. _this.minZ = 1;
  20017. /**
  20018. * Define the maximum distance the camera can see to.
  20019. * This is important to note that the depth buffer are not infinite and the further it end
  20020. * the more your scene might encounter depth fighting issue.
  20021. */
  20022. _this.maxZ = 10000.0;
  20023. /**
  20024. * Define the default inertia of the camera.
  20025. * This helps giving a smooth feeling to the camera movement.
  20026. */
  20027. _this.inertia = 0.9;
  20028. /**
  20029. * Define the mode of the camera (Camera.PERSPECTIVE_CAMERA or Camera.PERSPECTIVE_ORTHOGRAPHIC)
  20030. */
  20031. _this.mode = Camera.PERSPECTIVE_CAMERA;
  20032. /**
  20033. * Define wether the camera is intermediate.
  20034. * This is useful to not present the output directly to the screen in case of rig without post process for instance
  20035. */
  20036. _this.isIntermediate = false;
  20037. /**
  20038. * Define the viewport of the camera.
  20039. * This correspond to the portion of the screen the camera will render to in normalized 0 to 1 unit.
  20040. */
  20041. _this.viewport = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Viewport"](0, 0, 1.0, 1.0);
  20042. /**
  20043. * Restricts the camera to viewing objects with the same layerMask.
  20044. * A camera with a layerMask of 1 will render mesh.layerMask & camera.layerMask!== 0
  20045. */
  20046. _this.layerMask = 0x0FFFFFFF;
  20047. /**
  20048. * fovMode sets the camera frustum bounds to the viewport bounds. (default is FOVMODE_VERTICAL_FIXED)
  20049. */
  20050. _this.fovMode = Camera.FOVMODE_VERTICAL_FIXED;
  20051. /**
  20052. * Rig mode of the camera.
  20053. * This is useful to create the camera with two "eyes" instead of one to create VR or stereoscopic scenes.
  20054. * This is normally controlled byt the camera themselves as internal use.
  20055. */
  20056. _this.cameraRigMode = Camera.RIG_MODE_NONE;
  20057. /**
  20058. * Defines the list of custom render target which are rendered to and then used as the input to this camera's render. Eg. display another camera view on a TV in the main scene
  20059. * This is pretty helpfull if you wish to make a camera render to a texture you could reuse somewhere
  20060. * else in the scene.
  20061. */
  20062. _this.customRenderTargets = new Array();
  20063. /**
  20064. * When set, the camera will render to this render target instead of the default canvas
  20065. */
  20066. _this.outputRenderTarget = null;
  20067. /**
  20068. * Observable triggered when the camera view matrix has changed.
  20069. */
  20070. _this.onViewMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20071. /**
  20072. * Observable triggered when the camera Projection matrix has changed.
  20073. */
  20074. _this.onProjectionMatrixChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20075. /**
  20076. * Observable triggered when the inputs have been processed.
  20077. */
  20078. _this.onAfterCheckInputsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20079. /**
  20080. * Observable triggered when reset has been called and applied to the camera.
  20081. */
  20082. _this.onRestoreStateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_4__["Observable"]();
  20083. /** @hidden */
  20084. _this._rigCameras = new Array();
  20085. _this._webvrViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20086. /** @hidden */
  20087. _this._skipRendering = false;
  20088. /** @hidden */
  20089. _this._projectionMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  20090. /** @hidden */
  20091. _this._postProcesses = new Array();
  20092. /** @hidden */
  20093. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](256);
  20094. _this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20095. /** hidden */
  20096. _this._computedViewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20097. _this._doNotComputeProjectionMatrix = false;
  20098. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Zero();
  20099. _this._refreshFrustumPlanes = true;
  20100. /** @hidden */
  20101. _this._isCamera = true;
  20102. _this.getScene().addCamera(_this);
  20103. if (setActiveOnSceneIfNoneActive && !_this.getScene().activeCamera) {
  20104. _this.getScene().activeCamera = _this;
  20105. }
  20106. _this.position = position;
  20107. return _this;
  20108. }
  20109. /**
  20110. * Store current camera state (fov, position, etc..)
  20111. * @returns the camera
  20112. */
  20113. Camera.prototype.storeState = function () {
  20114. this._stateStored = true;
  20115. this._storedFov = this.fov;
  20116. return this;
  20117. };
  20118. /**
  20119. * Restores the camera state values if it has been stored. You must call storeState() first
  20120. */
  20121. Camera.prototype._restoreStateValues = function () {
  20122. if (!this._stateStored) {
  20123. return false;
  20124. }
  20125. this.fov = this._storedFov;
  20126. return true;
  20127. };
  20128. /**
  20129. * Restored camera state. You must call storeState() first.
  20130. * @returns true if restored and false otherwise
  20131. */
  20132. Camera.prototype.restoreState = function () {
  20133. if (this._restoreStateValues()) {
  20134. this.onRestoreStateObservable.notifyObservers(this);
  20135. return true;
  20136. }
  20137. return false;
  20138. };
  20139. /**
  20140. * Gets the class name of the camera.
  20141. * @returns the class name
  20142. */
  20143. Camera.prototype.getClassName = function () {
  20144. return "Camera";
  20145. };
  20146. /**
  20147. * Gets a string representation of the camera useful for debug purpose.
  20148. * @param fullDetails Defines that a more verboe level of logging is required
  20149. * @returns the string representation
  20150. */
  20151. Camera.prototype.toString = function (fullDetails) {
  20152. var ret = "Name: " + this.name;
  20153. ret += ", type: " + this.getClassName();
  20154. if (this.animations) {
  20155. for (var i = 0; i < this.animations.length; i++) {
  20156. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  20157. }
  20158. }
  20159. if (fullDetails) {
  20160. }
  20161. return ret;
  20162. };
  20163. Object.defineProperty(Camera.prototype, "globalPosition", {
  20164. /**
  20165. * Gets the current world space position of the camera.
  20166. */
  20167. get: function () {
  20168. return this._globalPosition;
  20169. },
  20170. enumerable: true,
  20171. configurable: true
  20172. });
  20173. /**
  20174. * Gets the list of active meshes this frame (meshes no culled or excluded by lod s in the frame)
  20175. * @returns the active meshe list
  20176. */
  20177. Camera.prototype.getActiveMeshes = function () {
  20178. return this._activeMeshes;
  20179. };
  20180. /**
  20181. * Check wether a mesh is part of the current active mesh list of the camera
  20182. * @param mesh Defines the mesh to check
  20183. * @returns true if active, false otherwise
  20184. */
  20185. Camera.prototype.isActiveMesh = function (mesh) {
  20186. return (this._activeMeshes.indexOf(mesh) !== -1);
  20187. };
  20188. /**
  20189. * Is this camera ready to be used/rendered
  20190. * @param completeCheck defines if a complete check (including post processes) has to be done (false by default)
  20191. * @return true if the camera is ready
  20192. */
  20193. Camera.prototype.isReady = function (completeCheck) {
  20194. if (completeCheck === void 0) { completeCheck = false; }
  20195. if (completeCheck) {
  20196. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  20197. var pp = _a[_i];
  20198. if (pp && !pp.isReady()) {
  20199. return false;
  20200. }
  20201. }
  20202. }
  20203. return _super.prototype.isReady.call(this, completeCheck);
  20204. };
  20205. /** @hidden */
  20206. Camera.prototype._initCache = function () {
  20207. _super.prototype._initCache.call(this);
  20208. this._cache.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20209. this._cache.upVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  20210. this._cache.mode = undefined;
  20211. this._cache.minZ = undefined;
  20212. this._cache.maxZ = undefined;
  20213. this._cache.fov = undefined;
  20214. this._cache.fovMode = undefined;
  20215. this._cache.aspectRatio = undefined;
  20216. this._cache.orthoLeft = undefined;
  20217. this._cache.orthoRight = undefined;
  20218. this._cache.orthoBottom = undefined;
  20219. this._cache.orthoTop = undefined;
  20220. this._cache.renderWidth = undefined;
  20221. this._cache.renderHeight = undefined;
  20222. };
  20223. /** @hidden */
  20224. Camera.prototype._updateCache = function (ignoreParentClass) {
  20225. if (!ignoreParentClass) {
  20226. _super.prototype._updateCache.call(this);
  20227. }
  20228. this._cache.position.copyFrom(this.position);
  20229. this._cache.upVector.copyFrom(this.upVector);
  20230. };
  20231. /** @hidden */
  20232. Camera.prototype._isSynchronized = function () {
  20233. return this._isSynchronizedViewMatrix() && this._isSynchronizedProjectionMatrix();
  20234. };
  20235. /** @hidden */
  20236. Camera.prototype._isSynchronizedViewMatrix = function () {
  20237. if (!_super.prototype._isSynchronized.call(this)) {
  20238. return false;
  20239. }
  20240. return this._cache.position.equals(this.position)
  20241. && this._cache.upVector.equals(this.upVector)
  20242. && this.isSynchronizedWithParent();
  20243. };
  20244. /** @hidden */
  20245. Camera.prototype._isSynchronizedProjectionMatrix = function () {
  20246. var check = this._cache.mode === this.mode
  20247. && this._cache.minZ === this.minZ
  20248. && this._cache.maxZ === this.maxZ;
  20249. if (!check) {
  20250. return false;
  20251. }
  20252. var engine = this.getEngine();
  20253. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20254. check = this._cache.fov === this.fov
  20255. && this._cache.fovMode === this.fovMode
  20256. && this._cache.aspectRatio === engine.getAspectRatio(this);
  20257. }
  20258. else {
  20259. check = this._cache.orthoLeft === this.orthoLeft
  20260. && this._cache.orthoRight === this.orthoRight
  20261. && this._cache.orthoBottom === this.orthoBottom
  20262. && this._cache.orthoTop === this.orthoTop
  20263. && this._cache.renderWidth === engine.getRenderWidth()
  20264. && this._cache.renderHeight === engine.getRenderHeight();
  20265. }
  20266. return check;
  20267. };
  20268. /**
  20269. * Attach the input controls to a specific dom element to get the input from.
  20270. * @param element Defines the element the controls should be listened from
  20271. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  20272. */
  20273. Camera.prototype.attachControl = function (element, noPreventDefault) {
  20274. };
  20275. /**
  20276. * Detach the current controls from the specified dom element.
  20277. * @param element Defines the element to stop listening the inputs from
  20278. */
  20279. Camera.prototype.detachControl = function (element) {
  20280. };
  20281. /**
  20282. * Update the camera state according to the different inputs gathered during the frame.
  20283. */
  20284. Camera.prototype.update = function () {
  20285. this._checkInputs();
  20286. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20287. this._updateRigCameras();
  20288. }
  20289. };
  20290. /** @hidden */
  20291. Camera.prototype._checkInputs = function () {
  20292. this.onAfterCheckInputsObservable.notifyObservers(this);
  20293. };
  20294. Object.defineProperty(Camera.prototype, "rigCameras", {
  20295. /** @hidden */
  20296. get: function () {
  20297. return this._rigCameras;
  20298. },
  20299. enumerable: true,
  20300. configurable: true
  20301. });
  20302. Object.defineProperty(Camera.prototype, "rigPostProcess", {
  20303. /**
  20304. * Gets the post process used by the rig cameras
  20305. */
  20306. get: function () {
  20307. return this._rigPostProcess;
  20308. },
  20309. enumerable: true,
  20310. configurable: true
  20311. });
  20312. /**
  20313. * Internal, gets the first post proces.
  20314. * @returns the first post process to be run on this camera.
  20315. */
  20316. Camera.prototype._getFirstPostProcess = function () {
  20317. for (var ppIndex = 0; ppIndex < this._postProcesses.length; ppIndex++) {
  20318. if (this._postProcesses[ppIndex] !== null) {
  20319. return this._postProcesses[ppIndex];
  20320. }
  20321. }
  20322. return null;
  20323. };
  20324. Camera.prototype._cascadePostProcessesToRigCams = function () {
  20325. // invalidate framebuffer
  20326. var firstPostProcess = this._getFirstPostProcess();
  20327. if (firstPostProcess) {
  20328. firstPostProcess.markTextureDirty();
  20329. }
  20330. // glue the rigPostProcess to the end of the user postprocesses & assign to each sub-camera
  20331. for (var i = 0, len = this._rigCameras.length; i < len; i++) {
  20332. var cam = this._rigCameras[i];
  20333. var rigPostProcess = cam._rigPostProcess;
  20334. // for VR rig, there does not have to be a post process
  20335. if (rigPostProcess) {
  20336. var isPass = rigPostProcess.getEffectName() === "pass";
  20337. if (isPass) {
  20338. // any rig which has a PassPostProcess for rig[0], cannot be isIntermediate when there are also user postProcesses
  20339. cam.isIntermediate = this._postProcesses.length === 0;
  20340. }
  20341. cam._postProcesses = this._postProcesses.slice(0).concat(rigPostProcess);
  20342. rigPostProcess.markTextureDirty();
  20343. }
  20344. else {
  20345. cam._postProcesses = this._postProcesses.slice(0);
  20346. }
  20347. }
  20348. };
  20349. /**
  20350. * Attach a post process to the camera.
  20351. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20352. * @param postProcess The post process to attach to the camera
  20353. * @param insertAt The position of the post process in case several of them are in use in the scene
  20354. * @returns the position the post process has been inserted at
  20355. */
  20356. Camera.prototype.attachPostProcess = function (postProcess, insertAt) {
  20357. if (insertAt === void 0) { insertAt = null; }
  20358. if (!postProcess.isReusable() && this._postProcesses.indexOf(postProcess) > -1) {
  20359. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("You're trying to reuse a post process not defined as reusable.");
  20360. return 0;
  20361. }
  20362. if (insertAt == null || insertAt < 0) {
  20363. this._postProcesses.push(postProcess);
  20364. }
  20365. else if (this._postProcesses[insertAt] === null) {
  20366. this._postProcesses[insertAt] = postProcess;
  20367. }
  20368. else {
  20369. this._postProcesses.splice(insertAt, 0, postProcess);
  20370. }
  20371. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20372. return this._postProcesses.indexOf(postProcess);
  20373. };
  20374. /**
  20375. * Detach a post process to the camera.
  20376. * @see http://doc.babylonjs.com/how_to/how_to_use_postprocesses#attach-postprocess
  20377. * @param postProcess The post process to detach from the camera
  20378. */
  20379. Camera.prototype.detachPostProcess = function (postProcess) {
  20380. var idx = this._postProcesses.indexOf(postProcess);
  20381. if (idx !== -1) {
  20382. this._postProcesses[idx] = null;
  20383. }
  20384. this._cascadePostProcessesToRigCams(); // also ensures framebuffer invalidated
  20385. };
  20386. /**
  20387. * Gets the current world matrix of the camera
  20388. */
  20389. Camera.prototype.getWorldMatrix = function () {
  20390. if (this._isSynchronizedViewMatrix()) {
  20391. return this._worldMatrix;
  20392. }
  20393. // Getting the the view matrix will also compute the world matrix.
  20394. this.getViewMatrix();
  20395. return this._worldMatrix;
  20396. };
  20397. /** @hidden */
  20398. Camera.prototype._getViewMatrix = function () {
  20399. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20400. };
  20401. /**
  20402. * Gets the current view matrix of the camera.
  20403. * @param force forces the camera to recompute the matrix without looking at the cached state
  20404. * @returns the view matrix
  20405. */
  20406. Camera.prototype.getViewMatrix = function (force) {
  20407. if (!force && this._isSynchronizedViewMatrix()) {
  20408. return this._computedViewMatrix;
  20409. }
  20410. this.updateCache();
  20411. this._computedViewMatrix = this._getViewMatrix();
  20412. this._currentRenderId = this.getScene().getRenderId();
  20413. this._childRenderId = this._currentRenderId;
  20414. this._refreshFrustumPlanes = true;
  20415. if (this._cameraRigParams && this._cameraRigParams.vrPreViewMatrix) {
  20416. this._computedViewMatrix.multiplyToRef(this._cameraRigParams.vrPreViewMatrix, this._computedViewMatrix);
  20417. }
  20418. this.onViewMatrixChangedObservable.notifyObservers(this);
  20419. this._computedViewMatrix.invertToRef(this._worldMatrix);
  20420. return this._computedViewMatrix;
  20421. };
  20422. /**
  20423. * Freeze the projection matrix.
  20424. * It will prevent the cache check of the camera projection compute and can speed up perf
  20425. * if no parameter of the camera are meant to change
  20426. * @param projection Defines manually a projection if necessary
  20427. */
  20428. Camera.prototype.freezeProjectionMatrix = function (projection) {
  20429. this._doNotComputeProjectionMatrix = true;
  20430. if (projection !== undefined) {
  20431. this._projectionMatrix = projection;
  20432. }
  20433. };
  20434. /**
  20435. * Unfreeze the projection matrix if it has previously been freezed by freezeProjectionMatrix.
  20436. */
  20437. Camera.prototype.unfreezeProjectionMatrix = function () {
  20438. this._doNotComputeProjectionMatrix = false;
  20439. };
  20440. /**
  20441. * Gets the current projection matrix of the camera.
  20442. * @param force forces the camera to recompute the matrix without looking at the cached state
  20443. * @returns the projection matrix
  20444. */
  20445. Camera.prototype.getProjectionMatrix = function (force) {
  20446. if (this._doNotComputeProjectionMatrix || (!force && this._isSynchronizedProjectionMatrix())) {
  20447. return this._projectionMatrix;
  20448. }
  20449. // Cache
  20450. this._cache.mode = this.mode;
  20451. this._cache.minZ = this.minZ;
  20452. this._cache.maxZ = this.maxZ;
  20453. // Matrix
  20454. this._refreshFrustumPlanes = true;
  20455. var engine = this.getEngine();
  20456. var scene = this.getScene();
  20457. if (this.mode === Camera.PERSPECTIVE_CAMERA) {
  20458. this._cache.fov = this.fov;
  20459. this._cache.fovMode = this.fovMode;
  20460. this._cache.aspectRatio = engine.getAspectRatio(this);
  20461. if (this.minZ <= 0) {
  20462. this.minZ = 0.1;
  20463. }
  20464. if (scene.useRightHandedSystem) {
  20465. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovRHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  20466. }
  20467. else {
  20468. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this.fov, engine.getAspectRatio(this), this.minZ, this.maxZ, this._projectionMatrix, this.fovMode === Camera.FOVMODE_VERTICAL_FIXED);
  20469. }
  20470. }
  20471. else {
  20472. var halfWidth = engine.getRenderWidth() / 2.0;
  20473. var halfHeight = engine.getRenderHeight() / 2.0;
  20474. if (scene.useRightHandedSystem) {
  20475. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterRHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  20476. }
  20477. else {
  20478. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].OrthoOffCenterLHToRef(this.orthoLeft || -halfWidth, this.orthoRight || halfWidth, this.orthoBottom || -halfHeight, this.orthoTop || halfHeight, this.minZ, this.maxZ, this._projectionMatrix);
  20479. }
  20480. this._cache.orthoLeft = this.orthoLeft;
  20481. this._cache.orthoRight = this.orthoRight;
  20482. this._cache.orthoBottom = this.orthoBottom;
  20483. this._cache.orthoTop = this.orthoTop;
  20484. this._cache.renderWidth = engine.getRenderWidth();
  20485. this._cache.renderHeight = engine.getRenderHeight();
  20486. }
  20487. this.onProjectionMatrixChangedObservable.notifyObservers(this);
  20488. return this._projectionMatrix;
  20489. };
  20490. /**
  20491. * Gets the transformation matrix (ie. the multiplication of view by projection matrices)
  20492. * @returns a Matrix
  20493. */
  20494. Camera.prototype.getTransformationMatrix = function () {
  20495. this._computedViewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  20496. return this._transformMatrix;
  20497. };
  20498. Camera.prototype._updateFrustumPlanes = function () {
  20499. if (!this._refreshFrustumPlanes) {
  20500. return;
  20501. }
  20502. this.getTransformationMatrix();
  20503. if (!this._frustumPlanes) {
  20504. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanes(this._transformMatrix);
  20505. }
  20506. else {
  20507. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  20508. }
  20509. this._refreshFrustumPlanes = false;
  20510. };
  20511. /**
  20512. * Checks if a cullable object (mesh...) is in the camera frustum
  20513. * This checks the bounding box center. See isCompletelyInFrustum for a full bounding check
  20514. * @param target The object to check
  20515. * @returns true if the object is in frustum otherwise false
  20516. */
  20517. Camera.prototype.isInFrustum = function (target) {
  20518. this._updateFrustumPlanes();
  20519. return target.isInFrustum(this._frustumPlanes);
  20520. };
  20521. /**
  20522. * Checks if a cullable object (mesh...) is in the camera frustum
  20523. * Unlike isInFrustum this cheks the full bounding box
  20524. * @param target The object to check
  20525. * @returns true if the object is in frustum otherwise false
  20526. */
  20527. Camera.prototype.isCompletelyInFrustum = function (target) {
  20528. this._updateFrustumPlanes();
  20529. return target.isCompletelyInFrustum(this._frustumPlanes);
  20530. };
  20531. /**
  20532. * Gets a ray in the forward direction from the camera.
  20533. * @param length Defines the length of the ray to create
  20534. * @param transform Defines the transform to apply to the ray, by default the world matrx is used to create a workd space ray
  20535. * @param origin Defines the start point of the ray which defaults to the camera position
  20536. * @returns the forward ray
  20537. */
  20538. Camera.prototype.getForwardRay = function (length, transform, origin) {
  20539. if (length === void 0) { length = 100; }
  20540. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("Ray");
  20541. };
  20542. /**
  20543. * Releases resources associated with this node.
  20544. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  20545. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  20546. */
  20547. Camera.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  20548. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  20549. // Observables
  20550. this.onViewMatrixChangedObservable.clear();
  20551. this.onProjectionMatrixChangedObservable.clear();
  20552. this.onAfterCheckInputsObservable.clear();
  20553. this.onRestoreStateObservable.clear();
  20554. // Inputs
  20555. if (this.inputs) {
  20556. this.inputs.clear();
  20557. }
  20558. // Animations
  20559. this.getScene().stopAnimation(this);
  20560. // Remove from scene
  20561. this.getScene().removeCamera(this);
  20562. while (this._rigCameras.length > 0) {
  20563. var camera = this._rigCameras.pop();
  20564. if (camera) {
  20565. camera.dispose();
  20566. }
  20567. }
  20568. // Postprocesses
  20569. if (this._rigPostProcess) {
  20570. this._rigPostProcess.dispose(this);
  20571. this._rigPostProcess = null;
  20572. this._postProcesses = [];
  20573. }
  20574. else if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20575. this._rigPostProcess = null;
  20576. this._postProcesses = [];
  20577. }
  20578. else {
  20579. var i = this._postProcesses.length;
  20580. while (--i >= 0) {
  20581. var postProcess = this._postProcesses[i];
  20582. if (postProcess) {
  20583. postProcess.dispose(this);
  20584. }
  20585. }
  20586. }
  20587. // Render targets
  20588. var i = this.customRenderTargets.length;
  20589. while (--i >= 0) {
  20590. this.customRenderTargets[i].dispose();
  20591. }
  20592. this.customRenderTargets = [];
  20593. // Active Meshes
  20594. this._activeMeshes.dispose();
  20595. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  20596. };
  20597. Object.defineProperty(Camera.prototype, "leftCamera", {
  20598. /**
  20599. * Gets the left camera of a rig setup in case of Rigged Camera
  20600. */
  20601. get: function () {
  20602. if (this._rigCameras.length < 1) {
  20603. return null;
  20604. }
  20605. return this._rigCameras[0];
  20606. },
  20607. enumerable: true,
  20608. configurable: true
  20609. });
  20610. Object.defineProperty(Camera.prototype, "rightCamera", {
  20611. /**
  20612. * Gets the right camera of a rig setup in case of Rigged Camera
  20613. */
  20614. get: function () {
  20615. if (this._rigCameras.length < 2) {
  20616. return null;
  20617. }
  20618. return this._rigCameras[1];
  20619. },
  20620. enumerable: true,
  20621. configurable: true
  20622. });
  20623. /**
  20624. * Gets the left camera target of a rig setup in case of Rigged Camera
  20625. * @returns the target position
  20626. */
  20627. Camera.prototype.getLeftTarget = function () {
  20628. if (this._rigCameras.length < 1) {
  20629. return null;
  20630. }
  20631. return this._rigCameras[0].getTarget();
  20632. };
  20633. /**
  20634. * Gets the right camera target of a rig setup in case of Rigged Camera
  20635. * @returns the target position
  20636. */
  20637. Camera.prototype.getRightTarget = function () {
  20638. if (this._rigCameras.length < 2) {
  20639. return null;
  20640. }
  20641. return this._rigCameras[1].getTarget();
  20642. };
  20643. /**
  20644. * @hidden
  20645. */
  20646. Camera.prototype.setCameraRigMode = function (mode, rigParams) {
  20647. if (this.cameraRigMode === mode) {
  20648. return;
  20649. }
  20650. while (this._rigCameras.length > 0) {
  20651. var camera = this._rigCameras.pop();
  20652. if (camera) {
  20653. camera.dispose();
  20654. }
  20655. }
  20656. this.cameraRigMode = mode;
  20657. this._cameraRigParams = {};
  20658. //we have to implement stereo camera calcultating left and right viewpoints from interaxialDistance and target,
  20659. //not from a given angle as it is now, but until that complete code rewriting provisional stereoHalfAngle value is introduced
  20660. this._cameraRigParams.interaxialDistance = rigParams.interaxialDistance || 0.0637;
  20661. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(this._cameraRigParams.interaxialDistance / 0.0637);
  20662. // create the rig cameras, unless none
  20663. if (this.cameraRigMode !== Camera.RIG_MODE_NONE) {
  20664. var leftCamera = this.createRigCamera(this.name + "_L", 0);
  20665. var rightCamera = this.createRigCamera(this.name + "_R", 1);
  20666. if (leftCamera && rightCamera) {
  20667. this._rigCameras.push(leftCamera);
  20668. this._rigCameras.push(rightCamera);
  20669. }
  20670. }
  20671. switch (this.cameraRigMode) {
  20672. case Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  20673. Camera._setStereoscopicAnaglyphRigMode(this);
  20674. break;
  20675. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  20676. case Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  20677. case Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER:
  20678. Camera._setStereoscopicRigMode(this);
  20679. break;
  20680. case Camera.RIG_MODE_VR:
  20681. Camera._setVRRigMode(this, rigParams);
  20682. break;
  20683. case Camera.RIG_MODE_WEBVR:
  20684. Camera._setWebVRRigMode(this, rigParams);
  20685. break;
  20686. }
  20687. this._cascadePostProcessesToRigCams();
  20688. this.update();
  20689. };
  20690. /** @hidden */
  20691. Camera._setStereoscopicRigMode = function (camera) {
  20692. throw "Import Cameras/RigModes/stereoscopicRigMode before using stereoscopic rig mode";
  20693. };
  20694. /** @hidden */
  20695. Camera._setStereoscopicAnaglyphRigMode = function (camera) {
  20696. throw "Import Cameras/RigModes/stereoscopicAnaglyphRigMode before using stereoscopic anaglyph rig mode";
  20697. };
  20698. /** @hidden */
  20699. Camera._setVRRigMode = function (camera, rigParams) {
  20700. throw "Import Cameras/RigModes/vrRigMode before using VR rig mode";
  20701. };
  20702. /** @hidden */
  20703. Camera._setWebVRRigMode = function (camera, rigParams) {
  20704. throw "Import Cameras/RigModes/WebVRRigMode before using Web VR rig mode";
  20705. };
  20706. /** @hidden */
  20707. Camera.prototype._getVRProjectionMatrix = function () {
  20708. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].PerspectiveFovLHToRef(this._cameraRigParams.vrMetrics.aspectRatioFov, this._cameraRigParams.vrMetrics.aspectRatio, this.minZ, this.maxZ, this._cameraRigParams.vrWorkMatrix);
  20709. this._cameraRigParams.vrWorkMatrix.multiplyToRef(this._cameraRigParams.vrHMatrix, this._projectionMatrix);
  20710. return this._projectionMatrix;
  20711. };
  20712. Camera.prototype._updateCameraRotationMatrix = function () {
  20713. //Here for WebVR
  20714. };
  20715. Camera.prototype._updateWebVRCameraRotationMatrix = function () {
  20716. //Here for WebVR
  20717. };
  20718. /**
  20719. * This function MUST be overwritten by the different WebVR cameras available.
  20720. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20721. * @hidden
  20722. */
  20723. Camera.prototype._getWebVRProjectionMatrix = function () {
  20724. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20725. };
  20726. /**
  20727. * This function MUST be overwritten by the different WebVR cameras available.
  20728. * The context in which it is running is the RIG camera. So 'this' is the TargetCamera, left or right.
  20729. * @hidden
  20730. */
  20731. Camera.prototype._getWebVRViewMatrix = function () {
  20732. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  20733. };
  20734. /** @hidden */
  20735. Camera.prototype.setCameraRigParameter = function (name, value) {
  20736. if (!this._cameraRigParams) {
  20737. this._cameraRigParams = {};
  20738. }
  20739. this._cameraRigParams[name] = value;
  20740. //provisionnally:
  20741. if (name === "interaxialDistance") {
  20742. this._cameraRigParams.stereoHalfAngle = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].ToRadians(value / 0.0637);
  20743. }
  20744. };
  20745. /**
  20746. * needs to be overridden by children so sub has required properties to be copied
  20747. * @hidden
  20748. */
  20749. Camera.prototype.createRigCamera = function (name, cameraIndex) {
  20750. return null;
  20751. };
  20752. /**
  20753. * May need to be overridden by children
  20754. * @hidden
  20755. */
  20756. Camera.prototype._updateRigCameras = function () {
  20757. for (var i = 0; i < this._rigCameras.length; i++) {
  20758. this._rigCameras[i].minZ = this.minZ;
  20759. this._rigCameras[i].maxZ = this.maxZ;
  20760. this._rigCameras[i].fov = this.fov;
  20761. this._rigCameras[i].upVector.copyFrom(this.upVector);
  20762. }
  20763. // only update viewport when ANAGLYPH
  20764. if (this.cameraRigMode === Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH) {
  20765. this._rigCameras[0].viewport = this._rigCameras[1].viewport = this.viewport;
  20766. }
  20767. };
  20768. /** @hidden */
  20769. Camera.prototype._setupInputs = function () {
  20770. };
  20771. /**
  20772. * Serialiaze the camera setup to a json represention
  20773. * @returns the JSON representation
  20774. */
  20775. Camera.prototype.serialize = function () {
  20776. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  20777. // Type
  20778. serializationObject.type = this.getClassName();
  20779. // Parent
  20780. if (this.parent) {
  20781. serializationObject.parentId = this.parent.id;
  20782. }
  20783. if (this.inputs) {
  20784. this.inputs.serialize(serializationObject);
  20785. }
  20786. // Animations
  20787. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  20788. serializationObject.ranges = this.serializeAnimationRanges();
  20789. return serializationObject;
  20790. };
  20791. /**
  20792. * Clones the current camera.
  20793. * @param name The cloned camera name
  20794. * @returns the cloned camera
  20795. */
  20796. Camera.prototype.clone = function (name) {
  20797. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(Camera.GetConstructorFromName(this.getClassName(), name, this.getScene(), this.interaxialDistance, this.isStereoscopicSideBySide), this);
  20798. };
  20799. /**
  20800. * Gets the direction of the camera relative to a given local axis.
  20801. * @param localAxis Defines the reference axis to provide a relative direction.
  20802. * @return the direction
  20803. */
  20804. Camera.prototype.getDirection = function (localAxis) {
  20805. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  20806. this.getDirectionToRef(localAxis, result);
  20807. return result;
  20808. };
  20809. /**
  20810. * Gets the direction of the camera relative to a given local axis into a passed vector.
  20811. * @param localAxis Defines the reference axis to provide a relative direction.
  20812. * @param result Defines the vector to store the result in
  20813. */
  20814. Camera.prototype.getDirectionToRef = function (localAxis, result) {
  20815. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  20816. };
  20817. /**
  20818. * Gets a camera constructor for a given camera type
  20819. * @param type The type of the camera to construct (should be equal to one of the camera class name)
  20820. * @param name The name of the camera the result will be able to instantiate
  20821. * @param scene The scene the result will construct the camera in
  20822. * @param interaxial_distance In case of stereoscopic setup, the distance between both eyes
  20823. * @param isStereoscopicSideBySide In case of stereoscopic setup, should the sereo be side b side
  20824. * @returns a factory method to construc the camera
  20825. */
  20826. Camera.GetConstructorFromName = function (type, name, scene, interaxial_distance, isStereoscopicSideBySide) {
  20827. if (interaxial_distance === void 0) { interaxial_distance = 0; }
  20828. if (isStereoscopicSideBySide === void 0) { isStereoscopicSideBySide = true; }
  20829. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_6__["Node"].Construct(type, name, scene, {
  20830. interaxial_distance: interaxial_distance,
  20831. isStereoscopicSideBySide: isStereoscopicSideBySide
  20832. });
  20833. if (constructorFunc) {
  20834. return constructorFunc;
  20835. }
  20836. // Default to universal camera
  20837. return function () { return Camera._createDefaultParsedCamera(name, scene); };
  20838. };
  20839. /**
  20840. * Compute the world matrix of the camera.
  20841. * @returns the camera workd matrix
  20842. */
  20843. Camera.prototype.computeWorldMatrix = function () {
  20844. return this.getWorldMatrix();
  20845. };
  20846. /**
  20847. * Parse a JSON and creates the camera from the parsed information
  20848. * @param parsedCamera The JSON to parse
  20849. * @param scene The scene to instantiate the camera in
  20850. * @returns the newly constructed camera
  20851. */
  20852. Camera.Parse = function (parsedCamera, scene) {
  20853. var type = parsedCamera.type;
  20854. var construct = Camera.GetConstructorFromName(type, parsedCamera.name, scene, parsedCamera.interaxial_distance, parsedCamera.isStereoscopicSideBySide);
  20855. var camera = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(construct, parsedCamera, scene);
  20856. // Parent
  20857. if (parsedCamera.parentId) {
  20858. camera._waitingParentId = parsedCamera.parentId;
  20859. }
  20860. //If camera has an input manager, let it parse inputs settings
  20861. if (camera.inputs) {
  20862. camera.inputs.parse(parsedCamera);
  20863. camera._setupInputs();
  20864. }
  20865. if (camera.setPosition) { // need to force position
  20866. camera.position.copyFromFloats(0, 0, 0);
  20867. camera.setPosition(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.position));
  20868. }
  20869. // Target
  20870. if (parsedCamera.target) {
  20871. if (camera.setTarget) {
  20872. camera.setTarget(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedCamera.target));
  20873. }
  20874. }
  20875. // Apply 3d rig, when found
  20876. if (parsedCamera.cameraRigMode) {
  20877. var rigParams = (parsedCamera.interaxial_distance) ? { interaxialDistance: parsedCamera.interaxial_distance } : {};
  20878. camera.setCameraRigMode(parsedCamera.cameraRigMode, rigParams);
  20879. }
  20880. // Animations
  20881. if (parsedCamera.animations) {
  20882. for (var animationIndex = 0; animationIndex < parsedCamera.animations.length; animationIndex++) {
  20883. var parsedAnimation = parsedCamera.animations[animationIndex];
  20884. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass("BABYLON.Animation");
  20885. if (internalClass) {
  20886. camera.animations.push(internalClass.Parse(parsedAnimation));
  20887. }
  20888. }
  20889. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(camera, parsedCamera, scene);
  20890. }
  20891. if (parsedCamera.autoAnimate) {
  20892. scene.beginAnimation(camera, parsedCamera.autoAnimateFrom, parsedCamera.autoAnimateTo, parsedCamera.autoAnimateLoop, parsedCamera.autoAnimateSpeed || 1.0);
  20893. }
  20894. return camera;
  20895. };
  20896. /** @hidden */
  20897. Camera._createDefaultParsedCamera = function (name, scene) {
  20898. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_9__["_DevTools"].WarnImport("UniversalCamera");
  20899. };
  20900. /**
  20901. * This is the default projection mode used by the cameras.
  20902. * It helps recreating a feeling of perspective and better appreciate depth.
  20903. * This is the best way to simulate real life cameras.
  20904. */
  20905. Camera.PERSPECTIVE_CAMERA = 0;
  20906. /**
  20907. * This helps creating camera with an orthographic mode.
  20908. * Orthographic is commonly used in engineering as a means to produce object specifications that communicate dimensions unambiguously, each line of 1 unit length (cm, meter..whatever) will appear to have the same length everywhere on the drawing. This allows the drafter to dimension only a subset of lines and let the reader know that other lines of that length on the drawing are also that length in reality. Every parallel line in the drawing is also parallel in the object.
  20909. */
  20910. Camera.ORTHOGRAPHIC_CAMERA = 1;
  20911. /**
  20912. * This is the default FOV mode for perspective cameras.
  20913. * This setting aligns the upper and lower bounds of the viewport to the upper and lower bounds of the camera frustum.
  20914. */
  20915. Camera.FOVMODE_VERTICAL_FIXED = 0;
  20916. /**
  20917. * This setting aligns the left and right bounds of the viewport to the left and right bounds of the camera frustum.
  20918. */
  20919. Camera.FOVMODE_HORIZONTAL_FIXED = 1;
  20920. /**
  20921. * This specifies ther is no need for a camera rig.
  20922. * Basically only one eye is rendered corresponding to the camera.
  20923. */
  20924. Camera.RIG_MODE_NONE = 0;
  20925. /**
  20926. * Simulates a camera Rig with one blue eye and one red eye.
  20927. * This can be use with 3d blue and red glasses.
  20928. */
  20929. Camera.RIG_MODE_STEREOSCOPIC_ANAGLYPH = 10;
  20930. /**
  20931. * Defines that both eyes of the camera will be rendered side by side with a parallel target.
  20932. */
  20933. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL = 11;
  20934. /**
  20935. * Defines that both eyes of the camera will be rendered side by side with a none parallel target.
  20936. */
  20937. Camera.RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED = 12;
  20938. /**
  20939. * Defines that both eyes of the camera will be rendered over under each other.
  20940. */
  20941. Camera.RIG_MODE_STEREOSCOPIC_OVERUNDER = 13;
  20942. /**
  20943. * Defines that both eyes of the camera should be renderered in a VR mode (carbox).
  20944. */
  20945. Camera.RIG_MODE_VR = 20;
  20946. /**
  20947. * Defines that both eyes of the camera should be renderered in a VR mode (webVR).
  20948. */
  20949. Camera.RIG_MODE_WEBVR = 21;
  20950. /**
  20951. * Custom rig mode allowing rig cameras to be populated manually with any number of cameras
  20952. */
  20953. Camera.RIG_MODE_CUSTOM = 22;
  20954. /**
  20955. * Defines if by default attaching controls should prevent the default javascript event to continue.
  20956. */
  20957. Camera.ForceAttachControlToAlwaysPreventDefault = false;
  20958. /**
  20959. * @hidden
  20960. * Might be removed once multiview will be a thing
  20961. */
  20962. Camera.UseAlternateWebVRRendering = false;
  20963. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20964. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20965. ], Camera.prototype, "position", void 0);
  20966. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20967. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  20968. ], Camera.prototype, "upVector", void 0);
  20969. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20970. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20971. ], Camera.prototype, "orthoLeft", void 0);
  20972. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20973. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20974. ], Camera.prototype, "orthoRight", void 0);
  20975. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20976. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20977. ], Camera.prototype, "orthoBottom", void 0);
  20978. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20979. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20980. ], Camera.prototype, "orthoTop", void 0);
  20981. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20982. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20983. ], Camera.prototype, "fov", void 0);
  20984. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20985. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20986. ], Camera.prototype, "minZ", void 0);
  20987. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20988. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20989. ], Camera.prototype, "maxZ", void 0);
  20990. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20991. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20992. ], Camera.prototype, "inertia", void 0);
  20993. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20994. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20995. ], Camera.prototype, "mode", void 0);
  20996. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  20997. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  20998. ], Camera.prototype, "layerMask", void 0);
  20999. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21000. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21001. ], Camera.prototype, "fovMode", void 0);
  21002. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21003. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21004. ], Camera.prototype, "cameraRigMode", void 0);
  21005. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21006. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21007. ], Camera.prototype, "interaxialDistance", void 0);
  21008. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21009. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21010. ], Camera.prototype, "isStereoscopicSideBySide", void 0);
  21011. return Camera;
  21012. }(_node__WEBPACK_IMPORTED_MODULE_6__["Node"]));
  21013. /***/ }),
  21014. /***/ "./Cameras/cameraInputsManager.ts":
  21015. /*!****************************************!*\
  21016. !*** ./Cameras/cameraInputsManager.ts ***!
  21017. \****************************************/
  21018. /*! exports provided: CameraInputTypes, CameraInputsManager */
  21019. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21020. "use strict";
  21021. __webpack_require__.r(__webpack_exports__);
  21022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return CameraInputTypes; });
  21023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return CameraInputsManager; });
  21024. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  21025. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21026. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  21027. /**
  21028. * @ignore
  21029. * This is a list of all the different input types that are available in the application.
  21030. * Fo instance: ArcRotateCameraGamepadInput...
  21031. */
  21032. var CameraInputTypes = {};
  21033. /**
  21034. * This represents the input manager used within a camera.
  21035. * It helps dealing with all the different kind of input attached to a camera.
  21036. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21037. */
  21038. var CameraInputsManager = /** @class */ (function () {
  21039. /**
  21040. * Instantiate a new Camera Input Manager.
  21041. * @param camera Defines the camera the input manager blongs to
  21042. */
  21043. function CameraInputsManager(camera) {
  21044. this.attached = {};
  21045. this.camera = camera;
  21046. this.checkInputs = function () { };
  21047. }
  21048. /**
  21049. * Add an input method to a camera
  21050. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21051. * @param input camera input method
  21052. */
  21053. CameraInputsManager.prototype.add = function (input) {
  21054. var type = input.getSimpleName();
  21055. if (this.attached[type]) {
  21056. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("camera input of type " + type + " already exists on camera");
  21057. return;
  21058. }
  21059. this.attached[type] = input;
  21060. input.camera = this.camera;
  21061. //for checkInputs, we are dynamically creating a function
  21062. //the goal is to avoid the performance penalty of looping for inputs in the render loop
  21063. if (input.checkInputs) {
  21064. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21065. }
  21066. if (this.attachedElement) {
  21067. input.attachControl(this.attachedElement);
  21068. }
  21069. };
  21070. /**
  21071. * Remove a specific input method from a camera
  21072. * example: camera.inputs.remove(camera.inputs.attached.mouse);
  21073. * @param inputToRemove camera input method
  21074. */
  21075. CameraInputsManager.prototype.remove = function (inputToRemove) {
  21076. for (var cam in this.attached) {
  21077. var input = this.attached[cam];
  21078. if (input === inputToRemove) {
  21079. input.detachControl(this.attachedElement);
  21080. input.camera = null;
  21081. delete this.attached[cam];
  21082. this.rebuildInputCheck();
  21083. }
  21084. }
  21085. };
  21086. /**
  21087. * Remove a specific input type from a camera
  21088. * example: camera.inputs.remove("ArcRotateCameraGamepadInput");
  21089. * @param inputType the type of the input to remove
  21090. */
  21091. CameraInputsManager.prototype.removeByType = function (inputType) {
  21092. for (var cam in this.attached) {
  21093. var input = this.attached[cam];
  21094. if (input.getClassName() === inputType) {
  21095. input.detachControl(this.attachedElement);
  21096. input.camera = null;
  21097. delete this.attached[cam];
  21098. this.rebuildInputCheck();
  21099. }
  21100. }
  21101. };
  21102. CameraInputsManager.prototype._addCheckInputs = function (fn) {
  21103. var current = this.checkInputs;
  21104. return function () {
  21105. current();
  21106. fn();
  21107. };
  21108. };
  21109. /**
  21110. * Attach the input controls to the currently attached dom element to listen the events from.
  21111. * @param input Defines the input to attach
  21112. */
  21113. CameraInputsManager.prototype.attachInput = function (input) {
  21114. if (this.attachedElement) {
  21115. input.attachControl(this.attachedElement, this.noPreventDefault);
  21116. }
  21117. };
  21118. /**
  21119. * Attach the current manager inputs controls to a specific dom element to listen the events from.
  21120. * @param element Defines the dom element to collect the events from
  21121. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21122. */
  21123. CameraInputsManager.prototype.attachElement = function (element, noPreventDefault) {
  21124. if (noPreventDefault === void 0) { noPreventDefault = false; }
  21125. if (this.attachedElement) {
  21126. return;
  21127. }
  21128. noPreventDefault = _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].ForceAttachControlToAlwaysPreventDefault ? false : noPreventDefault;
  21129. this.attachedElement = element;
  21130. this.noPreventDefault = noPreventDefault;
  21131. for (var cam in this.attached) {
  21132. this.attached[cam].attachControl(element, noPreventDefault);
  21133. }
  21134. };
  21135. /**
  21136. * Detach the current manager inputs controls from a specific dom element.
  21137. * @param element Defines the dom element to collect the events from
  21138. * @param disconnect Defines whether the input should be removed from the current list of attached inputs
  21139. */
  21140. CameraInputsManager.prototype.detachElement = function (element, disconnect) {
  21141. if (disconnect === void 0) { disconnect = false; }
  21142. if (this.attachedElement !== element) {
  21143. return;
  21144. }
  21145. for (var cam in this.attached) {
  21146. this.attached[cam].detachControl(element);
  21147. if (disconnect) {
  21148. this.attached[cam].camera = null;
  21149. }
  21150. }
  21151. this.attachedElement = null;
  21152. };
  21153. /**
  21154. * Rebuild the dynamic inputCheck function from the current list of
  21155. * defined inputs in the manager.
  21156. */
  21157. CameraInputsManager.prototype.rebuildInputCheck = function () {
  21158. this.checkInputs = function () { };
  21159. for (var cam in this.attached) {
  21160. var input = this.attached[cam];
  21161. if (input.checkInputs) {
  21162. this.checkInputs = this._addCheckInputs(input.checkInputs.bind(input));
  21163. }
  21164. }
  21165. };
  21166. /**
  21167. * Remove all attached input methods from a camera
  21168. */
  21169. CameraInputsManager.prototype.clear = function () {
  21170. if (this.attachedElement) {
  21171. this.detachElement(this.attachedElement, true);
  21172. }
  21173. this.attached = {};
  21174. this.attachedElement = null;
  21175. this.checkInputs = function () { };
  21176. };
  21177. /**
  21178. * Serialize the current input manager attached to a camera.
  21179. * This ensures than once parsed,
  21180. * the input associated to the camera will be identical to the current ones
  21181. * @param serializedCamera Defines the camera serialization JSON the input serialization should write to
  21182. */
  21183. CameraInputsManager.prototype.serialize = function (serializedCamera) {
  21184. var inputs = {};
  21185. for (var cam in this.attached) {
  21186. var input = this.attached[cam];
  21187. var res = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(input);
  21188. inputs[input.getClassName()] = res;
  21189. }
  21190. serializedCamera.inputsmgr = inputs;
  21191. };
  21192. /**
  21193. * Parses an input manager serialized JSON to restore the previous list of inputs
  21194. * and states associated to a camera.
  21195. * @param parsedCamera Defines the JSON to parse
  21196. */
  21197. CameraInputsManager.prototype.parse = function (parsedCamera) {
  21198. var parsedInputs = parsedCamera.inputsmgr;
  21199. if (parsedInputs) {
  21200. this.clear();
  21201. for (var n in parsedInputs) {
  21202. var construct = CameraInputTypes[n];
  21203. if (construct) {
  21204. var parsedinput = parsedInputs[n];
  21205. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedinput, null);
  21206. this.add(input);
  21207. }
  21208. }
  21209. }
  21210. else {
  21211. //2016-03-08 this part is for managing backward compatibility
  21212. for (var n in this.attached) {
  21213. var construct = CameraInputTypes[this.attached[n].getClassName()];
  21214. if (construct) {
  21215. var input = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new construct(); }, parsedCamera, null);
  21216. this.remove(this.attached[n]);
  21217. this.add(input);
  21218. }
  21219. }
  21220. }
  21221. };
  21222. return CameraInputsManager;
  21223. }());
  21224. /***/ }),
  21225. /***/ "./Cameras/deviceOrientationCamera.ts":
  21226. /*!********************************************!*\
  21227. !*** ./Cameras/deviceOrientationCamera.ts ***!
  21228. \********************************************/
  21229. /*! exports provided: DeviceOrientationCamera */
  21230. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21231. "use strict";
  21232. __webpack_require__.r(__webpack_exports__);
  21233. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return DeviceOrientationCamera; });
  21234. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21235. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  21236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21237. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  21238. /* harmony import */ var _Inputs_freeCameraDeviceOrientationInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraDeviceOrientationInput */ "./Cameras/Inputs/freeCameraDeviceOrientationInput.ts");
  21239. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("DeviceOrientationCamera", function (name, scene) {
  21240. return function () { return new DeviceOrientationCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  21241. });
  21242. // We're mainly based on the logic defined into the FreeCamera code
  21243. /**
  21244. * This is a camera specifically designed to react to device orientation events such as a modern mobile device
  21245. * being tilted forward or back and left or right.
  21246. */
  21247. var DeviceOrientationCamera = /** @class */ (function (_super) {
  21248. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DeviceOrientationCamera, _super);
  21249. /**
  21250. * Creates a new device orientation camera
  21251. * @param name The name of the camera
  21252. * @param position The start position camera
  21253. * @param scene The scene the camera belongs to
  21254. */
  21255. function DeviceOrientationCamera(name, position, scene) {
  21256. var _this = _super.call(this, name, position, scene) || this;
  21257. _this._quaternionCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21258. _this.inputs.addDeviceOrientation();
  21259. return _this;
  21260. }
  21261. /**
  21262. * Gets the current instance class name ("DeviceOrientationCamera").
  21263. * This helps avoiding instanceof at run time.
  21264. * @returns the class name
  21265. */
  21266. DeviceOrientationCamera.prototype.getClassName = function () {
  21267. return "DeviceOrientationCamera";
  21268. };
  21269. /**
  21270. * @hidden
  21271. * Checks and applies the current values of the inputs to the camera. (Internal use only)
  21272. */
  21273. DeviceOrientationCamera.prototype._checkInputs = function () {
  21274. _super.prototype._checkInputs.call(this);
  21275. this._quaternionCache.copyFrom(this.rotationQuaternion);
  21276. if (this._initialQuaternion) {
  21277. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21278. }
  21279. };
  21280. /**
  21281. * Reset the camera to its default orientation on the specified axis only.
  21282. * @param axis The axis to reset
  21283. */
  21284. DeviceOrientationCamera.prototype.resetToCurrentRotation = function (axis) {
  21285. var _this = this;
  21286. if (axis === void 0) { axis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y; }
  21287. //can only work if this camera has a rotation quaternion already.
  21288. if (!this.rotationQuaternion) {
  21289. return;
  21290. }
  21291. if (!this._initialQuaternion) {
  21292. this._initialQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  21293. }
  21294. this._initialQuaternion.copyFrom(this._quaternionCache || this.rotationQuaternion);
  21295. ['x', 'y', 'z'].forEach(function (axisName) {
  21296. if (!axis[axisName]) {
  21297. _this._initialQuaternion[axisName] = 0;
  21298. }
  21299. else {
  21300. _this._initialQuaternion[axisName] *= -1;
  21301. }
  21302. });
  21303. this._initialQuaternion.normalize();
  21304. //force rotation update
  21305. this._initialQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  21306. };
  21307. return DeviceOrientationCamera;
  21308. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  21309. /***/ }),
  21310. /***/ "./Cameras/flyCamera.ts":
  21311. /*!******************************!*\
  21312. !*** ./Cameras/flyCamera.ts ***!
  21313. \******************************/
  21314. /*! exports provided: FlyCamera */
  21315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21316. "use strict";
  21317. __webpack_require__.r(__webpack_exports__);
  21318. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return FlyCamera; });
  21319. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21320. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21321. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21322. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  21323. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21324. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  21325. /**
  21326. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21327. * such as in a 3D Space Shooter or a Flight Simulator.
  21328. */
  21329. var FlyCamera = /** @class */ (function (_super) {
  21330. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCamera, _super);
  21331. /**
  21332. * Instantiates a FlyCamera.
  21333. * This is a flying camera, designed for 3D movement and rotation in all directions,
  21334. * such as in a 3D Space Shooter or a Flight Simulator.
  21335. * @param name Define the name of the camera in the scene.
  21336. * @param position Define the starting position of the camera in the scene.
  21337. * @param scene Define the scene the camera belongs to.
  21338. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active, if no other camera has been defined as active.
  21339. */
  21340. function FlyCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  21341. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  21342. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  21343. /**
  21344. * Define the collision ellipsoid of the camera.
  21345. * This is helpful for simulating a camera body, like a player's body.
  21346. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  21347. */
  21348. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  21349. /**
  21350. * Define an offset for the position of the ellipsoid around the camera.
  21351. * This can be helpful if the camera is attached away from the player's body center,
  21352. * such as at its head.
  21353. */
  21354. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21355. /**
  21356. * Enable or disable collisions of the camera with the rest of the scene objects.
  21357. */
  21358. _this.checkCollisions = false;
  21359. /**
  21360. * Enable or disable gravity on the camera.
  21361. */
  21362. _this.applyGravity = false;
  21363. /**
  21364. * Define the current direction the camera is moving to.
  21365. */
  21366. _this.cameraDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21367. /**
  21368. * Track Roll to maintain the wanted Rolling when looking around.
  21369. */
  21370. _this._trackRoll = 0;
  21371. /**
  21372. * Slowly correct the Roll to its original value after a Pitch+Yaw rotation.
  21373. */
  21374. _this.rollCorrect = 100;
  21375. /**
  21376. * Mimic a banked turn, Rolling the camera when Yawing.
  21377. * It's recommended to use rollCorrect = 10 for faster banking correction.
  21378. */
  21379. _this.bankedTurn = false;
  21380. /**
  21381. * Limit in radians for how much Roll banking will add. (Default: 90°)
  21382. */
  21383. _this.bankedTurnLimit = Math.PI / 2;
  21384. /**
  21385. * Value of 0 disables the banked Roll.
  21386. * Value of 1 is equal to the Yaw angle in radians.
  21387. */
  21388. _this.bankedTurnMultiplier = 1;
  21389. _this._needMoveForGravity = false;
  21390. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21391. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21392. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21393. // Collisions.
  21394. _this._collisionMask = -1;
  21395. /** @hidden */
  21396. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  21397. if (collidedMesh === void 0) { collidedMesh = null; }
  21398. var updatePosition = function (newPos) {
  21399. _this._newPosition.copyFrom(newPos);
  21400. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  21401. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  21402. _this.position.addInPlace(_this._diffPosition);
  21403. if (_this.onCollide && collidedMesh) {
  21404. _this.onCollide(collidedMesh);
  21405. }
  21406. }
  21407. };
  21408. updatePosition(newPosition);
  21409. };
  21410. _this.inputs = new _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FlyCameraInputsManager"](_this);
  21411. _this.inputs.addKeyboard().addMouse();
  21412. return _this;
  21413. }
  21414. Object.defineProperty(FlyCamera.prototype, "angularSensibility", {
  21415. /**
  21416. * Gets the input sensibility for mouse input.
  21417. * Higher values reduce sensitivity.
  21418. */
  21419. get: function () {
  21420. var mouse = this.inputs.attached["mouse"];
  21421. if (mouse) {
  21422. return mouse.angularSensibility;
  21423. }
  21424. return 0;
  21425. },
  21426. /**
  21427. * Sets the input sensibility for a mouse input.
  21428. * Higher values reduce sensitivity.
  21429. */
  21430. set: function (value) {
  21431. var mouse = this.inputs.attached["mouse"];
  21432. if (mouse) {
  21433. mouse.angularSensibility = value;
  21434. }
  21435. },
  21436. enumerable: true,
  21437. configurable: true
  21438. });
  21439. Object.defineProperty(FlyCamera.prototype, "keysForward", {
  21440. /**
  21441. * Get the keys for camera movement forward.
  21442. */
  21443. get: function () {
  21444. var keyboard = this.inputs.attached["keyboard"];
  21445. if (keyboard) {
  21446. return keyboard.keysForward;
  21447. }
  21448. return [];
  21449. },
  21450. /**
  21451. * Set the keys for camera movement forward.
  21452. */
  21453. set: function (value) {
  21454. var keyboard = this.inputs.attached["keyboard"];
  21455. if (keyboard) {
  21456. keyboard.keysForward = value;
  21457. }
  21458. },
  21459. enumerable: true,
  21460. configurable: true
  21461. });
  21462. Object.defineProperty(FlyCamera.prototype, "keysBackward", {
  21463. /**
  21464. * Get the keys for camera movement backward.
  21465. */
  21466. get: function () {
  21467. var keyboard = this.inputs.attached["keyboard"];
  21468. if (keyboard) {
  21469. return keyboard.keysBackward;
  21470. }
  21471. return [];
  21472. },
  21473. set: function (value) {
  21474. var keyboard = this.inputs.attached["keyboard"];
  21475. if (keyboard) {
  21476. keyboard.keysBackward = value;
  21477. }
  21478. },
  21479. enumerable: true,
  21480. configurable: true
  21481. });
  21482. Object.defineProperty(FlyCamera.prototype, "keysUp", {
  21483. /**
  21484. * Get the keys for camera movement up.
  21485. */
  21486. get: function () {
  21487. var keyboard = this.inputs.attached["keyboard"];
  21488. if (keyboard) {
  21489. return keyboard.keysUp;
  21490. }
  21491. return [];
  21492. },
  21493. /**
  21494. * Set the keys for camera movement up.
  21495. */
  21496. set: function (value) {
  21497. var keyboard = this.inputs.attached["keyboard"];
  21498. if (keyboard) {
  21499. keyboard.keysUp = value;
  21500. }
  21501. },
  21502. enumerable: true,
  21503. configurable: true
  21504. });
  21505. Object.defineProperty(FlyCamera.prototype, "keysDown", {
  21506. /**
  21507. * Get the keys for camera movement down.
  21508. */
  21509. get: function () {
  21510. var keyboard = this.inputs.attached["keyboard"];
  21511. if (keyboard) {
  21512. return keyboard.keysDown;
  21513. }
  21514. return [];
  21515. },
  21516. /**
  21517. * Set the keys for camera movement down.
  21518. */
  21519. set: function (value) {
  21520. var keyboard = this.inputs.attached["keyboard"];
  21521. if (keyboard) {
  21522. keyboard.keysDown = value;
  21523. }
  21524. },
  21525. enumerable: true,
  21526. configurable: true
  21527. });
  21528. Object.defineProperty(FlyCamera.prototype, "keysLeft", {
  21529. /**
  21530. * Get the keys for camera movement left.
  21531. */
  21532. get: function () {
  21533. var keyboard = this.inputs.attached["keyboard"];
  21534. if (keyboard) {
  21535. return keyboard.keysLeft;
  21536. }
  21537. return [];
  21538. },
  21539. /**
  21540. * Set the keys for camera movement left.
  21541. */
  21542. set: function (value) {
  21543. var keyboard = this.inputs.attached["keyboard"];
  21544. if (keyboard) {
  21545. keyboard.keysLeft = value;
  21546. }
  21547. },
  21548. enumerable: true,
  21549. configurable: true
  21550. });
  21551. Object.defineProperty(FlyCamera.prototype, "keysRight", {
  21552. /**
  21553. * Set the keys for camera movement right.
  21554. */
  21555. get: function () {
  21556. var keyboard = this.inputs.attached["keyboard"];
  21557. if (keyboard) {
  21558. return keyboard.keysRight;
  21559. }
  21560. return [];
  21561. },
  21562. /**
  21563. * Set the keys for camera movement right.
  21564. */
  21565. set: function (value) {
  21566. var keyboard = this.inputs.attached["keyboard"];
  21567. if (keyboard) {
  21568. keyboard.keysRight = value;
  21569. }
  21570. },
  21571. enumerable: true,
  21572. configurable: true
  21573. });
  21574. /**
  21575. * Attach a control to the HTML DOM element.
  21576. * @param element Defines the element that listens to the input events.
  21577. * @param noPreventDefault Defines whether events caught by the controls should call preventdefault(). https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault
  21578. */
  21579. FlyCamera.prototype.attachControl = function (element, noPreventDefault) {
  21580. this.inputs.attachElement(element, noPreventDefault);
  21581. };
  21582. /**
  21583. * Detach a control from the HTML DOM element.
  21584. * The camera will stop reacting to that input.
  21585. * @param element Defines the element that listens to the input events.
  21586. */
  21587. FlyCamera.prototype.detachControl = function (element) {
  21588. this.inputs.detachElement(element);
  21589. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  21590. };
  21591. Object.defineProperty(FlyCamera.prototype, "collisionMask", {
  21592. /**
  21593. * Get the mask that the camera ignores in collision events.
  21594. */
  21595. get: function () {
  21596. return this._collisionMask;
  21597. },
  21598. /**
  21599. * Set the mask that the camera ignores in collision events.
  21600. */
  21601. set: function (mask) {
  21602. this._collisionMask = !isNaN(mask) ? mask : -1;
  21603. },
  21604. enumerable: true,
  21605. configurable: true
  21606. });
  21607. /** @hidden */
  21608. FlyCamera.prototype._collideWithWorld = function (displacement) {
  21609. var globalPosition;
  21610. if (this.parent) {
  21611. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  21612. }
  21613. else {
  21614. globalPosition = this.position;
  21615. }
  21616. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  21617. this._oldPosition.addInPlace(this.ellipsoidOffset);
  21618. var coordinator = this.getScene().collisionCoordinator;
  21619. if (!this._collider) {
  21620. this._collider = coordinator.createCollider();
  21621. }
  21622. this._collider._radius = this.ellipsoid;
  21623. this._collider.collisionMask = this._collisionMask;
  21624. // No need for clone, as long as gravity is not on.
  21625. var actualDisplacement = displacement;
  21626. // Add gravity to direction to prevent dual-collision checking.
  21627. if (this.applyGravity) {
  21628. // This prevents mending with cameraDirection, a global variable of the fly camera class.
  21629. actualDisplacement = displacement.add(this.getScene().gravity);
  21630. }
  21631. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  21632. };
  21633. /** @hidden */
  21634. FlyCamera.prototype._checkInputs = function () {
  21635. if (!this._localDirection) {
  21636. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21637. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  21638. }
  21639. this.inputs.checkInputs();
  21640. _super.prototype._checkInputs.call(this);
  21641. };
  21642. /** @hidden */
  21643. FlyCamera.prototype._decideIfNeedsToMove = function () {
  21644. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  21645. };
  21646. /** @hidden */
  21647. FlyCamera.prototype._updatePosition = function () {
  21648. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  21649. this._collideWithWorld(this.cameraDirection);
  21650. }
  21651. else {
  21652. _super.prototype._updatePosition.call(this);
  21653. }
  21654. };
  21655. /**
  21656. * Restore the Roll to its target value at the rate specified.
  21657. * @param rate - Higher means slower restoring.
  21658. * @hidden
  21659. */
  21660. FlyCamera.prototype.restoreRoll = function (rate) {
  21661. var limit = this._trackRoll; // Target Roll.
  21662. var z = this.rotation.z; // Current Roll.
  21663. var delta = limit - z; // Difference in Roll.
  21664. var minRad = 0.001; // Tenth of a radian is a barely noticable difference.
  21665. // If the difference is noticable, restore the Roll.
  21666. if (Math.abs(delta) >= minRad) {
  21667. // Change Z rotation towards the target Roll.
  21668. this.rotation.z += delta / rate;
  21669. // Match when near enough.
  21670. if (Math.abs(limit - this.rotation.z) <= minRad) {
  21671. this.rotation.z = limit;
  21672. }
  21673. }
  21674. };
  21675. /**
  21676. * Destroy the camera and release the current resources held by it.
  21677. */
  21678. FlyCamera.prototype.dispose = function () {
  21679. this.inputs.clear();
  21680. _super.prototype.dispose.call(this);
  21681. };
  21682. /**
  21683. * Get the current object class name.
  21684. * @returns the class name.
  21685. */
  21686. FlyCamera.prototype.getClassName = function () {
  21687. return "FlyCamera";
  21688. };
  21689. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21690. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21691. ], FlyCamera.prototype, "ellipsoid", void 0);
  21692. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21693. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  21694. ], FlyCamera.prototype, "ellipsoidOffset", void 0);
  21695. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21696. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21697. ], FlyCamera.prototype, "checkCollisions", void 0);
  21698. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21699. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21700. ], FlyCamera.prototype, "applyGravity", void 0);
  21701. return FlyCamera;
  21702. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  21703. /***/ }),
  21704. /***/ "./Cameras/flyCameraInputsManager.ts":
  21705. /*!*******************************************!*\
  21706. !*** ./Cameras/flyCameraInputsManager.ts ***!
  21707. \*******************************************/
  21708. /*! exports provided: FlyCameraInputsManager */
  21709. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21710. "use strict";
  21711. __webpack_require__.r(__webpack_exports__);
  21712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return FlyCameraInputsManager; });
  21713. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21714. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  21715. /* harmony import */ var _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraMouseInput */ "./Cameras/Inputs/flyCameraMouseInput.ts");
  21716. /* harmony import */ var _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/flyCameraKeyboardInput */ "./Cameras/Inputs/flyCameraKeyboardInput.ts");
  21717. /**
  21718. * Default Inputs manager for the FlyCamera.
  21719. * It groups all the default supported inputs for ease of use.
  21720. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  21721. */
  21722. var FlyCameraInputsManager = /** @class */ (function (_super) {
  21723. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FlyCameraInputsManager, _super);
  21724. /**
  21725. * Instantiates a new FlyCameraInputsManager.
  21726. * @param camera Defines the camera the inputs belong to.
  21727. */
  21728. function FlyCameraInputsManager(camera) {
  21729. return _super.call(this, camera) || this;
  21730. }
  21731. /**
  21732. * Add keyboard input support to the input manager.
  21733. * @returns the new FlyCameraKeyboardMoveInput().
  21734. */
  21735. FlyCameraInputsManager.prototype.addKeyboard = function () {
  21736. this.add(new _Cameras_Inputs_flyCameraKeyboardInput__WEBPACK_IMPORTED_MODULE_3__["FlyCameraKeyboardInput"]());
  21737. return this;
  21738. };
  21739. /**
  21740. * Add mouse input support to the input manager.
  21741. * @param touchEnabled Enable touch screen support.
  21742. * @returns the new FlyCameraMouseInput().
  21743. */
  21744. FlyCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  21745. if (touchEnabled === void 0) { touchEnabled = true; }
  21746. this.add(new _Cameras_Inputs_flyCameraMouseInput__WEBPACK_IMPORTED_MODULE_2__["FlyCameraMouseInput"](touchEnabled));
  21747. return this;
  21748. };
  21749. return FlyCameraInputsManager;
  21750. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  21751. /***/ }),
  21752. /***/ "./Cameras/followCamera.ts":
  21753. /*!*********************************!*\
  21754. !*** ./Cameras/followCamera.ts ***!
  21755. \*********************************/
  21756. /*! exports provided: FollowCamera, ArcFollowCamera */
  21757. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  21758. "use strict";
  21759. __webpack_require__.r(__webpack_exports__);
  21760. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return FollowCamera; });
  21761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return ArcFollowCamera; });
  21762. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  21763. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  21764. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  21765. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  21766. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  21767. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../node */ "./node.ts");
  21768. /* harmony import */ var _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./followCameraInputsManager */ "./Cameras/followCameraInputsManager.ts");
  21769. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("FollowCamera", function (name, scene) {
  21770. return function () { return new FollowCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene); };
  21771. });
  21772. _node__WEBPACK_IMPORTED_MODULE_5__["Node"].AddNodeConstructor("ArcFollowCamera", function (name, scene) {
  21773. return function () { return new ArcFollowCamera(name, 0, 0, 1.0, null, scene); };
  21774. });
  21775. /**
  21776. * A follow camera takes a mesh as a target and follows it as it moves. Both a free camera version followCamera and
  21777. * an arc rotate version arcFollowCamera are available.
  21778. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21779. */
  21780. var FollowCamera = /** @class */ (function (_super) {
  21781. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCamera, _super);
  21782. /**
  21783. * Instantiates the follow camera.
  21784. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21785. * @param name Define the name of the camera in the scene
  21786. * @param position Define the position of the camera
  21787. * @param scene Define the scene the camera belong to
  21788. * @param lockedTarget Define the target of the camera
  21789. */
  21790. function FollowCamera(name, position, scene, lockedTarget) {
  21791. if (lockedTarget === void 0) { lockedTarget = null; }
  21792. var _this = _super.call(this, name, position, scene) || this;
  21793. /**
  21794. * Distance the follow camera should follow an object at
  21795. */
  21796. _this.radius = 12;
  21797. /**
  21798. * Minimum allowed distance of the camera to the axis of rotation
  21799. * (The camera can not get closer).
  21800. * This can help limiting how the Camera is able to move in the scene.
  21801. */
  21802. _this.lowerRadiusLimit = null;
  21803. /**
  21804. * Maximum allowed distance of the camera to the axis of rotation
  21805. * (The camera can not get further).
  21806. * This can help limiting how the Camera is able to move in the scene.
  21807. */
  21808. _this.upperRadiusLimit = null;
  21809. /**
  21810. * Define a rotation offset between the camera and the object it follows
  21811. */
  21812. _this.rotationOffset = 0;
  21813. /**
  21814. * Minimum allowed angle to camera position relative to target object.
  21815. * This can help limiting how the Camera is able to move in the scene.
  21816. */
  21817. _this.lowerRotationOffsetLimit = null;
  21818. /**
  21819. * Maximum allowed angle to camera position relative to target object.
  21820. * This can help limiting how the Camera is able to move in the scene.
  21821. */
  21822. _this.upperRotationOffsetLimit = null;
  21823. /**
  21824. * Define a height offset between the camera and the object it follows.
  21825. * It can help following an object from the top (like a car chaing a plane)
  21826. */
  21827. _this.heightOffset = 4;
  21828. /**
  21829. * Minimum allowed height of camera position relative to target object.
  21830. * This can help limiting how the Camera is able to move in the scene.
  21831. */
  21832. _this.lowerHeightOffsetLimit = null;
  21833. /**
  21834. * Maximum allowed height of camera position relative to target object.
  21835. * This can help limiting how the Camera is able to move in the scene.
  21836. */
  21837. _this.upperHeightOffsetLimit = null;
  21838. /**
  21839. * Define how fast the camera can accelerate to follow it s target.
  21840. */
  21841. _this.cameraAcceleration = 0.05;
  21842. /**
  21843. * Define the speed limit of the camera following an object.
  21844. */
  21845. _this.maxCameraSpeed = 20;
  21846. _this.lockedTarget = lockedTarget;
  21847. _this.inputs = new _followCameraInputsManager__WEBPACK_IMPORTED_MODULE_6__["FollowCameraInputsManager"](_this);
  21848. _this.inputs.addKeyboard().addMouseWheel();
  21849. return _this;
  21850. // Uncomment the following line when the relevant handlers have been implemented.
  21851. // this.inputs.addKeyboard().addMouseWheel().addPointers().addVRDeviceOrientation();
  21852. }
  21853. FollowCamera.prototype._follow = function (cameraTarget) {
  21854. if (!cameraTarget) {
  21855. return;
  21856. }
  21857. var yRotation;
  21858. if (cameraTarget.rotationQuaternion) {
  21859. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  21860. cameraTarget.rotationQuaternion.toRotationMatrix(rotMatrix);
  21861. yRotation = Math.atan2(rotMatrix.m[8], rotMatrix.m[10]);
  21862. }
  21863. else {
  21864. yRotation = cameraTarget.rotation.y;
  21865. }
  21866. var radians = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].ToRadians(this.rotationOffset) + yRotation;
  21867. var targetPosition = cameraTarget.getAbsolutePosition();
  21868. var targetX = targetPosition.x + Math.sin(radians) * this.radius;
  21869. var targetZ = targetPosition.z + Math.cos(radians) * this.radius;
  21870. var dx = targetX - this.position.x;
  21871. var dy = (targetPosition.y + this.heightOffset) - this.position.y;
  21872. var dz = (targetZ) - this.position.z;
  21873. var vx = dx * this.cameraAcceleration * 2; //this is set to .05
  21874. var vy = dy * this.cameraAcceleration;
  21875. var vz = dz * this.cameraAcceleration * 2;
  21876. if (vx > this.maxCameraSpeed || vx < -this.maxCameraSpeed) {
  21877. vx = vx < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21878. }
  21879. if (vy > this.maxCameraSpeed || vy < -this.maxCameraSpeed) {
  21880. vy = vy < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21881. }
  21882. if (vz > this.maxCameraSpeed || vz < -this.maxCameraSpeed) {
  21883. vz = vz < 1 ? -this.maxCameraSpeed : this.maxCameraSpeed;
  21884. }
  21885. this.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](this.position.x + vx, this.position.y + vy, this.position.z + vz);
  21886. this.setTarget(targetPosition);
  21887. };
  21888. /**
  21889. * Attached controls to the current camera.
  21890. * @param element Defines the element the controls should be listened from
  21891. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  21892. */
  21893. FollowCamera.prototype.attachControl = function (element, noPreventDefault) {
  21894. this.inputs.attachElement(element, noPreventDefault);
  21895. this._reset = function () {
  21896. };
  21897. };
  21898. /**
  21899. * Detach the current controls from the camera.
  21900. * The camera will stop reacting to inputs.
  21901. * @param element Defines the element to stop listening the inputs from
  21902. */
  21903. FollowCamera.prototype.detachControl = function (element) {
  21904. this.inputs.detachElement(element);
  21905. if (this._reset) {
  21906. this._reset();
  21907. }
  21908. };
  21909. /** @hidden */
  21910. FollowCamera.prototype._checkInputs = function () {
  21911. this.inputs.checkInputs();
  21912. this._checkLimits();
  21913. _super.prototype._checkInputs.call(this);
  21914. if (this.lockedTarget) {
  21915. this._follow(this.lockedTarget);
  21916. }
  21917. };
  21918. FollowCamera.prototype._checkLimits = function () {
  21919. if (this.lowerRadiusLimit !== null && this.radius < this.lowerRadiusLimit) {
  21920. this.radius = this.lowerRadiusLimit;
  21921. }
  21922. if (this.upperRadiusLimit !== null && this.radius > this.upperRadiusLimit) {
  21923. this.radius = this.upperRadiusLimit;
  21924. }
  21925. if (this.lowerHeightOffsetLimit !== null &&
  21926. this.heightOffset < this.lowerHeightOffsetLimit) {
  21927. this.heightOffset = this.lowerHeightOffsetLimit;
  21928. }
  21929. if (this.upperHeightOffsetLimit !== null &&
  21930. this.heightOffset > this.upperHeightOffsetLimit) {
  21931. this.heightOffset = this.upperHeightOffsetLimit;
  21932. }
  21933. if (this.lowerRotationOffsetLimit !== null &&
  21934. this.rotationOffset < this.lowerRotationOffsetLimit) {
  21935. this.rotationOffset = this.lowerRotationOffsetLimit;
  21936. }
  21937. if (this.upperRotationOffsetLimit !== null &&
  21938. this.rotationOffset > this.upperRotationOffsetLimit) {
  21939. this.rotationOffset = this.upperRotationOffsetLimit;
  21940. }
  21941. };
  21942. /**
  21943. * Gets the camera class name.
  21944. * @returns the class name
  21945. */
  21946. FollowCamera.prototype.getClassName = function () {
  21947. return "FollowCamera";
  21948. };
  21949. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21950. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21951. ], FollowCamera.prototype, "radius", void 0);
  21952. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21953. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21954. ], FollowCamera.prototype, "lowerRadiusLimit", void 0);
  21955. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21956. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21957. ], FollowCamera.prototype, "upperRadiusLimit", void 0);
  21958. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21959. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21960. ], FollowCamera.prototype, "rotationOffset", void 0);
  21961. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21962. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21963. ], FollowCamera.prototype, "lowerRotationOffsetLimit", void 0);
  21964. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21965. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21966. ], FollowCamera.prototype, "upperRotationOffsetLimit", void 0);
  21967. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21968. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21969. ], FollowCamera.prototype, "heightOffset", void 0);
  21970. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21971. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21972. ], FollowCamera.prototype, "lowerHeightOffsetLimit", void 0);
  21973. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21974. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21975. ], FollowCamera.prototype, "upperHeightOffsetLimit", void 0);
  21976. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21977. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21978. ], FollowCamera.prototype, "cameraAcceleration", void 0);
  21979. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21980. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  21981. ], FollowCamera.prototype, "maxCameraSpeed", void 0);
  21982. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  21983. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  21984. ], FollowCamera.prototype, "lockedTarget", void 0);
  21985. return FollowCamera;
  21986. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  21987. /**
  21988. * Arc Rotate version of the follow camera.
  21989. * It still follows a Defined mesh but in an Arc Rotate Camera fashion.
  21990. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21991. */
  21992. var ArcFollowCamera = /** @class */ (function (_super) {
  21993. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ArcFollowCamera, _super);
  21994. /**
  21995. * Instantiates a new ArcFollowCamera
  21996. * @see http://doc.babylonjs.com/features/cameras#follow-camera
  21997. * @param name Define the name of the camera
  21998. * @param alpha Define the rotation angle of the camera around the logitudinal axis
  21999. * @param beta Define the rotation angle of the camera around the elevation axis
  22000. * @param radius Define the radius of the camera from its target point
  22001. * @param target Define the target of the camera
  22002. * @param scene Define the scene the camera belongs to
  22003. */
  22004. function ArcFollowCamera(name,
  22005. /** The longitudinal angle of the camera */
  22006. alpha,
  22007. /** The latitudinal angle of the camera */
  22008. beta,
  22009. /** The radius of the camera from its target */
  22010. radius,
  22011. /** Define the camera target (the messh it should follow) */
  22012. target, scene) {
  22013. var _this = _super.call(this, name, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero(), scene) || this;
  22014. _this.alpha = alpha;
  22015. _this.beta = beta;
  22016. _this.radius = radius;
  22017. _this.target = target;
  22018. _this._cartesianCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  22019. _this._follow();
  22020. return _this;
  22021. }
  22022. ArcFollowCamera.prototype._follow = function () {
  22023. if (!this.target) {
  22024. return;
  22025. }
  22026. this._cartesianCoordinates.x = this.radius * Math.cos(this.alpha) * Math.cos(this.beta);
  22027. this._cartesianCoordinates.y = this.radius * Math.sin(this.beta);
  22028. this._cartesianCoordinates.z = this.radius * Math.sin(this.alpha) * Math.cos(this.beta);
  22029. var targetPosition = this.target.getAbsolutePosition();
  22030. this.position = targetPosition.add(this._cartesianCoordinates);
  22031. this.setTarget(targetPosition);
  22032. };
  22033. /** @hidden */
  22034. ArcFollowCamera.prototype._checkInputs = function () {
  22035. _super.prototype._checkInputs.call(this);
  22036. this._follow();
  22037. };
  22038. /**
  22039. * Returns the class name of the object.
  22040. * It is mostly used internally for serialization purposes.
  22041. */
  22042. ArcFollowCamera.prototype.getClassName = function () {
  22043. return "ArcFollowCamera";
  22044. };
  22045. return ArcFollowCamera;
  22046. }(_targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]));
  22047. /***/ }),
  22048. /***/ "./Cameras/followCameraInputsManager.ts":
  22049. /*!**********************************************!*\
  22050. !*** ./Cameras/followCameraInputsManager.ts ***!
  22051. \**********************************************/
  22052. /*! exports provided: FollowCameraInputsManager */
  22053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22054. "use strict";
  22055. __webpack_require__.r(__webpack_exports__);
  22056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FollowCameraInputsManager", function() { return FollowCameraInputsManager; });
  22057. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22058. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22059. /* harmony import */ var _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Inputs/followCameraKeyboardMoveInput */ "./Cameras/Inputs/followCameraKeyboardMoveInput.ts");
  22060. /* harmony import */ var _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Inputs/followCameraMouseWheelInput */ "./Cameras/Inputs/followCameraMouseWheelInput.ts");
  22061. /**
  22062. * Default Inputs manager for the FollowCamera.
  22063. * It groups all the default supported inputs for ease of use.
  22064. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22065. */
  22066. var FollowCameraInputsManager = /** @class */ (function (_super) {
  22067. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FollowCameraInputsManager, _super);
  22068. /**
  22069. * Instantiates a new FollowCameraInputsManager.
  22070. * @param camera Defines the camera the inputs belong to
  22071. */
  22072. function FollowCameraInputsManager(camera) {
  22073. return _super.call(this, camera) || this;
  22074. }
  22075. /**
  22076. * Add keyboard input support to the input manager.
  22077. * @returns the current input manager
  22078. */
  22079. FollowCameraInputsManager.prototype.addKeyboard = function () {
  22080. this.add(new _Inputs_followCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FollowCameraKeyboardMoveInput"]());
  22081. return this;
  22082. };
  22083. /**
  22084. * Add mouse wheel input support to the input manager.
  22085. * @returns the current input manager
  22086. */
  22087. FollowCameraInputsManager.prototype.addMouseWheel = function () {
  22088. this.add(new _Inputs_followCameraMouseWheelInput__WEBPACK_IMPORTED_MODULE_3__["FollowCameraMouseWheelInput"]());
  22089. return this;
  22090. };
  22091. /**
  22092. * Add pointers input support to the input manager.
  22093. * @returns the current input manager
  22094. */
  22095. FollowCameraInputsManager.prototype.addPointers = function () {
  22096. console.warn("Pointer support not yet implemented for FollowCamera.");
  22097. return this;
  22098. };
  22099. /**
  22100. * Add orientation input support to the input manager.
  22101. * @returns the current input manager
  22102. */
  22103. FollowCameraInputsManager.prototype.addVRDeviceOrientation = function () {
  22104. console.warn("DeviceOrientation support not yet implemented for FollowCamera.");
  22105. return this;
  22106. };
  22107. return FollowCameraInputsManager;
  22108. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22109. /***/ }),
  22110. /***/ "./Cameras/freeCamera.ts":
  22111. /*!*******************************!*\
  22112. !*** ./Cameras/freeCamera.ts ***!
  22113. \*******************************/
  22114. /*! exports provided: FreeCamera */
  22115. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22116. "use strict";
  22117. __webpack_require__.r(__webpack_exports__);
  22118. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return FreeCamera; });
  22119. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22120. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22121. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22122. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  22123. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22124. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22125. /**
  22126. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22127. * Please consider using the new UniversalCamera instead as it adds more functionality like the gamepad.
  22128. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22129. */
  22130. var FreeCamera = /** @class */ (function (_super) {
  22131. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCamera, _super);
  22132. /**
  22133. * Instantiates a Free Camera.
  22134. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  22135. * Please consider using the new UniversalCamera instead as it adds more functionality like touch to this camera.
  22136. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22137. * @param name Define the name of the camera in the scene
  22138. * @param position Define the start position of the camera in the scene
  22139. * @param scene Define the scene the camera belongs to
  22140. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22141. */
  22142. function FreeCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22143. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22144. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22145. /**
  22146. * Define the collision ellipsoid of the camera.
  22147. * This is helpful to simulate a camera body like the player body around the camera
  22148. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity#arcrotatecamera
  22149. */
  22150. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.5, 1, 0.5);
  22151. /**
  22152. * Define an offset for the position of the ellipsoid around the camera.
  22153. * This can be helpful to determine the center of the body near the gravity center of the body
  22154. * instead of its head.
  22155. */
  22156. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22157. /**
  22158. * Enable or disable collisions of the camera with the rest of the scene objects.
  22159. */
  22160. _this.checkCollisions = false;
  22161. /**
  22162. * Enable or disable gravity on the camera.
  22163. */
  22164. _this.applyGravity = false;
  22165. _this._needMoveForGravity = false;
  22166. _this._oldPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22167. _this._diffPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22168. _this._newPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22169. // Collisions
  22170. _this._collisionMask = -1;
  22171. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  22172. if (collidedMesh === void 0) { collidedMesh = null; }
  22173. var updatePosition = function (newPos) {
  22174. _this._newPosition.copyFrom(newPos);
  22175. _this._newPosition.subtractToRef(_this._oldPosition, _this._diffPosition);
  22176. if (_this._diffPosition.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].CollisionsEpsilon) {
  22177. _this.position.addInPlace(_this._diffPosition);
  22178. if (_this.onCollide && collidedMesh) {
  22179. _this.onCollide(collidedMesh);
  22180. }
  22181. }
  22182. };
  22183. updatePosition(newPosition);
  22184. };
  22185. _this.inputs = new _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"](_this);
  22186. _this.inputs.addKeyboard().addMouse();
  22187. return _this;
  22188. }
  22189. Object.defineProperty(FreeCamera.prototype, "angularSensibility", {
  22190. /**
  22191. * Gets the input sensibility for a mouse input. (default is 2000.0)
  22192. * Higher values reduce sensitivity.
  22193. */
  22194. get: function () {
  22195. var mouse = this.inputs.attached["mouse"];
  22196. if (mouse) {
  22197. return mouse.angularSensibility;
  22198. }
  22199. return 0;
  22200. },
  22201. /**
  22202. * Sets the input sensibility for a mouse input. (default is 2000.0)
  22203. * Higher values reduce sensitivity.
  22204. */
  22205. set: function (value) {
  22206. var mouse = this.inputs.attached["mouse"];
  22207. if (mouse) {
  22208. mouse.angularSensibility = value;
  22209. }
  22210. },
  22211. enumerable: true,
  22212. configurable: true
  22213. });
  22214. Object.defineProperty(FreeCamera.prototype, "keysUp", {
  22215. /**
  22216. * Gets or Set the list of keyboard keys used to control the forward move of the camera.
  22217. */
  22218. get: function () {
  22219. var keyboard = this.inputs.attached["keyboard"];
  22220. if (keyboard) {
  22221. return keyboard.keysUp;
  22222. }
  22223. return [];
  22224. },
  22225. set: function (value) {
  22226. var keyboard = this.inputs.attached["keyboard"];
  22227. if (keyboard) {
  22228. keyboard.keysUp = value;
  22229. }
  22230. },
  22231. enumerable: true,
  22232. configurable: true
  22233. });
  22234. Object.defineProperty(FreeCamera.prototype, "keysDown", {
  22235. /**
  22236. * Gets or Set the list of keyboard keys used to control the backward move of the camera.
  22237. */
  22238. get: function () {
  22239. var keyboard = this.inputs.attached["keyboard"];
  22240. if (keyboard) {
  22241. return keyboard.keysDown;
  22242. }
  22243. return [];
  22244. },
  22245. set: function (value) {
  22246. var keyboard = this.inputs.attached["keyboard"];
  22247. if (keyboard) {
  22248. keyboard.keysDown = value;
  22249. }
  22250. },
  22251. enumerable: true,
  22252. configurable: true
  22253. });
  22254. Object.defineProperty(FreeCamera.prototype, "keysLeft", {
  22255. /**
  22256. * Gets or Set the list of keyboard keys used to control the left strafe move of the camera.
  22257. */
  22258. get: function () {
  22259. var keyboard = this.inputs.attached["keyboard"];
  22260. if (keyboard) {
  22261. return keyboard.keysLeft;
  22262. }
  22263. return [];
  22264. },
  22265. set: function (value) {
  22266. var keyboard = this.inputs.attached["keyboard"];
  22267. if (keyboard) {
  22268. keyboard.keysLeft = value;
  22269. }
  22270. },
  22271. enumerable: true,
  22272. configurable: true
  22273. });
  22274. Object.defineProperty(FreeCamera.prototype, "keysRight", {
  22275. /**
  22276. * Gets or Set the list of keyboard keys used to control the right strafe move of the camera.
  22277. */
  22278. get: function () {
  22279. var keyboard = this.inputs.attached["keyboard"];
  22280. if (keyboard) {
  22281. return keyboard.keysRight;
  22282. }
  22283. return [];
  22284. },
  22285. set: function (value) {
  22286. var keyboard = this.inputs.attached["keyboard"];
  22287. if (keyboard) {
  22288. keyboard.keysRight = value;
  22289. }
  22290. },
  22291. enumerable: true,
  22292. configurable: true
  22293. });
  22294. /**
  22295. * Attached controls to the current camera.
  22296. * @param element Defines the element the controls should be listened from
  22297. * @param noPreventDefault Defines whether event caught by the controls should call preventdefault() (https://developer.mozilla.org/en-US/docs/Web/API/Event/preventDefault)
  22298. */
  22299. FreeCamera.prototype.attachControl = function (element, noPreventDefault) {
  22300. this.inputs.attachElement(element, noPreventDefault);
  22301. };
  22302. /**
  22303. * Detach the current controls from the camera.
  22304. * The camera will stop reacting to inputs.
  22305. * @param element Defines the element to stop listening the inputs from
  22306. */
  22307. FreeCamera.prototype.detachControl = function (element) {
  22308. this.inputs.detachElement(element);
  22309. this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0);
  22310. this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](0, 0);
  22311. };
  22312. Object.defineProperty(FreeCamera.prototype, "collisionMask", {
  22313. /**
  22314. * Define a collision mask to limit the list of object the camera can collide with
  22315. */
  22316. get: function () {
  22317. return this._collisionMask;
  22318. },
  22319. set: function (mask) {
  22320. this._collisionMask = !isNaN(mask) ? mask : -1;
  22321. },
  22322. enumerable: true,
  22323. configurable: true
  22324. });
  22325. /** @hidden */
  22326. FreeCamera.prototype._collideWithWorld = function (displacement) {
  22327. var globalPosition;
  22328. if (this.parent) {
  22329. globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(this.position, this.parent.getWorldMatrix());
  22330. }
  22331. else {
  22332. globalPosition = this.position;
  22333. }
  22334. globalPosition.subtractFromFloatsToRef(0, this.ellipsoid.y, 0, this._oldPosition);
  22335. this._oldPosition.addInPlace(this.ellipsoidOffset);
  22336. var coordinator = this.getScene().collisionCoordinator;
  22337. if (!this._collider) {
  22338. this._collider = coordinator.createCollider();
  22339. }
  22340. this._collider._radius = this.ellipsoid;
  22341. this._collider.collisionMask = this._collisionMask;
  22342. //no need for clone, as long as gravity is not on.
  22343. var actualDisplacement = displacement;
  22344. //add gravity to the direction to prevent the dual-collision checking
  22345. if (this.applyGravity) {
  22346. //this prevents mending with cameraDirection, a global variable of the free camera class.
  22347. actualDisplacement = displacement.add(this.getScene().gravity);
  22348. }
  22349. coordinator.getNewPosition(this._oldPosition, actualDisplacement, this._collider, 3, null, this._onCollisionPositionChange, this.uniqueId);
  22350. };
  22351. /** @hidden */
  22352. FreeCamera.prototype._checkInputs = function () {
  22353. if (!this._localDirection) {
  22354. this._localDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22355. this._transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  22356. }
  22357. this.inputs.checkInputs();
  22358. _super.prototype._checkInputs.call(this);
  22359. };
  22360. /** @hidden */
  22361. FreeCamera.prototype._decideIfNeedsToMove = function () {
  22362. return this._needMoveForGravity || Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22363. };
  22364. /** @hidden */
  22365. FreeCamera.prototype._updatePosition = function () {
  22366. if (this.checkCollisions && this.getScene().collisionsEnabled) {
  22367. this._collideWithWorld(this.cameraDirection);
  22368. }
  22369. else {
  22370. _super.prototype._updatePosition.call(this);
  22371. }
  22372. };
  22373. /**
  22374. * Destroy the camera and release the current resources hold by it.
  22375. */
  22376. FreeCamera.prototype.dispose = function () {
  22377. this.inputs.clear();
  22378. _super.prototype.dispose.call(this);
  22379. };
  22380. /**
  22381. * Gets the current object class name.
  22382. * @return the class name
  22383. */
  22384. FreeCamera.prototype.getClassName = function () {
  22385. return "FreeCamera";
  22386. };
  22387. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22389. ], FreeCamera.prototype, "ellipsoid", void 0);
  22390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  22392. ], FreeCamera.prototype, "ellipsoidOffset", void 0);
  22393. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22394. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22395. ], FreeCamera.prototype, "checkCollisions", void 0);
  22396. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  22397. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  22398. ], FreeCamera.prototype, "applyGravity", void 0);
  22399. return FreeCamera;
  22400. }(_targetCamera__WEBPACK_IMPORTED_MODULE_4__["TargetCamera"]));
  22401. /***/ }),
  22402. /***/ "./Cameras/freeCameraInputsManager.ts":
  22403. /*!********************************************!*\
  22404. !*** ./Cameras/freeCameraInputsManager.ts ***!
  22405. \********************************************/
  22406. /*! exports provided: FreeCameraInputsManager */
  22407. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22408. "use strict";
  22409. __webpack_require__.r(__webpack_exports__);
  22410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return FreeCameraInputsManager; });
  22411. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22412. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22413. /* harmony import */ var _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraKeyboardMoveInput */ "./Cameras/Inputs/freeCameraKeyboardMoveInput.ts");
  22414. /* harmony import */ var _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraMouseInput */ "./Cameras/Inputs/freeCameraMouseInput.ts");
  22415. /* harmony import */ var _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraTouchInput */ "./Cameras/Inputs/freeCameraTouchInput.ts");
  22416. /**
  22417. * Default Inputs manager for the FreeCamera.
  22418. * It groups all the default supported inputs for ease of use.
  22419. * @see http://doc.babylonjs.com/how_to/customizing_camera_inputs
  22420. */
  22421. var FreeCameraInputsManager = /** @class */ (function (_super) {
  22422. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FreeCameraInputsManager, _super);
  22423. /**
  22424. * Instantiates a new FreeCameraInputsManager.
  22425. * @param camera Defines the camera the inputs belong to
  22426. */
  22427. function FreeCameraInputsManager(camera) {
  22428. return _super.call(this, camera) || this;
  22429. }
  22430. /**
  22431. * Add keyboard input support to the input manager.
  22432. * @returns the current input manager
  22433. */
  22434. FreeCameraInputsManager.prototype.addKeyboard = function () {
  22435. this.add(new _Cameras_Inputs_freeCameraKeyboardMoveInput__WEBPACK_IMPORTED_MODULE_2__["FreeCameraKeyboardMoveInput"]());
  22436. return this;
  22437. };
  22438. /**
  22439. * Add mouse input support to the input manager.
  22440. * @param touchEnabled if the FreeCameraMouseInput should support touch (default: true)
  22441. * @returns the current input manager
  22442. */
  22443. FreeCameraInputsManager.prototype.addMouse = function (touchEnabled) {
  22444. if (touchEnabled === void 0) { touchEnabled = true; }
  22445. this.add(new _Cameras_Inputs_freeCameraMouseInput__WEBPACK_IMPORTED_MODULE_3__["FreeCameraMouseInput"](touchEnabled));
  22446. return this;
  22447. };
  22448. /**
  22449. * Add touch input support to the input manager.
  22450. * @returns the current input manager
  22451. */
  22452. FreeCameraInputsManager.prototype.addTouch = function () {
  22453. this.add(new _Cameras_Inputs_freeCameraTouchInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraTouchInput"]());
  22454. return this;
  22455. };
  22456. return FreeCameraInputsManager;
  22457. }(_cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]));
  22458. /***/ }),
  22459. /***/ "./Cameras/gamepadCamera.ts":
  22460. /*!**********************************!*\
  22461. !*** ./Cameras/gamepadCamera.ts ***!
  22462. \**********************************/
  22463. /*! exports provided: GamepadCamera */
  22464. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22465. "use strict";
  22466. __webpack_require__.r(__webpack_exports__);
  22467. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return GamepadCamera; });
  22468. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22469. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22470. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22471. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  22472. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("GamepadCamera", function (name, scene) {
  22473. return function () { return new GamepadCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  22474. });
  22475. /**
  22476. * This represents a FPS type of camera. This is only here for back compat purpose.
  22477. * Please use the UniversalCamera instead as both are identical.
  22478. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22479. */
  22480. var GamepadCamera = /** @class */ (function (_super) {
  22481. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GamepadCamera, _super);
  22482. /**
  22483. * Instantiates a new Gamepad Camera
  22484. * This represents a FPS type of camera. This is only here for back compat purpose.
  22485. * Please use the UniversalCamera instead as both are identical.
  22486. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  22487. * @param name Define the name of the camera in the scene
  22488. * @param position Define the start position of the camera in the scene
  22489. * @param scene Define the scene the camera belongs to
  22490. */
  22491. function GamepadCamera(name, position, scene) {
  22492. return _super.call(this, name, position, scene) || this;
  22493. }
  22494. /**
  22495. * Gets the current object class name.
  22496. * @return the class name
  22497. */
  22498. GamepadCamera.prototype.getClassName = function () {
  22499. return "GamepadCamera";
  22500. };
  22501. return GamepadCamera;
  22502. }(_universalCamera__WEBPACK_IMPORTED_MODULE_1__["UniversalCamera"]));
  22503. /***/ }),
  22504. /***/ "./Cameras/index.ts":
  22505. /*!**************************!*\
  22506. !*** ./Cameras/index.ts ***!
  22507. \**************************/
  22508. /*! exports provided: CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager */
  22509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22510. "use strict";
  22511. __webpack_require__.r(__webpack_exports__);
  22512. /* harmony import */ var _Inputs_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Inputs/index */ "./Cameras/Inputs/index.ts");
  22513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  22514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  22515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  22516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  22517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  22518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  22519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  22520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  22521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  22522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  22523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  22524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  22525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Inputs_index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  22526. /* harmony import */ var _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./cameraInputsManager */ "./Cameras/cameraInputsManager.ts");
  22527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputTypes"]; });
  22528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _cameraInputsManager__WEBPACK_IMPORTED_MODULE_1__["CameraInputsManager"]; });
  22529. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]; });
  22531. /* harmony import */ var _targetCamera__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./targetCamera */ "./Cameras/targetCamera.ts");
  22532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _targetCamera__WEBPACK_IMPORTED_MODULE_3__["TargetCamera"]; });
  22533. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  22534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _freeCamera__WEBPACK_IMPORTED_MODULE_4__["FreeCamera"]; });
  22535. /* harmony import */ var _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  22536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["FreeCameraInputsManager"]; });
  22537. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  22538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _touchCamera__WEBPACK_IMPORTED_MODULE_6__["TouchCamera"]; });
  22539. /* harmony import */ var _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  22540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _arcRotateCamera__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  22541. /* harmony import */ var _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  22542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_8__["ArcRotateCameraInputsManager"]; });
  22543. /* harmony import */ var _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deviceOrientationCamera */ "./Cameras/deviceOrientationCamera.ts");
  22544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _deviceOrientationCamera__WEBPACK_IMPORTED_MODULE_9__["DeviceOrientationCamera"]; });
  22545. /* harmony import */ var _flyCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./flyCamera */ "./Cameras/flyCamera.ts");
  22546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _flyCamera__WEBPACK_IMPORTED_MODULE_10__["FlyCamera"]; });
  22547. /* harmony import */ var _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./flyCameraInputsManager */ "./Cameras/flyCameraInputsManager.ts");
  22548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _flyCameraInputsManager__WEBPACK_IMPORTED_MODULE_11__["FlyCameraInputsManager"]; });
  22549. /* harmony import */ var _followCamera__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./followCamera */ "./Cameras/followCamera.ts");
  22550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["FollowCamera"]; });
  22551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _followCamera__WEBPACK_IMPORTED_MODULE_12__["ArcFollowCamera"]; });
  22552. /* harmony import */ var _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./gamepadCamera */ "./Cameras/gamepadCamera.ts");
  22553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _gamepadCamera__WEBPACK_IMPORTED_MODULE_13__["GamepadCamera"]; });
  22554. /* harmony import */ var _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Stereoscopic/index */ "./Cameras/Stereoscopic/index.ts");
  22555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphArcRotateCamera"]; });
  22556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphFreeCamera"]; });
  22557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphGamepadCamera"]; });
  22558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["AnaglyphUniversalCamera"]; });
  22559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicArcRotateCamera"]; });
  22560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicFreeCamera"]; });
  22561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicGamepadCamera"]; });
  22562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Stereoscopic_index__WEBPACK_IMPORTED_MODULE_14__["StereoscopicUniversalCamera"]; });
  22563. /* harmony import */ var _universalCamera__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./universalCamera */ "./Cameras/universalCamera.ts");
  22564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _universalCamera__WEBPACK_IMPORTED_MODULE_15__["UniversalCamera"]; });
  22565. /* harmony import */ var _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./virtualJoysticksCamera */ "./Cameras/virtualJoysticksCamera.ts");
  22566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _virtualJoysticksCamera__WEBPACK_IMPORTED_MODULE_16__["VirtualJoysticksCamera"]; });
  22567. /* harmony import */ var _VR_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./VR/index */ "./Cameras/VR/index.ts");
  22568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRCameraMetrics"]; });
  22569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationArcRotateCamera"]; });
  22570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationFreeCamera"]; });
  22571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRDeviceOrientationGamepadCamera"]; });
  22572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["VRExperienceHelper"]; });
  22573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _VR_index__WEBPACK_IMPORTED_MODULE_17__["WebVRFreeCamera"]; });
  22574. /* harmony import */ var _XR_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./XR/index */ "./Cameras/XR/index.ts");
  22575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRCamera"]; });
  22576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIButton"]; });
  22577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUIOptions"]; });
  22578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXREnterExitUI"]; });
  22579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRState"]; });
  22580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRExperienceHelper"]; });
  22581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRController"]; });
  22582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRInput"]; });
  22583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRManagedOutputCanvas"]; });
  22584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _XR_index__WEBPACK_IMPORTED_MODULE_18__["WebXRSessionManager"]; });
  22585. /***/ }),
  22586. /***/ "./Cameras/targetCamera.ts":
  22587. /*!*********************************!*\
  22588. !*** ./Cameras/targetCamera.ts ***!
  22589. \*********************************/
  22590. /*! exports provided: TargetCamera */
  22591. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  22592. "use strict";
  22593. __webpack_require__.r(__webpack_exports__);
  22594. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return TargetCamera; });
  22595. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  22596. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  22597. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  22598. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  22599. /**
  22600. * A target camera takes a mesh or position as a target and continues to look at it while it moves.
  22601. * This is the base of the follow, arc rotate cameras and Free camera
  22602. * @see http://doc.babylonjs.com/features/cameras
  22603. */
  22604. var TargetCamera = /** @class */ (function (_super) {
  22605. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TargetCamera, _super);
  22606. /**
  22607. * Instantiates a target camera that takes a meshor position as a target and continues to look at it while it moves.
  22608. * This is the base of the follow, arc rotate cameras and Free camera
  22609. * @see http://doc.babylonjs.com/features/cameras
  22610. * @param name Defines the name of the camera in the scene
  22611. * @param position Defines the start position of the camera in the scene
  22612. * @param scene Defines the scene the camera belongs to
  22613. * @param setActiveOnSceneIfNoneActive Defines wheter the camera should be marked as active if not other active cameras have been defined
  22614. */
  22615. function TargetCamera(name, position, scene, setActiveOnSceneIfNoneActive) {
  22616. if (setActiveOnSceneIfNoneActive === void 0) { setActiveOnSceneIfNoneActive = true; }
  22617. var _this = _super.call(this, name, position, scene, setActiveOnSceneIfNoneActive) || this;
  22618. /**
  22619. * Define the current direction the camera is moving to
  22620. */
  22621. _this.cameraDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22622. /**
  22623. * Define the current rotation the camera is rotating to
  22624. */
  22625. _this.cameraRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  22626. /**
  22627. * When set, the up vector of the camera will be updated by the rotation of the camera
  22628. */
  22629. _this.updateUpVectorFromRotation = false;
  22630. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22631. /**
  22632. * Define the current rotation of the camera
  22633. */
  22634. _this.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  22635. /**
  22636. * Define the current speed of the camera
  22637. */
  22638. _this.speed = 2.0;
  22639. /**
  22640. * Add cconstraint to the camera to prevent it to move freely in all directions and
  22641. * around all axis.
  22642. */
  22643. _this.noRotationConstraint = false;
  22644. /**
  22645. * Define the current target of the camera as an object or a position.
  22646. */
  22647. _this.lockedTarget = null;
  22648. /** @hidden */
  22649. _this._currentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22650. /** @hidden */
  22651. _this._initialFocalDistance = 1;
  22652. /** @hidden */
  22653. _this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22654. /** @hidden */
  22655. _this._camMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22656. /** @hidden */
  22657. _this._cameraTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22658. /** @hidden */
  22659. _this._cameraRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  22660. /** @hidden */
  22661. _this._referencePoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  22662. /** @hidden */
  22663. _this._transformedReferencePoint = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22664. _this._globalCurrentTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22665. _this._globalCurrentUpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  22666. _this._defaultUp = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up();
  22667. _this._cachedRotationZ = 0;
  22668. _this._cachedQuaternionRotationZ = 0;
  22669. return _this;
  22670. }
  22671. /**
  22672. * Gets the position in front of the camera at a given distance.
  22673. * @param distance The distance from the camera we want the position to be
  22674. * @returns the position
  22675. */
  22676. TargetCamera.prototype.getFrontPosition = function (distance) {
  22677. this.getWorldMatrix();
  22678. var direction = this.getTarget().subtract(this.position);
  22679. direction.normalize();
  22680. direction.scaleInPlace(distance);
  22681. return this.globalPosition.add(direction);
  22682. };
  22683. /** @hidden */
  22684. TargetCamera.prototype._getLockedTargetPosition = function () {
  22685. if (!this.lockedTarget) {
  22686. return null;
  22687. }
  22688. if (this.lockedTarget.absolutePosition) {
  22689. this.lockedTarget.computeWorldMatrix();
  22690. }
  22691. return this.lockedTarget.absolutePosition || this.lockedTarget;
  22692. };
  22693. /**
  22694. * Store current camera state of the camera (fov, position, rotation, etc..)
  22695. * @returns the camera
  22696. */
  22697. TargetCamera.prototype.storeState = function () {
  22698. this._storedPosition = this.position.clone();
  22699. this._storedRotation = this.rotation.clone();
  22700. if (this.rotationQuaternion) {
  22701. this._storedRotationQuaternion = this.rotationQuaternion.clone();
  22702. }
  22703. return _super.prototype.storeState.call(this);
  22704. };
  22705. /**
  22706. * Restored camera state. You must call storeState() first
  22707. * @returns whether it was successful or not
  22708. * @hidden
  22709. */
  22710. TargetCamera.prototype._restoreStateValues = function () {
  22711. if (!_super.prototype._restoreStateValues.call(this)) {
  22712. return false;
  22713. }
  22714. this.position = this._storedPosition.clone();
  22715. this.rotation = this._storedRotation.clone();
  22716. if (this.rotationQuaternion) {
  22717. this.rotationQuaternion = this._storedRotationQuaternion.clone();
  22718. }
  22719. this.cameraDirection.copyFromFloats(0, 0, 0);
  22720. this.cameraRotation.copyFromFloats(0, 0);
  22721. return true;
  22722. };
  22723. /** @hidden */
  22724. TargetCamera.prototype._initCache = function () {
  22725. _super.prototype._initCache.call(this);
  22726. this._cache.lockedTarget = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22727. this._cache.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22728. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  22729. };
  22730. /** @hidden */
  22731. TargetCamera.prototype._updateCache = function (ignoreParentClass) {
  22732. if (!ignoreParentClass) {
  22733. _super.prototype._updateCache.call(this);
  22734. }
  22735. var lockedTargetPosition = this._getLockedTargetPosition();
  22736. if (!lockedTargetPosition) {
  22737. this._cache.lockedTarget = null;
  22738. }
  22739. else {
  22740. if (!this._cache.lockedTarget) {
  22741. this._cache.lockedTarget = lockedTargetPosition.clone();
  22742. }
  22743. else {
  22744. this._cache.lockedTarget.copyFrom(lockedTargetPosition);
  22745. }
  22746. }
  22747. this._cache.rotation.copyFrom(this.rotation);
  22748. if (this.rotationQuaternion) {
  22749. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22750. }
  22751. };
  22752. // Synchronized
  22753. /** @hidden */
  22754. TargetCamera.prototype._isSynchronizedViewMatrix = function () {
  22755. if (!_super.prototype._isSynchronizedViewMatrix.call(this)) {
  22756. return false;
  22757. }
  22758. var lockedTargetPosition = this._getLockedTargetPosition();
  22759. return (this._cache.lockedTarget ? this._cache.lockedTarget.equals(lockedTargetPosition) : !lockedTargetPosition)
  22760. && (this.rotationQuaternion ? this.rotationQuaternion.equals(this._cache.rotationQuaternion) : this._cache.rotation.equals(this.rotation));
  22761. };
  22762. // Methods
  22763. /** @hidden */
  22764. TargetCamera.prototype._computeLocalCameraSpeed = function () {
  22765. var engine = this.getEngine();
  22766. return this.speed * Math.sqrt((engine.getDeltaTime() / (engine.getFps() * 100.0)));
  22767. };
  22768. // Target
  22769. /** @hidden */
  22770. TargetCamera.prototype.setTarget = function (target) {
  22771. this.upVector.normalize();
  22772. this._initialFocalDistance = target.subtract(this.position).length();
  22773. if (this.position.z === target.z) {
  22774. this.position.z += _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  22775. }
  22776. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this.position, target, this._defaultUp, this._camMatrix);
  22777. this._camMatrix.invert();
  22778. this.rotation.x = Math.atan(this._camMatrix.m[6] / this._camMatrix.m[10]);
  22779. var vDir = target.subtract(this.position);
  22780. if (vDir.x >= 0.0) {
  22781. this.rotation.y = (-Math.atan(vDir.z / vDir.x) + Math.PI / 2.0);
  22782. }
  22783. else {
  22784. this.rotation.y = (-Math.atan(vDir.z / vDir.x) - Math.PI / 2.0);
  22785. }
  22786. this.rotation.z = 0;
  22787. if (isNaN(this.rotation.x)) {
  22788. this.rotation.x = 0;
  22789. }
  22790. if (isNaN(this.rotation.y)) {
  22791. this.rotation.y = 0;
  22792. }
  22793. if (isNaN(this.rotation.z)) {
  22794. this.rotation.z = 0;
  22795. }
  22796. if (this.rotationQuaternion) {
  22797. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22798. }
  22799. };
  22800. /**
  22801. * Return the current target position of the camera. This value is expressed in local space.
  22802. * @returns the target position
  22803. */
  22804. TargetCamera.prototype.getTarget = function () {
  22805. return this._currentTarget;
  22806. };
  22807. /** @hidden */
  22808. TargetCamera.prototype._decideIfNeedsToMove = function () {
  22809. return Math.abs(this.cameraDirection.x) > 0 || Math.abs(this.cameraDirection.y) > 0 || Math.abs(this.cameraDirection.z) > 0;
  22810. };
  22811. /** @hidden */
  22812. TargetCamera.prototype._updatePosition = function () {
  22813. if (this.parent) {
  22814. this.parent.getWorldMatrix().invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  22815. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this.cameraDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22816. this.position.addInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0]);
  22817. return;
  22818. }
  22819. this.position.addInPlace(this.cameraDirection);
  22820. };
  22821. /** @hidden */
  22822. TargetCamera.prototype._checkInputs = function () {
  22823. var needToMove = this._decideIfNeedsToMove();
  22824. var needToRotate = Math.abs(this.cameraRotation.x) > 0 || Math.abs(this.cameraRotation.y) > 0;
  22825. // Move
  22826. if (needToMove) {
  22827. this._updatePosition();
  22828. }
  22829. // Rotate
  22830. if (needToRotate) {
  22831. this.rotation.x += this.cameraRotation.x;
  22832. this.rotation.y += this.cameraRotation.y;
  22833. //rotate, if quaternion is set and rotation was used
  22834. if (this.rotationQuaternion) {
  22835. var len = this.rotation.lengthSquared();
  22836. if (len) {
  22837. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this.rotationQuaternion);
  22838. }
  22839. }
  22840. if (!this.noRotationConstraint) {
  22841. var limit = (Math.PI / 2) * 0.95;
  22842. if (this.rotation.x > limit) {
  22843. this.rotation.x = limit;
  22844. }
  22845. if (this.rotation.x < -limit) {
  22846. this.rotation.x = -limit;
  22847. }
  22848. }
  22849. }
  22850. // Inertia
  22851. if (needToMove) {
  22852. if (Math.abs(this.cameraDirection.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22853. this.cameraDirection.x = 0;
  22854. }
  22855. if (Math.abs(this.cameraDirection.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22856. this.cameraDirection.y = 0;
  22857. }
  22858. if (Math.abs(this.cameraDirection.z) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22859. this.cameraDirection.z = 0;
  22860. }
  22861. this.cameraDirection.scaleInPlace(this.inertia);
  22862. }
  22863. if (needToRotate) {
  22864. if (Math.abs(this.cameraRotation.x) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22865. this.cameraRotation.x = 0;
  22866. }
  22867. if (Math.abs(this.cameraRotation.y) < this.speed * _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"]) {
  22868. this.cameraRotation.y = 0;
  22869. }
  22870. this.cameraRotation.scaleInPlace(this.inertia);
  22871. }
  22872. _super.prototype._checkInputs.call(this);
  22873. };
  22874. TargetCamera.prototype._updateCameraRotationMatrix = function () {
  22875. if (this.rotationQuaternion) {
  22876. this.rotationQuaternion.toRotationMatrix(this._cameraRotationMatrix);
  22877. }
  22878. else {
  22879. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, this._cameraRotationMatrix);
  22880. }
  22881. };
  22882. /**
  22883. * Update the up vector to apply the rotation of the camera (So if you changed the camera rotation.z this will let you update the up vector as well)
  22884. * @returns the current camera
  22885. */
  22886. TargetCamera.prototype._rotateUpVectorWithCameraRotationMatrix = function () {
  22887. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(this._defaultUp, this._cameraRotationMatrix, this.upVector);
  22888. return this;
  22889. };
  22890. /** @hidden */
  22891. TargetCamera.prototype._getViewMatrix = function () {
  22892. if (this.lockedTarget) {
  22893. this.setTarget(this._getLockedTargetPosition());
  22894. }
  22895. // Compute
  22896. this._updateCameraRotationMatrix();
  22897. // Apply the changed rotation to the upVector
  22898. if (this.rotationQuaternion && this._cachedQuaternionRotationZ != this.rotationQuaternion.z) {
  22899. this._rotateUpVectorWithCameraRotationMatrix();
  22900. this._cachedQuaternionRotationZ = this.rotationQuaternion.z;
  22901. }
  22902. else if (this._cachedRotationZ != this.rotation.z) {
  22903. this._rotateUpVectorWithCameraRotationMatrix();
  22904. this._cachedRotationZ = this.rotation.z;
  22905. }
  22906. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this._referencePoint, this._cameraRotationMatrix, this._transformedReferencePoint);
  22907. // Computing target and final matrix
  22908. this.position.addToRef(this._transformedReferencePoint, this._currentTarget);
  22909. if (this.updateUpVectorFromRotation) {
  22910. if (this.rotationQuaternion) {
  22911. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this.rotationQuaternion, this.upVector);
  22912. }
  22913. else {
  22914. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, this._tmpQuaternion);
  22915. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y.rotateByQuaternionToRef(this._tmpQuaternion, this.upVector);
  22916. }
  22917. }
  22918. this._computeViewMatrix(this.position, this._currentTarget, this.upVector);
  22919. return this._viewMatrix;
  22920. };
  22921. TargetCamera.prototype._computeViewMatrix = function (position, target, up) {
  22922. if (this.parent) {
  22923. var parentWorldMatrix = this.parent.getWorldMatrix();
  22924. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(position, parentWorldMatrix, this._globalPosition);
  22925. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(target, parentWorldMatrix, this._globalCurrentTarget);
  22926. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(up, parentWorldMatrix, this._globalCurrentUpVector);
  22927. this._markSyncedWithParent();
  22928. }
  22929. else {
  22930. this._globalPosition.copyFrom(position);
  22931. this._globalCurrentTarget.copyFrom(target);
  22932. this._globalCurrentUpVector.copyFrom(up);
  22933. }
  22934. if (this.getScene().useRightHandedSystem) {
  22935. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtRHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22936. }
  22937. else {
  22938. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(this._globalPosition, this._globalCurrentTarget, this._globalCurrentUpVector, this._viewMatrix);
  22939. }
  22940. };
  22941. /**
  22942. * @hidden
  22943. */
  22944. TargetCamera.prototype.createRigCamera = function (name, cameraIndex) {
  22945. if (this.cameraRigMode !== _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_NONE) {
  22946. var rigCamera = new TargetCamera(name, this.position.clone(), this.getScene());
  22947. if (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR || this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_WEBVR) {
  22948. if (!this.rotationQuaternion) {
  22949. this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22950. }
  22951. rigCamera._cameraRigParams = {};
  22952. rigCamera.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  22953. }
  22954. return rigCamera;
  22955. }
  22956. return null;
  22957. };
  22958. /**
  22959. * @hidden
  22960. */
  22961. TargetCamera.prototype._updateRigCameras = function () {
  22962. var camLeft = this._rigCameras[0];
  22963. var camRight = this._rigCameras[1];
  22964. this.computeWorldMatrix();
  22965. switch (this.cameraRigMode) {
  22966. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_ANAGLYPH:
  22967. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_PARALLEL:
  22968. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED:
  22969. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_OVERUNDER:
  22970. //provisionnaly using _cameraRigParams.stereoHalfAngle instead of calculations based on _cameraRigParams.interaxialDistance:
  22971. var leftSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? 1 : -1;
  22972. var rightSign = (this.cameraRigMode === _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_STEREOSCOPIC_SIDEBYSIDE_CROSSEYED) ? -1 : 1;
  22973. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * leftSign, camLeft);
  22974. this._getRigCamPositionAndTarget(this._cameraRigParams.stereoHalfAngle * rightSign, camRight);
  22975. break;
  22976. case _camera__WEBPACK_IMPORTED_MODULE_2__["Camera"].RIG_MODE_VR:
  22977. if (camLeft.rotationQuaternion) {
  22978. camLeft.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22979. camRight.rotationQuaternion.copyFrom(this.rotationQuaternion);
  22980. }
  22981. else {
  22982. camLeft.rotation.copyFrom(this.rotation);
  22983. camRight.rotation.copyFrom(this.rotation);
  22984. }
  22985. camLeft.position.copyFrom(this.position);
  22986. camRight.position.copyFrom(this.position);
  22987. break;
  22988. }
  22989. _super.prototype._updateRigCameras.call(this);
  22990. };
  22991. TargetCamera.prototype._getRigCamPositionAndTarget = function (halfSpace, rigCamera) {
  22992. var target = this.getTarget();
  22993. target.subtractToRef(this.position, TargetCamera._TargetFocalPoint);
  22994. TargetCamera._TargetFocalPoint.normalize().scaleInPlace(this._initialFocalDistance);
  22995. var newFocalTarget = TargetCamera._TargetFocalPoint.addInPlace(this.position);
  22996. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-newFocalTarget.x, -newFocalTarget.y, -newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22997. TargetCamera._TargetTransformMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(halfSpace), TargetCamera._RigCamTransformMatrix);
  22998. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(newFocalTarget.x, newFocalTarget.y, newFocalTarget.z, TargetCamera._TargetTransformMatrix);
  22999. TargetCamera._RigCamTransformMatrix.multiplyToRef(TargetCamera._TargetTransformMatrix, TargetCamera._RigCamTransformMatrix);
  23000. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, TargetCamera._RigCamTransformMatrix, rigCamera.position);
  23001. rigCamera.setTarget(newFocalTarget);
  23002. };
  23003. /**
  23004. * Gets the current object class name.
  23005. * @return the class name
  23006. */
  23007. TargetCamera.prototype.getClassName = function () {
  23008. return "TargetCamera";
  23009. };
  23010. TargetCamera._RigCamTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23011. TargetCamera._TargetTransformMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  23012. TargetCamera._TargetFocalPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  23013. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23014. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  23015. ], TargetCamera.prototype, "rotation", void 0);
  23016. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23017. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  23018. ], TargetCamera.prototype, "speed", void 0);
  23019. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  23020. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])("lockedTargetId")
  23021. ], TargetCamera.prototype, "lockedTarget", void 0);
  23022. return TargetCamera;
  23023. }(_camera__WEBPACK_IMPORTED_MODULE_2__["Camera"]));
  23024. /***/ }),
  23025. /***/ "./Cameras/touchCamera.ts":
  23026. /*!********************************!*\
  23027. !*** ./Cameras/touchCamera.ts ***!
  23028. \********************************/
  23029. /*! exports provided: TouchCamera */
  23030. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23031. "use strict";
  23032. __webpack_require__.r(__webpack_exports__);
  23033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return TouchCamera; });
  23034. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23035. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23037. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23038. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("TouchCamera", function (name, scene) {
  23039. return function () { return new TouchCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23040. });
  23041. /**
  23042. * This represents a FPS type of camera controlled by touch.
  23043. * This is like a universal camera minus the Gamepad controls.
  23044. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23045. */
  23046. var TouchCamera = /** @class */ (function (_super) {
  23047. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TouchCamera, _super);
  23048. /**
  23049. * Instantiates a new touch camera.
  23050. * This represents a FPS type of camera controlled by touch.
  23051. * This is like a universal camera minus the Gamepad controls.
  23052. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23053. * @param name Define the name of the camera in the scene
  23054. * @param position Define the start position of the camera in the scene
  23055. * @param scene Define the scene the camera belongs to
  23056. */
  23057. function TouchCamera(name, position, scene) {
  23058. var _this = _super.call(this, name, position, scene) || this;
  23059. _this.inputs.addTouch();
  23060. _this._setupInputs();
  23061. return _this;
  23062. }
  23063. Object.defineProperty(TouchCamera.prototype, "touchAngularSensibility", {
  23064. /**
  23065. * Defines the touch sensibility for rotation.
  23066. * The higher the faster.
  23067. */
  23068. get: function () {
  23069. var touch = this.inputs.attached["touch"];
  23070. if (touch) {
  23071. return touch.touchAngularSensibility;
  23072. }
  23073. return 0;
  23074. },
  23075. set: function (value) {
  23076. var touch = this.inputs.attached["touch"];
  23077. if (touch) {
  23078. touch.touchAngularSensibility = value;
  23079. }
  23080. },
  23081. enumerable: true,
  23082. configurable: true
  23083. });
  23084. Object.defineProperty(TouchCamera.prototype, "touchMoveSensibility", {
  23085. /**
  23086. * Defines the touch sensibility for move.
  23087. * The higher the faster.
  23088. */
  23089. get: function () {
  23090. var touch = this.inputs.attached["touch"];
  23091. if (touch) {
  23092. return touch.touchMoveSensibility;
  23093. }
  23094. return 0;
  23095. },
  23096. set: function (value) {
  23097. var touch = this.inputs.attached["touch"];
  23098. if (touch) {
  23099. touch.touchMoveSensibility = value;
  23100. }
  23101. },
  23102. enumerable: true,
  23103. configurable: true
  23104. });
  23105. /**
  23106. * Gets the current object class name.
  23107. * @return the class name
  23108. */
  23109. TouchCamera.prototype.getClassName = function () {
  23110. return "TouchCamera";
  23111. };
  23112. /** @hidden */
  23113. TouchCamera.prototype._setupInputs = function () {
  23114. var mouse = this.inputs.attached["mouse"];
  23115. if (mouse) {
  23116. mouse.touchEnabled = false;
  23117. }
  23118. };
  23119. return TouchCamera;
  23120. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23121. /***/ }),
  23122. /***/ "./Cameras/universalCamera.ts":
  23123. /*!************************************!*\
  23124. !*** ./Cameras/universalCamera.ts ***!
  23125. \************************************/
  23126. /*! exports provided: UniversalCamera */
  23127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23128. "use strict";
  23129. __webpack_require__.r(__webpack_exports__);
  23130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return UniversalCamera; });
  23131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23132. /* harmony import */ var _touchCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./touchCamera */ "./Cameras/touchCamera.ts");
  23133. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../node */ "./node.ts");
  23134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23135. /* harmony import */ var _camera__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./camera */ "./Cameras/camera.ts");
  23136. _node__WEBPACK_IMPORTED_MODULE_2__["Node"].AddNodeConstructor("FreeCamera", function (name, scene) {
  23137. // Forcing to use the Universal camera
  23138. return function () { return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene); };
  23139. });
  23140. /**
  23141. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  23142. * which still works and will still be found in many Playgrounds.
  23143. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23144. */
  23145. var UniversalCamera = /** @class */ (function (_super) {
  23146. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](UniversalCamera, _super);
  23147. /**
  23148. * The Universal Camera is the one to choose for first person shooter type games, and works with all the keyboard, mouse, touch and gamepads. This replaces the earlier Free Camera,
  23149. * which still works and will still be found in many Playgrounds.
  23150. * @see http://doc.babylonjs.com/features/cameras#universal-camera
  23151. * @param name Define the name of the camera in the scene
  23152. * @param position Define the start position of the camera in the scene
  23153. * @param scene Define the scene the camera belongs to
  23154. */
  23155. function UniversalCamera(name, position, scene) {
  23156. var _this = _super.call(this, name, position, scene) || this;
  23157. _this.inputs.addGamepad();
  23158. return _this;
  23159. }
  23160. Object.defineProperty(UniversalCamera.prototype, "gamepadAngularSensibility", {
  23161. /**
  23162. * Defines the gamepad rotation sensiblity.
  23163. * This is the threshold from when rotation starts to be accounted for to prevent jittering.
  23164. */
  23165. get: function () {
  23166. var gamepad = this.inputs.attached["gamepad"];
  23167. if (gamepad) {
  23168. return gamepad.gamepadAngularSensibility;
  23169. }
  23170. return 0;
  23171. },
  23172. set: function (value) {
  23173. var gamepad = this.inputs.attached["gamepad"];
  23174. if (gamepad) {
  23175. gamepad.gamepadAngularSensibility = value;
  23176. }
  23177. },
  23178. enumerable: true,
  23179. configurable: true
  23180. });
  23181. Object.defineProperty(UniversalCamera.prototype, "gamepadMoveSensibility", {
  23182. /**
  23183. * Defines the gamepad move sensiblity.
  23184. * This is the threshold from when moving starts to be accounted for for to prevent jittering.
  23185. */
  23186. get: function () {
  23187. var gamepad = this.inputs.attached["gamepad"];
  23188. if (gamepad) {
  23189. return gamepad.gamepadMoveSensibility;
  23190. }
  23191. return 0;
  23192. },
  23193. set: function (value) {
  23194. var gamepad = this.inputs.attached["gamepad"];
  23195. if (gamepad) {
  23196. gamepad.gamepadMoveSensibility = value;
  23197. }
  23198. },
  23199. enumerable: true,
  23200. configurable: true
  23201. });
  23202. /**
  23203. * Gets the current object class name.
  23204. * @return the class name
  23205. */
  23206. UniversalCamera.prototype.getClassName = function () {
  23207. return "UniversalCamera";
  23208. };
  23209. return UniversalCamera;
  23210. }(_touchCamera__WEBPACK_IMPORTED_MODULE_1__["TouchCamera"]));
  23211. _camera__WEBPACK_IMPORTED_MODULE_4__["Camera"]._createDefaultParsedCamera = function (name, scene) {
  23212. return new UniversalCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(), scene);
  23213. };
  23214. /***/ }),
  23215. /***/ "./Cameras/virtualJoysticksCamera.ts":
  23216. /*!*******************************************!*\
  23217. !*** ./Cameras/virtualJoysticksCamera.ts ***!
  23218. \*******************************************/
  23219. /*! exports provided: VirtualJoysticksCamera */
  23220. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23221. "use strict";
  23222. __webpack_require__.r(__webpack_exports__);
  23223. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return VirtualJoysticksCamera; });
  23224. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  23225. /* harmony import */ var _freeCamera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./freeCamera */ "./Cameras/freeCamera.ts");
  23226. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23227. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  23228. /* harmony import */ var _Inputs_freeCameraVirtualJoystickInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Inputs/freeCameraVirtualJoystickInput */ "./Cameras/Inputs/freeCameraVirtualJoystickInput.ts");
  23229. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("VirtualJoysticksCamera", function (name, scene) {
  23230. return function () { return new VirtualJoysticksCamera(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  23231. });
  23232. /**
  23233. * This represents a free type of camera. It can be useful in First Person Shooter game for instance.
  23234. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23235. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23236. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23237. */
  23238. var VirtualJoysticksCamera = /** @class */ (function (_super) {
  23239. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VirtualJoysticksCamera, _super);
  23240. /**
  23241. * Intantiates a VirtualJoysticksCamera. It can be useful in First Person Shooter game for instance.
  23242. * It is identical to the Free Camera and simply adds by default a virtual joystick.
  23243. * Virtual Joysticks are on-screen 2D graphics that are used to control the camera or other scene items.
  23244. * @see http://doc.babylonjs.com/features/cameras#virtual-joysticks-camera
  23245. * @param name Define the name of the camera in the scene
  23246. * @param position Define the start position of the camera in the scene
  23247. * @param scene Define the scene the camera belongs to
  23248. */
  23249. function VirtualJoysticksCamera(name, position, scene) {
  23250. var _this = _super.call(this, name, position, scene) || this;
  23251. _this.inputs.addVirtualJoystick();
  23252. return _this;
  23253. }
  23254. /**
  23255. * Gets the current object class name.
  23256. * @return the class name
  23257. */
  23258. VirtualJoysticksCamera.prototype.getClassName = function () {
  23259. return "VirtualJoysticksCamera";
  23260. };
  23261. return VirtualJoysticksCamera;
  23262. }(_freeCamera__WEBPACK_IMPORTED_MODULE_1__["FreeCamera"]));
  23263. /***/ }),
  23264. /***/ "./Collisions/collider.ts":
  23265. /*!********************************!*\
  23266. !*** ./Collisions/collider.ts ***!
  23267. \********************************/
  23268. /*! exports provided: Collider */
  23269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23270. "use strict";
  23271. __webpack_require__.r(__webpack_exports__);
  23272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return Collider; });
  23273. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23274. var intersectBoxAASphere = function (boxMin, boxMax, sphereCenter, sphereRadius) {
  23275. if (boxMin.x > sphereCenter.x + sphereRadius) {
  23276. return false;
  23277. }
  23278. if (sphereCenter.x - sphereRadius > boxMax.x) {
  23279. return false;
  23280. }
  23281. if (boxMin.y > sphereCenter.y + sphereRadius) {
  23282. return false;
  23283. }
  23284. if (sphereCenter.y - sphereRadius > boxMax.y) {
  23285. return false;
  23286. }
  23287. if (boxMin.z > sphereCenter.z + sphereRadius) {
  23288. return false;
  23289. }
  23290. if (sphereCenter.z - sphereRadius > boxMax.z) {
  23291. return false;
  23292. }
  23293. return true;
  23294. };
  23295. var getLowestRoot = (function () {
  23296. var result = { root: 0, found: false };
  23297. return function (a, b, c, maxR) {
  23298. result.root = 0;
  23299. result.found = false;
  23300. var determinant = b * b - 4.0 * a * c;
  23301. if (determinant < 0) {
  23302. return result;
  23303. }
  23304. var sqrtD = Math.sqrt(determinant);
  23305. var r1 = (-b - sqrtD) / (2.0 * a);
  23306. var r2 = (-b + sqrtD) / (2.0 * a);
  23307. if (r1 > r2) {
  23308. var temp = r2;
  23309. r2 = r1;
  23310. r1 = temp;
  23311. }
  23312. if (r1 > 0 && r1 < maxR) {
  23313. result.root = r1;
  23314. result.found = true;
  23315. return result;
  23316. }
  23317. if (r2 > 0 && r2 < maxR) {
  23318. result.root = r2;
  23319. result.found = true;
  23320. return result;
  23321. }
  23322. return result;
  23323. };
  23324. })();
  23325. /** @hidden */
  23326. var Collider = /** @class */ (function () {
  23327. function Collider() {
  23328. this._collisionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23329. this._planeIntersectionPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23330. this._tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23331. this._tempVector2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23332. this._tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23333. this._tempVector4 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23334. this._edge = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23335. this._baseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23336. this._destinationPoint = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23337. this._slidePlaneNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23338. this._displacementVector = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23339. /** @hidden */
  23340. this._radius = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  23341. /** @hidden */
  23342. this._retry = 0;
  23343. /** @hidden */
  23344. this._basePointWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23345. this._velocityWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23346. this._normalizedVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  23347. this._collisionMask = -1;
  23348. }
  23349. Object.defineProperty(Collider.prototype, "collisionMask", {
  23350. get: function () {
  23351. return this._collisionMask;
  23352. },
  23353. set: function (mask) {
  23354. this._collisionMask = !isNaN(mask) ? mask : -1;
  23355. },
  23356. enumerable: true,
  23357. configurable: true
  23358. });
  23359. Object.defineProperty(Collider.prototype, "slidePlaneNormal", {
  23360. /**
  23361. * Gets the plane normal used to compute the sliding response (in local space)
  23362. */
  23363. get: function () {
  23364. return this._slidePlaneNormal;
  23365. },
  23366. enumerable: true,
  23367. configurable: true
  23368. });
  23369. // Methods
  23370. /** @hidden */
  23371. Collider.prototype._initialize = function (source, dir, e) {
  23372. this._velocity = dir;
  23373. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].NormalizeToRef(dir, this._normalizedVelocity);
  23374. this._basePoint = source;
  23375. source.multiplyToRef(this._radius, this._basePointWorld);
  23376. dir.multiplyToRef(this._radius, this._velocityWorld);
  23377. this._velocityWorldLength = this._velocityWorld.length();
  23378. this._epsilon = e;
  23379. this.collisionFound = false;
  23380. };
  23381. /** @hidden */
  23382. Collider.prototype._checkPointInTriangle = function (point, pa, pb, pc, n) {
  23383. pa.subtractToRef(point, this._tempVector);
  23384. pb.subtractToRef(point, this._tempVector2);
  23385. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector, this._tempVector2, this._tempVector4);
  23386. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23387. if (d < 0) {
  23388. return false;
  23389. }
  23390. pc.subtractToRef(point, this._tempVector3);
  23391. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector2, this._tempVector3, this._tempVector4);
  23392. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23393. if (d < 0) {
  23394. return false;
  23395. }
  23396. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(this._tempVector3, this._tempVector, this._tempVector4);
  23397. d = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._tempVector4, n);
  23398. return d >= 0;
  23399. };
  23400. /** @hidden */
  23401. Collider.prototype._canDoCollision = function (sphereCenter, sphereRadius, vecMin, vecMax) {
  23402. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Distance(this._basePointWorld, sphereCenter);
  23403. var max = Math.max(this._radius.x, this._radius.y, this._radius.z);
  23404. if (distance > this._velocityWorldLength + max + sphereRadius) {
  23405. return false;
  23406. }
  23407. if (!intersectBoxAASphere(vecMin, vecMax, this._basePointWorld, this._velocityWorldLength + max)) {
  23408. return false;
  23409. }
  23410. return true;
  23411. };
  23412. /** @hidden */
  23413. Collider.prototype._testTriangle = function (faceIndex, trianglePlaneArray, p1, p2, p3, hasMaterial) {
  23414. var t0;
  23415. var embeddedInPlane = false;
  23416. //defensive programming, actually not needed.
  23417. if (!trianglePlaneArray) {
  23418. trianglePlaneArray = [];
  23419. }
  23420. if (!trianglePlaneArray[faceIndex]) {
  23421. trianglePlaneArray[faceIndex] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"](0, 0, 0, 0);
  23422. trianglePlaneArray[faceIndex].copyFromPoints(p1, p2, p3);
  23423. }
  23424. var trianglePlane = trianglePlaneArray[faceIndex];
  23425. if ((!hasMaterial) && !trianglePlane.isFrontFacingTo(this._normalizedVelocity, 0)) {
  23426. return;
  23427. }
  23428. var signedDistToTrianglePlane = trianglePlane.signedDistanceTo(this._basePoint);
  23429. var normalDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(trianglePlane.normal, this._velocity);
  23430. if (normalDotVelocity == 0) {
  23431. if (Math.abs(signedDistToTrianglePlane) >= 1.0) {
  23432. return;
  23433. }
  23434. embeddedInPlane = true;
  23435. t0 = 0;
  23436. }
  23437. else {
  23438. t0 = (-1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23439. var t1 = (1.0 - signedDistToTrianglePlane) / normalDotVelocity;
  23440. if (t0 > t1) {
  23441. var temp = t1;
  23442. t1 = t0;
  23443. t0 = temp;
  23444. }
  23445. if (t0 > 1.0 || t1 < 0.0) {
  23446. return;
  23447. }
  23448. if (t0 < 0) {
  23449. t0 = 0;
  23450. }
  23451. if (t0 > 1.0) {
  23452. t0 = 1.0;
  23453. }
  23454. }
  23455. this._collisionPoint.copyFromFloats(0, 0, 0);
  23456. var found = false;
  23457. var t = 1.0;
  23458. if (!embeddedInPlane) {
  23459. this._basePoint.subtractToRef(trianglePlane.normal, this._planeIntersectionPoint);
  23460. this._velocity.scaleToRef(t0, this._tempVector);
  23461. this._planeIntersectionPoint.addInPlace(this._tempVector);
  23462. if (this._checkPointInTriangle(this._planeIntersectionPoint, p1, p2, p3, trianglePlane.normal)) {
  23463. found = true;
  23464. t = t0;
  23465. this._collisionPoint.copyFrom(this._planeIntersectionPoint);
  23466. }
  23467. }
  23468. if (!found) {
  23469. var velocitySquaredLength = this._velocity.lengthSquared();
  23470. var a = velocitySquaredLength;
  23471. this._basePoint.subtractToRef(p1, this._tempVector);
  23472. var b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23473. var c = this._tempVector.lengthSquared() - 1.0;
  23474. var lowestRoot = getLowestRoot(a, b, c, t);
  23475. if (lowestRoot.found) {
  23476. t = lowestRoot.root;
  23477. found = true;
  23478. this._collisionPoint.copyFrom(p1);
  23479. }
  23480. this._basePoint.subtractToRef(p2, this._tempVector);
  23481. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23482. c = this._tempVector.lengthSquared() - 1.0;
  23483. lowestRoot = getLowestRoot(a, b, c, t);
  23484. if (lowestRoot.found) {
  23485. t = lowestRoot.root;
  23486. found = true;
  23487. this._collisionPoint.copyFrom(p2);
  23488. }
  23489. this._basePoint.subtractToRef(p3, this._tempVector);
  23490. b = 2.0 * (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._tempVector));
  23491. c = this._tempVector.lengthSquared() - 1.0;
  23492. lowestRoot = getLowestRoot(a, b, c, t);
  23493. if (lowestRoot.found) {
  23494. t = lowestRoot.root;
  23495. found = true;
  23496. this._collisionPoint.copyFrom(p3);
  23497. }
  23498. p2.subtractToRef(p1, this._edge);
  23499. p1.subtractToRef(this._basePoint, this._baseToVertex);
  23500. var edgeSquaredLength = this._edge.lengthSquared();
  23501. var edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23502. var edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23503. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23504. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23505. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23506. lowestRoot = getLowestRoot(a, b, c, t);
  23507. if (lowestRoot.found) {
  23508. var f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23509. if (f >= 0.0 && f <= 1.0) {
  23510. t = lowestRoot.root;
  23511. found = true;
  23512. this._edge.scaleInPlace(f);
  23513. p1.addToRef(this._edge, this._collisionPoint);
  23514. }
  23515. }
  23516. p3.subtractToRef(p2, this._edge);
  23517. p2.subtractToRef(this._basePoint, this._baseToVertex);
  23518. edgeSquaredLength = this._edge.lengthSquared();
  23519. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23520. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23521. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23522. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23523. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23524. lowestRoot = getLowestRoot(a, b, c, t);
  23525. if (lowestRoot.found) {
  23526. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23527. if (f >= 0.0 && f <= 1.0) {
  23528. t = lowestRoot.root;
  23529. found = true;
  23530. this._edge.scaleInPlace(f);
  23531. p2.addToRef(this._edge, this._collisionPoint);
  23532. }
  23533. }
  23534. p1.subtractToRef(p3, this._edge);
  23535. p3.subtractToRef(this._basePoint, this._baseToVertex);
  23536. edgeSquaredLength = this._edge.lengthSquared();
  23537. edgeDotVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._velocity);
  23538. edgeDotBaseToVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._edge, this._baseToVertex);
  23539. a = edgeSquaredLength * (-velocitySquaredLength) + edgeDotVelocity * edgeDotVelocity;
  23540. b = edgeSquaredLength * (2.0 * _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this._velocity, this._baseToVertex)) - 2.0 * edgeDotVelocity * edgeDotBaseToVertex;
  23541. c = edgeSquaredLength * (1.0 - this._baseToVertex.lengthSquared()) + edgeDotBaseToVertex * edgeDotBaseToVertex;
  23542. lowestRoot = getLowestRoot(a, b, c, t);
  23543. if (lowestRoot.found) {
  23544. f = (edgeDotVelocity * lowestRoot.root - edgeDotBaseToVertex) / edgeSquaredLength;
  23545. if (f >= 0.0 && f <= 1.0) {
  23546. t = lowestRoot.root;
  23547. found = true;
  23548. this._edge.scaleInPlace(f);
  23549. p3.addToRef(this._edge, this._collisionPoint);
  23550. }
  23551. }
  23552. }
  23553. if (found) {
  23554. var distToCollision = t * this._velocity.length();
  23555. if (!this.collisionFound || distToCollision < this._nearestDistance) {
  23556. if (!this.intersectionPoint) {
  23557. this.intersectionPoint = this._collisionPoint.clone();
  23558. }
  23559. else {
  23560. this.intersectionPoint.copyFrom(this._collisionPoint);
  23561. }
  23562. this._nearestDistance = distToCollision;
  23563. this.collisionFound = true;
  23564. }
  23565. }
  23566. };
  23567. /** @hidden */
  23568. Collider.prototype._collide = function (trianglePlaneArray, pts, indices, indexStart, indexEnd, decal, hasMaterial) {
  23569. for (var i = indexStart; i < indexEnd; i += 3) {
  23570. var p1 = pts[indices[i] - decal];
  23571. var p2 = pts[indices[i + 1] - decal];
  23572. var p3 = pts[indices[i + 2] - decal];
  23573. this._testTriangle(i, trianglePlaneArray, p3, p2, p1, hasMaterial);
  23574. }
  23575. };
  23576. /** @hidden */
  23577. Collider.prototype._getResponse = function (pos, vel) {
  23578. pos.addToRef(vel, this._destinationPoint);
  23579. vel.scaleInPlace((this._nearestDistance / vel.length()));
  23580. this._basePoint.addToRef(vel, pos);
  23581. pos.subtractToRef(this.intersectionPoint, this._slidePlaneNormal);
  23582. this._slidePlaneNormal.normalize();
  23583. this._slidePlaneNormal.scaleToRef(this._epsilon, this._displacementVector);
  23584. pos.addInPlace(this._displacementVector);
  23585. this.intersectionPoint.addInPlace(this._displacementVector);
  23586. this._slidePlaneNormal.scaleInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Plane"].SignedDistanceToPlaneFromPositionAndNormal(this.intersectionPoint, this._slidePlaneNormal, this._destinationPoint));
  23587. this._destinationPoint.subtractInPlace(this._slidePlaneNormal);
  23588. this._destinationPoint.subtractToRef(this.intersectionPoint, vel);
  23589. };
  23590. return Collider;
  23591. }());
  23592. /***/ }),
  23593. /***/ "./Collisions/collisionCoordinator.ts":
  23594. /*!********************************************!*\
  23595. !*** ./Collisions/collisionCoordinator.ts ***!
  23596. \********************************************/
  23597. /*! exports provided: DefaultCollisionCoordinator */
  23598. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23599. "use strict";
  23600. __webpack_require__.r(__webpack_exports__);
  23601. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return DefaultCollisionCoordinator; });
  23602. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  23603. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23604. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  23605. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23606. /** @hidden */
  23607. var DefaultCollisionCoordinator = /** @class */ (function () {
  23608. function DefaultCollisionCoordinator() {
  23609. this._scaledPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23610. this._scaledVelocity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23611. this._finalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  23612. }
  23613. DefaultCollisionCoordinator.prototype.getNewPosition = function (position, displacement, collider, maximumRetry, excludedMesh, onNewPosition, collisionIndex) {
  23614. position.divideToRef(collider._radius, this._scaledPosition);
  23615. displacement.divideToRef(collider._radius, this._scaledVelocity);
  23616. collider.collidedMesh = null;
  23617. collider._retry = 0;
  23618. collider._initialVelocity = this._scaledVelocity;
  23619. collider._initialPosition = this._scaledPosition;
  23620. this._collideWithWorld(this._scaledPosition, this._scaledVelocity, collider, maximumRetry, this._finalPosition, excludedMesh);
  23621. this._finalPosition.multiplyInPlace(collider._radius);
  23622. //run the callback
  23623. onNewPosition(collisionIndex, this._finalPosition, collider.collidedMesh);
  23624. };
  23625. DefaultCollisionCoordinator.prototype.createCollider = function () {
  23626. return new _collider__WEBPACK_IMPORTED_MODULE_3__["Collider"]();
  23627. };
  23628. DefaultCollisionCoordinator.prototype.init = function (scene) {
  23629. this._scene = scene;
  23630. };
  23631. DefaultCollisionCoordinator.prototype._collideWithWorld = function (position, velocity, collider, maximumRetry, finalPosition, excludedMesh) {
  23632. if (excludedMesh === void 0) { excludedMesh = null; }
  23633. var closeDistance = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].CollisionsEpsilon * 10.0;
  23634. if (collider._retry >= maximumRetry) {
  23635. finalPosition.copyFrom(position);
  23636. return;
  23637. }
  23638. // Check if this is a mesh else camera or -1
  23639. var collisionMask = (excludedMesh ? excludedMesh.collisionMask : collider.collisionMask);
  23640. collider._initialize(position, velocity, closeDistance);
  23641. // Check all meshes
  23642. for (var index = 0; index < this._scene.meshes.length; index++) {
  23643. var mesh = this._scene.meshes[index];
  23644. if (mesh.isEnabled() && mesh.checkCollisions && mesh.subMeshes && mesh !== excludedMesh && ((collisionMask & mesh.collisionGroup) !== 0)) {
  23645. mesh._checkCollision(collider);
  23646. }
  23647. }
  23648. if (!collider.collisionFound) {
  23649. position.addToRef(velocity, finalPosition);
  23650. return;
  23651. }
  23652. if (velocity.x !== 0 || velocity.y !== 0 || velocity.z !== 0) {
  23653. collider._getResponse(position, velocity);
  23654. }
  23655. if (velocity.length() <= closeDistance) {
  23656. finalPosition.copyFrom(position);
  23657. return;
  23658. }
  23659. collider._retry++;
  23660. this._collideWithWorld(position, velocity, collider, maximumRetry, finalPosition, excludedMesh);
  23661. };
  23662. return DefaultCollisionCoordinator;
  23663. }());
  23664. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].CollisionCoordinatorFactory = function () {
  23665. return new DefaultCollisionCoordinator();
  23666. };
  23667. /***/ }),
  23668. /***/ "./Collisions/index.ts":
  23669. /*!*****************************!*\
  23670. !*** ./Collisions/index.ts ***!
  23671. \*****************************/
  23672. /*! exports provided: Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo */
  23673. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23674. "use strict";
  23675. __webpack_require__.r(__webpack_exports__);
  23676. /* harmony import */ var _collider__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./collider */ "./Collisions/collider.ts");
  23677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _collider__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  23678. /* harmony import */ var _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./collisionCoordinator */ "./Collisions/collisionCoordinator.ts");
  23679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _collisionCoordinator__WEBPACK_IMPORTED_MODULE_1__["DefaultCollisionCoordinator"]; });
  23680. /* harmony import */ var _pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pickingInfo */ "./Collisions/pickingInfo.ts");
  23681. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]; });
  23682. /* harmony import */ var _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./intersectionInfo */ "./Collisions/intersectionInfo.ts");
  23683. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"]; });
  23684. /***/ }),
  23685. /***/ "./Collisions/intersectionInfo.ts":
  23686. /*!****************************************!*\
  23687. !*** ./Collisions/intersectionInfo.ts ***!
  23688. \****************************************/
  23689. /*! exports provided: IntersectionInfo */
  23690. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23691. "use strict";
  23692. __webpack_require__.r(__webpack_exports__);
  23693. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return IntersectionInfo; });
  23694. /**
  23695. * @hidden
  23696. */
  23697. var IntersectionInfo = /** @class */ (function () {
  23698. function IntersectionInfo(bu, bv, distance) {
  23699. this.bu = bu;
  23700. this.bv = bv;
  23701. this.distance = distance;
  23702. this.faceId = 0;
  23703. this.subMeshId = 0;
  23704. }
  23705. return IntersectionInfo;
  23706. }());
  23707. /***/ }),
  23708. /***/ "./Collisions/pickingInfo.ts":
  23709. /*!***********************************!*\
  23710. !*** ./Collisions/pickingInfo.ts ***!
  23711. \***********************************/
  23712. /*! exports provided: PickingInfo */
  23713. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23714. "use strict";
  23715. __webpack_require__.r(__webpack_exports__);
  23716. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return PickingInfo; });
  23717. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  23718. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  23719. /**
  23720. * Information about the result of picking within a scene
  23721. * @see https://doc.babylonjs.com/babylon101/picking_collisions
  23722. */
  23723. var PickingInfo = /** @class */ (function () {
  23724. function PickingInfo() {
  23725. /** @hidden */
  23726. this._pickingUnavailable = false;
  23727. /**
  23728. * If the pick collided with an object
  23729. */
  23730. this.hit = false;
  23731. /**
  23732. * Distance away where the pick collided
  23733. */
  23734. this.distance = 0;
  23735. /**
  23736. * The location of pick collision
  23737. */
  23738. this.pickedPoint = null;
  23739. /**
  23740. * The mesh corresponding the the pick collision
  23741. */
  23742. this.pickedMesh = null;
  23743. /** (See getTextureCoordinates) The barycentric U coordinate that is used when calulating the texture coordinates of the collision.*/
  23744. this.bu = 0;
  23745. /** (See getTextureCoordinates) The barycentric V coordinate that is used when calulating the texture coordinates of the collision.*/
  23746. this.bv = 0;
  23747. /** The index of the face on the mesh that was picked, or the index of the Line if the picked Mesh is a LinesMesh */
  23748. this.faceId = -1;
  23749. /** Id of the the submesh that was picked */
  23750. this.subMeshId = 0;
  23751. /** If a sprite was picked, this will be the sprite the pick collided with */
  23752. this.pickedSprite = null;
  23753. /**
  23754. * If a mesh was used to do the picking (eg. 6dof controller) this will be populated.
  23755. */
  23756. this.originMesh = null;
  23757. /**
  23758. * The ray that was used to perform the picking.
  23759. */
  23760. this.ray = null;
  23761. }
  23762. /**
  23763. * Gets the normal correspodning to the face the pick collided with
  23764. * @param useWorldCoordinates If the resulting normal should be relative to the world (default: false)
  23765. * @param useVerticesNormals If the vertices normals should be used to calculate the normal instead of the normal map
  23766. * @returns The normal correspodning to the face the pick collided with
  23767. */
  23768. PickingInfo.prototype.getNormal = function (useWorldCoordinates, useVerticesNormals) {
  23769. if (useWorldCoordinates === void 0) { useWorldCoordinates = false; }
  23770. if (useVerticesNormals === void 0) { useVerticesNormals = true; }
  23771. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  23772. return null;
  23773. }
  23774. var indices = this.pickedMesh.getIndices();
  23775. if (!indices) {
  23776. return null;
  23777. }
  23778. var result;
  23779. if (useVerticesNormals) {
  23780. var normals = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  23781. var normal0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3] * 3);
  23782. var normal1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 1] * 3);
  23783. var normal2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(normals, indices[this.faceId * 3 + 2] * 3);
  23784. normal0 = normal0.scale(this.bu);
  23785. normal1 = normal1.scale(this.bv);
  23786. normal2 = normal2.scale(1.0 - this.bu - this.bv);
  23787. result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal0.x + normal1.x + normal2.x, normal0.y + normal1.y + normal2.y, normal0.z + normal1.z + normal2.z);
  23788. }
  23789. else {
  23790. var positions = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  23791. var vertex1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3] * 3);
  23792. var vertex2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 1] * 3);
  23793. var vertex3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, indices[this.faceId * 3 + 2] * 3);
  23794. var p1p2 = vertex1.subtract(vertex2);
  23795. var p3p2 = vertex3.subtract(vertex2);
  23796. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(p1p2, p3p2);
  23797. }
  23798. if (useWorldCoordinates) {
  23799. var wm = this.pickedMesh.getWorldMatrix();
  23800. if (this.pickedMesh.nonUniformScaling) {
  23801. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0].copyFrom(wm);
  23802. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  23803. wm.setTranslationFromFloats(0, 0, 0);
  23804. wm.invert();
  23805. wm.transposeToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1]);
  23806. wm = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  23807. }
  23808. result = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result, wm);
  23809. }
  23810. result.normalize();
  23811. return result;
  23812. };
  23813. /**
  23814. * Gets the texture coordinates of where the pick occured
  23815. * @returns the vector containing the coordnates of the texture
  23816. */
  23817. PickingInfo.prototype.getTextureCoordinates = function () {
  23818. if (!this.pickedMesh || !this.pickedMesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  23819. return null;
  23820. }
  23821. var indices = this.pickedMesh.getIndices();
  23822. if (!indices) {
  23823. return null;
  23824. }
  23825. var uvs = this.pickedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  23826. if (!uvs) {
  23827. return null;
  23828. }
  23829. var uv0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3] * 2);
  23830. var uv1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 1] * 2);
  23831. var uv2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].FromArray(uvs, indices[this.faceId * 3 + 2] * 2);
  23832. uv0 = uv0.scale(1.0 - this.bu - this.bv);
  23833. uv1 = uv1.scale(this.bu);
  23834. uv2 = uv2.scale(this.bv);
  23835. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uv0.x + uv1.x + uv2.x, uv0.y + uv1.y + uv2.y);
  23836. };
  23837. return PickingInfo;
  23838. }());
  23839. /***/ }),
  23840. /***/ "./Culling/Octrees/index.ts":
  23841. /*!**********************************!*\
  23842. !*** ./Culling/Octrees/index.ts ***!
  23843. \**********************************/
  23844. /*! exports provided: Octree, OctreeBlock, OctreeSceneComponent */
  23845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23846. "use strict";
  23847. __webpack_require__.r(__webpack_exports__);
  23848. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  23849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _octree__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  23850. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]; });
  23852. /* harmony import */ var _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./octreeSceneComponent */ "./Culling/Octrees/octreeSceneComponent.ts");
  23853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _octreeSceneComponent__WEBPACK_IMPORTED_MODULE_2__["OctreeSceneComponent"]; });
  23854. /***/ }),
  23855. /***/ "./Culling/Octrees/octree.ts":
  23856. /*!***********************************!*\
  23857. !*** ./Culling/Octrees/octree.ts ***!
  23858. \***********************************/
  23859. /*! exports provided: Octree */
  23860. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  23861. "use strict";
  23862. __webpack_require__.r(__webpack_exports__);
  23863. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return Octree; });
  23864. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  23865. /* harmony import */ var _octreeBlock__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./octreeBlock */ "./Culling/Octrees/octreeBlock.ts");
  23866. /**
  23867. * Octrees are a really powerful data structure that can quickly select entities based on space coordinates.
  23868. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23869. */
  23870. var Octree = /** @class */ (function () {
  23871. /**
  23872. * Creates a octree
  23873. * @see https://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  23874. * @param creationFunc function to be used to instatiate the octree
  23875. * @param maxBlockCapacity defines the maximum number of meshes you want on your octree's leaves (default: 64)
  23876. * @param maxDepth defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.)
  23877. */
  23878. function Octree(creationFunc, maxBlockCapacity,
  23879. /** Defines the maximum depth (sub-levels) for your octree. Default value is 2, which means 8 8 8 = 512 blocks :) (This parameter takes precedence over capacity.) */
  23880. maxDepth) {
  23881. if (maxDepth === void 0) { maxDepth = 2; }
  23882. this.maxDepth = maxDepth;
  23883. /**
  23884. * Content stored in the octree
  23885. */
  23886. this.dynamicContent = new Array();
  23887. this._maxBlockCapacity = maxBlockCapacity || 64;
  23888. this._selectionContent = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"](1024);
  23889. this._creationFunc = creationFunc;
  23890. }
  23891. // Methods
  23892. /**
  23893. * Updates the octree by adding blocks for the passed in meshes within the min and max world parameters
  23894. * @param worldMin worldMin for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  23895. * @param worldMax worldMax for the octree blocks var blockSize = new Vector3((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  23896. * @param entries meshes to be added to the octree blocks
  23897. */
  23898. Octree.prototype.update = function (worldMin, worldMax, entries) {
  23899. _octreeBlock__WEBPACK_IMPORTED_MODULE_1__["OctreeBlock"]._CreateBlocks(worldMin, worldMax, entries, this._maxBlockCapacity, 0, this.maxDepth, this, this._creationFunc);
  23900. };
  23901. /**
  23902. * Adds a mesh to the octree
  23903. * @param entry Mesh to add to the octree
  23904. */
  23905. Octree.prototype.addMesh = function (entry) {
  23906. for (var index = 0; index < this.blocks.length; index++) {
  23907. var block = this.blocks[index];
  23908. block.addEntry(entry);
  23909. }
  23910. };
  23911. /**
  23912. * Remove an element from the octree
  23913. * @param entry defines the element to remove
  23914. */
  23915. Octree.prototype.removeMesh = function (entry) {
  23916. for (var index = 0; index < this.blocks.length; index++) {
  23917. var block = this.blocks[index];
  23918. block.removeEntry(entry);
  23919. }
  23920. };
  23921. /**
  23922. * Selects an array of meshes within the frustum
  23923. * @param frustumPlanes The frustum planes to use which will select all meshes within it
  23924. * @param allowDuplicate If duplicate objects are allowed in the resulting object array
  23925. * @returns array of meshes within the frustum
  23926. */
  23927. Octree.prototype.select = function (frustumPlanes, allowDuplicate) {
  23928. this._selectionContent.reset();
  23929. for (var index = 0; index < this.blocks.length; index++) {
  23930. var block = this.blocks[index];
  23931. block.select(frustumPlanes, this._selectionContent, allowDuplicate);
  23932. }
  23933. if (allowDuplicate) {
  23934. this._selectionContent.concat(this.dynamicContent);
  23935. }
  23936. else {
  23937. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23938. }
  23939. return this._selectionContent;
  23940. };
  23941. /**
  23942. * Test if the octree intersect with the given bounding sphere and if yes, then add its content to the selection array
  23943. * @param sphereCenter defines the bounding sphere center
  23944. * @param sphereRadius defines the bounding sphere radius
  23945. * @param allowDuplicate defines if the selection array can contains duplicated entries
  23946. * @returns an array of objects that intersect the sphere
  23947. */
  23948. Octree.prototype.intersects = function (sphereCenter, sphereRadius, allowDuplicate) {
  23949. this._selectionContent.reset();
  23950. for (var index = 0; index < this.blocks.length; index++) {
  23951. var block = this.blocks[index];
  23952. block.intersects(sphereCenter, sphereRadius, this._selectionContent, allowDuplicate);
  23953. }
  23954. if (allowDuplicate) {
  23955. this._selectionContent.concat(this.dynamicContent);
  23956. }
  23957. else {
  23958. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23959. }
  23960. return this._selectionContent;
  23961. };
  23962. /**
  23963. * Test if the octree intersect with the given ray and if yes, then add its content to resulting array
  23964. * @param ray defines the ray to test with
  23965. * @returns array of intersected objects
  23966. */
  23967. Octree.prototype.intersectsRay = function (ray) {
  23968. this._selectionContent.reset();
  23969. for (var index = 0; index < this.blocks.length; index++) {
  23970. var block = this.blocks[index];
  23971. block.intersectsRay(ray, this._selectionContent);
  23972. }
  23973. this._selectionContent.concatWithNoDuplicate(this.dynamicContent);
  23974. return this._selectionContent;
  23975. };
  23976. /**
  23977. * Adds a mesh into the octree block if it intersects the block
  23978. */
  23979. Octree.CreationFuncForMeshes = function (entry, block) {
  23980. var boundingInfo = entry.getBoundingInfo();
  23981. if (!entry.isBlocked && boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23982. block.entries.push(entry);
  23983. }
  23984. };
  23985. /**
  23986. * Adds a submesh into the octree block if it intersects the block
  23987. */
  23988. Octree.CreationFuncForSubMeshes = function (entry, block) {
  23989. var boundingInfo = entry.getBoundingInfo();
  23990. if (boundingInfo.boundingBox.intersectsMinMax(block.minPoint, block.maxPoint)) {
  23991. block.entries.push(entry);
  23992. }
  23993. };
  23994. return Octree;
  23995. }());
  23996. /***/ }),
  23997. /***/ "./Culling/Octrees/octreeBlock.ts":
  23998. /*!****************************************!*\
  23999. !*** ./Culling/Octrees/octreeBlock.ts ***!
  24000. \****************************************/
  24001. /*! exports provided: OctreeBlock */
  24002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24003. "use strict";
  24004. __webpack_require__.r(__webpack_exports__);
  24005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return OctreeBlock; });
  24006. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24007. /* harmony import */ var _Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Culling/boundingBox */ "./Culling/boundingBox.ts");
  24008. /**
  24009. * Class used to store a cell in an octree
  24010. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24011. */
  24012. var OctreeBlock = /** @class */ (function () {
  24013. /**
  24014. * Creates a new block
  24015. * @param minPoint defines the minimum vector (in world space) of the block's bounding box
  24016. * @param maxPoint defines the maximum vector (in world space) of the block's bounding box
  24017. * @param capacity defines the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24018. * @param depth defines the current depth of this block in the octree
  24019. * @param maxDepth defines the maximal depth allowed (beyond this value, the capacity is ignored)
  24020. * @param creationFunc defines a callback to call when an element is added to the block
  24021. */
  24022. function OctreeBlock(minPoint, maxPoint, capacity, depth, maxDepth, creationFunc) {
  24023. /**
  24024. * Gets the content of the current block
  24025. */
  24026. this.entries = new Array();
  24027. this._boundingVectors = new Array();
  24028. this._capacity = capacity;
  24029. this._depth = depth;
  24030. this._maxDepth = maxDepth;
  24031. this._creationFunc = creationFunc;
  24032. this._minPoint = minPoint;
  24033. this._maxPoint = maxPoint;
  24034. this._boundingVectors.push(minPoint.clone());
  24035. this._boundingVectors.push(maxPoint.clone());
  24036. this._boundingVectors.push(minPoint.clone());
  24037. this._boundingVectors[2].x = maxPoint.x;
  24038. this._boundingVectors.push(minPoint.clone());
  24039. this._boundingVectors[3].y = maxPoint.y;
  24040. this._boundingVectors.push(minPoint.clone());
  24041. this._boundingVectors[4].z = maxPoint.z;
  24042. this._boundingVectors.push(maxPoint.clone());
  24043. this._boundingVectors[5].z = minPoint.z;
  24044. this._boundingVectors.push(maxPoint.clone());
  24045. this._boundingVectors[6].x = minPoint.x;
  24046. this._boundingVectors.push(maxPoint.clone());
  24047. this._boundingVectors[7].y = minPoint.y;
  24048. }
  24049. Object.defineProperty(OctreeBlock.prototype, "capacity", {
  24050. // Property
  24051. /**
  24052. * Gets the maximum capacity of this block (if capacity is reached the block will be split into sub blocks)
  24053. */
  24054. get: function () {
  24055. return this._capacity;
  24056. },
  24057. enumerable: true,
  24058. configurable: true
  24059. });
  24060. Object.defineProperty(OctreeBlock.prototype, "minPoint", {
  24061. /**
  24062. * Gets the minimum vector (in world space) of the block's bounding box
  24063. */
  24064. get: function () {
  24065. return this._minPoint;
  24066. },
  24067. enumerable: true,
  24068. configurable: true
  24069. });
  24070. Object.defineProperty(OctreeBlock.prototype, "maxPoint", {
  24071. /**
  24072. * Gets the maximum vector (in world space) of the block's bounding box
  24073. */
  24074. get: function () {
  24075. return this._maxPoint;
  24076. },
  24077. enumerable: true,
  24078. configurable: true
  24079. });
  24080. // Methods
  24081. /**
  24082. * Add a new element to this block
  24083. * @param entry defines the element to add
  24084. */
  24085. OctreeBlock.prototype.addEntry = function (entry) {
  24086. if (this.blocks) {
  24087. for (var index = 0; index < this.blocks.length; index++) {
  24088. var block = this.blocks[index];
  24089. block.addEntry(entry);
  24090. }
  24091. return;
  24092. }
  24093. this._creationFunc(entry, this);
  24094. if (this.entries.length > this.capacity && this._depth < this._maxDepth) {
  24095. this.createInnerBlocks();
  24096. }
  24097. };
  24098. /**
  24099. * Remove an element from this block
  24100. * @param entry defines the element to remove
  24101. */
  24102. OctreeBlock.prototype.removeEntry = function (entry) {
  24103. if (this.blocks) {
  24104. for (var index = 0; index < this.blocks.length; index++) {
  24105. var block = this.blocks[index];
  24106. block.removeEntry(entry);
  24107. }
  24108. return;
  24109. }
  24110. var entryIndex = this.entries.indexOf(entry);
  24111. if (entryIndex > -1) {
  24112. this.entries.splice(entryIndex, 1);
  24113. }
  24114. };
  24115. /**
  24116. * Add an array of elements to this block
  24117. * @param entries defines the array of elements to add
  24118. */
  24119. OctreeBlock.prototype.addEntries = function (entries) {
  24120. for (var index = 0; index < entries.length; index++) {
  24121. var mesh = entries[index];
  24122. this.addEntry(mesh);
  24123. }
  24124. };
  24125. /**
  24126. * Test if the current block intersects the furstum planes and if yes, then add its content to the selection array
  24127. * @param frustumPlanes defines the frustum planes to test
  24128. * @param selection defines the array to store current content if selection is positive
  24129. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24130. */
  24131. OctreeBlock.prototype.select = function (frustumPlanes, selection, allowDuplicate) {
  24132. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IsInFrustum(this._boundingVectors, frustumPlanes)) {
  24133. if (this.blocks) {
  24134. for (var index = 0; index < this.blocks.length; index++) {
  24135. var block = this.blocks[index];
  24136. block.select(frustumPlanes, selection, allowDuplicate);
  24137. }
  24138. return;
  24139. }
  24140. if (allowDuplicate) {
  24141. selection.concat(this.entries);
  24142. }
  24143. else {
  24144. selection.concatWithNoDuplicate(this.entries);
  24145. }
  24146. }
  24147. };
  24148. /**
  24149. * Test if the current block intersect with the given bounding sphere and if yes, then add its content to the selection array
  24150. * @param sphereCenter defines the bounding sphere center
  24151. * @param sphereRadius defines the bounding sphere radius
  24152. * @param selection defines the array to store current content if selection is positive
  24153. * @param allowDuplicate defines if the selection array can contains duplicated entries
  24154. */
  24155. OctreeBlock.prototype.intersects = function (sphereCenter, sphereRadius, selection, allowDuplicate) {
  24156. if (_Culling_boundingBox__WEBPACK_IMPORTED_MODULE_1__["BoundingBox"].IntersectsSphere(this._minPoint, this._maxPoint, sphereCenter, sphereRadius)) {
  24157. if (this.blocks) {
  24158. for (var index = 0; index < this.blocks.length; index++) {
  24159. var block = this.blocks[index];
  24160. block.intersects(sphereCenter, sphereRadius, selection, allowDuplicate);
  24161. }
  24162. return;
  24163. }
  24164. if (allowDuplicate) {
  24165. selection.concat(this.entries);
  24166. }
  24167. else {
  24168. selection.concatWithNoDuplicate(this.entries);
  24169. }
  24170. }
  24171. };
  24172. /**
  24173. * Test if the current block intersect with the given ray and if yes, then add its content to the selection array
  24174. * @param ray defines the ray to test with
  24175. * @param selection defines the array to store current content if selection is positive
  24176. */
  24177. OctreeBlock.prototype.intersectsRay = function (ray, selection) {
  24178. if (ray.intersectsBoxMinMax(this._minPoint, this._maxPoint)) {
  24179. if (this.blocks) {
  24180. for (var index = 0; index < this.blocks.length; index++) {
  24181. var block = this.blocks[index];
  24182. block.intersectsRay(ray, selection);
  24183. }
  24184. return;
  24185. }
  24186. selection.concatWithNoDuplicate(this.entries);
  24187. }
  24188. };
  24189. /**
  24190. * Subdivide the content into child blocks (this block will then be empty)
  24191. */
  24192. OctreeBlock.prototype.createInnerBlocks = function () {
  24193. OctreeBlock._CreateBlocks(this._minPoint, this._maxPoint, this.entries, this._capacity, this._depth, this._maxDepth, this, this._creationFunc);
  24194. };
  24195. /**
  24196. * @hidden
  24197. */
  24198. OctreeBlock._CreateBlocks = function (worldMin, worldMax, entries, maxBlockCapacity, currentDepth, maxDepth, target, creationFunc) {
  24199. target.blocks = new Array();
  24200. var blockSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((worldMax.x - worldMin.x) / 2, (worldMax.y - worldMin.y) / 2, (worldMax.z - worldMin.z) / 2);
  24201. // Segmenting space
  24202. for (var x = 0; x < 2; x++) {
  24203. for (var y = 0; y < 2; y++) {
  24204. for (var z = 0; z < 2; z++) {
  24205. var localMin = worldMin.add(blockSize.multiplyByFloats(x, y, z));
  24206. var localMax = worldMin.add(blockSize.multiplyByFloats(x + 1, y + 1, z + 1));
  24207. var block = new OctreeBlock(localMin, localMax, maxBlockCapacity, currentDepth + 1, maxDepth, creationFunc);
  24208. block.addEntries(entries);
  24209. target.blocks.push(block);
  24210. }
  24211. }
  24212. }
  24213. };
  24214. return OctreeBlock;
  24215. }());
  24216. /***/ }),
  24217. /***/ "./Culling/Octrees/octreeSceneComponent.ts":
  24218. /*!*************************************************!*\
  24219. !*** ./Culling/Octrees/octreeSceneComponent.ts ***!
  24220. \*************************************************/
  24221. /*! exports provided: OctreeSceneComponent */
  24222. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24223. "use strict";
  24224. __webpack_require__.r(__webpack_exports__);
  24225. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return OctreeSceneComponent; });
  24226. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  24227. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  24228. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  24229. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  24230. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  24231. /* harmony import */ var _octree__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./octree */ "./Culling/Octrees/octree.ts");
  24232. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.createOrUpdateSelectionOctree = function (maxCapacity, maxDepth) {
  24233. if (maxCapacity === void 0) { maxCapacity = 64; }
  24234. if (maxDepth === void 0) { maxDepth = 2; }
  24235. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24236. if (!component) {
  24237. component = new OctreeSceneComponent(this);
  24238. this._addComponent(component);
  24239. }
  24240. if (!this._selectionOctree) {
  24241. this._selectionOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForMeshes, maxCapacity, maxDepth);
  24242. }
  24243. var worldExtends = this.getWorldExtends();
  24244. // Update octree
  24245. this._selectionOctree.update(worldExtends.min, worldExtends.max, this.meshes);
  24246. return this._selectionOctree;
  24247. };
  24248. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "selectionOctree", {
  24249. get: function () {
  24250. return this._selectionOctree;
  24251. },
  24252. enumerable: true,
  24253. configurable: true
  24254. });
  24255. /**
  24256. * This function will create an octree to help to select the right submeshes for rendering, picking and collision computations.
  24257. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  24258. * @param maxCapacity defines the maximum size of each block (64 by default)
  24259. * @param maxDepth defines the maximum depth to use (no more than 2 levels by default)
  24260. * @returns the new octree
  24261. * @see https://www.babylonjs-playground.com/#NA4OQ#12
  24262. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene_with_octrees
  24263. */
  24264. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.createOrUpdateSubmeshesOctree = function (maxCapacity, maxDepth) {
  24265. if (maxCapacity === void 0) { maxCapacity = 64; }
  24266. if (maxDepth === void 0) { maxDepth = 2; }
  24267. var scene = this.getScene();
  24268. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE);
  24269. if (!component) {
  24270. component = new OctreeSceneComponent(scene);
  24271. scene._addComponent(component);
  24272. }
  24273. if (!this._submeshesOctree) {
  24274. this._submeshesOctree = new _octree__WEBPACK_IMPORTED_MODULE_5__["Octree"](_octree__WEBPACK_IMPORTED_MODULE_5__["Octree"].CreationFuncForSubMeshes, maxCapacity, maxDepth);
  24275. }
  24276. this.computeWorldMatrix(true);
  24277. var boundingInfo = this.getBoundingInfo();
  24278. // Update octree
  24279. var bbox = boundingInfo.boundingBox;
  24280. this._submeshesOctree.update(bbox.minimumWorld, bbox.maximumWorld, this.subMeshes);
  24281. return this._submeshesOctree;
  24282. };
  24283. /**
  24284. * Defines the octree scene component responsible to manage any octrees
  24285. * in a given scene.
  24286. */
  24287. var OctreeSceneComponent = /** @class */ (function () {
  24288. /**
  24289. * Creates a new instance of the component for the given scene
  24290. * @param scene Defines the scene to register the component in
  24291. */
  24292. function OctreeSceneComponent(scene) {
  24293. /**
  24294. * The component name helpfull to identify the component in the list of scene components.
  24295. */
  24296. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OCTREE;
  24297. /**
  24298. * Indicates if the meshes have been checked to make sure they are isEnabled()
  24299. */
  24300. this.checksIsEnabled = true;
  24301. this._tempRay = new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](1, 1, 1));
  24302. this.scene = scene;
  24303. this.scene.getActiveMeshCandidates = this.getActiveMeshCandidates.bind(this);
  24304. this.scene.getActiveSubMeshCandidates = this.getActiveSubMeshCandidates.bind(this);
  24305. this.scene.getCollidingSubMeshCandidates = this.getCollidingSubMeshCandidates.bind(this);
  24306. this.scene.getIntersectingSubMeshCandidates = this.getIntersectingSubMeshCandidates.bind(this);
  24307. }
  24308. /**
  24309. * Registers the component in a given scene
  24310. */
  24311. OctreeSceneComponent.prototype.register = function () {
  24312. var _this = this;
  24313. this.scene.onMeshRemovedObservable.add(function (mesh) {
  24314. var sceneOctree = _this.scene.selectionOctree;
  24315. if (sceneOctree !== undefined && sceneOctree !== null) {
  24316. var index = sceneOctree.dynamicContent.indexOf(mesh);
  24317. if (index !== -1) {
  24318. sceneOctree.dynamicContent.splice(index, 1);
  24319. }
  24320. }
  24321. });
  24322. this.scene.onMeshImportedObservable.add(function (mesh) {
  24323. var sceneOctree = _this.scene.selectionOctree;
  24324. if (sceneOctree !== undefined && sceneOctree !== null) {
  24325. sceneOctree.addMesh(mesh);
  24326. }
  24327. });
  24328. };
  24329. /**
  24330. * Return the list of active meshes
  24331. * @returns the list of active meshes
  24332. */
  24333. OctreeSceneComponent.prototype.getActiveMeshCandidates = function () {
  24334. if (this.scene._selectionOctree) {
  24335. var selection = this.scene._selectionOctree.select(this.scene.frustumPlanes);
  24336. return selection;
  24337. }
  24338. return this.scene._getDefaultMeshCandidates();
  24339. };
  24340. /**
  24341. * Return the list of active sub meshes
  24342. * @param mesh The mesh to get the candidates sub meshes from
  24343. * @returns the list of active sub meshes
  24344. */
  24345. OctreeSceneComponent.prototype.getActiveSubMeshCandidates = function (mesh) {
  24346. if (mesh._submeshesOctree && mesh.useOctreeForRenderingSelection) {
  24347. var intersections = mesh._submeshesOctree.select(this.scene.frustumPlanes);
  24348. return intersections;
  24349. }
  24350. return this.scene._getDefaultSubMeshCandidates(mesh);
  24351. };
  24352. /**
  24353. * Return the list of sub meshes intersecting with a given local ray
  24354. * @param mesh defines the mesh to find the submesh for
  24355. * @param localRay defines the ray in local space
  24356. * @returns the list of intersecting sub meshes
  24357. */
  24358. OctreeSceneComponent.prototype.getIntersectingSubMeshCandidates = function (mesh, localRay) {
  24359. if (mesh._submeshesOctree && mesh.useOctreeForPicking) {
  24360. _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"].TransformToRef(localRay, mesh.getWorldMatrix(), this._tempRay);
  24361. var intersections = mesh._submeshesOctree.intersectsRay(this._tempRay);
  24362. return intersections;
  24363. }
  24364. return this.scene._getDefaultSubMeshCandidates(mesh);
  24365. };
  24366. /**
  24367. * Return the list of sub meshes colliding with a collider
  24368. * @param mesh defines the mesh to find the submesh for
  24369. * @param collider defines the collider to evaluate the collision against
  24370. * @returns the list of colliding sub meshes
  24371. */
  24372. OctreeSceneComponent.prototype.getCollidingSubMeshCandidates = function (mesh, collider) {
  24373. if (mesh._submeshesOctree && mesh.useOctreeForCollisions) {
  24374. var radius = collider._velocityWorldLength + Math.max(collider._radius.x, collider._radius.y, collider._radius.z);
  24375. var intersections = mesh._submeshesOctree.intersects(collider._basePointWorld, radius);
  24376. return intersections;
  24377. }
  24378. return this.scene._getDefaultSubMeshCandidates(mesh);
  24379. };
  24380. /**
  24381. * Rebuilds the elements related to this component in case of
  24382. * context lost for instance.
  24383. */
  24384. OctreeSceneComponent.prototype.rebuild = function () {
  24385. // Nothing to do here.
  24386. };
  24387. /**
  24388. * Disposes the component and the associated ressources.
  24389. */
  24390. OctreeSceneComponent.prototype.dispose = function () {
  24391. // Nothing to do here.
  24392. };
  24393. return OctreeSceneComponent;
  24394. }());
  24395. /***/ }),
  24396. /***/ "./Culling/boundingBox.ts":
  24397. /*!********************************!*\
  24398. !*** ./Culling/boundingBox.ts ***!
  24399. \********************************/
  24400. /*! exports provided: BoundingBox */
  24401. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24402. "use strict";
  24403. __webpack_require__.r(__webpack_exports__);
  24404. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return BoundingBox; });
  24405. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24406. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24407. /**
  24408. * Class used to store bounding box information
  24409. */
  24410. var BoundingBox = /** @class */ (function () {
  24411. /**
  24412. * Creates a new bounding box
  24413. * @param min defines the minimum vector (in local space)
  24414. * @param max defines the maximum vector (in local space)
  24415. * @param worldMatrix defines the new world matrix
  24416. */
  24417. function BoundingBox(min, max, worldMatrix) {
  24418. /**
  24419. * Gets the 8 vectors representing the bounding box in local space
  24420. */
  24421. this.vectors = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24422. /**
  24423. * Gets the center of the bounding box in local space
  24424. */
  24425. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24426. /**
  24427. * Gets the center of the bounding box in world space
  24428. */
  24429. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24430. /**
  24431. * Gets the extend size in local space
  24432. */
  24433. this.extendSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24434. /**
  24435. * Gets the extend size in world space
  24436. */
  24437. this.extendSizeWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24438. /**
  24439. * Gets the OBB (object bounding box) directions
  24440. */
  24441. this.directions = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24442. /**
  24443. * Gets the 8 vectors representing the bounding box in world space
  24444. */
  24445. this.vectorsWorld = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24446. /**
  24447. * Gets the minimum vector in world space
  24448. */
  24449. this.minimumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24450. /**
  24451. * Gets the maximum vector in world space
  24452. */
  24453. this.maximumWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24454. /**
  24455. * Gets the minimum vector in local space
  24456. */
  24457. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24458. /**
  24459. * Gets the maximum vector in local space
  24460. */
  24461. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24462. this.reConstruct(min, max, worldMatrix);
  24463. }
  24464. // Methods
  24465. /**
  24466. * Recreates the entire bounding box from scratch as if we call the constructor in place
  24467. * @param min defines the new minimum vector (in local space)
  24468. * @param max defines the new maximum vector (in local space)
  24469. * @param worldMatrix defines the new world matrix
  24470. */
  24471. BoundingBox.prototype.reConstruct = function (min, max, worldMatrix) {
  24472. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24473. var vectors = this.vectors;
  24474. this.minimum.copyFromFloats(minX, minY, minZ);
  24475. this.maximum.copyFromFloats(maxX, maxY, maxZ);
  24476. vectors[0].copyFromFloats(minX, minY, minZ);
  24477. vectors[1].copyFromFloats(maxX, maxY, maxZ);
  24478. vectors[2].copyFromFloats(maxX, minY, minZ);
  24479. vectors[3].copyFromFloats(minX, maxY, minZ);
  24480. vectors[4].copyFromFloats(minX, minY, maxZ);
  24481. vectors[5].copyFromFloats(maxX, maxY, minZ);
  24482. vectors[6].copyFromFloats(minX, maxY, maxZ);
  24483. vectors[7].copyFromFloats(maxX, minY, maxZ);
  24484. // OBB
  24485. max.addToRef(min, this.center).scaleInPlace(0.5);
  24486. max.subtractToRef(min, this.extendSize).scaleInPlace(0.5);
  24487. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24488. };
  24489. /**
  24490. * Scale the current bounding box by applying a scale factor
  24491. * @param factor defines the scale factor to apply
  24492. * @returns the current bounding box
  24493. */
  24494. BoundingBox.prototype.scale = function (factor) {
  24495. var tmpVectors = BoundingBox.TmpVector3;
  24496. var diff = this.maximum.subtractToRef(this.minimum, tmpVectors[0]);
  24497. var len = diff.length();
  24498. diff.normalizeFromLength(len);
  24499. var distance = len * factor;
  24500. var newRadius = diff.scaleInPlace(distance * 0.5);
  24501. var min = this.center.subtractToRef(newRadius, tmpVectors[1]);
  24502. var max = this.center.addToRef(newRadius, tmpVectors[2]);
  24503. this.reConstruct(min, max, this._worldMatrix);
  24504. return this;
  24505. };
  24506. /**
  24507. * Gets the world matrix of the bounding box
  24508. * @returns a matrix
  24509. */
  24510. BoundingBox.prototype.getWorldMatrix = function () {
  24511. return this._worldMatrix;
  24512. };
  24513. /** @hidden */
  24514. BoundingBox.prototype._update = function (world) {
  24515. var minWorld = this.minimumWorld;
  24516. var maxWorld = this.maximumWorld;
  24517. var directions = this.directions;
  24518. var vectorsWorld = this.vectorsWorld;
  24519. var vectors = this.vectors;
  24520. if (!world.isIdentity()) {
  24521. minWorld.setAll(Number.MAX_VALUE);
  24522. maxWorld.setAll(-Number.MAX_VALUE);
  24523. for (var index = 0; index < 8; ++index) {
  24524. var v = vectorsWorld[index];
  24525. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(vectors[index], world, v);
  24526. minWorld.minimizeInPlace(v);
  24527. maxWorld.maximizeInPlace(v);
  24528. }
  24529. // Extend
  24530. maxWorld.subtractToRef(minWorld, this.extendSizeWorld).scaleInPlace(0.5);
  24531. maxWorld.addToRef(minWorld, this.centerWorld).scaleInPlace(0.5);
  24532. }
  24533. else {
  24534. minWorld.copyFrom(this.minimum);
  24535. maxWorld.copyFrom(this.maximum);
  24536. for (var index = 0; index < 8; ++index) {
  24537. vectorsWorld[index].copyFrom(vectors[index]);
  24538. }
  24539. // Extend
  24540. this.extendSizeWorld.copyFrom(this.extendSize);
  24541. this.centerWorld.copyFrom(this.center);
  24542. }
  24543. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 0, directions[0]);
  24544. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 4, directions[1]);
  24545. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(world.m, 8, directions[2]);
  24546. this._worldMatrix = world;
  24547. };
  24548. /**
  24549. * Tests if the bounding box is intersecting the frustum planes
  24550. * @param frustumPlanes defines the frustum planes to test
  24551. * @returns true if there is an intersection
  24552. */
  24553. BoundingBox.prototype.isInFrustum = function (frustumPlanes) {
  24554. return BoundingBox.IsInFrustum(this.vectorsWorld, frustumPlanes);
  24555. };
  24556. /**
  24557. * Tests if the bounding box is entirely inside the frustum planes
  24558. * @param frustumPlanes defines the frustum planes to test
  24559. * @returns true if there is an inclusion
  24560. */
  24561. BoundingBox.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24562. return BoundingBox.IsCompletelyInFrustum(this.vectorsWorld, frustumPlanes);
  24563. };
  24564. /**
  24565. * Tests if a point is inside the bounding box
  24566. * @param point defines the point to test
  24567. * @returns true if the point is inside the bounding box
  24568. */
  24569. BoundingBox.prototype.intersectsPoint = function (point) {
  24570. var min = this.minimumWorld;
  24571. var max = this.maximumWorld;
  24572. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24573. var pointX = point.x, pointY = point.y, pointZ = point.z;
  24574. var delta = -_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"];
  24575. if (maxX - pointX < delta || delta > pointX - minX) {
  24576. return false;
  24577. }
  24578. if (maxY - pointY < delta || delta > pointY - minY) {
  24579. return false;
  24580. }
  24581. if (maxZ - pointZ < delta || delta > pointZ - minZ) {
  24582. return false;
  24583. }
  24584. return true;
  24585. };
  24586. /**
  24587. * Tests if the bounding box intersects with a bounding sphere
  24588. * @param sphere defines the sphere to test
  24589. * @returns true if there is an intersection
  24590. */
  24591. BoundingBox.prototype.intersectsSphere = function (sphere) {
  24592. return BoundingBox.IntersectsSphere(this.minimumWorld, this.maximumWorld, sphere.centerWorld, sphere.radiusWorld);
  24593. };
  24594. /**
  24595. * Tests if the bounding box intersects with a box defined by a min and max vectors
  24596. * @param min defines the min vector to use
  24597. * @param max defines the max vector to use
  24598. * @returns true if there is an intersection
  24599. */
  24600. BoundingBox.prototype.intersectsMinMax = function (min, max) {
  24601. var myMin = this.minimumWorld;
  24602. var myMax = this.maximumWorld;
  24603. var myMinX = myMin.x, myMinY = myMin.y, myMinZ = myMin.z, myMaxX = myMax.x, myMaxY = myMax.y, myMaxZ = myMax.z;
  24604. var minX = min.x, minY = min.y, minZ = min.z, maxX = max.x, maxY = max.y, maxZ = max.z;
  24605. if (myMaxX < minX || myMinX > maxX) {
  24606. return false;
  24607. }
  24608. if (myMaxY < minY || myMinY > maxY) {
  24609. return false;
  24610. }
  24611. if (myMaxZ < minZ || myMinZ > maxZ) {
  24612. return false;
  24613. }
  24614. return true;
  24615. };
  24616. // Statics
  24617. /**
  24618. * Tests if two bounding boxes are intersections
  24619. * @param box0 defines the first box to test
  24620. * @param box1 defines the second box to test
  24621. * @returns true if there is an intersection
  24622. */
  24623. BoundingBox.Intersects = function (box0, box1) {
  24624. return box0.intersectsMinMax(box1.minimumWorld, box1.maximumWorld);
  24625. };
  24626. /**
  24627. * Tests if a bounding box defines by a min/max vectors intersects a sphere
  24628. * @param minPoint defines the minimum vector of the bounding box
  24629. * @param maxPoint defines the maximum vector of the bounding box
  24630. * @param sphereCenter defines the sphere center
  24631. * @param sphereRadius defines the sphere radius
  24632. * @returns true if there is an intersection
  24633. */
  24634. BoundingBox.IntersectsSphere = function (minPoint, maxPoint, sphereCenter, sphereRadius) {
  24635. var vector = BoundingBox.TmpVector3[0];
  24636. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].ClampToRef(sphereCenter, minPoint, maxPoint, vector);
  24637. var num = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphereCenter, vector);
  24638. return (num <= (sphereRadius * sphereRadius));
  24639. };
  24640. /**
  24641. * Tests if a bounding box defined with 8 vectors is entirely inside frustum planes
  24642. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24643. * @param frustumPlanes defines the frustum planes to test
  24644. * @return true if there is an inclusion
  24645. */
  24646. BoundingBox.IsCompletelyInFrustum = function (boundingVectors, frustumPlanes) {
  24647. for (var p = 0; p < 6; ++p) {
  24648. var frustumPlane = frustumPlanes[p];
  24649. for (var i = 0; i < 8; ++i) {
  24650. if (frustumPlane.dotCoordinate(boundingVectors[i]) < 0) {
  24651. return false;
  24652. }
  24653. }
  24654. }
  24655. return true;
  24656. };
  24657. /**
  24658. * Tests if a bounding box defined with 8 vectors intersects frustum planes
  24659. * @param boundingVectors defines an array of 8 vectors representing a bounding box
  24660. * @param frustumPlanes defines the frustum planes to test
  24661. * @return true if there is an intersection
  24662. */
  24663. BoundingBox.IsInFrustum = function (boundingVectors, frustumPlanes) {
  24664. for (var p = 0; p < 6; ++p) {
  24665. var canReturnFalse = true;
  24666. var frustumPlane = frustumPlanes[p];
  24667. for (var i = 0; i < 8; ++i) {
  24668. if (frustumPlane.dotCoordinate(boundingVectors[i]) >= 0) {
  24669. canReturnFalse = false;
  24670. break;
  24671. }
  24672. }
  24673. if (canReturnFalse) {
  24674. return false;
  24675. }
  24676. }
  24677. return true;
  24678. };
  24679. BoundingBox.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24680. return BoundingBox;
  24681. }());
  24682. /***/ }),
  24683. /***/ "./Culling/boundingInfo.ts":
  24684. /*!*********************************!*\
  24685. !*** ./Culling/boundingInfo.ts ***!
  24686. \*********************************/
  24687. /*! exports provided: BoundingInfo */
  24688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24689. "use strict";
  24690. __webpack_require__.r(__webpack_exports__);
  24691. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return BoundingInfo; });
  24692. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24693. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24694. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  24695. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  24696. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  24697. var _result0 = { min: 0, max: 0 };
  24698. var _result1 = { min: 0, max: 0 };
  24699. var computeBoxExtents = function (axis, box, result) {
  24700. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.centerWorld, axis);
  24701. var r0 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[0], axis)) * box.extendSize.x;
  24702. var r1 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[1], axis)) * box.extendSize.y;
  24703. var r2 = Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(box.directions[2], axis)) * box.extendSize.z;
  24704. var r = r0 + r1 + r2;
  24705. result.min = p - r;
  24706. result.max = p + r;
  24707. };
  24708. var axisOverlap = function (axis, box0, box1) {
  24709. computeBoxExtents(axis, box0, _result0);
  24710. computeBoxExtents(axis, box1, _result1);
  24711. return !(_result0.min > _result1.max || _result1.min > _result0.max);
  24712. };
  24713. /**
  24714. * Info for a bounding data of a mesh
  24715. */
  24716. var BoundingInfo = /** @class */ (function () {
  24717. /**
  24718. * Constructs bounding info
  24719. * @param minimum min vector of the bounding box/sphere
  24720. * @param maximum max vector of the bounding box/sphere
  24721. * @param worldMatrix defines the new world matrix
  24722. */
  24723. function BoundingInfo(minimum, maximum, worldMatrix) {
  24724. this._isLocked = false;
  24725. this.boundingBox = new _boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"](minimum, maximum, worldMatrix);
  24726. this.boundingSphere = new _boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"](minimum, maximum, worldMatrix);
  24727. }
  24728. /**
  24729. * Recreates the entire bounding info from scratch as if we call the constructor in place
  24730. * @param min defines the new minimum vector (in local space)
  24731. * @param max defines the new maximum vector (in local space)
  24732. * @param worldMatrix defines the new world matrix
  24733. */
  24734. BoundingInfo.prototype.reConstruct = function (min, max, worldMatrix) {
  24735. this.boundingBox.reConstruct(min, max, worldMatrix);
  24736. this.boundingSphere.reConstruct(min, max, worldMatrix);
  24737. };
  24738. Object.defineProperty(BoundingInfo.prototype, "minimum", {
  24739. /**
  24740. * min vector of the bounding box/sphere
  24741. */
  24742. get: function () {
  24743. return this.boundingBox.minimum;
  24744. },
  24745. enumerable: true,
  24746. configurable: true
  24747. });
  24748. Object.defineProperty(BoundingInfo.prototype, "maximum", {
  24749. /**
  24750. * max vector of the bounding box/sphere
  24751. */
  24752. get: function () {
  24753. return this.boundingBox.maximum;
  24754. },
  24755. enumerable: true,
  24756. configurable: true
  24757. });
  24758. Object.defineProperty(BoundingInfo.prototype, "isLocked", {
  24759. /**
  24760. * If the info is locked and won't be updated to avoid perf overhead
  24761. */
  24762. get: function () {
  24763. return this._isLocked;
  24764. },
  24765. set: function (value) {
  24766. this._isLocked = value;
  24767. },
  24768. enumerable: true,
  24769. configurable: true
  24770. });
  24771. // Methods
  24772. /**
  24773. * Updates the bounding sphere and box
  24774. * @param world world matrix to be used to update
  24775. */
  24776. BoundingInfo.prototype.update = function (world) {
  24777. if (this._isLocked) {
  24778. return;
  24779. }
  24780. this.boundingBox._update(world);
  24781. this.boundingSphere._update(world);
  24782. };
  24783. /**
  24784. * Recreate the bounding info to be centered around a specific point given a specific extend.
  24785. * @param center New center of the bounding info
  24786. * @param extend New extend of the bounding info
  24787. * @returns the current bounding info
  24788. */
  24789. BoundingInfo.prototype.centerOn = function (center, extend) {
  24790. var minimum = BoundingInfo.TmpVector3[0].copyFrom(center).subtractInPlace(extend);
  24791. var maximum = BoundingInfo.TmpVector3[1].copyFrom(center).addInPlace(extend);
  24792. this.boundingBox.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24793. this.boundingSphere.reConstruct(minimum, maximum, this.boundingBox.getWorldMatrix());
  24794. return this;
  24795. };
  24796. /**
  24797. * Scale the current bounding info by applying a scale factor
  24798. * @param factor defines the scale factor to apply
  24799. * @returns the current bounding info
  24800. */
  24801. BoundingInfo.prototype.scale = function (factor) {
  24802. this.boundingBox.scale(factor);
  24803. this.boundingSphere.scale(factor);
  24804. return this;
  24805. };
  24806. /**
  24807. * Returns `true` if the bounding info is within the frustum defined by the passed array of planes.
  24808. * @param frustumPlanes defines the frustum to test
  24809. * @param strategy defines the strategy to use for the culling (default is BABYLON.AbstractMesh.CULLINGSTRATEGY_STANDARD)
  24810. * @returns true if the bounding info is in the frustum planes
  24811. */
  24812. BoundingInfo.prototype.isInFrustum = function (frustumPlanes, strategy) {
  24813. if (strategy === void 0) { strategy = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD; }
  24814. var inclusionTest = (strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION || strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY);
  24815. if (inclusionTest) {
  24816. if (this.boundingSphere.isCenterInFrustum(frustumPlanes)) {
  24817. return true;
  24818. }
  24819. }
  24820. if (!this.boundingSphere.isInFrustum(frustumPlanes)) {
  24821. return false;
  24822. }
  24823. var bSphereOnlyTest = (strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY || strategy === _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY);
  24824. if (bSphereOnlyTest) {
  24825. return true;
  24826. }
  24827. return this.boundingBox.isInFrustum(frustumPlanes);
  24828. };
  24829. Object.defineProperty(BoundingInfo.prototype, "diagonalLength", {
  24830. /**
  24831. * Gets the world distance between the min and max points of the bounding box
  24832. */
  24833. get: function () {
  24834. var boundingBox = this.boundingBox;
  24835. var diag = boundingBox.maximumWorld.subtractToRef(boundingBox.minimumWorld, BoundingInfo.TmpVector3[0]);
  24836. return diag.length();
  24837. },
  24838. enumerable: true,
  24839. configurable: true
  24840. });
  24841. /**
  24842. * Checks if a cullable object (mesh...) is in the camera frustum
  24843. * Unlike isInFrustum this cheks the full bounding box
  24844. * @param frustumPlanes Camera near/planes
  24845. * @returns true if the object is in frustum otherwise false
  24846. */
  24847. BoundingInfo.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  24848. return this.boundingBox.isCompletelyInFrustum(frustumPlanes);
  24849. };
  24850. /** @hidden */
  24851. BoundingInfo.prototype._checkCollision = function (collider) {
  24852. return collider._canDoCollision(this.boundingSphere.centerWorld, this.boundingSphere.radiusWorld, this.boundingBox.minimumWorld, this.boundingBox.maximumWorld);
  24853. };
  24854. /**
  24855. * Checks if a point is inside the bounding box and bounding sphere or the mesh
  24856. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24857. * @param point the point to check intersection with
  24858. * @returns if the point intersects
  24859. */
  24860. BoundingInfo.prototype.intersectsPoint = function (point) {
  24861. if (!this.boundingSphere.centerWorld) {
  24862. return false;
  24863. }
  24864. if (!this.boundingSphere.intersectsPoint(point)) {
  24865. return false;
  24866. }
  24867. if (!this.boundingBox.intersectsPoint(point)) {
  24868. return false;
  24869. }
  24870. return true;
  24871. };
  24872. /**
  24873. * Checks if another bounding info intersects the bounding box and bounding sphere or the mesh
  24874. * @see https://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  24875. * @param boundingInfo the bounding info to check intersection with
  24876. * @param precise if the intersection should be done using OBB
  24877. * @returns if the bounding info intersects
  24878. */
  24879. BoundingInfo.prototype.intersects = function (boundingInfo, precise) {
  24880. if (!_boundingSphere__WEBPACK_IMPORTED_MODULE_4__["BoundingSphere"].Intersects(this.boundingSphere, boundingInfo.boundingSphere)) {
  24881. return false;
  24882. }
  24883. if (!_boundingBox__WEBPACK_IMPORTED_MODULE_3__["BoundingBox"].Intersects(this.boundingBox, boundingInfo.boundingBox)) {
  24884. return false;
  24885. }
  24886. if (!precise) {
  24887. return true;
  24888. }
  24889. var box0 = this.boundingBox;
  24890. var box1 = boundingInfo.boundingBox;
  24891. if (!axisOverlap(box0.directions[0], box0, box1)) {
  24892. return false;
  24893. }
  24894. if (!axisOverlap(box0.directions[1], box0, box1)) {
  24895. return false;
  24896. }
  24897. if (!axisOverlap(box0.directions[2], box0, box1)) {
  24898. return false;
  24899. }
  24900. if (!axisOverlap(box1.directions[0], box0, box1)) {
  24901. return false;
  24902. }
  24903. if (!axisOverlap(box1.directions[1], box0, box1)) {
  24904. return false;
  24905. }
  24906. if (!axisOverlap(box1.directions[2], box0, box1)) {
  24907. return false;
  24908. }
  24909. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[0]), box0, box1)) {
  24910. return false;
  24911. }
  24912. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[1]), box0, box1)) {
  24913. return false;
  24914. }
  24915. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[0], box1.directions[2]), box0, box1)) {
  24916. return false;
  24917. }
  24918. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[0]), box0, box1)) {
  24919. return false;
  24920. }
  24921. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[1]), box0, box1)) {
  24922. return false;
  24923. }
  24924. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[1], box1.directions[2]), box0, box1)) {
  24925. return false;
  24926. }
  24927. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[0]), box0, box1)) {
  24928. return false;
  24929. }
  24930. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[1]), box0, box1)) {
  24931. return false;
  24932. }
  24933. if (!axisOverlap(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(box0.directions[2], box1.directions[2]), box0, box1)) {
  24934. return false;
  24935. }
  24936. return true;
  24937. };
  24938. BoundingInfo.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  24939. return BoundingInfo;
  24940. }());
  24941. /***/ }),
  24942. /***/ "./Culling/boundingSphere.ts":
  24943. /*!***********************************!*\
  24944. !*** ./Culling/boundingSphere.ts ***!
  24945. \***********************************/
  24946. /*! exports provided: BoundingSphere */
  24947. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  24948. "use strict";
  24949. __webpack_require__.r(__webpack_exports__);
  24950. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return BoundingSphere; });
  24951. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  24952. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  24953. /**
  24954. * Class used to store bounding sphere information
  24955. */
  24956. var BoundingSphere = /** @class */ (function () {
  24957. /**
  24958. * Creates a new bounding sphere
  24959. * @param min defines the minimum vector (in local space)
  24960. * @param max defines the maximum vector (in local space)
  24961. * @param worldMatrix defines the new world matrix
  24962. */
  24963. function BoundingSphere(min, max, worldMatrix) {
  24964. /**
  24965. * Gets the center of the bounding sphere in local space
  24966. */
  24967. this.center = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24968. /**
  24969. * Gets the center of the bounding sphere in world space
  24970. */
  24971. this.centerWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24972. /**
  24973. * Gets the minimum vector in local space
  24974. */
  24975. this.minimum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24976. /**
  24977. * Gets the maximum vector in local space
  24978. */
  24979. this.maximum = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  24980. this.reConstruct(min, max, worldMatrix);
  24981. }
  24982. /**
  24983. * Recreates the entire bounding sphere from scratch as if we call the constructor in place
  24984. * @param min defines the new minimum vector (in local space)
  24985. * @param max defines the new maximum vector (in local space)
  24986. * @param worldMatrix defines the new world matrix
  24987. */
  24988. BoundingSphere.prototype.reConstruct = function (min, max, worldMatrix) {
  24989. this.minimum.copyFrom(min);
  24990. this.maximum.copyFrom(max);
  24991. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(min, max);
  24992. max.addToRef(min, this.center).scaleInPlace(0.5);
  24993. this.radius = distance * 0.5;
  24994. this._update(worldMatrix || _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly);
  24995. };
  24996. /**
  24997. * Scale the current bounding sphere by applying a scale factor
  24998. * @param factor defines the scale factor to apply
  24999. * @returns the current bounding box
  25000. */
  25001. BoundingSphere.prototype.scale = function (factor) {
  25002. var newRadius = this.radius * factor;
  25003. var tmpVectors = BoundingSphere.TmpVector3;
  25004. var tempRadiusVector = tmpVectors[0].setAll(newRadius);
  25005. var min = this.center.subtractToRef(tempRadiusVector, tmpVectors[1]);
  25006. var max = this.center.addToRef(tempRadiusVector, tmpVectors[2]);
  25007. this.reConstruct(min, max, this._worldMatrix);
  25008. return this;
  25009. };
  25010. /**
  25011. * Gets the world matrix of the bounding box
  25012. * @returns a matrix
  25013. */
  25014. BoundingSphere.prototype.getWorldMatrix = function () {
  25015. return this._worldMatrix;
  25016. };
  25017. // Methods
  25018. /** @hidden */
  25019. BoundingSphere.prototype._update = function (worldMatrix) {
  25020. if (!worldMatrix.isIdentity()) {
  25021. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(this.center, worldMatrix, this.centerWorld);
  25022. var tempVector = BoundingSphere.TmpVector3[0];
  25023. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(1.0, 1.0, 1.0, worldMatrix, tempVector);
  25024. this.radiusWorld = Math.max(Math.abs(tempVector.x), Math.abs(tempVector.y), Math.abs(tempVector.z)) * this.radius;
  25025. }
  25026. else {
  25027. this.centerWorld.copyFrom(this.center);
  25028. this.radiusWorld = this.radius;
  25029. }
  25030. };
  25031. /**
  25032. * Tests if the bounding sphere is intersecting the frustum planes
  25033. * @param frustumPlanes defines the frustum planes to test
  25034. * @returns true if there is an intersection
  25035. */
  25036. BoundingSphere.prototype.isInFrustum = function (frustumPlanes) {
  25037. var center = this.centerWorld;
  25038. var radius = this.radiusWorld;
  25039. for (var i = 0; i < 6; i++) {
  25040. if (frustumPlanes[i].dotCoordinate(center) <= -radius) {
  25041. return false;
  25042. }
  25043. }
  25044. return true;
  25045. };
  25046. /**
  25047. * Tests if the bounding sphere center is in between the frustum planes.
  25048. * Used for optimistic fast inclusion.
  25049. * @param frustumPlanes defines the frustum planes to test
  25050. * @returns true if the sphere center is in between the frustum planes
  25051. */
  25052. BoundingSphere.prototype.isCenterInFrustum = function (frustumPlanes) {
  25053. var center = this.centerWorld;
  25054. for (var i = 0; i < 6; i++) {
  25055. if (frustumPlanes[i].dotCoordinate(center) < 0) {
  25056. return false;
  25057. }
  25058. }
  25059. return true;
  25060. };
  25061. /**
  25062. * Tests if a point is inside the bounding sphere
  25063. * @param point defines the point to test
  25064. * @returns true if the point is inside the bounding sphere
  25065. */
  25066. BoundingSphere.prototype.intersectsPoint = function (point) {
  25067. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(this.centerWorld, point);
  25068. if (this.radiusWorld * this.radiusWorld < squareDistance) {
  25069. return false;
  25070. }
  25071. return true;
  25072. };
  25073. // Statics
  25074. /**
  25075. * Checks if two sphere intersct
  25076. * @param sphere0 sphere 0
  25077. * @param sphere1 sphere 1
  25078. * @returns true if the speres intersect
  25079. */
  25080. BoundingSphere.Intersects = function (sphere0, sphere1) {
  25081. var squareDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].DistanceSquared(sphere0.centerWorld, sphere1.centerWorld);
  25082. var radiusSum = sphere0.radiusWorld + sphere1.radiusWorld;
  25083. if (radiusSum * radiusSum < squareDistance) {
  25084. return false;
  25085. }
  25086. return true;
  25087. };
  25088. BoundingSphere.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25089. return BoundingSphere;
  25090. }());
  25091. /***/ }),
  25092. /***/ "./Culling/index.ts":
  25093. /*!**************************!*\
  25094. !*** ./Culling/index.ts ***!
  25095. \**************************/
  25096. /*! exports provided: BoundingBox, BoundingInfo, BoundingSphere, Ray, Octree, OctreeBlock, OctreeSceneComponent */
  25097. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25098. "use strict";
  25099. __webpack_require__.r(__webpack_exports__);
  25100. /* harmony import */ var _boundingBox__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBox */ "./Culling/boundingBox.ts");
  25101. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _boundingBox__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  25102. /* harmony import */ var _boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boundingInfo */ "./Culling/boundingInfo.ts");
  25103. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"]; });
  25104. /* harmony import */ var _boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingSphere */ "./Culling/boundingSphere.ts");
  25105. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"]; });
  25106. /* harmony import */ var _Octrees_index__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Octrees/index */ "./Culling/Octrees/index.ts");
  25107. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["Octree"]; });
  25108. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeBlock"]; });
  25109. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Octrees_index__WEBPACK_IMPORTED_MODULE_3__["OctreeSceneComponent"]; });
  25110. /* harmony import */ var _ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ray */ "./Culling/ray.ts");
  25111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _ray__WEBPACK_IMPORTED_MODULE_4__["Ray"]; });
  25112. /***/ }),
  25113. /***/ "./Culling/ray.ts":
  25114. /*!************************!*\
  25115. !*** ./Culling/ray.ts ***!
  25116. \************************/
  25117. /*! exports provided: Ray */
  25118. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25119. "use strict";
  25120. __webpack_require__.r(__webpack_exports__);
  25121. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return Ray; });
  25122. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  25123. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25124. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  25125. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  25126. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25127. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  25128. /**
  25129. * Class representing a ray with position and direction
  25130. */
  25131. var Ray = /** @class */ (function () {
  25132. /**
  25133. * Creates a new ray
  25134. * @param origin origin point
  25135. * @param direction direction
  25136. * @param length length of the ray
  25137. */
  25138. function Ray(
  25139. /** origin point */
  25140. origin,
  25141. /** direction */
  25142. direction,
  25143. /** length of the ray */
  25144. length) {
  25145. if (length === void 0) { length = Number.MAX_VALUE; }
  25146. this.origin = origin;
  25147. this.direction = direction;
  25148. this.length = length;
  25149. }
  25150. // Methods
  25151. /**
  25152. * Checks if the ray intersects a box
  25153. * @param minimum bound of the box
  25154. * @param maximum bound of the box
  25155. * @param intersectionTreshold extra extend to be added to the box in all direction
  25156. * @returns if the box was hit
  25157. */
  25158. Ray.prototype.intersectsBoxMinMax = function (minimum, maximum, intersectionTreshold) {
  25159. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25160. var newMinimum = Ray.TmpVector3[0].copyFromFloats(minimum.x - intersectionTreshold, minimum.y - intersectionTreshold, minimum.z - intersectionTreshold);
  25161. var newMaximum = Ray.TmpVector3[1].copyFromFloats(maximum.x + intersectionTreshold, maximum.y + intersectionTreshold, maximum.z + intersectionTreshold);
  25162. var d = 0.0;
  25163. var maxValue = Number.MAX_VALUE;
  25164. var inv;
  25165. var min;
  25166. var max;
  25167. var temp;
  25168. if (Math.abs(this.direction.x) < 0.0000001) {
  25169. if (this.origin.x < newMinimum.x || this.origin.x > newMaximum.x) {
  25170. return false;
  25171. }
  25172. }
  25173. else {
  25174. inv = 1.0 / this.direction.x;
  25175. min = (newMinimum.x - this.origin.x) * inv;
  25176. max = (newMaximum.x - this.origin.x) * inv;
  25177. if (max === -Infinity) {
  25178. max = Infinity;
  25179. }
  25180. if (min > max) {
  25181. temp = min;
  25182. min = max;
  25183. max = temp;
  25184. }
  25185. d = Math.max(min, d);
  25186. maxValue = Math.min(max, maxValue);
  25187. if (d > maxValue) {
  25188. return false;
  25189. }
  25190. }
  25191. if (Math.abs(this.direction.y) < 0.0000001) {
  25192. if (this.origin.y < newMinimum.y || this.origin.y > newMaximum.y) {
  25193. return false;
  25194. }
  25195. }
  25196. else {
  25197. inv = 1.0 / this.direction.y;
  25198. min = (newMinimum.y - this.origin.y) * inv;
  25199. max = (newMaximum.y - this.origin.y) * inv;
  25200. if (max === -Infinity) {
  25201. max = Infinity;
  25202. }
  25203. if (min > max) {
  25204. temp = min;
  25205. min = max;
  25206. max = temp;
  25207. }
  25208. d = Math.max(min, d);
  25209. maxValue = Math.min(max, maxValue);
  25210. if (d > maxValue) {
  25211. return false;
  25212. }
  25213. }
  25214. if (Math.abs(this.direction.z) < 0.0000001) {
  25215. if (this.origin.z < newMinimum.z || this.origin.z > newMaximum.z) {
  25216. return false;
  25217. }
  25218. }
  25219. else {
  25220. inv = 1.0 / this.direction.z;
  25221. min = (newMinimum.z - this.origin.z) * inv;
  25222. max = (newMaximum.z - this.origin.z) * inv;
  25223. if (max === -Infinity) {
  25224. max = Infinity;
  25225. }
  25226. if (min > max) {
  25227. temp = min;
  25228. min = max;
  25229. max = temp;
  25230. }
  25231. d = Math.max(min, d);
  25232. maxValue = Math.min(max, maxValue);
  25233. if (d > maxValue) {
  25234. return false;
  25235. }
  25236. }
  25237. return true;
  25238. };
  25239. /**
  25240. * Checks if the ray intersects a box
  25241. * @param box the bounding box to check
  25242. * @param intersectionTreshold extra extend to be added to the BoundingBox in all direction
  25243. * @returns if the box was hit
  25244. */
  25245. Ray.prototype.intersectsBox = function (box, intersectionTreshold) {
  25246. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25247. return this.intersectsBoxMinMax(box.minimum, box.maximum, intersectionTreshold);
  25248. };
  25249. /**
  25250. * If the ray hits a sphere
  25251. * @param sphere the bounding sphere to check
  25252. * @param intersectionTreshold extra extend to be added to the BoundingSphere in all direction
  25253. * @returns true if it hits the sphere
  25254. */
  25255. Ray.prototype.intersectsSphere = function (sphere, intersectionTreshold) {
  25256. if (intersectionTreshold === void 0) { intersectionTreshold = 0; }
  25257. var x = sphere.center.x - this.origin.x;
  25258. var y = sphere.center.y - this.origin.y;
  25259. var z = sphere.center.z - this.origin.z;
  25260. var pyth = (x * x) + (y * y) + (z * z);
  25261. var radius = sphere.radius + intersectionTreshold;
  25262. var rr = radius * radius;
  25263. if (pyth <= rr) {
  25264. return true;
  25265. }
  25266. var dot = (x * this.direction.x) + (y * this.direction.y) + (z * this.direction.z);
  25267. if (dot < 0.0) {
  25268. return false;
  25269. }
  25270. var temp = pyth - (dot * dot);
  25271. return temp <= rr;
  25272. };
  25273. /**
  25274. * If the ray hits a triange
  25275. * @param vertex0 triangle vertex
  25276. * @param vertex1 triangle vertex
  25277. * @param vertex2 triangle vertex
  25278. * @returns intersection information if hit
  25279. */
  25280. Ray.prototype.intersectsTriangle = function (vertex0, vertex1, vertex2) {
  25281. var edge1 = Ray.TmpVector3[0];
  25282. var edge2 = Ray.TmpVector3[1];
  25283. var pvec = Ray.TmpVector3[2];
  25284. var tvec = Ray.TmpVector3[3];
  25285. var qvec = Ray.TmpVector3[4];
  25286. vertex1.subtractToRef(vertex0, edge1);
  25287. vertex2.subtractToRef(vertex0, edge2);
  25288. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(this.direction, edge2, pvec);
  25289. var det = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge1, pvec);
  25290. if (det === 0) {
  25291. return null;
  25292. }
  25293. var invdet = 1 / det;
  25294. this.origin.subtractToRef(vertex0, tvec);
  25295. var bu = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(tvec, pvec) * invdet;
  25296. if (bu < 0 || bu > 1.0) {
  25297. return null;
  25298. }
  25299. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(tvec, edge1, qvec);
  25300. var bv = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this.direction, qvec) * invdet;
  25301. if (bv < 0 || bu + bv > 1.0) {
  25302. return null;
  25303. }
  25304. //check if the distance is longer than the predefined length.
  25305. var distance = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(edge2, qvec) * invdet;
  25306. if (distance > this.length) {
  25307. return null;
  25308. }
  25309. return new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](bu, bv, distance);
  25310. };
  25311. /**
  25312. * Checks if ray intersects a plane
  25313. * @param plane the plane to check
  25314. * @returns the distance away it was hit
  25315. */
  25316. Ray.prototype.intersectsPlane = function (plane) {
  25317. var distance;
  25318. var result1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.direction);
  25319. if (Math.abs(result1) < 9.99999997475243E-07) {
  25320. return null;
  25321. }
  25322. else {
  25323. var result2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(plane.normal, this.origin);
  25324. distance = (-plane.d - result2) / result1;
  25325. if (distance < 0.0) {
  25326. if (distance < -9.99999997475243E-07) {
  25327. return null;
  25328. }
  25329. else {
  25330. return 0;
  25331. }
  25332. }
  25333. return distance;
  25334. }
  25335. };
  25336. /**
  25337. * Checks if ray intersects a mesh
  25338. * @param mesh the mesh to check
  25339. * @param fastCheck if only the bounding box should checked
  25340. * @returns picking info of the intersecton
  25341. */
  25342. Ray.prototype.intersectsMesh = function (mesh, fastCheck) {
  25343. var tm = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25344. mesh.getWorldMatrix().invertToRef(tm);
  25345. if (this._tmpRay) {
  25346. Ray.TransformToRef(this, tm, this._tmpRay);
  25347. }
  25348. else {
  25349. this._tmpRay = Ray.Transform(this, tm);
  25350. }
  25351. return mesh.intersects(this._tmpRay, fastCheck);
  25352. };
  25353. /**
  25354. * Checks if ray intersects a mesh
  25355. * @param meshes the meshes to check
  25356. * @param fastCheck if only the bounding box should checked
  25357. * @param results array to store result in
  25358. * @returns Array of picking infos
  25359. */
  25360. Ray.prototype.intersectsMeshes = function (meshes, fastCheck, results) {
  25361. if (results) {
  25362. results.length = 0;
  25363. }
  25364. else {
  25365. results = [];
  25366. }
  25367. for (var i = 0; i < meshes.length; i++) {
  25368. var pickInfo = this.intersectsMesh(meshes[i], fastCheck);
  25369. if (pickInfo.hit) {
  25370. results.push(pickInfo);
  25371. }
  25372. }
  25373. results.sort(this._comparePickingInfo);
  25374. return results;
  25375. };
  25376. Ray.prototype._comparePickingInfo = function (pickingInfoA, pickingInfoB) {
  25377. if (pickingInfoA.distance < pickingInfoB.distance) {
  25378. return -1;
  25379. }
  25380. else if (pickingInfoA.distance > pickingInfoB.distance) {
  25381. return 1;
  25382. }
  25383. else {
  25384. return 0;
  25385. }
  25386. };
  25387. /**
  25388. * Intersection test between the ray and a given segment whithin a given tolerance (threshold)
  25389. * @param sega the first point of the segment to test the intersection against
  25390. * @param segb the second point of the segment to test the intersection against
  25391. * @param threshold the tolerance margin, if the ray doesn't intersect the segment but is close to the given threshold, the intersection is successful
  25392. * @return the distance from the ray origin to the intersection point if there's intersection, or -1 if there's no intersection
  25393. */
  25394. Ray.prototype.intersectionSegment = function (sega, segb, threshold) {
  25395. var o = this.origin;
  25396. var u = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25397. var rsegb = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  25398. var v = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25399. var w = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25400. segb.subtractToRef(sega, u);
  25401. this.direction.scaleToRef(Ray.rayl, v);
  25402. o.addToRef(v, rsegb);
  25403. sega.subtractToRef(o, w);
  25404. var a = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, u); // always >= 0
  25405. var b = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, v);
  25406. var c = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, v); // always >= 0
  25407. var d = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(u, w);
  25408. var e = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(v, w);
  25409. var D = a * c - b * b; // always >= 0
  25410. var sc, sN, sD = D; // sc = sN / sD, default sD = D >= 0
  25411. var tc, tN, tD = D; // tc = tN / tD, default tD = D >= 0
  25412. // compute the line parameters of the two closest points
  25413. if (D < Ray.smallnum) { // the lines are almost parallel
  25414. sN = 0.0; // force using point P0 on segment S1
  25415. sD = 1.0; // to prevent possible division by 0.0 later
  25416. tN = e;
  25417. tD = c;
  25418. }
  25419. else { // get the closest points on the infinite lines
  25420. sN = (b * e - c * d);
  25421. tN = (a * e - b * d);
  25422. if (sN < 0.0) { // sc < 0 => the s=0 edge is visible
  25423. sN = 0.0;
  25424. tN = e;
  25425. tD = c;
  25426. }
  25427. else if (sN > sD) { // sc > 1 => the s=1 edge is visible
  25428. sN = sD;
  25429. tN = e + b;
  25430. tD = c;
  25431. }
  25432. }
  25433. if (tN < 0.0) { // tc < 0 => the t=0 edge is visible
  25434. tN = 0.0;
  25435. // recompute sc for this edge
  25436. if (-d < 0.0) {
  25437. sN = 0.0;
  25438. }
  25439. else if (-d > a) {
  25440. sN = sD;
  25441. }
  25442. else {
  25443. sN = -d;
  25444. sD = a;
  25445. }
  25446. }
  25447. else if (tN > tD) { // tc > 1 => the t=1 edge is visible
  25448. tN = tD;
  25449. // recompute sc for this edge
  25450. if ((-d + b) < 0.0) {
  25451. sN = 0;
  25452. }
  25453. else if ((-d + b) > a) {
  25454. sN = sD;
  25455. }
  25456. else {
  25457. sN = (-d + b);
  25458. sD = a;
  25459. }
  25460. }
  25461. // finally do the division to get sc and tc
  25462. sc = (Math.abs(sN) < Ray.smallnum ? 0.0 : sN / sD);
  25463. tc = (Math.abs(tN) < Ray.smallnum ? 0.0 : tN / tD);
  25464. // get the difference of the two closest points
  25465. var qtc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  25466. v.scaleToRef(tc, qtc);
  25467. var qsc = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  25468. u.scaleToRef(sc, qsc);
  25469. qsc.addInPlace(w);
  25470. var dP = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  25471. qsc.subtractToRef(qtc, dP); // = S1(sc) - S2(tc)
  25472. var isIntersected = (tc > 0) && (tc <= this.length) && (dP.lengthSquared() < (threshold * threshold)); // return intersection result
  25473. if (isIntersected) {
  25474. return qsc.length();
  25475. }
  25476. return -1;
  25477. };
  25478. /**
  25479. * Update the ray from viewport position
  25480. * @param x position
  25481. * @param y y position
  25482. * @param viewportWidth viewport width
  25483. * @param viewportHeight viewport height
  25484. * @param world world matrix
  25485. * @param view view matrix
  25486. * @param projection projection matrix
  25487. * @returns this ray updated
  25488. */
  25489. Ray.prototype.update = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25490. this.unprojectRayToRef(x, y, viewportWidth, viewportHeight, world, view, projection);
  25491. return this;
  25492. };
  25493. // Statics
  25494. /**
  25495. * Creates a ray with origin and direction of 0,0,0
  25496. * @returns the new ray
  25497. */
  25498. Ray.Zero = function () {
  25499. return new Ray(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero());
  25500. };
  25501. /**
  25502. * Creates a new ray from screen space and viewport
  25503. * @param x position
  25504. * @param y y position
  25505. * @param viewportWidth viewport width
  25506. * @param viewportHeight viewport height
  25507. * @param world world matrix
  25508. * @param view view matrix
  25509. * @param projection projection matrix
  25510. * @returns new ray
  25511. */
  25512. Ray.CreateNew = function (x, y, viewportWidth, viewportHeight, world, view, projection) {
  25513. var result = Ray.Zero();
  25514. return result.update(x, y, viewportWidth, viewportHeight, world, view, projection);
  25515. };
  25516. /**
  25517. * Function will create a new transformed ray starting from origin and ending at the end point. Ray's length will be set, and ray will be
  25518. * transformed to the given world matrix.
  25519. * @param origin The origin point
  25520. * @param end The end point
  25521. * @param world a matrix to transform the ray to. Default is the identity matrix.
  25522. * @returns the new ray
  25523. */
  25524. Ray.CreateNewFromTo = function (origin, end, world) {
  25525. if (world === void 0) { world = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly; }
  25526. var direction = end.subtract(origin);
  25527. var length = Math.sqrt((direction.x * direction.x) + (direction.y * direction.y) + (direction.z * direction.z));
  25528. direction.normalize();
  25529. return Ray.Transform(new Ray(origin, direction, length), world);
  25530. };
  25531. /**
  25532. * Transforms a ray by a matrix
  25533. * @param ray ray to transform
  25534. * @param matrix matrix to apply
  25535. * @returns the resulting new ray
  25536. */
  25537. Ray.Transform = function (ray, matrix) {
  25538. var result = new Ray(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 0));
  25539. Ray.TransformToRef(ray, matrix, result);
  25540. return result;
  25541. };
  25542. /**
  25543. * Transforms a ray by a matrix
  25544. * @param ray ray to transform
  25545. * @param matrix matrix to apply
  25546. * @param result ray to store result in
  25547. */
  25548. Ray.TransformToRef = function (ray, matrix, result) {
  25549. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesToRef(ray.origin, matrix, result.origin);
  25550. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalToRef(ray.direction, matrix, result.direction);
  25551. result.length = ray.length;
  25552. var dir = result.direction;
  25553. var len = dir.length();
  25554. if (!(len === 0 || len === 1)) {
  25555. var num = 1.0 / len;
  25556. dir.x *= num;
  25557. dir.y *= num;
  25558. dir.z *= num;
  25559. result.length *= len;
  25560. }
  25561. };
  25562. /**
  25563. * Unproject a ray from screen space to object space
  25564. * @param sourceX defines the screen space x coordinate to use
  25565. * @param sourceY defines the screen space y coordinate to use
  25566. * @param viewportWidth defines the current width of the viewport
  25567. * @param viewportHeight defines the current height of the viewport
  25568. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  25569. * @param view defines the view matrix to use
  25570. * @param projection defines the projection matrix to use
  25571. */
  25572. Ray.prototype.unprojectRayToRef = function (sourceX, sourceY, viewportWidth, viewportHeight, world, view, projection) {
  25573. var matrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[0];
  25574. world.multiplyToRef(view, matrix);
  25575. matrix.multiplyToRef(projection, matrix);
  25576. matrix.invert();
  25577. var nearScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  25578. nearScreenSource.x = sourceX / viewportWidth * 2 - 1;
  25579. nearScreenSource.y = -(sourceY / viewportHeight * 2 - 1);
  25580. nearScreenSource.z = -1.0;
  25581. var farScreenSource = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1].copyFromFloats(nearScreenSource.x, nearScreenSource.y, 1.0);
  25582. var nearVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  25583. var farVec3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  25584. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(nearScreenSource, matrix, nearVec3);
  25585. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]._UnprojectFromInvertedMatrixToRef(farScreenSource, matrix, farVec3);
  25586. this.origin.copyFrom(nearVec3);
  25587. farVec3.subtractToRef(nearVec3, this.direction);
  25588. this.direction.normalize();
  25589. };
  25590. Ray.TmpVector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero);
  25591. Ray.smallnum = 0.00000001;
  25592. Ray.rayl = 10e8;
  25593. return Ray;
  25594. }());
  25595. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  25596. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25597. var result = Ray.Zero();
  25598. this.createPickingRayToRef(x, y, world, result, camera, cameraViewSpace);
  25599. return result;
  25600. };
  25601. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  25602. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  25603. var engine = this.getEngine();
  25604. if (!camera) {
  25605. if (!this.activeCamera) {
  25606. throw new Error("Active camera not set");
  25607. }
  25608. camera = this.activeCamera;
  25609. }
  25610. var cameraViewport = camera.viewport;
  25611. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25612. // Moving coordinates to local viewport world
  25613. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25614. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25615. result.update(x, y, viewport.width, viewport.height, world ? world : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly, cameraViewSpace ? _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].IdentityReadOnly : camera.getViewMatrix(), camera.getProjectionMatrix());
  25616. return this;
  25617. };
  25618. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  25619. var result = Ray.Zero();
  25620. this.createPickingRayInCameraSpaceToRef(x, y, result, camera);
  25621. return result;
  25622. };
  25623. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  25624. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25625. return this;
  25626. }
  25627. var engine = this.getEngine();
  25628. if (!camera) {
  25629. if (!this.activeCamera) {
  25630. throw new Error("Active camera not set");
  25631. }
  25632. camera = this.activeCamera;
  25633. }
  25634. var cameraViewport = camera.viewport;
  25635. var viewport = cameraViewport.toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  25636. var identity = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25637. // Moving coordinates to local viewport world
  25638. x = x / engine.getHardwareScalingLevel() - viewport.x;
  25639. y = y / engine.getHardwareScalingLevel() - (engine.getRenderHeight() - viewport.y - viewport.height);
  25640. result.update(x, y, viewport.width, viewport.height, identity, identity, camera.getProjectionMatrix());
  25641. return this;
  25642. };
  25643. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalPick = function (rayFunction, predicate, fastCheck) {
  25644. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25645. return null;
  25646. }
  25647. var pickingInfo = null;
  25648. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25649. var mesh = this.meshes[meshIndex];
  25650. if (predicate) {
  25651. if (!predicate(mesh)) {
  25652. continue;
  25653. }
  25654. }
  25655. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25656. continue;
  25657. }
  25658. var world = mesh.getWorldMatrix();
  25659. var ray = rayFunction(world);
  25660. var result = mesh.intersects(ray, fastCheck);
  25661. if (!result || !result.hit) {
  25662. continue;
  25663. }
  25664. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  25665. continue;
  25666. }
  25667. pickingInfo = result;
  25668. if (fastCheck) {
  25669. break;
  25670. }
  25671. }
  25672. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]();
  25673. };
  25674. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._internalMultiPick = function (rayFunction, predicate) {
  25675. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25676. return null;
  25677. }
  25678. var pickingInfos = new Array();
  25679. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  25680. var mesh = this.meshes[meshIndex];
  25681. if (predicate) {
  25682. if (!predicate(mesh)) {
  25683. continue;
  25684. }
  25685. }
  25686. else if (!mesh.isEnabled() || !mesh.isVisible || !mesh.isPickable) {
  25687. continue;
  25688. }
  25689. var world = mesh.getWorldMatrix();
  25690. var ray = rayFunction(world);
  25691. var result = mesh.intersects(ray, false);
  25692. if (!result || !result.hit) {
  25693. continue;
  25694. }
  25695. pickingInfos.push(result);
  25696. }
  25697. return pickingInfos;
  25698. };
  25699. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pick = function (x, y, predicate, fastCheck, camera) {
  25700. var _this = this;
  25701. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_2__["PickingInfo"]) {
  25702. return null;
  25703. }
  25704. var result = this._internalPick(function (world) {
  25705. if (!_this._tempPickingRay) {
  25706. _this._tempPickingRay = Ray.Zero();
  25707. }
  25708. _this.createPickingRayToRef(x, y, world, _this._tempPickingRay, camera || null);
  25709. return _this._tempPickingRay;
  25710. }, predicate, fastCheck);
  25711. if (result) {
  25712. result.ray = this.createPickingRay(x, y, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), camera || null);
  25713. }
  25714. return result;
  25715. };
  25716. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.pickWithRay = function (ray, predicate, fastCheck) {
  25717. var _this = this;
  25718. var result = this._internalPick(function (world) {
  25719. if (!_this._pickWithRayInverseMatrix) {
  25720. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25721. }
  25722. world.invertToRef(_this._pickWithRayInverseMatrix);
  25723. if (!_this._cachedRayForTransform) {
  25724. _this._cachedRayForTransform = Ray.Zero();
  25725. }
  25726. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25727. return _this._cachedRayForTransform;
  25728. }, predicate, fastCheck);
  25729. if (result) {
  25730. result.ray = ray;
  25731. }
  25732. return result;
  25733. };
  25734. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPick = function (x, y, predicate, camera) {
  25735. var _this = this;
  25736. return this._internalMultiPick(function (world) { return _this.createPickingRay(x, y, world, camera || null); }, predicate);
  25737. };
  25738. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.multiPickWithRay = function (ray, predicate) {
  25739. var _this = this;
  25740. return this._internalMultiPick(function (world) {
  25741. if (!_this._pickWithRayInverseMatrix) {
  25742. _this._pickWithRayInverseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  25743. }
  25744. world.invertToRef(_this._pickWithRayInverseMatrix);
  25745. if (!_this._cachedRayForTransform) {
  25746. _this._cachedRayForTransform = Ray.Zero();
  25747. }
  25748. Ray.TransformToRef(ray, _this._pickWithRayInverseMatrix, _this._cachedRayForTransform);
  25749. return _this._cachedRayForTransform;
  25750. }, predicate);
  25751. };
  25752. _Cameras_camera__WEBPACK_IMPORTED_MODULE_5__["Camera"].prototype.getForwardRay = function (length, transform, origin) {
  25753. if (length === void 0) { length = 100; }
  25754. if (!transform) {
  25755. transform = this.getWorldMatrix();
  25756. }
  25757. if (!origin) {
  25758. origin = this.position;
  25759. }
  25760. var forward = this._scene.useRightHandedSystem ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, -1) : new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 0, 1);
  25761. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormal(forward, transform);
  25762. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Normalize(forwardWorld);
  25763. return new Ray(origin, direction, length);
  25764. };
  25765. /***/ }),
  25766. /***/ "./Debug/axesViewer.ts":
  25767. /*!*****************************!*\
  25768. !*** ./Debug/axesViewer.ts ***!
  25769. \*****************************/
  25770. /*! exports provided: AxesViewer */
  25771. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25772. "use strict";
  25773. __webpack_require__.r(__webpack_exports__);
  25774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return AxesViewer; });
  25775. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25776. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  25777. /* harmony import */ var _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gizmos/axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  25778. /**
  25779. * The Axes viewer will show 3 axes in a specific point in space
  25780. */
  25781. var AxesViewer = /** @class */ (function () {
  25782. /**
  25783. * Creates a new AxesViewer
  25784. * @param scene defines the hosting scene
  25785. * @param scaleLines defines a number used to scale line length (1 by default)
  25786. * @param renderingGroupId defines a number used to set the renderingGroupId of the meshes (2 by default)
  25787. * @param xAxis defines the node hierarchy used to render the x-axis
  25788. * @param yAxis defines the node hierarchy used to render the y-axis
  25789. * @param zAxis defines the node hierarchy used to render the z-axis
  25790. */
  25791. function AxesViewer(scene, scaleLines, renderingGroupId, xAxis, yAxis, zAxis) {
  25792. if (scaleLines === void 0) { scaleLines = 1; }
  25793. if (renderingGroupId === void 0) { renderingGroupId = 2; }
  25794. this._scaleLinesFactor = 4;
  25795. this._instanced = false;
  25796. /**
  25797. * Gets or sets a number used to scale line length
  25798. */
  25799. this.scaleLines = 1;
  25800. this.scaleLines = scaleLines;
  25801. if (!xAxis) {
  25802. var redColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25803. redColoredMaterial.disableLighting = true;
  25804. redColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Red().scale(0.5);
  25805. xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, redColoredMaterial);
  25806. }
  25807. if (!yAxis) {
  25808. var greenColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25809. greenColoredMaterial.disableLighting = true;
  25810. greenColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Green().scale(0.5);
  25811. yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, greenColoredMaterial);
  25812. }
  25813. if (!zAxis) {
  25814. var blueColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_1__["StandardMaterial"]("", scene);
  25815. blueColoredMaterial.disableLighting = true;
  25816. blueColoredMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].Blue().scale(0.5);
  25817. zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrow(scene, blueColoredMaterial);
  25818. }
  25819. this._xAxis = xAxis;
  25820. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25821. this._yAxis = yAxis;
  25822. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25823. this._zAxis = zAxis;
  25824. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25825. if (renderingGroupId != null) {
  25826. AxesViewer._SetRenderingGroupId(this._xAxis, renderingGroupId);
  25827. AxesViewer._SetRenderingGroupId(this._yAxis, renderingGroupId);
  25828. AxesViewer._SetRenderingGroupId(this._zAxis, renderingGroupId);
  25829. }
  25830. this.scene = scene;
  25831. this.update(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Right(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Forward());
  25832. }
  25833. Object.defineProperty(AxesViewer.prototype, "xAxis", {
  25834. /** Gets the node hierarchy used to render x-axis */
  25835. get: function () {
  25836. return this._xAxis;
  25837. },
  25838. enumerable: true,
  25839. configurable: true
  25840. });
  25841. Object.defineProperty(AxesViewer.prototype, "yAxis", {
  25842. /** Gets the node hierarchy used to render y-axis */
  25843. get: function () {
  25844. return this._yAxis;
  25845. },
  25846. enumerable: true,
  25847. configurable: true
  25848. });
  25849. Object.defineProperty(AxesViewer.prototype, "zAxis", {
  25850. /** Gets the node hierarchy used to render z-axis */
  25851. get: function () {
  25852. return this._zAxis;
  25853. },
  25854. enumerable: true,
  25855. configurable: true
  25856. });
  25857. /**
  25858. * Force the viewer to update
  25859. * @param position defines the position of the viewer
  25860. * @param xaxis defines the x axis of the viewer
  25861. * @param yaxis defines the y axis of the viewer
  25862. * @param zaxis defines the z axis of the viewer
  25863. */
  25864. AxesViewer.prototype.update = function (position, xaxis, yaxis, zaxis) {
  25865. this._xAxis.position.copyFrom(position);
  25866. this._xAxis.setDirection(xaxis);
  25867. this._xAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25868. this._yAxis.position.copyFrom(position);
  25869. this._yAxis.setDirection(yaxis);
  25870. this._yAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25871. this._zAxis.position.copyFrom(position);
  25872. this._zAxis.setDirection(zaxis);
  25873. this._zAxis.scaling.setAll(this.scaleLines * this._scaleLinesFactor);
  25874. };
  25875. /**
  25876. * Creates an instance of this axes viewer.
  25877. * @returns a new axes viewer with instanced meshes
  25878. */
  25879. AxesViewer.prototype.createInstance = function () {
  25880. var xAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._xAxis);
  25881. var yAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._yAxis);
  25882. var zAxis = _Gizmos_axisDragGizmo__WEBPACK_IMPORTED_MODULE_2__["AxisDragGizmo"]._CreateArrowInstance(this.scene, this._zAxis);
  25883. var axesViewer = new AxesViewer(this.scene, this.scaleLines, null, xAxis, yAxis, zAxis);
  25884. axesViewer._instanced = true;
  25885. return axesViewer;
  25886. };
  25887. /** Releases resources */
  25888. AxesViewer.prototype.dispose = function () {
  25889. if (this._xAxis) {
  25890. this._xAxis.dispose(false, !this._instanced);
  25891. delete this._xAxis;
  25892. }
  25893. if (this._yAxis) {
  25894. this._yAxis.dispose(false, !this._instanced);
  25895. delete this._yAxis;
  25896. }
  25897. if (this._zAxis) {
  25898. this._zAxis.dispose(false, !this._instanced);
  25899. delete this._zAxis;
  25900. }
  25901. delete this.scene;
  25902. };
  25903. AxesViewer._SetRenderingGroupId = function (node, id) {
  25904. node.getChildMeshes().forEach(function (mesh) {
  25905. mesh.renderingGroupId = id;
  25906. });
  25907. };
  25908. return AxesViewer;
  25909. }());
  25910. /***/ }),
  25911. /***/ "./Debug/boneAxesViewer.ts":
  25912. /*!*********************************!*\
  25913. !*** ./Debug/boneAxesViewer.ts ***!
  25914. \*********************************/
  25915. /*! exports provided: BoneAxesViewer */
  25916. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25917. "use strict";
  25918. __webpack_require__.r(__webpack_exports__);
  25919. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return BoneAxesViewer; });
  25920. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25921. /* harmony import */ var _Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/axesViewer */ "./Debug/axesViewer.ts");
  25922. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  25923. /**
  25924. * The BoneAxesViewer will attach 3 axes to a specific bone of a specific mesh
  25925. * @see demo here: https://www.babylonjs-playground.com/#0DE8F4#8
  25926. */
  25927. var BoneAxesViewer = /** @class */ (function (_super) {
  25928. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoneAxesViewer, _super);
  25929. /**
  25930. * Creates a new BoneAxesViewer
  25931. * @param scene defines the hosting scene
  25932. * @param bone defines the target bone
  25933. * @param mesh defines the target mesh
  25934. * @param scaleLines defines a scaling factor for line length (1 by default)
  25935. */
  25936. function BoneAxesViewer(scene, bone, mesh, scaleLines) {
  25937. if (scaleLines === void 0) { scaleLines = 1; }
  25938. var _this = _super.call(this, scene, scaleLines) || this;
  25939. /** Gets current position */
  25940. _this.pos = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25941. /** Gets direction of X axis */
  25942. _this.xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25943. /** Gets direction of Y axis */
  25944. _this.yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25945. /** Gets direction of Z axis */
  25946. _this.zaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  25947. _this.mesh = mesh;
  25948. _this.bone = bone;
  25949. return _this;
  25950. }
  25951. /**
  25952. * Force the viewer to update
  25953. */
  25954. BoneAxesViewer.prototype.update = function () {
  25955. if (!this.mesh || !this.bone) {
  25956. return;
  25957. }
  25958. var bone = this.bone;
  25959. bone.getAbsolutePositionToRef(this.mesh, this.pos);
  25960. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].X, this.mesh, this.xaxis);
  25961. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y, this.mesh, this.yaxis);
  25962. bone.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Z, this.mesh, this.zaxis);
  25963. _super.prototype.update.call(this, this.pos, this.xaxis, this.yaxis, this.zaxis);
  25964. };
  25965. /** Releases resources */
  25966. BoneAxesViewer.prototype.dispose = function () {
  25967. if (this.mesh) {
  25968. this.mesh = null;
  25969. this.bone = null;
  25970. _super.prototype.dispose.call(this);
  25971. }
  25972. };
  25973. return BoneAxesViewer;
  25974. }(_Debug_axesViewer__WEBPACK_IMPORTED_MODULE_1__["AxesViewer"]));
  25975. /***/ }),
  25976. /***/ "./Debug/debugLayer.ts":
  25977. /*!*****************************!*\
  25978. !*** ./Debug/debugLayer.ts ***!
  25979. \*****************************/
  25980. /*! exports provided: DebugLayer */
  25981. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  25982. "use strict";
  25983. __webpack_require__.r(__webpack_exports__);
  25984. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return DebugLayer; });
  25985. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  25986. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  25987. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  25988. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  25989. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  25990. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].prototype, "debugLayer", {
  25991. get: function () {
  25992. if (!this._debugLayer) {
  25993. this._debugLayer = new DebugLayer(this);
  25994. }
  25995. return this._debugLayer;
  25996. },
  25997. enumerable: true,
  25998. configurable: true
  25999. });
  26000. /**
  26001. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26002. * what is happening in your scene
  26003. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26004. */
  26005. var DebugLayer = /** @class */ (function () {
  26006. /**
  26007. * Instantiates a new debug layer.
  26008. * The debug layer (aka Inspector) is the go to tool in order to better understand
  26009. * what is happening in your scene
  26010. * @see http://doc.babylonjs.com/features/playground_debuglayer
  26011. * @param scene Defines the scene to inspect
  26012. */
  26013. function DebugLayer(scene) {
  26014. var _this = this;
  26015. this.BJSINSPECTOR = this._getGlobalInspector();
  26016. /**
  26017. * Observable triggered when a property is changed through the inspector.
  26018. */
  26019. this.onPropertyChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  26020. this._scene = scene;
  26021. this._scene.onDisposeObservable.add(function () {
  26022. // Debug layer
  26023. if (_this._scene._debugLayer) {
  26024. _this._scene._debugLayer.hide();
  26025. }
  26026. });
  26027. }
  26028. /** Creates the inspector window. */
  26029. DebugLayer.prototype._createInspector = function (config) {
  26030. if (this.isVisible()) {
  26031. return;
  26032. }
  26033. var userOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ overlay: false, showExplorer: true, showInspector: true, embedMode: false, handleResize: true, enablePopup: true }, config);
  26034. this.BJSINSPECTOR = this.BJSINSPECTOR || this._getGlobalInspector();
  26035. this.BJSINSPECTOR.Inspector.Show(this._scene, userOptions);
  26036. };
  26037. DebugLayer.prototype.select = function (entity, lineContainerTitle) {
  26038. if (this.BJSINSPECTOR) {
  26039. this.BJSINSPECTOR.Inspector.MarkLineContainerTitleForHighlighting(lineContainerTitle);
  26040. this.BJSINSPECTOR.Inspector.OnSelectionChangeObservable.notifyObservers(entity);
  26041. }
  26042. };
  26043. /** Get the inspector from bundle or global */
  26044. DebugLayer.prototype._getGlobalInspector = function () {
  26045. // UMD Global name detection from Webpack Bundle UMD Name.
  26046. if (typeof INSPECTOR !== 'undefined') {
  26047. return INSPECTOR;
  26048. }
  26049. // In case of module let s check the global emitted from the Inspector entry point.
  26050. if (typeof BABYLON !== 'undefined' && typeof BABYLON.Inspector !== 'undefined') {
  26051. return BABYLON;
  26052. }
  26053. return undefined;
  26054. };
  26055. /**
  26056. * Get if the inspector is visible or not.
  26057. * @returns true if visible otherwise, false
  26058. */
  26059. DebugLayer.prototype.isVisible = function () {
  26060. return this.BJSINSPECTOR && this.BJSINSPECTOR.Inspector.IsVisible;
  26061. };
  26062. /**
  26063. * Hide the inspector and close its window.
  26064. */
  26065. DebugLayer.prototype.hide = function () {
  26066. if (this.BJSINSPECTOR) {
  26067. this.BJSINSPECTOR.Inspector.Hide();
  26068. }
  26069. };
  26070. /**
  26071. * Launch the debugLayer.
  26072. * @param config Define the configuration of the inspector
  26073. * @return a promise fulfilled when the debug layer is visible
  26074. */
  26075. DebugLayer.prototype.show = function (config) {
  26076. var _this = this;
  26077. return new Promise(function (resolve, reject) {
  26078. if (typeof _this.BJSINSPECTOR == 'undefined') {
  26079. var inspectorUrl = config && config.inspectorURL ? config.inspectorURL : DebugLayer.InspectorURL;
  26080. // Load inspector and add it to the DOM
  26081. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadScript(inspectorUrl, function () {
  26082. _this._createInspector(config);
  26083. resolve(_this);
  26084. });
  26085. }
  26086. else {
  26087. // Otherwise creates the inspector
  26088. _this._createInspector(config);
  26089. resolve(_this);
  26090. }
  26091. });
  26092. };
  26093. /**
  26094. * Define the url to get the inspector script from.
  26095. * By default it uses the babylonjs CDN.
  26096. * @ignoreNaming
  26097. */
  26098. DebugLayer.InspectorURL = "https://unpkg.com/babylonjs-inspector@" + _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].Version + "/babylon.inspector.bundle.js";
  26099. return DebugLayer;
  26100. }());
  26101. /***/ }),
  26102. /***/ "./Debug/index.ts":
  26103. /*!************************!*\
  26104. !*** ./Debug/index.ts ***!
  26105. \************************/
  26106. /*! exports provided: AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer */
  26107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26108. "use strict";
  26109. __webpack_require__.r(__webpack_exports__);
  26110. /* harmony import */ var _axesViewer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axesViewer */ "./Debug/axesViewer.ts");
  26111. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _axesViewer__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  26112. /* harmony import */ var _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./boneAxesViewer */ "./Debug/boneAxesViewer.ts");
  26113. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _boneAxesViewer__WEBPACK_IMPORTED_MODULE_1__["BoneAxesViewer"]; });
  26114. /* harmony import */ var _debugLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./debugLayer */ "./Debug/debugLayer.ts");
  26115. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _debugLayer__WEBPACK_IMPORTED_MODULE_2__["DebugLayer"]; });
  26116. /* harmony import */ var _physicsViewer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsViewer */ "./Debug/physicsViewer.ts");
  26117. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _physicsViewer__WEBPACK_IMPORTED_MODULE_3__["PhysicsViewer"]; });
  26118. /* harmony import */ var _rayHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./rayHelper */ "./Debug/rayHelper.ts");
  26119. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _rayHelper__WEBPACK_IMPORTED_MODULE_4__["RayHelper"]; });
  26120. /* harmony import */ var _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./skeletonViewer */ "./Debug/skeletonViewer.ts");
  26121. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _skeletonViewer__WEBPACK_IMPORTED_MODULE_5__["SkeletonViewer"]; });
  26122. /***/ }),
  26123. /***/ "./Debug/physicsViewer.ts":
  26124. /*!********************************!*\
  26125. !*** ./Debug/physicsViewer.ts ***!
  26126. \********************************/
  26127. /*! exports provided: PhysicsViewer */
  26128. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26129. "use strict";
  26130. __webpack_require__.r(__webpack_exports__);
  26131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return PhysicsViewer; });
  26132. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  26133. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  26134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26135. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  26136. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  26137. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  26138. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26139. /**
  26140. * Used to show the physics impostor around the specific mesh
  26141. */
  26142. var PhysicsViewer = /** @class */ (function () {
  26143. /**
  26144. * Creates a new PhysicsViewer
  26145. * @param scene defines the hosting scene
  26146. */
  26147. function PhysicsViewer(scene) {
  26148. /** @hidden */
  26149. this._impostors = [];
  26150. /** @hidden */
  26151. this._meshes = [];
  26152. /** @hidden */
  26153. this._numMeshes = 0;
  26154. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  26155. var physicEngine = this._scene.getPhysicsEngine();
  26156. if (physicEngine) {
  26157. this._physicsEnginePlugin = physicEngine.getPhysicsPlugin();
  26158. }
  26159. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"](this._scene, false);
  26160. this._utilityLayer.pickUtilitySceneFirst = false;
  26161. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26162. }
  26163. /** @hidden */
  26164. PhysicsViewer.prototype._updateDebugMeshes = function () {
  26165. var plugin = this._physicsEnginePlugin;
  26166. for (var i = 0; i < this._numMeshes; i++) {
  26167. var impostor = this._impostors[i];
  26168. if (!impostor) {
  26169. continue;
  26170. }
  26171. if (impostor.isDisposed) {
  26172. this.hideImpostor(this._impostors[i--]);
  26173. }
  26174. else {
  26175. var mesh = this._meshes[i];
  26176. if (mesh && plugin) {
  26177. plugin.syncMeshWithImpostor(mesh, impostor);
  26178. }
  26179. }
  26180. }
  26181. };
  26182. /**
  26183. * Renders a specified physic impostor
  26184. * @param impostor defines the impostor to render
  26185. * @returns the new debug mesh used to render the impostor
  26186. */
  26187. PhysicsViewer.prototype.showImpostor = function (impostor) {
  26188. if (!this._scene) {
  26189. return null;
  26190. }
  26191. for (var i = 0; i < this._numMeshes; i++) {
  26192. if (this._impostors[i] == impostor) {
  26193. return null;
  26194. }
  26195. }
  26196. var debugMesh = this._getDebugMesh(impostor);
  26197. if (debugMesh) {
  26198. this._impostors[this._numMeshes] = impostor;
  26199. this._meshes[this._numMeshes] = debugMesh;
  26200. if (this._numMeshes === 0) {
  26201. this._renderFunction = this._updateDebugMeshes.bind(this);
  26202. this._scene.registerBeforeRender(this._renderFunction);
  26203. }
  26204. this._numMeshes++;
  26205. }
  26206. return debugMesh;
  26207. };
  26208. /**
  26209. * Hides a specified physic impostor
  26210. * @param impostor defines the impostor to hide
  26211. */
  26212. PhysicsViewer.prototype.hideImpostor = function (impostor) {
  26213. if (!impostor || !this._scene || !this._utilityLayer) {
  26214. return;
  26215. }
  26216. var removed = false;
  26217. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26218. for (var i = 0; i < this._numMeshes; i++) {
  26219. if (this._impostors[i] == impostor) {
  26220. var mesh = this._meshes[i];
  26221. if (!mesh) {
  26222. continue;
  26223. }
  26224. utilityLayerScene.removeMesh(mesh);
  26225. mesh.dispose();
  26226. this._numMeshes--;
  26227. if (this._numMeshes > 0) {
  26228. this._meshes[i] = this._meshes[this._numMeshes];
  26229. this._impostors[i] = this._impostors[this._numMeshes];
  26230. this._meshes[this._numMeshes] = null;
  26231. this._impostors[this._numMeshes] = null;
  26232. }
  26233. else {
  26234. this._meshes[0] = null;
  26235. this._impostors[0] = null;
  26236. }
  26237. removed = true;
  26238. break;
  26239. }
  26240. }
  26241. if (removed && this._numMeshes === 0) {
  26242. this._scene.unregisterBeforeRender(this._renderFunction);
  26243. }
  26244. };
  26245. PhysicsViewer.prototype._getDebugMaterial = function (scene) {
  26246. if (!this._debugMaterial) {
  26247. this._debugMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_4__["StandardMaterial"]('', scene);
  26248. this._debugMaterial.wireframe = true;
  26249. this._debugMaterial.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].White();
  26250. this._debugMaterial.disableLighting = true;
  26251. }
  26252. return this._debugMaterial;
  26253. };
  26254. PhysicsViewer.prototype._getDebugBoxMesh = function (scene) {
  26255. if (!this._debugBoxMesh) {
  26256. this._debugBoxMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"].CreateBox('physicsBodyBoxViewMesh', { size: 1 }, scene);
  26257. this._debugBoxMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26258. this._debugBoxMesh.material = this._getDebugMaterial(scene);
  26259. }
  26260. return this._debugBoxMesh.createInstance('physicsBodyBoxViewInstance');
  26261. };
  26262. PhysicsViewer.prototype._getDebugSphereMesh = function (scene) {
  26263. if (!this._debugSphereMesh) {
  26264. this._debugSphereMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere('physicsBodySphereViewMesh', { diameter: 1 }, scene);
  26265. this._debugSphereMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  26266. this._debugSphereMesh.material = this._getDebugMaterial(scene);
  26267. }
  26268. return this._debugSphereMesh.createInstance('physicsBodyBoxViewInstance');
  26269. };
  26270. PhysicsViewer.prototype._getDebugMesh = function (impostor) {
  26271. if (!this._utilityLayer) {
  26272. return null;
  26273. }
  26274. var mesh = null;
  26275. var utilityLayerScene = this._utilityLayer.utilityLayerScene;
  26276. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].BoxImpostor) {
  26277. mesh = this._getDebugBoxMesh(utilityLayerScene);
  26278. impostor.getBoxSizeToRef(mesh.scaling);
  26279. }
  26280. else if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_5__["PhysicsImpostor"].SphereImpostor) {
  26281. mesh = this._getDebugSphereMesh(utilityLayerScene);
  26282. var radius = impostor.getRadius();
  26283. mesh.scaling.x = radius * 2;
  26284. mesh.scaling.y = radius * 2;
  26285. mesh.scaling.z = radius * 2;
  26286. }
  26287. return mesh;
  26288. };
  26289. /** Releases all resources */
  26290. PhysicsViewer.prototype.dispose = function () {
  26291. for (var i = 0; i < this._numMeshes; i++) {
  26292. this.hideImpostor(this._impostors[i]);
  26293. }
  26294. if (this._debugBoxMesh) {
  26295. this._debugBoxMesh.dispose();
  26296. }
  26297. if (this._debugSphereMesh) {
  26298. this._debugSphereMesh.dispose();
  26299. }
  26300. if (this._debugMaterial) {
  26301. this._debugMaterial.dispose();
  26302. }
  26303. this._impostors.length = 0;
  26304. this._scene = null;
  26305. this._physicsEnginePlugin = null;
  26306. if (this._utilityLayer) {
  26307. this._utilityLayer.dispose();
  26308. this._utilityLayer = null;
  26309. }
  26310. };
  26311. return PhysicsViewer;
  26312. }());
  26313. /***/ }),
  26314. /***/ "./Debug/rayHelper.ts":
  26315. /*!****************************!*\
  26316. !*** ./Debug/rayHelper.ts ***!
  26317. \****************************/
  26318. /*! exports provided: RayHelper */
  26319. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26320. "use strict";
  26321. __webpack_require__.r(__webpack_exports__);
  26322. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return RayHelper; });
  26323. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26324. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  26325. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26326. /**
  26327. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26328. * in order to better appreciate the issue one might have.
  26329. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26330. */
  26331. var RayHelper = /** @class */ (function () {
  26332. /**
  26333. * Instantiate a new ray helper.
  26334. * As raycast might be hard to debug, the RayHelper can help rendering the different rays
  26335. * in order to better appreciate the issue one might have.
  26336. * @see http://doc.babylonjs.com/babylon101/raycasts#debugging
  26337. * @param ray Defines the ray we are currently tryin to visualize
  26338. */
  26339. function RayHelper(ray) {
  26340. this.ray = ray;
  26341. }
  26342. /**
  26343. * Helper function to create a colored helper in a scene in one line.
  26344. * @param ray Defines the ray we are currently tryin to visualize
  26345. * @param scene Defines the scene the ray is used in
  26346. * @param color Defines the color we want to see the ray in
  26347. * @returns The newly created ray helper.
  26348. */
  26349. RayHelper.CreateAndShow = function (ray, scene, color) {
  26350. var helper = new RayHelper(ray);
  26351. helper.show(scene, color);
  26352. return helper;
  26353. };
  26354. /**
  26355. * Shows the ray we are willing to debug.
  26356. * @param scene Defines the scene the ray needs to be rendered in
  26357. * @param color Defines the color the ray needs to be rendered in
  26358. */
  26359. RayHelper.prototype.show = function (scene, color) {
  26360. if (!this._renderFunction && this.ray) {
  26361. var ray = this.ray;
  26362. this._renderFunction = this._render.bind(this);
  26363. this._scene = scene;
  26364. this._renderPoints = [ray.origin, ray.origin.add(ray.direction.scale(ray.length))];
  26365. this._renderLine = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, scene, true);
  26366. if (this._renderFunction) {
  26367. this._scene.registerBeforeRender(this._renderFunction);
  26368. }
  26369. }
  26370. if (color && this._renderLine) {
  26371. this._renderLine.color.copyFrom(color);
  26372. }
  26373. };
  26374. /**
  26375. * Hides the ray we are debugging.
  26376. */
  26377. RayHelper.prototype.hide = function () {
  26378. if (this._renderFunction && this._scene) {
  26379. this._scene.unregisterBeforeRender(this._renderFunction);
  26380. this._scene = null;
  26381. this._renderFunction = null;
  26382. if (this._renderLine) {
  26383. this._renderLine.dispose();
  26384. this._renderLine = null;
  26385. }
  26386. this._renderPoints = [];
  26387. }
  26388. };
  26389. RayHelper.prototype._render = function () {
  26390. var ray = this.ray;
  26391. if (!ray) {
  26392. return;
  26393. }
  26394. var point = this._renderPoints[1];
  26395. var len = Math.min(ray.length, 1000000);
  26396. point.copyFrom(ray.direction);
  26397. point.scaleInPlace(len);
  26398. point.addInPlace(ray.origin);
  26399. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines("ray", this._renderPoints, this._scene, true, this._renderLine);
  26400. };
  26401. /**
  26402. * Attach a ray helper to a mesh so that we can easily see its orientation for instance or information like its normals.
  26403. * @param mesh Defines the mesh we want the helper attached to
  26404. * @param meshSpaceDirection Defines the direction of the Ray in mesh space (local space of the mesh node)
  26405. * @param meshSpaceOrigin Defines the origin of the Ray in mesh space (local space of the mesh node)
  26406. * @param length Defines the length of the ray
  26407. */
  26408. RayHelper.prototype.attachToMesh = function (mesh, meshSpaceDirection, meshSpaceOrigin, length) {
  26409. this._attachedToMesh = mesh;
  26410. var ray = this.ray;
  26411. if (!ray) {
  26412. return;
  26413. }
  26414. if (!ray.direction) {
  26415. ray.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26416. }
  26417. if (!ray.origin) {
  26418. ray.origin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26419. }
  26420. if (length) {
  26421. ray.length = length;
  26422. }
  26423. if (!meshSpaceOrigin) {
  26424. meshSpaceOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  26425. }
  26426. if (!meshSpaceDirection) {
  26427. // -1 so that this will work with Mesh.lookAt
  26428. meshSpaceDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1);
  26429. }
  26430. if (!this._meshSpaceDirection) {
  26431. this._meshSpaceDirection = meshSpaceDirection.clone();
  26432. this._meshSpaceOrigin = meshSpaceOrigin.clone();
  26433. }
  26434. else {
  26435. this._meshSpaceDirection.copyFrom(meshSpaceDirection);
  26436. this._meshSpaceOrigin.copyFrom(meshSpaceOrigin);
  26437. }
  26438. if (!this._updateToMeshFunction) {
  26439. this._updateToMeshFunction = this._updateToMesh.bind(this);
  26440. this._attachedToMesh.getScene().registerBeforeRender(this._updateToMeshFunction);
  26441. }
  26442. this._updateToMesh();
  26443. };
  26444. /**
  26445. * Detach the ray helper from the mesh it has previously been attached to.
  26446. */
  26447. RayHelper.prototype.detachFromMesh = function () {
  26448. if (this._attachedToMesh) {
  26449. if (this._updateToMeshFunction) {
  26450. this._attachedToMesh.getScene().unregisterBeforeRender(this._updateToMeshFunction);
  26451. }
  26452. this._attachedToMesh = null;
  26453. this._updateToMeshFunction = null;
  26454. }
  26455. };
  26456. RayHelper.prototype._updateToMesh = function () {
  26457. var ray = this.ray;
  26458. if (!this._attachedToMesh || !ray) {
  26459. return;
  26460. }
  26461. if (this._attachedToMesh._isDisposed) {
  26462. this.detachFromMesh();
  26463. return;
  26464. }
  26465. this._attachedToMesh.getDirectionToRef(this._meshSpaceDirection, ray.direction);
  26466. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._meshSpaceOrigin, this._attachedToMesh.getWorldMatrix(), ray.origin);
  26467. };
  26468. /**
  26469. * Dispose the helper and release its associated resources.
  26470. */
  26471. RayHelper.prototype.dispose = function () {
  26472. this.hide();
  26473. this.detachFromMesh();
  26474. this.ray = null;
  26475. };
  26476. return RayHelper;
  26477. }());
  26478. /***/ }),
  26479. /***/ "./Debug/skeletonViewer.ts":
  26480. /*!*********************************!*\
  26481. !*** ./Debug/skeletonViewer.ts ***!
  26482. \*********************************/
  26483. /*! exports provided: SkeletonViewer */
  26484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26485. "use strict";
  26486. __webpack_require__.r(__webpack_exports__);
  26487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return SkeletonViewer; });
  26488. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  26489. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  26490. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  26491. /**
  26492. * Class used to render a debug view of a given skeleton
  26493. * @see http://www.babylonjs-playground.com/#1BZJVJ#8
  26494. */
  26495. var SkeletonViewer = /** @class */ (function () {
  26496. /**
  26497. * Creates a new SkeletonViewer
  26498. * @param skeleton defines the skeleton to render
  26499. * @param mesh defines the mesh attached to the skeleton
  26500. * @param scene defines the hosting scene
  26501. * @param autoUpdateBonesMatrices defines a boolean indicating if bones matrices must be forced to update before rendering (true by default)
  26502. * @param renderingGroupId defines the rendering group id to use with the viewer
  26503. */
  26504. function SkeletonViewer(
  26505. /** defines the skeleton to render */
  26506. skeleton,
  26507. /** defines the mesh attached to the skeleton */
  26508. mesh, scene,
  26509. /** defines a boolean indicating if bones matrices must be forced to update before rendering (true by default) */
  26510. autoUpdateBonesMatrices,
  26511. /** defines the rendering group id to use with the viewer */
  26512. renderingGroupId) {
  26513. if (autoUpdateBonesMatrices === void 0) { autoUpdateBonesMatrices = true; }
  26514. if (renderingGroupId === void 0) { renderingGroupId = 1; }
  26515. this.skeleton = skeleton;
  26516. this.mesh = mesh;
  26517. this.autoUpdateBonesMatrices = autoUpdateBonesMatrices;
  26518. this.renderingGroupId = renderingGroupId;
  26519. /** Gets or sets the color used to render the skeleton */
  26520. this.color = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].White();
  26521. this._debugLines = new Array();
  26522. this._isEnabled = false;
  26523. this._scene = scene;
  26524. this._utilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"](this._scene, false);
  26525. this._utilityLayer.pickUtilitySceneFirst = false;
  26526. this._utilityLayer.utilityLayerScene.autoClearDepthAndStencil = true;
  26527. this.update();
  26528. this._renderFunction = this.update.bind(this);
  26529. }
  26530. Object.defineProperty(SkeletonViewer.prototype, "debugMesh", {
  26531. /**
  26532. * Returns the mesh used to render the bones
  26533. */
  26534. get: function () {
  26535. return this._debugMesh;
  26536. },
  26537. enumerable: true,
  26538. configurable: true
  26539. });
  26540. Object.defineProperty(SkeletonViewer.prototype, "isEnabled", {
  26541. get: function () {
  26542. return this._isEnabled;
  26543. },
  26544. /** Gets or sets a boolean indicating if the viewer is enabled */
  26545. set: function (value) {
  26546. if (this._isEnabled === value) {
  26547. return;
  26548. }
  26549. this._isEnabled = value;
  26550. if (value) {
  26551. this._scene.registerBeforeRender(this._renderFunction);
  26552. }
  26553. else {
  26554. this._scene.unregisterBeforeRender(this._renderFunction);
  26555. }
  26556. },
  26557. enumerable: true,
  26558. configurable: true
  26559. });
  26560. SkeletonViewer.prototype._getBonePosition = function (position, bone, meshMat, x, y, z) {
  26561. if (x === void 0) { x = 0; }
  26562. if (y === void 0) { y = 0; }
  26563. if (z === void 0) { z = 0; }
  26564. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  26565. var parentBone = bone.getParent();
  26566. tmat.copyFrom(bone.getLocalMatrix());
  26567. if (x !== 0 || y !== 0 || z !== 0) {
  26568. var tmat2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  26569. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(tmat2);
  26570. tmat2.setTranslationFromFloats(x, y, z);
  26571. tmat2.multiplyToRef(tmat, tmat);
  26572. }
  26573. if (parentBone) {
  26574. tmat.multiplyToRef(parentBone.getAbsoluteTransform(), tmat);
  26575. }
  26576. tmat.multiplyToRef(meshMat, tmat);
  26577. position.x = tmat.m[12];
  26578. position.y = tmat.m[13];
  26579. position.z = tmat.m[14];
  26580. };
  26581. SkeletonViewer.prototype._getLinesForBonesWithLength = function (bones, meshMat) {
  26582. var len = bones.length;
  26583. var meshPos = this.mesh.position;
  26584. for (var i = 0; i < len; i++) {
  26585. var bone = bones[i];
  26586. var points = this._debugLines[i];
  26587. if (!points) {
  26588. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26589. this._debugLines[i] = points;
  26590. }
  26591. this._getBonePosition(points[0], bone, meshMat);
  26592. this._getBonePosition(points[1], bone, meshMat, 0, bone.length, 0);
  26593. points[0].subtractInPlace(meshPos);
  26594. points[1].subtractInPlace(meshPos);
  26595. }
  26596. };
  26597. SkeletonViewer.prototype._getLinesForBonesNoLength = function (bones, meshMat) {
  26598. var len = bones.length;
  26599. var boneNum = 0;
  26600. var meshPos = this.mesh.position;
  26601. for (var i = len - 1; i >= 0; i--) {
  26602. var childBone = bones[i];
  26603. var parentBone = childBone.getParent();
  26604. if (!parentBone) {
  26605. continue;
  26606. }
  26607. var points = this._debugLines[boneNum];
  26608. if (!points) {
  26609. points = [_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero(), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero()];
  26610. this._debugLines[boneNum] = points;
  26611. }
  26612. childBone.getAbsolutePositionToRef(this.mesh, points[0]);
  26613. parentBone.getAbsolutePositionToRef(this.mesh, points[1]);
  26614. points[0].subtractInPlace(meshPos);
  26615. points[1].subtractInPlace(meshPos);
  26616. boneNum++;
  26617. }
  26618. };
  26619. /** Update the viewer to sync with current skeleton state */
  26620. SkeletonViewer.prototype.update = function () {
  26621. if (!this._utilityLayer) {
  26622. return;
  26623. }
  26624. if (this.autoUpdateBonesMatrices) {
  26625. this.skeleton.computeAbsoluteTransforms();
  26626. }
  26627. if (this.skeleton.bones[0].length === undefined) {
  26628. this._getLinesForBonesNoLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26629. }
  26630. else {
  26631. this._getLinesForBonesWithLength(this.skeleton.bones, this.mesh.getWorldMatrix());
  26632. }
  26633. var targetScene = this._utilityLayer.utilityLayerScene;
  26634. if (!this._debugMesh) {
  26635. this._debugMesh = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: null }, targetScene);
  26636. this._debugMesh.renderingGroupId = this.renderingGroupId;
  26637. }
  26638. else {
  26639. _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_1__["LinesBuilder"].CreateLineSystem("", { lines: this._debugLines, updatable: true, instance: this._debugMesh }, targetScene);
  26640. }
  26641. this._debugMesh.position.copyFrom(this.mesh.position);
  26642. this._debugMesh.color = this.color;
  26643. };
  26644. /** Release associated resources */
  26645. SkeletonViewer.prototype.dispose = function () {
  26646. this.isEnabled = false;
  26647. if (this._debugMesh) {
  26648. this.isEnabled = false;
  26649. this._debugMesh.dispose();
  26650. this._debugMesh = null;
  26651. }
  26652. if (this._utilityLayer) {
  26653. this._utilityLayer.dispose();
  26654. this._utilityLayer = null;
  26655. }
  26656. };
  26657. return SkeletonViewer;
  26658. }());
  26659. /***/ }),
  26660. /***/ "./Engines/Extensions/engine.occlusionQuery.ts":
  26661. /*!*****************************************************!*\
  26662. !*** ./Engines/Extensions/engine.occlusionQuery.ts ***!
  26663. \*****************************************************/
  26664. /*! exports provided: _OcclusionDataStorage */
  26665. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26666. "use strict";
  26667. __webpack_require__.r(__webpack_exports__);
  26668. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _OcclusionDataStorage; });
  26669. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26670. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  26671. /* harmony import */ var _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Instrumentation/timeToken */ "./Instrumentation/timeToken.ts");
  26672. /** @hidden */
  26673. var _OcclusionDataStorage = /** @class */ (function () {
  26674. function _OcclusionDataStorage() {
  26675. /** @hidden */
  26676. this.occlusionInternalRetryCounter = 0;
  26677. /** @hidden */
  26678. this.isOcclusionQueryInProgress = false;
  26679. /** @hidden */
  26680. this.isOccluded = false;
  26681. /** @hidden */
  26682. this.occlusionRetryCount = -1;
  26683. /** @hidden */
  26684. this.occlusionType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE;
  26685. /** @hidden */
  26686. this.occlusionQueryAlgorithmType = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE;
  26687. }
  26688. return _OcclusionDataStorage;
  26689. }());
  26690. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createQuery = function () {
  26691. return this._gl.createQuery();
  26692. };
  26693. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteQuery = function (query) {
  26694. this._gl.deleteQuery(query);
  26695. return this;
  26696. };
  26697. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.isQueryResultAvailable = function (query) {
  26698. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT_AVAILABLE);
  26699. };
  26700. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.getQueryResult = function (query) {
  26701. return this._gl.getQueryParameter(query, this._gl.QUERY_RESULT);
  26702. };
  26703. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginOcclusionQuery = function (algorithmType, query) {
  26704. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26705. this._gl.beginQuery(glAlgorithm, query);
  26706. return this;
  26707. };
  26708. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endOcclusionQuery = function (algorithmType) {
  26709. var glAlgorithm = this._getGlAlgorithmType(algorithmType);
  26710. this._gl.endQuery(glAlgorithm);
  26711. return this;
  26712. };
  26713. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._createTimeQuery = function () {
  26714. var timerQuery = this.getCaps().timerQuery;
  26715. if (timerQuery.createQueryEXT) {
  26716. return timerQuery.createQueryEXT();
  26717. }
  26718. return this.createQuery();
  26719. };
  26720. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._deleteTimeQuery = function (query) {
  26721. var timerQuery = this.getCaps().timerQuery;
  26722. if (timerQuery.deleteQueryEXT) {
  26723. timerQuery.deleteQueryEXT(query);
  26724. return;
  26725. }
  26726. this.deleteQuery(query);
  26727. };
  26728. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryResult = function (query) {
  26729. var timerQuery = this.getCaps().timerQuery;
  26730. if (timerQuery.getQueryObjectEXT) {
  26731. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_EXT);
  26732. }
  26733. return this.getQueryResult(query);
  26734. };
  26735. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getTimeQueryAvailability = function (query) {
  26736. var timerQuery = this.getCaps().timerQuery;
  26737. if (timerQuery.getQueryObjectEXT) {
  26738. return timerQuery.getQueryObjectEXT(query, timerQuery.QUERY_RESULT_AVAILABLE_EXT);
  26739. }
  26740. return this.isQueryResultAvailable(query);
  26741. };
  26742. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.startTimeQuery = function () {
  26743. var caps = this.getCaps();
  26744. var timerQuery = caps.timerQuery;
  26745. if (!timerQuery) {
  26746. return null;
  26747. }
  26748. var token = new _Instrumentation_timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]();
  26749. this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26750. if (caps.canUseTimestampForTimerQuery) {
  26751. token._startTimeQuery = this._createTimeQuery();
  26752. timerQuery.queryCounterEXT(token._startTimeQuery, timerQuery.TIMESTAMP_EXT);
  26753. }
  26754. else {
  26755. if (this._currentNonTimestampToken) {
  26756. return this._currentNonTimestampToken;
  26757. }
  26758. token._timeElapsedQuery = this._createTimeQuery();
  26759. if (timerQuery.beginQueryEXT) {
  26760. timerQuery.beginQueryEXT(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26761. }
  26762. else {
  26763. this._gl.beginQuery(timerQuery.TIME_ELAPSED_EXT, token._timeElapsedQuery);
  26764. }
  26765. this._currentNonTimestampToken = token;
  26766. }
  26767. return token;
  26768. };
  26769. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTimeQuery = function (token) {
  26770. var caps = this.getCaps();
  26771. var timerQuery = caps.timerQuery;
  26772. if (!timerQuery || !token) {
  26773. return -1;
  26774. }
  26775. if (caps.canUseTimestampForTimerQuery) {
  26776. if (!token._startTimeQuery) {
  26777. return -1;
  26778. }
  26779. if (!token._endTimeQuery) {
  26780. token._endTimeQuery = this._createTimeQuery();
  26781. timerQuery.queryCounterEXT(token._endTimeQuery, timerQuery.TIMESTAMP_EXT);
  26782. }
  26783. }
  26784. else if (!token._timeElapsedQueryEnded) {
  26785. if (!token._timeElapsedQuery) {
  26786. return -1;
  26787. }
  26788. if (timerQuery.endQueryEXT) {
  26789. timerQuery.endQueryEXT(timerQuery.TIME_ELAPSED_EXT);
  26790. }
  26791. else {
  26792. this._gl.endQuery(timerQuery.TIME_ELAPSED_EXT);
  26793. }
  26794. token._timeElapsedQueryEnded = true;
  26795. }
  26796. var disjoint = this._gl.getParameter(timerQuery.GPU_DISJOINT_EXT);
  26797. var available = false;
  26798. if (token._endTimeQuery) {
  26799. available = this._getTimeQueryAvailability(token._endTimeQuery);
  26800. }
  26801. else if (token._timeElapsedQuery) {
  26802. available = this._getTimeQueryAvailability(token._timeElapsedQuery);
  26803. }
  26804. if (available && !disjoint) {
  26805. var result = 0;
  26806. if (caps.canUseTimestampForTimerQuery) {
  26807. if (!token._startTimeQuery || !token._endTimeQuery) {
  26808. return -1;
  26809. }
  26810. var timeStart = this._getTimeQueryResult(token._startTimeQuery);
  26811. var timeEnd = this._getTimeQueryResult(token._endTimeQuery);
  26812. result = timeEnd - timeStart;
  26813. this._deleteTimeQuery(token._startTimeQuery);
  26814. this._deleteTimeQuery(token._endTimeQuery);
  26815. token._startTimeQuery = null;
  26816. token._endTimeQuery = null;
  26817. }
  26818. else {
  26819. if (!token._timeElapsedQuery) {
  26820. return -1;
  26821. }
  26822. result = this._getTimeQueryResult(token._timeElapsedQuery);
  26823. this._deleteTimeQuery(token._timeElapsedQuery);
  26824. token._timeElapsedQuery = null;
  26825. token._timeElapsedQueryEnded = false;
  26826. this._currentNonTimestampToken = null;
  26827. }
  26828. return result;
  26829. }
  26830. return -1;
  26831. };
  26832. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype._getGlAlgorithmType = function (algorithmType) {
  26833. return algorithmType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE ? this._gl.ANY_SAMPLES_PASSED_CONSERVATIVE : this._gl.ANY_SAMPLES_PASSED;
  26834. };
  26835. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOcclusionQueryInProgress", {
  26836. get: function () {
  26837. return this._occlusionDataStorage.isOcclusionQueryInProgress;
  26838. },
  26839. enumerable: false,
  26840. configurable: true
  26841. });
  26842. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "_occlusionDataStorage", {
  26843. get: function () {
  26844. if (!this.__occlusionDataStorage) {
  26845. this.__occlusionDataStorage = new _OcclusionDataStorage();
  26846. }
  26847. return this.__occlusionDataStorage;
  26848. },
  26849. enumerable: false,
  26850. configurable: true
  26851. });
  26852. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "isOccluded", {
  26853. get: function () {
  26854. return this._occlusionDataStorage.isOccluded;
  26855. },
  26856. set: function (value) {
  26857. this._occlusionDataStorage.isOccluded = value;
  26858. },
  26859. enumerable: true,
  26860. configurable: true
  26861. });
  26862. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionQueryAlgorithmType", {
  26863. get: function () {
  26864. return this._occlusionDataStorage.occlusionQueryAlgorithmType;
  26865. },
  26866. set: function (value) {
  26867. this._occlusionDataStorage.occlusionQueryAlgorithmType = value;
  26868. },
  26869. enumerable: true,
  26870. configurable: true
  26871. });
  26872. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionType", {
  26873. get: function () {
  26874. return this._occlusionDataStorage.occlusionType;
  26875. },
  26876. set: function (value) {
  26877. this._occlusionDataStorage.occlusionType = value;
  26878. },
  26879. enumerable: true,
  26880. configurable: true
  26881. });
  26882. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "occlusionRetryCount", {
  26883. get: function () {
  26884. return this._occlusionDataStorage.occlusionRetryCount;
  26885. },
  26886. set: function (value) {
  26887. this._occlusionDataStorage.occlusionRetryCount = value;
  26888. },
  26889. enumerable: true,
  26890. configurable: true
  26891. });
  26892. // We also need to update AbstractMesh as there is a portion of the code there
  26893. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype._checkOcclusionQuery = function () {
  26894. var dataStorage = this._occlusionDataStorage;
  26895. if (dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_NONE) {
  26896. dataStorage.isOccluded = false;
  26897. return false;
  26898. }
  26899. var engine = this.getEngine();
  26900. if (engine.webGLVersion < 2) {
  26901. dataStorage.isOccluded = false;
  26902. return false;
  26903. }
  26904. if (!engine.isQueryResultAvailable) { // Occlusion query where not referenced
  26905. dataStorage.isOccluded = false;
  26906. return false;
  26907. }
  26908. if (this.isOcclusionQueryInProgress && this._occlusionQuery) {
  26909. var isOcclusionQueryAvailable = engine.isQueryResultAvailable(this._occlusionQuery);
  26910. if (isOcclusionQueryAvailable) {
  26911. var occlusionQueryResult = engine.getQueryResult(this._occlusionQuery);
  26912. dataStorage.isOcclusionQueryInProgress = false;
  26913. dataStorage.occlusionInternalRetryCounter = 0;
  26914. dataStorage.isOccluded = occlusionQueryResult === 1 ? false : true;
  26915. }
  26916. else {
  26917. dataStorage.occlusionInternalRetryCounter++;
  26918. if (dataStorage.occlusionRetryCount !== -1 && dataStorage.occlusionInternalRetryCounter > dataStorage.occlusionRetryCount) {
  26919. dataStorage.isOcclusionQueryInProgress = false;
  26920. dataStorage.occlusionInternalRetryCounter = 0;
  26921. // if optimistic set isOccluded to false regardless of the status of isOccluded. (Render in the current render loop)
  26922. // if strict continue the last state of the object.
  26923. dataStorage.isOccluded = dataStorage.occlusionType === _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].OCCLUSION_TYPE_OPTIMISTIC ? false : dataStorage.isOccluded;
  26924. }
  26925. else {
  26926. return false;
  26927. }
  26928. }
  26929. }
  26930. var scene = this.getScene();
  26931. if (scene.getBoundingBoxRenderer) {
  26932. var occlusionBoundingBoxRenderer = scene.getBoundingBoxRenderer();
  26933. if (!this._occlusionQuery) {
  26934. this._occlusionQuery = engine.createQuery();
  26935. }
  26936. engine.beginOcclusionQuery(dataStorage.occlusionQueryAlgorithmType, this._occlusionQuery);
  26937. occlusionBoundingBoxRenderer.renderOcclusionBoundingBox(this);
  26938. engine.endOcclusionQuery(dataStorage.occlusionQueryAlgorithmType);
  26939. this._occlusionDataStorage.isOcclusionQueryInProgress = true;
  26940. }
  26941. return dataStorage.isOccluded;
  26942. };
  26943. /***/ }),
  26944. /***/ "./Engines/Extensions/engine.transformFeedback.ts":
  26945. /*!********************************************************!*\
  26946. !*** ./Engines/Extensions/engine.transformFeedback.ts ***!
  26947. \********************************************************/
  26948. /*! exports provided: _forceTransformFeedbackToBundle */
  26949. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26950. "use strict";
  26951. __webpack_require__.r(__webpack_exports__);
  26952. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _forceTransformFeedbackToBundle; });
  26953. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  26954. /** @hidden */
  26955. var _forceTransformFeedbackToBundle = true;
  26956. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.createTransformFeedback = function () {
  26957. return this._gl.createTransformFeedback();
  26958. };
  26959. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.deleteTransformFeedback = function (value) {
  26960. this._gl.deleteTransformFeedback(value);
  26961. };
  26962. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedback = function (value) {
  26963. this._gl.bindTransformFeedback(this._gl.TRANSFORM_FEEDBACK, value);
  26964. };
  26965. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.beginTransformFeedback = function (usePoints) {
  26966. if (usePoints === void 0) { usePoints = true; }
  26967. this._gl.beginTransformFeedback(usePoints ? this._gl.POINTS : this._gl.TRIANGLES);
  26968. };
  26969. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.endTransformFeedback = function () {
  26970. this._gl.endTransformFeedback();
  26971. };
  26972. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.setTranformFeedbackVaryings = function (program, value) {
  26973. this._gl.transformFeedbackVaryings(program, value, this._gl.INTERLEAVED_ATTRIBS);
  26974. };
  26975. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].prototype.bindTransformFeedbackBuffer = function (value) {
  26976. this._gl.bindBufferBase(this._gl.TRANSFORM_FEEDBACK_BUFFER, 0, value);
  26977. };
  26978. /***/ }),
  26979. /***/ "./Engines/Extensions/index.ts":
  26980. /*!*************************************!*\
  26981. !*** ./Engines/Extensions/index.ts ***!
  26982. \*************************************/
  26983. /*! exports provided: _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  26984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26985. "use strict";
  26986. __webpack_require__.r(__webpack_exports__);
  26987. /* harmony import */ var _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.occlusionQuery */ "./Engines/Extensions/engine.occlusionQuery.ts");
  26988. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _engine_occlusionQuery__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  26989. /* harmony import */ var _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.transformFeedback */ "./Engines/Extensions/engine.transformFeedback.ts");
  26990. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _engine_transformFeedback__WEBPACK_IMPORTED_MODULE_1__["_forceTransformFeedbackToBundle"]; });
  26991. /***/ }),
  26992. /***/ "./Engines/constants.ts":
  26993. /*!******************************!*\
  26994. !*** ./Engines/constants.ts ***!
  26995. \******************************/
  26996. /*! exports provided: Constants */
  26997. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  26998. "use strict";
  26999. __webpack_require__.r(__webpack_exports__);
  27000. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return Constants; });
  27001. /** Defines the cross module used constants to avoid circular dependncies */
  27002. var Constants = /** @class */ (function () {
  27003. function Constants() {
  27004. }
  27005. /** Defines that alpha blending is disabled */
  27006. Constants.ALPHA_DISABLE = 0;
  27007. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  27008. Constants.ALPHA_ADD = 1;
  27009. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  27010. Constants.ALPHA_COMBINE = 2;
  27011. /** Defines that alpha blending to DEST - SRC * DEST */
  27012. Constants.ALPHA_SUBTRACT = 3;
  27013. /** Defines that alpha blending to SRC * DEST */
  27014. Constants.ALPHA_MULTIPLY = 4;
  27015. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  27016. Constants.ALPHA_MAXIMIZED = 5;
  27017. /** Defines that alpha blending to SRC + DEST */
  27018. Constants.ALPHA_ONEONE = 6;
  27019. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  27020. Constants.ALPHA_PREMULTIPLIED = 7;
  27021. /**
  27022. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  27023. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  27024. */
  27025. Constants.ALPHA_PREMULTIPLIED_PORTERDUFF = 8;
  27026. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  27027. Constants.ALPHA_INTERPOLATE = 9;
  27028. /**
  27029. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  27030. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  27031. */
  27032. Constants.ALPHA_SCREENMODE = 10;
  27033. /** Defines that the ressource is not delayed*/
  27034. Constants.DELAYLOADSTATE_NONE = 0;
  27035. /** Defines that the ressource was successfully delay loaded */
  27036. Constants.DELAYLOADSTATE_LOADED = 1;
  27037. /** Defines that the ressource is currently delay loading */
  27038. Constants.DELAYLOADSTATE_LOADING = 2;
  27039. /** Defines that the ressource is delayed and has not started loading */
  27040. Constants.DELAYLOADSTATE_NOTLOADED = 4;
  27041. // Depht or Stencil test Constants.
  27042. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  27043. Constants.NEVER = 0x0200;
  27044. /** 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 */
  27045. Constants.ALWAYS = 0x0207;
  27046. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  27047. Constants.LESS = 0x0201;
  27048. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  27049. Constants.EQUAL = 0x0202;
  27050. /** 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 */
  27051. Constants.LEQUAL = 0x0203;
  27052. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  27053. Constants.GREATER = 0x0204;
  27054. /** 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 */
  27055. Constants.GEQUAL = 0x0206;
  27056. /** 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 */
  27057. Constants.NOTEQUAL = 0x0205;
  27058. // Stencil Actions Constants.
  27059. /** Passed to stencilOperation to specify that stencil value must be kept */
  27060. Constants.KEEP = 0x1E00;
  27061. /** Passed to stencilOperation to specify that stencil value must be replaced */
  27062. Constants.REPLACE = 0x1E01;
  27063. /** Passed to stencilOperation to specify that stencil value must be incremented */
  27064. Constants.INCR = 0x1E02;
  27065. /** Passed to stencilOperation to specify that stencil value must be decremented */
  27066. Constants.DECR = 0x1E03;
  27067. /** Passed to stencilOperation to specify that stencil value must be inverted */
  27068. Constants.INVERT = 0x150A;
  27069. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  27070. Constants.INCR_WRAP = 0x8507;
  27071. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  27072. Constants.DECR_WRAP = 0x8508;
  27073. /** Texture is not repeating outside of 0..1 UVs */
  27074. Constants.TEXTURE_CLAMP_ADDRESSMODE = 0;
  27075. /** Texture is repeating outside of 0..1 UVs */
  27076. Constants.TEXTURE_WRAP_ADDRESSMODE = 1;
  27077. /** Texture is repeating and mirrored */
  27078. Constants.TEXTURE_MIRROR_ADDRESSMODE = 2;
  27079. /** ALPHA */
  27080. Constants.TEXTUREFORMAT_ALPHA = 0;
  27081. /** LUMINANCE */
  27082. Constants.TEXTUREFORMAT_LUMINANCE = 1;
  27083. /** LUMINANCE_ALPHA */
  27084. Constants.TEXTUREFORMAT_LUMINANCE_ALPHA = 2;
  27085. /** RGB */
  27086. Constants.TEXTUREFORMAT_RGB = 4;
  27087. /** RGBA */
  27088. Constants.TEXTUREFORMAT_RGBA = 5;
  27089. /** RED */
  27090. Constants.TEXTUREFORMAT_RED = 6;
  27091. /** RED (2nd reference) */
  27092. Constants.TEXTUREFORMAT_R = 6;
  27093. /** RG */
  27094. Constants.TEXTUREFORMAT_RG = 7;
  27095. /** RED_INTEGER */
  27096. Constants.TEXTUREFORMAT_RED_INTEGER = 8;
  27097. /** RED_INTEGER (2nd reference) */
  27098. Constants.TEXTUREFORMAT_R_INTEGER = 8;
  27099. /** RG_INTEGER */
  27100. Constants.TEXTUREFORMAT_RG_INTEGER = 9;
  27101. /** RGB_INTEGER */
  27102. Constants.TEXTUREFORMAT_RGB_INTEGER = 10;
  27103. /** RGBA_INTEGER */
  27104. Constants.TEXTUREFORMAT_RGBA_INTEGER = 11;
  27105. /** UNSIGNED_BYTE */
  27106. Constants.TEXTURETYPE_UNSIGNED_BYTE = 0;
  27107. /** UNSIGNED_BYTE (2nd reference) */
  27108. Constants.TEXTURETYPE_UNSIGNED_INT = 0;
  27109. /** FLOAT */
  27110. Constants.TEXTURETYPE_FLOAT = 1;
  27111. /** HALF_FLOAT */
  27112. Constants.TEXTURETYPE_HALF_FLOAT = 2;
  27113. /** BYTE */
  27114. Constants.TEXTURETYPE_BYTE = 3;
  27115. /** SHORT */
  27116. Constants.TEXTURETYPE_SHORT = 4;
  27117. /** UNSIGNED_SHORT */
  27118. Constants.TEXTURETYPE_UNSIGNED_SHORT = 5;
  27119. /** INT */
  27120. Constants.TEXTURETYPE_INT = 6;
  27121. /** UNSIGNED_INT */
  27122. Constants.TEXTURETYPE_UNSIGNED_INTEGER = 7;
  27123. /** UNSIGNED_SHORT_4_4_4_4 */
  27124. Constants.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = 8;
  27125. /** UNSIGNED_SHORT_5_5_5_1 */
  27126. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = 9;
  27127. /** UNSIGNED_SHORT_5_6_5 */
  27128. Constants.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = 10;
  27129. /** UNSIGNED_INT_2_10_10_10_REV */
  27130. Constants.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = 11;
  27131. /** UNSIGNED_INT_24_8 */
  27132. Constants.TEXTURETYPE_UNSIGNED_INT_24_8 = 12;
  27133. /** UNSIGNED_INT_10F_11F_11F_REV */
  27134. Constants.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = 13;
  27135. /** UNSIGNED_INT_5_9_9_9_REV */
  27136. Constants.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = 14;
  27137. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  27138. Constants.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = 15;
  27139. /** nearest is mag = nearest and min = nearest and mip = linear */
  27140. Constants.TEXTURE_NEAREST_SAMPLINGMODE = 1;
  27141. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27142. Constants.TEXTURE_BILINEAR_SAMPLINGMODE = 2;
  27143. /** Trilinear is mag = linear and min = linear and mip = linear */
  27144. Constants.TEXTURE_TRILINEAR_SAMPLINGMODE = 3;
  27145. /** nearest is mag = nearest and min = nearest and mip = linear */
  27146. Constants.TEXTURE_NEAREST_NEAREST_MIPLINEAR = 1;
  27147. /** Bilinear is mag = linear and min = linear and mip = nearest */
  27148. Constants.TEXTURE_LINEAR_LINEAR_MIPNEAREST = 2;
  27149. /** Trilinear is mag = linear and min = linear and mip = linear */
  27150. Constants.TEXTURE_LINEAR_LINEAR_MIPLINEAR = 3;
  27151. /** mag = nearest and min = nearest and mip = nearest */
  27152. Constants.TEXTURE_NEAREST_NEAREST_MIPNEAREST = 4;
  27153. /** mag = nearest and min = linear and mip = nearest */
  27154. Constants.TEXTURE_NEAREST_LINEAR_MIPNEAREST = 5;
  27155. /** mag = nearest and min = linear and mip = linear */
  27156. Constants.TEXTURE_NEAREST_LINEAR_MIPLINEAR = 6;
  27157. /** mag = nearest and min = linear and mip = none */
  27158. Constants.TEXTURE_NEAREST_LINEAR = 7;
  27159. /** mag = nearest and min = nearest and mip = none */
  27160. Constants.TEXTURE_NEAREST_NEAREST = 8;
  27161. /** mag = linear and min = nearest and mip = nearest */
  27162. Constants.TEXTURE_LINEAR_NEAREST_MIPNEAREST = 9;
  27163. /** mag = linear and min = nearest and mip = linear */
  27164. Constants.TEXTURE_LINEAR_NEAREST_MIPLINEAR = 10;
  27165. /** mag = linear and min = linear and mip = none */
  27166. Constants.TEXTURE_LINEAR_LINEAR = 11;
  27167. /** mag = linear and min = nearest and mip = none */
  27168. Constants.TEXTURE_LINEAR_NEAREST = 12;
  27169. /** Explicit coordinates mode */
  27170. Constants.TEXTURE_EXPLICIT_MODE = 0;
  27171. /** Spherical coordinates mode */
  27172. Constants.TEXTURE_SPHERICAL_MODE = 1;
  27173. /** Planar coordinates mode */
  27174. Constants.TEXTURE_PLANAR_MODE = 2;
  27175. /** Cubic coordinates mode */
  27176. Constants.TEXTURE_CUBIC_MODE = 3;
  27177. /** Projection coordinates mode */
  27178. Constants.TEXTURE_PROJECTION_MODE = 4;
  27179. /** Skybox coordinates mode */
  27180. Constants.TEXTURE_SKYBOX_MODE = 5;
  27181. /** Inverse Cubic coordinates mode */
  27182. Constants.TEXTURE_INVCUBIC_MODE = 6;
  27183. /** Equirectangular coordinates mode */
  27184. Constants.TEXTURE_EQUIRECTANGULAR_MODE = 7;
  27185. /** Equirectangular Fixed coordinates mode */
  27186. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = 8;
  27187. /** Equirectangular Fixed Mirrored coordinates mode */
  27188. Constants.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = 9;
  27189. // Texture rescaling mode
  27190. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  27191. Constants.SCALEMODE_FLOOR = 1;
  27192. /** Defines that texture rescaling will look for the nearest power of 2 size */
  27193. Constants.SCALEMODE_NEAREST = 2;
  27194. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  27195. Constants.SCALEMODE_CEILING = 3;
  27196. /**
  27197. * The dirty texture flag value
  27198. */
  27199. Constants.MATERIAL_TextureDirtyFlag = 1;
  27200. /**
  27201. * The dirty light flag value
  27202. */
  27203. Constants.MATERIAL_LightDirtyFlag = 2;
  27204. /**
  27205. * The dirty fresnel flag value
  27206. */
  27207. Constants.MATERIAL_FresnelDirtyFlag = 4;
  27208. /**
  27209. * The dirty attribute flag value
  27210. */
  27211. Constants.MATERIAL_AttributesDirtyFlag = 8;
  27212. /**
  27213. * The dirty misc flag value
  27214. */
  27215. Constants.MATERIAL_MiscDirtyFlag = 16;
  27216. /**
  27217. * The all dirty flag value
  27218. */
  27219. Constants.MATERIAL_AllDirtyFlag = 31;
  27220. /**
  27221. * Returns the triangle fill mode
  27222. */
  27223. Constants.MATERIAL_TriangleFillMode = 0;
  27224. /**
  27225. * Returns the wireframe mode
  27226. */
  27227. Constants.MATERIAL_WireFrameFillMode = 1;
  27228. /**
  27229. * Returns the point fill mode
  27230. */
  27231. Constants.MATERIAL_PointFillMode = 2;
  27232. /**
  27233. * Returns the point list draw mode
  27234. */
  27235. Constants.MATERIAL_PointListDrawMode = 3;
  27236. /**
  27237. * Returns the line list draw mode
  27238. */
  27239. Constants.MATERIAL_LineListDrawMode = 4;
  27240. /**
  27241. * Returns the line loop draw mode
  27242. */
  27243. Constants.MATERIAL_LineLoopDrawMode = 5;
  27244. /**
  27245. * Returns the line strip draw mode
  27246. */
  27247. Constants.MATERIAL_LineStripDrawMode = 6;
  27248. /**
  27249. * Returns the triangle strip draw mode
  27250. */
  27251. Constants.MATERIAL_TriangleStripDrawMode = 7;
  27252. /**
  27253. * Returns the triangle fan draw mode
  27254. */
  27255. Constants.MATERIAL_TriangleFanDrawMode = 8;
  27256. /**
  27257. * Stores the clock-wise side orientation
  27258. */
  27259. Constants.MATERIAL_ClockWiseSideOrientation = 0;
  27260. /**
  27261. * Stores the counter clock-wise side orientation
  27262. */
  27263. Constants.MATERIAL_CounterClockWiseSideOrientation = 1;
  27264. /**
  27265. * Nothing
  27266. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27267. */
  27268. Constants.ACTION_NothingTrigger = 0;
  27269. /**
  27270. * On pick
  27271. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27272. */
  27273. Constants.ACTION_OnPickTrigger = 1;
  27274. /**
  27275. * On left pick
  27276. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27277. */
  27278. Constants.ACTION_OnLeftPickTrigger = 2;
  27279. /**
  27280. * On right pick
  27281. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27282. */
  27283. Constants.ACTION_OnRightPickTrigger = 3;
  27284. /**
  27285. * On center pick
  27286. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27287. */
  27288. Constants.ACTION_OnCenterPickTrigger = 4;
  27289. /**
  27290. * On pick down
  27291. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27292. */
  27293. Constants.ACTION_OnPickDownTrigger = 5;
  27294. /**
  27295. * On double pick
  27296. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27297. */
  27298. Constants.ACTION_OnDoublePickTrigger = 6;
  27299. /**
  27300. * On pick up
  27301. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27302. */
  27303. Constants.ACTION_OnPickUpTrigger = 7;
  27304. /**
  27305. * On pick out.
  27306. * This trigger will only be raised if you also declared a OnPickDown
  27307. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27308. */
  27309. Constants.ACTION_OnPickOutTrigger = 16;
  27310. /**
  27311. * On long press
  27312. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27313. */
  27314. Constants.ACTION_OnLongPressTrigger = 8;
  27315. /**
  27316. * On pointer over
  27317. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27318. */
  27319. Constants.ACTION_OnPointerOverTrigger = 9;
  27320. /**
  27321. * On pointer out
  27322. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27323. */
  27324. Constants.ACTION_OnPointerOutTrigger = 10;
  27325. /**
  27326. * On every frame
  27327. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27328. */
  27329. Constants.ACTION_OnEveryFrameTrigger = 11;
  27330. /**
  27331. * On intersection enter
  27332. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27333. */
  27334. Constants.ACTION_OnIntersectionEnterTrigger = 12;
  27335. /**
  27336. * On intersection exit
  27337. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27338. */
  27339. Constants.ACTION_OnIntersectionExitTrigger = 13;
  27340. /**
  27341. * On key down
  27342. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27343. */
  27344. Constants.ACTION_OnKeyDownTrigger = 14;
  27345. /**
  27346. * On key up
  27347. * @see http://doc.babylonjs.com/how_to/how_to_use_actions#triggers
  27348. */
  27349. Constants.ACTION_OnKeyUpTrigger = 15;
  27350. /**
  27351. * Billboard mode will only apply to Y axis
  27352. */
  27353. Constants.PARTICLES_BILLBOARDMODE_Y = 2;
  27354. /**
  27355. * Billboard mode will apply to all axes
  27356. */
  27357. Constants.PARTICLES_BILLBOARDMODE_ALL = 7;
  27358. /**
  27359. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  27360. */
  27361. Constants.PARTICLES_BILLBOARDMODE_STRETCHED = 8;
  27362. /**
  27363. * Gets or sets base Assets URL
  27364. */
  27365. Constants.PARTICLES_BaseAssetsUrl = "https://assets.babylonjs.com/particles";
  27366. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  27367. * Test order :
  27368. * Is the bounding sphere outside the frustum ?
  27369. * If not, are the bounding box vertices outside the frustum ?
  27370. * It not, then the cullable object is in the frustum.
  27371. */
  27372. Constants.MESHES_CULLINGSTRATEGY_STANDARD = 0;
  27373. /** Culling strategy : Bounding Sphere Only.
  27374. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  27375. * It's also less accurate than the standard because some not visible objects can still be selected.
  27376. * Test : is the bounding sphere outside the frustum ?
  27377. * If not, then the cullable object is in the frustum.
  27378. */
  27379. Constants.MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = 1;
  27380. /** Culling strategy : Optimistic Inclusion.
  27381. * This in an inclusion test first, then the standard exclusion test.
  27382. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  27383. * 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.
  27384. * Anyway, it's as accurate as the standard strategy.
  27385. * Test :
  27386. * Is the cullable object bounding sphere center in the frustum ?
  27387. * If not, apply the default culling strategy.
  27388. */
  27389. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = 2;
  27390. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  27391. * This in an inclusion test first, then the bounding sphere only exclusion test.
  27392. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  27393. * 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.
  27394. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  27395. * Test :
  27396. * Is the cullable object bounding sphere center in the frustum ?
  27397. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  27398. */
  27399. Constants.MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = 3;
  27400. /**
  27401. * No logging while loading
  27402. */
  27403. Constants.SCENELOADER_NO_LOGGING = 0;
  27404. /**
  27405. * Minimal logging while loading
  27406. */
  27407. Constants.SCENELOADER_MINIMAL_LOGGING = 1;
  27408. /**
  27409. * Summary logging while loading
  27410. */
  27411. Constants.SCENELOADER_SUMMARY_LOGGING = 2;
  27412. /**
  27413. * Detailled logging while loading
  27414. */
  27415. Constants.SCENELOADER_DETAILED_LOGGING = 3;
  27416. return Constants;
  27417. }());
  27418. /***/ }),
  27419. /***/ "./Engines/engine.ts":
  27420. /*!***************************!*\
  27421. !*** ./Engines/engine.ts ***!
  27422. \***************************/
  27423. /*! exports provided: InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine */
  27424. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  27425. "use strict";
  27426. __webpack_require__.r(__webpack_exports__);
  27427. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return InstancingAttributeInfo; });
  27428. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return DepthTextureCreationOptions; });
  27429. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return EngineCapabilities; });
  27430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return Engine; });
  27431. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  27432. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  27433. /* harmony import */ var _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/performanceMonitor */ "./Misc/performanceMonitor.ts");
  27434. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  27435. /* harmony import */ var _Misc_promise__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/promise */ "./Misc/promise.ts");
  27436. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  27437. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  27438. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  27439. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  27440. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  27441. /* harmony import */ var _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  27442. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  27443. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../States/index */ "./States/index.ts");
  27444. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  27445. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  27446. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  27447. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  27448. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  27449. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  27450. /**
  27451. * Keeps track of all the buffer info used in engine.
  27452. */
  27453. var BufferPointer = /** @class */ (function () {
  27454. function BufferPointer() {
  27455. }
  27456. return BufferPointer;
  27457. }());
  27458. /**
  27459. * Interface for attribute information associated with buffer instanciation
  27460. */
  27461. var InstancingAttributeInfo = /** @class */ (function () {
  27462. function InstancingAttributeInfo() {
  27463. }
  27464. return InstancingAttributeInfo;
  27465. }());
  27466. /**
  27467. * Define options used to create a depth texture
  27468. */
  27469. var DepthTextureCreationOptions = /** @class */ (function () {
  27470. function DepthTextureCreationOptions() {
  27471. }
  27472. return DepthTextureCreationOptions;
  27473. }());
  27474. /**
  27475. * Class used to describe the capabilities of the engine relatively to the current browser
  27476. */
  27477. var EngineCapabilities = /** @class */ (function () {
  27478. function EngineCapabilities() {
  27479. }
  27480. return EngineCapabilities;
  27481. }());
  27482. /**
  27483. * The engine class is responsible for interfacing with all lower-level APIs such as WebGL and Audio
  27484. */
  27485. var Engine = /** @class */ (function () {
  27486. /**
  27487. * Creates a new engine
  27488. * @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
  27489. * @param antialias defines enable antialiasing (default: false)
  27490. * @param options defines further options to be sent to the getContext() function
  27491. * @param adaptToDeviceRatio defines whether to adapt to the device's viewport characteristics (default: false)
  27492. */
  27493. function Engine(canvasOrContext, antialias, options, adaptToDeviceRatio) {
  27494. if (adaptToDeviceRatio === void 0) { adaptToDeviceRatio = false; }
  27495. var _this = this;
  27496. // Public members
  27497. /**
  27498. * Gets or sets a boolean that indicates if textures must be forced to power of 2 size even if not required
  27499. */
  27500. this.forcePOTTextures = false;
  27501. /**
  27502. * Gets a boolean indicating if the engine is currently rendering in fullscreen mode
  27503. */
  27504. this.isFullscreen = false;
  27505. /**
  27506. * Gets a boolean indicating if the pointer is currently locked
  27507. */
  27508. this.isPointerLock = false;
  27509. /**
  27510. * Gets or sets a boolean indicating if back faces must be culled (true by default)
  27511. */
  27512. this.cullBackFaces = true;
  27513. /**
  27514. * Gets or sets a boolean indicating if the engine must keep rendering even if the window is not in foregroun
  27515. */
  27516. this.renderEvenInBackground = true;
  27517. /**
  27518. * Gets or sets a boolean indicating that cache can be kept between frames
  27519. */
  27520. this.preventCacheWipeBetweenFrames = false;
  27521. /**
  27522. * Gets or sets a boolean to enable/disable IndexedDB support and avoid XHR on .manifest
  27523. **/
  27524. this.enableOfflineSupport = false;
  27525. /**
  27526. * 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)
  27527. **/
  27528. this.disableManifestCheck = false;
  27529. /**
  27530. * Gets the list of created scenes
  27531. */
  27532. this.scenes = new Array();
  27533. /**
  27534. * Event raised when a new scene is created
  27535. */
  27536. this.onNewSceneAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27537. /**
  27538. * Gets the list of created postprocesses
  27539. */
  27540. this.postProcesses = new Array();
  27541. /** Gets or sets a boolean indicating if the engine should validate programs after compilation */
  27542. this.validateShaderPrograms = false;
  27543. // Observables
  27544. /**
  27545. * Observable event triggered each time the rendering canvas is resized
  27546. */
  27547. this.onResizeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27548. /**
  27549. * Observable event triggered each time the canvas loses focus
  27550. */
  27551. this.onCanvasBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27552. /**
  27553. * Observable event triggered each time the canvas gains focus
  27554. */
  27555. this.onCanvasFocusObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27556. /**
  27557. * Observable event triggered each time the canvas receives pointerout event
  27558. */
  27559. this.onCanvasPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27560. /**
  27561. * Observable event triggered before each texture is initialized
  27562. */
  27563. this.onBeforeTextureInitObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27564. //WebVR
  27565. this._vrDisplay = undefined;
  27566. this._vrSupported = false;
  27567. this._vrExclusivePointerMode = false;
  27568. // Uniform buffers list
  27569. /**
  27570. * Gets or sets a boolean indicating that uniform buffers must be disabled even if they are supported
  27571. */
  27572. this.disableUniformBuffers = false;
  27573. /** @hidden */
  27574. this._uniformBuffers = new Array();
  27575. // Observables
  27576. /**
  27577. * Observable raised when the engine begins a new frame
  27578. */
  27579. this.onBeginFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27580. /**
  27581. * If set, will be used to request the next animation frame for the render loop
  27582. */
  27583. this.customAnimationFrameRequester = null;
  27584. /**
  27585. * Observable raised when the engine ends the current frame
  27586. */
  27587. this.onEndFrameObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27588. /**
  27589. * Observable raised when the engine is about to compile a shader
  27590. */
  27591. this.onBeforeShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27592. /**
  27593. * Observable raised when the engine has jsut compiled a shader
  27594. */
  27595. this.onAfterShaderCompilationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27596. this._windowIsBackground = false;
  27597. this._webGLVersion = 1.0;
  27598. /** @hidden */
  27599. this._badOS = false;
  27600. /** @hidden */
  27601. this._badDesktopOS = false;
  27602. /**
  27603. * Gets or sets a value indicating if we want to disable texture binding optimization.
  27604. * This could be required on some buggy drivers which wants to have textures bound in a progressive order.
  27605. * By default Babylon.js will try to let textures bound where they are and only update the samplers to point where the texture is
  27606. */
  27607. this.disableTextureBindingOptimization = false;
  27608. /**
  27609. * Observable signaled when VR display mode changes
  27610. */
  27611. this.onVRDisplayChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27612. /**
  27613. * Observable signaled when VR request present is complete
  27614. */
  27615. this.onVRRequestPresentComplete = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27616. /**
  27617. * Observable signaled when VR request present starts
  27618. */
  27619. this.onVRRequestPresentStart = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27620. this._colorWrite = true;
  27621. /** @hidden */
  27622. this._drawCalls = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27623. /** @hidden */
  27624. this._textureCollisions = new _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["PerfCounter"]();
  27625. this._renderingQueueLaunched = false;
  27626. this._activeRenderLoops = new Array();
  27627. // Deterministic lockstepMaxSteps
  27628. this._deterministicLockstep = false;
  27629. this._lockstepMaxSteps = 4;
  27630. // Lost context
  27631. /**
  27632. * Observable signaled when a context lost event is raised
  27633. */
  27634. this.onContextLostObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27635. /**
  27636. * Observable signaled when a context restored event is raised
  27637. */
  27638. this.onContextRestoredObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  27639. this._contextWasLost = false;
  27640. this._doNotHandleContextLost = false;
  27641. // FPS
  27642. this._performanceMonitor = new _Misc_performanceMonitor__WEBPACK_IMPORTED_MODULE_2__["PerformanceMonitor"]();
  27643. this._fps = 60;
  27644. this._deltaTime = 0;
  27645. /**
  27646. * Turn this value on if you want to pause FPS computation when in background
  27647. */
  27648. this.disablePerformanceMonitorInBackground = false;
  27649. // States
  27650. /** @hidden */
  27651. this._depthCullingState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_DepthCullingState"]();
  27652. /** @hidden */
  27653. this._stencilState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_StencilState"]();
  27654. /** @hidden */
  27655. this._alphaState = new _States_index__WEBPACK_IMPORTED_MODULE_12__["_AlphaState"]();
  27656. /** @hidden */
  27657. this._alphaMode = Engine.ALPHA_DISABLE;
  27658. // Cache
  27659. this._internalTexturesCache = new Array();
  27660. /** @hidden */
  27661. this._activeChannel = 0;
  27662. this._currentTextureChannel = -1;
  27663. /** @hidden */
  27664. this._boundTexturesCache = {};
  27665. this._compiledEffects = {};
  27666. this._vertexAttribArraysEnabled = [];
  27667. this._uintIndicesCurrentlySet = false;
  27668. this._currentBoundBuffer = new Array();
  27669. /** @hidden */
  27670. this._currentFramebuffer = null;
  27671. this._currentBufferPointers = new Array();
  27672. this._currentInstanceLocations = new Array();
  27673. this._currentInstanceBuffers = new Array();
  27674. this._firstBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27675. this._lastBoundInternalTextureTracker = new _Materials_Textures_internalTextureTracker__WEBPACK_IMPORTED_MODULE_10__["DummyInternalTextureTracker"]();
  27676. this._vaoRecordInProgress = false;
  27677. this._mustWipeVertexAttributes = false;
  27678. this._nextFreeTextureSlots = new Array();
  27679. this._maxSimultaneousTextures = 0;
  27680. this._activeRequests = new Array();
  27681. // Hardware supported Compressed Textures
  27682. this._texturesSupported = new Array();
  27683. /**
  27684. * Defines whether the engine has been created with the premultipliedAlpha option on or not.
  27685. */
  27686. this.premultipliedAlpha = true;
  27687. this._viewportCached = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](0, 0, 0, 0);
  27688. this._onVRFullScreenTriggered = function () {
  27689. if (_this._vrDisplay && _this._vrDisplay.isPresenting) {
  27690. //get the old size before we change
  27691. _this._oldSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Size"](_this.getRenderWidth(), _this.getRenderHeight());
  27692. _this._oldHardwareScaleFactor = _this.getHardwareScalingLevel();
  27693. //get the width and height, change the render size
  27694. var leftEye = _this._vrDisplay.getEyeParameters('left');
  27695. _this.setHardwareScalingLevel(1);
  27696. _this.setSize(leftEye.renderWidth * 2, leftEye.renderHeight);
  27697. }
  27698. else {
  27699. _this.setHardwareScalingLevel(_this._oldHardwareScaleFactor);
  27700. _this.setSize(_this._oldSize.width, _this._oldSize.height);
  27701. }
  27702. };
  27703. this._unpackFlipYCached = null;
  27704. /**
  27705. * In case you are sharing the context with other applications, it might
  27706. * be interested to not cache the unpack flip y state to ensure a consistent
  27707. * value would be set.
  27708. */
  27709. this.enableUnpackFlipYCached = true;
  27710. this._boundUniforms = {};
  27711. // Register promises
  27712. _Misc_promise__WEBPACK_IMPORTED_MODULE_4__["PromisePolyfill"].Apply();
  27713. var canvas = null;
  27714. Engine.Instances.push(this);
  27715. if (!canvasOrContext) {
  27716. return;
  27717. }
  27718. options = options || {};
  27719. if (canvasOrContext.getContext) {
  27720. canvas = canvasOrContext;
  27721. this._renderingCanvas = canvas;
  27722. if (antialias != null) {
  27723. options.antialias = antialias;
  27724. }
  27725. if (options.deterministicLockstep === undefined) {
  27726. options.deterministicLockstep = false;
  27727. }
  27728. if (options.lockstepMaxSteps === undefined) {
  27729. options.lockstepMaxSteps = 4;
  27730. }
  27731. if (options.preserveDrawingBuffer === undefined) {
  27732. options.preserveDrawingBuffer = false;
  27733. }
  27734. if (options.audioEngine === undefined) {
  27735. options.audioEngine = true;
  27736. }
  27737. if (options.stencil === undefined) {
  27738. options.stencil = true;
  27739. }
  27740. if (options.premultipliedAlpha === false) {
  27741. this.premultipliedAlpha = false;
  27742. }
  27743. this._deterministicLockstep = options.deterministicLockstep;
  27744. this._lockstepMaxSteps = options.lockstepMaxSteps;
  27745. this._doNotHandleContextLost = options.doNotHandleContextLost ? true : false;
  27746. // Exceptions
  27747. if (navigator && navigator.userAgent) {
  27748. var ua = navigator.userAgent;
  27749. for (var _i = 0, _a = Engine.ExceptionList; _i < _a.length; _i++) {
  27750. var exception = _a[_i];
  27751. var key = exception.key;
  27752. var targets = exception.targets;
  27753. if (ua.indexOf(key) > -1) {
  27754. if (exception.capture && exception.captureConstraint) {
  27755. var capture = exception.capture;
  27756. var constraint = exception.captureConstraint;
  27757. var regex = new RegExp(capture);
  27758. var matches = regex.exec(ua);
  27759. if (matches && matches.length > 0) {
  27760. var capturedValue = parseInt(matches[matches.length - 1]);
  27761. if (capturedValue >= constraint) {
  27762. continue;
  27763. }
  27764. }
  27765. }
  27766. for (var _b = 0, targets_1 = targets; _b < targets_1.length; _b++) {
  27767. var target = targets_1[_b];
  27768. switch (target) {
  27769. case "uniformBuffer":
  27770. this.disableUniformBuffers = true;
  27771. break;
  27772. case "textureBindingOptimization":
  27773. this.disableTextureBindingOptimization = true;
  27774. break;
  27775. }
  27776. }
  27777. }
  27778. }
  27779. }
  27780. // GL
  27781. if (!options.disableWebGL2Support) {
  27782. try {
  27783. this._gl = (canvas.getContext("webgl2", options) || canvas.getContext("experimental-webgl2", options));
  27784. if (this._gl) {
  27785. this._webGLVersion = 2.0;
  27786. // Prevent weird browsers to lie :-)
  27787. if (!this._gl.deleteQuery) {
  27788. this._webGLVersion = 1.0;
  27789. }
  27790. }
  27791. }
  27792. catch (e) {
  27793. // Do nothing
  27794. }
  27795. }
  27796. if (!this._gl) {
  27797. if (!canvas) {
  27798. throw new Error("The provided canvas is null or undefined.");
  27799. }
  27800. try {
  27801. this._gl = (canvas.getContext("webgl", options) || canvas.getContext("experimental-webgl", options));
  27802. }
  27803. catch (e) {
  27804. throw new Error("WebGL not supported");
  27805. }
  27806. }
  27807. if (!this._gl) {
  27808. throw new Error("WebGL not supported");
  27809. }
  27810. this._onCanvasFocus = function () {
  27811. _this.onCanvasFocusObservable.notifyObservers(_this);
  27812. };
  27813. this._onCanvasBlur = function () {
  27814. _this.onCanvasBlurObservable.notifyObservers(_this);
  27815. };
  27816. canvas.addEventListener("focus", this._onCanvasFocus);
  27817. canvas.addEventListener("blur", this._onCanvasBlur);
  27818. this._onBlur = function () {
  27819. if (_this.disablePerformanceMonitorInBackground) {
  27820. _this._performanceMonitor.disable();
  27821. }
  27822. _this._windowIsBackground = true;
  27823. };
  27824. this._onFocus = function () {
  27825. if (_this.disablePerformanceMonitorInBackground) {
  27826. _this._performanceMonitor.enable();
  27827. }
  27828. _this._windowIsBackground = false;
  27829. };
  27830. this._onCanvasPointerOut = function (ev) {
  27831. _this.onCanvasPointerOutObservable.notifyObservers(ev);
  27832. };
  27833. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27834. window.addEventListener("blur", this._onBlur);
  27835. window.addEventListener("focus", this._onFocus);
  27836. }
  27837. canvas.addEventListener("pointerout", this._onCanvasPointerOut);
  27838. // Context lost
  27839. if (!this._doNotHandleContextLost) {
  27840. this._onContextLost = function (evt) {
  27841. evt.preventDefault();
  27842. _this._contextWasLost = true;
  27843. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context lost.");
  27844. _this.onContextLostObservable.notifyObservers(_this);
  27845. };
  27846. this._onContextRestored = function () {
  27847. // Adding a timeout to avoid race condition at browser level
  27848. setTimeout(function () {
  27849. // Rebuild gl context
  27850. _this._initGLContext();
  27851. // Rebuild effects
  27852. _this._rebuildEffects();
  27853. // Rebuild textures
  27854. _this._rebuildInternalTextures();
  27855. // Rebuild buffers
  27856. _this._rebuildBuffers();
  27857. // Cache
  27858. _this.wipeCaches(true);
  27859. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("WebGL context successfully restored.");
  27860. _this.onContextRestoredObservable.notifyObservers(_this);
  27861. _this._contextWasLost = false;
  27862. }, 0);
  27863. };
  27864. canvas.addEventListener("webglcontextlost", this._onContextLost, false);
  27865. canvas.addEventListener("webglcontextrestored", this._onContextRestored, false);
  27866. }
  27867. if (!options.doNotHandleTouchAction) {
  27868. this._disableTouchAction();
  27869. }
  27870. }
  27871. else {
  27872. this._gl = canvasOrContext;
  27873. this._renderingCanvas = this._gl.canvas;
  27874. if (this._gl.renderbufferStorageMultisample) {
  27875. this._webGLVersion = 2.0;
  27876. }
  27877. var attributes = this._gl.getContextAttributes();
  27878. if (attributes) {
  27879. options.stencil = attributes.stencil;
  27880. }
  27881. }
  27882. // Viewport
  27883. var devicePixelRatio = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist() ? (window.devicePixelRatio || 1.0) : 1.0;
  27884. var limitDeviceRatio = options.limitDeviceRatio || devicePixelRatio;
  27885. this._hardwareScalingLevel = adaptToDeviceRatio ? 1.0 / Math.min(limitDeviceRatio, devicePixelRatio) : 1.0;
  27886. this.resize();
  27887. this._isStencilEnable = options.stencil ? true : false;
  27888. this._initGLContext();
  27889. if (canvas) {
  27890. // Fullscreen
  27891. this._onFullscreenChange = function () {
  27892. if (document.fullscreen !== undefined) {
  27893. _this.isFullscreen = document.fullscreen;
  27894. }
  27895. else if (document.mozFullScreen !== undefined) {
  27896. _this.isFullscreen = document.mozFullScreen;
  27897. }
  27898. else if (document.webkitIsFullScreen !== undefined) {
  27899. _this.isFullscreen = document.webkitIsFullScreen;
  27900. }
  27901. else if (document.msIsFullScreen !== undefined) {
  27902. _this.isFullscreen = document.msIsFullScreen;
  27903. }
  27904. // Pointer lock
  27905. if (_this.isFullscreen && _this._pointerLockRequested && canvas) {
  27906. canvas.requestPointerLock = canvas.requestPointerLock ||
  27907. canvas.msRequestPointerLock ||
  27908. canvas.mozRequestPointerLock ||
  27909. canvas.webkitRequestPointerLock;
  27910. if (canvas.requestPointerLock) {
  27911. canvas.requestPointerLock();
  27912. }
  27913. }
  27914. };
  27915. document.addEventListener("fullscreenchange", this._onFullscreenChange, false);
  27916. document.addEventListener("mozfullscreenchange", this._onFullscreenChange, false);
  27917. document.addEventListener("webkitfullscreenchange", this._onFullscreenChange, false);
  27918. document.addEventListener("msfullscreenchange", this._onFullscreenChange, false);
  27919. // Pointer lock
  27920. this._onPointerLockChange = function () {
  27921. _this.isPointerLock = (document.mozPointerLockElement === canvas ||
  27922. document.webkitPointerLockElement === canvas ||
  27923. document.msPointerLockElement === canvas ||
  27924. document.pointerLockElement === canvas);
  27925. };
  27926. document.addEventListener("pointerlockchange", this._onPointerLockChange, false);
  27927. document.addEventListener("mspointerlockchange", this._onPointerLockChange, false);
  27928. document.addEventListener("mozpointerlockchange", this._onPointerLockChange, false);
  27929. document.addEventListener("webkitpointerlockchange", this._onPointerLockChange, false);
  27930. this._onVRDisplayPointerRestricted = function () {
  27931. if (canvas) {
  27932. canvas.requestPointerLock();
  27933. }
  27934. };
  27935. this._onVRDisplayPointerUnrestricted = function () {
  27936. document.exitPointerLock();
  27937. };
  27938. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  27939. window.addEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted, false);
  27940. window.addEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted, false);
  27941. }
  27942. }
  27943. // Create Audio Engine if needed.
  27944. if (!Engine.audioEngine && options.audioEngine && Engine.AudioEngineFactory) {
  27945. Engine.audioEngine = Engine.AudioEngineFactory(this.getRenderingCanvas());
  27946. }
  27947. // Prepare buffer pointers
  27948. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  27949. this._currentBufferPointers[i] = new BufferPointer();
  27950. }
  27951. this._linkTrackers(this._firstBoundInternalTextureTracker, this._lastBoundInternalTextureTracker);
  27952. // Load WebVR Devices
  27953. if (options.autoEnableWebVR) {
  27954. this.initWebVR();
  27955. }
  27956. // Detect if we are running on a faulty buggy OS.
  27957. this._badOS = /iPad/i.test(navigator.userAgent) || /iPhone/i.test(navigator.userAgent);
  27958. // Detect if we are running on a faulty buggy desktop OS.
  27959. this._badDesktopOS = /^((?!chrome|android).)*safari/i.test(navigator.userAgent);
  27960. console.log("Babylon.js v" + Engine.Version + " - " + this.description);
  27961. this.enableOfflineSupport = Engine.OfflineProviderFactory !== undefined;
  27962. }
  27963. Object.defineProperty(Engine, "Instances", {
  27964. /** Gets the list of created engines */
  27965. get: function () {
  27966. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].Instances;
  27967. },
  27968. enumerable: true,
  27969. configurable: true
  27970. });
  27971. Object.defineProperty(Engine, "LastCreatedEngine", {
  27972. /**
  27973. * Gets the latest created engine
  27974. */
  27975. get: function () {
  27976. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine;
  27977. },
  27978. enumerable: true,
  27979. configurable: true
  27980. });
  27981. Object.defineProperty(Engine, "LastCreatedScene", {
  27982. /**
  27983. * Gets the latest created scene
  27984. */
  27985. get: function () {
  27986. return _engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  27987. },
  27988. enumerable: true,
  27989. configurable: true
  27990. });
  27991. /**
  27992. * Will flag all materials in all scenes in all engines as dirty to trigger new shader compilation
  27993. * @param flag defines which part of the materials must be marked as dirty
  27994. * @param predicate defines a predicate used to filter which materials should be affected
  27995. */
  27996. Engine.MarkAllMaterialsAsDirty = function (flag, predicate) {
  27997. for (var engineIndex = 0; engineIndex < Engine.Instances.length; engineIndex++) {
  27998. var engine = Engine.Instances[engineIndex];
  27999. for (var sceneIndex = 0; sceneIndex < engine.scenes.length; sceneIndex++) {
  28000. engine.scenes[sceneIndex].markAllMaterialsAsDirty(flag, predicate);
  28001. }
  28002. }
  28003. };
  28004. Object.defineProperty(Engine, "Version", {
  28005. /**
  28006. * Returns the current version of the framework
  28007. */
  28008. get: function () {
  28009. return "4.0.0-alpha.22";
  28010. },
  28011. enumerable: true,
  28012. configurable: true
  28013. });
  28014. Object.defineProperty(Engine.prototype, "description", {
  28015. /**
  28016. * Returns a string describing the current engine
  28017. */
  28018. get: function () {
  28019. var description = "WebGL" + this.webGLVersion;
  28020. if (this._caps.parallelShaderCompile) {
  28021. description += " - Parallel shader compilation";
  28022. }
  28023. return description;
  28024. },
  28025. enumerable: true,
  28026. configurable: true
  28027. });
  28028. Object.defineProperty(Engine, "ShadersRepository", {
  28029. /**
  28030. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  28031. */
  28032. get: function () {
  28033. return _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository;
  28034. },
  28035. set: function (value) {
  28036. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ShadersRepository = value;
  28037. },
  28038. enumerable: true,
  28039. configurable: true
  28040. });
  28041. /**
  28042. * Method called to create the default loading screen.
  28043. * This can be overriden in your own app.
  28044. * @param canvas The rendering canvas element
  28045. * @returns The loading screen
  28046. */
  28047. Engine.DefaultLoadingScreenFactory = function (canvas) {
  28048. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_18__["_DevTools"].WarnImport("LoadingScreen");
  28049. };
  28050. Object.defineProperty(Engine.prototype, "isInVRExclusivePointerMode", {
  28051. /**
  28052. * Gets a boolean indicating that the engine is currently in VR exclusive mode for the pointers
  28053. * @see https://docs.microsoft.com/en-us/microsoft-edge/webvr/essentials#mouse-input
  28054. */
  28055. get: function () {
  28056. return this._vrExclusivePointerMode;
  28057. },
  28058. enumerable: true,
  28059. configurable: true
  28060. });
  28061. Object.defineProperty(Engine.prototype, "supportsUniformBuffers", {
  28062. /**
  28063. * Gets a boolean indicating that the engine supports uniform buffers
  28064. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  28065. */
  28066. get: function () {
  28067. return this.webGLVersion > 1 && !this.disableUniformBuffers;
  28068. },
  28069. enumerable: true,
  28070. configurable: true
  28071. });
  28072. Object.defineProperty(Engine.prototype, "needPOTTextures", {
  28073. /**
  28074. * Gets a boolean indicating that only power of 2 textures are supported
  28075. * Please note that you can still use non power of 2 textures but in this case the engine will forcefully convert them
  28076. */
  28077. get: function () {
  28078. return this._webGLVersion < 2 || this.forcePOTTextures;
  28079. },
  28080. enumerable: true,
  28081. configurable: true
  28082. });
  28083. Object.defineProperty(Engine.prototype, "doNotHandleContextLost", {
  28084. /**
  28085. * Gets or sets a boolean indicating if resources should be retained to be able to handle context lost events
  28086. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#handling-webgl-context-lost
  28087. */
  28088. get: function () {
  28089. return this._doNotHandleContextLost;
  28090. },
  28091. set: function (value) {
  28092. this._doNotHandleContextLost = value;
  28093. },
  28094. enumerable: true,
  28095. configurable: true
  28096. });
  28097. Object.defineProperty(Engine.prototype, "performanceMonitor", {
  28098. /**
  28099. * Gets the performance monitor attached to this engine
  28100. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  28101. */
  28102. get: function () {
  28103. return this._performanceMonitor;
  28104. },
  28105. enumerable: true,
  28106. configurable: true
  28107. });
  28108. Object.defineProperty(Engine.prototype, "texturesSupported", {
  28109. /**
  28110. * Gets the list of texture formats supported
  28111. */
  28112. get: function () {
  28113. return this._texturesSupported;
  28114. },
  28115. enumerable: true,
  28116. configurable: true
  28117. });
  28118. Object.defineProperty(Engine.prototype, "textureFormatInUse", {
  28119. /**
  28120. * Gets the list of texture formats in use
  28121. */
  28122. get: function () {
  28123. return this._textureFormatInUse;
  28124. },
  28125. enumerable: true,
  28126. configurable: true
  28127. });
  28128. Object.defineProperty(Engine.prototype, "currentViewport", {
  28129. /**
  28130. * Gets the current viewport
  28131. */
  28132. get: function () {
  28133. return this._cachedViewport;
  28134. },
  28135. enumerable: true,
  28136. configurable: true
  28137. });
  28138. Object.defineProperty(Engine.prototype, "emptyTexture", {
  28139. /**
  28140. * Gets the default empty texture
  28141. */
  28142. get: function () {
  28143. if (!this._emptyTexture) {
  28144. this._emptyTexture = this.createRawTexture(new Uint8Array(4), 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28145. }
  28146. return this._emptyTexture;
  28147. },
  28148. enumerable: true,
  28149. configurable: true
  28150. });
  28151. Object.defineProperty(Engine.prototype, "emptyTexture3D", {
  28152. /**
  28153. * Gets the default empty 3D texture
  28154. */
  28155. get: function () {
  28156. if (!this._emptyTexture3D) {
  28157. this._emptyTexture3D = this.createRawTexture3D(new Uint8Array(4), 1, 1, 1, Engine.TEXTUREFORMAT_RGBA, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28158. }
  28159. return this._emptyTexture3D;
  28160. },
  28161. enumerable: true,
  28162. configurable: true
  28163. });
  28164. Object.defineProperty(Engine.prototype, "emptyCubeTexture", {
  28165. /**
  28166. * Gets the default empty cube texture
  28167. */
  28168. get: function () {
  28169. if (!this._emptyCubeTexture) {
  28170. var faceData = new Uint8Array(4);
  28171. var cubeData = [faceData, faceData, faceData, faceData, faceData, faceData];
  28172. this._emptyCubeTexture = this.createRawCubeTexture(cubeData, 1, Engine.TEXTUREFORMAT_RGBA, Engine.TEXTURETYPE_UNSIGNED_INT, false, false, Engine.TEXTURE_NEAREST_SAMPLINGMODE);
  28173. }
  28174. return this._emptyCubeTexture;
  28175. },
  28176. enumerable: true,
  28177. configurable: true
  28178. });
  28179. Engine.prototype._disableTouchAction = function () {
  28180. if (!this._renderingCanvas) {
  28181. return;
  28182. }
  28183. this._renderingCanvas.setAttribute("touch-action", "none");
  28184. this._renderingCanvas.style.touchAction = "none";
  28185. this._renderingCanvas.style.msTouchAction = "none";
  28186. };
  28187. Engine.prototype._rebuildInternalTextures = function () {
  28188. var currentState = this._internalTexturesCache.slice(); // Do a copy because the rebuild will add proxies
  28189. for (var _i = 0, currentState_1 = currentState; _i < currentState_1.length; _i++) {
  28190. var internalTexture = currentState_1[_i];
  28191. internalTexture._rebuild();
  28192. }
  28193. };
  28194. Engine.prototype._rebuildEffects = function () {
  28195. for (var key in this._compiledEffects) {
  28196. var effect = this._compiledEffects[key];
  28197. effect._prepareEffect();
  28198. }
  28199. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  28200. };
  28201. /**
  28202. * Gets a boolean indicating if all created effects are ready
  28203. * @returns true if all effects are ready
  28204. */
  28205. Engine.prototype.areAllEffectsReady = function () {
  28206. for (var key in this._compiledEffects) {
  28207. var effect = this._compiledEffects[key];
  28208. if (!effect.isReady()) {
  28209. return false;
  28210. }
  28211. }
  28212. return true;
  28213. };
  28214. Engine.prototype._rebuildBuffers = function () {
  28215. // Index / Vertex
  28216. for (var _i = 0, _a = this.scenes; _i < _a.length; _i++) {
  28217. var scene = _a[_i];
  28218. scene.resetCachedMaterial();
  28219. scene._rebuildGeometries();
  28220. scene._rebuildTextures();
  28221. }
  28222. // Uniforms
  28223. for (var _b = 0, _c = this._uniformBuffers; _b < _c.length; _b++) {
  28224. var uniformBuffer = _c[_b];
  28225. uniformBuffer._rebuild();
  28226. }
  28227. };
  28228. Engine.prototype._initGLContext = function () {
  28229. // Caps
  28230. this._caps = new EngineCapabilities();
  28231. this._caps.maxTexturesImageUnits = this._gl.getParameter(this._gl.MAX_TEXTURE_IMAGE_UNITS);
  28232. this._caps.maxCombinedTexturesImageUnits = this._gl.getParameter(this._gl.MAX_COMBINED_TEXTURE_IMAGE_UNITS);
  28233. this._caps.maxVertexTextureImageUnits = this._gl.getParameter(this._gl.MAX_VERTEX_TEXTURE_IMAGE_UNITS);
  28234. this._caps.maxTextureSize = this._gl.getParameter(this._gl.MAX_TEXTURE_SIZE);
  28235. this._caps.maxCubemapTextureSize = this._gl.getParameter(this._gl.MAX_CUBE_MAP_TEXTURE_SIZE);
  28236. this._caps.maxRenderTextureSize = this._gl.getParameter(this._gl.MAX_RENDERBUFFER_SIZE);
  28237. this._caps.maxVertexAttribs = this._gl.getParameter(this._gl.MAX_VERTEX_ATTRIBS);
  28238. this._caps.maxVaryingVectors = this._gl.getParameter(this._gl.MAX_VARYING_VECTORS);
  28239. this._caps.maxFragmentUniformVectors = this._gl.getParameter(this._gl.MAX_FRAGMENT_UNIFORM_VECTORS);
  28240. this._caps.maxVertexUniformVectors = this._gl.getParameter(this._gl.MAX_VERTEX_UNIFORM_VECTORS);
  28241. // Infos
  28242. this._glVersion = this._gl.getParameter(this._gl.VERSION);
  28243. var rendererInfo = this._gl.getExtension("WEBGL_debug_renderer_info");
  28244. if (rendererInfo != null) {
  28245. this._glRenderer = this._gl.getParameter(rendererInfo.UNMASKED_RENDERER_WEBGL);
  28246. this._glVendor = this._gl.getParameter(rendererInfo.UNMASKED_VENDOR_WEBGL);
  28247. }
  28248. if (!this._glVendor) {
  28249. this._glVendor = "Unknown vendor";
  28250. }
  28251. if (!this._glRenderer) {
  28252. this._glRenderer = "Unknown renderer";
  28253. }
  28254. // Constants
  28255. this._gl.HALF_FLOAT_OES = 0x8D61; // Half floating-point type (16-bit).
  28256. if (this._gl.RGBA16F !== 0x881A) {
  28257. this._gl.RGBA16F = 0x881A; // RGBA 16-bit floating-point color-renderable internal sized format.
  28258. }
  28259. if (this._gl.RGBA32F !== 0x8814) {
  28260. this._gl.RGBA32F = 0x8814; // RGBA 32-bit floating-point color-renderable internal sized format.
  28261. }
  28262. if (this._gl.DEPTH24_STENCIL8 !== 35056) {
  28263. this._gl.DEPTH24_STENCIL8 = 35056;
  28264. }
  28265. // Extensions
  28266. this._caps.standardDerivatives = this._webGLVersion > 1 || (this._gl.getExtension('OES_standard_derivatives') !== null);
  28267. this._caps.astc = this._gl.getExtension('WEBGL_compressed_texture_astc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_astc');
  28268. this._caps.s3tc = this._gl.getExtension('WEBGL_compressed_texture_s3tc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_s3tc');
  28269. this._caps.pvrtc = this._gl.getExtension('WEBGL_compressed_texture_pvrtc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_pvrtc');
  28270. this._caps.etc1 = this._gl.getExtension('WEBGL_compressed_texture_etc1') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc1');
  28271. this._caps.etc2 = this._gl.getExtension('WEBGL_compressed_texture_etc') || this._gl.getExtension('WEBKIT_WEBGL_compressed_texture_etc') ||
  28272. this._gl.getExtension('WEBGL_compressed_texture_es3_0'); // also a requirement of OpenGL ES 3
  28273. 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');
  28274. this._caps.maxAnisotropy = this._caps.textureAnisotropicFilterExtension ? this._gl.getParameter(this._caps.textureAnisotropicFilterExtension.MAX_TEXTURE_MAX_ANISOTROPY_EXT) : 0;
  28275. this._caps.uintIndices = this._webGLVersion > 1 || this._gl.getExtension('OES_element_index_uint') !== null;
  28276. this._caps.fragmentDepthSupported = this._webGLVersion > 1 || this._gl.getExtension('EXT_frag_depth') !== null;
  28277. this._caps.highPrecisionShaderSupported = false;
  28278. this._caps.timerQuery = this._gl.getExtension('EXT_disjoint_timer_query_webgl2') || this._gl.getExtension("EXT_disjoint_timer_query");
  28279. if (this._caps.timerQuery) {
  28280. if (this._webGLVersion === 1) {
  28281. this._gl.getQuery = this._caps.timerQuery.getQueryEXT.bind(this._caps.timerQuery);
  28282. }
  28283. this._caps.canUseTimestampForTimerQuery = this._gl.getQuery(this._caps.timerQuery.TIMESTAMP_EXT, this._caps.timerQuery.QUERY_COUNTER_BITS_EXT) > 0;
  28284. }
  28285. // Checks if some of the format renders first to allow the use of webgl inspector.
  28286. this._caps.colorBufferFloat = this._webGLVersion > 1 && this._gl.getExtension('EXT_color_buffer_float');
  28287. this._caps.textureFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_float')) ? true : false;
  28288. this._caps.textureFloatLinearFiltering = this._caps.textureFloat && this._gl.getExtension('OES_texture_float_linear') ? true : false;
  28289. this._caps.textureFloatRender = this._caps.textureFloat && this._canRenderToFloatFramebuffer() ? true : false;
  28290. this._caps.textureHalfFloat = (this._webGLVersion > 1 || this._gl.getExtension('OES_texture_half_float')) ? true : false;
  28291. this._caps.textureHalfFloatLinearFiltering = (this._webGLVersion > 1 || (this._caps.textureHalfFloat && this._gl.getExtension('OES_texture_half_float_linear'))) ? true : false;
  28292. if (this._webGLVersion > 1) {
  28293. this._gl.HALF_FLOAT_OES = 0x140B;
  28294. }
  28295. this._caps.textureHalfFloatRender = this._caps.textureHalfFloat && this._canRenderToHalfFloatFramebuffer();
  28296. this._caps.textureLOD = (this._webGLVersion > 1 || this._gl.getExtension('EXT_shader_texture_lod')) ? true : false;
  28297. // Draw buffers
  28298. if (this._webGLVersion > 1) {
  28299. this._caps.drawBuffersExtension = true;
  28300. }
  28301. else {
  28302. var drawBuffersExtension = this._gl.getExtension('WEBGL_draw_buffers');
  28303. if (drawBuffersExtension !== null) {
  28304. this._caps.drawBuffersExtension = true;
  28305. this._gl.drawBuffers = drawBuffersExtension.drawBuffersWEBGL.bind(drawBuffersExtension);
  28306. this._gl.DRAW_FRAMEBUFFER = this._gl.FRAMEBUFFER;
  28307. for (var i = 0; i < 16; i++) {
  28308. this._gl["COLOR_ATTACHMENT" + i + "_WEBGL"] = drawBuffersExtension["COLOR_ATTACHMENT" + i + "_WEBGL"];
  28309. }
  28310. }
  28311. else {
  28312. this._caps.drawBuffersExtension = false;
  28313. }
  28314. }
  28315. // Shader compiler threads
  28316. this._caps.parallelShaderCompile = this._gl.getExtension('KHR_parallel_shader_compile');
  28317. if (this._caps.parallelShaderCompile) {
  28318. var threads = this._gl.getParameter(this._caps.parallelShaderCompile.MAX_SHADER_COMPILER_THREADS_KHR);
  28319. this._caps.parallelShaderCompile.maxShaderCompilerThreadsKHR(threads);
  28320. }
  28321. // Depth Texture
  28322. if (this._webGLVersion > 1) {
  28323. this._caps.depthTextureExtension = true;
  28324. }
  28325. else {
  28326. var depthTextureExtension = this._gl.getExtension('WEBGL_depth_texture');
  28327. if (depthTextureExtension != null) {
  28328. this._caps.depthTextureExtension = true;
  28329. this._gl.UNSIGNED_INT_24_8 = depthTextureExtension.UNSIGNED_INT_24_8_WEBGL;
  28330. }
  28331. }
  28332. // Vertex array object
  28333. if (this._webGLVersion > 1) {
  28334. this._caps.vertexArrayObject = true;
  28335. }
  28336. else {
  28337. var vertexArrayObjectExtension = this._gl.getExtension('OES_vertex_array_object');
  28338. if (vertexArrayObjectExtension != null) {
  28339. this._caps.vertexArrayObject = true;
  28340. this._gl.createVertexArray = vertexArrayObjectExtension.createVertexArrayOES.bind(vertexArrayObjectExtension);
  28341. this._gl.bindVertexArray = vertexArrayObjectExtension.bindVertexArrayOES.bind(vertexArrayObjectExtension);
  28342. this._gl.deleteVertexArray = vertexArrayObjectExtension.deleteVertexArrayOES.bind(vertexArrayObjectExtension);
  28343. }
  28344. else {
  28345. this._caps.vertexArrayObject = false;
  28346. }
  28347. }
  28348. // Instances count
  28349. if (this._webGLVersion > 1) {
  28350. this._caps.instancedArrays = true;
  28351. }
  28352. else {
  28353. var instanceExtension = this._gl.getExtension('ANGLE_instanced_arrays');
  28354. if (instanceExtension != null) {
  28355. this._caps.instancedArrays = true;
  28356. this._gl.drawArraysInstanced = instanceExtension.drawArraysInstancedANGLE.bind(instanceExtension);
  28357. this._gl.drawElementsInstanced = instanceExtension.drawElementsInstancedANGLE.bind(instanceExtension);
  28358. this._gl.vertexAttribDivisor = instanceExtension.vertexAttribDivisorANGLE.bind(instanceExtension);
  28359. }
  28360. else {
  28361. this._caps.instancedArrays = false;
  28362. }
  28363. }
  28364. // Intelligently add supported compressed formats in order to check for.
  28365. // Check for ASTC support first as it is most powerful and to be very cross platform.
  28366. // Next PVRTC & DXT, which are probably superior to ETC1/2.
  28367. // Likely no hardware which supports both PVR & DXT, so order matters little.
  28368. // ETC2 is newer and handles ETC1 (no alpha capability), so check for first.
  28369. if (this._caps.astc) {
  28370. this.texturesSupported.push('-astc.ktx');
  28371. }
  28372. if (this._caps.s3tc) {
  28373. this.texturesSupported.push('-dxt.ktx');
  28374. }
  28375. if (this._caps.pvrtc) {
  28376. this.texturesSupported.push('-pvrtc.ktx');
  28377. }
  28378. if (this._caps.etc2) {
  28379. this.texturesSupported.push('-etc2.ktx');
  28380. }
  28381. if (this._caps.etc1) {
  28382. this.texturesSupported.push('-etc1.ktx');
  28383. }
  28384. if (this._gl.getShaderPrecisionFormat) {
  28385. var vertex_highp = this._gl.getShaderPrecisionFormat(this._gl.VERTEX_SHADER, this._gl.HIGH_FLOAT);
  28386. var fragment_highp = this._gl.getShaderPrecisionFormat(this._gl.FRAGMENT_SHADER, this._gl.HIGH_FLOAT);
  28387. if (vertex_highp && fragment_highp) {
  28388. this._caps.highPrecisionShaderSupported = vertex_highp.precision !== 0 && fragment_highp.precision !== 0;
  28389. }
  28390. }
  28391. // Depth buffer
  28392. this.setDepthBuffer(true);
  28393. this.setDepthFunctionToLessOrEqual();
  28394. this.setDepthWrite(true);
  28395. // Texture maps
  28396. this._maxSimultaneousTextures = this._caps.maxCombinedTexturesImageUnits;
  28397. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28398. this._nextFreeTextureSlots.push(slot);
  28399. }
  28400. };
  28401. Object.defineProperty(Engine.prototype, "webGLVersion", {
  28402. /**
  28403. * Gets version of the current webGL context
  28404. */
  28405. get: function () {
  28406. return this._webGLVersion;
  28407. },
  28408. enumerable: true,
  28409. configurable: true
  28410. });
  28411. Object.defineProperty(Engine.prototype, "isStencilEnable", {
  28412. /**
  28413. * Returns true if the stencil buffer has been enabled through the creation option of the context.
  28414. */
  28415. get: function () {
  28416. return this._isStencilEnable;
  28417. },
  28418. enumerable: true,
  28419. configurable: true
  28420. });
  28421. Engine.prototype._prepareWorkingCanvas = function () {
  28422. if (this._workingCanvas) {
  28423. return;
  28424. }
  28425. this._workingCanvas = document.createElement("canvas");
  28426. var context = this._workingCanvas.getContext("2d");
  28427. if (context) {
  28428. this._workingContext = context;
  28429. }
  28430. };
  28431. /**
  28432. * Reset the texture cache to empty state
  28433. */
  28434. Engine.prototype.resetTextureCache = function () {
  28435. for (var key in this._boundTexturesCache) {
  28436. if (!this._boundTexturesCache.hasOwnProperty(key)) {
  28437. continue;
  28438. }
  28439. var boundTexture = this._boundTexturesCache[key];
  28440. if (boundTexture) {
  28441. this._removeDesignatedSlot(boundTexture);
  28442. }
  28443. this._boundTexturesCache[key] = null;
  28444. }
  28445. if (!this.disableTextureBindingOptimization) {
  28446. this._nextFreeTextureSlots = [];
  28447. for (var slot = 0; slot < this._maxSimultaneousTextures; slot++) {
  28448. this._nextFreeTextureSlots.push(slot);
  28449. }
  28450. }
  28451. this._currentTextureChannel = -1;
  28452. };
  28453. /**
  28454. * Gets a boolean indicating that the engine is running in deterministic lock step mode
  28455. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28456. * @returns true if engine is in deterministic lock step mode
  28457. */
  28458. Engine.prototype.isDeterministicLockStep = function () {
  28459. return this._deterministicLockstep;
  28460. };
  28461. /**
  28462. * Gets the max steps when engine is running in deterministic lock step
  28463. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  28464. * @returns the max steps
  28465. */
  28466. Engine.prototype.getLockstepMaxSteps = function () {
  28467. return this._lockstepMaxSteps;
  28468. };
  28469. /**
  28470. * Gets an object containing information about the current webGL context
  28471. * @returns an object containing the vender, the renderer and the version of the current webGL context
  28472. */
  28473. Engine.prototype.getGlInfo = function () {
  28474. return {
  28475. vendor: this._glVendor,
  28476. renderer: this._glRenderer,
  28477. version: this._glVersion
  28478. };
  28479. };
  28480. /**
  28481. * Gets current aspect ratio
  28482. * @param camera defines the camera to use to get the aspect ratio
  28483. * @param useScreen defines if screen size must be used (or the current render target if any)
  28484. * @returns a number defining the aspect ratio
  28485. */
  28486. Engine.prototype.getAspectRatio = function (camera, useScreen) {
  28487. if (useScreen === void 0) { useScreen = false; }
  28488. var viewport = camera.viewport;
  28489. return (this.getRenderWidth(useScreen) * viewport.width) / (this.getRenderHeight(useScreen) * viewport.height);
  28490. };
  28491. /**
  28492. * Gets current screen aspect ratio
  28493. * @returns a number defining the aspect ratio
  28494. */
  28495. Engine.prototype.getScreenAspectRatio = function () {
  28496. return (this.getRenderWidth(true)) / (this.getRenderHeight(true));
  28497. };
  28498. /**
  28499. * Gets the current render width
  28500. * @param useScreen defines if screen size must be used (or the current render target if any)
  28501. * @returns a number defining the current render width
  28502. */
  28503. Engine.prototype.getRenderWidth = function (useScreen) {
  28504. if (useScreen === void 0) { useScreen = false; }
  28505. if (!useScreen && this._currentRenderTarget) {
  28506. return this._currentRenderTarget.width;
  28507. }
  28508. return this._gl.drawingBufferWidth;
  28509. };
  28510. /**
  28511. * Gets the current render height
  28512. * @param useScreen defines if screen size must be used (or the current render target if any)
  28513. * @returns a number defining the current render height
  28514. */
  28515. Engine.prototype.getRenderHeight = function (useScreen) {
  28516. if (useScreen === void 0) { useScreen = false; }
  28517. if (!useScreen && this._currentRenderTarget) {
  28518. return this._currentRenderTarget.height;
  28519. }
  28520. return this._gl.drawingBufferHeight;
  28521. };
  28522. /**
  28523. * Gets the HTML canvas attached with the current webGL context
  28524. * @returns a HTML canvas
  28525. */
  28526. Engine.prototype.getRenderingCanvas = function () {
  28527. return this._renderingCanvas;
  28528. };
  28529. /**
  28530. * Gets the client rect of the HTML canvas attached with the current webGL context
  28531. * @returns a client rectanglee
  28532. */
  28533. Engine.prototype.getRenderingCanvasClientRect = function () {
  28534. if (!this._renderingCanvas) {
  28535. return null;
  28536. }
  28537. return this._renderingCanvas.getBoundingClientRect();
  28538. };
  28539. /**
  28540. * Defines the hardware scaling level.
  28541. * By default the hardware scaling level is computed from the window device ratio.
  28542. * 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.
  28543. * @param level defines the level to use
  28544. */
  28545. Engine.prototype.setHardwareScalingLevel = function (level) {
  28546. this._hardwareScalingLevel = level;
  28547. this.resize();
  28548. };
  28549. /**
  28550. * Gets the current hardware scaling level.
  28551. * By default the hardware scaling level is computed from the window device ratio.
  28552. * 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.
  28553. * @returns a number indicating the current hardware scaling level
  28554. */
  28555. Engine.prototype.getHardwareScalingLevel = function () {
  28556. return this._hardwareScalingLevel;
  28557. };
  28558. /**
  28559. * Gets the list of loaded textures
  28560. * @returns an array containing all loaded textures
  28561. */
  28562. Engine.prototype.getLoadedTexturesCache = function () {
  28563. return this._internalTexturesCache;
  28564. };
  28565. /**
  28566. * Gets the object containing all engine capabilities
  28567. * @returns the EngineCapabilities object
  28568. */
  28569. Engine.prototype.getCaps = function () {
  28570. return this._caps;
  28571. };
  28572. /**
  28573. * Gets the current depth function
  28574. * @returns a number defining the depth function
  28575. */
  28576. Engine.prototype.getDepthFunction = function () {
  28577. return this._depthCullingState.depthFunc;
  28578. };
  28579. /**
  28580. * Sets the current depth function
  28581. * @param depthFunc defines the function to use
  28582. */
  28583. Engine.prototype.setDepthFunction = function (depthFunc) {
  28584. this._depthCullingState.depthFunc = depthFunc;
  28585. };
  28586. /**
  28587. * Sets the current depth function to GREATER
  28588. */
  28589. Engine.prototype.setDepthFunctionToGreater = function () {
  28590. this._depthCullingState.depthFunc = this._gl.GREATER;
  28591. };
  28592. /**
  28593. * Sets the current depth function to GEQUAL
  28594. */
  28595. Engine.prototype.setDepthFunctionToGreaterOrEqual = function () {
  28596. this._depthCullingState.depthFunc = this._gl.GEQUAL;
  28597. };
  28598. /**
  28599. * Sets the current depth function to LESS
  28600. */
  28601. Engine.prototype.setDepthFunctionToLess = function () {
  28602. this._depthCullingState.depthFunc = this._gl.LESS;
  28603. };
  28604. /**
  28605. * Sets the current depth function to LEQUAL
  28606. */
  28607. Engine.prototype.setDepthFunctionToLessOrEqual = function () {
  28608. this._depthCullingState.depthFunc = this._gl.LEQUAL;
  28609. };
  28610. /**
  28611. * Gets a boolean indicating if stencil buffer is enabled
  28612. * @returns the current stencil buffer state
  28613. */
  28614. Engine.prototype.getStencilBuffer = function () {
  28615. return this._stencilState.stencilTest;
  28616. };
  28617. /**
  28618. * Enable or disable the stencil buffer
  28619. * @param enable defines if the stencil buffer must be enabled or disabled
  28620. */
  28621. Engine.prototype.setStencilBuffer = function (enable) {
  28622. this._stencilState.stencilTest = enable;
  28623. };
  28624. /**
  28625. * Gets the current stencil mask
  28626. * @returns a number defining the new stencil mask to use
  28627. */
  28628. Engine.prototype.getStencilMask = function () {
  28629. return this._stencilState.stencilMask;
  28630. };
  28631. /**
  28632. * Sets the current stencil mask
  28633. * @param mask defines the new stencil mask to use
  28634. */
  28635. Engine.prototype.setStencilMask = function (mask) {
  28636. this._stencilState.stencilMask = mask;
  28637. };
  28638. /**
  28639. * Gets the current stencil function
  28640. * @returns a number defining the stencil function to use
  28641. */
  28642. Engine.prototype.getStencilFunction = function () {
  28643. return this._stencilState.stencilFunc;
  28644. };
  28645. /**
  28646. * Gets the current stencil reference value
  28647. * @returns a number defining the stencil reference value to use
  28648. */
  28649. Engine.prototype.getStencilFunctionReference = function () {
  28650. return this._stencilState.stencilFuncRef;
  28651. };
  28652. /**
  28653. * Gets the current stencil mask
  28654. * @returns a number defining the stencil mask to use
  28655. */
  28656. Engine.prototype.getStencilFunctionMask = function () {
  28657. return this._stencilState.stencilFuncMask;
  28658. };
  28659. /**
  28660. * Sets the current stencil function
  28661. * @param stencilFunc defines the new stencil function to use
  28662. */
  28663. Engine.prototype.setStencilFunction = function (stencilFunc) {
  28664. this._stencilState.stencilFunc = stencilFunc;
  28665. };
  28666. /**
  28667. * Sets the current stencil reference
  28668. * @param reference defines the new stencil reference to use
  28669. */
  28670. Engine.prototype.setStencilFunctionReference = function (reference) {
  28671. this._stencilState.stencilFuncRef = reference;
  28672. };
  28673. /**
  28674. * Sets the current stencil mask
  28675. * @param mask defines the new stencil mask to use
  28676. */
  28677. Engine.prototype.setStencilFunctionMask = function (mask) {
  28678. this._stencilState.stencilFuncMask = mask;
  28679. };
  28680. /**
  28681. * Gets the current stencil operation when stencil fails
  28682. * @returns a number defining stencil operation to use when stencil fails
  28683. */
  28684. Engine.prototype.getStencilOperationFail = function () {
  28685. return this._stencilState.stencilOpStencilFail;
  28686. };
  28687. /**
  28688. * Gets the current stencil operation when depth fails
  28689. * @returns a number defining stencil operation to use when depth fails
  28690. */
  28691. Engine.prototype.getStencilOperationDepthFail = function () {
  28692. return this._stencilState.stencilOpDepthFail;
  28693. };
  28694. /**
  28695. * Gets the current stencil operation when stencil passes
  28696. * @returns a number defining stencil operation to use when stencil passes
  28697. */
  28698. Engine.prototype.getStencilOperationPass = function () {
  28699. return this._stencilState.stencilOpStencilDepthPass;
  28700. };
  28701. /**
  28702. * Sets the stencil operation to use when stencil fails
  28703. * @param operation defines the stencil operation to use when stencil fails
  28704. */
  28705. Engine.prototype.setStencilOperationFail = function (operation) {
  28706. this._stencilState.stencilOpStencilFail = operation;
  28707. };
  28708. /**
  28709. * Sets the stencil operation to use when depth fails
  28710. * @param operation defines the stencil operation to use when depth fails
  28711. */
  28712. Engine.prototype.setStencilOperationDepthFail = function (operation) {
  28713. this._stencilState.stencilOpDepthFail = operation;
  28714. };
  28715. /**
  28716. * Sets the stencil operation to use when stencil passes
  28717. * @param operation defines the stencil operation to use when stencil passes
  28718. */
  28719. Engine.prototype.setStencilOperationPass = function (operation) {
  28720. this._stencilState.stencilOpStencilDepthPass = operation;
  28721. };
  28722. /**
  28723. * Sets a boolean indicating if the dithering state is enabled or disabled
  28724. * @param value defines the dithering state
  28725. */
  28726. Engine.prototype.setDitheringState = function (value) {
  28727. if (value) {
  28728. this._gl.enable(this._gl.DITHER);
  28729. }
  28730. else {
  28731. this._gl.disable(this._gl.DITHER);
  28732. }
  28733. };
  28734. /**
  28735. * Sets a boolean indicating if the rasterizer state is enabled or disabled
  28736. * @param value defines the rasterizer state
  28737. */
  28738. Engine.prototype.setRasterizerState = function (value) {
  28739. if (value) {
  28740. this._gl.disable(this._gl.RASTERIZER_DISCARD);
  28741. }
  28742. else {
  28743. this._gl.enable(this._gl.RASTERIZER_DISCARD);
  28744. }
  28745. };
  28746. /**
  28747. * stop executing a render loop function and remove it from the execution array
  28748. * @param renderFunction defines the function to be removed. If not provided all functions will be removed.
  28749. */
  28750. Engine.prototype.stopRenderLoop = function (renderFunction) {
  28751. if (!renderFunction) {
  28752. this._activeRenderLoops = [];
  28753. return;
  28754. }
  28755. var index = this._activeRenderLoops.indexOf(renderFunction);
  28756. if (index >= 0) {
  28757. this._activeRenderLoops.splice(index, 1);
  28758. }
  28759. };
  28760. /** @hidden */
  28761. Engine.prototype._renderLoop = function () {
  28762. if (!this._contextWasLost) {
  28763. var shouldRender = true;
  28764. if (!this.renderEvenInBackground && this._windowIsBackground) {
  28765. shouldRender = false;
  28766. }
  28767. if (shouldRender) {
  28768. // Start new frame
  28769. this.beginFrame();
  28770. for (var index = 0; index < this._activeRenderLoops.length; index++) {
  28771. var renderFunction = this._activeRenderLoops[index];
  28772. renderFunction();
  28773. }
  28774. // Present
  28775. this.endFrame();
  28776. }
  28777. }
  28778. if (this._activeRenderLoops.length > 0) {
  28779. // Register new frame
  28780. if (this.customAnimationFrameRequester) {
  28781. this.customAnimationFrameRequester.requestID = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this.customAnimationFrameRequester.renderFunction || this._bindedRenderFunction, this.customAnimationFrameRequester);
  28782. this._frameHandler = this.customAnimationFrameRequester.requestID;
  28783. }
  28784. else if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28785. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction, this._vrDisplay);
  28786. }
  28787. else {
  28788. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28789. }
  28790. }
  28791. else {
  28792. this._renderingQueueLaunched = false;
  28793. }
  28794. };
  28795. /**
  28796. * Register and execute a render loop. The engine can have more than one render function
  28797. * @param renderFunction defines the function to continuously execute
  28798. */
  28799. Engine.prototype.runRenderLoop = function (renderFunction) {
  28800. if (this._activeRenderLoops.indexOf(renderFunction) !== -1) {
  28801. return;
  28802. }
  28803. this._activeRenderLoops.push(renderFunction);
  28804. if (!this._renderingQueueLaunched) {
  28805. this._renderingQueueLaunched = true;
  28806. this._bindedRenderFunction = this._renderLoop.bind(this);
  28807. this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(this._bindedRenderFunction);
  28808. }
  28809. };
  28810. /**
  28811. * Toggle full screen mode
  28812. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28813. */
  28814. Engine.prototype.switchFullscreen = function (requestPointerLock) {
  28815. if (this.isFullscreen) {
  28816. this.exitFullscreen();
  28817. }
  28818. else {
  28819. this.enterFullscreen(requestPointerLock);
  28820. }
  28821. };
  28822. /**
  28823. * Enters full screen mode
  28824. * @param requestPointerLock defines if a pointer lock should be requested from the user
  28825. */
  28826. Engine.prototype.enterFullscreen = function (requestPointerLock) {
  28827. if (!this.isFullscreen) {
  28828. this._pointerLockRequested = requestPointerLock;
  28829. if (this._renderingCanvas) {
  28830. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].RequestFullscreen(this._renderingCanvas);
  28831. }
  28832. }
  28833. };
  28834. /**
  28835. * Exits full screen mode
  28836. */
  28837. Engine.prototype.exitFullscreen = function () {
  28838. if (this.isFullscreen) {
  28839. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].ExitFullscreen();
  28840. }
  28841. };
  28842. /**
  28843. * Clear the current render buffer or the current render target (if any is set up)
  28844. * @param color defines the color to use
  28845. * @param backBuffer defines if the back buffer must be cleared
  28846. * @param depth defines if the depth buffer must be cleared
  28847. * @param stencil defines if the stencil buffer must be cleared
  28848. */
  28849. Engine.prototype.clear = function (color, backBuffer, depth, stencil) {
  28850. if (stencil === void 0) { stencil = false; }
  28851. this.applyStates();
  28852. var mode = 0;
  28853. if (backBuffer && color) {
  28854. this._gl.clearColor(color.r, color.g, color.b, color.a !== undefined ? color.a : 1.0);
  28855. mode |= this._gl.COLOR_BUFFER_BIT;
  28856. }
  28857. if (depth) {
  28858. this._gl.clearDepth(1.0);
  28859. mode |= this._gl.DEPTH_BUFFER_BIT;
  28860. }
  28861. if (stencil) {
  28862. this._gl.clearStencil(0);
  28863. mode |= this._gl.STENCIL_BUFFER_BIT;
  28864. }
  28865. this._gl.clear(mode);
  28866. };
  28867. /**
  28868. * Executes a scissor clear (ie. a clear on a specific portion of the screen)
  28869. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28870. * @param y defines the y-coordinate of the corner of the clear rectangle
  28871. * @param width defines the width of the clear rectangle
  28872. * @param height defines the height of the clear rectangle
  28873. * @param clearColor defines the clear color
  28874. */
  28875. Engine.prototype.scissorClear = function (x, y, width, height, clearColor) {
  28876. this.enableScissor(x, y, width, height);
  28877. this.clear(clearColor, true, true, true);
  28878. this.disableScissor();
  28879. };
  28880. /**
  28881. * Enable scissor test on a specific rectangle (ie. render will only be executed on a specific portion of the screen)
  28882. * @param x defines the x-coordinate of the top left corner of the clear rectangle
  28883. * @param y defines the y-coordinate of the corner of the clear rectangle
  28884. * @param width defines the width of the clear rectangle
  28885. * @param height defines the height of the clear rectangle
  28886. */
  28887. Engine.prototype.enableScissor = function (x, y, width, height) {
  28888. var gl = this._gl;
  28889. // Change state
  28890. gl.enable(gl.SCISSOR_TEST);
  28891. gl.scissor(x, y, width, height);
  28892. };
  28893. /**
  28894. * Disable previously set scissor test rectangle
  28895. */
  28896. Engine.prototype.disableScissor = function () {
  28897. var gl = this._gl;
  28898. gl.disable(gl.SCISSOR_TEST);
  28899. };
  28900. /** @hidden */
  28901. Engine.prototype._viewport = function (x, y, width, height) {
  28902. if (x !== this._viewportCached.x ||
  28903. y !== this._viewportCached.y ||
  28904. width !== this._viewportCached.z ||
  28905. height !== this._viewportCached.w) {
  28906. this._viewportCached.x = x;
  28907. this._viewportCached.y = y;
  28908. this._viewportCached.z = width;
  28909. this._viewportCached.w = height;
  28910. this._gl.viewport(x, y, width, height);
  28911. }
  28912. };
  28913. /**
  28914. * Set the WebGL's viewport
  28915. * @param viewport defines the viewport element to be used
  28916. * @param requiredWidth defines the width required for rendering. If not provided the rendering canvas' width is used
  28917. * @param requiredHeight defines the height required for rendering. If not provided the rendering canvas' height is used
  28918. */
  28919. Engine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  28920. var width = requiredWidth || this.getRenderWidth();
  28921. var height = requiredHeight || this.getRenderHeight();
  28922. var x = viewport.x || 0;
  28923. var y = viewport.y || 0;
  28924. this._cachedViewport = viewport;
  28925. this._viewport(x * width, y * height, width * viewport.width, height * viewport.height);
  28926. };
  28927. /**
  28928. * Directly set the WebGL Viewport
  28929. * @param x defines the x coordinate of the viewport (in screen space)
  28930. * @param y defines the y coordinate of the viewport (in screen space)
  28931. * @param width defines the width of the viewport (in screen space)
  28932. * @param height defines the height of the viewport (in screen space)
  28933. * @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
  28934. */
  28935. Engine.prototype.setDirectViewport = function (x, y, width, height) {
  28936. var currentViewport = this._cachedViewport;
  28937. this._cachedViewport = null;
  28938. this._viewport(x, y, width, height);
  28939. return currentViewport;
  28940. };
  28941. /**
  28942. * Begin a new frame
  28943. */
  28944. Engine.prototype.beginFrame = function () {
  28945. this.onBeginFrameObservable.notifyObservers(this);
  28946. this._measureFps();
  28947. };
  28948. /**
  28949. * Enf the current frame
  28950. */
  28951. Engine.prototype.endFrame = function () {
  28952. // Force a flush in case we are using a bad OS.
  28953. if (this._badOS) {
  28954. this.flushFramebuffer();
  28955. }
  28956. // Submit frame to the vr device, if enabled
  28957. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  28958. // TODO: We should only submit the frame if we read frameData successfully.
  28959. try {
  28960. this._vrDisplay.submitFrame();
  28961. }
  28962. catch (e) {
  28963. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].Warn("webVR submitFrame has had an unexpected failure: " + e);
  28964. }
  28965. }
  28966. this.onEndFrameObservable.notifyObservers(this);
  28967. };
  28968. /**
  28969. * Resize the view according to the canvas' size
  28970. */
  28971. Engine.prototype.resize = function () {
  28972. // We're not resizing the size of the canvas while in VR mode & presenting
  28973. if (!(this._vrDisplay && this._vrDisplay.isPresenting)) {
  28974. var width = this._renderingCanvas ? this._renderingCanvas.clientWidth : window.innerWidth;
  28975. var height = this._renderingCanvas ? this._renderingCanvas.clientHeight : window.innerHeight;
  28976. this.setSize(width / this._hardwareScalingLevel, height / this._hardwareScalingLevel);
  28977. }
  28978. };
  28979. /**
  28980. * Force a specific size of the canvas
  28981. * @param width defines the new canvas' width
  28982. * @param height defines the new canvas' height
  28983. */
  28984. Engine.prototype.setSize = function (width, height) {
  28985. if (!this._renderingCanvas) {
  28986. return;
  28987. }
  28988. if (this._renderingCanvas.width === width && this._renderingCanvas.height === height) {
  28989. return;
  28990. }
  28991. this._renderingCanvas.width = width;
  28992. this._renderingCanvas.height = height;
  28993. for (var index = 0; index < this.scenes.length; index++) {
  28994. var scene = this.scenes[index];
  28995. for (var camIndex = 0; camIndex < scene.cameras.length; camIndex++) {
  28996. var cam = scene.cameras[camIndex];
  28997. cam._currentRenderId = 0;
  28998. }
  28999. }
  29000. if (this.onResizeObservable.hasObservers) {
  29001. this.onResizeObservable.notifyObservers(this);
  29002. }
  29003. };
  29004. // WebVR functions
  29005. /**
  29006. * Gets a boolean indicating if a webVR device was detected
  29007. * @returns true if a webVR device was detected
  29008. */
  29009. Engine.prototype.isVRDevicePresent = function () {
  29010. return !!this._vrDisplay;
  29011. };
  29012. /**
  29013. * Gets the current webVR device
  29014. * @returns the current webVR device (or null)
  29015. */
  29016. Engine.prototype.getVRDevice = function () {
  29017. return this._vrDisplay;
  29018. };
  29019. /**
  29020. * Initializes a webVR display and starts listening to display change events
  29021. * The onVRDisplayChangedObservable will be notified upon these changes
  29022. * @returns The onVRDisplayChangedObservable
  29023. */
  29024. Engine.prototype.initWebVR = function () {
  29025. this.initWebVRAsync();
  29026. return this.onVRDisplayChangedObservable;
  29027. };
  29028. /**
  29029. * Initializes a webVR display and starts listening to display change events
  29030. * The onVRDisplayChangedObservable will be notified upon these changes
  29031. * @returns A promise containing a VRDisplay and if vr is supported
  29032. */
  29033. Engine.prototype.initWebVRAsync = function () {
  29034. var _this = this;
  29035. var notifyObservers = function () {
  29036. var eventArgs = {
  29037. vrDisplay: _this._vrDisplay,
  29038. vrSupported: _this._vrSupported
  29039. };
  29040. _this.onVRDisplayChangedObservable.notifyObservers(eventArgs);
  29041. _this._webVRInitPromise = new Promise(function (res) { res(eventArgs); });
  29042. };
  29043. if (!this._onVrDisplayConnect) {
  29044. this._onVrDisplayConnect = function (event) {
  29045. _this._vrDisplay = event.display;
  29046. notifyObservers();
  29047. };
  29048. this._onVrDisplayDisconnect = function () {
  29049. _this._vrDisplay.cancelAnimationFrame(_this._frameHandler);
  29050. _this._vrDisplay = undefined;
  29051. _this._frameHandler = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].QueueNewFrame(_this._bindedRenderFunction);
  29052. notifyObservers();
  29053. };
  29054. this._onVrDisplayPresentChange = function () {
  29055. _this._vrExclusivePointerMode = _this._vrDisplay && _this._vrDisplay.isPresenting;
  29056. };
  29057. window.addEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  29058. window.addEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  29059. window.addEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  29060. }
  29061. this._webVRInitPromise = this._webVRInitPromise || this._getVRDisplaysAsync();
  29062. this._webVRInitPromise.then(notifyObservers);
  29063. return this._webVRInitPromise;
  29064. };
  29065. /**
  29066. * Call this function to switch to webVR mode
  29067. * Will do nothing if webVR is not supported or if there is no webVR device
  29068. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29069. */
  29070. Engine.prototype.enableVR = function () {
  29071. var _this = this;
  29072. if (this._vrDisplay && !this._vrDisplay.isPresenting) {
  29073. var onResolved = function () {
  29074. _this.onVRRequestPresentComplete.notifyObservers(true);
  29075. _this._onVRFullScreenTriggered();
  29076. };
  29077. var onRejected = function () {
  29078. _this.onVRRequestPresentComplete.notifyObservers(false);
  29079. };
  29080. this.onVRRequestPresentStart.notifyObservers(this);
  29081. this._vrDisplay.requestPresent([{ source: this.getRenderingCanvas() }]).then(onResolved).catch(onRejected);
  29082. }
  29083. };
  29084. /**
  29085. * Call this function to leave webVR mode
  29086. * Will do nothing if webVR is not supported or if there is no webVR device
  29087. * @see http://doc.babylonjs.com/how_to/webvr_camera
  29088. */
  29089. Engine.prototype.disableVR = function () {
  29090. if (this._vrDisplay && this._vrDisplay.isPresenting) {
  29091. this._vrDisplay.exitPresent().then(this._onVRFullScreenTriggered).catch(this._onVRFullScreenTriggered);
  29092. }
  29093. };
  29094. Engine.prototype._getVRDisplaysAsync = function () {
  29095. var _this = this;
  29096. return new Promise(function (res) {
  29097. if (navigator.getVRDisplays) {
  29098. navigator.getVRDisplays().then(function (devices) {
  29099. _this._vrSupported = true;
  29100. // note that devices may actually be an empty array. This is fine;
  29101. // we expect this._vrDisplay to be undefined in this case.
  29102. _this._vrDisplay = devices[0];
  29103. res({
  29104. vrDisplay: _this._vrDisplay,
  29105. vrSupported: _this._vrSupported
  29106. });
  29107. });
  29108. }
  29109. else {
  29110. _this._vrDisplay = undefined;
  29111. _this._vrSupported = false;
  29112. res({
  29113. vrDisplay: _this._vrDisplay,
  29114. vrSupported: _this._vrSupported
  29115. });
  29116. }
  29117. });
  29118. };
  29119. /**
  29120. * Binds the frame buffer to the specified texture.
  29121. * @param texture The texture to render to or null for the default canvas
  29122. * @param faceIndex The face of the texture to render to in case of cube texture
  29123. * @param requiredWidth The width of the target to render to
  29124. * @param requiredHeight The height of the target to render to
  29125. * @param forceFullscreenViewport Forces the viewport to be the entire texture/screen if true
  29126. * @param depthStencilTexture The depth stencil texture to use to render
  29127. * @param lodLevel defines le lod level to bind to the frame buffer
  29128. */
  29129. Engine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport, depthStencilTexture, lodLevel) {
  29130. if (lodLevel === void 0) { lodLevel = 0; }
  29131. if (this._currentRenderTarget) {
  29132. this.unBindFramebuffer(this._currentRenderTarget);
  29133. }
  29134. this._currentRenderTarget = texture;
  29135. this.bindUnboundFramebuffer(texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer);
  29136. var gl = this._gl;
  29137. if (texture.isCube) {
  29138. if (faceIndex === undefined) {
  29139. faceIndex = 0;
  29140. }
  29141. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, lodLevel);
  29142. if (depthStencilTexture) {
  29143. if (depthStencilTexture._generateStencilBuffer) {
  29144. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29145. }
  29146. else {
  29147. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, depthStencilTexture._webGLTexture, lodLevel);
  29148. }
  29149. }
  29150. }
  29151. if (this._cachedViewport && !forceFullscreenViewport) {
  29152. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  29153. }
  29154. else {
  29155. if (!requiredWidth) {
  29156. requiredWidth = texture.width;
  29157. if (lodLevel) {
  29158. requiredWidth = requiredWidth / Math.pow(2, lodLevel);
  29159. }
  29160. }
  29161. if (!requiredHeight) {
  29162. requiredHeight = texture.height;
  29163. if (lodLevel) {
  29164. requiredHeight = requiredHeight / Math.pow(2, lodLevel);
  29165. }
  29166. }
  29167. this._viewport(0, 0, requiredWidth, requiredHeight);
  29168. }
  29169. this.wipeCaches();
  29170. };
  29171. Engine.prototype.bindUnboundFramebuffer = function (framebuffer) {
  29172. if (this._currentFramebuffer !== framebuffer) {
  29173. this._gl.bindFramebuffer(this._gl.FRAMEBUFFER, framebuffer);
  29174. this._currentFramebuffer = framebuffer;
  29175. }
  29176. };
  29177. /**
  29178. * Unbind the current render target texture from the webGL context
  29179. * @param texture defines the render target texture to unbind
  29180. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29181. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29182. */
  29183. Engine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  29184. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29185. this._currentRenderTarget = null;
  29186. // If MSAA, we need to bitblt back to main texture
  29187. var gl = this._gl;
  29188. if (texture._MSAAFramebuffer) {
  29189. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, texture._MSAAFramebuffer);
  29190. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, texture._framebuffer);
  29191. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29192. }
  29193. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29194. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  29195. gl.generateMipmap(gl.TEXTURE_2D);
  29196. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29197. }
  29198. if (onBeforeUnbind) {
  29199. if (texture._MSAAFramebuffer) {
  29200. // Bind the correct framebuffer
  29201. this.bindUnboundFramebuffer(texture._framebuffer);
  29202. }
  29203. onBeforeUnbind();
  29204. }
  29205. this.bindUnboundFramebuffer(null);
  29206. };
  29207. /**
  29208. * Unbind a list of render target textures from the webGL context
  29209. * This is used only when drawBuffer extension or webGL2 are active
  29210. * @param textures defines the render target textures to unbind
  29211. * @param disableGenerateMipMaps defines a boolean indicating that mipmaps must not be generated
  29212. * @param onBeforeUnbind defines a function which will be called before the effective unbind
  29213. */
  29214. Engine.prototype.unBindMultiColorAttachmentFramebuffer = function (textures, disableGenerateMipMaps, onBeforeUnbind) {
  29215. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  29216. this._currentRenderTarget = null;
  29217. // If MSAA, we need to bitblt back to main texture
  29218. var gl = this._gl;
  29219. if (textures[0]._MSAAFramebuffer) {
  29220. gl.bindFramebuffer(gl.READ_FRAMEBUFFER, textures[0]._MSAAFramebuffer);
  29221. gl.bindFramebuffer(gl.DRAW_FRAMEBUFFER, textures[0]._framebuffer);
  29222. var attachments = textures[0]._attachments;
  29223. if (!attachments) {
  29224. attachments = new Array(textures.length);
  29225. textures[0]._attachments = attachments;
  29226. }
  29227. for (var i = 0; i < textures.length; i++) {
  29228. var texture = textures[i];
  29229. for (var j = 0; j < attachments.length; j++) {
  29230. attachments[j] = gl.NONE;
  29231. }
  29232. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29233. gl.readBuffer(attachments[i]);
  29234. gl.drawBuffers(attachments);
  29235. gl.blitFramebuffer(0, 0, texture.width, texture.height, 0, 0, texture.width, texture.height, gl.COLOR_BUFFER_BIT, gl.NEAREST);
  29236. }
  29237. for (var i = 0; i < attachments.length; i++) {
  29238. attachments[i] = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  29239. }
  29240. gl.drawBuffers(attachments);
  29241. }
  29242. for (var i = 0; i < textures.length; i++) {
  29243. var texture = textures[i];
  29244. if (texture.generateMipMaps && !disableGenerateMipMaps && !texture.isCube) {
  29245. this._bindTextureDirectly(gl.TEXTURE_2D, texture);
  29246. gl.generateMipmap(gl.TEXTURE_2D);
  29247. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  29248. }
  29249. }
  29250. if (onBeforeUnbind) {
  29251. if (textures[0]._MSAAFramebuffer) {
  29252. // Bind the correct framebuffer
  29253. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  29254. }
  29255. onBeforeUnbind();
  29256. }
  29257. this.bindUnboundFramebuffer(null);
  29258. };
  29259. /**
  29260. * Force the mipmap generation for the given render target texture
  29261. * @param texture defines the render target texture to use
  29262. */
  29263. Engine.prototype.generateMipMapsForCubemap = function (texture) {
  29264. if (texture.generateMipMaps) {
  29265. var gl = this._gl;
  29266. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  29267. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  29268. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  29269. }
  29270. };
  29271. /**
  29272. * Force a webGL flush (ie. a flush of all waiting webGL commands)
  29273. */
  29274. Engine.prototype.flushFramebuffer = function () {
  29275. this._gl.flush();
  29276. };
  29277. /**
  29278. * Unbind the current render target and bind the default framebuffer
  29279. */
  29280. Engine.prototype.restoreDefaultFramebuffer = function () {
  29281. if (this._currentRenderTarget) {
  29282. this.unBindFramebuffer(this._currentRenderTarget);
  29283. }
  29284. else {
  29285. this.bindUnboundFramebuffer(null);
  29286. }
  29287. if (this._cachedViewport) {
  29288. this.setViewport(this._cachedViewport);
  29289. }
  29290. this.wipeCaches();
  29291. };
  29292. // UBOs
  29293. /**
  29294. * Create an uniform buffer
  29295. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29296. * @param elements defines the content of the uniform buffer
  29297. * @returns the webGL uniform buffer
  29298. */
  29299. Engine.prototype.createUniformBuffer = function (elements) {
  29300. var ubo = this._gl.createBuffer();
  29301. if (!ubo) {
  29302. throw new Error("Unable to create uniform buffer");
  29303. }
  29304. this.bindUniformBuffer(ubo);
  29305. if (elements instanceof Float32Array) {
  29306. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.STATIC_DRAW);
  29307. }
  29308. else {
  29309. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.STATIC_DRAW);
  29310. }
  29311. this.bindUniformBuffer(null);
  29312. ubo.references = 1;
  29313. return ubo;
  29314. };
  29315. /**
  29316. * Create a dynamic uniform buffer
  29317. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29318. * @param elements defines the content of the uniform buffer
  29319. * @returns the webGL uniform buffer
  29320. */
  29321. Engine.prototype.createDynamicUniformBuffer = function (elements) {
  29322. var ubo = this._gl.createBuffer();
  29323. if (!ubo) {
  29324. throw new Error("Unable to create dynamic uniform buffer");
  29325. }
  29326. this.bindUniformBuffer(ubo);
  29327. if (elements instanceof Float32Array) {
  29328. this._gl.bufferData(this._gl.UNIFORM_BUFFER, elements, this._gl.DYNAMIC_DRAW);
  29329. }
  29330. else {
  29331. this._gl.bufferData(this._gl.UNIFORM_BUFFER, new Float32Array(elements), this._gl.DYNAMIC_DRAW);
  29332. }
  29333. this.bindUniformBuffer(null);
  29334. ubo.references = 1;
  29335. return ubo;
  29336. };
  29337. /**
  29338. * Update an existing uniform buffer
  29339. * @see http://doc.babylonjs.com/features/webgl2#uniform-buffer-objets
  29340. * @param uniformBuffer defines the target uniform buffer
  29341. * @param elements defines the content to update
  29342. * @param offset defines the offset in the uniform buffer where update should start
  29343. * @param count defines the size of the data to update
  29344. */
  29345. Engine.prototype.updateUniformBuffer = function (uniformBuffer, elements, offset, count) {
  29346. this.bindUniformBuffer(uniformBuffer);
  29347. if (offset === undefined) {
  29348. offset = 0;
  29349. }
  29350. if (count === undefined) {
  29351. if (elements instanceof Float32Array) {
  29352. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, elements);
  29353. }
  29354. else {
  29355. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, offset, new Float32Array(elements));
  29356. }
  29357. }
  29358. else {
  29359. if (elements instanceof Float32Array) {
  29360. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, elements.subarray(offset, offset + count));
  29361. }
  29362. else {
  29363. this._gl.bufferSubData(this._gl.UNIFORM_BUFFER, 0, new Float32Array(elements).subarray(offset, offset + count));
  29364. }
  29365. }
  29366. this.bindUniformBuffer(null);
  29367. };
  29368. // VBOs
  29369. Engine.prototype._resetVertexBufferBinding = function () {
  29370. this.bindArrayBuffer(null);
  29371. this._cachedVertexBuffers = null;
  29372. };
  29373. /**
  29374. * Creates a vertex buffer
  29375. * @param data the data for the vertex buffer
  29376. * @returns the new WebGL static buffer
  29377. */
  29378. Engine.prototype.createVertexBuffer = function (data) {
  29379. var vbo = this._gl.createBuffer();
  29380. if (!vbo) {
  29381. throw new Error("Unable to create vertex buffer");
  29382. }
  29383. this.bindArrayBuffer(vbo);
  29384. if (data instanceof Array) {
  29385. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.STATIC_DRAW);
  29386. }
  29387. else {
  29388. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.STATIC_DRAW);
  29389. }
  29390. this._resetVertexBufferBinding();
  29391. vbo.references = 1;
  29392. return vbo;
  29393. };
  29394. /**
  29395. * Creates a dynamic vertex buffer
  29396. * @param data the data for the dynamic vertex buffer
  29397. * @returns the new WebGL dynamic buffer
  29398. */
  29399. Engine.prototype.createDynamicVertexBuffer = function (data) {
  29400. var vbo = this._gl.createBuffer();
  29401. if (!vbo) {
  29402. throw new Error("Unable to create dynamic vertex buffer");
  29403. }
  29404. this.bindArrayBuffer(vbo);
  29405. if (data instanceof Array) {
  29406. this._gl.bufferData(this._gl.ARRAY_BUFFER, new Float32Array(data), this._gl.DYNAMIC_DRAW);
  29407. }
  29408. else {
  29409. this._gl.bufferData(this._gl.ARRAY_BUFFER, data, this._gl.DYNAMIC_DRAW);
  29410. }
  29411. this._resetVertexBufferBinding();
  29412. vbo.references = 1;
  29413. return vbo;
  29414. };
  29415. /**
  29416. * Update a dynamic index buffer
  29417. * @param indexBuffer defines the target index buffer
  29418. * @param indices defines the data to update
  29419. * @param offset defines the offset in the target index buffer where update should start
  29420. */
  29421. Engine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  29422. if (offset === void 0) { offset = 0; }
  29423. // Force cache update
  29424. this._currentBoundBuffer[this._gl.ELEMENT_ARRAY_BUFFER] = null;
  29425. this.bindIndexBuffer(indexBuffer);
  29426. var arrayBuffer;
  29427. if (indices instanceof Uint16Array || indices instanceof Uint32Array) {
  29428. arrayBuffer = indices;
  29429. }
  29430. else {
  29431. arrayBuffer = indexBuffer.is32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29432. }
  29433. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, this._gl.DYNAMIC_DRAW);
  29434. this._resetIndexBufferBinding();
  29435. };
  29436. /**
  29437. * Updates a dynamic vertex buffer.
  29438. * @param vertexBuffer the vertex buffer to update
  29439. * @param data the data used to update the vertex buffer
  29440. * @param byteOffset the byte offset of the data
  29441. * @param byteLength the byte length of the data
  29442. */
  29443. Engine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, data, byteOffset, byteLength) {
  29444. this.bindArrayBuffer(vertexBuffer);
  29445. if (byteOffset === undefined) {
  29446. byteOffset = 0;
  29447. }
  29448. if (byteLength === undefined) {
  29449. if (data instanceof Array) {
  29450. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, new Float32Array(data));
  29451. }
  29452. else {
  29453. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, byteOffset, data);
  29454. }
  29455. }
  29456. else {
  29457. if (data instanceof Array) {
  29458. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, new Float32Array(data).subarray(byteOffset, byteOffset + byteLength));
  29459. }
  29460. else {
  29461. if (data instanceof ArrayBuffer) {
  29462. data = new Uint8Array(data, byteOffset, byteLength);
  29463. }
  29464. else {
  29465. data = new Uint8Array(data.buffer, data.byteOffset + byteOffset, byteLength);
  29466. }
  29467. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29468. }
  29469. }
  29470. this._resetVertexBufferBinding();
  29471. };
  29472. Engine.prototype._resetIndexBufferBinding = function () {
  29473. this.bindIndexBuffer(null);
  29474. this._cachedIndexBuffer = null;
  29475. };
  29476. /**
  29477. * Creates a new index buffer
  29478. * @param indices defines the content of the index buffer
  29479. * @param updatable defines if the index buffer must be updatable
  29480. * @returns a new webGL buffer
  29481. */
  29482. Engine.prototype.createIndexBuffer = function (indices, updatable) {
  29483. var vbo = this._gl.createBuffer();
  29484. if (!vbo) {
  29485. throw new Error("Unable to create index buffer");
  29486. }
  29487. this.bindIndexBuffer(vbo);
  29488. // Check for 32 bits indices
  29489. var arrayBuffer;
  29490. var need32Bits = false;
  29491. if (indices instanceof Uint16Array) {
  29492. arrayBuffer = indices;
  29493. }
  29494. else {
  29495. //check 32 bit support
  29496. if (this._caps.uintIndices) {
  29497. if (indices instanceof Uint32Array) {
  29498. arrayBuffer = indices;
  29499. need32Bits = true;
  29500. }
  29501. else {
  29502. //number[] or Int32Array, check if 32 bit is necessary
  29503. for (var index = 0; index < indices.length; index++) {
  29504. if (indices[index] > 65535) {
  29505. need32Bits = true;
  29506. break;
  29507. }
  29508. }
  29509. arrayBuffer = need32Bits ? new Uint32Array(indices) : new Uint16Array(indices);
  29510. }
  29511. }
  29512. else {
  29513. //no 32 bit support, force conversion to 16 bit (values greater 16 bit are lost)
  29514. arrayBuffer = new Uint16Array(indices);
  29515. }
  29516. }
  29517. this._gl.bufferData(this._gl.ELEMENT_ARRAY_BUFFER, arrayBuffer, updatable ? this._gl.DYNAMIC_DRAW : this._gl.STATIC_DRAW);
  29518. this._resetIndexBufferBinding();
  29519. vbo.references = 1;
  29520. vbo.is32Bits = need32Bits;
  29521. return vbo;
  29522. };
  29523. /**
  29524. * Bind a webGL buffer to the webGL context
  29525. * @param buffer defines the buffer to bind
  29526. */
  29527. Engine.prototype.bindArrayBuffer = function (buffer) {
  29528. if (!this._vaoRecordInProgress) {
  29529. this._unbindVertexArrayObject();
  29530. }
  29531. this.bindBuffer(buffer, this._gl.ARRAY_BUFFER);
  29532. };
  29533. /**
  29534. * Bind an uniform buffer to the current webGL context
  29535. * @param buffer defines the buffer to bind
  29536. */
  29537. Engine.prototype.bindUniformBuffer = function (buffer) {
  29538. this._gl.bindBuffer(this._gl.UNIFORM_BUFFER, buffer);
  29539. };
  29540. /**
  29541. * Bind a buffer to the current webGL context at a given location
  29542. * @param buffer defines the buffer to bind
  29543. * @param location defines the index where to bind the buffer
  29544. */
  29545. Engine.prototype.bindUniformBufferBase = function (buffer, location) {
  29546. this._gl.bindBufferBase(this._gl.UNIFORM_BUFFER, location, buffer);
  29547. };
  29548. /**
  29549. * Bind a specific block at a given index in a specific shader program
  29550. * @param shaderProgram defines the shader program
  29551. * @param blockName defines the block name
  29552. * @param index defines the index where to bind the block
  29553. */
  29554. Engine.prototype.bindUniformBlock = function (shaderProgram, blockName, index) {
  29555. var uniformLocation = this._gl.getUniformBlockIndex(shaderProgram, blockName);
  29556. this._gl.uniformBlockBinding(shaderProgram, uniformLocation, index);
  29557. };
  29558. Engine.prototype.bindIndexBuffer = function (buffer) {
  29559. if (!this._vaoRecordInProgress) {
  29560. this._unbindVertexArrayObject();
  29561. }
  29562. this.bindBuffer(buffer, this._gl.ELEMENT_ARRAY_BUFFER);
  29563. };
  29564. Engine.prototype.bindBuffer = function (buffer, target) {
  29565. if (this._vaoRecordInProgress || this._currentBoundBuffer[target] !== buffer) {
  29566. this._gl.bindBuffer(target, buffer);
  29567. this._currentBoundBuffer[target] = buffer;
  29568. }
  29569. };
  29570. /**
  29571. * update the bound buffer with the given data
  29572. * @param data defines the data to update
  29573. */
  29574. Engine.prototype.updateArrayBuffer = function (data) {
  29575. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29576. };
  29577. Engine.prototype._vertexAttribPointer = function (buffer, indx, size, type, normalized, stride, offset) {
  29578. var pointer = this._currentBufferPointers[indx];
  29579. var changed = false;
  29580. if (!pointer.active) {
  29581. changed = true;
  29582. pointer.active = true;
  29583. pointer.index = indx;
  29584. pointer.size = size;
  29585. pointer.type = type;
  29586. pointer.normalized = normalized;
  29587. pointer.stride = stride;
  29588. pointer.offset = offset;
  29589. pointer.buffer = buffer;
  29590. }
  29591. else {
  29592. if (pointer.buffer !== buffer) {
  29593. pointer.buffer = buffer;
  29594. changed = true;
  29595. }
  29596. if (pointer.size !== size) {
  29597. pointer.size = size;
  29598. changed = true;
  29599. }
  29600. if (pointer.type !== type) {
  29601. pointer.type = type;
  29602. changed = true;
  29603. }
  29604. if (pointer.normalized !== normalized) {
  29605. pointer.normalized = normalized;
  29606. changed = true;
  29607. }
  29608. if (pointer.stride !== stride) {
  29609. pointer.stride = stride;
  29610. changed = true;
  29611. }
  29612. if (pointer.offset !== offset) {
  29613. pointer.offset = offset;
  29614. changed = true;
  29615. }
  29616. }
  29617. if (changed || this._vaoRecordInProgress) {
  29618. this.bindArrayBuffer(buffer);
  29619. this._gl.vertexAttribPointer(indx, size, type, normalized, stride, offset);
  29620. }
  29621. };
  29622. Engine.prototype._bindIndexBufferWithCache = function (indexBuffer) {
  29623. if (indexBuffer == null) {
  29624. return;
  29625. }
  29626. if (this._cachedIndexBuffer !== indexBuffer) {
  29627. this._cachedIndexBuffer = indexBuffer;
  29628. this.bindIndexBuffer(indexBuffer);
  29629. this._uintIndicesCurrentlySet = indexBuffer.is32Bits;
  29630. }
  29631. };
  29632. Engine.prototype._bindVertexBuffersAttributes = function (vertexBuffers, effect) {
  29633. var attributes = effect.getAttributesNames();
  29634. if (!this._vaoRecordInProgress) {
  29635. this._unbindVertexArrayObject();
  29636. }
  29637. this.unbindAllAttributes();
  29638. for (var index = 0; index < attributes.length; index++) {
  29639. var order = effect.getAttributeLocation(index);
  29640. if (order >= 0) {
  29641. var vertexBuffer = vertexBuffers[attributes[index]];
  29642. if (!vertexBuffer) {
  29643. continue;
  29644. }
  29645. this._gl.enableVertexAttribArray(order);
  29646. if (!this._vaoRecordInProgress) {
  29647. this._vertexAttribArraysEnabled[order] = true;
  29648. }
  29649. var buffer = vertexBuffer.getBuffer();
  29650. if (buffer) {
  29651. this._vertexAttribPointer(buffer, order, vertexBuffer.getSize(), vertexBuffer.type, vertexBuffer.normalized, vertexBuffer.byteStride, vertexBuffer.byteOffset);
  29652. if (vertexBuffer.getIsInstanced()) {
  29653. this._gl.vertexAttribDivisor(order, vertexBuffer.getInstanceDivisor());
  29654. if (!this._vaoRecordInProgress) {
  29655. this._currentInstanceLocations.push(order);
  29656. this._currentInstanceBuffers.push(buffer);
  29657. }
  29658. }
  29659. }
  29660. }
  29661. }
  29662. };
  29663. /**
  29664. * Records a vertex array object
  29665. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29666. * @param vertexBuffers defines the list of vertex buffers to store
  29667. * @param indexBuffer defines the index buffer to store
  29668. * @param effect defines the effect to store
  29669. * @returns the new vertex array object
  29670. */
  29671. Engine.prototype.recordVertexArrayObject = function (vertexBuffers, indexBuffer, effect) {
  29672. var vao = this._gl.createVertexArray();
  29673. this._vaoRecordInProgress = true;
  29674. this._gl.bindVertexArray(vao);
  29675. this._mustWipeVertexAttributes = true;
  29676. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29677. this.bindIndexBuffer(indexBuffer);
  29678. this._vaoRecordInProgress = false;
  29679. this._gl.bindVertexArray(null);
  29680. return vao;
  29681. };
  29682. /**
  29683. * Bind a specific vertex array object
  29684. * @see http://doc.babylonjs.com/features/webgl2#vertex-array-objects
  29685. * @param vertexArrayObject defines the vertex array object to bind
  29686. * @param indexBuffer defines the index buffer to bind
  29687. */
  29688. Engine.prototype.bindVertexArrayObject = function (vertexArrayObject, indexBuffer) {
  29689. if (this._cachedVertexArrayObject !== vertexArrayObject) {
  29690. this._cachedVertexArrayObject = vertexArrayObject;
  29691. this._gl.bindVertexArray(vertexArrayObject);
  29692. this._cachedVertexBuffers = null;
  29693. this._cachedIndexBuffer = null;
  29694. this._uintIndicesCurrentlySet = indexBuffer != null && indexBuffer.is32Bits;
  29695. this._mustWipeVertexAttributes = true;
  29696. }
  29697. };
  29698. /**
  29699. * Bind webGl buffers directly to the webGL context
  29700. * @param vertexBuffer defines the vertex buffer to bind
  29701. * @param indexBuffer defines the index buffer to bind
  29702. * @param vertexDeclaration defines the vertex declaration to use with the vertex buffer
  29703. * @param vertexStrideSize defines the vertex stride of the vertex buffer
  29704. * @param effect defines the effect associated with the vertex buffer
  29705. */
  29706. Engine.prototype.bindBuffersDirectly = function (vertexBuffer, indexBuffer, vertexDeclaration, vertexStrideSize, effect) {
  29707. if (this._cachedVertexBuffers !== vertexBuffer || this._cachedEffectForVertexBuffers !== effect) {
  29708. this._cachedVertexBuffers = vertexBuffer;
  29709. this._cachedEffectForVertexBuffers = effect;
  29710. var attributesCount = effect.getAttributesCount();
  29711. this._unbindVertexArrayObject();
  29712. this.unbindAllAttributes();
  29713. var offset = 0;
  29714. for (var index = 0; index < attributesCount; index++) {
  29715. if (index < vertexDeclaration.length) {
  29716. var order = effect.getAttributeLocation(index);
  29717. if (order >= 0) {
  29718. this._gl.enableVertexAttribArray(order);
  29719. this._vertexAttribArraysEnabled[order] = true;
  29720. this._vertexAttribPointer(vertexBuffer, order, vertexDeclaration[index], this._gl.FLOAT, false, vertexStrideSize, offset);
  29721. }
  29722. offset += vertexDeclaration[index] * 4;
  29723. }
  29724. }
  29725. }
  29726. this._bindIndexBufferWithCache(indexBuffer);
  29727. };
  29728. Engine.prototype._unbindVertexArrayObject = function () {
  29729. if (!this._cachedVertexArrayObject) {
  29730. return;
  29731. }
  29732. this._cachedVertexArrayObject = null;
  29733. this._gl.bindVertexArray(null);
  29734. };
  29735. /**
  29736. * Bind a list of vertex buffers to the webGL context
  29737. * @param vertexBuffers defines the list of vertex buffers to bind
  29738. * @param indexBuffer defines the index buffer to bind
  29739. * @param effect defines the effect associated with the vertex buffers
  29740. */
  29741. Engine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  29742. if (this._cachedVertexBuffers !== vertexBuffers || this._cachedEffectForVertexBuffers !== effect) {
  29743. this._cachedVertexBuffers = vertexBuffers;
  29744. this._cachedEffectForVertexBuffers = effect;
  29745. this._bindVertexBuffersAttributes(vertexBuffers, effect);
  29746. }
  29747. this._bindIndexBufferWithCache(indexBuffer);
  29748. };
  29749. /**
  29750. * Unbind all instance attributes
  29751. */
  29752. Engine.prototype.unbindInstanceAttributes = function () {
  29753. var boundBuffer;
  29754. for (var i = 0, ul = this._currentInstanceLocations.length; i < ul; i++) {
  29755. var instancesBuffer = this._currentInstanceBuffers[i];
  29756. if (boundBuffer != instancesBuffer && instancesBuffer.references) {
  29757. boundBuffer = instancesBuffer;
  29758. this.bindArrayBuffer(instancesBuffer);
  29759. }
  29760. var offsetLocation = this._currentInstanceLocations[i];
  29761. this._gl.vertexAttribDivisor(offsetLocation, 0);
  29762. }
  29763. this._currentInstanceBuffers.length = 0;
  29764. this._currentInstanceLocations.length = 0;
  29765. };
  29766. /**
  29767. * Release and free the memory of a vertex array object
  29768. * @param vao defines the vertex array object to delete
  29769. */
  29770. Engine.prototype.releaseVertexArrayObject = function (vao) {
  29771. this._gl.deleteVertexArray(vao);
  29772. };
  29773. /** @hidden */
  29774. Engine.prototype._releaseBuffer = function (buffer) {
  29775. buffer.references--;
  29776. if (buffer.references === 0) {
  29777. this._gl.deleteBuffer(buffer);
  29778. return true;
  29779. }
  29780. return false;
  29781. };
  29782. /**
  29783. * Creates a webGL buffer to use with instanciation
  29784. * @param capacity defines the size of the buffer
  29785. * @returns the webGL buffer
  29786. */
  29787. Engine.prototype.createInstancesBuffer = function (capacity) {
  29788. var buffer = this._gl.createBuffer();
  29789. if (!buffer) {
  29790. throw new Error("Unable to create instance buffer");
  29791. }
  29792. buffer.capacity = capacity;
  29793. this.bindArrayBuffer(buffer);
  29794. this._gl.bufferData(this._gl.ARRAY_BUFFER, capacity, this._gl.DYNAMIC_DRAW);
  29795. return buffer;
  29796. };
  29797. /**
  29798. * Delete a webGL buffer used with instanciation
  29799. * @param buffer defines the webGL buffer to delete
  29800. */
  29801. Engine.prototype.deleteInstancesBuffer = function (buffer) {
  29802. this._gl.deleteBuffer(buffer);
  29803. };
  29804. /**
  29805. * Update the content of a webGL buffer used with instanciation and bind it to the webGL context
  29806. * @param instancesBuffer defines the webGL buffer to update and bind
  29807. * @param data defines the data to store in the buffer
  29808. * @param offsetLocations defines the offsets or attributes information used to determine where data must be stored in the buffer
  29809. */
  29810. Engine.prototype.updateAndBindInstancesBuffer = function (instancesBuffer, data, offsetLocations) {
  29811. this.bindArrayBuffer(instancesBuffer);
  29812. if (data) {
  29813. this._gl.bufferSubData(this._gl.ARRAY_BUFFER, 0, data);
  29814. }
  29815. if (offsetLocations[0].index !== undefined) {
  29816. var stride = 0;
  29817. for (var i = 0; i < offsetLocations.length; i++) {
  29818. var ai = offsetLocations[i];
  29819. stride += ai.attributeSize * 4;
  29820. }
  29821. for (var i = 0; i < offsetLocations.length; i++) {
  29822. var ai = offsetLocations[i];
  29823. if (!this._vertexAttribArraysEnabled[ai.index]) {
  29824. this._gl.enableVertexAttribArray(ai.index);
  29825. this._vertexAttribArraysEnabled[ai.index] = true;
  29826. }
  29827. this._vertexAttribPointer(instancesBuffer, ai.index, ai.attributeSize, ai.attribyteType || this._gl.FLOAT, ai.normalized || false, stride, ai.offset);
  29828. this._gl.vertexAttribDivisor(ai.index, 1);
  29829. this._currentInstanceLocations.push(ai.index);
  29830. this._currentInstanceBuffers.push(instancesBuffer);
  29831. }
  29832. }
  29833. else {
  29834. for (var index = 0; index < 4; index++) {
  29835. var offsetLocation = offsetLocations[index];
  29836. if (!this._vertexAttribArraysEnabled[offsetLocation]) {
  29837. this._gl.enableVertexAttribArray(offsetLocation);
  29838. this._vertexAttribArraysEnabled[offsetLocation] = true;
  29839. }
  29840. this._vertexAttribPointer(instancesBuffer, offsetLocation, 4, this._gl.FLOAT, false, 64, index * 16);
  29841. this._gl.vertexAttribDivisor(offsetLocation, 1);
  29842. this._currentInstanceLocations.push(offsetLocation);
  29843. this._currentInstanceBuffers.push(instancesBuffer);
  29844. }
  29845. }
  29846. };
  29847. /**
  29848. * Apply all cached states (depth, culling, stencil and alpha)
  29849. */
  29850. Engine.prototype.applyStates = function () {
  29851. this._depthCullingState.apply(this._gl);
  29852. this._stencilState.apply(this._gl);
  29853. this._alphaState.apply(this._gl);
  29854. };
  29855. /**
  29856. * Send a draw order
  29857. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29858. * @param indexStart defines the starting index
  29859. * @param indexCount defines the number of index to draw
  29860. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29861. */
  29862. Engine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  29863. this.drawElementsType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, indexStart, indexCount, instancesCount);
  29864. };
  29865. /**
  29866. * Draw a list of points
  29867. * @param verticesStart defines the index of first vertex to draw
  29868. * @param verticesCount defines the count of vertices to draw
  29869. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29870. */
  29871. Engine.prototype.drawPointClouds = function (verticesStart, verticesCount, instancesCount) {
  29872. this.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode, verticesStart, verticesCount, instancesCount);
  29873. };
  29874. /**
  29875. * Draw a list of unindexed primitives
  29876. * @param useTriangles defines if triangles must be used to draw (else wireframe will be used)
  29877. * @param verticesStart defines the index of first vertex to draw
  29878. * @param verticesCount defines the count of vertices to draw
  29879. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29880. */
  29881. Engine.prototype.drawUnIndexed = function (useTriangles, verticesStart, verticesCount, instancesCount) {
  29882. this.drawArraysType(useTriangles ? _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode : _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode, verticesStart, verticesCount, instancesCount);
  29883. };
  29884. /**
  29885. * Draw a list of indexed primitives
  29886. * @param fillMode defines the primitive to use
  29887. * @param indexStart defines the starting index
  29888. * @param indexCount defines the number of index to draw
  29889. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29890. */
  29891. Engine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  29892. // Apply states
  29893. this.applyStates();
  29894. this._drawCalls.addCount(1, false);
  29895. // Render
  29896. var drawMode = this._drawMode(fillMode);
  29897. var indexFormat = this._uintIndicesCurrentlySet ? this._gl.UNSIGNED_INT : this._gl.UNSIGNED_SHORT;
  29898. var mult = this._uintIndicesCurrentlySet ? 4 : 2;
  29899. if (instancesCount) {
  29900. this._gl.drawElementsInstanced(drawMode, indexCount, indexFormat, indexStart * mult, instancesCount);
  29901. }
  29902. else {
  29903. this._gl.drawElements(drawMode, indexCount, indexFormat, indexStart * mult);
  29904. }
  29905. };
  29906. /**
  29907. * Draw a list of unindexed primitives
  29908. * @param fillMode defines the primitive to use
  29909. * @param verticesStart defines the index of first vertex to draw
  29910. * @param verticesCount defines the count of vertices to draw
  29911. * @param instancesCount defines the number of instances to draw (if instanciation is enabled)
  29912. */
  29913. Engine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  29914. // Apply states
  29915. this.applyStates();
  29916. this._drawCalls.addCount(1, false);
  29917. var drawMode = this._drawMode(fillMode);
  29918. if (instancesCount) {
  29919. this._gl.drawArraysInstanced(drawMode, verticesStart, verticesCount, instancesCount);
  29920. }
  29921. else {
  29922. this._gl.drawArrays(drawMode, verticesStart, verticesCount);
  29923. }
  29924. };
  29925. Engine.prototype._drawMode = function (fillMode) {
  29926. switch (fillMode) {
  29927. // Triangle views
  29928. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode:
  29929. return this._gl.TRIANGLES;
  29930. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointFillMode:
  29931. return this._gl.POINTS;
  29932. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].WireFrameFillMode:
  29933. return this._gl.LINES;
  29934. // Draw modes
  29935. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].PointListDrawMode:
  29936. return this._gl.POINTS;
  29937. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineListDrawMode:
  29938. return this._gl.LINES;
  29939. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineLoopDrawMode:
  29940. return this._gl.LINE_LOOP;
  29941. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].LineStripDrawMode:
  29942. return this._gl.LINE_STRIP;
  29943. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleStripDrawMode:
  29944. return this._gl.TRIANGLE_STRIP;
  29945. case _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFanDrawMode:
  29946. return this._gl.TRIANGLE_FAN;
  29947. default:
  29948. return this._gl.TRIANGLES;
  29949. }
  29950. };
  29951. // Shaders
  29952. /** @hidden */
  29953. Engine.prototype._releaseEffect = function (effect) {
  29954. if (this._compiledEffects[effect._key]) {
  29955. delete this._compiledEffects[effect._key];
  29956. this._deleteProgram(effect.getProgram());
  29957. }
  29958. };
  29959. /** @hidden */
  29960. Engine.prototype._deleteProgram = function (program) {
  29961. if (program) {
  29962. program.__SPECTOR_rebuildProgram = null;
  29963. if (program.transformFeedback) {
  29964. this.deleteTransformFeedback(program.transformFeedback);
  29965. program.transformFeedback = null;
  29966. }
  29967. this._gl.deleteProgram(program);
  29968. }
  29969. };
  29970. /**
  29971. * Create a new effect (used to store vertex/fragment shaders)
  29972. * @param baseName defines the base name of the effect (The name of file without .fragment.fx or .vertex.fx)
  29973. * @param attributesNamesOrOptions defines either a list of attribute names or an EffectCreationOptions object
  29974. * @param uniformsNamesOrEngine defines either a list of uniform names or the engine to use
  29975. * @param samplers defines an array of string used to represent textures
  29976. * @param defines defines the string containing the defines to use to compile the shaders
  29977. * @param fallbacks defines the list of potential fallbacks to use if shader conmpilation fails
  29978. * @param onCompiled defines a function to call when the effect creation is successful
  29979. * @param onError defines a function to call when the effect creation has failed
  29980. * @param indexParameters defines an object containing the index values to use to compile shaders (like the maximum number of simultaneous lights)
  29981. * @returns the new Effect
  29982. */
  29983. Engine.prototype.createEffect = function (baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, defines, fallbacks, onCompiled, onError, indexParameters) {
  29984. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  29985. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  29986. var name = vertex + "+" + fragment + "@" + (defines ? defines : attributesNamesOrOptions.defines);
  29987. if (this._compiledEffects[name]) {
  29988. var compiledEffect = this._compiledEffects[name];
  29989. if (onCompiled && compiledEffect.isReady()) {
  29990. onCompiled(compiledEffect);
  29991. }
  29992. return compiledEffect;
  29993. }
  29994. var effect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"](baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, this, defines, fallbacks, onCompiled, onError, indexParameters);
  29995. effect._key = name;
  29996. this._compiledEffects[name] = effect;
  29997. return effect;
  29998. };
  29999. Engine.prototype._compileShader = function (source, type, defines, shaderVersion) {
  30000. return this._compileRawShader(shaderVersion + (defines ? defines + "\n" : "") + source, type);
  30001. };
  30002. Engine.prototype._compileRawShader = function (source, type) {
  30003. var gl = this._gl;
  30004. var shader = gl.createShader(type === "vertex" ? gl.VERTEX_SHADER : gl.FRAGMENT_SHADER);
  30005. if (!shader) {
  30006. throw new Error("Something went wrong while compile the shader.");
  30007. }
  30008. gl.shaderSource(shader, source);
  30009. gl.compileShader(shader);
  30010. if (!gl.getShaderParameter(shader, gl.COMPILE_STATUS)) {
  30011. var log = gl.getShaderInfoLog(shader);
  30012. if (log) {
  30013. throw new Error(log);
  30014. }
  30015. }
  30016. return shader;
  30017. };
  30018. /**
  30019. * Directly creates a webGL program
  30020. * @param vertexCode defines the vertex shader code to use
  30021. * @param fragmentCode defines the fragment shader code to use
  30022. * @param context defines the webGL context to use (if not set, the current one will be used)
  30023. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30024. * @returns the new webGL program
  30025. */
  30026. Engine.prototype.createRawShaderProgram = function (vertexCode, fragmentCode, context, transformFeedbackVaryings) {
  30027. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30028. context = context || this._gl;
  30029. var vertexShader = this._compileRawShader(vertexCode, "vertex");
  30030. var fragmentShader = this._compileRawShader(fragmentCode, "fragment");
  30031. return this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30032. };
  30033. /**
  30034. * Creates a webGL program
  30035. * @param vertexCode defines the vertex shader code to use
  30036. * @param fragmentCode defines the fragment shader code to use
  30037. * @param defines defines the string containing the defines to use to compile the shaders
  30038. * @param context defines the webGL context to use (if not set, the current one will be used)
  30039. * @param transformFeedbackVaryings defines the list of transform feedback varyings to use
  30040. * @returns the new webGL program
  30041. */
  30042. Engine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context, transformFeedbackVaryings) {
  30043. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30044. context = context || this._gl;
  30045. this.onBeforeShaderCompilationObservable.notifyObservers(this);
  30046. var shaderVersion = (this._webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  30047. var vertexShader = this._compileShader(vertexCode, "vertex", defines, shaderVersion);
  30048. var fragmentShader = this._compileShader(fragmentCode, "fragment", defines, shaderVersion);
  30049. var program = this._createShaderProgram(vertexShader, fragmentShader, context, transformFeedbackVaryings);
  30050. this.onAfterShaderCompilationObservable.notifyObservers(this);
  30051. return program;
  30052. };
  30053. Engine.prototype._createShaderProgram = function (vertexShader, fragmentShader, context, transformFeedbackVaryings) {
  30054. if (transformFeedbackVaryings === void 0) { transformFeedbackVaryings = null; }
  30055. var shaderProgram = context.createProgram();
  30056. if (!shaderProgram) {
  30057. throw new Error("Unable to create program");
  30058. }
  30059. context.attachShader(shaderProgram, vertexShader);
  30060. context.attachShader(shaderProgram, fragmentShader);
  30061. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30062. var transformFeedback = this.createTransformFeedback();
  30063. this.bindTransformFeedback(transformFeedback);
  30064. this.setTranformFeedbackVaryings(shaderProgram, transformFeedbackVaryings);
  30065. shaderProgram.transformFeedback = transformFeedback;
  30066. }
  30067. context.linkProgram(shaderProgram);
  30068. if (this.webGLVersion > 1 && transformFeedbackVaryings) {
  30069. this.bindTransformFeedback(null);
  30070. }
  30071. shaderProgram.context = context;
  30072. shaderProgram.vertexShader = vertexShader;
  30073. shaderProgram.fragmentShader = fragmentShader;
  30074. if (!this._caps.parallelShaderCompile) {
  30075. this._finalizeProgram(shaderProgram);
  30076. }
  30077. else {
  30078. shaderProgram.isParallelCompiled = true;
  30079. }
  30080. return shaderProgram;
  30081. };
  30082. Engine.prototype._finalizeProgram = function (shaderProgram) {
  30083. var context = shaderProgram.context;
  30084. var vertexShader = shaderProgram.vertexShader;
  30085. var fragmentShader = shaderProgram.fragmentShader;
  30086. var linked = context.getProgramParameter(shaderProgram, context.LINK_STATUS);
  30087. if (!linked) {
  30088. var error = context.getProgramInfoLog(shaderProgram);
  30089. if (error) {
  30090. throw new Error(error);
  30091. }
  30092. }
  30093. if (this.validateShaderPrograms) {
  30094. context.validateProgram(shaderProgram);
  30095. var validated = context.getProgramParameter(shaderProgram, context.VALIDATE_STATUS);
  30096. if (!validated) {
  30097. var error = context.getProgramInfoLog(shaderProgram);
  30098. if (error) {
  30099. throw new Error(error);
  30100. }
  30101. }
  30102. }
  30103. context.deleteShader(vertexShader);
  30104. context.deleteShader(fragmentShader);
  30105. shaderProgram.context = undefined;
  30106. shaderProgram.vertexShader = undefined;
  30107. shaderProgram.fragmentShader = undefined;
  30108. if (shaderProgram.onCompiled) {
  30109. shaderProgram.onCompiled();
  30110. shaderProgram.onCompiled = undefined;
  30111. }
  30112. };
  30113. /** @hidden */
  30114. Engine.prototype._isProgramCompiled = function (shaderProgram) {
  30115. if (!shaderProgram.isParallelCompiled) {
  30116. return true;
  30117. }
  30118. if (this._gl.getProgramParameter(shaderProgram, this._caps.parallelShaderCompile.COMPLETION_STATUS_KHR)) {
  30119. this._finalizeProgram(shaderProgram);
  30120. return true;
  30121. }
  30122. return false;
  30123. };
  30124. /** @hidden */
  30125. Engine.prototype._executeWhenProgramIsCompiled = function (shaderProgram, action) {
  30126. if (!shaderProgram.isParallelCompiled) {
  30127. action();
  30128. return;
  30129. }
  30130. shaderProgram.onCompiled = action;
  30131. };
  30132. /**
  30133. * Gets the list of webGL uniform locations associated with a specific program based on a list of uniform names
  30134. * @param shaderProgram defines the webGL program to use
  30135. * @param uniformsNames defines the list of uniform names
  30136. * @returns an array of webGL uniform locations
  30137. */
  30138. Engine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  30139. var results = new Array();
  30140. for (var index = 0; index < uniformsNames.length; index++) {
  30141. results.push(this._gl.getUniformLocation(shaderProgram, uniformsNames[index]));
  30142. }
  30143. return results;
  30144. };
  30145. /**
  30146. * Gets the lsit of active attributes for a given webGL program
  30147. * @param shaderProgram defines the webGL program to use
  30148. * @param attributesNames defines the list of attribute names to get
  30149. * @returns an array of indices indicating the offset of each attribute
  30150. */
  30151. Engine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  30152. var results = [];
  30153. for (var index = 0; index < attributesNames.length; index++) {
  30154. try {
  30155. results.push(this._gl.getAttribLocation(shaderProgram, attributesNames[index]));
  30156. }
  30157. catch (e) {
  30158. results.push(-1);
  30159. }
  30160. }
  30161. return results;
  30162. };
  30163. /**
  30164. * Activates an effect, mkaing it the current one (ie. the one used for rendering)
  30165. * @param effect defines the effect to activate
  30166. */
  30167. Engine.prototype.enableEffect = function (effect) {
  30168. if (!effect || effect === this._currentEffect) {
  30169. return;
  30170. }
  30171. // Use program
  30172. this.bindSamplers(effect);
  30173. this._currentEffect = effect;
  30174. if (effect.onBind) {
  30175. effect.onBind(effect);
  30176. }
  30177. if (effect._onBindObservable) {
  30178. effect._onBindObservable.notifyObservers(effect);
  30179. }
  30180. };
  30181. /**
  30182. * Set the value of an uniform to an array of int32
  30183. * @param uniform defines the webGL uniform location where to store the value
  30184. * @param array defines the array of int32 to store
  30185. */
  30186. Engine.prototype.setIntArray = function (uniform, array) {
  30187. if (!uniform) {
  30188. return;
  30189. }
  30190. this._gl.uniform1iv(uniform, array);
  30191. };
  30192. /**
  30193. * Set the value of an uniform to an array of int32 (stored as vec2)
  30194. * @param uniform defines the webGL uniform location where to store the value
  30195. * @param array defines the array of int32 to store
  30196. */
  30197. Engine.prototype.setIntArray2 = function (uniform, array) {
  30198. if (!uniform || array.length % 2 !== 0) {
  30199. return;
  30200. }
  30201. this._gl.uniform2iv(uniform, array);
  30202. };
  30203. /**
  30204. * Set the value of an uniform to an array of int32 (stored as vec3)
  30205. * @param uniform defines the webGL uniform location where to store the value
  30206. * @param array defines the array of int32 to store
  30207. */
  30208. Engine.prototype.setIntArray3 = function (uniform, array) {
  30209. if (!uniform || array.length % 3 !== 0) {
  30210. return;
  30211. }
  30212. this._gl.uniform3iv(uniform, array);
  30213. };
  30214. /**
  30215. * Set the value of an uniform to an array of int32 (stored as vec4)
  30216. * @param uniform defines the webGL uniform location where to store the value
  30217. * @param array defines the array of int32 to store
  30218. */
  30219. Engine.prototype.setIntArray4 = function (uniform, array) {
  30220. if (!uniform || array.length % 4 !== 0) {
  30221. return;
  30222. }
  30223. this._gl.uniform4iv(uniform, array);
  30224. };
  30225. /**
  30226. * Set the value of an uniform to an array of float32
  30227. * @param uniform defines the webGL uniform location where to store the value
  30228. * @param array defines the array of float32 to store
  30229. */
  30230. Engine.prototype.setFloatArray = function (uniform, array) {
  30231. if (!uniform) {
  30232. return;
  30233. }
  30234. this._gl.uniform1fv(uniform, array);
  30235. };
  30236. /**
  30237. * Set the value of an uniform to an array of float32 (stored as vec2)
  30238. * @param uniform defines the webGL uniform location where to store the value
  30239. * @param array defines the array of float32 to store
  30240. */
  30241. Engine.prototype.setFloatArray2 = function (uniform, array) {
  30242. if (!uniform || array.length % 2 !== 0) {
  30243. return;
  30244. }
  30245. this._gl.uniform2fv(uniform, array);
  30246. };
  30247. /**
  30248. * Set the value of an uniform to an array of float32 (stored as vec3)
  30249. * @param uniform defines the webGL uniform location where to store the value
  30250. * @param array defines the array of float32 to store
  30251. */
  30252. Engine.prototype.setFloatArray3 = function (uniform, array) {
  30253. if (!uniform || array.length % 3 !== 0) {
  30254. return;
  30255. }
  30256. this._gl.uniform3fv(uniform, array);
  30257. };
  30258. /**
  30259. * Set the value of an uniform to an array of float32 (stored as vec4)
  30260. * @param uniform defines the webGL uniform location where to store the value
  30261. * @param array defines the array of float32 to store
  30262. */
  30263. Engine.prototype.setFloatArray4 = function (uniform, array) {
  30264. if (!uniform || array.length % 4 !== 0) {
  30265. return;
  30266. }
  30267. this._gl.uniform4fv(uniform, array);
  30268. };
  30269. /**
  30270. * Set the value of an uniform to an array of number
  30271. * @param uniform defines the webGL uniform location where to store the value
  30272. * @param array defines the array of number to store
  30273. */
  30274. Engine.prototype.setArray = function (uniform, array) {
  30275. if (!uniform) {
  30276. return;
  30277. }
  30278. this._gl.uniform1fv(uniform, array);
  30279. };
  30280. /**
  30281. * Set the value of an uniform to an array of number (stored as vec2)
  30282. * @param uniform defines the webGL uniform location where to store the value
  30283. * @param array defines the array of number to store
  30284. */
  30285. Engine.prototype.setArray2 = function (uniform, array) {
  30286. if (!uniform || array.length % 2 !== 0) {
  30287. return;
  30288. }
  30289. this._gl.uniform2fv(uniform, array);
  30290. };
  30291. /**
  30292. * Set the value of an uniform to an array of number (stored as vec3)
  30293. * @param uniform defines the webGL uniform location where to store the value
  30294. * @param array defines the array of number to store
  30295. */
  30296. Engine.prototype.setArray3 = function (uniform, array) {
  30297. if (!uniform || array.length % 3 !== 0) {
  30298. return;
  30299. }
  30300. this._gl.uniform3fv(uniform, array);
  30301. };
  30302. /**
  30303. * Set the value of an uniform to an array of number (stored as vec4)
  30304. * @param uniform defines the webGL uniform location where to store the value
  30305. * @param array defines the array of number to store
  30306. */
  30307. Engine.prototype.setArray4 = function (uniform, array) {
  30308. if (!uniform || array.length % 4 !== 0) {
  30309. return;
  30310. }
  30311. this._gl.uniform4fv(uniform, array);
  30312. };
  30313. /**
  30314. * Set the value of an uniform to an array of float32 (stored as matrices)
  30315. * @param uniform defines the webGL uniform location where to store the value
  30316. * @param matrices defines the array of float32 to store
  30317. */
  30318. Engine.prototype.setMatrices = function (uniform, matrices) {
  30319. if (!uniform) {
  30320. return;
  30321. }
  30322. this._gl.uniformMatrix4fv(uniform, false, matrices);
  30323. };
  30324. /**
  30325. * Set the value of an uniform to a matrix
  30326. * @param uniform defines the webGL uniform location where to store the value
  30327. * @param matrix defines the matrix to store
  30328. */
  30329. Engine.prototype.setMatrix = function (uniform, matrix) {
  30330. if (!uniform) {
  30331. return;
  30332. }
  30333. this._gl.uniformMatrix4fv(uniform, false, matrix.toArray());
  30334. };
  30335. /**
  30336. * Set the value of an uniform to a matrix (3x3)
  30337. * @param uniform defines the webGL uniform location where to store the value
  30338. * @param matrix defines the Float32Array representing the 3x3 matrix to store
  30339. */
  30340. Engine.prototype.setMatrix3x3 = function (uniform, matrix) {
  30341. if (!uniform) {
  30342. return;
  30343. }
  30344. this._gl.uniformMatrix3fv(uniform, false, matrix);
  30345. };
  30346. /**
  30347. * Set the value of an uniform to a matrix (2x2)
  30348. * @param uniform defines the webGL uniform location where to store the value
  30349. * @param matrix defines the Float32Array representing the 2x2 matrix to store
  30350. */
  30351. Engine.prototype.setMatrix2x2 = function (uniform, matrix) {
  30352. if (!uniform) {
  30353. return;
  30354. }
  30355. this._gl.uniformMatrix2fv(uniform, false, matrix);
  30356. };
  30357. /**
  30358. * Set the value of an uniform to a number (int)
  30359. * @param uniform defines the webGL uniform location where to store the value
  30360. * @param value defines the int number to store
  30361. */
  30362. Engine.prototype.setInt = function (uniform, value) {
  30363. if (!uniform) {
  30364. return;
  30365. }
  30366. this._gl.uniform1i(uniform, value);
  30367. };
  30368. /**
  30369. * Set the value of an uniform to a number (float)
  30370. * @param uniform defines the webGL uniform location where to store the value
  30371. * @param value defines the float number to store
  30372. */
  30373. Engine.prototype.setFloat = function (uniform, value) {
  30374. if (!uniform) {
  30375. return;
  30376. }
  30377. this._gl.uniform1f(uniform, value);
  30378. };
  30379. /**
  30380. * Set the value of an uniform to a vec2
  30381. * @param uniform defines the webGL uniform location where to store the value
  30382. * @param x defines the 1st component of the value
  30383. * @param y defines the 2nd component of the value
  30384. */
  30385. Engine.prototype.setFloat2 = function (uniform, x, y) {
  30386. if (!uniform) {
  30387. return;
  30388. }
  30389. this._gl.uniform2f(uniform, x, y);
  30390. };
  30391. /**
  30392. * Set the value of an uniform to a vec3
  30393. * @param uniform defines the webGL uniform location where to store the value
  30394. * @param x defines the 1st component of the value
  30395. * @param y defines the 2nd component of the value
  30396. * @param z defines the 3rd component of the value
  30397. */
  30398. Engine.prototype.setFloat3 = function (uniform, x, y, z) {
  30399. if (!uniform) {
  30400. return;
  30401. }
  30402. this._gl.uniform3f(uniform, x, y, z);
  30403. };
  30404. /**
  30405. * Set the value of an uniform to a boolean
  30406. * @param uniform defines the webGL uniform location where to store the value
  30407. * @param bool defines the boolean to store
  30408. */
  30409. Engine.prototype.setBool = function (uniform, bool) {
  30410. if (!uniform) {
  30411. return;
  30412. }
  30413. this._gl.uniform1i(uniform, bool);
  30414. };
  30415. /**
  30416. * Set the value of an uniform to a vec4
  30417. * @param uniform defines the webGL uniform location where to store the value
  30418. * @param x defines the 1st component of the value
  30419. * @param y defines the 2nd component of the value
  30420. * @param z defines the 3rd component of the value
  30421. * @param w defines the 4th component of the value
  30422. */
  30423. Engine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  30424. if (!uniform) {
  30425. return;
  30426. }
  30427. this._gl.uniform4f(uniform, x, y, z, w);
  30428. };
  30429. /**
  30430. * Set the value of an uniform to a Color3
  30431. * @param uniform defines the webGL uniform location where to store the value
  30432. * @param color3 defines the color to store
  30433. */
  30434. Engine.prototype.setColor3 = function (uniform, color3) {
  30435. if (!uniform) {
  30436. return;
  30437. }
  30438. this._gl.uniform3f(uniform, color3.r, color3.g, color3.b);
  30439. };
  30440. /**
  30441. * Set the value of an uniform to a Color3 and an alpha value
  30442. * @param uniform defines the webGL uniform location where to store the value
  30443. * @param color3 defines the color to store
  30444. * @param alpha defines the alpha component to store
  30445. */
  30446. Engine.prototype.setColor4 = function (uniform, color3, alpha) {
  30447. if (!uniform) {
  30448. return;
  30449. }
  30450. this._gl.uniform4f(uniform, color3.r, color3.g, color3.b, alpha);
  30451. };
  30452. /**
  30453. * Sets a Color4 on a uniform variable
  30454. * @param uniform defines the uniform location
  30455. * @param color4 defines the value to be set
  30456. */
  30457. Engine.prototype.setDirectColor4 = function (uniform, color4) {
  30458. if (!uniform) {
  30459. return;
  30460. }
  30461. this._gl.uniform4f(uniform, color4.r, color4.g, color4.b, color4.a);
  30462. };
  30463. // States
  30464. /**
  30465. * Set various states to the webGL context
  30466. * @param culling defines backface culling state
  30467. * @param zOffset defines the value to apply to zOffset (0 by default)
  30468. * @param force defines if states must be applied even if cache is up to date
  30469. * @param reverseSide defines if culling must be reversed (CCW instead of CW and CW instead of CCW)
  30470. */
  30471. Engine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  30472. if (zOffset === void 0) { zOffset = 0; }
  30473. if (reverseSide === void 0) { reverseSide = false; }
  30474. // Culling
  30475. if (this._depthCullingState.cull !== culling || force) {
  30476. this._depthCullingState.cull = culling;
  30477. }
  30478. // Cull face
  30479. var cullFace = this.cullBackFaces ? this._gl.BACK : this._gl.FRONT;
  30480. if (this._depthCullingState.cullFace !== cullFace || force) {
  30481. this._depthCullingState.cullFace = cullFace;
  30482. }
  30483. // Z offset
  30484. this.setZOffset(zOffset);
  30485. // Front face
  30486. var frontFace = reverseSide ? this._gl.CW : this._gl.CCW;
  30487. if (this._depthCullingState.frontFace !== frontFace || force) {
  30488. this._depthCullingState.frontFace = frontFace;
  30489. }
  30490. };
  30491. /**
  30492. * Set the z offset to apply to current rendering
  30493. * @param value defines the offset to apply
  30494. */
  30495. Engine.prototype.setZOffset = function (value) {
  30496. this._depthCullingState.zOffset = value;
  30497. };
  30498. /**
  30499. * Gets the current value of the zOffset
  30500. * @returns the current zOffset state
  30501. */
  30502. Engine.prototype.getZOffset = function () {
  30503. return this._depthCullingState.zOffset;
  30504. };
  30505. /**
  30506. * Enable or disable depth buffering
  30507. * @param enable defines the state to set
  30508. */
  30509. Engine.prototype.setDepthBuffer = function (enable) {
  30510. this._depthCullingState.depthTest = enable;
  30511. };
  30512. /**
  30513. * Gets a boolean indicating if depth writing is enabled
  30514. * @returns the current depth writing state
  30515. */
  30516. Engine.prototype.getDepthWrite = function () {
  30517. return this._depthCullingState.depthMask;
  30518. };
  30519. /**
  30520. * Enable or disable depth writing
  30521. * @param enable defines the state to set
  30522. */
  30523. Engine.prototype.setDepthWrite = function (enable) {
  30524. this._depthCullingState.depthMask = enable;
  30525. };
  30526. /**
  30527. * Enable or disable color writing
  30528. * @param enable defines the state to set
  30529. */
  30530. Engine.prototype.setColorWrite = function (enable) {
  30531. this._gl.colorMask(enable, enable, enable, enable);
  30532. this._colorWrite = enable;
  30533. };
  30534. /**
  30535. * Gets a boolean indicating if color writing is enabled
  30536. * @returns the current color writing state
  30537. */
  30538. Engine.prototype.getColorWrite = function () {
  30539. return this._colorWrite;
  30540. };
  30541. /**
  30542. * Sets alpha constants used by some alpha blending modes
  30543. * @param r defines the red component
  30544. * @param g defines the green component
  30545. * @param b defines the blue component
  30546. * @param a defines the alpha component
  30547. */
  30548. Engine.prototype.setAlphaConstants = function (r, g, b, a) {
  30549. this._alphaState.setAlphaBlendConstants(r, g, b, a);
  30550. };
  30551. /**
  30552. * Sets the current alpha mode
  30553. * @param mode defines the mode to use (one of the Engine.ALPHA_XXX)
  30554. * @param noDepthWriteChange defines if depth writing state should remains unchanged (false by default)
  30555. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30556. */
  30557. Engine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  30558. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  30559. if (this._alphaMode === mode) {
  30560. return;
  30561. }
  30562. switch (mode) {
  30563. case Engine.ALPHA_DISABLE:
  30564. this._alphaState.alphaBlend = false;
  30565. break;
  30566. case Engine.ALPHA_PREMULTIPLIED:
  30567. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30568. this._alphaState.alphaBlend = true;
  30569. break;
  30570. case Engine.ALPHA_PREMULTIPLIED_PORTERDUFF:
  30571. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30572. this._alphaState.alphaBlend = true;
  30573. break;
  30574. case Engine.ALPHA_COMBINE:
  30575. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_ALPHA, this._gl.ONE, this._gl.ONE);
  30576. this._alphaState.alphaBlend = true;
  30577. break;
  30578. case Engine.ALPHA_ONEONE:
  30579. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30580. this._alphaState.alphaBlend = true;
  30581. break;
  30582. case Engine.ALPHA_ADD:
  30583. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE, this._gl.ZERO, this._gl.ONE);
  30584. this._alphaState.alphaBlend = true;
  30585. break;
  30586. case Engine.ALPHA_SUBTRACT:
  30587. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ZERO, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30588. this._alphaState.alphaBlend = true;
  30589. break;
  30590. case Engine.ALPHA_MULTIPLY:
  30591. this._alphaState.setAlphaBlendFunctionParameters(this._gl.DST_COLOR, this._gl.ZERO, this._gl.ONE, this._gl.ONE);
  30592. this._alphaState.alphaBlend = true;
  30593. break;
  30594. case Engine.ALPHA_MAXIMIZED:
  30595. this._alphaState.setAlphaBlendFunctionParameters(this._gl.SRC_ALPHA, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE);
  30596. this._alphaState.alphaBlend = true;
  30597. break;
  30598. case Engine.ALPHA_INTERPOLATE:
  30599. this._alphaState.setAlphaBlendFunctionParameters(this._gl.CONSTANT_COLOR, this._gl.ONE_MINUS_CONSTANT_COLOR, this._gl.CONSTANT_ALPHA, this._gl.ONE_MINUS_CONSTANT_ALPHA);
  30600. this._alphaState.alphaBlend = true;
  30601. break;
  30602. case Engine.ALPHA_SCREENMODE:
  30603. this._alphaState.setAlphaBlendFunctionParameters(this._gl.ONE, this._gl.ONE_MINUS_SRC_COLOR, this._gl.ONE, this._gl.ONE_MINUS_SRC_ALPHA);
  30604. this._alphaState.alphaBlend = true;
  30605. break;
  30606. }
  30607. if (!noDepthWriteChange) {
  30608. this.setDepthWrite(mode === Engine.ALPHA_DISABLE);
  30609. }
  30610. this._alphaMode = mode;
  30611. };
  30612. /**
  30613. * Gets the current alpha mode
  30614. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered
  30615. * @returns the current alpha mode
  30616. */
  30617. Engine.prototype.getAlphaMode = function () {
  30618. return this._alphaMode;
  30619. };
  30620. // Textures
  30621. /**
  30622. * Clears the list of texture accessible through engine.
  30623. * This can help preventing texture load conflict due to name collision.
  30624. */
  30625. Engine.prototype.clearInternalTexturesCache = function () {
  30626. this._internalTexturesCache = [];
  30627. };
  30628. /**
  30629. * Force the entire cache to be cleared
  30630. * You should not have to use this function unless your engine needs to share the webGL context with another engine
  30631. * @param bruteForce defines a boolean to force clearing ALL caches (including stencil, detoh and alpha states)
  30632. */
  30633. Engine.prototype.wipeCaches = function (bruteForce) {
  30634. if (this.preventCacheWipeBetweenFrames && !bruteForce) {
  30635. return;
  30636. }
  30637. this._currentEffect = null;
  30638. this._viewportCached.x = 0;
  30639. this._viewportCached.y = 0;
  30640. this._viewportCached.z = 0;
  30641. this._viewportCached.w = 0;
  30642. if (bruteForce) {
  30643. this.resetTextureCache();
  30644. this._currentProgram = null;
  30645. this._stencilState.reset();
  30646. this._depthCullingState.reset();
  30647. this.setDepthFunctionToLessOrEqual();
  30648. this._alphaState.reset();
  30649. this._unpackFlipYCached = null;
  30650. }
  30651. this._resetVertexBufferBinding();
  30652. this._cachedIndexBuffer = null;
  30653. this._cachedEffectForVertexBuffers = null;
  30654. this._unbindVertexArrayObject();
  30655. this.bindIndexBuffer(null);
  30656. };
  30657. /**
  30658. * Set the compressed texture format to use, based on the formats you have, and the formats
  30659. * supported by the hardware / browser.
  30660. *
  30661. * Khronos Texture Container (.ktx) files are used to support this. This format has the
  30662. * advantage of being specifically designed for OpenGL. Header elements directly correspond
  30663. * to API arguments needed to compressed textures. This puts the burden on the container
  30664. * generator to house the arcane code for determining these for current & future formats.
  30665. *
  30666. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  30667. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  30668. *
  30669. * Note: The result of this call is not taken into account when a texture is base64.
  30670. *
  30671. * @param formatsAvailable defines the list of those format families you have created
  30672. * on your server. Syntax: '-' + format family + '.ktx'. (Case and order do not matter.)
  30673. *
  30674. * Current families are astc, dxt, pvrtc, etc2, & etc1.
  30675. * @returns The extension selected.
  30676. */
  30677. Engine.prototype.setTextureFormatToUse = function (formatsAvailable) {
  30678. for (var i = 0, len1 = this.texturesSupported.length; i < len1; i++) {
  30679. for (var j = 0, len2 = formatsAvailable.length; j < len2; j++) {
  30680. if (this._texturesSupported[i] === formatsAvailable[j].toLowerCase()) {
  30681. return this._textureFormatInUse = this._texturesSupported[i];
  30682. }
  30683. }
  30684. }
  30685. // actively set format to nothing, to allow this to be called more than once
  30686. // and possibly fail the 2nd time
  30687. this._textureFormatInUse = null;
  30688. return null;
  30689. };
  30690. Engine.prototype._getSamplingParameters = function (samplingMode, generateMipMaps) {
  30691. var gl = this._gl;
  30692. var magFilter = gl.NEAREST;
  30693. var minFilter = gl.NEAREST;
  30694. switch (samplingMode) {
  30695. case Engine.TEXTURE_BILINEAR_SAMPLINGMODE:
  30696. magFilter = gl.LINEAR;
  30697. if (generateMipMaps) {
  30698. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30699. }
  30700. else {
  30701. minFilter = gl.LINEAR;
  30702. }
  30703. break;
  30704. case Engine.TEXTURE_TRILINEAR_SAMPLINGMODE:
  30705. magFilter = gl.LINEAR;
  30706. if (generateMipMaps) {
  30707. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30708. }
  30709. else {
  30710. minFilter = gl.LINEAR;
  30711. }
  30712. break;
  30713. case Engine.TEXTURE_NEAREST_SAMPLINGMODE:
  30714. magFilter = gl.NEAREST;
  30715. if (generateMipMaps) {
  30716. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30717. }
  30718. else {
  30719. minFilter = gl.NEAREST;
  30720. }
  30721. break;
  30722. case Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST:
  30723. magFilter = gl.NEAREST;
  30724. if (generateMipMaps) {
  30725. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30726. }
  30727. else {
  30728. minFilter = gl.NEAREST;
  30729. }
  30730. break;
  30731. case Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST:
  30732. magFilter = gl.NEAREST;
  30733. if (generateMipMaps) {
  30734. minFilter = gl.LINEAR_MIPMAP_NEAREST;
  30735. }
  30736. else {
  30737. minFilter = gl.LINEAR;
  30738. }
  30739. break;
  30740. case Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR:
  30741. magFilter = gl.NEAREST;
  30742. if (generateMipMaps) {
  30743. minFilter = gl.LINEAR_MIPMAP_LINEAR;
  30744. }
  30745. else {
  30746. minFilter = gl.LINEAR;
  30747. }
  30748. break;
  30749. case Engine.TEXTURE_NEAREST_LINEAR:
  30750. magFilter = gl.NEAREST;
  30751. minFilter = gl.LINEAR;
  30752. break;
  30753. case Engine.TEXTURE_NEAREST_NEAREST:
  30754. magFilter = gl.NEAREST;
  30755. minFilter = gl.NEAREST;
  30756. break;
  30757. case Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST:
  30758. magFilter = gl.LINEAR;
  30759. if (generateMipMaps) {
  30760. minFilter = gl.NEAREST_MIPMAP_NEAREST;
  30761. }
  30762. else {
  30763. minFilter = gl.NEAREST;
  30764. }
  30765. break;
  30766. case Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR:
  30767. magFilter = gl.LINEAR;
  30768. if (generateMipMaps) {
  30769. minFilter = gl.NEAREST_MIPMAP_LINEAR;
  30770. }
  30771. else {
  30772. minFilter = gl.NEAREST;
  30773. }
  30774. break;
  30775. case Engine.TEXTURE_LINEAR_LINEAR:
  30776. magFilter = gl.LINEAR;
  30777. minFilter = gl.LINEAR;
  30778. break;
  30779. case Engine.TEXTURE_LINEAR_NEAREST:
  30780. magFilter = gl.LINEAR;
  30781. minFilter = gl.NEAREST;
  30782. break;
  30783. }
  30784. return {
  30785. min: minFilter,
  30786. mag: magFilter
  30787. };
  30788. };
  30789. Engine.prototype._partialLoadImg = function (url, index, loadedImages, scene, onfinish, onErrorCallBack) {
  30790. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  30791. var img;
  30792. var onload = function () {
  30793. loadedImages[index] = img;
  30794. loadedImages._internalCount++;
  30795. if (scene) {
  30796. scene._removePendingData(img);
  30797. }
  30798. if (loadedImages._internalCount === 6) {
  30799. onfinish(loadedImages);
  30800. }
  30801. };
  30802. var onerror = function (message, exception) {
  30803. if (scene) {
  30804. scene._removePendingData(img);
  30805. }
  30806. if (onErrorCallBack) {
  30807. onErrorCallBack(message, exception);
  30808. }
  30809. };
  30810. img = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onerror, scene ? scene.offlineProvider : null);
  30811. if (scene) {
  30812. scene._addPendingData(img);
  30813. }
  30814. };
  30815. Engine.prototype._cascadeLoadImgs = function (scene, onfinish, files, onError) {
  30816. if (onError === void 0) { onError = null; }
  30817. var loadedImages = [];
  30818. loadedImages._internalCount = 0;
  30819. for (var index = 0; index < 6; index++) {
  30820. this._partialLoadImg(files[index], index, loadedImages, scene, onfinish, onError);
  30821. }
  30822. };
  30823. /** @hidden */
  30824. Engine.prototype._createTexture = function () {
  30825. var texture = this._gl.createTexture();
  30826. if (!texture) {
  30827. throw new Error("Unable to create texture");
  30828. }
  30829. return texture;
  30830. };
  30831. /**
  30832. * Usually called from Texture.ts.
  30833. * Passed information to create a WebGLTexture
  30834. * @param urlArg defines a value which contains one of the following:
  30835. * * A conventional http URL, e.g. 'http://...' or 'file://...'
  30836. * * A base64 string of in-line texture data, e.g. 'data:image/jpg;base64,/...'
  30837. * * An indicator that data being passed using the buffer parameter, e.g. 'data:mytexture.jpg'
  30838. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated. Ignored for compressed textures. They must be in the file
  30839. * @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)
  30840. * @param scene needed for loading to the correct scene
  30841. * @param samplingMode mode with should be used sample / access the texture (Default: Texture.TRILINEAR_SAMPLINGMODE)
  30842. * @param onLoad optional callback to be called upon successful completion
  30843. * @param onError optional callback to be called upon failure
  30844. * @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
  30845. * @param fallback an internal argument in case the function must be called again, due to etc1 not having alpha capabilities
  30846. * @param format internal format. Default: RGB when extension is '.jpg' else RGBA. Ignored for compressed textures
  30847. * @param forcedExtension defines the extension to use to pick the right loader
  30848. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (default: empty array)
  30849. * @returns a InternalTexture for assignment back into BABYLON.Texture
  30850. */
  30851. Engine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallback, format, forcedExtension, excludeLoaders) {
  30852. var _this = this;
  30853. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  30854. if (onLoad === void 0) { onLoad = null; }
  30855. if (onError === void 0) { onError = null; }
  30856. if (buffer === void 0) { buffer = null; }
  30857. if (fallback === void 0) { fallback = null; }
  30858. if (format === void 0) { format = null; }
  30859. if (forcedExtension === void 0) { forcedExtension = null; }
  30860. if (excludeLoaders === void 0) { excludeLoaders = []; }
  30861. var url = String(urlArg); // assign a new string, so that the original is still available in case of fallback
  30862. var fromData = url.substr(0, 5) === "data:";
  30863. var fromBlob = url.substr(0, 5) === "blob:";
  30864. var isBase64 = fromData && url.indexOf(";base64,") !== -1;
  30865. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_URL);
  30866. // establish the file extension, if possible
  30867. var lastDot = url.lastIndexOf('.');
  30868. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? url.substring(lastDot).toLowerCase() : "");
  30869. var loader = null;
  30870. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  30871. var availableLoader = _a[_i];
  30872. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, isBase64, buffer ? true : false)) {
  30873. loader = availableLoader;
  30874. break;
  30875. }
  30876. }
  30877. if (loader) {
  30878. url = loader.transformUrl(url, this._textureFormatInUse);
  30879. }
  30880. if (scene) {
  30881. scene._addPendingData(texture);
  30882. }
  30883. texture.url = url;
  30884. texture.generateMipMaps = !noMipmap;
  30885. texture.samplingMode = samplingMode;
  30886. texture.invertY = invertY;
  30887. if (!this._doNotHandleContextLost) {
  30888. // Keep a link to the buffer only if we plan to handle context lost
  30889. texture._buffer = buffer;
  30890. }
  30891. var onLoadObserver = null;
  30892. if (onLoad && !fallback) {
  30893. onLoadObserver = texture.onLoadedObservable.add(onLoad);
  30894. }
  30895. if (!fallback) {
  30896. this._internalTexturesCache.push(texture);
  30897. }
  30898. var onInternalError = function (message, exception) {
  30899. if (scene) {
  30900. scene._removePendingData(texture);
  30901. }
  30902. var customFallback = false;
  30903. if (loader) {
  30904. var fallbackUrl = loader.getFallbackTextureUrl(url, _this._textureFormatInUse);
  30905. if (fallbackUrl) {
  30906. // Add Back
  30907. customFallback = true;
  30908. excludeLoaders.push(loader);
  30909. _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");
  30910. _this.createTexture(urlArg, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture, undefined, undefined, excludeLoaders);
  30911. }
  30912. }
  30913. if (!customFallback) {
  30914. if (onLoadObserver) {
  30915. texture.onLoadedObservable.remove(onLoadObserver);
  30916. }
  30917. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].UseFallbackTexture) {
  30918. _this.createTexture(_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].fallbackTexture, noMipmap, texture.invertY, scene, samplingMode, null, null, buffer, texture);
  30919. }
  30920. }
  30921. if (onError) {
  30922. onError(message || "Unknown error", exception);
  30923. }
  30924. };
  30925. // processing for non-image formats
  30926. if (loader) {
  30927. var callback = function (data) {
  30928. loader.loadData(data, texture, function (width, height, loadMipmap, isCompressed, done, loadFailed) {
  30929. if (loadFailed) {
  30930. onInternalError("TextureLoader failed to load data");
  30931. }
  30932. else {
  30933. _this._prepareWebGLTexture(texture, scene, width, height, texture.invertY, !loadMipmap, isCompressed, function () {
  30934. done();
  30935. return false;
  30936. }, samplingMode);
  30937. }
  30938. });
  30939. };
  30940. if (!buffer) {
  30941. this._loadFile(url, callback, undefined, scene ? scene.offlineProvider : undefined, true, function (request, exception) {
  30942. onInternalError("Unable to load " + (request ? request.responseURL : url, exception));
  30943. });
  30944. }
  30945. else {
  30946. callback(buffer);
  30947. }
  30948. }
  30949. else {
  30950. var onload = function (img) {
  30951. if (fromBlob && !_this._doNotHandleContextLost) {
  30952. // We need to store the image if we need to rebuild the texture
  30953. // in case of a webgl context lost
  30954. texture._buffer = img;
  30955. }
  30956. _this._prepareWebGLTexture(texture, scene, img.width, img.height, texture.invertY, noMipmap, false, function (potWidth, potHeight, continuationCallback) {
  30957. var gl = _this._gl;
  30958. var isPot = (img.width === potWidth && img.height === potHeight);
  30959. var internalFormat = format ? _this._getInternalFormat(format) : ((extension === ".jpg") ? gl.RGB : gl.RGBA);
  30960. if (isPot) {
  30961. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30962. return false;
  30963. }
  30964. var maxTextureSize = _this._caps.maxTextureSize;
  30965. if (img.width > maxTextureSize || img.height > maxTextureSize || Engine._RescalePostProcessFactory === null) {
  30966. _this._prepareWorkingCanvas();
  30967. if (!_this._workingCanvas || !_this._workingContext) {
  30968. return false;
  30969. }
  30970. _this._workingCanvas.width = potWidth;
  30971. _this._workingCanvas.height = potHeight;
  30972. _this._workingContext.drawImage(img, 0, 0, img.width, img.height, 0, 0, potWidth, potHeight);
  30973. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  30974. texture.width = potWidth;
  30975. texture.height = potHeight;
  30976. return false;
  30977. }
  30978. else {
  30979. // Using shaders when possible to rescale because canvas.drawImage is lossy
  30980. var source_1 = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_TEMP);
  30981. _this._bindTextureDirectly(gl.TEXTURE_2D, source_1, true);
  30982. gl.texImage2D(gl.TEXTURE_2D, 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, img);
  30983. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  30984. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  30985. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  30986. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  30987. _this._rescaleTexture(source_1, texture, scene, internalFormat, function () {
  30988. _this._releaseTexture(source_1);
  30989. _this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  30990. continuationCallback();
  30991. });
  30992. }
  30993. return true;
  30994. }, samplingMode);
  30995. };
  30996. if (!fromData || isBase64) {
  30997. if (buffer instanceof HTMLImageElement) {
  30998. onload(buffer);
  30999. }
  31000. else {
  31001. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(url, onload, onInternalError, scene ? scene.offlineProvider : null);
  31002. }
  31003. }
  31004. else if (typeof buffer === "string" || buffer instanceof ArrayBuffer || buffer instanceof Blob) {
  31005. _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadImage(buffer, onload, onInternalError, scene ? scene.offlineProvider : null);
  31006. }
  31007. else {
  31008. onload(buffer);
  31009. }
  31010. }
  31011. return texture;
  31012. };
  31013. Engine.prototype._rescaleTexture = function (source, destination, scene, internalFormat, onComplete) {
  31014. var _this = this;
  31015. var rtt = this.createRenderTargetTexture({
  31016. width: destination.width,
  31017. height: destination.height,
  31018. }, {
  31019. generateMipMaps: false,
  31020. type: Engine.TEXTURETYPE_UNSIGNED_INT,
  31021. samplingMode: Engine.TEXTURE_BILINEAR_SAMPLINGMODE,
  31022. generateDepthBuffer: false,
  31023. generateStencilBuffer: false
  31024. });
  31025. if (!this._rescalePostProcess && Engine._RescalePostProcessFactory) {
  31026. this._rescalePostProcess = Engine._RescalePostProcessFactory(this);
  31027. }
  31028. this._rescalePostProcess.getEffect().executeWhenCompiled(function () {
  31029. _this._rescalePostProcess.onApply = function (effect) {
  31030. effect._bindTexture("textureSampler", source);
  31031. };
  31032. var hostingScene = scene;
  31033. if (!hostingScene) {
  31034. hostingScene = _this.scenes[_this.scenes.length - 1];
  31035. }
  31036. hostingScene.postProcessManager.directRender([_this._rescalePostProcess], rtt, true);
  31037. _this._bindTextureDirectly(_this._gl.TEXTURE_2D, destination, true);
  31038. _this._gl.copyTexImage2D(_this._gl.TEXTURE_2D, 0, internalFormat, 0, 0, destination.width, destination.height, 0);
  31039. _this.unBindFramebuffer(rtt);
  31040. _this._releaseTexture(rtt);
  31041. if (onComplete) {
  31042. onComplete();
  31043. }
  31044. });
  31045. };
  31046. /**
  31047. * Update a raw texture
  31048. * @param texture defines the texture to update
  31049. * @param data defines the data to store in the texture
  31050. * @param format defines the format of the data
  31051. * @param invertY defines if data must be stored with Y axis inverted
  31052. * @param compression defines the compression used (null by default)
  31053. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31054. */
  31055. Engine.prototype.updateRawTexture = function (texture, data, format, invertY, compression, type) {
  31056. if (compression === void 0) { compression = null; }
  31057. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31058. if (!texture) {
  31059. return;
  31060. }
  31061. // babylon's internalSizedFomat but gl's texImage2D internalFormat
  31062. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type, format);
  31063. // babylon's internalFormat but gl's texImage2D format
  31064. var internalFormat = this._getInternalFormat(format);
  31065. var textureType = this._getWebGLTextureType(type);
  31066. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31067. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  31068. if (!this._doNotHandleContextLost) {
  31069. texture._bufferView = data;
  31070. texture.format = format;
  31071. texture.type = type;
  31072. texture.invertY = invertY;
  31073. texture._compression = compression;
  31074. }
  31075. if (texture.width % 4 !== 0) {
  31076. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  31077. }
  31078. if (compression && data) {
  31079. this._gl.compressedTexImage2D(this._gl.TEXTURE_2D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, 0, data);
  31080. }
  31081. else {
  31082. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, data);
  31083. }
  31084. if (texture.generateMipMaps) {
  31085. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31086. }
  31087. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31088. // this.resetTextureCache();
  31089. texture.isReady = true;
  31090. };
  31091. /**
  31092. * Creates a raw texture
  31093. * @param data defines the data to store in the texture
  31094. * @param width defines the width of the texture
  31095. * @param height defines the height of the texture
  31096. * @param format defines the format of the data
  31097. * @param generateMipMaps defines if the engine should generate the mip levels
  31098. * @param invertY defines if data must be stored with Y axis inverted
  31099. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31100. * @param compression defines the compression used (null by default)
  31101. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  31102. * @returns the raw texture inside an InternalTexture
  31103. */
  31104. Engine.prototype.createRawTexture = function (data, width, height, format, generateMipMaps, invertY, samplingMode, compression, type) {
  31105. if (compression === void 0) { compression = null; }
  31106. if (type === void 0) { type = Engine.TEXTURETYPE_UNSIGNED_INT; }
  31107. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW);
  31108. texture.baseWidth = width;
  31109. texture.baseHeight = height;
  31110. texture.width = width;
  31111. texture.height = height;
  31112. texture.format = format;
  31113. texture.generateMipMaps = generateMipMaps;
  31114. texture.samplingMode = samplingMode;
  31115. texture.invertY = invertY;
  31116. texture._compression = compression;
  31117. texture.type = type;
  31118. if (!this._doNotHandleContextLost) {
  31119. texture._bufferView = data;
  31120. }
  31121. this.updateRawTexture(texture, data, format, invertY, compression, type);
  31122. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31123. // Filters
  31124. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31125. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  31126. this._gl.texParameteri(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31127. if (generateMipMaps) {
  31128. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31129. }
  31130. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31131. this._internalTexturesCache.push(texture);
  31132. return texture;
  31133. };
  31134. /** @hidden */
  31135. Engine.prototype._unpackFlipY = function (value) {
  31136. if (this._unpackFlipYCached !== value) {
  31137. this._gl.pixelStorei(this._gl.UNPACK_FLIP_Y_WEBGL, value ? 1 : 0);
  31138. if (this.enableUnpackFlipYCached) {
  31139. this._unpackFlipYCached = value;
  31140. }
  31141. }
  31142. };
  31143. /** @hidden */
  31144. Engine.prototype._getUnpackAlignement = function () {
  31145. return this._gl.getParameter(this._gl.UNPACK_ALIGNMENT);
  31146. };
  31147. /**
  31148. * Creates a dynamic texture
  31149. * @param width defines the width of the texture
  31150. * @param height defines the height of the texture
  31151. * @param generateMipMaps defines if the engine should generate the mip levels
  31152. * @param samplingMode defines the required sampling mode (Texture.NEAREST_SAMPLINGMODE by default)
  31153. * @returns the dynamic texture inside an InternalTexture
  31154. */
  31155. Engine.prototype.createDynamicTexture = function (width, height, generateMipMaps, samplingMode) {
  31156. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DYNAMIC);
  31157. texture.baseWidth = width;
  31158. texture.baseHeight = height;
  31159. if (generateMipMaps) {
  31160. width = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, this._caps.maxTextureSize) : width;
  31161. height = this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, this._caps.maxTextureSize) : height;
  31162. }
  31163. // this.resetTextureCache();
  31164. texture.width = width;
  31165. texture.height = height;
  31166. texture.isReady = false;
  31167. texture.generateMipMaps = generateMipMaps;
  31168. texture.samplingMode = samplingMode;
  31169. this.updateTextureSamplingMode(samplingMode, texture);
  31170. this._internalTexturesCache.push(texture);
  31171. return texture;
  31172. };
  31173. /**
  31174. * Update the sampling mode of a given texture
  31175. * @param samplingMode defines the required sampling mode
  31176. * @param texture defines the texture to update
  31177. */
  31178. Engine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  31179. var filters = this._getSamplingParameters(samplingMode, texture.generateMipMaps);
  31180. if (texture.isCube) {
  31181. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31182. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31183. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31184. }
  31185. else if (texture.is3D) {
  31186. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31187. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31188. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  31189. }
  31190. else {
  31191. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MAG_FILTER, filters.mag, texture);
  31192. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  31193. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31194. }
  31195. texture.samplingMode = samplingMode;
  31196. };
  31197. /**
  31198. * Update the content of a dynamic texture
  31199. * @param texture defines the texture to update
  31200. * @param canvas defines the canvas containing the source
  31201. * @param invertY defines if data must be stored with Y axis inverted
  31202. * @param premulAlpha defines if alpha is stored as premultiplied
  31203. * @param format defines the format of the data
  31204. * @param forceBindTexture if the texture should be forced to be bound eg. after a graphics context loss (Default: false)
  31205. */
  31206. Engine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format, forceBindTexture) {
  31207. if (premulAlpha === void 0) { premulAlpha = false; }
  31208. if (forceBindTexture === void 0) { forceBindTexture = false; }
  31209. if (!texture) {
  31210. return;
  31211. }
  31212. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true, forceBindTexture);
  31213. this._unpackFlipY(invertY);
  31214. if (premulAlpha) {
  31215. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 1);
  31216. }
  31217. var internalFormat = format ? this._getInternalFormat(format) : this._gl.RGBA;
  31218. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, internalFormat, internalFormat, this._gl.UNSIGNED_BYTE, canvas);
  31219. if (texture.generateMipMaps) {
  31220. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31221. }
  31222. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31223. if (premulAlpha) {
  31224. this._gl.pixelStorei(this._gl.UNPACK_PREMULTIPLY_ALPHA_WEBGL, 0);
  31225. }
  31226. texture.isReady = true;
  31227. };
  31228. /**
  31229. * Update a video texture
  31230. * @param texture defines the texture to update
  31231. * @param video defines the video element to use
  31232. * @param invertY defines if data must be stored with Y axis inverted
  31233. */
  31234. Engine.prototype.updateVideoTexture = function (texture, video, invertY) {
  31235. if (!texture || texture._isDisabled) {
  31236. return;
  31237. }
  31238. var wasPreviouslyBound = this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31239. this._unpackFlipY(!invertY); // Video are upside down by default
  31240. try {
  31241. // Testing video texture support
  31242. if (this._videoTextureSupported === undefined) {
  31243. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31244. if (this._gl.getError() !== 0) {
  31245. this._videoTextureSupported = false;
  31246. }
  31247. else {
  31248. this._videoTextureSupported = true;
  31249. }
  31250. }
  31251. // Copy video through the current working canvas if video texture is not supported
  31252. if (!this._videoTextureSupported) {
  31253. if (!texture._workingCanvas) {
  31254. texture._workingCanvas = document.createElement("canvas");
  31255. var context = texture._workingCanvas.getContext("2d");
  31256. if (!context) {
  31257. throw new Error("Unable to get 2d context");
  31258. }
  31259. texture._workingContext = context;
  31260. texture._workingCanvas.width = texture.width;
  31261. texture._workingCanvas.height = texture.height;
  31262. }
  31263. texture._workingContext.drawImage(video, 0, 0, video.videoWidth, video.videoHeight, 0, 0, texture.width, texture.height);
  31264. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, texture._workingCanvas);
  31265. }
  31266. else {
  31267. this._gl.texImage2D(this._gl.TEXTURE_2D, 0, this._gl.RGBA, this._gl.RGBA, this._gl.UNSIGNED_BYTE, video);
  31268. }
  31269. if (texture.generateMipMaps) {
  31270. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31271. }
  31272. if (!wasPreviouslyBound) {
  31273. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31274. }
  31275. // this.resetTextureCache();
  31276. texture.isReady = true;
  31277. }
  31278. catch (ex) {
  31279. // Something unexpected
  31280. // Let's disable the texture
  31281. texture._isDisabled = true;
  31282. }
  31283. };
  31284. /**
  31285. * Updates a depth texture Comparison Mode and Function.
  31286. * If the comparison Function is equal to 0, the mode will be set to none.
  31287. * Otherwise, this only works in webgl 2 and requires a shadow sampler in the shader.
  31288. * @param texture The texture to set the comparison function for
  31289. * @param comparisonFunction The comparison function to set, 0 if no comparison required
  31290. */
  31291. Engine.prototype.updateTextureComparisonFunction = function (texture, comparisonFunction) {
  31292. if (this.webGLVersion === 1) {
  31293. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("WebGL 1 does not support texture comparison.");
  31294. return;
  31295. }
  31296. var gl = this._gl;
  31297. if (texture.isCube) {
  31298. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  31299. if (comparisonFunction === 0) {
  31300. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31301. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31302. }
  31303. else {
  31304. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31305. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31306. }
  31307. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  31308. }
  31309. else {
  31310. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture, true);
  31311. if (comparisonFunction === 0) {
  31312. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31313. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31314. }
  31315. else {
  31316. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31317. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31318. }
  31319. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  31320. }
  31321. texture._comparisonFunction = comparisonFunction;
  31322. };
  31323. Engine.prototype._setupDepthStencilTexture = function (internalTexture, size, generateStencil, bilinearFiltering, comparisonFunction) {
  31324. var width = size.width || size;
  31325. var height = size.height || size;
  31326. internalTexture.baseWidth = width;
  31327. internalTexture.baseHeight = height;
  31328. internalTexture.width = width;
  31329. internalTexture.height = height;
  31330. internalTexture.isReady = true;
  31331. internalTexture.samples = 1;
  31332. internalTexture.generateMipMaps = false;
  31333. internalTexture._generateDepthBuffer = true;
  31334. internalTexture._generateStencilBuffer = generateStencil;
  31335. internalTexture.samplingMode = bilinearFiltering ? Engine.TEXTURE_BILINEAR_SAMPLINGMODE : Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31336. internalTexture.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31337. internalTexture._comparisonFunction = comparisonFunction;
  31338. var gl = this._gl;
  31339. var target = internalTexture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31340. var samplingParameters = this._getSamplingParameters(internalTexture.samplingMode, false);
  31341. gl.texParameteri(target, gl.TEXTURE_MAG_FILTER, samplingParameters.mag);
  31342. gl.texParameteri(target, gl.TEXTURE_MIN_FILTER, samplingParameters.min);
  31343. gl.texParameteri(target, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31344. gl.texParameteri(target, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31345. if (comparisonFunction === 0) {
  31346. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, Engine.LEQUAL);
  31347. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.NONE);
  31348. }
  31349. else {
  31350. gl.texParameteri(target, gl.TEXTURE_COMPARE_FUNC, comparisonFunction);
  31351. gl.texParameteri(target, gl.TEXTURE_COMPARE_MODE, gl.COMPARE_REF_TO_TEXTURE);
  31352. }
  31353. };
  31354. /**
  31355. * Creates a depth stencil texture.
  31356. * This is only available in WebGL 2 or with the depth texture extension available.
  31357. * @param size The size of face edge in the texture.
  31358. * @param options The options defining the texture.
  31359. * @returns The texture
  31360. */
  31361. Engine.prototype.createDepthStencilTexture = function (size, options) {
  31362. if (options.isCube) {
  31363. var width = size.width || size;
  31364. return this._createDepthStencilCubeTexture(width, options);
  31365. }
  31366. else {
  31367. return this._createDepthStencilTexture(size, options);
  31368. }
  31369. };
  31370. /**
  31371. * Creates a depth stencil texture.
  31372. * This is only available in WebGL 2 or with the depth texture extension available.
  31373. * @param size The size of face edge in the texture.
  31374. * @param options The options defining the texture.
  31375. * @returns The texture
  31376. */
  31377. Engine.prototype._createDepthStencilTexture = function (size, options) {
  31378. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_DEPTHTEXTURE);
  31379. if (!this._caps.depthTextureExtension) {
  31380. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth texture is not supported by your browser or hardware.");
  31381. return internalTexture;
  31382. }
  31383. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31384. var gl = this._gl;
  31385. this._bindTextureDirectly(gl.TEXTURE_2D, internalTexture, true);
  31386. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31387. if (this.webGLVersion > 1) {
  31388. if (internalOptions.generateStencil) {
  31389. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH24_STENCIL8, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31390. }
  31391. else {
  31392. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT24, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31393. }
  31394. }
  31395. else {
  31396. if (internalOptions.generateStencil) {
  31397. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_STENCIL, internalTexture.width, internalTexture.height, 0, gl.DEPTH_STENCIL, gl.UNSIGNED_INT_24_8, null);
  31398. }
  31399. else {
  31400. gl.texImage2D(gl.TEXTURE_2D, 0, gl.DEPTH_COMPONENT, internalTexture.width, internalTexture.height, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31401. }
  31402. }
  31403. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31404. return internalTexture;
  31405. };
  31406. /**
  31407. * Creates a depth stencil cube texture.
  31408. * This is only available in WebGL 2.
  31409. * @param size The size of face edge in the cube texture.
  31410. * @param options The options defining the cube texture.
  31411. * @returns The cube texture
  31412. */
  31413. Engine.prototype._createDepthStencilCubeTexture = function (size, options) {
  31414. var internalTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_UNKNOWN);
  31415. internalTexture.isCube = true;
  31416. if (this.webGLVersion === 1) {
  31417. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Error("Depth cube texture is not supported by WebGL 1.");
  31418. return internalTexture;
  31419. }
  31420. var internalOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ bilinearFiltering: false, comparisonFunction: 0, generateStencil: false }, options);
  31421. var gl = this._gl;
  31422. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, internalTexture, true);
  31423. this._setupDepthStencilTexture(internalTexture, size, internalOptions.generateStencil, internalOptions.bilinearFiltering, internalOptions.comparisonFunction);
  31424. // Create the depth/stencil buffer
  31425. for (var face = 0; face < 6; face++) {
  31426. if (internalOptions.generateStencil) {
  31427. 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);
  31428. }
  31429. else {
  31430. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + face, 0, gl.DEPTH_COMPONENT24, size, size, 0, gl.DEPTH_COMPONENT, gl.UNSIGNED_INT, null);
  31431. }
  31432. }
  31433. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31434. return internalTexture;
  31435. };
  31436. /**
  31437. * Sets the frame buffer Depth / Stencil attachement of the render target to the defined depth stencil texture.
  31438. * @param renderTarget The render target to set the frame buffer for
  31439. */
  31440. Engine.prototype.setFrameBufferDepthStencilTexture = function (renderTarget) {
  31441. // Create the framebuffer
  31442. var internalTexture = renderTarget.getInternalTexture();
  31443. if (!internalTexture || !internalTexture._framebuffer || !renderTarget.depthStencilTexture) {
  31444. return;
  31445. }
  31446. var gl = this._gl;
  31447. var depthStencilTexture = renderTarget.depthStencilTexture;
  31448. this.bindUnboundFramebuffer(internalTexture._framebuffer);
  31449. if (depthStencilTexture.isCube) {
  31450. if (depthStencilTexture._generateStencilBuffer) {
  31451. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31452. }
  31453. else {
  31454. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_CUBE_MAP_POSITIVE_X, depthStencilTexture._webGLTexture, 0);
  31455. }
  31456. }
  31457. else {
  31458. if (depthStencilTexture._generateStencilBuffer) {
  31459. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31460. }
  31461. else {
  31462. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthStencilTexture._webGLTexture, 0);
  31463. }
  31464. }
  31465. this.bindUnboundFramebuffer(null);
  31466. };
  31467. /**
  31468. * Creates a new render target texture
  31469. * @param size defines the size of the texture
  31470. * @param options defines the options used to create the texture
  31471. * @returns a new render target texture stored in an InternalTexture
  31472. */
  31473. Engine.prototype.createRenderTargetTexture = function (size, options) {
  31474. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_17__["RenderTargetCreationOptions"]();
  31475. if (options !== undefined && typeof options === "object") {
  31476. fullOptions.generateMipMaps = options.generateMipMaps;
  31477. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31478. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  31479. fullOptions.type = options.type === undefined ? Engine.TEXTURETYPE_UNSIGNED_INT : options.type;
  31480. fullOptions.samplingMode = options.samplingMode === undefined ? Engine.TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  31481. fullOptions.format = options.format === undefined ? Engine.TEXTUREFORMAT_RGBA : options.format;
  31482. }
  31483. else {
  31484. fullOptions.generateMipMaps = options;
  31485. fullOptions.generateDepthBuffer = true;
  31486. fullOptions.generateStencilBuffer = false;
  31487. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31488. fullOptions.samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31489. fullOptions.format = Engine.TEXTUREFORMAT_RGBA;
  31490. }
  31491. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31492. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31493. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31494. }
  31495. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31496. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31497. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31498. }
  31499. var gl = this._gl;
  31500. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31501. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  31502. var width = size.width || size;
  31503. var height = size.height || size;
  31504. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps ? true : false);
  31505. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31506. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31507. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31508. }
  31509. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31510. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31511. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31512. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31513. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(fullOptions.type, fullOptions.format), width, height, 0, this._getInternalFormat(fullOptions.format), this._getWebGLTextureType(fullOptions.type), null);
  31514. // Create the framebuffer
  31515. var currentFrameBuffer = this._currentFramebuffer;
  31516. var framebuffer = gl.createFramebuffer();
  31517. this.bindUnboundFramebuffer(framebuffer);
  31518. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31519. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer ? true : false, fullOptions.generateDepthBuffer, width, height);
  31520. if (fullOptions.generateMipMaps) {
  31521. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31522. }
  31523. // Unbind
  31524. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31525. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31526. this.bindUnboundFramebuffer(currentFrameBuffer);
  31527. texture._framebuffer = framebuffer;
  31528. texture.baseWidth = width;
  31529. texture.baseHeight = height;
  31530. texture.width = width;
  31531. texture.height = height;
  31532. texture.isReady = true;
  31533. texture.samples = 1;
  31534. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  31535. texture.samplingMode = fullOptions.samplingMode;
  31536. texture.type = fullOptions.type;
  31537. texture.format = fullOptions.format;
  31538. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31539. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  31540. // this.resetTextureCache();
  31541. this._internalTexturesCache.push(texture);
  31542. return texture;
  31543. };
  31544. /**
  31545. * Create a multi render target texture
  31546. * @see http://doc.babylonjs.com/features/webgl2#multiple-render-target
  31547. * @param size defines the size of the texture
  31548. * @param options defines the creation options
  31549. * @returns the cube texture as an InternalTexture
  31550. */
  31551. Engine.prototype.createMultipleRenderTarget = function (size, options) {
  31552. var generateMipMaps = false;
  31553. var generateDepthBuffer = true;
  31554. var generateStencilBuffer = false;
  31555. var generateDepthTexture = false;
  31556. var textureCount = 1;
  31557. var defaultType = Engine.TEXTURETYPE_UNSIGNED_INT;
  31558. var defaultSamplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE;
  31559. var types = new Array();
  31560. var samplingModes = new Array();
  31561. if (options !== undefined) {
  31562. generateMipMaps = options.generateMipMaps === undefined ? false : options.generateMipMaps;
  31563. generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  31564. generateStencilBuffer = options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  31565. generateDepthTexture = options.generateDepthTexture === undefined ? false : options.generateDepthTexture;
  31566. textureCount = options.textureCount || 1;
  31567. if (options.types) {
  31568. types = options.types;
  31569. }
  31570. if (options.samplingModes) {
  31571. samplingModes = options.samplingModes;
  31572. }
  31573. }
  31574. var gl = this._gl;
  31575. // Create the framebuffer
  31576. var framebuffer = gl.createFramebuffer();
  31577. this.bindUnboundFramebuffer(framebuffer);
  31578. var width = size.width || size;
  31579. var height = size.height || size;
  31580. var textures = [];
  31581. var attachments = [];
  31582. var depthStencilBuffer = this._setupFramebufferDepthAttachments(generateStencilBuffer, generateDepthBuffer, width, height);
  31583. for (var i = 0; i < textureCount; i++) {
  31584. var samplingMode = samplingModes[i] || defaultSamplingMode;
  31585. var type = types[i] || defaultType;
  31586. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31587. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31588. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31589. }
  31590. else if (type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31591. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31592. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31593. }
  31594. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  31595. if (type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31596. type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31597. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Render target forced to TEXTURETYPE_UNSIGNED_BYTE type");
  31598. }
  31599. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31600. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31601. textures.push(texture);
  31602. attachments.push(attachment);
  31603. gl.activeTexture(gl["TEXTURE" + i]);
  31604. gl.bindTexture(gl.TEXTURE_2D, texture._webGLTexture);
  31605. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  31606. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  31607. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31608. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31609. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), width, height, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  31610. gl.framebufferTexture2D(gl.DRAW_FRAMEBUFFER, attachment, gl.TEXTURE_2D, texture._webGLTexture, 0);
  31611. if (generateMipMaps) {
  31612. this._gl.generateMipmap(this._gl.TEXTURE_2D);
  31613. }
  31614. // Unbind
  31615. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  31616. texture._framebuffer = framebuffer;
  31617. texture._depthStencilBuffer = depthStencilBuffer;
  31618. texture.baseWidth = width;
  31619. texture.baseHeight = height;
  31620. texture.width = width;
  31621. texture.height = height;
  31622. texture.isReady = true;
  31623. texture.samples = 1;
  31624. texture.generateMipMaps = generateMipMaps;
  31625. texture.samplingMode = samplingMode;
  31626. texture.type = type;
  31627. texture._generateDepthBuffer = generateDepthBuffer;
  31628. texture._generateStencilBuffer = generateStencilBuffer;
  31629. texture._attachments = attachments;
  31630. this._internalTexturesCache.push(texture);
  31631. }
  31632. if (generateDepthTexture && this._caps.depthTextureExtension) {
  31633. // Depth texture
  31634. var depthTexture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_MULTIRENDERTARGET);
  31635. gl.activeTexture(gl.TEXTURE0);
  31636. gl.bindTexture(gl.TEXTURE_2D, depthTexture._webGLTexture);
  31637. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  31638. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  31639. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31640. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31641. 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);
  31642. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.TEXTURE_2D, depthTexture._webGLTexture, 0);
  31643. depthTexture._framebuffer = framebuffer;
  31644. depthTexture.baseWidth = width;
  31645. depthTexture.baseHeight = height;
  31646. depthTexture.width = width;
  31647. depthTexture.height = height;
  31648. depthTexture.isReady = true;
  31649. depthTexture.samples = 1;
  31650. depthTexture.generateMipMaps = generateMipMaps;
  31651. depthTexture.samplingMode = gl.NEAREST;
  31652. depthTexture._generateDepthBuffer = generateDepthBuffer;
  31653. depthTexture._generateStencilBuffer = generateStencilBuffer;
  31654. textures.push(depthTexture);
  31655. this._internalTexturesCache.push(depthTexture);
  31656. }
  31657. gl.drawBuffers(attachments);
  31658. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31659. this.bindUnboundFramebuffer(null);
  31660. this.resetTextureCache();
  31661. return textures;
  31662. };
  31663. Engine.prototype._setupFramebufferDepthAttachments = function (generateStencilBuffer, generateDepthBuffer, width, height, samples) {
  31664. if (samples === void 0) { samples = 1; }
  31665. var depthStencilBuffer = null;
  31666. var gl = this._gl;
  31667. // Create the depth/stencil buffer
  31668. if (generateStencilBuffer) {
  31669. depthStencilBuffer = gl.createRenderbuffer();
  31670. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31671. if (samples > 1) {
  31672. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH24_STENCIL8, width, height);
  31673. }
  31674. else {
  31675. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_STENCIL, width, height);
  31676. }
  31677. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_STENCIL_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31678. }
  31679. else if (generateDepthBuffer) {
  31680. depthStencilBuffer = gl.createRenderbuffer();
  31681. gl.bindRenderbuffer(gl.RENDERBUFFER, depthStencilBuffer);
  31682. if (samples > 1) {
  31683. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, gl.DEPTH_COMPONENT16, width, height);
  31684. }
  31685. else {
  31686. gl.renderbufferStorage(gl.RENDERBUFFER, gl.DEPTH_COMPONENT16, width, height);
  31687. }
  31688. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.DEPTH_ATTACHMENT, gl.RENDERBUFFER, depthStencilBuffer);
  31689. }
  31690. return depthStencilBuffer;
  31691. };
  31692. /**
  31693. * Updates the sample count of a render target texture
  31694. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31695. * @param texture defines the texture to update
  31696. * @param samples defines the sample count to set
  31697. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31698. */
  31699. Engine.prototype.updateRenderTargetTextureSampleCount = function (texture, samples) {
  31700. if (this.webGLVersion < 2 || !texture) {
  31701. return 1;
  31702. }
  31703. if (texture.samples === samples) {
  31704. return samples;
  31705. }
  31706. var gl = this._gl;
  31707. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31708. // Dispose previous render buffers
  31709. if (texture._depthStencilBuffer) {
  31710. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  31711. texture._depthStencilBuffer = null;
  31712. }
  31713. if (texture._MSAAFramebuffer) {
  31714. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  31715. texture._MSAAFramebuffer = null;
  31716. }
  31717. if (texture._MSAARenderBuffer) {
  31718. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  31719. texture._MSAARenderBuffer = null;
  31720. }
  31721. if (samples > 1) {
  31722. var framebuffer = gl.createFramebuffer();
  31723. if (!framebuffer) {
  31724. throw new Error("Unable to create multi sampled framebuffer");
  31725. }
  31726. texture._MSAAFramebuffer = framebuffer;
  31727. this.bindUnboundFramebuffer(texture._MSAAFramebuffer);
  31728. var colorRenderbuffer = gl.createRenderbuffer();
  31729. if (!colorRenderbuffer) {
  31730. throw new Error("Unable to create multi sampled framebuffer");
  31731. }
  31732. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31733. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31734. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.RENDERBUFFER, colorRenderbuffer);
  31735. texture._MSAARenderBuffer = colorRenderbuffer;
  31736. }
  31737. else {
  31738. this.bindUnboundFramebuffer(texture._framebuffer);
  31739. }
  31740. texture.samples = samples;
  31741. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(texture._generateStencilBuffer, texture._generateDepthBuffer, texture.width, texture.height, samples);
  31742. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31743. this.bindUnboundFramebuffer(null);
  31744. return samples;
  31745. };
  31746. /**
  31747. * Update the sample count for a given multiple render target texture
  31748. * @see http://doc.babylonjs.com/features/webgl2#multisample-render-targets
  31749. * @param textures defines the textures to update
  31750. * @param samples defines the sample count to set
  31751. * @returns the effective sample count (could be 0 if multisample render targets are not supported)
  31752. */
  31753. Engine.prototype.updateMultipleRenderTargetTextureSampleCount = function (textures, samples) {
  31754. if (this.webGLVersion < 2 || !textures || textures.length == 0) {
  31755. return 1;
  31756. }
  31757. if (textures[0].samples === samples) {
  31758. return samples;
  31759. }
  31760. var gl = this._gl;
  31761. samples = Math.min(samples, gl.getParameter(gl.MAX_SAMPLES));
  31762. // Dispose previous render buffers
  31763. if (textures[0]._depthStencilBuffer) {
  31764. gl.deleteRenderbuffer(textures[0]._depthStencilBuffer);
  31765. textures[0]._depthStencilBuffer = null;
  31766. }
  31767. if (textures[0]._MSAAFramebuffer) {
  31768. gl.deleteFramebuffer(textures[0]._MSAAFramebuffer);
  31769. textures[0]._MSAAFramebuffer = null;
  31770. }
  31771. for (var i = 0; i < textures.length; i++) {
  31772. if (textures[i]._MSAARenderBuffer) {
  31773. gl.deleteRenderbuffer(textures[i]._MSAARenderBuffer);
  31774. textures[i]._MSAARenderBuffer = null;
  31775. }
  31776. }
  31777. if (samples > 1) {
  31778. var framebuffer = gl.createFramebuffer();
  31779. if (!framebuffer) {
  31780. throw new Error("Unable to create multi sampled framebuffer");
  31781. }
  31782. this.bindUnboundFramebuffer(framebuffer);
  31783. var depthStencilBuffer = this._setupFramebufferDepthAttachments(textures[0]._generateStencilBuffer, textures[0]._generateDepthBuffer, textures[0].width, textures[0].height, samples);
  31784. var attachments = [];
  31785. for (var i = 0; i < textures.length; i++) {
  31786. var texture = textures[i];
  31787. var attachment = gl[this.webGLVersion > 1 ? "COLOR_ATTACHMENT" + i : "COLOR_ATTACHMENT" + i + "_WEBGL"];
  31788. var colorRenderbuffer = gl.createRenderbuffer();
  31789. if (!colorRenderbuffer) {
  31790. throw new Error("Unable to create multi sampled framebuffer");
  31791. }
  31792. gl.bindRenderbuffer(gl.RENDERBUFFER, colorRenderbuffer);
  31793. gl.renderbufferStorageMultisample(gl.RENDERBUFFER, samples, this._getRGBAMultiSampleBufferFormat(texture.type), texture.width, texture.height);
  31794. gl.framebufferRenderbuffer(gl.FRAMEBUFFER, attachment, gl.RENDERBUFFER, colorRenderbuffer);
  31795. texture._MSAAFramebuffer = framebuffer;
  31796. texture._MSAARenderBuffer = colorRenderbuffer;
  31797. texture.samples = samples;
  31798. texture._depthStencilBuffer = depthStencilBuffer;
  31799. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31800. attachments.push(attachment);
  31801. }
  31802. gl.drawBuffers(attachments);
  31803. }
  31804. else {
  31805. this.bindUnboundFramebuffer(textures[0]._framebuffer);
  31806. }
  31807. this.bindUnboundFramebuffer(null);
  31808. return samples;
  31809. };
  31810. /** @hidden */
  31811. Engine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  31812. if (faceIndex === void 0) { faceIndex = 0; }
  31813. if (lod === void 0) { lod = 0; }
  31814. var gl = this._gl;
  31815. var target = gl.TEXTURE_2D;
  31816. if (texture.isCube) {
  31817. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31818. }
  31819. this._gl.compressedTexImage2D(target, lod, internalFormat, width, height, 0, data);
  31820. };
  31821. /** @hidden */
  31822. Engine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  31823. if (faceIndex === void 0) { faceIndex = 0; }
  31824. if (lod === void 0) { lod = 0; }
  31825. var gl = this._gl;
  31826. var textureType = this._getWebGLTextureType(texture.type);
  31827. var format = this._getInternalFormat(texture.format);
  31828. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31829. this._unpackFlipY(texture.invertY);
  31830. var target = gl.TEXTURE_2D;
  31831. if (texture.isCube) {
  31832. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31833. }
  31834. var lodMaxWidth = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.width));
  31835. var lodMaxHeight = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_7__["Scalar"].Log2(texture.height));
  31836. var width = Math.pow(2, Math.max(lodMaxWidth - lod, 0));
  31837. var height = Math.pow(2, Math.max(lodMaxHeight - lod, 0));
  31838. gl.texImage2D(target, lod, internalFormat, width, height, 0, format, textureType, imageData);
  31839. };
  31840. /** @hidden */
  31841. Engine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  31842. if (faceIndex === void 0) { faceIndex = 0; }
  31843. if (lod === void 0) { lod = 0; }
  31844. var gl = this._gl;
  31845. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31846. this._bindTextureDirectly(bindTarget, texture, true);
  31847. this._uploadDataToTextureDirectly(texture, imageData, faceIndex, lod);
  31848. this._bindTextureDirectly(bindTarget, null, true);
  31849. };
  31850. /** @hidden */
  31851. Engine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  31852. if (faceIndex === void 0) { faceIndex = 0; }
  31853. if (lod === void 0) { lod = 0; }
  31854. var gl = this._gl;
  31855. var textureType = this._getWebGLTextureType(texture.type);
  31856. var format = this._getInternalFormat(texture.format);
  31857. var internalFormat = this._getRGBABufferInternalSizedFormat(texture.type, format);
  31858. var bindTarget = texture.isCube ? gl.TEXTURE_CUBE_MAP : gl.TEXTURE_2D;
  31859. this._bindTextureDirectly(bindTarget, texture, true);
  31860. this._unpackFlipY(texture.invertY);
  31861. var target = gl.TEXTURE_2D;
  31862. if (texture.isCube) {
  31863. target = gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex;
  31864. }
  31865. gl.texImage2D(target, lod, internalFormat, format, textureType, image);
  31866. this._bindTextureDirectly(bindTarget, null, true);
  31867. };
  31868. /**
  31869. * Creates a new render target cube texture
  31870. * @param size defines the size of the texture
  31871. * @param options defines the options used to create the texture
  31872. * @returns a new render target cube texture stored in an InternalTexture
  31873. */
  31874. Engine.prototype.createRenderTargetCubeTexture = function (size, options) {
  31875. 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);
  31876. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && fullOptions.generateStencilBuffer;
  31877. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloatLinearFiltering) {
  31878. // if floating point linear (gl.FLOAT) then force to NEAREST_SAMPLINGMODE
  31879. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31880. }
  31881. else if (fullOptions.type === Engine.TEXTURETYPE_HALF_FLOAT && !this._caps.textureHalfFloatLinearFiltering) {
  31882. // if floating point linear (HALF_FLOAT) then force to NEAREST_SAMPLINGMODE
  31883. fullOptions.samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  31884. }
  31885. var gl = this._gl;
  31886. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RENDERTARGET);
  31887. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31888. var filters = this._getSamplingParameters(fullOptions.samplingMode, fullOptions.generateMipMaps);
  31889. if (fullOptions.type === Engine.TEXTURETYPE_FLOAT && !this._caps.textureFloat) {
  31890. fullOptions.type = Engine.TEXTURETYPE_UNSIGNED_INT;
  31891. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float textures are not supported. Cube render target forced to TEXTURETYPE_UNESIGNED_BYTE type");
  31892. }
  31893. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  31894. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  31895. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  31896. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  31897. for (var face = 0; face < 6; face++) {
  31898. 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);
  31899. }
  31900. // Create the framebuffer
  31901. var framebuffer = gl.createFramebuffer();
  31902. this.bindUnboundFramebuffer(framebuffer);
  31903. texture._depthStencilBuffer = this._setupFramebufferDepthAttachments(fullOptions.generateStencilBuffer, fullOptions.generateDepthBuffer, size, size);
  31904. // MipMaps
  31905. if (fullOptions.generateMipMaps) {
  31906. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  31907. }
  31908. // Unbind
  31909. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  31910. gl.bindRenderbuffer(gl.RENDERBUFFER, null);
  31911. this.bindUnboundFramebuffer(null);
  31912. texture._framebuffer = framebuffer;
  31913. texture.width = size;
  31914. texture.height = size;
  31915. texture.isReady = true;
  31916. texture.isCube = true;
  31917. texture.samples = 1;
  31918. texture.generateMipMaps = fullOptions.generateMipMaps;
  31919. texture.samplingMode = fullOptions.samplingMode;
  31920. texture.type = fullOptions.type;
  31921. texture.format = fullOptions.format;
  31922. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  31923. texture._generateStencilBuffer = fullOptions.generateStencilBuffer;
  31924. this._internalTexturesCache.push(texture);
  31925. return texture;
  31926. };
  31927. /**
  31928. * Creates a cube texture
  31929. * @param rootUrl defines the url where the files to load is located
  31930. * @param scene defines the current scene
  31931. * @param files defines the list of files to load (1 per face)
  31932. * @param noMipmap defines a boolean indicating that no mipmaps shall be generated (false by default)
  31933. * @param onLoad defines an optional callback raised when the texture is loaded
  31934. * @param onError defines an optional callback raised if there is an issue to load the texture
  31935. * @param format defines the format of the data
  31936. * @param forcedExtension defines the extension to use to pick the right loader
  31937. * @param createPolynomials if a polynomial sphere should be created for the cube texture
  31938. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  31939. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  31940. * @param fallback defines texture to use while falling back when (compressed) texture file not found.
  31941. * @param excludeLoaders array of texture loaders that should be excluded when picking a loader for the texture (defualt: empty array)
  31942. * @returns the cube texture as an InternalTexture
  31943. */
  31944. Engine.prototype.createCubeTexture = function (rootUrl, scene, files, noMipmap, onLoad, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset, fallback, excludeLoaders) {
  31945. var _this = this;
  31946. if (onLoad === void 0) { onLoad = null; }
  31947. if (onError === void 0) { onError = null; }
  31948. if (forcedExtension === void 0) { forcedExtension = null; }
  31949. if (createPolynomials === void 0) { createPolynomials = false; }
  31950. if (lodScale === void 0) { lodScale = 0; }
  31951. if (lodOffset === void 0) { lodOffset = 0; }
  31952. if (fallback === void 0) { fallback = null; }
  31953. if (excludeLoaders === void 0) { excludeLoaders = []; }
  31954. var gl = this._gl;
  31955. var texture = fallback ? fallback : new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBE);
  31956. texture.isCube = true;
  31957. texture.url = rootUrl;
  31958. texture.generateMipMaps = !noMipmap;
  31959. texture._lodGenerationScale = lodScale;
  31960. texture._lodGenerationOffset = lodOffset;
  31961. if (!this._doNotHandleContextLost) {
  31962. texture._extension = forcedExtension;
  31963. texture._files = files;
  31964. }
  31965. var lastDot = rootUrl.lastIndexOf('.');
  31966. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  31967. var loader = null;
  31968. for (var _i = 0, _a = Engine._TextureLoaders; _i < _a.length; _i++) {
  31969. var availableLoader = _a[_i];
  31970. if (excludeLoaders.indexOf(availableLoader) === -1 && availableLoader.canLoad(extension, this._textureFormatInUse, fallback, false, false)) {
  31971. loader = availableLoader;
  31972. break;
  31973. }
  31974. }
  31975. var onInternalError = function (request, exception) {
  31976. if (loader) {
  31977. var fallbackUrl = loader.getFallbackTextureUrl(texture.url, _this._textureFormatInUse);
  31978. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn(loader.constructor.name + " failed when trying to load " + texture.url + ", falling back to the next supported loader");
  31979. if (fallbackUrl) {
  31980. excludeLoaders.push(loader);
  31981. _this.createCubeTexture(fallbackUrl, scene, files, noMipmap, onLoad, onError, format, extension, createPolynomials, lodScale, lodOffset, texture, excludeLoaders);
  31982. return;
  31983. }
  31984. }
  31985. if (onError && request) {
  31986. onError(request.status + " " + request.statusText, exception);
  31987. }
  31988. };
  31989. if (loader) {
  31990. rootUrl = loader.transformUrl(rootUrl, this._textureFormatInUse);
  31991. var onloaddata = function (data) {
  31992. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  31993. loader.loadCubeData(data, texture, createPolynomials, onLoad, onError);
  31994. };
  31995. if (files && files.length === 6) {
  31996. if (loader.supportCascades) {
  31997. this._cascadeLoadFiles(scene, onloaddata, files, onError);
  31998. }
  31999. else if (onError) {
  32000. onError("Textures type does not support cascades.");
  32001. }
  32002. }
  32003. else {
  32004. this._loadFile(rootUrl, onloaddata, undefined, undefined, true, onInternalError);
  32005. }
  32006. }
  32007. else {
  32008. if (!files) {
  32009. throw new Error("Cannot load cubemap because files were not defined");
  32010. }
  32011. this._cascadeLoadImgs(scene, function (imgs) {
  32012. var width = _this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(imgs[0].width, _this._caps.maxCubemapTextureSize) : imgs[0].width;
  32013. var height = width;
  32014. _this._prepareWorkingCanvas();
  32015. if (!_this._workingCanvas || !_this._workingContext) {
  32016. return;
  32017. }
  32018. _this._workingCanvas.width = width;
  32019. _this._workingCanvas.height = height;
  32020. var faces = [
  32021. gl.TEXTURE_CUBE_MAP_POSITIVE_X, gl.TEXTURE_CUBE_MAP_POSITIVE_Y, gl.TEXTURE_CUBE_MAP_POSITIVE_Z,
  32022. gl.TEXTURE_CUBE_MAP_NEGATIVE_X, gl.TEXTURE_CUBE_MAP_NEGATIVE_Y, gl.TEXTURE_CUBE_MAP_NEGATIVE_Z
  32023. ];
  32024. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32025. _this._unpackFlipY(false);
  32026. var internalFormat = format ? _this._getInternalFormat(format) : _this._gl.RGBA;
  32027. for (var index = 0; index < faces.length; index++) {
  32028. _this._workingContext.drawImage(imgs[index], 0, 0, imgs[index].width, imgs[index].height, 0, 0, width, height);
  32029. gl.texImage2D(faces[index], 0, internalFormat, internalFormat, gl.UNSIGNED_BYTE, _this._workingCanvas);
  32030. }
  32031. if (!noMipmap) {
  32032. gl.generateMipmap(gl.TEXTURE_CUBE_MAP);
  32033. }
  32034. _this._setCubeMapTextureParams(!noMipmap);
  32035. texture.width = width;
  32036. texture.height = height;
  32037. texture.isReady = true;
  32038. if (format) {
  32039. texture.format = format;
  32040. }
  32041. texture.onLoadedObservable.notifyObservers(texture);
  32042. texture.onLoadedObservable.clear();
  32043. if (onLoad) {
  32044. onLoad();
  32045. }
  32046. }, files, onError);
  32047. }
  32048. this._internalTexturesCache.push(texture);
  32049. return texture;
  32050. };
  32051. /**
  32052. * @hidden
  32053. */
  32054. Engine.prototype._setCubeMapTextureParams = function (loadMipmap) {
  32055. var gl = this._gl;
  32056. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  32057. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, loadMipmap ? gl.LINEAR_MIPMAP_LINEAR : gl.LINEAR);
  32058. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32059. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32060. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32061. // this.resetTextureCache();
  32062. };
  32063. /**
  32064. * Update a raw cube texture
  32065. * @param texture defines the texture to udpdate
  32066. * @param data defines the data to store
  32067. * @param format defines the data format
  32068. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  32069. * @param invertY defines if data must be stored with Y axis inverted
  32070. * @param compression defines the compression used (null by default)
  32071. * @param level defines which level of the texture to update
  32072. */
  32073. Engine.prototype.updateRawCubeTexture = function (texture, data, format, type, invertY, compression, level) {
  32074. if (compression === void 0) { compression = null; }
  32075. if (level === void 0) { level = 0; }
  32076. texture._bufferViewArray = data;
  32077. texture.format = format;
  32078. texture.type = type;
  32079. texture.invertY = invertY;
  32080. texture._compression = compression;
  32081. var gl = this._gl;
  32082. var textureType = this._getWebGLTextureType(type);
  32083. var internalFormat = this._getInternalFormat(format);
  32084. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(type);
  32085. var needConversion = false;
  32086. if (internalFormat === gl.RGB) {
  32087. internalFormat = gl.RGBA;
  32088. needConversion = true;
  32089. }
  32090. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32091. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32092. if (texture.width % 4 !== 0) {
  32093. gl.pixelStorei(gl.UNPACK_ALIGNMENT, 1);
  32094. }
  32095. // Data are known to be in +X +Y +Z -X -Y -Z
  32096. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32097. var faceData = data[faceIndex];
  32098. if (compression) {
  32099. gl.compressedTexImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, (this.getCaps().s3tc)[compression], texture.width, texture.height, 0, faceData);
  32100. }
  32101. else {
  32102. if (needConversion) {
  32103. faceData = this._convertRGBtoRGBATextureData(faceData, texture.width, texture.height, type);
  32104. }
  32105. gl.texImage2D(gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, level, internalSizedFomat, texture.width, texture.height, 0, internalFormat, textureType, faceData);
  32106. }
  32107. }
  32108. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32109. if (isPot && texture.generateMipMaps && level === 0) {
  32110. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32111. }
  32112. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32113. // this.resetTextureCache();
  32114. texture.isReady = true;
  32115. };
  32116. /**
  32117. * Creates a new raw cube texture
  32118. * @param data defines the array of data to use to create each face
  32119. * @param size defines the size of the textures
  32120. * @param format defines the format of the data
  32121. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32122. * @param generateMipMaps defines if the engine should generate the mip levels
  32123. * @param invertY defines if data must be stored with Y axis inverted
  32124. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32125. * @param compression defines the compression used (null by default)
  32126. * @returns the cube texture as an InternalTexture
  32127. */
  32128. Engine.prototype.createRawCubeTexture = function (data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  32129. if (compression === void 0) { compression = null; }
  32130. var gl = this._gl;
  32131. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_CUBERAW);
  32132. texture.isCube = true;
  32133. texture.format = format;
  32134. texture.type = type;
  32135. if (!this._doNotHandleContextLost) {
  32136. texture._bufferViewArray = data;
  32137. }
  32138. var textureType = this._getWebGLTextureType(type);
  32139. var internalFormat = this._getInternalFormat(format);
  32140. if (internalFormat === gl.RGB) {
  32141. internalFormat = gl.RGBA;
  32142. }
  32143. // Mipmap generation needs a sized internal format that is both color-renderable and texture-filterable
  32144. if (textureType === gl.FLOAT && !this._caps.textureFloatLinearFiltering) {
  32145. generateMipMaps = false;
  32146. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32147. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  32148. }
  32149. else if (textureType === this._gl.HALF_FLOAT_OES && !this._caps.textureHalfFloatLinearFiltering) {
  32150. generateMipMaps = false;
  32151. samplingMode = Engine.TEXTURE_NEAREST_SAMPLINGMODE;
  32152. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Half float texture filtering is not supported. Mipmap generation and sampling mode are forced to false and TEXTURE_NEAREST_SAMPLINGMODE, respectively.");
  32153. }
  32154. else if (textureType === gl.FLOAT && !this._caps.textureFloatRender) {
  32155. generateMipMaps = false;
  32156. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to float textures is not supported. Mipmap generation forced to false.");
  32157. }
  32158. else if (textureType === gl.HALF_FLOAT && !this._caps.colorBufferFloat) {
  32159. generateMipMaps = false;
  32160. _Misc_logger__WEBPACK_IMPORTED_MODULE_15__["Logger"].Warn("Render to half float textures is not supported. Mipmap generation forced to false.");
  32161. }
  32162. var width = size;
  32163. var height = width;
  32164. texture.width = width;
  32165. texture.height = height;
  32166. // Double check on POT to generate Mips.
  32167. var isPot = !this.needPOTTextures || (_Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.width) && _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].IsExponentOfTwo(texture.height));
  32168. if (!isPot) {
  32169. generateMipMaps = false;
  32170. }
  32171. // Upload data if needed. The texture won't be ready until then.
  32172. if (data) {
  32173. this.updateRawCubeTexture(texture, data, format, type, invertY, compression);
  32174. }
  32175. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, texture, true);
  32176. // Filters
  32177. if (data && generateMipMaps) {
  32178. this._gl.generateMipmap(this._gl.TEXTURE_CUBE_MAP);
  32179. }
  32180. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32181. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, filters.mag);
  32182. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, filters.min);
  32183. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  32184. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  32185. this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32186. texture.generateMipMaps = generateMipMaps;
  32187. return texture;
  32188. };
  32189. /**
  32190. * Creates a new raw cube texture from a specified url
  32191. * @param url defines the url where the data is located
  32192. * @param scene defines the current scene
  32193. * @param size defines the size of the textures
  32194. * @param format defines the format of the data
  32195. * @param type defines the type fo the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  32196. * @param noMipmap defines if the engine should avoid generating the mip levels
  32197. * @param callback defines a callback used to extract texture data from loaded data
  32198. * @param mipmapGenerator defines to provide an optional tool to generate mip levels
  32199. * @param onLoad defines a callback called when texture is loaded
  32200. * @param onError defines a callback called if there is an error
  32201. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32202. * @param invertY defines if data must be stored with Y axis inverted
  32203. * @returns the cube texture as an InternalTexture
  32204. */
  32205. Engine.prototype.createRawCubeTextureFromUrl = function (url, scene, size, format, type, noMipmap, callback, mipmapGenerator, onLoad, onError, samplingMode, invertY) {
  32206. var _this = this;
  32207. if (onLoad === void 0) { onLoad = null; }
  32208. if (onError === void 0) { onError = null; }
  32209. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32210. if (invertY === void 0) { invertY = false; }
  32211. var gl = this._gl;
  32212. var texture = this.createRawCubeTexture(null, size, format, type, !noMipmap, invertY, samplingMode);
  32213. scene._addPendingData(texture);
  32214. texture.url = url;
  32215. this._internalTexturesCache.push(texture);
  32216. var onerror = function (request, exception) {
  32217. scene._removePendingData(texture);
  32218. if (onError && request) {
  32219. onError(request.status + " " + request.statusText, exception);
  32220. }
  32221. };
  32222. var internalCallback = function (data) {
  32223. var width = texture.width;
  32224. var faceDataArrays = callback(data);
  32225. if (!faceDataArrays) {
  32226. return;
  32227. }
  32228. if (mipmapGenerator) {
  32229. var textureType = _this._getWebGLTextureType(type);
  32230. var internalFormat = _this._getInternalFormat(format);
  32231. var internalSizedFomat = _this._getRGBABufferInternalSizedFormat(type);
  32232. var needConversion = false;
  32233. if (internalFormat === gl.RGB) {
  32234. internalFormat = gl.RGBA;
  32235. needConversion = true;
  32236. }
  32237. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, texture, true);
  32238. _this._unpackFlipY(false);
  32239. var mipData = mipmapGenerator(faceDataArrays);
  32240. for (var level = 0; level < mipData.length; level++) {
  32241. var mipSize = width >> level;
  32242. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  32243. var mipFaceData = mipData[level][faceIndex];
  32244. if (needConversion) {
  32245. mipFaceData = _this._convertRGBtoRGBATextureData(mipFaceData, mipSize, mipSize, type);
  32246. }
  32247. gl.texImage2D(faceIndex, level, internalSizedFomat, mipSize, mipSize, 0, internalFormat, textureType, mipFaceData);
  32248. }
  32249. }
  32250. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  32251. }
  32252. else {
  32253. _this.updateRawCubeTexture(texture, faceDataArrays, format, type, invertY);
  32254. }
  32255. texture.isReady = true;
  32256. // this.resetTextureCache();
  32257. scene._removePendingData(texture);
  32258. if (onLoad) {
  32259. onLoad();
  32260. }
  32261. };
  32262. this._loadFile(url, function (data) {
  32263. internalCallback(data);
  32264. }, undefined, scene.offlineProvider, true, onerror);
  32265. return texture;
  32266. };
  32267. /**
  32268. * Update a raw 3D texture
  32269. * @param texture defines the texture to update
  32270. * @param data defines the data to store
  32271. * @param format defines the data format
  32272. * @param invertY defines if data must be stored with Y axis inverted
  32273. * @param compression defines the used compression (can be null)
  32274. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  32275. */
  32276. Engine.prototype.updateRawTexture3D = function (texture, data, format, invertY, compression, textureType) {
  32277. if (compression === void 0) { compression = null; }
  32278. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32279. var internalType = this._getWebGLTextureType(textureType);
  32280. var internalFormat = this._getInternalFormat(format);
  32281. var internalSizedFomat = this._getRGBABufferInternalSizedFormat(textureType, format);
  32282. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32283. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32284. if (!this._doNotHandleContextLost) {
  32285. texture._bufferView = data;
  32286. texture.format = format;
  32287. texture.invertY = invertY;
  32288. texture._compression = compression;
  32289. }
  32290. if (texture.width % 4 !== 0) {
  32291. this._gl.pixelStorei(this._gl.UNPACK_ALIGNMENT, 1);
  32292. }
  32293. if (compression && data) {
  32294. this._gl.compressedTexImage3D(this._gl.TEXTURE_3D, 0, this.getCaps().s3tc[compression], texture.width, texture.height, texture.depth, 0, data);
  32295. }
  32296. else {
  32297. this._gl.texImage3D(this._gl.TEXTURE_3D, 0, internalSizedFomat, texture.width, texture.height, texture.depth, 0, internalFormat, internalType, data);
  32298. }
  32299. if (texture.generateMipMaps) {
  32300. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32301. }
  32302. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32303. // this.resetTextureCache();
  32304. texture.isReady = true;
  32305. };
  32306. /**
  32307. * Creates a new raw 3D texture
  32308. * @param data defines the data used to create the texture
  32309. * @param width defines the width of the texture
  32310. * @param height defines the height of the texture
  32311. * @param depth defines the depth of the texture
  32312. * @param format defines the format of the texture
  32313. * @param generateMipMaps defines if the engine must generate mip levels
  32314. * @param invertY defines if data must be stored with Y axis inverted
  32315. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  32316. * @param compression defines the compressed used (can be null)
  32317. * @param textureType defines the compressed used (can be null)
  32318. * @returns a new raw 3D texture (stored in an InternalTexture)
  32319. */
  32320. Engine.prototype.createRawTexture3D = function (data, width, height, depth, format, generateMipMaps, invertY, samplingMode, compression, textureType) {
  32321. if (compression === void 0) { compression = null; }
  32322. if (textureType === void 0) { textureType = Engine.TEXTURETYPE_UNSIGNED_INT; }
  32323. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_11__["InternalTexture"].DATASOURCE_RAW3D);
  32324. texture.baseWidth = width;
  32325. texture.baseHeight = height;
  32326. texture.baseDepth = depth;
  32327. texture.width = width;
  32328. texture.height = height;
  32329. texture.depth = depth;
  32330. texture.format = format;
  32331. texture.type = textureType;
  32332. texture.generateMipMaps = generateMipMaps;
  32333. texture.samplingMode = samplingMode;
  32334. texture.is3D = true;
  32335. if (!this._doNotHandleContextLost) {
  32336. texture._bufferView = data;
  32337. }
  32338. this.updateRawTexture3D(texture, data, format, invertY, compression, textureType);
  32339. this._bindTextureDirectly(this._gl.TEXTURE_3D, texture, true);
  32340. // Filters
  32341. var filters = this._getSamplingParameters(samplingMode, generateMipMaps);
  32342. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MAG_FILTER, filters.mag);
  32343. this._gl.texParameteri(this._gl.TEXTURE_3D, this._gl.TEXTURE_MIN_FILTER, filters.min);
  32344. if (generateMipMaps) {
  32345. this._gl.generateMipmap(this._gl.TEXTURE_3D);
  32346. }
  32347. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32348. this._internalTexturesCache.push(texture);
  32349. return texture;
  32350. };
  32351. Engine.prototype._prepareWebGLTextureContinuation = function (texture, scene, noMipmap, isCompressed, samplingMode) {
  32352. var gl = this._gl;
  32353. if (!gl) {
  32354. return;
  32355. }
  32356. var filters = this._getSamplingParameters(samplingMode, !noMipmap);
  32357. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, filters.mag);
  32358. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, filters.min);
  32359. if (!noMipmap && !isCompressed) {
  32360. gl.generateMipmap(gl.TEXTURE_2D);
  32361. }
  32362. this._bindTextureDirectly(gl.TEXTURE_2D, null);
  32363. // this.resetTextureCache();
  32364. if (scene) {
  32365. scene._removePendingData(texture);
  32366. }
  32367. texture.onLoadedObservable.notifyObservers(texture);
  32368. texture.onLoadedObservable.clear();
  32369. };
  32370. Engine.prototype._prepareWebGLTexture = function (texture, scene, width, height, invertY, noMipmap, isCompressed, processFunction, samplingMode) {
  32371. var _this = this;
  32372. if (samplingMode === void 0) { samplingMode = Engine.TEXTURE_TRILINEAR_SAMPLINGMODE; }
  32373. var maxTextureSize = this.getCaps().maxTextureSize;
  32374. var potWidth = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(width, maxTextureSize) : width);
  32375. var potHeight = Math.min(maxTextureSize, this.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].GetExponentOfTwo(height, maxTextureSize) : height);
  32376. var gl = this._gl;
  32377. if (!gl) {
  32378. return;
  32379. }
  32380. if (!texture._webGLTexture) {
  32381. // this.resetTextureCache();
  32382. if (scene) {
  32383. scene._removePendingData(texture);
  32384. }
  32385. return;
  32386. }
  32387. this._bindTextureDirectly(gl.TEXTURE_2D, texture, true);
  32388. this._unpackFlipY(invertY === undefined ? true : (invertY ? true : false));
  32389. texture.baseWidth = width;
  32390. texture.baseHeight = height;
  32391. texture.width = potWidth;
  32392. texture.height = potHeight;
  32393. texture.isReady = true;
  32394. if (processFunction(potWidth, potHeight, function () {
  32395. _this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32396. })) {
  32397. // Returning as texture needs extra async steps
  32398. return;
  32399. }
  32400. this._prepareWebGLTextureContinuation(texture, scene, noMipmap, isCompressed, samplingMode);
  32401. };
  32402. Engine.prototype._convertRGBtoRGBATextureData = function (rgbData, width, height, textureType) {
  32403. // Create new RGBA data container.
  32404. var rgbaData;
  32405. if (textureType === Engine.TEXTURETYPE_FLOAT) {
  32406. rgbaData = new Float32Array(width * height * 4);
  32407. }
  32408. else {
  32409. rgbaData = new Uint32Array(width * height * 4);
  32410. }
  32411. // Convert each pixel.
  32412. for (var x = 0; x < width; x++) {
  32413. for (var y = 0; y < height; y++) {
  32414. var index = (y * width + x) * 3;
  32415. var newIndex = (y * width + x) * 4;
  32416. // Map Old Value to new value.
  32417. rgbaData[newIndex + 0] = rgbData[index + 0];
  32418. rgbaData[newIndex + 1] = rgbData[index + 1];
  32419. rgbaData[newIndex + 2] = rgbData[index + 2];
  32420. // Add fully opaque alpha channel.
  32421. rgbaData[newIndex + 3] = 1;
  32422. }
  32423. }
  32424. return rgbaData;
  32425. };
  32426. /** @hidden */
  32427. Engine.prototype._releaseFramebufferObjects = function (texture) {
  32428. var gl = this._gl;
  32429. if (texture._framebuffer) {
  32430. gl.deleteFramebuffer(texture._framebuffer);
  32431. texture._framebuffer = null;
  32432. }
  32433. if (texture._depthStencilBuffer) {
  32434. gl.deleteRenderbuffer(texture._depthStencilBuffer);
  32435. texture._depthStencilBuffer = null;
  32436. }
  32437. if (texture._MSAAFramebuffer) {
  32438. gl.deleteFramebuffer(texture._MSAAFramebuffer);
  32439. texture._MSAAFramebuffer = null;
  32440. }
  32441. if (texture._MSAARenderBuffer) {
  32442. gl.deleteRenderbuffer(texture._MSAARenderBuffer);
  32443. texture._MSAARenderBuffer = null;
  32444. }
  32445. };
  32446. /** @hidden */
  32447. Engine.prototype._releaseTexture = function (texture) {
  32448. var gl = this._gl;
  32449. this._releaseFramebufferObjects(texture);
  32450. gl.deleteTexture(texture._webGLTexture);
  32451. // Unbind channels
  32452. this.unbindAllTextures();
  32453. var index = this._internalTexturesCache.indexOf(texture);
  32454. if (index !== -1) {
  32455. this._internalTexturesCache.splice(index, 1);
  32456. }
  32457. // Integrated fixed lod samplers.
  32458. if (texture._lodTextureHigh) {
  32459. texture._lodTextureHigh.dispose();
  32460. }
  32461. if (texture._lodTextureMid) {
  32462. texture._lodTextureMid.dispose();
  32463. }
  32464. if (texture._lodTextureLow) {
  32465. texture._lodTextureLow.dispose();
  32466. }
  32467. // Set output texture of post process to null if the texture has been released/disposed
  32468. this.scenes.forEach(function (scene) {
  32469. scene.postProcesses.forEach(function (postProcess) {
  32470. if (postProcess._outputTexture == texture) {
  32471. postProcess._outputTexture = null;
  32472. }
  32473. });
  32474. scene.cameras.forEach(function (camera) {
  32475. camera._postProcesses.forEach(function (postProcess) {
  32476. if (postProcess) {
  32477. if (postProcess._outputTexture == texture) {
  32478. postProcess._outputTexture = null;
  32479. }
  32480. }
  32481. });
  32482. });
  32483. });
  32484. };
  32485. Engine.prototype.setProgram = function (program) {
  32486. if (this._currentProgram !== program) {
  32487. this._gl.useProgram(program);
  32488. this._currentProgram = program;
  32489. }
  32490. };
  32491. /**
  32492. * Binds an effect to the webGL context
  32493. * @param effect defines the effect to bind
  32494. */
  32495. Engine.prototype.bindSamplers = function (effect) {
  32496. this.setProgram(effect.getProgram());
  32497. var samplers = effect.getSamplers();
  32498. for (var index = 0; index < samplers.length; index++) {
  32499. var uniform = effect.getUniform(samplers[index]);
  32500. if (uniform) {
  32501. this._boundUniforms[index] = uniform;
  32502. }
  32503. }
  32504. this._currentEffect = null;
  32505. };
  32506. Engine.prototype._moveBoundTextureOnTop = function (internalTexture) {
  32507. if (this.disableTextureBindingOptimization || this._lastBoundInternalTextureTracker.previous === internalTexture) {
  32508. return;
  32509. }
  32510. // Remove
  32511. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32512. // Bind last to it
  32513. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, internalTexture);
  32514. // Bind to dummy
  32515. this._linkTrackers(internalTexture, this._lastBoundInternalTextureTracker);
  32516. };
  32517. Engine.prototype._getCorrectTextureChannel = function (channel, internalTexture) {
  32518. if (!internalTexture) {
  32519. return -1;
  32520. }
  32521. internalTexture._initialSlot = channel;
  32522. if (this.disableTextureBindingOptimization) { // We want texture sampler ID === texture channel
  32523. if (channel !== internalTexture._designatedSlot) {
  32524. this._textureCollisions.addCount(1, false);
  32525. }
  32526. }
  32527. else {
  32528. if (channel !== internalTexture._designatedSlot) {
  32529. if (internalTexture._designatedSlot > -1) { // Texture is already assigned to a slot
  32530. return internalTexture._designatedSlot;
  32531. }
  32532. else {
  32533. // No slot for this texture, let's pick a new one (if we find a free slot)
  32534. if (this._nextFreeTextureSlots.length) {
  32535. return this._nextFreeTextureSlots[0];
  32536. }
  32537. // We need to recycle the oldest bound texture, sorry.
  32538. this._textureCollisions.addCount(1, false);
  32539. return this._removeDesignatedSlot(this._firstBoundInternalTextureTracker.next);
  32540. }
  32541. }
  32542. }
  32543. return channel;
  32544. };
  32545. Engine.prototype._linkTrackers = function (previous, next) {
  32546. previous.next = next;
  32547. next.previous = previous;
  32548. };
  32549. Engine.prototype._removeDesignatedSlot = function (internalTexture) {
  32550. var currentSlot = internalTexture._designatedSlot;
  32551. if (currentSlot === -1) {
  32552. return -1;
  32553. }
  32554. internalTexture._designatedSlot = -1;
  32555. if (this.disableTextureBindingOptimization) {
  32556. return -1;
  32557. }
  32558. // Remove from bound list
  32559. this._linkTrackers(internalTexture.previous, internalTexture.next);
  32560. // Free the slot
  32561. this._boundTexturesCache[currentSlot] = null;
  32562. this._nextFreeTextureSlots.push(currentSlot);
  32563. return currentSlot;
  32564. };
  32565. Engine.prototype._activateCurrentTexture = function () {
  32566. if (this._currentTextureChannel !== this._activeChannel) {
  32567. this._gl.activeTexture(this._gl.TEXTURE0 + this._activeChannel);
  32568. this._currentTextureChannel = this._activeChannel;
  32569. }
  32570. };
  32571. /** @hidden */
  32572. Engine.prototype._bindTextureDirectly = function (target, texture, forTextureDataUpdate, force) {
  32573. if (forTextureDataUpdate === void 0) { forTextureDataUpdate = false; }
  32574. if (force === void 0) { force = false; }
  32575. var wasPreviouslyBound = false;
  32576. if (forTextureDataUpdate && texture && texture._designatedSlot > -1) {
  32577. this._activeChannel = texture._designatedSlot;
  32578. }
  32579. var currentTextureBound = this._boundTexturesCache[this._activeChannel];
  32580. var isTextureForRendering = texture && texture._initialSlot > -1;
  32581. if (currentTextureBound !== texture || force) {
  32582. if (currentTextureBound) {
  32583. this._removeDesignatedSlot(currentTextureBound);
  32584. }
  32585. this._activateCurrentTexture();
  32586. this._gl.bindTexture(target, texture ? texture._webGLTexture : null);
  32587. this._boundTexturesCache[this._activeChannel] = texture;
  32588. if (texture) {
  32589. if (!this.disableTextureBindingOptimization) {
  32590. var slotIndex = this._nextFreeTextureSlots.indexOf(this._activeChannel);
  32591. if (slotIndex > -1) {
  32592. this._nextFreeTextureSlots.splice(slotIndex, 1);
  32593. }
  32594. this._linkTrackers(this._lastBoundInternalTextureTracker.previous, texture);
  32595. this._linkTrackers(texture, this._lastBoundInternalTextureTracker);
  32596. }
  32597. texture._designatedSlot = this._activeChannel;
  32598. }
  32599. }
  32600. else if (forTextureDataUpdate) {
  32601. wasPreviouslyBound = true;
  32602. this._activateCurrentTexture();
  32603. }
  32604. if (isTextureForRendering && !forTextureDataUpdate) {
  32605. this._bindSamplerUniformToChannel(texture._initialSlot, this._activeChannel);
  32606. }
  32607. return wasPreviouslyBound;
  32608. };
  32609. /** @hidden */
  32610. Engine.prototype._bindTexture = function (channel, texture) {
  32611. if (channel < 0) {
  32612. return;
  32613. }
  32614. if (texture) {
  32615. channel = this._getCorrectTextureChannel(channel, texture);
  32616. }
  32617. this._activeChannel = channel;
  32618. this._bindTextureDirectly(this._gl.TEXTURE_2D, texture);
  32619. };
  32620. /**
  32621. * Sets a texture to the webGL context from a postprocess
  32622. * @param channel defines the channel to use
  32623. * @param postProcess defines the source postprocess
  32624. */
  32625. Engine.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  32626. this._bindTexture(channel, postProcess ? postProcess._textures.data[postProcess._currentRenderTextureInd] : null);
  32627. };
  32628. /**
  32629. * Binds the output of the passed in post process to the texture channel specified
  32630. * @param channel The channel the texture should be bound to
  32631. * @param postProcess The post process which's output should be bound
  32632. */
  32633. Engine.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  32634. this._bindTexture(channel, postProcess ? postProcess._outputTexture : null);
  32635. };
  32636. /**
  32637. * Unbind all textures from the webGL context
  32638. */
  32639. Engine.prototype.unbindAllTextures = function () {
  32640. for (var channel = 0; channel < this._maxSimultaneousTextures; channel++) {
  32641. this._activeChannel = channel;
  32642. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32643. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32644. if (this.webGLVersion > 1) {
  32645. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32646. }
  32647. }
  32648. };
  32649. /**
  32650. * Sets a texture to the according uniform.
  32651. * @param channel The texture channel
  32652. * @param uniform The uniform to set
  32653. * @param texture The texture to apply
  32654. */
  32655. Engine.prototype.setTexture = function (channel, uniform, texture) {
  32656. if (channel < 0) {
  32657. return;
  32658. }
  32659. if (uniform) {
  32660. this._boundUniforms[channel] = uniform;
  32661. }
  32662. this._setTexture(channel, texture);
  32663. };
  32664. /**
  32665. * Sets a depth stencil texture from a render target to the according uniform.
  32666. * @param channel The texture channel
  32667. * @param uniform The uniform to set
  32668. * @param texture The render target texture containing the depth stencil texture to apply
  32669. */
  32670. Engine.prototype.setDepthStencilTexture = function (channel, uniform, texture) {
  32671. if (channel < 0) {
  32672. return;
  32673. }
  32674. if (uniform) {
  32675. this._boundUniforms[channel] = uniform;
  32676. }
  32677. if (!texture || !texture.depthStencilTexture) {
  32678. this._setTexture(channel, null);
  32679. }
  32680. else {
  32681. this._setTexture(channel, texture, false, true);
  32682. }
  32683. };
  32684. Engine.prototype._bindSamplerUniformToChannel = function (sourceSlot, destination) {
  32685. var uniform = this._boundUniforms[sourceSlot];
  32686. if (uniform._currentState === destination) {
  32687. return;
  32688. }
  32689. this._gl.uniform1i(uniform, destination);
  32690. uniform._currentState = destination;
  32691. };
  32692. Engine.prototype._getTextureWrapMode = function (mode) {
  32693. switch (mode) {
  32694. case Engine.TEXTURE_WRAP_ADDRESSMODE:
  32695. return this._gl.REPEAT;
  32696. case Engine.TEXTURE_CLAMP_ADDRESSMODE:
  32697. return this._gl.CLAMP_TO_EDGE;
  32698. case Engine.TEXTURE_MIRROR_ADDRESSMODE:
  32699. return this._gl.MIRRORED_REPEAT;
  32700. }
  32701. return this._gl.REPEAT;
  32702. };
  32703. Engine.prototype._setTexture = function (channel, texture, isPartOfTextureArray, depthStencilTexture) {
  32704. if (isPartOfTextureArray === void 0) { isPartOfTextureArray = false; }
  32705. if (depthStencilTexture === void 0) { depthStencilTexture = false; }
  32706. // Not ready?
  32707. if (!texture) {
  32708. if (this._boundTexturesCache[channel] != null) {
  32709. this._activeChannel = channel;
  32710. this._bindTextureDirectly(this._gl.TEXTURE_2D, null);
  32711. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, null);
  32712. if (this.webGLVersion > 1) {
  32713. this._bindTextureDirectly(this._gl.TEXTURE_3D, null);
  32714. }
  32715. }
  32716. return false;
  32717. }
  32718. // Video
  32719. if (texture.video) {
  32720. this._activeChannel = channel;
  32721. texture.update();
  32722. }
  32723. else if (texture.delayLoadState === Engine.DELAYLOADSTATE_NOTLOADED) { // Delay loading
  32724. texture.delayLoad();
  32725. return false;
  32726. }
  32727. var internalTexture;
  32728. if (depthStencilTexture) {
  32729. internalTexture = texture.depthStencilTexture;
  32730. }
  32731. else if (texture.isReady()) {
  32732. internalTexture = texture.getInternalTexture();
  32733. }
  32734. else if (texture.isCube) {
  32735. internalTexture = this.emptyCubeTexture;
  32736. }
  32737. else if (texture.is3D) {
  32738. internalTexture = this.emptyTexture3D;
  32739. }
  32740. else {
  32741. internalTexture = this.emptyTexture;
  32742. }
  32743. if (!isPartOfTextureArray) {
  32744. channel = this._getCorrectTextureChannel(channel, internalTexture);
  32745. }
  32746. var needToBind = true;
  32747. if (this._boundTexturesCache[channel] === internalTexture) {
  32748. this._moveBoundTextureOnTop(internalTexture);
  32749. if (!isPartOfTextureArray) {
  32750. this._bindSamplerUniformToChannel(internalTexture._initialSlot, channel);
  32751. }
  32752. needToBind = false;
  32753. }
  32754. this._activeChannel = channel;
  32755. if (internalTexture && internalTexture.is3D) {
  32756. if (needToBind) {
  32757. this._bindTextureDirectly(this._gl.TEXTURE_3D, internalTexture, isPartOfTextureArray);
  32758. }
  32759. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32760. internalTexture._cachedWrapU = texture.wrapU;
  32761. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32762. }
  32763. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32764. internalTexture._cachedWrapV = texture.wrapV;
  32765. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32766. }
  32767. if (internalTexture && internalTexture._cachedWrapR !== texture.wrapR) {
  32768. internalTexture._cachedWrapR = texture.wrapR;
  32769. this._setTextureParameterInteger(this._gl.TEXTURE_3D, this._gl.TEXTURE_WRAP_R, this._getTextureWrapMode(texture.wrapR), internalTexture);
  32770. }
  32771. this._setAnisotropicLevel(this._gl.TEXTURE_3D, texture);
  32772. }
  32773. else if (internalTexture && internalTexture.isCube) {
  32774. if (needToBind) {
  32775. this._bindTextureDirectly(this._gl.TEXTURE_CUBE_MAP, internalTexture, isPartOfTextureArray);
  32776. }
  32777. if (internalTexture._cachedCoordinatesMode !== texture.coordinatesMode) {
  32778. internalTexture._cachedCoordinatesMode = texture.coordinatesMode;
  32779. // CUBIC_MODE and SKYBOX_MODE both require CLAMP_TO_EDGE. All other modes use REPEAT.
  32780. var textureWrapMode = (texture.coordinatesMode !== Engine.TEXTURE_CUBIC_MODE && texture.coordinatesMode !== Engine.TEXTURE_SKYBOX_MODE) ? this._gl.REPEAT : this._gl.CLAMP_TO_EDGE;
  32781. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_S, textureWrapMode, internalTexture);
  32782. this._setTextureParameterInteger(this._gl.TEXTURE_CUBE_MAP, this._gl.TEXTURE_WRAP_T, textureWrapMode);
  32783. }
  32784. this._setAnisotropicLevel(this._gl.TEXTURE_CUBE_MAP, texture);
  32785. }
  32786. else {
  32787. if (needToBind) {
  32788. this._bindTextureDirectly(this._gl.TEXTURE_2D, internalTexture, isPartOfTextureArray);
  32789. }
  32790. if (internalTexture && internalTexture._cachedWrapU !== texture.wrapU) {
  32791. internalTexture._cachedWrapU = texture.wrapU;
  32792. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_S, this._getTextureWrapMode(texture.wrapU), internalTexture);
  32793. }
  32794. if (internalTexture && internalTexture._cachedWrapV !== texture.wrapV) {
  32795. internalTexture._cachedWrapV = texture.wrapV;
  32796. this._setTextureParameterInteger(this._gl.TEXTURE_2D, this._gl.TEXTURE_WRAP_T, this._getTextureWrapMode(texture.wrapV), internalTexture);
  32797. }
  32798. this._setAnisotropicLevel(this._gl.TEXTURE_2D, texture);
  32799. }
  32800. return true;
  32801. };
  32802. /**
  32803. * Sets an array of texture to the webGL context
  32804. * @param channel defines the channel where the texture array must be set
  32805. * @param uniform defines the associated uniform location
  32806. * @param textures defines the array of textures to bind
  32807. */
  32808. Engine.prototype.setTextureArray = function (channel, uniform, textures) {
  32809. if (channel < 0 || !uniform) {
  32810. return;
  32811. }
  32812. if (!this._textureUnits || this._textureUnits.length !== textures.length) {
  32813. this._textureUnits = new Int32Array(textures.length);
  32814. }
  32815. for (var i = 0; i < textures.length; i++) {
  32816. this._textureUnits[i] = this._getCorrectTextureChannel(channel + i, textures[i].getInternalTexture());
  32817. }
  32818. this._gl.uniform1iv(uniform, this._textureUnits);
  32819. for (var index = 0; index < textures.length; index++) {
  32820. this._setTexture(this._textureUnits[index], textures[index], true);
  32821. }
  32822. };
  32823. /** @hidden */
  32824. Engine.prototype._setAnisotropicLevel = function (target, texture) {
  32825. var internalTexture = texture.getInternalTexture();
  32826. if (!internalTexture) {
  32827. return;
  32828. }
  32829. var anisotropicFilterExtension = this._caps.textureAnisotropicFilterExtension;
  32830. var value = texture.anisotropicFilteringLevel;
  32831. if (internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST
  32832. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR
  32833. && internalTexture.samplingMode !== Engine.TEXTURE_LINEAR_LINEAR) {
  32834. value = 1; // Forcing the anisotropic to 1 because else webgl will force filters to linear
  32835. }
  32836. if (anisotropicFilterExtension && internalTexture._cachedAnisotropicFilteringLevel !== value) {
  32837. this._setTextureParameterFloat(target, anisotropicFilterExtension.TEXTURE_MAX_ANISOTROPY_EXT, Math.min(value, this._caps.maxAnisotropy), internalTexture);
  32838. internalTexture._cachedAnisotropicFilteringLevel = value;
  32839. }
  32840. };
  32841. Engine.prototype._setTextureParameterFloat = function (target, parameter, value, texture) {
  32842. this._bindTextureDirectly(target, texture, true, true);
  32843. this._gl.texParameterf(target, parameter, value);
  32844. };
  32845. Engine.prototype._setTextureParameterInteger = function (target, parameter, value, texture) {
  32846. if (texture) {
  32847. this._bindTextureDirectly(target, texture, true, true);
  32848. }
  32849. this._gl.texParameteri(target, parameter, value);
  32850. };
  32851. /**
  32852. * Reads pixels from the current frame buffer. Please note that this function can be slow
  32853. * @param x defines the x coordinate of the rectangle where pixels must be read
  32854. * @param y defines the y coordinate of the rectangle where pixels must be read
  32855. * @param width defines the width of the rectangle where pixels must be read
  32856. * @param height defines the height of the rectangle where pixels must be read
  32857. * @returns a Uint8Array containing RGBA colors
  32858. */
  32859. Engine.prototype.readPixels = function (x, y, width, height) {
  32860. var data = new Uint8Array(height * width * 4);
  32861. this._gl.readPixels(x, y, width, height, this._gl.RGBA, this._gl.UNSIGNED_BYTE, data);
  32862. return data;
  32863. };
  32864. /**
  32865. * Add an externaly attached data from its key.
  32866. * This method call will fail and return false, if such key already exists.
  32867. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  32868. * @param key the unique key that identifies the data
  32869. * @param data the data object to associate to the key for this Engine instance
  32870. * @return true if no such key were already present and the data was added successfully, false otherwise
  32871. */
  32872. Engine.prototype.addExternalData = function (key, data) {
  32873. if (!this._externalData) {
  32874. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32875. }
  32876. return this._externalData.add(key, data);
  32877. };
  32878. /**
  32879. * Get an externaly attached data from its key
  32880. * @param key the unique key that identifies the data
  32881. * @return the associated data, if present (can be null), or undefined if not present
  32882. */
  32883. Engine.prototype.getExternalData = function (key) {
  32884. if (!this._externalData) {
  32885. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32886. }
  32887. return this._externalData.get(key);
  32888. };
  32889. /**
  32890. * Get an externaly attached data from its key, create it using a factory if it's not already present
  32891. * @param key the unique key that identifies the data
  32892. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  32893. * @return the associated data, can be null if the factory returned null.
  32894. */
  32895. Engine.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  32896. if (!this._externalData) {
  32897. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32898. }
  32899. return this._externalData.getOrAddWithFactory(key, factory);
  32900. };
  32901. /**
  32902. * Remove an externaly attached data from the Engine instance
  32903. * @param key the unique key that identifies the data
  32904. * @return true if the data was successfully removed, false if it doesn't exist
  32905. */
  32906. Engine.prototype.removeExternalData = function (key) {
  32907. if (!this._externalData) {
  32908. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_3__["StringDictionary"]();
  32909. }
  32910. return this._externalData.remove(key);
  32911. };
  32912. /**
  32913. * Unbind all vertex attributes from the webGL context
  32914. */
  32915. Engine.prototype.unbindAllAttributes = function () {
  32916. if (this._mustWipeVertexAttributes) {
  32917. this._mustWipeVertexAttributes = false;
  32918. for (var i = 0; i < this._caps.maxVertexAttribs; i++) {
  32919. this._gl.disableVertexAttribArray(i);
  32920. this._vertexAttribArraysEnabled[i] = false;
  32921. this._currentBufferPointers[i].active = false;
  32922. }
  32923. return;
  32924. }
  32925. for (var i = 0, ul = this._vertexAttribArraysEnabled.length; i < ul; i++) {
  32926. if (i >= this._caps.maxVertexAttribs || !this._vertexAttribArraysEnabled[i]) {
  32927. continue;
  32928. }
  32929. this._gl.disableVertexAttribArray(i);
  32930. this._vertexAttribArraysEnabled[i] = false;
  32931. this._currentBufferPointers[i].active = false;
  32932. }
  32933. };
  32934. /**
  32935. * 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
  32936. */
  32937. Engine.prototype.releaseEffects = function () {
  32938. for (var name in this._compiledEffects) {
  32939. this._deleteProgram(this._compiledEffects[name]._program);
  32940. }
  32941. this._compiledEffects = {};
  32942. };
  32943. /**
  32944. * Dispose and release all associated resources
  32945. */
  32946. Engine.prototype.dispose = function () {
  32947. this.hideLoadingUI();
  32948. this.stopRenderLoop();
  32949. this.onNewSceneAddedObservable.clear();
  32950. // Release postProcesses
  32951. while (this.postProcesses.length) {
  32952. this.postProcesses[0].dispose();
  32953. }
  32954. // Empty texture
  32955. if (this._emptyTexture) {
  32956. this._releaseTexture(this._emptyTexture);
  32957. this._emptyTexture = null;
  32958. }
  32959. if (this._emptyCubeTexture) {
  32960. this._releaseTexture(this._emptyCubeTexture);
  32961. this._emptyCubeTexture = null;
  32962. }
  32963. // Rescale PP
  32964. if (this._rescalePostProcess) {
  32965. this._rescalePostProcess.dispose();
  32966. }
  32967. // Release scenes
  32968. while (this.scenes.length) {
  32969. this.scenes[0].dispose();
  32970. }
  32971. // Release audio engine
  32972. if (Engine.Instances.length === 1 && Engine.audioEngine) {
  32973. Engine.audioEngine.dispose();
  32974. }
  32975. // Release effects
  32976. this.releaseEffects();
  32977. // Unbind
  32978. this.unbindAllAttributes();
  32979. this._boundUniforms = [];
  32980. if (this._dummyFramebuffer) {
  32981. this._gl.deleteFramebuffer(this._dummyFramebuffer);
  32982. }
  32983. //WebVR
  32984. this.disableVR();
  32985. // Events
  32986. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  32987. window.removeEventListener("blur", this._onBlur);
  32988. window.removeEventListener("focus", this._onFocus);
  32989. window.removeEventListener('vrdisplaypointerrestricted', this._onVRDisplayPointerRestricted);
  32990. window.removeEventListener('vrdisplaypointerunrestricted', this._onVRDisplayPointerUnrestricted);
  32991. if (this._renderingCanvas) {
  32992. this._renderingCanvas.removeEventListener("focus", this._onCanvasFocus);
  32993. this._renderingCanvas.removeEventListener("blur", this._onCanvasBlur);
  32994. this._renderingCanvas.removeEventListener("pointerout", this._onCanvasPointerOut);
  32995. if (!this._doNotHandleContextLost) {
  32996. this._renderingCanvas.removeEventListener("webglcontextlost", this._onContextLost);
  32997. this._renderingCanvas.removeEventListener("webglcontextrestored", this._onContextRestored);
  32998. }
  32999. }
  33000. document.removeEventListener("fullscreenchange", this._onFullscreenChange);
  33001. document.removeEventListener("mozfullscreenchange", this._onFullscreenChange);
  33002. document.removeEventListener("webkitfullscreenchange", this._onFullscreenChange);
  33003. document.removeEventListener("msfullscreenchange", this._onFullscreenChange);
  33004. document.removeEventListener("pointerlockchange", this._onPointerLockChange);
  33005. document.removeEventListener("mspointerlockchange", this._onPointerLockChange);
  33006. document.removeEventListener("mozpointerlockchange", this._onPointerLockChange);
  33007. document.removeEventListener("webkitpointerlockchange", this._onPointerLockChange);
  33008. if (this._onVrDisplayConnect) {
  33009. window.removeEventListener('vrdisplayconnect', this._onVrDisplayConnect);
  33010. if (this._onVrDisplayDisconnect) {
  33011. window.removeEventListener('vrdisplaydisconnect', this._onVrDisplayDisconnect);
  33012. }
  33013. if (this._onVrDisplayPresentChange) {
  33014. window.removeEventListener('vrdisplaypresentchange', this._onVrDisplayPresentChange);
  33015. }
  33016. this._onVrDisplayConnect = null;
  33017. this._onVrDisplayDisconnect = null;
  33018. }
  33019. }
  33020. // Remove from Instances
  33021. var index = Engine.Instances.indexOf(this);
  33022. if (index >= 0) {
  33023. Engine.Instances.splice(index, 1);
  33024. }
  33025. this._workingCanvas = null;
  33026. this._workingContext = null;
  33027. this._currentBufferPointers = [];
  33028. this._renderingCanvas = null;
  33029. this._currentProgram = null;
  33030. this._bindedRenderFunction = null;
  33031. this.onResizeObservable.clear();
  33032. this.onCanvasBlurObservable.clear();
  33033. this.onCanvasFocusObservable.clear();
  33034. this.onCanvasPointerOutObservable.clear();
  33035. this.onBeginFrameObservable.clear();
  33036. this.onEndFrameObservable.clear();
  33037. _Materials_effect__WEBPACK_IMPORTED_MODULE_8__["Effect"].ResetCache();
  33038. // Abort active requests
  33039. for (var _i = 0, _a = this._activeRequests; _i < _a.length; _i++) {
  33040. var request = _a[_i];
  33041. request.abort();
  33042. }
  33043. };
  33044. // Loading screen
  33045. /**
  33046. * Display the loading screen
  33047. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33048. */
  33049. Engine.prototype.displayLoadingUI = function () {
  33050. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33051. return;
  33052. }
  33053. var loadingScreen = this.loadingScreen;
  33054. if (loadingScreen) {
  33055. loadingScreen.displayLoadingUI();
  33056. }
  33057. };
  33058. /**
  33059. * Hide the loading screen
  33060. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33061. */
  33062. Engine.prototype.hideLoadingUI = function () {
  33063. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_14__["DomManagement"].IsWindowObjectExist()) {
  33064. return;
  33065. }
  33066. var loadingScreen = this.loadingScreen;
  33067. if (loadingScreen) {
  33068. loadingScreen.hideLoadingUI();
  33069. }
  33070. };
  33071. Object.defineProperty(Engine.prototype, "loadingScreen", {
  33072. /**
  33073. * Gets the current loading screen object
  33074. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33075. */
  33076. get: function () {
  33077. if (!this._loadingScreen && this._renderingCanvas) {
  33078. this._loadingScreen = Engine.DefaultLoadingScreenFactory(this._renderingCanvas);
  33079. }
  33080. return this._loadingScreen;
  33081. },
  33082. /**
  33083. * Sets the current loading screen object
  33084. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33085. */
  33086. set: function (loadingScreen) {
  33087. this._loadingScreen = loadingScreen;
  33088. },
  33089. enumerable: true,
  33090. configurable: true
  33091. });
  33092. Object.defineProperty(Engine.prototype, "loadingUIText", {
  33093. /**
  33094. * Sets the current loading screen text
  33095. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33096. */
  33097. set: function (text) {
  33098. this.loadingScreen.loadingUIText = text;
  33099. },
  33100. enumerable: true,
  33101. configurable: true
  33102. });
  33103. Object.defineProperty(Engine.prototype, "loadingUIBackgroundColor", {
  33104. /**
  33105. * Sets the current loading screen background color
  33106. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  33107. */
  33108. set: function (color) {
  33109. this.loadingScreen.loadingUIBackgroundColor = color;
  33110. },
  33111. enumerable: true,
  33112. configurable: true
  33113. });
  33114. /**
  33115. * Attach a new callback raised when context lost event is fired
  33116. * @param callback defines the callback to call
  33117. */
  33118. Engine.prototype.attachContextLostEvent = function (callback) {
  33119. if (this._renderingCanvas) {
  33120. this._renderingCanvas.addEventListener("webglcontextlost", callback, false);
  33121. }
  33122. };
  33123. /**
  33124. * Attach a new callback raised when context restored event is fired
  33125. * @param callback defines the callback to call
  33126. */
  33127. Engine.prototype.attachContextRestoredEvent = function (callback) {
  33128. if (this._renderingCanvas) {
  33129. this._renderingCanvas.addEventListener("webglcontextrestored", callback, false);
  33130. }
  33131. };
  33132. /**
  33133. * Gets the source code of the vertex shader associated with a specific webGL program
  33134. * @param program defines the program to use
  33135. * @returns a string containing the source code of the vertex shader associated with the program
  33136. */
  33137. Engine.prototype.getVertexShaderSource = function (program) {
  33138. var shaders = this._gl.getAttachedShaders(program);
  33139. if (!shaders) {
  33140. return null;
  33141. }
  33142. return this._gl.getShaderSource(shaders[0]);
  33143. };
  33144. /**
  33145. * Gets the source code of the fragment shader associated with a specific webGL program
  33146. * @param program defines the program to use
  33147. * @returns a string containing the source code of the fragment shader associated with the program
  33148. */
  33149. Engine.prototype.getFragmentShaderSource = function (program) {
  33150. var shaders = this._gl.getAttachedShaders(program);
  33151. if (!shaders) {
  33152. return null;
  33153. }
  33154. return this._gl.getShaderSource(shaders[1]);
  33155. };
  33156. /**
  33157. * Get the current error code of the webGL context
  33158. * @returns the error code
  33159. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  33160. */
  33161. Engine.prototype.getError = function () {
  33162. return this._gl.getError();
  33163. };
  33164. // FPS
  33165. /**
  33166. * Gets the current framerate
  33167. * @returns a number representing the framerate
  33168. */
  33169. Engine.prototype.getFps = function () {
  33170. return this._fps;
  33171. };
  33172. /**
  33173. * Gets the time spent between current and previous frame
  33174. * @returns a number representing the delta time in ms
  33175. */
  33176. Engine.prototype.getDeltaTime = function () {
  33177. return this._deltaTime;
  33178. };
  33179. Engine.prototype._measureFps = function () {
  33180. this._performanceMonitor.sampleFrame();
  33181. this._fps = this._performanceMonitor.averageFPS;
  33182. this._deltaTime = this._performanceMonitor.instantaneousFrameTime || 0;
  33183. };
  33184. /** @hidden */
  33185. Engine.prototype._readTexturePixels = function (texture, width, height, faceIndex, level, buffer) {
  33186. if (faceIndex === void 0) { faceIndex = -1; }
  33187. if (level === void 0) { level = 0; }
  33188. if (buffer === void 0) { buffer = null; }
  33189. var gl = this._gl;
  33190. if (!this._dummyFramebuffer) {
  33191. var dummy = gl.createFramebuffer();
  33192. if (!dummy) {
  33193. throw new Error("Unable to create dummy framebuffer");
  33194. }
  33195. this._dummyFramebuffer = dummy;
  33196. }
  33197. gl.bindFramebuffer(gl.FRAMEBUFFER, this._dummyFramebuffer);
  33198. if (faceIndex > -1) {
  33199. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_CUBE_MAP_POSITIVE_X + faceIndex, texture._webGLTexture, level);
  33200. }
  33201. else {
  33202. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture._webGLTexture, level);
  33203. }
  33204. var readType = (texture.type !== undefined) ? this._getWebGLTextureType(texture.type) : gl.UNSIGNED_BYTE;
  33205. switch (readType) {
  33206. case gl.UNSIGNED_BYTE:
  33207. if (!buffer) {
  33208. buffer = new Uint8Array(4 * width * height);
  33209. }
  33210. readType = gl.UNSIGNED_BYTE;
  33211. break;
  33212. default:
  33213. if (!buffer) {
  33214. buffer = new Float32Array(4 * width * height);
  33215. }
  33216. readType = gl.FLOAT;
  33217. break;
  33218. }
  33219. gl.readPixels(0, 0, width, height, gl.RGBA, readType, buffer);
  33220. gl.bindFramebuffer(gl.FRAMEBUFFER, this._currentFramebuffer);
  33221. return buffer;
  33222. };
  33223. Engine.prototype._canRenderToFloatFramebuffer = function () {
  33224. if (this._webGLVersion > 1) {
  33225. return this._caps.colorBufferFloat;
  33226. }
  33227. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_FLOAT);
  33228. };
  33229. Engine.prototype._canRenderToHalfFloatFramebuffer = function () {
  33230. if (this._webGLVersion > 1) {
  33231. return this._caps.colorBufferFloat;
  33232. }
  33233. return this._canRenderToFramebuffer(Engine.TEXTURETYPE_HALF_FLOAT);
  33234. };
  33235. // Thank you : http://stackoverflow.com/questions/28827511/webgl-ios-render-to-floating-point-texture
  33236. Engine.prototype._canRenderToFramebuffer = function (type) {
  33237. var gl = this._gl;
  33238. //clear existing errors
  33239. while (gl.getError() !== gl.NO_ERROR) { }
  33240. var successful = true;
  33241. var texture = gl.createTexture();
  33242. gl.bindTexture(gl.TEXTURE_2D, texture);
  33243. gl.texImage2D(gl.TEXTURE_2D, 0, this._getRGBABufferInternalSizedFormat(type), 1, 1, 0, gl.RGBA, this._getWebGLTextureType(type), null);
  33244. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER, gl.NEAREST);
  33245. gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);
  33246. var fb = gl.createFramebuffer();
  33247. gl.bindFramebuffer(gl.FRAMEBUFFER, fb);
  33248. gl.framebufferTexture2D(gl.FRAMEBUFFER, gl.COLOR_ATTACHMENT0, gl.TEXTURE_2D, texture, 0);
  33249. var status = gl.checkFramebufferStatus(gl.FRAMEBUFFER);
  33250. successful = successful && (status === gl.FRAMEBUFFER_COMPLETE);
  33251. successful = successful && (gl.getError() === gl.NO_ERROR);
  33252. //try render by clearing frame buffer's color buffer
  33253. if (successful) {
  33254. gl.clear(gl.COLOR_BUFFER_BIT);
  33255. successful = successful && (gl.getError() === gl.NO_ERROR);
  33256. }
  33257. //try reading from frame to ensure render occurs (just creating the FBO is not sufficient to determine if rendering is supported)
  33258. if (successful) {
  33259. //in practice it's sufficient to just read from the backbuffer rather than handle potentially issues reading from the texture
  33260. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33261. var readFormat = gl.RGBA;
  33262. var readType = gl.UNSIGNED_BYTE;
  33263. var buffer = new Uint8Array(4);
  33264. gl.readPixels(0, 0, 1, 1, readFormat, readType, buffer);
  33265. successful = successful && (gl.getError() === gl.NO_ERROR);
  33266. }
  33267. //clean up
  33268. gl.deleteTexture(texture);
  33269. gl.deleteFramebuffer(fb);
  33270. gl.bindFramebuffer(gl.FRAMEBUFFER, null);
  33271. //clear accumulated errors
  33272. while (!successful && (gl.getError() !== gl.NO_ERROR)) { }
  33273. return successful;
  33274. };
  33275. /** @hidden */
  33276. Engine.prototype._getWebGLTextureType = function (type) {
  33277. if (this._webGLVersion === 1) {
  33278. switch (type) {
  33279. case Engine.TEXTURETYPE_FLOAT:
  33280. return this._gl.FLOAT;
  33281. case Engine.TEXTURETYPE_HALF_FLOAT:
  33282. return this._gl.HALF_FLOAT_OES;
  33283. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33284. return this._gl.UNSIGNED_BYTE;
  33285. }
  33286. return this._gl.UNSIGNED_BYTE;
  33287. }
  33288. switch (type) {
  33289. case Engine.TEXTURETYPE_BYTE:
  33290. return this._gl.BYTE;
  33291. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33292. return this._gl.UNSIGNED_BYTE;
  33293. case Engine.TEXTURETYPE_SHORT:
  33294. return this._gl.SHORT;
  33295. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33296. return this._gl.UNSIGNED_SHORT;
  33297. case Engine.TEXTURETYPE_INT:
  33298. return this._gl.INT;
  33299. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33300. return this._gl.UNSIGNED_INT;
  33301. case Engine.TEXTURETYPE_FLOAT:
  33302. return this._gl.FLOAT;
  33303. case Engine.TEXTURETYPE_HALF_FLOAT:
  33304. return this._gl.HALF_FLOAT;
  33305. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33306. return this._gl.UNSIGNED_SHORT_4_4_4_4;
  33307. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33308. return this._gl.UNSIGNED_SHORT_5_5_5_1;
  33309. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33310. return this._gl.UNSIGNED_SHORT_5_6_5;
  33311. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33312. return this._gl.UNSIGNED_INT_2_10_10_10_REV;
  33313. case Engine.TEXTURETYPE_UNSIGNED_INT_24_8:
  33314. return this._gl.UNSIGNED_INT_24_8;
  33315. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33316. return this._gl.UNSIGNED_INT_10F_11F_11F_REV;
  33317. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33318. return this._gl.UNSIGNED_INT_5_9_9_9_REV;
  33319. case Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV:
  33320. return this._gl.FLOAT_32_UNSIGNED_INT_24_8_REV;
  33321. }
  33322. return this._gl.UNSIGNED_BYTE;
  33323. };
  33324. Engine.prototype._getInternalFormat = function (format) {
  33325. var internalFormat = this._gl.RGBA;
  33326. switch (format) {
  33327. case Engine.TEXTUREFORMAT_ALPHA:
  33328. internalFormat = this._gl.ALPHA;
  33329. break;
  33330. case Engine.TEXTUREFORMAT_LUMINANCE:
  33331. internalFormat = this._gl.LUMINANCE;
  33332. break;
  33333. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33334. internalFormat = this._gl.LUMINANCE_ALPHA;
  33335. break;
  33336. case Engine.TEXTUREFORMAT_RED:
  33337. internalFormat = this._gl.RED;
  33338. break;
  33339. case Engine.TEXTUREFORMAT_RG:
  33340. internalFormat = this._gl.RG;
  33341. break;
  33342. case Engine.TEXTUREFORMAT_RGB:
  33343. internalFormat = this._gl.RGB;
  33344. break;
  33345. case Engine.TEXTUREFORMAT_RGBA:
  33346. internalFormat = this._gl.RGBA;
  33347. break;
  33348. }
  33349. if (this._webGLVersion > 1) {
  33350. switch (format) {
  33351. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33352. internalFormat = this._gl.RED_INTEGER;
  33353. break;
  33354. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33355. internalFormat = this._gl.RG_INTEGER;
  33356. break;
  33357. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33358. internalFormat = this._gl.RGB_INTEGER;
  33359. break;
  33360. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33361. internalFormat = this._gl.RGBA_INTEGER;
  33362. break;
  33363. }
  33364. }
  33365. return internalFormat;
  33366. };
  33367. /** @hidden */
  33368. Engine.prototype._getRGBABufferInternalSizedFormat = function (type, format) {
  33369. if (this._webGLVersion === 1) {
  33370. if (format !== undefined) {
  33371. switch (format) {
  33372. case Engine.TEXTUREFORMAT_ALPHA:
  33373. return this._gl.ALPHA;
  33374. case Engine.TEXTUREFORMAT_LUMINANCE:
  33375. return this._gl.LUMINANCE;
  33376. case Engine.TEXTUREFORMAT_LUMINANCE_ALPHA:
  33377. return this._gl.LUMINANCE_ALPHA;
  33378. }
  33379. }
  33380. return this._gl.RGBA;
  33381. }
  33382. switch (type) {
  33383. case Engine.TEXTURETYPE_BYTE:
  33384. switch (format) {
  33385. case Engine.TEXTUREFORMAT_RED:
  33386. return this._gl.R8_SNORM;
  33387. case Engine.TEXTUREFORMAT_RG:
  33388. return this._gl.RG8_SNORM;
  33389. case Engine.TEXTUREFORMAT_RGB:
  33390. return this._gl.RGB8_SNORM;
  33391. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33392. return this._gl.R8I;
  33393. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33394. return this._gl.RG8I;
  33395. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33396. return this._gl.RGB8I;
  33397. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33398. return this._gl.RGBA8I;
  33399. default:
  33400. return this._gl.RGBA8_SNORM;
  33401. }
  33402. case Engine.TEXTURETYPE_UNSIGNED_BYTE:
  33403. switch (format) {
  33404. case Engine.TEXTUREFORMAT_RED:
  33405. return this._gl.R8;
  33406. case Engine.TEXTUREFORMAT_RG:
  33407. return this._gl.RG8;
  33408. case Engine.TEXTUREFORMAT_RGB:
  33409. return this._gl.RGB8; // By default. Other possibilities are RGB565, SRGB8.
  33410. case Engine.TEXTUREFORMAT_RGBA:
  33411. return this._gl.RGBA8; // By default. Other possibilities are RGB5_A1, RGBA4, SRGB8_ALPHA8.
  33412. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33413. return this._gl.R8UI;
  33414. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33415. return this._gl.RG8UI;
  33416. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33417. return this._gl.RGB8UI;
  33418. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33419. return this._gl.RGBA8UI;
  33420. default:
  33421. return this._gl.RGBA8;
  33422. }
  33423. case Engine.TEXTURETYPE_SHORT:
  33424. switch (format) {
  33425. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33426. return this._gl.R16I;
  33427. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33428. return this._gl.RG16I;
  33429. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33430. return this._gl.RGB16I;
  33431. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33432. return this._gl.RGBA16I;
  33433. default:
  33434. return this._gl.RGBA16I;
  33435. }
  33436. case Engine.TEXTURETYPE_UNSIGNED_SHORT:
  33437. switch (format) {
  33438. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33439. return this._gl.R16UI;
  33440. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33441. return this._gl.RG16UI;
  33442. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33443. return this._gl.RGB16UI;
  33444. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33445. return this._gl.RGBA16UI;
  33446. default:
  33447. return this._gl.RGBA16UI;
  33448. }
  33449. case Engine.TEXTURETYPE_INT:
  33450. switch (format) {
  33451. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33452. return this._gl.R32I;
  33453. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33454. return this._gl.RG32I;
  33455. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33456. return this._gl.RGB32I;
  33457. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33458. return this._gl.RGBA32I;
  33459. default:
  33460. return this._gl.RGBA32I;
  33461. }
  33462. case Engine.TEXTURETYPE_UNSIGNED_INTEGER: // Refers to UNSIGNED_INT
  33463. switch (format) {
  33464. case Engine.TEXTUREFORMAT_RED_INTEGER:
  33465. return this._gl.R32UI;
  33466. case Engine.TEXTUREFORMAT_RG_INTEGER:
  33467. return this._gl.RG32UI;
  33468. case Engine.TEXTUREFORMAT_RGB_INTEGER:
  33469. return this._gl.RGB32UI;
  33470. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33471. return this._gl.RGBA32UI;
  33472. default:
  33473. return this._gl.RGBA32UI;
  33474. }
  33475. case Engine.TEXTURETYPE_FLOAT:
  33476. switch (format) {
  33477. case Engine.TEXTUREFORMAT_RED:
  33478. return this._gl.R32F; // By default. Other possibility is R16F.
  33479. case Engine.TEXTUREFORMAT_RG:
  33480. return this._gl.RG32F; // By default. Other possibility is RG16F.
  33481. case Engine.TEXTUREFORMAT_RGB:
  33482. return this._gl.RGB32F; // By default. Other possibilities are RGB16F, R11F_G11F_B10F, RGB9_E5.
  33483. case Engine.TEXTUREFORMAT_RGBA:
  33484. return this._gl.RGBA32F; // By default. Other possibility is RGBA16F.
  33485. default:
  33486. return this._gl.RGBA32F;
  33487. }
  33488. case Engine.TEXTURETYPE_HALF_FLOAT:
  33489. switch (format) {
  33490. case Engine.TEXTUREFORMAT_RED:
  33491. return this._gl.R16F;
  33492. case Engine.TEXTUREFORMAT_RG:
  33493. return this._gl.RG16F;
  33494. case Engine.TEXTUREFORMAT_RGB:
  33495. return this._gl.RGB16F; // By default. Other possibilities are R11F_G11F_B10F, RGB9_E5.
  33496. case Engine.TEXTUREFORMAT_RGBA:
  33497. return this._gl.RGBA16F;
  33498. default:
  33499. return this._gl.RGBA16F;
  33500. }
  33501. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5:
  33502. return this._gl.RGB565;
  33503. case Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV:
  33504. return this._gl.R11F_G11F_B10F;
  33505. case Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV:
  33506. return this._gl.RGB9_E5;
  33507. case Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4:
  33508. return this._gl.RGBA4;
  33509. case Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1:
  33510. return this._gl.RGB5_A1;
  33511. case Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV:
  33512. switch (format) {
  33513. case Engine.TEXTUREFORMAT_RGBA:
  33514. return this._gl.RGB10_A2; // By default. Other possibility is RGB5_A1.
  33515. case Engine.TEXTUREFORMAT_RGBA_INTEGER:
  33516. return this._gl.RGB10_A2UI;
  33517. default:
  33518. return this._gl.RGB10_A2;
  33519. }
  33520. }
  33521. return this._gl.RGBA8;
  33522. };
  33523. /** @hidden */
  33524. Engine.prototype._getRGBAMultiSampleBufferFormat = function (type) {
  33525. if (type === Engine.TEXTURETYPE_FLOAT) {
  33526. return this._gl.RGBA32F;
  33527. }
  33528. else if (type === Engine.TEXTURETYPE_HALF_FLOAT) {
  33529. return this._gl.RGBA16F;
  33530. }
  33531. return this._gl.RGBA8;
  33532. };
  33533. /** @hidden */
  33534. Engine.prototype._loadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  33535. var _this = this;
  33536. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].LoadFile(url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError);
  33537. this._activeRequests.push(request);
  33538. request.onCompleteObservable.add(function (request) {
  33539. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  33540. });
  33541. return request;
  33542. };
  33543. /** @hidden */
  33544. Engine.prototype._loadFileAsync = function (url, offlineProvider, useArrayBuffer) {
  33545. var _this = this;
  33546. return new Promise(function (resolve, reject) {
  33547. _this._loadFile(url, function (data) {
  33548. resolve(data);
  33549. }, undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  33550. reject(exception);
  33551. });
  33552. });
  33553. };
  33554. Engine.prototype._partialLoadFile = function (url, index, loadedFiles, onfinish, onErrorCallBack) {
  33555. if (onErrorCallBack === void 0) { onErrorCallBack = null; }
  33556. var onload = function (data) {
  33557. loadedFiles[index] = data;
  33558. loadedFiles._internalCount++;
  33559. if (loadedFiles._internalCount === 6) {
  33560. onfinish(loadedFiles);
  33561. }
  33562. };
  33563. var onerror = function (request, exception) {
  33564. if (onErrorCallBack && request) {
  33565. onErrorCallBack(request.status + " " + request.statusText, exception);
  33566. }
  33567. };
  33568. this._loadFile(url, onload, undefined, undefined, true, onerror);
  33569. };
  33570. Engine.prototype._cascadeLoadFiles = function (scene, onfinish, files, onError) {
  33571. if (onError === void 0) { onError = null; }
  33572. var loadedFiles = [];
  33573. loadedFiles._internalCount = 0;
  33574. for (var index = 0; index < 6; index++) {
  33575. this._partialLoadFile(files[index], index, loadedFiles, onfinish, onError);
  33576. }
  33577. };
  33578. // Statics
  33579. /**
  33580. * Gets a boolean indicating if the engine can be instanciated (ie. if a webGL context can be found)
  33581. * @returns true if the engine can be created
  33582. * @ignorenaming
  33583. */
  33584. Engine.isSupported = function () {
  33585. try {
  33586. var tempcanvas = document.createElement("canvas");
  33587. var gl = tempcanvas.getContext("webgl") || tempcanvas.getContext("experimental-webgl");
  33588. return gl != null && !!window.WebGLRenderingContext;
  33589. }
  33590. catch (e) {
  33591. return false;
  33592. }
  33593. };
  33594. /** Use this array to turn off some WebGL2 features on known buggy browsers version */
  33595. Engine.ExceptionList = [
  33596. { key: "Chrome/63.0", capture: "63\\.0\\.3239\\.(\\d+)", captureConstraint: 108, targets: ["uniformBuffer"] },
  33597. { key: "Firefox/58", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33598. { key: "Firefox/59", capture: null, captureConstraint: null, targets: ["uniformBuffer"] },
  33599. { key: "Macintosh", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33600. { key: "iPhone", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] },
  33601. { key: "iPad", capture: null, captureConstraint: null, targets: ["textureBindingOptimization"] }
  33602. ];
  33603. /**
  33604. * Hidden
  33605. */
  33606. Engine._TextureLoaders = [];
  33607. // Const statics
  33608. /** Defines that alpha blending is disabled */
  33609. Engine.ALPHA_DISABLE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_DISABLE;
  33610. /** Defines that alpha blending to SRC ALPHA * SRC + DEST */
  33611. Engine.ALPHA_ADD = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ADD;
  33612. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC ALPHA) * DEST */
  33613. Engine.ALPHA_COMBINE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_COMBINE;
  33614. /** Defines that alpha blending to DEST - SRC * DEST */
  33615. Engine.ALPHA_SUBTRACT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SUBTRACT;
  33616. /** Defines that alpha blending to SRC * DEST */
  33617. Engine.ALPHA_MULTIPLY = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MULTIPLY;
  33618. /** Defines that alpha blending to SRC ALPHA * SRC + (1 - SRC) * DEST */
  33619. Engine.ALPHA_MAXIMIZED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_MAXIMIZED;
  33620. /** Defines that alpha blending to SRC + DEST */
  33621. Engine.ALPHA_ONEONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_ONEONE;
  33622. /** Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST */
  33623. Engine.ALPHA_PREMULTIPLIED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED;
  33624. /**
  33625. * Defines that alpha blending to SRC + (1 - SRC ALPHA) * DEST
  33626. * Alpha will be set to (1 - SRC ALPHA) * DEST ALPHA
  33627. */
  33628. Engine.ALPHA_PREMULTIPLIED_PORTERDUFF = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  33629. /** Defines that alpha blending to CST * SRC + (1 - CST) * DEST */
  33630. Engine.ALPHA_INTERPOLATE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_INTERPOLATE;
  33631. /**
  33632. * Defines that alpha blending to SRC + (1 - SRC) * DEST
  33633. * Alpha will be set to SRC ALPHA + (1 - SRC ALPHA) * DEST ALPHA
  33634. */
  33635. Engine.ALPHA_SCREENMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALPHA_SCREENMODE;
  33636. /** Defines that the ressource is not delayed*/
  33637. Engine.DELAYLOADSTATE_NONE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NONE;
  33638. /** Defines that the ressource was successfully delay loaded */
  33639. Engine.DELAYLOADSTATE_LOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADED;
  33640. /** Defines that the ressource is currently delay loading */
  33641. Engine.DELAYLOADSTATE_LOADING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_LOADING;
  33642. /** Defines that the ressource is delayed and has not started loading */
  33643. Engine.DELAYLOADSTATE_NOTLOADED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DELAYLOADSTATE_NOTLOADED;
  33644. // Depht or Stencil test Constants.
  33645. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will never pass. i.e. Nothing will be drawn */
  33646. Engine.NEVER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NEVER;
  33647. /** 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 */
  33648. Engine.ALWAYS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].ALWAYS;
  33649. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is less than the stored value */
  33650. Engine.LESS = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LESS;
  33651. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is equals to the stored value */
  33652. Engine.EQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].EQUAL;
  33653. /** 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 */
  33654. Engine.LEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].LEQUAL;
  33655. /** Passed to depthFunction or stencilFunction to specify depth or stencil tests will pass if the new depth value is greater than the stored value */
  33656. Engine.GREATER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GREATER;
  33657. /** 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 */
  33658. Engine.GEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].GEQUAL;
  33659. /** 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 */
  33660. Engine.NOTEQUAL = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].NOTEQUAL;
  33661. // Stencil Actions Constants.
  33662. /** Passed to stencilOperation to specify that stencil value must be kept */
  33663. Engine.KEEP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].KEEP;
  33664. /** Passed to stencilOperation to specify that stencil value must be replaced */
  33665. Engine.REPLACE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].REPLACE;
  33666. /** Passed to stencilOperation to specify that stencil value must be incremented */
  33667. Engine.INCR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR;
  33668. /** Passed to stencilOperation to specify that stencil value must be decremented */
  33669. Engine.DECR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR;
  33670. /** Passed to stencilOperation to specify that stencil value must be inverted */
  33671. Engine.INVERT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INVERT;
  33672. /** Passed to stencilOperation to specify that stencil value must be incremented with wrapping */
  33673. Engine.INCR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].INCR_WRAP;
  33674. /** Passed to stencilOperation to specify that stencil value must be decremented with wrapping */
  33675. Engine.DECR_WRAP = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].DECR_WRAP;
  33676. /** Texture is not repeating outside of 0..1 UVs */
  33677. Engine.TEXTURE_CLAMP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  33678. /** Texture is repeating outside of 0..1 UVs */
  33679. Engine.TEXTURE_WRAP_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  33680. /** Texture is repeating and mirrored */
  33681. Engine.TEXTURE_MIRROR_ADDRESSMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  33682. /** ALPHA */
  33683. Engine.TEXTUREFORMAT_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_ALPHA;
  33684. /** LUMINANCE */
  33685. Engine.TEXTUREFORMAT_LUMINANCE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE;
  33686. /** LUMINANCE_ALPHA */
  33687. Engine.TEXTUREFORMAT_LUMINANCE_ALPHA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA;
  33688. /** RGB */
  33689. Engine.TEXTUREFORMAT_RGB = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB;
  33690. /** RGBA */
  33691. Engine.TEXTUREFORMAT_RGBA = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA;
  33692. /** RED */
  33693. Engine.TEXTUREFORMAT_RED = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED;
  33694. /** RED (2nd reference) */
  33695. Engine.TEXTUREFORMAT_R = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R;
  33696. /** RG */
  33697. Engine.TEXTUREFORMAT_RG = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG;
  33698. /** RED_INTEGER */
  33699. Engine.TEXTUREFORMAT_RED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RED_INTEGER;
  33700. /** RED_INTEGER (2nd reference) */
  33701. Engine.TEXTUREFORMAT_R_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_R_INTEGER;
  33702. /** RG_INTEGER */
  33703. Engine.TEXTUREFORMAT_RG_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RG_INTEGER;
  33704. /** RGB_INTEGER */
  33705. Engine.TEXTUREFORMAT_RGB_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGB_INTEGER;
  33706. /** RGBA_INTEGER */
  33707. Engine.TEXTUREFORMAT_RGBA_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTUREFORMAT_RGBA_INTEGER;
  33708. /** UNSIGNED_BYTE */
  33709. Engine.TEXTURETYPE_UNSIGNED_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_BYTE;
  33710. /** UNSIGNED_BYTE (2nd reference) */
  33711. Engine.TEXTURETYPE_UNSIGNED_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  33712. /** FLOAT */
  33713. Engine.TEXTURETYPE_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT;
  33714. /** HALF_FLOAT */
  33715. Engine.TEXTURETYPE_HALF_FLOAT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_HALF_FLOAT;
  33716. /** BYTE */
  33717. Engine.TEXTURETYPE_BYTE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_BYTE;
  33718. /** SHORT */
  33719. Engine.TEXTURETYPE_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_SHORT;
  33720. /** UNSIGNED_SHORT */
  33721. Engine.TEXTURETYPE_UNSIGNED_SHORT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT;
  33722. /** INT */
  33723. Engine.TEXTURETYPE_INT = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_INT;
  33724. /** UNSIGNED_INT */
  33725. Engine.TEXTURETYPE_UNSIGNED_INTEGER = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INTEGER;
  33726. /** UNSIGNED_SHORT_4_4_4_4 */
  33727. Engine.TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_4_4_4_4;
  33728. /** UNSIGNED_SHORT_5_5_5_1 */
  33729. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_5_5_1;
  33730. /** UNSIGNED_SHORT_5_6_5 */
  33731. Engine.TEXTURETYPE_UNSIGNED_SHORT_5_6_5 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_SHORT_5_6_5;
  33732. /** UNSIGNED_INT_2_10_10_10_REV */
  33733. Engine.TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_2_10_10_10_REV;
  33734. /** UNSIGNED_INT_24_8 */
  33735. Engine.TEXTURETYPE_UNSIGNED_INT_24_8 = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_24_8;
  33736. /** UNSIGNED_INT_10F_11F_11F_REV */
  33737. Engine.TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_10F_11F_11F_REV;
  33738. /** UNSIGNED_INT_5_9_9_9_REV */
  33739. Engine.TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_UNSIGNED_INT_5_9_9_9_REV;
  33740. /** FLOAT_32_UNSIGNED_INT_24_8_REV */
  33741. Engine.TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURETYPE_FLOAT_32_UNSIGNED_INT_24_8_REV;
  33742. /** nearest is mag = nearest and min = nearest and mip = linear */
  33743. Engine.TEXTURE_NEAREST_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  33744. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33745. Engine.TEXTURE_BILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  33746. /** Trilinear is mag = linear and min = linear and mip = linear */
  33747. Engine.TEXTURE_TRILINEAR_SAMPLINGMODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  33748. /** nearest is mag = nearest and min = nearest and mip = linear */
  33749. Engine.TEXTURE_NEAREST_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPLINEAR;
  33750. /** Bilinear is mag = linear and min = linear and mip = nearest */
  33751. Engine.TEXTURE_LINEAR_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPNEAREST;
  33752. /** Trilinear is mag = linear and min = linear and mip = linear */
  33753. Engine.TEXTURE_LINEAR_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR_MIPLINEAR;
  33754. /** mag = nearest and min = nearest and mip = nearest */
  33755. Engine.TEXTURE_NEAREST_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  33756. /** mag = nearest and min = linear and mip = nearest */
  33757. Engine.TEXTURE_NEAREST_LINEAR_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  33758. /** mag = nearest and min = linear and mip = linear */
  33759. Engine.TEXTURE_NEAREST_LINEAR_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  33760. /** mag = nearest and min = linear and mip = none */
  33761. Engine.TEXTURE_NEAREST_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_LINEAR;
  33762. /** mag = nearest and min = nearest and mip = none */
  33763. Engine.TEXTURE_NEAREST_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_NEAREST_NEAREST;
  33764. /** mag = linear and min = nearest and mip = nearest */
  33765. Engine.TEXTURE_LINEAR_NEAREST_MIPNEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  33766. /** mag = linear and min = nearest and mip = linear */
  33767. Engine.TEXTURE_LINEAR_NEAREST_MIPLINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  33768. /** mag = linear and min = linear and mip = none */
  33769. Engine.TEXTURE_LINEAR_LINEAR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_LINEAR;
  33770. /** mag = linear and min = nearest and mip = none */
  33771. Engine.TEXTURE_LINEAR_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_LINEAR_NEAREST;
  33772. /** Explicit coordinates mode */
  33773. Engine.TEXTURE_EXPLICIT_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EXPLICIT_MODE;
  33774. /** Spherical coordinates mode */
  33775. Engine.TEXTURE_SPHERICAL_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SPHERICAL_MODE;
  33776. /** Planar coordinates mode */
  33777. Engine.TEXTURE_PLANAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PLANAR_MODE;
  33778. /** Cubic coordinates mode */
  33779. Engine.TEXTURE_CUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_CUBIC_MODE;
  33780. /** Projection coordinates mode */
  33781. Engine.TEXTURE_PROJECTION_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_PROJECTION_MODE;
  33782. /** Skybox coordinates mode */
  33783. Engine.TEXTURE_SKYBOX_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_SKYBOX_MODE;
  33784. /** Inverse Cubic coordinates mode */
  33785. Engine.TEXTURE_INVCUBIC_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_INVCUBIC_MODE;
  33786. /** Equirectangular coordinates mode */
  33787. Engine.TEXTURE_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  33788. /** Equirectangular Fixed coordinates mode */
  33789. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  33790. /** Equirectangular Fixed Mirrored coordinates mode */
  33791. Engine.TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  33792. // Texture rescaling mode
  33793. /** Defines that texture rescaling will use a floor to find the closer power of 2 size */
  33794. Engine.SCALEMODE_FLOOR = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_FLOOR;
  33795. /** Defines that texture rescaling will look for the nearest power of 2 size */
  33796. Engine.SCALEMODE_NEAREST = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_NEAREST;
  33797. /** Defines that texture rescaling will use a ceil to find the closer power of 2 size */
  33798. Engine.SCALEMODE_CEILING = _constants__WEBPACK_IMPORTED_MODULE_13__["Constants"].SCALEMODE_CEILING;
  33799. // Updatable statics so stick with vars here
  33800. /**
  33801. * Gets or sets the epsilon value used by collision engine
  33802. */
  33803. Engine.CollisionsEpsilon = 0.001;
  33804. /**
  33805. * Method called to create the default rescale post process on each engine.
  33806. */
  33807. Engine._RescalePostProcessFactory = null;
  33808. return Engine;
  33809. }());
  33810. /***/ }),
  33811. /***/ "./Engines/engineStore.ts":
  33812. /*!********************************!*\
  33813. !*** ./Engines/engineStore.ts ***!
  33814. \********************************/
  33815. /*! exports provided: EngineStore */
  33816. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33817. "use strict";
  33818. __webpack_require__.r(__webpack_exports__);
  33819. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return EngineStore; });
  33820. /**
  33821. * The engine store class is responsible to hold all the instances of Engine and Scene created
  33822. * during the life time of the application.
  33823. */
  33824. var EngineStore = /** @class */ (function () {
  33825. function EngineStore() {
  33826. }
  33827. Object.defineProperty(EngineStore, "LastCreatedEngine", {
  33828. /**
  33829. * Gets the latest created engine
  33830. */
  33831. get: function () {
  33832. if (this.Instances.length === 0) {
  33833. return null;
  33834. }
  33835. return this.Instances[this.Instances.length - 1];
  33836. },
  33837. enumerable: true,
  33838. configurable: true
  33839. });
  33840. Object.defineProperty(EngineStore, "LastCreatedScene", {
  33841. /**
  33842. * Gets the latest created scene
  33843. */
  33844. get: function () {
  33845. var lastCreatedEngine = this.LastCreatedEngine;
  33846. if (!lastCreatedEngine) {
  33847. return null;
  33848. }
  33849. if (lastCreatedEngine.scenes.length === 0) {
  33850. return null;
  33851. }
  33852. return lastCreatedEngine.scenes[lastCreatedEngine.scenes.length - 1];
  33853. },
  33854. enumerable: true,
  33855. configurable: true
  33856. });
  33857. /** Gets the list of created engines */
  33858. EngineStore.Instances = new Array();
  33859. return EngineStore;
  33860. }());
  33861. /***/ }),
  33862. /***/ "./Engines/index.ts":
  33863. /*!**************************!*\
  33864. !*** ./Engines/index.ts ***!
  33865. \**************************/
  33866. /*! exports provided: Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, _OcclusionDataStorage, _forceTransformFeedbackToBundle */
  33867. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33868. "use strict";
  33869. __webpack_require__.r(__webpack_exports__);
  33870. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33871. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _constants__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  33872. /* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ "./Engines/engine.ts");
  33873. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["InstancingAttributeInfo"]; });
  33874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["DepthTextureCreationOptions"]; });
  33875. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["EngineCapabilities"]; });
  33876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]; });
  33877. /* harmony import */ var _engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engineStore */ "./Engines/engineStore.ts");
  33878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"]; });
  33879. /* harmony import */ var _nullEngine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./nullEngine */ "./Engines/nullEngine.ts");
  33880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngineOptions"]; });
  33881. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _nullEngine__WEBPACK_IMPORTED_MODULE_3__["NullEngine"]; });
  33882. /* harmony import */ var _Extensions_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Extensions/index */ "./Engines/Extensions/index.ts");
  33883. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_OcclusionDataStorage"]; });
  33884. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Extensions_index__WEBPACK_IMPORTED_MODULE_4__["_forceTransformFeedbackToBundle"]; });
  33885. /***/ }),
  33886. /***/ "./Engines/nullEngine.ts":
  33887. /*!*******************************!*\
  33888. !*** ./Engines/nullEngine.ts ***!
  33889. \*******************************/
  33890. /*! exports provided: NullEngineOptions, NullEngine */
  33891. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  33892. "use strict";
  33893. __webpack_require__.r(__webpack_exports__);
  33894. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return NullEngineOptions; });
  33895. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return NullEngine; });
  33896. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  33897. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  33898. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  33899. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  33900. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  33901. /* harmony import */ var _constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./constants */ "./Engines/constants.ts");
  33902. /**
  33903. * Options to create the null engine
  33904. */
  33905. var NullEngineOptions = /** @class */ (function () {
  33906. function NullEngineOptions() {
  33907. /**
  33908. * Render width (Default: 512)
  33909. */
  33910. this.renderWidth = 512;
  33911. /**
  33912. * Render height (Default: 256)
  33913. */
  33914. this.renderHeight = 256;
  33915. /**
  33916. * Texture size (Default: 512)
  33917. */
  33918. this.textureSize = 512;
  33919. /**
  33920. * If delta time between frames should be constant
  33921. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33922. */
  33923. this.deterministicLockstep = false;
  33924. /**
  33925. * Maximum about of steps between frames (Default: 4)
  33926. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33927. */
  33928. this.lockstepMaxSteps = 4;
  33929. }
  33930. return NullEngineOptions;
  33931. }());
  33932. /**
  33933. * The null engine class provides support for headless version of babylon.js.
  33934. * This can be used in server side scenario or for testing purposes
  33935. */
  33936. var NullEngine = /** @class */ (function (_super) {
  33937. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NullEngine, _super);
  33938. function NullEngine(options) {
  33939. if (options === void 0) { options = new NullEngineOptions(); }
  33940. var _this = _super.call(this, null) || this;
  33941. if (options.deterministicLockstep === undefined) {
  33942. options.deterministicLockstep = false;
  33943. }
  33944. if (options.lockstepMaxSteps === undefined) {
  33945. options.lockstepMaxSteps = 4;
  33946. }
  33947. _this._options = options;
  33948. // Init caps
  33949. // We consider we are on a webgl1 capable device
  33950. _this._caps = new _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["EngineCapabilities"]();
  33951. _this._caps.maxTexturesImageUnits = 16;
  33952. _this._caps.maxVertexTextureImageUnits = 16;
  33953. _this._caps.maxTextureSize = 512;
  33954. _this._caps.maxCubemapTextureSize = 512;
  33955. _this._caps.maxRenderTextureSize = 512;
  33956. _this._caps.maxVertexAttribs = 16;
  33957. _this._caps.maxVaryingVectors = 16;
  33958. _this._caps.maxFragmentUniformVectors = 16;
  33959. _this._caps.maxVertexUniformVectors = 16;
  33960. // Extensions
  33961. _this._caps.standardDerivatives = false;
  33962. _this._caps.astc = null;
  33963. _this._caps.s3tc = null;
  33964. _this._caps.pvrtc = null;
  33965. _this._caps.etc1 = null;
  33966. _this._caps.etc2 = null;
  33967. _this._caps.textureAnisotropicFilterExtension = null;
  33968. _this._caps.maxAnisotropy = 0;
  33969. _this._caps.uintIndices = false;
  33970. _this._caps.fragmentDepthSupported = false;
  33971. _this._caps.highPrecisionShaderSupported = true;
  33972. _this._caps.colorBufferFloat = false;
  33973. _this._caps.textureFloat = false;
  33974. _this._caps.textureFloatLinearFiltering = false;
  33975. _this._caps.textureFloatRender = false;
  33976. _this._caps.textureHalfFloat = false;
  33977. _this._caps.textureHalfFloatLinearFiltering = false;
  33978. _this._caps.textureHalfFloatRender = false;
  33979. _this._caps.textureLOD = false;
  33980. _this._caps.drawBuffersExtension = false;
  33981. _this._caps.depthTextureExtension = false;
  33982. _this._caps.vertexArrayObject = false;
  33983. _this._caps.instancedArrays = false;
  33984. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log("Babylon.js v" + _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].Version + " - Null engine");
  33985. // Wrappers
  33986. if (typeof URL === "undefined") {
  33987. URL = {
  33988. createObjectURL: function () { },
  33989. revokeObjectURL: function () { }
  33990. };
  33991. }
  33992. if (typeof Blob === "undefined") {
  33993. Blob = function () { };
  33994. }
  33995. return _this;
  33996. }
  33997. /**
  33998. * @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  33999. */
  34000. NullEngine.prototype.isDeterministicLockStep = function () {
  34001. return this._options.deterministicLockstep;
  34002. };
  34003. /** @see https://doc.babylonjs.com/babylon101/animations#deterministic-lockstep */
  34004. NullEngine.prototype.getLockstepMaxSteps = function () {
  34005. return this._options.lockstepMaxSteps;
  34006. };
  34007. /**
  34008. * Sets hardware scaling, used to save performance if needed
  34009. * @see https://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  34010. */
  34011. NullEngine.prototype.getHardwareScalingLevel = function () {
  34012. return 1.0;
  34013. };
  34014. NullEngine.prototype.createVertexBuffer = function (vertices) {
  34015. return {
  34016. capacity: 0,
  34017. references: 1,
  34018. is32Bits: false
  34019. };
  34020. };
  34021. NullEngine.prototype.createIndexBuffer = function (indices) {
  34022. return {
  34023. capacity: 0,
  34024. references: 1,
  34025. is32Bits: false
  34026. };
  34027. };
  34028. NullEngine.prototype.clear = function (color, backBuffer, depth, stencil) {
  34029. if (stencil === void 0) { stencil = false; }
  34030. };
  34031. NullEngine.prototype.getRenderWidth = function (useScreen) {
  34032. if (useScreen === void 0) { useScreen = false; }
  34033. if (!useScreen && this._currentRenderTarget) {
  34034. return this._currentRenderTarget.width;
  34035. }
  34036. return this._options.renderWidth;
  34037. };
  34038. NullEngine.prototype.getRenderHeight = function (useScreen) {
  34039. if (useScreen === void 0) { useScreen = false; }
  34040. if (!useScreen && this._currentRenderTarget) {
  34041. return this._currentRenderTarget.height;
  34042. }
  34043. return this._options.renderHeight;
  34044. };
  34045. NullEngine.prototype.setViewport = function (viewport, requiredWidth, requiredHeight) {
  34046. this._cachedViewport = viewport;
  34047. };
  34048. NullEngine.prototype.createShaderProgram = function (vertexCode, fragmentCode, defines, context) {
  34049. return {
  34050. transformFeedback: null,
  34051. __SPECTOR_rebuildProgram: null,
  34052. isParallelCompiled: false
  34053. };
  34054. };
  34055. NullEngine.prototype.getUniforms = function (shaderProgram, uniformsNames) {
  34056. return [];
  34057. };
  34058. NullEngine.prototype.getAttributes = function (shaderProgram, attributesNames) {
  34059. return [];
  34060. };
  34061. NullEngine.prototype.bindSamplers = function (effect) {
  34062. this._currentEffect = null;
  34063. };
  34064. NullEngine.prototype.enableEffect = function (effect) {
  34065. this._currentEffect = effect;
  34066. if (effect.onBind) {
  34067. effect.onBind(effect);
  34068. }
  34069. if (effect._onBindObservable) {
  34070. effect._onBindObservable.notifyObservers(effect);
  34071. }
  34072. };
  34073. NullEngine.prototype.setState = function (culling, zOffset, force, reverseSide) {
  34074. if (zOffset === void 0) { zOffset = 0; }
  34075. if (reverseSide === void 0) { reverseSide = false; }
  34076. };
  34077. NullEngine.prototype.setIntArray = function (uniform, array) {
  34078. };
  34079. NullEngine.prototype.setIntArray2 = function (uniform, array) {
  34080. };
  34081. NullEngine.prototype.setIntArray3 = function (uniform, array) {
  34082. };
  34083. NullEngine.prototype.setIntArray4 = function (uniform, array) {
  34084. };
  34085. NullEngine.prototype.setFloatArray = function (uniform, array) {
  34086. };
  34087. NullEngine.prototype.setFloatArray2 = function (uniform, array) {
  34088. };
  34089. NullEngine.prototype.setFloatArray3 = function (uniform, array) {
  34090. };
  34091. NullEngine.prototype.setFloatArray4 = function (uniform, array) {
  34092. };
  34093. NullEngine.prototype.setArray = function (uniform, array) {
  34094. };
  34095. NullEngine.prototype.setArray2 = function (uniform, array) {
  34096. };
  34097. NullEngine.prototype.setArray3 = function (uniform, array) {
  34098. };
  34099. NullEngine.prototype.setArray4 = function (uniform, array) {
  34100. };
  34101. NullEngine.prototype.setMatrices = function (uniform, matrices) {
  34102. };
  34103. NullEngine.prototype.setMatrix = function (uniform, matrix) {
  34104. };
  34105. NullEngine.prototype.setMatrix3x3 = function (uniform, matrix) {
  34106. };
  34107. NullEngine.prototype.setMatrix2x2 = function (uniform, matrix) {
  34108. };
  34109. NullEngine.prototype.setFloat = function (uniform, value) {
  34110. };
  34111. NullEngine.prototype.setFloat2 = function (uniform, x, y) {
  34112. };
  34113. NullEngine.prototype.setFloat3 = function (uniform, x, y, z) {
  34114. };
  34115. NullEngine.prototype.setBool = function (uniform, bool) {
  34116. };
  34117. NullEngine.prototype.setFloat4 = function (uniform, x, y, z, w) {
  34118. };
  34119. NullEngine.prototype.setColor3 = function (uniform, color3) {
  34120. };
  34121. NullEngine.prototype.setColor4 = function (uniform, color3, alpha) {
  34122. };
  34123. NullEngine.prototype.setAlphaMode = function (mode, noDepthWriteChange) {
  34124. if (noDepthWriteChange === void 0) { noDepthWriteChange = false; }
  34125. if (this._alphaMode === mode) {
  34126. return;
  34127. }
  34128. this._alphaState.alphaBlend = (mode !== _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34129. if (!noDepthWriteChange) {
  34130. this.setDepthWrite(mode === _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].ALPHA_DISABLE);
  34131. }
  34132. this._alphaMode = mode;
  34133. };
  34134. NullEngine.prototype.bindBuffers = function (vertexBuffers, indexBuffer, effect) {
  34135. };
  34136. NullEngine.prototype.wipeCaches = function (bruteForce) {
  34137. if (this.preventCacheWipeBetweenFrames) {
  34138. return;
  34139. }
  34140. this.resetTextureCache();
  34141. this._currentEffect = null;
  34142. if (bruteForce) {
  34143. this._currentProgram = null;
  34144. this._stencilState.reset();
  34145. this._depthCullingState.reset();
  34146. this._alphaState.reset();
  34147. }
  34148. this._cachedVertexBuffers = null;
  34149. this._cachedIndexBuffer = null;
  34150. this._cachedEffectForVertexBuffers = null;
  34151. };
  34152. NullEngine.prototype.draw = function (useTriangles, indexStart, indexCount, instancesCount) {
  34153. };
  34154. NullEngine.prototype.drawElementsType = function (fillMode, indexStart, indexCount, instancesCount) {
  34155. };
  34156. NullEngine.prototype.drawArraysType = function (fillMode, verticesStart, verticesCount, instancesCount) {
  34157. };
  34158. /** @hidden */
  34159. NullEngine.prototype._createTexture = function () {
  34160. return {};
  34161. };
  34162. /** @hidden */
  34163. NullEngine.prototype._releaseTexture = function (texture) {
  34164. };
  34165. NullEngine.prototype.createTexture = function (urlArg, noMipmap, invertY, scene, samplingMode, onLoad, onError, buffer, fallBack, format) {
  34166. if (samplingMode === void 0) { samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  34167. if (onLoad === void 0) { onLoad = null; }
  34168. if (onError === void 0) { onError = null; }
  34169. if (buffer === void 0) { buffer = null; }
  34170. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_URL);
  34171. var url = String(urlArg);
  34172. texture.url = url;
  34173. texture.generateMipMaps = !noMipmap;
  34174. texture.samplingMode = samplingMode;
  34175. texture.invertY = invertY;
  34176. texture.baseWidth = this._options.textureSize;
  34177. texture.baseHeight = this._options.textureSize;
  34178. texture.width = this._options.textureSize;
  34179. texture.height = this._options.textureSize;
  34180. if (format) {
  34181. texture.format = format;
  34182. }
  34183. texture.isReady = true;
  34184. if (onLoad) {
  34185. onLoad();
  34186. }
  34187. this._internalTexturesCache.push(texture);
  34188. return texture;
  34189. };
  34190. NullEngine.prototype.createRenderTargetTexture = function (size, options) {
  34191. var fullOptions = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_3__["RenderTargetCreationOptions"]();
  34192. if (options !== undefined && typeof options === "object") {
  34193. fullOptions.generateMipMaps = options.generateMipMaps;
  34194. fullOptions.generateDepthBuffer = options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  34195. fullOptions.generateStencilBuffer = fullOptions.generateDepthBuffer && options.generateStencilBuffer;
  34196. fullOptions.type = options.type === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT : options.type;
  34197. fullOptions.samplingMode = options.samplingMode === undefined ? _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE : options.samplingMode;
  34198. }
  34199. else {
  34200. fullOptions.generateMipMaps = options;
  34201. fullOptions.generateDepthBuffer = true;
  34202. fullOptions.generateStencilBuffer = false;
  34203. fullOptions.type = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  34204. fullOptions.samplingMode = _constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  34205. }
  34206. var texture = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_RENDERTARGET);
  34207. var width = size.width || size;
  34208. var height = size.height || size;
  34209. texture._depthStencilBuffer = {};
  34210. texture._framebuffer = {};
  34211. texture.baseWidth = width;
  34212. texture.baseHeight = height;
  34213. texture.width = width;
  34214. texture.height = height;
  34215. texture.isReady = true;
  34216. texture.samples = 1;
  34217. texture.generateMipMaps = fullOptions.generateMipMaps ? true : false;
  34218. texture.samplingMode = fullOptions.samplingMode;
  34219. texture.type = fullOptions.type;
  34220. texture._generateDepthBuffer = fullOptions.generateDepthBuffer;
  34221. texture._generateStencilBuffer = fullOptions.generateStencilBuffer ? true : false;
  34222. this._internalTexturesCache.push(texture);
  34223. return texture;
  34224. };
  34225. NullEngine.prototype.updateTextureSamplingMode = function (samplingMode, texture) {
  34226. texture.samplingMode = samplingMode;
  34227. };
  34228. NullEngine.prototype.bindFramebuffer = function (texture, faceIndex, requiredWidth, requiredHeight, forceFullscreenViewport) {
  34229. if (this._currentRenderTarget) {
  34230. this.unBindFramebuffer(this._currentRenderTarget);
  34231. }
  34232. this._currentRenderTarget = texture;
  34233. this._currentFramebuffer = texture._MSAAFramebuffer ? texture._MSAAFramebuffer : texture._framebuffer;
  34234. if (this._cachedViewport && !forceFullscreenViewport) {
  34235. this.setViewport(this._cachedViewport, requiredWidth, requiredHeight);
  34236. }
  34237. };
  34238. NullEngine.prototype.unBindFramebuffer = function (texture, disableGenerateMipMaps, onBeforeUnbind) {
  34239. if (disableGenerateMipMaps === void 0) { disableGenerateMipMaps = false; }
  34240. this._currentRenderTarget = null;
  34241. if (onBeforeUnbind) {
  34242. if (texture._MSAAFramebuffer) {
  34243. this._currentFramebuffer = texture._framebuffer;
  34244. }
  34245. onBeforeUnbind();
  34246. }
  34247. this._currentFramebuffer = null;
  34248. };
  34249. NullEngine.prototype.createDynamicVertexBuffer = function (vertices) {
  34250. var vbo = {
  34251. capacity: 1,
  34252. references: 1,
  34253. is32Bits: false
  34254. };
  34255. return vbo;
  34256. };
  34257. NullEngine.prototype.updateDynamicTexture = function (texture, canvas, invertY, premulAlpha, format) {
  34258. if (premulAlpha === void 0) { premulAlpha = false; }
  34259. };
  34260. NullEngine.prototype.areAllEffectsReady = function () {
  34261. return true;
  34262. };
  34263. /**
  34264. * @hidden
  34265. * Get the current error code of the webGL context
  34266. * @returns the error code
  34267. * @see https://developer.mozilla.org/en-US/docs/Web/API/WebGLRenderingContext/getError
  34268. */
  34269. NullEngine.prototype.getError = function () {
  34270. return 0;
  34271. };
  34272. /** @hidden */
  34273. NullEngine.prototype._getUnpackAlignement = function () {
  34274. return 1;
  34275. };
  34276. /** @hidden */
  34277. NullEngine.prototype._unpackFlipY = function (value) {
  34278. };
  34279. NullEngine.prototype.updateDynamicIndexBuffer = function (indexBuffer, indices, offset) {
  34280. if (offset === void 0) { offset = 0; }
  34281. };
  34282. /**
  34283. * Updates a dynamic vertex buffer.
  34284. * @param vertexBuffer the vertex buffer to update
  34285. * @param data the data used to update the vertex buffer
  34286. * @param byteOffset the byte offset of the data (optional)
  34287. * @param byteLength the byte length of the data (optional)
  34288. */
  34289. NullEngine.prototype.updateDynamicVertexBuffer = function (vertexBuffer, vertices, byteOffset, byteLength) {
  34290. };
  34291. NullEngine.prototype._bindTextureDirectly = function (target, texture) {
  34292. if (this._boundTexturesCache[this._activeChannel] !== texture) {
  34293. this._boundTexturesCache[this._activeChannel] = texture;
  34294. return true;
  34295. }
  34296. return false;
  34297. };
  34298. /** @hidden */
  34299. NullEngine.prototype._bindTexture = function (channel, texture) {
  34300. if (channel < 0) {
  34301. return;
  34302. }
  34303. this._bindTextureDirectly(0, texture);
  34304. };
  34305. /** @hidden */
  34306. NullEngine.prototype._releaseBuffer = function (buffer) {
  34307. buffer.references--;
  34308. if (buffer.references === 0) {
  34309. return true;
  34310. }
  34311. return false;
  34312. };
  34313. NullEngine.prototype.releaseEffects = function () {
  34314. };
  34315. NullEngine.prototype.displayLoadingUI = function () {
  34316. };
  34317. NullEngine.prototype.hideLoadingUI = function () {
  34318. };
  34319. /** @hidden */
  34320. NullEngine.prototype._uploadCompressedDataToTextureDirectly = function (texture, internalFormat, width, height, data, faceIndex, lod) {
  34321. if (faceIndex === void 0) { faceIndex = 0; }
  34322. if (lod === void 0) { lod = 0; }
  34323. };
  34324. /** @hidden */
  34325. NullEngine.prototype._uploadDataToTextureDirectly = function (texture, imageData, faceIndex, lod) {
  34326. if (faceIndex === void 0) { faceIndex = 0; }
  34327. if (lod === void 0) { lod = 0; }
  34328. };
  34329. /** @hidden */
  34330. NullEngine.prototype._uploadArrayBufferViewToTexture = function (texture, imageData, faceIndex, lod) {
  34331. if (faceIndex === void 0) { faceIndex = 0; }
  34332. if (lod === void 0) { lod = 0; }
  34333. };
  34334. /** @hidden */
  34335. NullEngine.prototype._uploadImageToTexture = function (texture, image, faceIndex, lod) {
  34336. if (faceIndex === void 0) { faceIndex = 0; }
  34337. if (lod === void 0) { lod = 0; }
  34338. };
  34339. return NullEngine;
  34340. }(_Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]));
  34341. /***/ }),
  34342. /***/ "./Events/clipboardEvents.ts":
  34343. /*!***********************************!*\
  34344. !*** ./Events/clipboardEvents.ts ***!
  34345. \***********************************/
  34346. /*! exports provided: ClipboardEventTypes, ClipboardInfo */
  34347. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34348. "use strict";
  34349. __webpack_require__.r(__webpack_exports__);
  34350. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return ClipboardEventTypes; });
  34351. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return ClipboardInfo; });
  34352. /**
  34353. * Gather the list of clipboard event types as constants.
  34354. */
  34355. var ClipboardEventTypes = /** @class */ (function () {
  34356. function ClipboardEventTypes() {
  34357. }
  34358. /**
  34359. * The clipboard event is fired when a copy command is active (pressed).
  34360. */
  34361. ClipboardEventTypes.COPY = 0x01; //
  34362. /**
  34363. * The clipboard event is fired when a cut command is active (pressed).
  34364. */
  34365. ClipboardEventTypes.CUT = 0x02;
  34366. /**
  34367. * The clipboard event is fired when a paste command is active (pressed).
  34368. */
  34369. ClipboardEventTypes.PASTE = 0x03;
  34370. return ClipboardEventTypes;
  34371. }());
  34372. /**
  34373. * This class is used to store clipboard related info for the onClipboardObservable event.
  34374. */
  34375. var ClipboardInfo = /** @class */ (function () {
  34376. /**
  34377. *Creates an instance of ClipboardInfo.
  34378. * @param type Defines the type of event (BABYLON.ClipboardEventTypes)
  34379. * @param event Defines the related dom event
  34380. */
  34381. function ClipboardInfo(
  34382. /**
  34383. * Defines the type of event (BABYLON.ClipboardEventTypes)
  34384. */
  34385. type,
  34386. /**
  34387. * Defines the related dom event
  34388. */
  34389. event) {
  34390. this.type = type;
  34391. this.event = event;
  34392. }
  34393. /**
  34394. * Get the clipboard event's type from the keycode.
  34395. * @param keyCode Defines the keyCode for the current keyboard event.
  34396. * @return {number}
  34397. */
  34398. ClipboardInfo.GetTypeFromCharacter = function (keyCode) {
  34399. var charCode = keyCode;
  34400. //TODO: add codes for extended ASCII
  34401. switch (charCode) {
  34402. case 67: return ClipboardEventTypes.COPY;
  34403. case 86: return ClipboardEventTypes.PASTE;
  34404. case 88: return ClipboardEventTypes.CUT;
  34405. default: return -1;
  34406. }
  34407. };
  34408. return ClipboardInfo;
  34409. }());
  34410. /***/ }),
  34411. /***/ "./Events/index.ts":
  34412. /*!*************************!*\
  34413. !*** ./Events/index.ts ***!
  34414. \*************************/
  34415. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo */
  34416. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34417. "use strict";
  34418. __webpack_require__.r(__webpack_exports__);
  34419. /* harmony import */ var _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./keyboardEvents */ "./Events/keyboardEvents.ts");
  34420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  34421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  34422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _keyboardEvents__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  34423. /* harmony import */ var _pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pointerEvents */ "./Events/pointerEvents.ts");
  34424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"]; });
  34425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoBase"]; });
  34426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfoPre"]; });
  34427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerInfo"]; });
  34428. /* harmony import */ var _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./clipboardEvents */ "./Events/clipboardEvents.ts");
  34429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardEventTypes"]; });
  34430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _clipboardEvents__WEBPACK_IMPORTED_MODULE_2__["ClipboardInfo"]; });
  34431. /***/ }),
  34432. /***/ "./Events/keyboardEvents.ts":
  34433. /*!**********************************!*\
  34434. !*** ./Events/keyboardEvents.ts ***!
  34435. \**********************************/
  34436. /*! exports provided: KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre */
  34437. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34438. "use strict";
  34439. __webpack_require__.r(__webpack_exports__);
  34440. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return KeyboardEventTypes; });
  34441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return KeyboardInfo; });
  34442. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return KeyboardInfoPre; });
  34443. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34444. /**
  34445. * Gather the list of keyboard event types as constants.
  34446. */
  34447. var KeyboardEventTypes = /** @class */ (function () {
  34448. function KeyboardEventTypes() {
  34449. }
  34450. /**
  34451. * The keydown event is fired when a key becomes active (pressed).
  34452. */
  34453. KeyboardEventTypes.KEYDOWN = 0x01;
  34454. /**
  34455. * The keyup event is fired when a key has been released.
  34456. */
  34457. KeyboardEventTypes.KEYUP = 0x02;
  34458. return KeyboardEventTypes;
  34459. }());
  34460. /**
  34461. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34462. */
  34463. var KeyboardInfo = /** @class */ (function () {
  34464. /**
  34465. * Instantiates a new keyboard info.
  34466. * This class is used to store keyboard related info for the onKeyboardObservable event.
  34467. * @param type Defines the type of event (KeyboardEventTypes)
  34468. * @param event Defines the related dom event
  34469. */
  34470. function KeyboardInfo(
  34471. /**
  34472. * Defines the type of event (KeyboardEventTypes)
  34473. */
  34474. type,
  34475. /**
  34476. * Defines the related dom event
  34477. */
  34478. event) {
  34479. this.type = type;
  34480. this.event = event;
  34481. }
  34482. return KeyboardInfo;
  34483. }());
  34484. /**
  34485. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34486. * Set the skipOnKeyboardObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onKeyboardObservable
  34487. */
  34488. var KeyboardInfoPre = /** @class */ (function (_super) {
  34489. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeyboardInfoPre, _super);
  34490. /**
  34491. * Instantiates a new keyboard pre info.
  34492. * This class is used to store keyboard related info for the onPreKeyboardObservable event.
  34493. * @param type Defines the type of event (KeyboardEventTypes)
  34494. * @param event Defines the related dom event
  34495. */
  34496. function KeyboardInfoPre(
  34497. /**
  34498. * Defines the type of event (KeyboardEventTypes)
  34499. */
  34500. type,
  34501. /**
  34502. * Defines the related dom event
  34503. */
  34504. event) {
  34505. var _this = _super.call(this, type, event) || this;
  34506. _this.type = type;
  34507. _this.event = event;
  34508. _this.skipOnPointerObservable = false;
  34509. return _this;
  34510. }
  34511. return KeyboardInfoPre;
  34512. }(KeyboardInfo));
  34513. /***/ }),
  34514. /***/ "./Events/pointerEvents.ts":
  34515. /*!*********************************!*\
  34516. !*** ./Events/pointerEvents.ts ***!
  34517. \*********************************/
  34518. /*! exports provided: PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo */
  34519. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34520. "use strict";
  34521. __webpack_require__.r(__webpack_exports__);
  34522. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return PointerEventTypes; });
  34523. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return PointerInfoBase; });
  34524. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return PointerInfoPre; });
  34525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return PointerInfo; });
  34526. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34527. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  34528. /**
  34529. * Gather the list of pointer event types as constants.
  34530. */
  34531. var PointerEventTypes = /** @class */ (function () {
  34532. function PointerEventTypes() {
  34533. }
  34534. /**
  34535. * 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.
  34536. */
  34537. PointerEventTypes.POINTERDOWN = 0x01;
  34538. /**
  34539. * The pointerup event is fired when a pointer is no longer active.
  34540. */
  34541. PointerEventTypes.POINTERUP = 0x02;
  34542. /**
  34543. * The pointermove event is fired when a pointer changes coordinates.
  34544. */
  34545. PointerEventTypes.POINTERMOVE = 0x04;
  34546. /**
  34547. * The pointerwheel event is fired when a mouse wheel has been rotated.
  34548. */
  34549. PointerEventTypes.POINTERWHEEL = 0x08;
  34550. /**
  34551. * The pointerpick event is fired when a mesh or sprite has been picked by the pointer.
  34552. */
  34553. PointerEventTypes.POINTERPICK = 0x10;
  34554. /**
  34555. * The pointertap event is fired when a the object has been touched and released without drag.
  34556. */
  34557. PointerEventTypes.POINTERTAP = 0x20;
  34558. /**
  34559. * The pointerdoubletap event is fired when a the object has been touched and released twice without drag.
  34560. */
  34561. PointerEventTypes.POINTERDOUBLETAP = 0x40;
  34562. return PointerEventTypes;
  34563. }());
  34564. /**
  34565. * Base class of pointer info types.
  34566. */
  34567. var PointerInfoBase = /** @class */ (function () {
  34568. /**
  34569. * Instantiates the base class of pointers info.
  34570. * @param type Defines the type of event (PointerEventTypes)
  34571. * @param event Defines the related dom event
  34572. */
  34573. function PointerInfoBase(
  34574. /**
  34575. * Defines the type of event (PointerEventTypes)
  34576. */
  34577. type,
  34578. /**
  34579. * Defines the related dom event
  34580. */
  34581. event) {
  34582. this.type = type;
  34583. this.event = event;
  34584. }
  34585. return PointerInfoBase;
  34586. }());
  34587. /**
  34588. * This class is used to store pointer related info for the onPrePointerObservable event.
  34589. * Set the skipOnPointerObservable property to true if you want the engine to stop any process after this event is triggered, even not calling onPointerObservable
  34590. */
  34591. var PointerInfoPre = /** @class */ (function (_super) {
  34592. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfoPre, _super);
  34593. /**
  34594. * Instantiates a PointerInfoPre to store pointer related info to the onPrePointerObservable event.
  34595. * @param type Defines the type of event (PointerEventTypes)
  34596. * @param event Defines the related dom event
  34597. * @param localX Defines the local x coordinates of the pointer when the event occured
  34598. * @param localY Defines the local y coordinates of the pointer when the event occured
  34599. */
  34600. function PointerInfoPre(type, event, localX, localY) {
  34601. var _this = _super.call(this, type, event) || this;
  34602. /**
  34603. * Ray from a pointer if availible (eg. 6dof controller)
  34604. */
  34605. _this.ray = null;
  34606. _this.skipOnPointerObservable = false;
  34607. _this.localPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](localX, localY);
  34608. return _this;
  34609. }
  34610. return PointerInfoPre;
  34611. }(PointerInfoBase));
  34612. /**
  34613. * This type contains all the data related to a pointer event in Babylon.js.
  34614. * 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.
  34615. */
  34616. var PointerInfo = /** @class */ (function (_super) {
  34617. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointerInfo, _super);
  34618. /**
  34619. * Instantiates a PointerInfo to store pointer related info to the onPointerObservable event.
  34620. * @param type Defines the type of event (PointerEventTypes)
  34621. * @param event Defines the related dom event
  34622. * @param pickInfo Defines the picking info associated to the info (if any)\
  34623. */
  34624. function PointerInfo(type, event,
  34625. /**
  34626. * Defines the picking info associated to the info (if any)\
  34627. */
  34628. pickInfo) {
  34629. var _this = _super.call(this, type, event) || this;
  34630. _this.pickInfo = pickInfo;
  34631. return _this;
  34632. }
  34633. return PointerInfo;
  34634. }(PointerInfoBase));
  34635. /***/ }),
  34636. /***/ "./Gamepads/Controllers/daydreamController.ts":
  34637. /*!****************************************************!*\
  34638. !*** ./Gamepads/Controllers/daydreamController.ts ***!
  34639. \****************************************************/
  34640. /*! exports provided: DaydreamController */
  34641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34642. "use strict";
  34643. __webpack_require__.r(__webpack_exports__);
  34644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return DaydreamController; });
  34645. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34646. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  34647. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34648. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34649. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34650. /**
  34651. * Google Daydream controller
  34652. */
  34653. var DaydreamController = /** @class */ (function (_super) {
  34654. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DaydreamController, _super);
  34655. /**
  34656. * Creates a new DaydreamController from a gamepad
  34657. * @param vrGamepad the gamepad that the controller should be created from
  34658. */
  34659. function DaydreamController(vrGamepad) {
  34660. var _this = _super.call(this, vrGamepad) || this;
  34661. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].DAYDREAM;
  34662. return _this;
  34663. }
  34664. /**
  34665. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34666. * @param scene scene in which to add meshes
  34667. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34668. */
  34669. DaydreamController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34670. var _this = this;
  34671. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", DaydreamController.MODEL_BASE_URL, DaydreamController.MODEL_FILENAME, scene, function (newMeshes) {
  34672. _this._defaultModel = newMeshes[1];
  34673. _this.attachToMesh(_this._defaultModel);
  34674. if (meshLoaded) {
  34675. meshLoaded(_this._defaultModel);
  34676. }
  34677. });
  34678. };
  34679. /**
  34680. * Called once for each button that changed state since the last frame
  34681. * @param buttonIdx Which button index changed
  34682. * @param state New state of the button
  34683. * @param changes Which properties on the state changed since last frame
  34684. */
  34685. DaydreamController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34686. // Daydream controller only has 1 GamepadButton (on the trackpad).
  34687. if (buttonIdx === 0) {
  34688. var observable = this.onTriggerStateChangedObservable;
  34689. if (observable) {
  34690. observable.notifyObservers(state);
  34691. }
  34692. }
  34693. else {
  34694. // If the app or home buttons are ever made available
  34695. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Unrecognized Daydream button index: " + buttonIdx);
  34696. }
  34697. };
  34698. /**
  34699. * Base Url for the controller model.
  34700. */
  34701. DaydreamController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34702. /**
  34703. * File name for the controller model.
  34704. */
  34705. DaydreamController.MODEL_FILENAME = 'generic.babylon';
  34706. /**
  34707. * Gamepad Id prefix used to identify Daydream Controller.
  34708. */
  34709. DaydreamController.GAMEPAD_ID_PREFIX = 'Daydream'; // id is 'Daydream Controller'
  34710. return DaydreamController;
  34711. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  34712. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34713. canCreate: function (gamepadInfo) {
  34714. return gamepadInfo.id.indexOf(DaydreamController.GAMEPAD_ID_PREFIX) === 0;
  34715. },
  34716. create: function (gamepadInfo) {
  34717. return new DaydreamController(gamepadInfo);
  34718. }
  34719. });
  34720. /***/ }),
  34721. /***/ "./Gamepads/Controllers/gearVRController.ts":
  34722. /*!**************************************************!*\
  34723. !*** ./Gamepads/Controllers/gearVRController.ts ***!
  34724. \**************************************************/
  34725. /*! exports provided: GearVRController */
  34726. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34727. "use strict";
  34728. __webpack_require__.r(__webpack_exports__);
  34729. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return GearVRController; });
  34730. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34731. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  34732. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  34733. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34734. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34735. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34736. /**
  34737. * Gear VR Controller
  34738. */
  34739. var GearVRController = /** @class */ (function (_super) {
  34740. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GearVRController, _super);
  34741. /**
  34742. * Creates a new GearVRController from a gamepad
  34743. * @param vrGamepad the gamepad that the controller should be created from
  34744. */
  34745. function GearVRController(vrGamepad) {
  34746. var _this = _super.call(this, vrGamepad) || this;
  34747. _this._buttonIndexToObservableNameMap = [
  34748. 'onTrackpadChangedObservable',
  34749. 'onTriggerStateChangedObservable' // Trigger
  34750. ];
  34751. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerType"].GEAR_VR;
  34752. // Initial starting position defaults to where hand would be (incase of only 3dof controller)
  34753. _this._calculatedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](_this.hand == "left" ? -0.15 : 0.15, -0.5, 0.25);
  34754. _this._disableTrackPosition(_this._calculatedPosition);
  34755. return _this;
  34756. }
  34757. /**
  34758. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34759. * @param scene scene in which to add meshes
  34760. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34761. */
  34762. GearVRController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34763. var _this = this;
  34764. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_3__["SceneLoader"].ImportMesh("", GearVRController.MODEL_BASE_URL, GearVRController.MODEL_FILENAME, scene, function (newMeshes) {
  34765. // Offset the controller so it will rotate around the users wrist
  34766. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", scene);
  34767. newMeshes[1].parent = mesh;
  34768. newMeshes[1].position.z = -0.15;
  34769. _this._defaultModel = mesh;
  34770. _this.attachToMesh(_this._defaultModel);
  34771. if (meshLoaded) {
  34772. meshLoaded(_this._defaultModel);
  34773. }
  34774. });
  34775. };
  34776. /**
  34777. * Called once for each button that changed state since the last frame
  34778. * @param buttonIdx Which button index changed
  34779. * @param state New state of the button
  34780. * @param changes Which properties on the state changed since last frame
  34781. */
  34782. GearVRController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34783. if (buttonIdx < this._buttonIndexToObservableNameMap.length) {
  34784. var observableName = this._buttonIndexToObservableNameMap[buttonIdx];
  34785. // Only emit events for buttons that we know how to map from index to observable
  34786. var observable = this[observableName];
  34787. if (observable) {
  34788. observable.notifyObservers(state);
  34789. }
  34790. }
  34791. };
  34792. /**
  34793. * Base Url for the controller model.
  34794. */
  34795. GearVRController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34796. /**
  34797. * File name for the controller model.
  34798. */
  34799. GearVRController.MODEL_FILENAME = 'generic.babylon';
  34800. /**
  34801. * Gamepad Id prefix used to identify this controller.
  34802. */
  34803. GearVRController.GAMEPAD_ID_PREFIX = 'Gear VR'; // id is 'Gear VR Controller'
  34804. return GearVRController;
  34805. }(_webVRController__WEBPACK_IMPORTED_MODULE_4__["WebVRController"]));
  34806. _poseEnabledController__WEBPACK_IMPORTED_MODULE_5__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  34807. canCreate: function (gamepadInfo) {
  34808. return gamepadInfo.id.indexOf(GearVRController.GAMEPAD_ID_PREFIX) === 0 ||
  34809. gamepadInfo.id.indexOf('Oculus Go') !== -1;
  34810. },
  34811. create: function (gamepadInfo) {
  34812. return new GearVRController(gamepadInfo);
  34813. }
  34814. });
  34815. /***/ }),
  34816. /***/ "./Gamepads/Controllers/genericController.ts":
  34817. /*!***************************************************!*\
  34818. !*** ./Gamepads/Controllers/genericController.ts ***!
  34819. \***************************************************/
  34820. /*! exports provided: GenericController */
  34821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34822. "use strict";
  34823. __webpack_require__.r(__webpack_exports__);
  34824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return GenericController; });
  34825. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34826. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34827. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34828. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34829. /**
  34830. * Generic Controller
  34831. */
  34832. var GenericController = /** @class */ (function (_super) {
  34833. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericController, _super);
  34834. /**
  34835. * Creates a new GenericController from a gamepad
  34836. * @param vrGamepad the gamepad that the controller should be created from
  34837. */
  34838. function GenericController(vrGamepad) {
  34839. return _super.call(this, vrGamepad) || this;
  34840. }
  34841. /**
  34842. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34843. * @param scene scene in which to add meshes
  34844. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34845. */
  34846. GenericController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34847. var _this = this;
  34848. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", GenericController.MODEL_BASE_URL, GenericController.MODEL_FILENAME, scene, function (newMeshes) {
  34849. _this._defaultModel = newMeshes[1];
  34850. _this.attachToMesh(_this._defaultModel);
  34851. if (meshLoaded) {
  34852. meshLoaded(_this._defaultModel);
  34853. }
  34854. });
  34855. };
  34856. /**
  34857. * Called once for each button that changed state since the last frame
  34858. * @param buttonIdx Which button index changed
  34859. * @param state New state of the button
  34860. * @param changes Which properties on the state changed since last frame
  34861. */
  34862. GenericController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  34863. console.log("Button id: " + buttonIdx + "state: ");
  34864. console.dir(state);
  34865. };
  34866. /**
  34867. * Base Url for the controller model.
  34868. */
  34869. GenericController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/generic/';
  34870. /**
  34871. * File name for the controller model.
  34872. */
  34873. GenericController.MODEL_FILENAME = 'generic.babylon';
  34874. return GenericController;
  34875. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  34876. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._DefaultControllerFactory = function (gamepadInfo) { return new GenericController(gamepadInfo); };
  34877. /***/ }),
  34878. /***/ "./Gamepads/Controllers/index.ts":
  34879. /*!***************************************!*\
  34880. !*** ./Gamepads/Controllers/index.ts ***!
  34881. \***************************************/
  34882. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController */
  34883. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34884. "use strict";
  34885. __webpack_require__.r(__webpack_exports__);
  34886. /* harmony import */ var _daydreamController__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./daydreamController */ "./Gamepads/Controllers/daydreamController.ts");
  34887. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _daydreamController__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  34888. /* harmony import */ var _gearVRController__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gearVRController */ "./Gamepads/Controllers/gearVRController.ts");
  34889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _gearVRController__WEBPACK_IMPORTED_MODULE_1__["GearVRController"]; });
  34890. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  34891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _genericController__WEBPACK_IMPORTED_MODULE_2__["GenericController"]; });
  34892. /* harmony import */ var _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./oculusTouchController */ "./Gamepads/Controllers/oculusTouchController.ts");
  34893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _oculusTouchController__WEBPACK_IMPORTED_MODULE_3__["OculusTouchController"]; });
  34894. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"]; });
  34896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]; });
  34897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledController"]; });
  34898. /* harmony import */ var _viveController__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./viveController */ "./Gamepads/Controllers/viveController.ts");
  34899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _viveController__WEBPACK_IMPORTED_MODULE_5__["ViveController"]; });
  34900. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _webVRController__WEBPACK_IMPORTED_MODULE_6__["WebVRController"]; });
  34902. /* harmony import */ var _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./windowsMotionController */ "./Gamepads/Controllers/windowsMotionController.ts");
  34903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _windowsMotionController__WEBPACK_IMPORTED_MODULE_7__["WindowsMotionController"]; });
  34904. /***/ }),
  34905. /***/ "./Gamepads/Controllers/oculusTouchController.ts":
  34906. /*!*******************************************************!*\
  34907. !*** ./Gamepads/Controllers/oculusTouchController.ts ***!
  34908. \*******************************************************/
  34909. /*! exports provided: OculusTouchController */
  34910. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  34911. "use strict";
  34912. __webpack_require__.r(__webpack_exports__);
  34913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return OculusTouchController; });
  34914. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  34915. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  34916. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  34917. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  34918. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  34919. /**
  34920. * Oculus Touch Controller
  34921. */
  34922. var OculusTouchController = /** @class */ (function (_super) {
  34923. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](OculusTouchController, _super);
  34924. /**
  34925. * Creates a new OculusTouchController from a gamepad
  34926. * @param vrGamepad the gamepad that the controller should be created from
  34927. */
  34928. function OculusTouchController(vrGamepad) {
  34929. var _this = _super.call(this, vrGamepad) || this;
  34930. /**
  34931. * Fired when the secondary trigger on this controller is modified
  34932. */
  34933. _this.onSecondaryTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34934. /**
  34935. * Fired when the thumb rest on this controller is modified
  34936. */
  34937. _this.onThumbRestChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  34938. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerType"].OCULUS;
  34939. return _this;
  34940. }
  34941. /**
  34942. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  34943. * @param scene scene in which to add meshes
  34944. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  34945. */
  34946. OculusTouchController.prototype.initControllerMesh = function (scene, meshLoaded) {
  34947. var _this = this;
  34948. var meshName;
  34949. // Hand
  34950. if (this.hand === 'left') {
  34951. meshName = OculusTouchController.MODEL_LEFT_FILENAME;
  34952. }
  34953. else { // Right is the default if no hand is specified
  34954. meshName = OculusTouchController.MODEL_RIGHT_FILENAME;
  34955. }
  34956. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"].ImportMesh("", OculusTouchController.MODEL_BASE_URL, meshName, scene, function (newMeshes) {
  34957. /*
  34958. Parent Mesh name: oculus_touch_left
  34959. - body
  34960. - trigger
  34961. - thumbstick
  34962. - grip
  34963. - button_y
  34964. - button_x
  34965. - button_enter
  34966. */
  34967. _this._defaultModel = newMeshes[1];
  34968. _this.attachToMesh(_this._defaultModel);
  34969. if (meshLoaded) {
  34970. meshLoaded(_this._defaultModel);
  34971. }
  34972. });
  34973. };
  34974. Object.defineProperty(OculusTouchController.prototype, "onAButtonStateChangedObservable", {
  34975. /**
  34976. * Fired when the A button on this controller is modified
  34977. */
  34978. get: function () {
  34979. if (this.hand === 'right') {
  34980. return this.onMainButtonStateChangedObservable;
  34981. }
  34982. else {
  34983. throw new Error('No A button on left hand');
  34984. }
  34985. },
  34986. enumerable: true,
  34987. configurable: true
  34988. });
  34989. Object.defineProperty(OculusTouchController.prototype, "onBButtonStateChangedObservable", {
  34990. /**
  34991. * Fired when the B button on this controller is modified
  34992. */
  34993. get: function () {
  34994. if (this.hand === 'right') {
  34995. return this.onSecondaryButtonStateChangedObservable;
  34996. }
  34997. else {
  34998. throw new Error('No B button on left hand');
  34999. }
  35000. },
  35001. enumerable: true,
  35002. configurable: true
  35003. });
  35004. Object.defineProperty(OculusTouchController.prototype, "onXButtonStateChangedObservable", {
  35005. /**
  35006. * Fired when the X button on this controller is modified
  35007. */
  35008. get: function () {
  35009. if (this.hand === 'left') {
  35010. return this.onMainButtonStateChangedObservable;
  35011. }
  35012. else {
  35013. throw new Error('No X button on right hand');
  35014. }
  35015. },
  35016. enumerable: true,
  35017. configurable: true
  35018. });
  35019. Object.defineProperty(OculusTouchController.prototype, "onYButtonStateChangedObservable", {
  35020. /**
  35021. * Fired when the Y button on this controller is modified
  35022. */
  35023. get: function () {
  35024. if (this.hand === 'left') {
  35025. return this.onSecondaryButtonStateChangedObservable;
  35026. }
  35027. else {
  35028. throw new Error('No Y button on right hand');
  35029. }
  35030. },
  35031. enumerable: true,
  35032. configurable: true
  35033. });
  35034. /**
  35035. * Called once for each button that changed state since the last frame
  35036. * 0) thumb stick (touch, press, value = pressed (0,1)). value is in this.leftStick
  35037. * 1) index trigger (touch (?), press (only when value > 0.1), value 0 to 1)
  35038. * 2) secondary trigger (same)
  35039. * 3) A (right) X (left), touch, pressed = value
  35040. * 4) B / Y
  35041. * 5) thumb rest
  35042. * @param buttonIdx Which button index changed
  35043. * @param state New state of the button
  35044. * @param changes Which properties on the state changed since last frame
  35045. */
  35046. OculusTouchController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35047. var notifyObject = state; //{ state: state, changes: changes };
  35048. var triggerDirection = this.hand === 'right' ? -1 : 1;
  35049. switch (buttonIdx) {
  35050. case 0:
  35051. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35052. return;
  35053. case 1: // index trigger
  35054. if (this._defaultModel) {
  35055. (this._defaultModel.getChildren()[3]).rotation.x = -notifyObject.value * 0.20;
  35056. (this._defaultModel.getChildren()[3]).position.y = -notifyObject.value * 0.005;
  35057. (this._defaultModel.getChildren()[3]).position.z = -notifyObject.value * 0.005;
  35058. }
  35059. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35060. return;
  35061. case 2: // secondary trigger
  35062. if (this._defaultModel) {
  35063. (this._defaultModel.getChildren()[4]).position.x = triggerDirection * notifyObject.value * 0.0035;
  35064. }
  35065. this.onSecondaryTriggerStateChangedObservable.notifyObservers(notifyObject);
  35066. return;
  35067. case 3:
  35068. if (this._defaultModel) {
  35069. if (notifyObject.pressed) {
  35070. (this._defaultModel.getChildren()[1]).position.y = -0.001;
  35071. }
  35072. else {
  35073. (this._defaultModel.getChildren()[1]).position.y = 0;
  35074. }
  35075. }
  35076. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35077. return;
  35078. case 4:
  35079. if (this._defaultModel) {
  35080. if (notifyObject.pressed) {
  35081. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35082. }
  35083. else {
  35084. (this._defaultModel.getChildren()[2]).position.y = 0;
  35085. }
  35086. }
  35087. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35088. return;
  35089. case 5:
  35090. this.onThumbRestChangedObservable.notifyObservers(notifyObject);
  35091. return;
  35092. }
  35093. };
  35094. /**
  35095. * Base Url for the controller model.
  35096. */
  35097. OculusTouchController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/oculus/';
  35098. /**
  35099. * File name for the left controller model.
  35100. */
  35101. OculusTouchController.MODEL_LEFT_FILENAME = 'left.babylon';
  35102. /**
  35103. * File name for the right controller model.
  35104. */
  35105. OculusTouchController.MODEL_RIGHT_FILENAME = 'right.babylon';
  35106. return OculusTouchController;
  35107. }(_webVRController__WEBPACK_IMPORTED_MODULE_3__["WebVRController"]));
  35108. _poseEnabledController__WEBPACK_IMPORTED_MODULE_4__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35109. canCreate: function (gamepadInfo) {
  35110. return gamepadInfo.id.indexOf('Oculus Touch') !== -1;
  35111. },
  35112. create: function (gamepadInfo) {
  35113. return new OculusTouchController(gamepadInfo);
  35114. }
  35115. });
  35116. /***/ }),
  35117. /***/ "./Gamepads/Controllers/poseEnabledController.ts":
  35118. /*!*******************************************************!*\
  35119. !*** ./Gamepads/Controllers/poseEnabledController.ts ***!
  35120. \*******************************************************/
  35121. /*! exports provided: PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController */
  35122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35123. "use strict";
  35124. __webpack_require__.r(__webpack_exports__);
  35125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return PoseEnabledControllerType; });
  35126. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return PoseEnabledControllerHelper; });
  35127. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return PoseEnabledController; });
  35128. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35129. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35130. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35131. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35132. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  35133. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  35134. /**
  35135. * Defines the types of pose enabled controllers that are supported
  35136. */
  35137. var PoseEnabledControllerType;
  35138. (function (PoseEnabledControllerType) {
  35139. /**
  35140. * HTC Vive
  35141. */
  35142. PoseEnabledControllerType[PoseEnabledControllerType["VIVE"] = 0] = "VIVE";
  35143. /**
  35144. * Oculus Rift
  35145. */
  35146. PoseEnabledControllerType[PoseEnabledControllerType["OCULUS"] = 1] = "OCULUS";
  35147. /**
  35148. * Windows mixed reality
  35149. */
  35150. PoseEnabledControllerType[PoseEnabledControllerType["WINDOWS"] = 2] = "WINDOWS";
  35151. /**
  35152. * Samsung gear VR
  35153. */
  35154. PoseEnabledControllerType[PoseEnabledControllerType["GEAR_VR"] = 3] = "GEAR_VR";
  35155. /**
  35156. * Google Daydream
  35157. */
  35158. PoseEnabledControllerType[PoseEnabledControllerType["DAYDREAM"] = 4] = "DAYDREAM";
  35159. /**
  35160. * Generic
  35161. */
  35162. PoseEnabledControllerType[PoseEnabledControllerType["GENERIC"] = 5] = "GENERIC";
  35163. })(PoseEnabledControllerType || (PoseEnabledControllerType = {}));
  35164. /**
  35165. * Defines the PoseEnabledControllerHelper object that is used initialize a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35166. */
  35167. var PoseEnabledControllerHelper = /** @class */ (function () {
  35168. function PoseEnabledControllerHelper() {
  35169. }
  35170. /**
  35171. * Initializes a gamepad as the controller type it is specified as (eg. windows mixed reality controller)
  35172. * @param vrGamepad the gamepad to initialized
  35173. * @returns a vr controller of the type the gamepad identified as
  35174. */
  35175. PoseEnabledControllerHelper.InitiateController = function (vrGamepad) {
  35176. for (var _i = 0, _a = this._ControllerFactories; _i < _a.length; _i++) {
  35177. var factory = _a[_i];
  35178. if (factory.canCreate(vrGamepad)) {
  35179. return factory.create(vrGamepad);
  35180. }
  35181. }
  35182. if (this._DefaultControllerFactory) {
  35183. return this._DefaultControllerFactory(vrGamepad);
  35184. }
  35185. throw "The type of gamepad you are trying to load needs to be imported first or is not supported.";
  35186. };
  35187. /** @hidden */
  35188. PoseEnabledControllerHelper._ControllerFactories = [];
  35189. /** @hidden */
  35190. PoseEnabledControllerHelper._DefaultControllerFactory = null;
  35191. return PoseEnabledControllerHelper;
  35192. }());
  35193. /**
  35194. * Defines the PoseEnabledController object that contains state of a vr capable controller
  35195. */
  35196. var PoseEnabledController = /** @class */ (function (_super) {
  35197. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PoseEnabledController, _super);
  35198. /**
  35199. * Creates a new PoseEnabledController from a gamepad
  35200. * @param browserGamepad the gamepad that the PoseEnabledController should be created from
  35201. */
  35202. function PoseEnabledController(browserGamepad) {
  35203. var _this = _super.call(this, browserGamepad.id, browserGamepad.index, browserGamepad) || this;
  35204. // Represents device position and rotation in room space. Should only be used to help calculate babylon space values
  35205. _this._deviceRoomPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35206. _this._deviceRoomRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35207. /**
  35208. * The device position in babylon space
  35209. */
  35210. _this.devicePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35211. /**
  35212. * The device rotation in babylon space
  35213. */
  35214. _this.deviceRotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35215. /**
  35216. * The scale factor of the device in babylon space
  35217. */
  35218. _this.deviceScaleFactor = 1;
  35219. // Used to convert 6dof controllers to 3dof
  35220. _this._trackPosition = true;
  35221. _this._maxRotationDistFromHeadset = Math.PI / 5;
  35222. _this._draggedRoomRotation = 0;
  35223. _this._leftHandSystemQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35224. /**
  35225. * Internal, matrix used to convert room space to babylon space
  35226. * @hidden
  35227. */
  35228. _this._deviceToWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35229. /**
  35230. * Node to be used when casting a ray from the controller
  35231. * @hidden
  35232. */
  35233. _this._pointingPoseNode = null;
  35234. _this._workingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  35235. /**
  35236. * @hidden
  35237. */
  35238. _this._meshAttachedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35239. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].POSE_ENABLED;
  35240. _this.controllerType = PoseEnabledControllerType.GENERIC;
  35241. _this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35242. _this.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35243. _this._calculatedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  35244. _this._calculatedRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35245. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(Math.PI, 0, 0, _this._leftHandSystemQuaternion);
  35246. return _this;
  35247. }
  35248. /**
  35249. * @hidden
  35250. */
  35251. PoseEnabledController.prototype._disableTrackPosition = function (fixedPosition) {
  35252. if (this._trackPosition) {
  35253. this._calculatedPosition.copyFrom(fixedPosition);
  35254. this._trackPosition = false;
  35255. }
  35256. };
  35257. /**
  35258. * Updates the state of the pose enbaled controller and mesh based on the current position and rotation of the controller
  35259. */
  35260. PoseEnabledController.prototype.update = function () {
  35261. _super.prototype.update.call(this);
  35262. this._updatePoseAndMesh();
  35263. };
  35264. /**
  35265. * Updates only the pose device and mesh without doing any button event checking
  35266. */
  35267. PoseEnabledController.prototype._updatePoseAndMesh = function () {
  35268. var pose = this.browserGamepad.pose;
  35269. this.updateFromDevice(pose);
  35270. 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) {
  35271. var camera = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene.activeCamera;
  35272. camera._computeDevicePosition();
  35273. this._deviceToWorld.setTranslation(camera.devicePosition);
  35274. if (camera.deviceRotationQuaternion) {
  35275. var camera = camera;
  35276. camera._deviceRoomRotationQuaternion.toEulerAnglesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Vector3[0]);
  35277. // Find the radian distance away that the headset is from the controllers rotation
  35278. 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));
  35279. if (Math.abs(distanceAway) > this._maxRotationDistFromHeadset) {
  35280. // Only rotate enouph to be within the _maxRotationDistFromHeadset
  35281. var rotationAmount = distanceAway - (distanceAway < 0 ? -this._maxRotationDistFromHeadset : this._maxRotationDistFromHeadset);
  35282. this._draggedRoomRotation += rotationAmount;
  35283. // Rotate controller around headset
  35284. var sin = Math.sin(-rotationAmount);
  35285. var cos = Math.cos(-rotationAmount);
  35286. this._calculatedPosition.x = this._calculatedPosition.x * cos - this._calculatedPosition.z * sin;
  35287. this._calculatedPosition.z = this._calculatedPosition.x * sin + this._calculatedPosition.z * cos;
  35288. }
  35289. }
  35290. }
  35291. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._calculatedPosition, this._deviceToWorld, this.devicePosition);
  35292. this._deviceToWorld.getRotationMatrixToRef(this._workingMatrix);
  35293. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].FromRotationMatrixToRef(this._workingMatrix, this.deviceRotationQuaternion);
  35294. this.deviceRotationQuaternion.multiplyInPlace(this._calculatedRotation);
  35295. if (this._mesh) {
  35296. this._mesh.position.copyFrom(this.devicePosition);
  35297. if (this._mesh.rotationQuaternion) {
  35298. this._mesh.rotationQuaternion.copyFrom(this.deviceRotationQuaternion);
  35299. }
  35300. }
  35301. };
  35302. /**
  35303. * Updates the state of the pose enbaled controller based on the raw pose data from the device
  35304. * @param poseData raw pose fromthe device
  35305. */
  35306. PoseEnabledController.prototype.updateFromDevice = function (poseData) {
  35307. if (poseData) {
  35308. this.rawPose = poseData;
  35309. if (poseData.position) {
  35310. this._deviceRoomPosition.copyFromFloats(poseData.position[0], poseData.position[1], -poseData.position[2]);
  35311. if (this._mesh && this._mesh.getScene().useRightHandedSystem) {
  35312. this._deviceRoomPosition.z *= -1;
  35313. }
  35314. if (this._trackPosition) {
  35315. this._deviceRoomPosition.scaleToRef(this.deviceScaleFactor, this._calculatedPosition);
  35316. }
  35317. this._calculatedPosition.addInPlace(this.position);
  35318. }
  35319. var pose = this.rawPose;
  35320. if (poseData.orientation && pose.orientation) {
  35321. this._deviceRoomRotationQuaternion.copyFromFloats(pose.orientation[0], pose.orientation[1], -pose.orientation[2], -pose.orientation[3]);
  35322. if (this._mesh) {
  35323. if (this._mesh.getScene().useRightHandedSystem) {
  35324. this._deviceRoomRotationQuaternion.z *= -1;
  35325. this._deviceRoomRotationQuaternion.w *= -1;
  35326. }
  35327. else {
  35328. this._deviceRoomRotationQuaternion.multiplyToRef(this._leftHandSystemQuaternion, this._deviceRoomRotationQuaternion);
  35329. }
  35330. }
  35331. // if the camera is set, rotate to the camera's rotation
  35332. this._deviceRoomRotationQuaternion.multiplyToRef(this.rotationQuaternion, this._calculatedRotation);
  35333. }
  35334. }
  35335. };
  35336. /**
  35337. * Attaches a mesh to the controller
  35338. * @param mesh the mesh to be attached
  35339. */
  35340. PoseEnabledController.prototype.attachToMesh = function (mesh) {
  35341. if (this._mesh) {
  35342. this._mesh.parent = null;
  35343. }
  35344. this._mesh = mesh;
  35345. if (this._poseControlledCamera) {
  35346. this._mesh.parent = this._poseControlledCamera;
  35347. }
  35348. if (!this._mesh.rotationQuaternion) {
  35349. this._mesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  35350. }
  35351. // 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
  35352. this._updatePoseAndMesh();
  35353. if (this._pointingPoseNode) {
  35354. var parents = [];
  35355. var obj = this._pointingPoseNode;
  35356. while (obj.parent) {
  35357. parents.push(obj.parent);
  35358. obj = obj.parent;
  35359. }
  35360. parents.reverse().forEach(function (p) { p.computeWorldMatrix(true); });
  35361. }
  35362. this._meshAttachedObservable.notifyObservers(mesh);
  35363. };
  35364. /**
  35365. * Attaches the controllers mesh to a camera
  35366. * @param camera the camera the mesh should be attached to
  35367. */
  35368. PoseEnabledController.prototype.attachToPoseControlledCamera = function (camera) {
  35369. this._poseControlledCamera = camera;
  35370. if (this._mesh) {
  35371. this._mesh.parent = this._poseControlledCamera;
  35372. }
  35373. };
  35374. /**
  35375. * Disposes of the controller
  35376. */
  35377. PoseEnabledController.prototype.dispose = function () {
  35378. if (this._mesh) {
  35379. this._mesh.dispose();
  35380. }
  35381. this._mesh = null;
  35382. _super.prototype.dispose.call(this);
  35383. };
  35384. Object.defineProperty(PoseEnabledController.prototype, "mesh", {
  35385. /**
  35386. * The mesh that is attached to the controller
  35387. */
  35388. get: function () {
  35389. return this._mesh;
  35390. },
  35391. enumerable: true,
  35392. configurable: true
  35393. });
  35394. /**
  35395. * Gets the ray of the controller in the direction the controller is pointing
  35396. * @param length the length the resulting ray should be
  35397. * @returns a ray in the direction the controller is pointing
  35398. */
  35399. PoseEnabledController.prototype.getForwardRay = function (length) {
  35400. if (length === void 0) { length = 100; }
  35401. if (!this.mesh) {
  35402. 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);
  35403. }
  35404. var m = this._pointingPoseNode ? this._pointingPoseNode.getWorldMatrix() : this.mesh.getWorldMatrix();
  35405. var origin = m.getTranslation();
  35406. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, -1);
  35407. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormal(forward, m);
  35408. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(forwardWorld);
  35409. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_3__["Ray"](origin, direction, length);
  35410. };
  35411. /**
  35412. * Name of the child mesh that can be used to cast a ray from the controller
  35413. */
  35414. PoseEnabledController.POINTING_POSE = "POINTING_POSE";
  35415. return PoseEnabledController;
  35416. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"]));
  35417. /***/ }),
  35418. /***/ "./Gamepads/Controllers/viveController.ts":
  35419. /*!************************************************!*\
  35420. !*** ./Gamepads/Controllers/viveController.ts ***!
  35421. \************************************************/
  35422. /*! exports provided: ViveController */
  35423. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35424. "use strict";
  35425. __webpack_require__.r(__webpack_exports__);
  35426. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return ViveController; });
  35427. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35428. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35429. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35430. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35431. /**
  35432. * Vive Controller
  35433. */
  35434. var ViveController = /** @class */ (function (_super) {
  35435. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ViveController, _super);
  35436. /**
  35437. * Creates a new ViveController from a gamepad
  35438. * @param vrGamepad the gamepad that the controller should be created from
  35439. */
  35440. function ViveController(vrGamepad) {
  35441. var _this = _super.call(this, vrGamepad) || this;
  35442. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerType"].VIVE;
  35443. _this._invertLeftStickY = true;
  35444. return _this;
  35445. }
  35446. /**
  35447. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35448. * @param scene scene in which to add meshes
  35449. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35450. */
  35451. ViveController.prototype.initControllerMesh = function (scene, meshLoaded) {
  35452. var _this = this;
  35453. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh("", ViveController.MODEL_BASE_URL, ViveController.MODEL_FILENAME, scene, function (newMeshes) {
  35454. /*
  35455. Parent Mesh name: ViveWand
  35456. - body
  35457. - r_gripper
  35458. - l_gripper
  35459. - menu_button
  35460. - system_button
  35461. - trackpad
  35462. - trigger
  35463. - LED
  35464. */
  35465. _this._defaultModel = newMeshes[1];
  35466. _this.attachToMesh(_this._defaultModel);
  35467. if (meshLoaded) {
  35468. meshLoaded(_this._defaultModel);
  35469. }
  35470. });
  35471. };
  35472. Object.defineProperty(ViveController.prototype, "onLeftButtonStateChangedObservable", {
  35473. /**
  35474. * Fired when the left button on this controller is modified
  35475. */
  35476. get: function () {
  35477. return this.onMainButtonStateChangedObservable;
  35478. },
  35479. enumerable: true,
  35480. configurable: true
  35481. });
  35482. Object.defineProperty(ViveController.prototype, "onRightButtonStateChangedObservable", {
  35483. /**
  35484. * Fired when the right button on this controller is modified
  35485. */
  35486. get: function () {
  35487. return this.onMainButtonStateChangedObservable;
  35488. },
  35489. enumerable: true,
  35490. configurable: true
  35491. });
  35492. Object.defineProperty(ViveController.prototype, "onMenuButtonStateChangedObservable", {
  35493. /**
  35494. * Fired when the menu button on this controller is modified
  35495. */
  35496. get: function () {
  35497. return this.onSecondaryButtonStateChangedObservable;
  35498. },
  35499. enumerable: true,
  35500. configurable: true
  35501. });
  35502. /**
  35503. * Called once for each button that changed state since the last frame
  35504. * Vive mapping:
  35505. * 0: touchpad
  35506. * 1: trigger
  35507. * 2: left AND right buttons
  35508. * 3: menu button
  35509. * @param buttonIdx Which button index changed
  35510. * @param state New state of the button
  35511. * @param changes Which properties on the state changed since last frame
  35512. */
  35513. ViveController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35514. var notifyObject = state; //{ state: state, changes: changes };
  35515. switch (buttonIdx) {
  35516. case 0:
  35517. this.onPadStateChangedObservable.notifyObservers(notifyObject);
  35518. return;
  35519. case 1: // index trigger
  35520. if (this._defaultModel) {
  35521. (this._defaultModel.getChildren()[6]).rotation.x = -notifyObject.value * 0.15;
  35522. }
  35523. this.onTriggerStateChangedObservable.notifyObservers(notifyObject);
  35524. return;
  35525. case 2: // left AND right button
  35526. this.onMainButtonStateChangedObservable.notifyObservers(notifyObject);
  35527. return;
  35528. case 3:
  35529. if (this._defaultModel) {
  35530. if (notifyObject.pressed) {
  35531. (this._defaultModel.getChildren()[2]).position.y = -0.001;
  35532. }
  35533. else {
  35534. (this._defaultModel.getChildren()[2]).position.y = 0;
  35535. }
  35536. }
  35537. this.onSecondaryButtonStateChangedObservable.notifyObservers(notifyObject);
  35538. return;
  35539. }
  35540. };
  35541. /**
  35542. * Base Url for the controller model.
  35543. */
  35544. ViveController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/vive/';
  35545. /**
  35546. * File name for the controller model.
  35547. */
  35548. ViveController.MODEL_FILENAME = 'wand.babylon';
  35549. return ViveController;
  35550. }(_webVRController__WEBPACK_IMPORTED_MODULE_2__["WebVRController"]));
  35551. _poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  35552. canCreate: function (gamepadInfo) {
  35553. return gamepadInfo.id.toLowerCase().indexOf('openvr') !== -1;
  35554. },
  35555. create: function (gamepadInfo) {
  35556. return new ViveController(gamepadInfo);
  35557. }
  35558. });
  35559. /***/ }),
  35560. /***/ "./Gamepads/Controllers/webVRController.ts":
  35561. /*!*************************************************!*\
  35562. !*** ./Gamepads/Controllers/webVRController.ts ***!
  35563. \*************************************************/
  35564. /*! exports provided: WebVRController */
  35565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35566. "use strict";
  35567. __webpack_require__.r(__webpack_exports__);
  35568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return WebVRController; });
  35569. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35570. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35571. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35572. /**
  35573. * Defines the WebVRController object that represents controllers tracked in 3D space
  35574. */
  35575. var WebVRController = /** @class */ (function (_super) {
  35576. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WebVRController, _super);
  35577. /**
  35578. * Creates a new WebVRController from a gamepad
  35579. * @param vrGamepad the gamepad that the WebVRController should be created from
  35580. */
  35581. function WebVRController(vrGamepad) {
  35582. var _this = _super.call(this, vrGamepad) || this;
  35583. // Observables
  35584. /**
  35585. * Fired when the trigger state has changed
  35586. */
  35587. _this.onTriggerStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35588. /**
  35589. * Fired when the main button state has changed
  35590. */
  35591. _this.onMainButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35592. /**
  35593. * Fired when the secondary button state has changed
  35594. */
  35595. _this.onSecondaryButtonStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35596. /**
  35597. * Fired when the pad state has changed
  35598. */
  35599. _this.onPadStateChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35600. /**
  35601. * Fired when controllers stick values have changed
  35602. */
  35603. _this.onPadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  35604. /**
  35605. * X and Y axis corrisponding to the controllers joystick
  35606. */
  35607. _this.pad = { x: 0, y: 0 };
  35608. // avoid GC, store state in a tmp object
  35609. _this._changes = {
  35610. pressChanged: false,
  35611. touchChanged: false,
  35612. valueChanged: false,
  35613. changed: false
  35614. };
  35615. _this._buttons = new Array(vrGamepad.buttons.length);
  35616. _this.hand = vrGamepad.hand;
  35617. return _this;
  35618. }
  35619. /**
  35620. * Fired when a controller button's state has changed
  35621. * @param callback the callback containing the button that was modified
  35622. */
  35623. WebVRController.prototype.onButtonStateChange = function (callback) {
  35624. this._onButtonStateChange = callback;
  35625. };
  35626. Object.defineProperty(WebVRController.prototype, "defaultModel", {
  35627. /**
  35628. * The default controller model for the controller
  35629. */
  35630. get: function () {
  35631. return this._defaultModel;
  35632. },
  35633. enumerable: true,
  35634. configurable: true
  35635. });
  35636. /**
  35637. * Updates the state of the controller and mesh based on the current position and rotation of the controller
  35638. */
  35639. WebVRController.prototype.update = function () {
  35640. _super.prototype.update.call(this);
  35641. for (var index = 0; index < this._buttons.length; index++) {
  35642. this._setButtonValue(this.browserGamepad.buttons[index], this._buttons[index], index);
  35643. }
  35644. if (this.leftStick.x !== this.pad.x || this.leftStick.y !== this.pad.y) {
  35645. this.pad.x = this.leftStick.x;
  35646. this.pad.y = this.leftStick.y;
  35647. this.onPadValuesChangedObservable.notifyObservers(this.pad);
  35648. }
  35649. };
  35650. WebVRController.prototype._setButtonValue = function (newState, currentState, buttonIndex) {
  35651. if (!newState) {
  35652. newState = {
  35653. pressed: false,
  35654. touched: false,
  35655. value: 0
  35656. };
  35657. }
  35658. if (!currentState) {
  35659. this._buttons[buttonIndex] = {
  35660. pressed: newState.pressed,
  35661. touched: newState.touched,
  35662. value: newState.value
  35663. };
  35664. return;
  35665. }
  35666. this._checkChanges(newState, currentState);
  35667. if (this._changes.changed) {
  35668. this._onButtonStateChange && this._onButtonStateChange(this.index, buttonIndex, newState);
  35669. this._handleButtonChange(buttonIndex, newState, this._changes);
  35670. }
  35671. this._buttons[buttonIndex].pressed = newState.pressed;
  35672. this._buttons[buttonIndex].touched = newState.touched;
  35673. // oculus triggers are never 0, thou not touched.
  35674. this._buttons[buttonIndex].value = newState.value < 0.00000001 ? 0 : newState.value;
  35675. };
  35676. WebVRController.prototype._checkChanges = function (newState, currentState) {
  35677. this._changes.pressChanged = newState.pressed !== currentState.pressed;
  35678. this._changes.touchChanged = newState.touched !== currentState.touched;
  35679. this._changes.valueChanged = newState.value !== currentState.value;
  35680. this._changes.changed = this._changes.pressChanged || this._changes.touchChanged || this._changes.valueChanged;
  35681. return this._changes;
  35682. };
  35683. /**
  35684. * Disposes of th webVRCOntroller
  35685. */
  35686. WebVRController.prototype.dispose = function () {
  35687. _super.prototype.dispose.call(this);
  35688. this.onTriggerStateChangedObservable.clear();
  35689. this.onMainButtonStateChangedObservable.clear();
  35690. this.onSecondaryButtonStateChangedObservable.clear();
  35691. this.onPadStateChangedObservable.clear();
  35692. this.onPadValuesChangedObservable.clear();
  35693. };
  35694. return WebVRController;
  35695. }(_poseEnabledController__WEBPACK_IMPORTED_MODULE_2__["PoseEnabledController"]));
  35696. /***/ }),
  35697. /***/ "./Gamepads/Controllers/windowsMotionController.ts":
  35698. /*!*********************************************************!*\
  35699. !*** ./Gamepads/Controllers/windowsMotionController.ts ***!
  35700. \*********************************************************/
  35701. /*! exports provided: WindowsMotionController */
  35702. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  35703. "use strict";
  35704. __webpack_require__.r(__webpack_exports__);
  35705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return WindowsMotionController; });
  35706. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  35707. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  35708. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  35709. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  35710. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  35711. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Culling/ray */ "./Culling/ray.ts");
  35712. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  35713. /* harmony import */ var _webVRController__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./webVRController */ "./Gamepads/Controllers/webVRController.ts");
  35714. /* harmony import */ var _genericController__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./genericController */ "./Gamepads/Controllers/genericController.ts");
  35715. /* harmony import */ var _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  35716. /**
  35717. * Defines the LoadedMeshInfo object that describes information about the loaded webVR controller mesh
  35718. */
  35719. var LoadedMeshInfo = /** @class */ (function () {
  35720. function LoadedMeshInfo() {
  35721. /**
  35722. * Map of the button meshes contained in the controller
  35723. */
  35724. this.buttonMeshes = {};
  35725. /**
  35726. * Map of the axis meshes contained in the controller
  35727. */
  35728. this.axisMeshes = {};
  35729. }
  35730. return LoadedMeshInfo;
  35731. }());
  35732. /**
  35733. * Defines the WindowsMotionController object that the state of the windows motion controller
  35734. */
  35735. var WindowsMotionController = /** @class */ (function (_super) {
  35736. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](WindowsMotionController, _super);
  35737. /**
  35738. * Creates a new WindowsMotionController from a gamepad
  35739. * @param vrGamepad the gamepad that the controller should be created from
  35740. */
  35741. function WindowsMotionController(vrGamepad) {
  35742. var _this = _super.call(this, vrGamepad) || this;
  35743. _this._mapping = {
  35744. // Semantic button names
  35745. buttons: ['thumbstick', 'trigger', 'grip', 'menu', 'trackpad'],
  35746. // A mapping of the button name to glTF model node name
  35747. // that should be transformed by button value.
  35748. buttonMeshNames: {
  35749. 'trigger': 'SELECT',
  35750. 'menu': 'MENU',
  35751. 'grip': 'GRASP',
  35752. 'thumbstick': 'THUMBSTICK_PRESS',
  35753. 'trackpad': 'TOUCHPAD_PRESS'
  35754. },
  35755. // This mapping is used to translate from the Motion Controller to Babylon semantics
  35756. buttonObservableNames: {
  35757. 'trigger': 'onTriggerStateChangedObservable',
  35758. 'menu': 'onSecondaryButtonStateChangedObservable',
  35759. 'grip': 'onMainButtonStateChangedObservable',
  35760. 'thumbstick': 'onPadStateChangedObservable',
  35761. 'trackpad': 'onTrackpadChangedObservable'
  35762. },
  35763. // A mapping of the axis name to glTF model node name
  35764. // that should be transformed by axis value.
  35765. // This array mirrors the browserGamepad.axes array, such that
  35766. // the mesh corresponding to axis 0 is in this array index 0.
  35767. axisMeshNames: [
  35768. 'THUMBSTICK_X',
  35769. 'THUMBSTICK_Y',
  35770. 'TOUCHPAD_TOUCH_X',
  35771. 'TOUCHPAD_TOUCH_Y'
  35772. ],
  35773. pointingPoseMeshName: _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledController"].POINTING_POSE
  35774. };
  35775. /**
  35776. * Fired when the trackpad on this controller is clicked
  35777. */
  35778. _this.onTrackpadChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35779. /**
  35780. * Fired when the trackpad on this controller is modified
  35781. */
  35782. _this.onTrackpadValuesChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  35783. /**
  35784. * The current x and y values of this controller's trackpad
  35785. */
  35786. _this.trackpad = { x: 0, y: 0 };
  35787. _this.controllerType = _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerType"].WINDOWS;
  35788. _this._loadedMeshInfo = null;
  35789. return _this;
  35790. }
  35791. Object.defineProperty(WindowsMotionController.prototype, "onTriggerButtonStateChangedObservable", {
  35792. /**
  35793. * Fired when the trigger on this controller is modified
  35794. */
  35795. get: function () {
  35796. return this.onTriggerStateChangedObservable;
  35797. },
  35798. enumerable: true,
  35799. configurable: true
  35800. });
  35801. Object.defineProperty(WindowsMotionController.prototype, "onMenuButtonStateChangedObservable", {
  35802. /**
  35803. * Fired when the menu button on this controller is modified
  35804. */
  35805. get: function () {
  35806. return this.onSecondaryButtonStateChangedObservable;
  35807. },
  35808. enumerable: true,
  35809. configurable: true
  35810. });
  35811. Object.defineProperty(WindowsMotionController.prototype, "onGripButtonStateChangedObservable", {
  35812. /**
  35813. * Fired when the grip button on this controller is modified
  35814. */
  35815. get: function () {
  35816. return this.onMainButtonStateChangedObservable;
  35817. },
  35818. enumerable: true,
  35819. configurable: true
  35820. });
  35821. Object.defineProperty(WindowsMotionController.prototype, "onThumbstickButtonStateChangedObservable", {
  35822. /**
  35823. * Fired when the thumbstick button on this controller is modified
  35824. */
  35825. get: function () {
  35826. return this.onPadStateChangedObservable;
  35827. },
  35828. enumerable: true,
  35829. configurable: true
  35830. });
  35831. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadButtonStateChangedObservable", {
  35832. /**
  35833. * Fired when the touchpad button on this controller is modified
  35834. */
  35835. get: function () {
  35836. return this.onTrackpadChangedObservable;
  35837. },
  35838. enumerable: true,
  35839. configurable: true
  35840. });
  35841. Object.defineProperty(WindowsMotionController.prototype, "onTouchpadValuesChangedObservable", {
  35842. /**
  35843. * Fired when the touchpad values on this controller are modified
  35844. */
  35845. get: function () {
  35846. return this.onTrackpadValuesChangedObservable;
  35847. },
  35848. enumerable: true,
  35849. configurable: true
  35850. });
  35851. WindowsMotionController.prototype._updateTrackpad = function () {
  35852. if (this.browserGamepad.axes && (this.browserGamepad.axes[2] != this.trackpad.x || this.browserGamepad.axes[3] != this.trackpad.y)) {
  35853. this.trackpad.x = this.browserGamepad["axes"][2];
  35854. this.trackpad.y = this.browserGamepad["axes"][3];
  35855. this.onTrackpadValuesChangedObservable.notifyObservers(this.trackpad);
  35856. }
  35857. };
  35858. /**
  35859. * Called once per frame by the engine.
  35860. */
  35861. WindowsMotionController.prototype.update = function () {
  35862. _super.prototype.update.call(this);
  35863. if (this.browserGamepad.axes) {
  35864. this._updateTrackpad();
  35865. // Only need to animate axes if there is a loaded mesh
  35866. if (this._loadedMeshInfo) {
  35867. for (var axis = 0; axis < this._mapping.axisMeshNames.length; axis++) {
  35868. this._lerpAxisTransform(axis, this.browserGamepad.axes[axis]);
  35869. }
  35870. }
  35871. }
  35872. };
  35873. /**
  35874. * Called once for each button that changed state since the last frame
  35875. * @param buttonIdx Which button index changed
  35876. * @param state New state of the button
  35877. * @param changes Which properties on the state changed since last frame
  35878. */
  35879. WindowsMotionController.prototype._handleButtonChange = function (buttonIdx, state, changes) {
  35880. var buttonName = this._mapping.buttons[buttonIdx];
  35881. if (!buttonName) {
  35882. return;
  35883. }
  35884. // Update the trackpad to ensure trackpad.x/y are accurate during button events between frames
  35885. this._updateTrackpad();
  35886. // Only emit events for buttons that we know how to map from index to name
  35887. var observable = this[(this._mapping.buttonObservableNames)[buttonName]];
  35888. if (observable) {
  35889. observable.notifyObservers(state);
  35890. }
  35891. this._lerpButtonTransform(buttonName, state.value);
  35892. };
  35893. /**
  35894. * Moves the buttons on the controller mesh based on their current state
  35895. * @param buttonName the name of the button to move
  35896. * @param buttonValue the value of the button which determines the buttons new position
  35897. */
  35898. WindowsMotionController.prototype._lerpButtonTransform = function (buttonName, buttonValue) {
  35899. // If there is no loaded mesh, there is nothing to transform.
  35900. if (!this._loadedMeshInfo) {
  35901. return;
  35902. }
  35903. var meshInfo = this._loadedMeshInfo.buttonMeshes[buttonName];
  35904. if (!meshInfo.unpressed.rotationQuaternion || !meshInfo.pressed.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35905. return;
  35906. }
  35907. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.unpressed.rotationQuaternion, meshInfo.pressed.rotationQuaternion, buttonValue, meshInfo.value.rotationQuaternion);
  35908. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.unpressed.position, meshInfo.pressed.position, buttonValue, meshInfo.value.position);
  35909. };
  35910. /**
  35911. * Moves the axis on the controller mesh based on its current state
  35912. * @param axis the index of the axis
  35913. * @param axisValue the value of the axis which determines the meshes new position
  35914. * @hidden
  35915. */
  35916. WindowsMotionController.prototype._lerpAxisTransform = function (axis, axisValue) {
  35917. if (!this._loadedMeshInfo) {
  35918. return;
  35919. }
  35920. var meshInfo = this._loadedMeshInfo.axisMeshes[axis];
  35921. if (!meshInfo) {
  35922. return;
  35923. }
  35924. if (!meshInfo.min.rotationQuaternion || !meshInfo.max.rotationQuaternion || !meshInfo.value.rotationQuaternion) {
  35925. return;
  35926. }
  35927. // Convert from gamepad value range (-1 to +1) to lerp range (0 to 1)
  35928. var lerpValue = axisValue * 0.5 + 0.5;
  35929. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].SlerpToRef(meshInfo.min.rotationQuaternion, meshInfo.max.rotationQuaternion, lerpValue, meshInfo.value.rotationQuaternion);
  35930. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].LerpToRef(meshInfo.min.position, meshInfo.max.position, lerpValue, meshInfo.value.position);
  35931. };
  35932. /**
  35933. * Implements abstract method on WebVRController class, loading controller meshes and calling this.attachToMesh if successful.
  35934. * @param scene scene in which to add meshes
  35935. * @param meshLoaded optional callback function that will be called if the mesh loads successfully.
  35936. */
  35937. WindowsMotionController.prototype.initControllerMesh = function (scene, meshLoaded, forceDefault) {
  35938. var _this = this;
  35939. if (forceDefault === void 0) { forceDefault = false; }
  35940. var path;
  35941. var filename;
  35942. // Checking if GLB loader is present
  35943. if (_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].IsPluginForExtensionAvailable(".glb")) {
  35944. // Determine the device specific folder based on the ID suffix
  35945. var device = 'default';
  35946. if (this.id && !forceDefault) {
  35947. var match = this.id.match(WindowsMotionController.GAMEPAD_ID_PATTERN);
  35948. device = ((match && match[0]) || device);
  35949. }
  35950. // Hand
  35951. if (this.hand === 'left') {
  35952. filename = WindowsMotionController.MODEL_LEFT_FILENAME;
  35953. }
  35954. else { // Right is the default if no hand is specified
  35955. filename = WindowsMotionController.MODEL_RIGHT_FILENAME;
  35956. }
  35957. path = WindowsMotionController.MODEL_BASE_URL + device + '/';
  35958. }
  35959. else {
  35960. _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");
  35961. path = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_BASE_URL;
  35962. filename = _genericController__WEBPACK_IMPORTED_MODULE_8__["GenericController"].MODEL_FILENAME;
  35963. }
  35964. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_6__["SceneLoader"].ImportMesh("", path, filename, scene, function (meshes) {
  35965. // glTF files successfully loaded from the remote server, now process them to ensure they are in the right format.
  35966. _this._loadedMeshInfo = _this.processModel(scene, meshes);
  35967. if (!_this._loadedMeshInfo) {
  35968. return;
  35969. }
  35970. _this._defaultModel = _this._loadedMeshInfo.rootNode;
  35971. _this.attachToMesh(_this._defaultModel);
  35972. if (meshLoaded) {
  35973. meshLoaded(_this._defaultModel);
  35974. }
  35975. }, null, function (scene, message) {
  35976. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log(message);
  35977. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Failed to retrieve controller model from the remote server: ' + path + filename);
  35978. if (!forceDefault) {
  35979. _this.initControllerMesh(scene, meshLoaded, true);
  35980. }
  35981. });
  35982. };
  35983. /**
  35984. * Takes a list of meshes (as loaded from the glTF file) and finds the root node, as well as nodes that
  35985. * can be transformed by button presses and axes values, based on this._mapping.
  35986. *
  35987. * @param scene scene in which the meshes exist
  35988. * @param meshes list of meshes that make up the controller model to process
  35989. * @return structured view of the given meshes, with mapping of buttons and axes to meshes that can be transformed.
  35990. */
  35991. WindowsMotionController.prototype.processModel = function (scene, meshes) {
  35992. var loadedMeshInfo = null;
  35993. // Create a new mesh to contain the glTF hierarchy
  35994. var parentMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this.id + " " + this.hand, scene);
  35995. // Find the root node in the loaded glTF scene, and attach it as a child of 'parentMesh'
  35996. var childMesh = null;
  35997. for (var i = 0; i < meshes.length; i++) {
  35998. var mesh = meshes[i];
  35999. if (!mesh.parent) {
  36000. // Exclude controller meshes from picking results
  36001. mesh.isPickable = false;
  36002. // Handle root node, attach to the new parentMesh
  36003. childMesh = mesh;
  36004. break;
  36005. }
  36006. }
  36007. if (childMesh) {
  36008. childMesh.setParent(parentMesh);
  36009. // Create our mesh info. Note that this method will always return non-null.
  36010. loadedMeshInfo = this.createMeshInfo(parentMesh);
  36011. }
  36012. else {
  36013. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Could not find root node in model file.');
  36014. }
  36015. return loadedMeshInfo;
  36016. };
  36017. WindowsMotionController.prototype.createMeshInfo = function (rootNode) {
  36018. var loadedMeshInfo = new LoadedMeshInfo();
  36019. var i;
  36020. loadedMeshInfo.rootNode = rootNode;
  36021. // Reset the caches
  36022. loadedMeshInfo.buttonMeshes = {};
  36023. loadedMeshInfo.axisMeshes = {};
  36024. // Button Meshes
  36025. for (i = 0; i < this._mapping.buttons.length; i++) {
  36026. var buttonMeshName = this._mapping.buttonMeshNames[this._mapping.buttons[i]];
  36027. if (!buttonMeshName) {
  36028. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown button at index: ' + i + ' with mapped name: ' + this._mapping.buttons[i]);
  36029. continue;
  36030. }
  36031. var buttonMesh = getChildByName(rootNode, buttonMeshName);
  36032. if (!buttonMesh) {
  36033. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button mesh with name: ' + buttonMeshName);
  36034. continue;
  36035. }
  36036. var buttonMeshInfo = {
  36037. index: i,
  36038. value: getImmediateChildByName(buttonMesh, 'VALUE'),
  36039. pressed: getImmediateChildByName(buttonMesh, 'PRESSED'),
  36040. unpressed: getImmediateChildByName(buttonMesh, 'UNPRESSED')
  36041. };
  36042. if (buttonMeshInfo.value && buttonMeshInfo.pressed && buttonMeshInfo.unpressed) {
  36043. loadedMeshInfo.buttonMeshes[this._mapping.buttons[i]] = buttonMeshInfo;
  36044. }
  36045. else {
  36046. // If we didn't find the mesh, it simply means this button won't have transforms applied as mapped button value changes.
  36047. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing button submesh under mesh with name: ' + buttonMeshName +
  36048. '(VALUE: ' + !!buttonMeshInfo.value +
  36049. ', PRESSED: ' + !!buttonMeshInfo.pressed +
  36050. ', UNPRESSED:' + !!buttonMeshInfo.unpressed +
  36051. ')');
  36052. }
  36053. }
  36054. // Axis Meshes
  36055. for (i = 0; i < this._mapping.axisMeshNames.length; i++) {
  36056. var axisMeshName = this._mapping.axisMeshNames[i];
  36057. if (!axisMeshName) {
  36058. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Log('Skipping unknown axis at index: ' + i);
  36059. continue;
  36060. }
  36061. var axisMesh = getChildByName(rootNode, axisMeshName);
  36062. if (!axisMesh) {
  36063. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis mesh with name: ' + axisMeshName);
  36064. continue;
  36065. }
  36066. var axisMeshInfo = {
  36067. index: i,
  36068. value: getImmediateChildByName(axisMesh, 'VALUE'),
  36069. min: getImmediateChildByName(axisMesh, 'MIN'),
  36070. max: getImmediateChildByName(axisMesh, 'MAX')
  36071. };
  36072. if (axisMeshInfo.value && axisMeshInfo.min && axisMeshInfo.max) {
  36073. loadedMeshInfo.axisMeshes[i] = axisMeshInfo;
  36074. }
  36075. else {
  36076. // If we didn't find the mesh, it simply means thit axis won't have transforms applied as mapped axis values change.
  36077. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing axis submesh under mesh with name: ' + axisMeshName +
  36078. '(VALUE: ' + !!axisMeshInfo.value +
  36079. ', MIN: ' + !!axisMeshInfo.min +
  36080. ', MAX:' + !!axisMeshInfo.max +
  36081. ')');
  36082. }
  36083. }
  36084. // Pointing Ray
  36085. loadedMeshInfo.pointingPoseNode = getChildByName(rootNode, this._mapping.pointingPoseMeshName);
  36086. if (!loadedMeshInfo.pointingPoseNode) {
  36087. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn('Missing pointing pose mesh with name: ' + this._mapping.pointingPoseMeshName);
  36088. }
  36089. else {
  36090. this._pointingPoseNode = loadedMeshInfo.pointingPoseNode;
  36091. }
  36092. return loadedMeshInfo;
  36093. // Look through all children recursively. This will return null if no mesh exists with the given name.
  36094. function getChildByName(node, name) {
  36095. return node.getChildren(function (n) { return n.name === name; }, false)[0];
  36096. }
  36097. // Look through only immediate children. This will return null if no mesh exists with the given name.
  36098. function getImmediateChildByName(node, name) {
  36099. return node.getChildren(function (n) { return n.name == name; }, true)[0];
  36100. }
  36101. };
  36102. /**
  36103. * Gets the ray of the controller in the direction the controller is pointing
  36104. * @param length the length the resulting ray should be
  36105. * @returns a ray in the direction the controller is pointing
  36106. */
  36107. WindowsMotionController.prototype.getForwardRay = function (length) {
  36108. if (length === void 0) { length = 100; }
  36109. if (!(this._loadedMeshInfo && this._loadedMeshInfo.pointingPoseNode)) {
  36110. return _super.prototype.getForwardRay.call(this, length);
  36111. }
  36112. var m = this._loadedMeshInfo.pointingPoseNode.getWorldMatrix();
  36113. var origin = m.getTranslation();
  36114. var forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  36115. var forwardWorld = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(forward, m);
  36116. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(forwardWorld);
  36117. return new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](origin, direction, length);
  36118. };
  36119. /**
  36120. * Disposes of the controller
  36121. */
  36122. WindowsMotionController.prototype.dispose = function () {
  36123. _super.prototype.dispose.call(this);
  36124. this.onTrackpadChangedObservable.clear();
  36125. };
  36126. /**
  36127. * The base url used to load the left and right controller models
  36128. */
  36129. WindowsMotionController.MODEL_BASE_URL = 'https://controllers.babylonjs.com/microsoft/';
  36130. /**
  36131. * The name of the left controller model file
  36132. */
  36133. WindowsMotionController.MODEL_LEFT_FILENAME = 'left.glb';
  36134. /**
  36135. * The name of the right controller model file
  36136. */
  36137. WindowsMotionController.MODEL_RIGHT_FILENAME = 'right.glb';
  36138. /**
  36139. * The controller name prefix for this controller type
  36140. */
  36141. WindowsMotionController.GAMEPAD_ID_PREFIX = 'Spatial Controller (Spatial Interaction Source) ';
  36142. /**
  36143. * The controller id pattern for this controller type
  36144. */
  36145. WindowsMotionController.GAMEPAD_ID_PATTERN = /([0-9a-zA-Z]+-[0-9a-zA-Z]+)$/;
  36146. return WindowsMotionController;
  36147. }(_webVRController__WEBPACK_IMPORTED_MODULE_7__["WebVRController"]));
  36148. _poseEnabledController__WEBPACK_IMPORTED_MODULE_9__["PoseEnabledControllerHelper"]._ControllerFactories.push({
  36149. canCreate: function (gamepadInfo) {
  36150. return gamepadInfo.id.indexOf(WindowsMotionController.GAMEPAD_ID_PREFIX) === 0;
  36151. },
  36152. create: function (gamepadInfo) {
  36153. return new WindowsMotionController(gamepadInfo);
  36154. }
  36155. });
  36156. /***/ }),
  36157. /***/ "./Gamepads/gamepad.ts":
  36158. /*!*****************************!*\
  36159. !*** ./Gamepads/gamepad.ts ***!
  36160. \*****************************/
  36161. /*! exports provided: StickValues, Gamepad, GenericPad */
  36162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36163. "use strict";
  36164. __webpack_require__.r(__webpack_exports__);
  36165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return StickValues; });
  36166. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return Gamepad; });
  36167. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return GenericPad; });
  36168. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36169. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36170. /**
  36171. * Represents a gamepad control stick position
  36172. */
  36173. var StickValues = /** @class */ (function () {
  36174. /**
  36175. * Initializes the gamepad x and y control stick values
  36176. * @param x The x component of the gamepad control stick value
  36177. * @param y The y component of the gamepad control stick value
  36178. */
  36179. function StickValues(
  36180. /**
  36181. * The x component of the control stick
  36182. */
  36183. x,
  36184. /**
  36185. * The y component of the control stick
  36186. */
  36187. y) {
  36188. this.x = x;
  36189. this.y = y;
  36190. }
  36191. return StickValues;
  36192. }());
  36193. /**
  36194. * Represents a gamepad
  36195. */
  36196. var Gamepad = /** @class */ (function () {
  36197. /**
  36198. * Initializes the gamepad
  36199. * @param id The id of the gamepad
  36200. * @param index The index of the gamepad
  36201. * @param browserGamepad The browser gamepad
  36202. * @param leftStickX The x component of the left joystick
  36203. * @param leftStickY The y component of the left joystick
  36204. * @param rightStickX The x component of the right joystick
  36205. * @param rightStickY The y component of the right joystick
  36206. */
  36207. function Gamepad(
  36208. /**
  36209. * The id of the gamepad
  36210. */
  36211. id,
  36212. /**
  36213. * The index of the gamepad
  36214. */
  36215. index,
  36216. /**
  36217. * The browser gamepad
  36218. */
  36219. browserGamepad, leftStickX, leftStickY, rightStickX, rightStickY) {
  36220. if (leftStickX === void 0) { leftStickX = 0; }
  36221. if (leftStickY === void 0) { leftStickY = 1; }
  36222. if (rightStickX === void 0) { rightStickX = 2; }
  36223. if (rightStickY === void 0) { rightStickY = 3; }
  36224. this.id = id;
  36225. this.index = index;
  36226. this.browserGamepad = browserGamepad;
  36227. this._leftStick = { x: 0, y: 0 };
  36228. this._rightStick = { x: 0, y: 0 };
  36229. /** @hidden */
  36230. this._isConnected = true;
  36231. /**
  36232. * Specifies whether the left control stick should be Y-inverted
  36233. */
  36234. this._invertLeftStickY = false;
  36235. this.type = Gamepad.GAMEPAD;
  36236. this._leftStickAxisX = leftStickX;
  36237. this._leftStickAxisY = leftStickY;
  36238. this._rightStickAxisX = rightStickX;
  36239. this._rightStickAxisY = rightStickY;
  36240. if (this.browserGamepad.axes.length >= 2) {
  36241. this._leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36242. }
  36243. if (this.browserGamepad.axes.length >= 4) {
  36244. this._rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36245. }
  36246. }
  36247. Object.defineProperty(Gamepad.prototype, "isConnected", {
  36248. /**
  36249. * Specifies if the gamepad has been connected
  36250. */
  36251. get: function () {
  36252. return this._isConnected;
  36253. },
  36254. enumerable: true,
  36255. configurable: true
  36256. });
  36257. /**
  36258. * Callback triggered when the left joystick has changed
  36259. * @param callback
  36260. */
  36261. Gamepad.prototype.onleftstickchanged = function (callback) {
  36262. this._onleftstickchanged = callback;
  36263. };
  36264. /**
  36265. * Callback triggered when the right joystick has changed
  36266. * @param callback
  36267. */
  36268. Gamepad.prototype.onrightstickchanged = function (callback) {
  36269. this._onrightstickchanged = callback;
  36270. };
  36271. Object.defineProperty(Gamepad.prototype, "leftStick", {
  36272. /**
  36273. * Gets the left joystick
  36274. */
  36275. get: function () {
  36276. return this._leftStick;
  36277. },
  36278. /**
  36279. * Sets the left joystick values
  36280. */
  36281. set: function (newValues) {
  36282. if (this._onleftstickchanged && (this._leftStick.x !== newValues.x || this._leftStick.y !== newValues.y)) {
  36283. this._onleftstickchanged(newValues);
  36284. }
  36285. this._leftStick = newValues;
  36286. },
  36287. enumerable: true,
  36288. configurable: true
  36289. });
  36290. Object.defineProperty(Gamepad.prototype, "rightStick", {
  36291. /**
  36292. * Gets the right joystick
  36293. */
  36294. get: function () {
  36295. return this._rightStick;
  36296. },
  36297. /**
  36298. * Sets the right joystick value
  36299. */
  36300. set: function (newValues) {
  36301. if (this._onrightstickchanged && (this._rightStick.x !== newValues.x || this._rightStick.y !== newValues.y)) {
  36302. this._onrightstickchanged(newValues);
  36303. }
  36304. this._rightStick = newValues;
  36305. },
  36306. enumerable: true,
  36307. configurable: true
  36308. });
  36309. /**
  36310. * Updates the gamepad joystick positions
  36311. */
  36312. Gamepad.prototype.update = function () {
  36313. if (this._leftStick) {
  36314. this.leftStick = { x: this.browserGamepad.axes[this._leftStickAxisX], y: this.browserGamepad.axes[this._leftStickAxisY] };
  36315. if (this._invertLeftStickY) {
  36316. this.leftStick.y *= -1;
  36317. }
  36318. }
  36319. if (this._rightStick) {
  36320. this.rightStick = { x: this.browserGamepad.axes[this._rightStickAxisX], y: this.browserGamepad.axes[this._rightStickAxisY] };
  36321. }
  36322. };
  36323. /**
  36324. * Disposes the gamepad
  36325. */
  36326. Gamepad.prototype.dispose = function () {
  36327. };
  36328. /**
  36329. * Represents a gamepad controller
  36330. */
  36331. Gamepad.GAMEPAD = 0;
  36332. /**
  36333. * Represents a generic controller
  36334. */
  36335. Gamepad.GENERIC = 1;
  36336. /**
  36337. * Represents an XBox controller
  36338. */
  36339. Gamepad.XBOX = 2;
  36340. /**
  36341. * Represents a pose-enabled controller
  36342. */
  36343. Gamepad.POSE_ENABLED = 3;
  36344. return Gamepad;
  36345. }());
  36346. /**
  36347. * Represents a generic gamepad
  36348. */
  36349. var GenericPad = /** @class */ (function (_super) {
  36350. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GenericPad, _super);
  36351. /**
  36352. * Initializes the generic gamepad
  36353. * @param id The id of the generic gamepad
  36354. * @param index The index of the generic gamepad
  36355. * @param browserGamepad The browser gamepad
  36356. */
  36357. function GenericPad(id, index, browserGamepad) {
  36358. var _this = _super.call(this, id, index, browserGamepad) || this;
  36359. /**
  36360. * Observable triggered when a button has been pressed
  36361. */
  36362. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36363. /**
  36364. * Observable triggered when a button has been released
  36365. */
  36366. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36367. _this.type = Gamepad.GENERIC;
  36368. _this._buttons = new Array(browserGamepad.buttons.length);
  36369. return _this;
  36370. }
  36371. /**
  36372. * Callback triggered when a button has been pressed
  36373. * @param callback Called when a button has been pressed
  36374. */
  36375. GenericPad.prototype.onbuttondown = function (callback) {
  36376. this._onbuttondown = callback;
  36377. };
  36378. /**
  36379. * Callback triggered when a button has been released
  36380. * @param callback Called when a button has been released
  36381. */
  36382. GenericPad.prototype.onbuttonup = function (callback) {
  36383. this._onbuttonup = callback;
  36384. };
  36385. GenericPad.prototype._setButtonValue = function (newValue, currentValue, buttonIndex) {
  36386. if (newValue !== currentValue) {
  36387. if (newValue === 1) {
  36388. if (this._onbuttondown) {
  36389. this._onbuttondown(buttonIndex);
  36390. }
  36391. this.onButtonDownObservable.notifyObservers(buttonIndex);
  36392. }
  36393. if (newValue === 0) {
  36394. if (this._onbuttonup) {
  36395. this._onbuttonup(buttonIndex);
  36396. }
  36397. this.onButtonUpObservable.notifyObservers(buttonIndex);
  36398. }
  36399. }
  36400. return newValue;
  36401. };
  36402. /**
  36403. * Updates the generic gamepad
  36404. */
  36405. GenericPad.prototype.update = function () {
  36406. _super.prototype.update.call(this);
  36407. for (var index = 0; index < this._buttons.length; index++) {
  36408. this._buttons[index] = this._setButtonValue(this.browserGamepad.buttons[index].value, this._buttons[index], index);
  36409. }
  36410. };
  36411. /**
  36412. * Disposes the generic gamepad
  36413. */
  36414. GenericPad.prototype.dispose = function () {
  36415. _super.prototype.dispose.call(this);
  36416. this.onButtonDownObservable.clear();
  36417. this.onButtonUpObservable.clear();
  36418. };
  36419. return GenericPad;
  36420. }(Gamepad));
  36421. /***/ }),
  36422. /***/ "./Gamepads/gamepadManager.ts":
  36423. /*!************************************!*\
  36424. !*** ./Gamepads/gamepadManager.ts ***!
  36425. \************************************/
  36426. /*! exports provided: GamepadManager */
  36427. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36428. "use strict";
  36429. __webpack_require__.r(__webpack_exports__);
  36430. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return GamepadManager; });
  36431. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  36432. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36433. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  36434. /* harmony import */ var _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Gamepads/Controllers/poseEnabledController */ "./Gamepads/Controllers/poseEnabledController.ts");
  36435. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36436. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36437. /**
  36438. * Manager for handling gamepads
  36439. */
  36440. var GamepadManager = /** @class */ (function () {
  36441. /**
  36442. * Initializes the gamepad manager
  36443. * @param _scene BabylonJS scene
  36444. */
  36445. function GamepadManager(_scene) {
  36446. var _this = this;
  36447. this._scene = _scene;
  36448. this._babylonGamepads = [];
  36449. this._oneGamepadConnected = false;
  36450. /** @hidden */
  36451. this._isMonitoring = false;
  36452. /**
  36453. * observable to be triggered when the gamepad controller has been disconnected
  36454. */
  36455. this.onGamepadDisconnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36456. if (!_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  36457. this._gamepadEventSupported = false;
  36458. }
  36459. else {
  36460. this._gamepadEventSupported = 'GamepadEvent' in window;
  36461. this._gamepadSupport = (navigator.getGamepads ||
  36462. navigator.webkitGetGamepads || navigator.msGetGamepads || navigator.webkitGamepads);
  36463. }
  36464. this.onGamepadConnectedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"](function (observer) {
  36465. // This will be used to raise the onGamepadConnected for all gamepads ALREADY connected
  36466. for (var i in _this._babylonGamepads) {
  36467. var gamepad = _this._babylonGamepads[i];
  36468. if (gamepad && gamepad._isConnected) {
  36469. _this.onGamepadConnectedObservable.notifyObserver(observer, gamepad);
  36470. }
  36471. }
  36472. });
  36473. this._onGamepadConnectedEvent = function (evt) {
  36474. var gamepad = evt.gamepad;
  36475. if (gamepad.index in _this._babylonGamepads) {
  36476. if (_this._babylonGamepads[gamepad.index].isConnected) {
  36477. return;
  36478. }
  36479. }
  36480. var newGamepad;
  36481. if (_this._babylonGamepads[gamepad.index]) {
  36482. newGamepad = _this._babylonGamepads[gamepad.index];
  36483. newGamepad.browserGamepad = gamepad;
  36484. newGamepad._isConnected = true;
  36485. }
  36486. else {
  36487. newGamepad = _this._addNewGamepad(gamepad);
  36488. }
  36489. _this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36490. _this._startMonitoringGamepads();
  36491. };
  36492. this._onGamepadDisconnectedEvent = function (evt) {
  36493. var gamepad = evt.gamepad;
  36494. // Remove the gamepad from the list of gamepads to monitor.
  36495. for (var i in _this._babylonGamepads) {
  36496. if (_this._babylonGamepads[i].index === gamepad.index) {
  36497. var disconnectedGamepad = _this._babylonGamepads[i];
  36498. disconnectedGamepad._isConnected = false;
  36499. _this.onGamepadDisconnectedObservable.notifyObservers(disconnectedGamepad);
  36500. break;
  36501. }
  36502. }
  36503. };
  36504. if (this._gamepadSupport) {
  36505. //first add already-connected gamepads
  36506. this._updateGamepadObjects();
  36507. if (this._babylonGamepads.length) {
  36508. this._startMonitoringGamepads();
  36509. }
  36510. // Checking if the gamepad connected event is supported (like in Firefox)
  36511. if (this._gamepadEventSupported) {
  36512. window.addEventListener('gamepadconnected', this._onGamepadConnectedEvent, false);
  36513. window.addEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent, false);
  36514. }
  36515. else {
  36516. this._startMonitoringGamepads();
  36517. }
  36518. }
  36519. }
  36520. Object.defineProperty(GamepadManager.prototype, "gamepads", {
  36521. /**
  36522. * The gamepads in the game pad manager
  36523. */
  36524. get: function () {
  36525. return this._babylonGamepads;
  36526. },
  36527. enumerable: true,
  36528. configurable: true
  36529. });
  36530. /**
  36531. * Get the gamepad controllers based on type
  36532. * @param type The type of gamepad controller
  36533. * @returns Nullable gamepad
  36534. */
  36535. GamepadManager.prototype.getGamepadByType = function (type) {
  36536. if (type === void 0) { type = _gamepad__WEBPACK_IMPORTED_MODULE_5__["Gamepad"].XBOX; }
  36537. for (var _i = 0, _a = this._babylonGamepads; _i < _a.length; _i++) {
  36538. var gamepad = _a[_i];
  36539. if (gamepad && gamepad.type === type) {
  36540. return gamepad;
  36541. }
  36542. }
  36543. return null;
  36544. };
  36545. /**
  36546. * Disposes the gamepad manager
  36547. */
  36548. GamepadManager.prototype.dispose = function () {
  36549. if (this._gamepadEventSupported) {
  36550. if (this._onGamepadConnectedEvent) {
  36551. window.removeEventListener('gamepadconnected', this._onGamepadConnectedEvent);
  36552. }
  36553. if (this._onGamepadDisconnectedEvent) {
  36554. window.removeEventListener('gamepaddisconnected', this._onGamepadDisconnectedEvent);
  36555. }
  36556. this._onGamepadConnectedEvent = null;
  36557. this._onGamepadDisconnectedEvent = null;
  36558. }
  36559. this._babylonGamepads.forEach(function (gamepad) {
  36560. gamepad.dispose();
  36561. });
  36562. this.onGamepadConnectedObservable.clear();
  36563. this.onGamepadDisconnectedObservable.clear();
  36564. this._oneGamepadConnected = false;
  36565. this._stopMonitoringGamepads();
  36566. this._babylonGamepads = [];
  36567. };
  36568. GamepadManager.prototype._addNewGamepad = function (gamepad) {
  36569. if (!this._oneGamepadConnected) {
  36570. this._oneGamepadConnected = true;
  36571. }
  36572. var newGamepad;
  36573. var xboxOne = (gamepad.id.search("Xbox One") !== -1);
  36574. if (xboxOne || gamepad.id.search("Xbox 360") !== -1 || gamepad.id.search("xinput") !== -1) {
  36575. newGamepad = new _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"](gamepad.id, gamepad.index, gamepad, xboxOne);
  36576. }
  36577. // if pose is supported, use the (WebVR) pose enabled controller
  36578. else if (gamepad.pose) {
  36579. newGamepad = _Gamepads_Controllers_poseEnabledController__WEBPACK_IMPORTED_MODULE_3__["PoseEnabledControllerHelper"].InitiateController(gamepad);
  36580. }
  36581. else {
  36582. newGamepad = new _gamepad__WEBPACK_IMPORTED_MODULE_5__["GenericPad"](gamepad.id, gamepad.index, gamepad);
  36583. }
  36584. this._babylonGamepads[newGamepad.index] = newGamepad;
  36585. return newGamepad;
  36586. };
  36587. GamepadManager.prototype._startMonitoringGamepads = function () {
  36588. if (!this._isMonitoring) {
  36589. this._isMonitoring = true;
  36590. //back-comp
  36591. if (!this._scene) {
  36592. this._checkGamepadsStatus();
  36593. }
  36594. }
  36595. };
  36596. GamepadManager.prototype._stopMonitoringGamepads = function () {
  36597. this._isMonitoring = false;
  36598. };
  36599. /** @hidden */
  36600. GamepadManager.prototype._checkGamepadsStatus = function () {
  36601. var _this = this;
  36602. // Hack to be compatible Chrome
  36603. this._updateGamepadObjects();
  36604. for (var i in this._babylonGamepads) {
  36605. var gamepad = this._babylonGamepads[i];
  36606. if (!gamepad || !gamepad.isConnected) {
  36607. continue;
  36608. }
  36609. gamepad.update();
  36610. }
  36611. if (this._isMonitoring && !this._scene) {
  36612. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].QueueNewFrame(function () { _this._checkGamepadsStatus(); });
  36613. }
  36614. };
  36615. // This function is called only on Chrome, which does not properly support
  36616. // connection/disconnection events and forces you to recopy again the gamepad object
  36617. GamepadManager.prototype._updateGamepadObjects = function () {
  36618. var gamepads = navigator.getGamepads ? navigator.getGamepads() : (navigator.webkitGetGamepads ? navigator.webkitGetGamepads() : []);
  36619. for (var i = 0; i < gamepads.length; i++) {
  36620. var gamepad = gamepads[i];
  36621. if (gamepad) {
  36622. if (!this._babylonGamepads[gamepad.index]) {
  36623. var newGamepad = this._addNewGamepad(gamepad);
  36624. this.onGamepadConnectedObservable.notifyObservers(newGamepad);
  36625. }
  36626. else {
  36627. // Forced to copy again this object for Chrome for unknown reason
  36628. this._babylonGamepads[i].browserGamepad = gamepad;
  36629. if (!this._babylonGamepads[i].isConnected) {
  36630. this._babylonGamepads[i]._isConnected = true;
  36631. this.onGamepadConnectedObservable.notifyObservers(this._babylonGamepads[i]);
  36632. }
  36633. }
  36634. }
  36635. }
  36636. };
  36637. return GamepadManager;
  36638. }());
  36639. /***/ }),
  36640. /***/ "./Gamepads/gamepadSceneComponent.ts":
  36641. /*!*******************************************!*\
  36642. !*** ./Gamepads/gamepadSceneComponent.ts ***!
  36643. \*******************************************/
  36644. /*! exports provided: GamepadSystemSceneComponent */
  36645. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36646. "use strict";
  36647. __webpack_require__.r(__webpack_exports__);
  36648. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return GamepadSystemSceneComponent; });
  36649. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  36650. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  36651. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36652. /* harmony import */ var _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Cameras/freeCameraInputsManager */ "./Cameras/freeCameraInputsManager.ts");
  36653. /* harmony import */ var _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Cameras/Inputs/freeCameraGamepadInput */ "./Cameras/Inputs/freeCameraGamepadInput.ts");
  36654. /* harmony import */ var _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Cameras/arcRotateCameraInputsManager */ "./Cameras/arcRotateCameraInputsManager.ts");
  36655. /* harmony import */ var _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Cameras/Inputs/arcRotateCameraGamepadInput */ "./Cameras/Inputs/arcRotateCameraGamepadInput.ts");
  36656. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "gamepadManager", {
  36657. get: function () {
  36658. if (!this._gamepadManager) {
  36659. this._gamepadManager = new _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"](this);
  36660. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD);
  36661. if (!component) {
  36662. component = new GamepadSystemSceneComponent(this);
  36663. this._addComponent(component);
  36664. }
  36665. }
  36666. return this._gamepadManager;
  36667. },
  36668. enumerable: true,
  36669. configurable: true
  36670. });
  36671. /**
  36672. * Adds a gamepad to the free camera inputs manager
  36673. */
  36674. _Cameras_freeCameraInputsManager__WEBPACK_IMPORTED_MODULE_3__["FreeCameraInputsManager"].prototype.addGamepad = function () {
  36675. this.add(new _Cameras_Inputs_freeCameraGamepadInput__WEBPACK_IMPORTED_MODULE_4__["FreeCameraGamepadInput"]());
  36676. return this;
  36677. };
  36678. /**
  36679. * Adds a gamepad to the arc rotate camera inputs manager
  36680. */
  36681. _Cameras_arcRotateCameraInputsManager__WEBPACK_IMPORTED_MODULE_5__["ArcRotateCameraInputsManager"].prototype.addGamepad = function () {
  36682. this.add(new _Cameras_Inputs_arcRotateCameraGamepadInput__WEBPACK_IMPORTED_MODULE_6__["ArcRotateCameraGamepadInput"]());
  36683. return this;
  36684. };
  36685. /**
  36686. * Defines the gamepad scene component responsible to manage gamepads in a given scene
  36687. */
  36688. var GamepadSystemSceneComponent = /** @class */ (function () {
  36689. /**
  36690. * Creates a new instance of the component for the given scene
  36691. * @param scene Defines the scene to register the component in
  36692. */
  36693. function GamepadSystemSceneComponent(scene) {
  36694. /**
  36695. * The component name helpfull to identify the component in the list of scene components.
  36696. */
  36697. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GAMEPAD;
  36698. this.scene = scene;
  36699. }
  36700. /**
  36701. * Registers the component in a given scene
  36702. */
  36703. GamepadSystemSceneComponent.prototype.register = function () {
  36704. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_GAMEPAD, this, this._beforeCameraUpdate);
  36705. };
  36706. /**
  36707. * Rebuilds the elements related to this component in case of
  36708. * context lost for instance.
  36709. */
  36710. GamepadSystemSceneComponent.prototype.rebuild = function () {
  36711. // Nothing to do for gamepads
  36712. };
  36713. /**
  36714. * Disposes the component and the associated ressources
  36715. */
  36716. GamepadSystemSceneComponent.prototype.dispose = function () {
  36717. var gamepadManager = this.scene._gamepadManager;
  36718. if (gamepadManager) {
  36719. gamepadManager.dispose();
  36720. this.scene._gamepadManager = null;
  36721. }
  36722. };
  36723. GamepadSystemSceneComponent.prototype._beforeCameraUpdate = function () {
  36724. var gamepadManager = this.scene._gamepadManager;
  36725. if (gamepadManager && gamepadManager._isMonitoring) {
  36726. gamepadManager._checkGamepadsStatus();
  36727. }
  36728. };
  36729. return GamepadSystemSceneComponent;
  36730. }());
  36731. /***/ }),
  36732. /***/ "./Gamepads/index.ts":
  36733. /*!***************************!*\
  36734. !*** ./Gamepads/index.ts ***!
  36735. \***************************/
  36736. /*! exports provided: DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36737. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36738. "use strict";
  36739. __webpack_require__.r(__webpack_exports__);
  36740. /* harmony import */ var _Controllers_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Controllers/index */ "./Gamepads/Controllers/index.ts");
  36741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  36742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  36743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  36744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  36745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  36746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  36747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  36748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  36749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  36750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Controllers_index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  36751. /* harmony import */ var _gamepad__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gamepad */ "./Gamepads/gamepad.ts");
  36752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["StickValues"]; });
  36753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["Gamepad"]; });
  36754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _gamepad__WEBPACK_IMPORTED_MODULE_1__["GenericPad"]; });
  36755. /* harmony import */ var _gamepadManager__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gamepadManager */ "./Gamepads/gamepadManager.ts");
  36756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _gamepadManager__WEBPACK_IMPORTED_MODULE_2__["GamepadManager"]; });
  36757. /* harmony import */ var _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gamepadSceneComponent */ "./Gamepads/gamepadSceneComponent.ts");
  36758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _gamepadSceneComponent__WEBPACK_IMPORTED_MODULE_3__["GamepadSystemSceneComponent"]; });
  36759. /* harmony import */ var _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./xboxGamepad */ "./Gamepads/xboxGamepad.ts");
  36760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Button"]; });
  36761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Dpad"]; });
  36762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _xboxGamepad__WEBPACK_IMPORTED_MODULE_4__["Xbox360Pad"]; });
  36763. /***/ }),
  36764. /***/ "./Gamepads/xboxGamepad.ts":
  36765. /*!*********************************!*\
  36766. !*** ./Gamepads/xboxGamepad.ts ***!
  36767. \*********************************/
  36768. /*! exports provided: Xbox360Button, Xbox360Dpad, Xbox360Pad */
  36769. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  36770. "use strict";
  36771. __webpack_require__.r(__webpack_exports__);
  36772. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return Xbox360Button; });
  36773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return Xbox360Dpad; });
  36774. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return Xbox360Pad; });
  36775. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  36776. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  36777. /* harmony import */ var _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Gamepads/gamepad */ "./Gamepads/gamepad.ts");
  36778. /**
  36779. * Defines supported buttons for XBox360 compatible gamepads
  36780. */
  36781. var Xbox360Button;
  36782. (function (Xbox360Button) {
  36783. /** A */
  36784. Xbox360Button[Xbox360Button["A"] = 0] = "A";
  36785. /** B */
  36786. Xbox360Button[Xbox360Button["B"] = 1] = "B";
  36787. /** X */
  36788. Xbox360Button[Xbox360Button["X"] = 2] = "X";
  36789. /** Y */
  36790. Xbox360Button[Xbox360Button["Y"] = 3] = "Y";
  36791. /** Start */
  36792. Xbox360Button[Xbox360Button["Start"] = 4] = "Start";
  36793. /** Back */
  36794. Xbox360Button[Xbox360Button["Back"] = 5] = "Back";
  36795. /** Left button */
  36796. Xbox360Button[Xbox360Button["LB"] = 6] = "LB";
  36797. /** Right button */
  36798. Xbox360Button[Xbox360Button["RB"] = 7] = "RB";
  36799. /** Left stick */
  36800. Xbox360Button[Xbox360Button["LeftStick"] = 8] = "LeftStick";
  36801. /** Right stick */
  36802. Xbox360Button[Xbox360Button["RightStick"] = 9] = "RightStick";
  36803. })(Xbox360Button || (Xbox360Button = {}));
  36804. /** Defines values for XBox360 DPad */
  36805. var Xbox360Dpad;
  36806. (function (Xbox360Dpad) {
  36807. /** Up */
  36808. Xbox360Dpad[Xbox360Dpad["Up"] = 0] = "Up";
  36809. /** Down */
  36810. Xbox360Dpad[Xbox360Dpad["Down"] = 1] = "Down";
  36811. /** Left */
  36812. Xbox360Dpad[Xbox360Dpad["Left"] = 2] = "Left";
  36813. /** Right */
  36814. Xbox360Dpad[Xbox360Dpad["Right"] = 3] = "Right";
  36815. })(Xbox360Dpad || (Xbox360Dpad = {}));
  36816. /**
  36817. * Defines a XBox360 gamepad
  36818. */
  36819. var Xbox360Pad = /** @class */ (function (_super) {
  36820. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Xbox360Pad, _super);
  36821. /**
  36822. * Creates a new XBox360 gamepad object
  36823. * @param id defines the id of this gamepad
  36824. * @param index defines its index
  36825. * @param gamepad defines the internal HTML gamepad object
  36826. * @param xboxOne defines if it is a XBox One gamepad
  36827. */
  36828. function Xbox360Pad(id, index, gamepad, xboxOne) {
  36829. if (xboxOne === void 0) { xboxOne = false; }
  36830. var _this = _super.call(this, id, index, gamepad, 0, 1, 2, 3) || this;
  36831. _this._leftTrigger = 0;
  36832. _this._rightTrigger = 0;
  36833. /** Observable raised when a button is pressed */
  36834. _this.onButtonDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36835. /** Observable raised when a button is released */
  36836. _this.onButtonUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36837. /** Observable raised when a pad is pressed */
  36838. _this.onPadDownObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36839. /** Observable raised when a pad is released */
  36840. _this.onPadUpObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  36841. _this._buttonA = 0;
  36842. _this._buttonB = 0;
  36843. _this._buttonX = 0;
  36844. _this._buttonY = 0;
  36845. _this._buttonBack = 0;
  36846. _this._buttonStart = 0;
  36847. _this._buttonLB = 0;
  36848. _this._buttonRB = 0;
  36849. _this._buttonLeftStick = 0;
  36850. _this._buttonRightStick = 0;
  36851. _this._dPadUp = 0;
  36852. _this._dPadDown = 0;
  36853. _this._dPadLeft = 0;
  36854. _this._dPadRight = 0;
  36855. _this._isXboxOnePad = false;
  36856. _this.type = _Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"].XBOX;
  36857. _this._isXboxOnePad = xboxOne;
  36858. return _this;
  36859. }
  36860. /**
  36861. * Defines the callback to call when left trigger is pressed
  36862. * @param callback defines the callback to use
  36863. */
  36864. Xbox360Pad.prototype.onlefttriggerchanged = function (callback) {
  36865. this._onlefttriggerchanged = callback;
  36866. };
  36867. /**
  36868. * Defines the callback to call when right trigger is pressed
  36869. * @param callback defines the callback to use
  36870. */
  36871. Xbox360Pad.prototype.onrighttriggerchanged = function (callback) {
  36872. this._onrighttriggerchanged = callback;
  36873. };
  36874. Object.defineProperty(Xbox360Pad.prototype, "leftTrigger", {
  36875. /**
  36876. * Gets the left trigger value
  36877. */
  36878. get: function () {
  36879. return this._leftTrigger;
  36880. },
  36881. /**
  36882. * Sets the left trigger value
  36883. */
  36884. set: function (newValue) {
  36885. if (this._onlefttriggerchanged && this._leftTrigger !== newValue) {
  36886. this._onlefttriggerchanged(newValue);
  36887. }
  36888. this._leftTrigger = newValue;
  36889. },
  36890. enumerable: true,
  36891. configurable: true
  36892. });
  36893. Object.defineProperty(Xbox360Pad.prototype, "rightTrigger", {
  36894. /**
  36895. * Gets the right trigger value
  36896. */
  36897. get: function () {
  36898. return this._rightTrigger;
  36899. },
  36900. /**
  36901. * Sets the right trigger value
  36902. */
  36903. set: function (newValue) {
  36904. if (this._onrighttriggerchanged && this._rightTrigger !== newValue) {
  36905. this._onrighttriggerchanged(newValue);
  36906. }
  36907. this._rightTrigger = newValue;
  36908. },
  36909. enumerable: true,
  36910. configurable: true
  36911. });
  36912. /**
  36913. * Defines the callback to call when a button is pressed
  36914. * @param callback defines the callback to use
  36915. */
  36916. Xbox360Pad.prototype.onbuttondown = function (callback) {
  36917. this._onbuttondown = callback;
  36918. };
  36919. /**
  36920. * Defines the callback to call when a button is released
  36921. * @param callback defines the callback to use
  36922. */
  36923. Xbox360Pad.prototype.onbuttonup = function (callback) {
  36924. this._onbuttonup = callback;
  36925. };
  36926. /**
  36927. * Defines the callback to call when a pad is pressed
  36928. * @param callback defines the callback to use
  36929. */
  36930. Xbox360Pad.prototype.ondpaddown = function (callback) {
  36931. this._ondpaddown = callback;
  36932. };
  36933. /**
  36934. * Defines the callback to call when a pad is released
  36935. * @param callback defines the callback to use
  36936. */
  36937. Xbox360Pad.prototype.ondpadup = function (callback) {
  36938. this._ondpadup = callback;
  36939. };
  36940. Xbox360Pad.prototype._setButtonValue = function (newValue, currentValue, buttonType) {
  36941. if (newValue !== currentValue) {
  36942. if (newValue === 1) {
  36943. if (this._onbuttondown) {
  36944. this._onbuttondown(buttonType);
  36945. }
  36946. this.onButtonDownObservable.notifyObservers(buttonType);
  36947. }
  36948. if (newValue === 0) {
  36949. if (this._onbuttonup) {
  36950. this._onbuttonup(buttonType);
  36951. }
  36952. this.onButtonUpObservable.notifyObservers(buttonType);
  36953. }
  36954. }
  36955. return newValue;
  36956. };
  36957. Xbox360Pad.prototype._setDPadValue = function (newValue, currentValue, buttonType) {
  36958. if (newValue !== currentValue) {
  36959. if (newValue === 1) {
  36960. if (this._ondpaddown) {
  36961. this._ondpaddown(buttonType);
  36962. }
  36963. this.onPadDownObservable.notifyObservers(buttonType);
  36964. }
  36965. if (newValue === 0) {
  36966. if (this._ondpadup) {
  36967. this._ondpadup(buttonType);
  36968. }
  36969. this.onPadUpObservable.notifyObservers(buttonType);
  36970. }
  36971. }
  36972. return newValue;
  36973. };
  36974. Object.defineProperty(Xbox360Pad.prototype, "buttonA", {
  36975. /**
  36976. * Gets the value of the `A` button
  36977. */
  36978. get: function () {
  36979. return this._buttonA;
  36980. },
  36981. /**
  36982. * Sets the value of the `A` button
  36983. */
  36984. set: function (value) {
  36985. this._buttonA = this._setButtonValue(value, this._buttonA, Xbox360Button.A);
  36986. },
  36987. enumerable: true,
  36988. configurable: true
  36989. });
  36990. Object.defineProperty(Xbox360Pad.prototype, "buttonB", {
  36991. /**
  36992. * Gets the value of the `B` button
  36993. */
  36994. get: function () {
  36995. return this._buttonB;
  36996. },
  36997. /**
  36998. * Sets the value of the `B` button
  36999. */
  37000. set: function (value) {
  37001. this._buttonB = this._setButtonValue(value, this._buttonB, Xbox360Button.B);
  37002. },
  37003. enumerable: true,
  37004. configurable: true
  37005. });
  37006. Object.defineProperty(Xbox360Pad.prototype, "buttonX", {
  37007. /**
  37008. * Gets the value of the `X` button
  37009. */
  37010. get: function () {
  37011. return this._buttonX;
  37012. },
  37013. /**
  37014. * Sets the value of the `X` button
  37015. */
  37016. set: function (value) {
  37017. this._buttonX = this._setButtonValue(value, this._buttonX, Xbox360Button.X);
  37018. },
  37019. enumerable: true,
  37020. configurable: true
  37021. });
  37022. Object.defineProperty(Xbox360Pad.prototype, "buttonY", {
  37023. /**
  37024. * Gets the value of the `Y` button
  37025. */
  37026. get: function () {
  37027. return this._buttonY;
  37028. },
  37029. /**
  37030. * Sets the value of the `Y` button
  37031. */
  37032. set: function (value) {
  37033. this._buttonY = this._setButtonValue(value, this._buttonY, Xbox360Button.Y);
  37034. },
  37035. enumerable: true,
  37036. configurable: true
  37037. });
  37038. Object.defineProperty(Xbox360Pad.prototype, "buttonStart", {
  37039. /**
  37040. * Gets the value of the `Start` button
  37041. */
  37042. get: function () {
  37043. return this._buttonStart;
  37044. },
  37045. /**
  37046. * Sets the value of the `Start` button
  37047. */
  37048. set: function (value) {
  37049. this._buttonStart = this._setButtonValue(value, this._buttonStart, Xbox360Button.Start);
  37050. },
  37051. enumerable: true,
  37052. configurable: true
  37053. });
  37054. Object.defineProperty(Xbox360Pad.prototype, "buttonBack", {
  37055. /**
  37056. * Gets the value of the `Back` button
  37057. */
  37058. get: function () {
  37059. return this._buttonBack;
  37060. },
  37061. /**
  37062. * Sets the value of the `Back` button
  37063. */
  37064. set: function (value) {
  37065. this._buttonBack = this._setButtonValue(value, this._buttonBack, Xbox360Button.Back);
  37066. },
  37067. enumerable: true,
  37068. configurable: true
  37069. });
  37070. Object.defineProperty(Xbox360Pad.prototype, "buttonLB", {
  37071. /**
  37072. * Gets the value of the `Left` button
  37073. */
  37074. get: function () {
  37075. return this._buttonLB;
  37076. },
  37077. /**
  37078. * Sets the value of the `Left` button
  37079. */
  37080. set: function (value) {
  37081. this._buttonLB = this._setButtonValue(value, this._buttonLB, Xbox360Button.LB);
  37082. },
  37083. enumerable: true,
  37084. configurable: true
  37085. });
  37086. Object.defineProperty(Xbox360Pad.prototype, "buttonRB", {
  37087. /**
  37088. * Gets the value of the `Right` button
  37089. */
  37090. get: function () {
  37091. return this._buttonRB;
  37092. },
  37093. /**
  37094. * Sets the value of the `Right` button
  37095. */
  37096. set: function (value) {
  37097. this._buttonRB = this._setButtonValue(value, this._buttonRB, Xbox360Button.RB);
  37098. },
  37099. enumerable: true,
  37100. configurable: true
  37101. });
  37102. Object.defineProperty(Xbox360Pad.prototype, "buttonLeftStick", {
  37103. /**
  37104. * Gets the value of the Left joystick
  37105. */
  37106. get: function () {
  37107. return this._buttonLeftStick;
  37108. },
  37109. /**
  37110. * Sets the value of the Left joystick
  37111. */
  37112. set: function (value) {
  37113. this._buttonLeftStick = this._setButtonValue(value, this._buttonLeftStick, Xbox360Button.LeftStick);
  37114. },
  37115. enumerable: true,
  37116. configurable: true
  37117. });
  37118. Object.defineProperty(Xbox360Pad.prototype, "buttonRightStick", {
  37119. /**
  37120. * Gets the value of the Right joystick
  37121. */
  37122. get: function () {
  37123. return this._buttonRightStick;
  37124. },
  37125. /**
  37126. * Sets the value of the Right joystick
  37127. */
  37128. set: function (value) {
  37129. this._buttonRightStick = this._setButtonValue(value, this._buttonRightStick, Xbox360Button.RightStick);
  37130. },
  37131. enumerable: true,
  37132. configurable: true
  37133. });
  37134. Object.defineProperty(Xbox360Pad.prototype, "dPadUp", {
  37135. /**
  37136. * Gets the value of D-pad up
  37137. */
  37138. get: function () {
  37139. return this._dPadUp;
  37140. },
  37141. /**
  37142. * Sets the value of D-pad up
  37143. */
  37144. set: function (value) {
  37145. this._dPadUp = this._setDPadValue(value, this._dPadUp, Xbox360Dpad.Up);
  37146. },
  37147. enumerable: true,
  37148. configurable: true
  37149. });
  37150. Object.defineProperty(Xbox360Pad.prototype, "dPadDown", {
  37151. /**
  37152. * Gets the value of D-pad down
  37153. */
  37154. get: function () {
  37155. return this._dPadDown;
  37156. },
  37157. /**
  37158. * Sets the value of D-pad down
  37159. */
  37160. set: function (value) {
  37161. this._dPadDown = this._setDPadValue(value, this._dPadDown, Xbox360Dpad.Down);
  37162. },
  37163. enumerable: true,
  37164. configurable: true
  37165. });
  37166. Object.defineProperty(Xbox360Pad.prototype, "dPadLeft", {
  37167. /**
  37168. * Gets the value of D-pad left
  37169. */
  37170. get: function () {
  37171. return this._dPadLeft;
  37172. },
  37173. /**
  37174. * Sets the value of D-pad left
  37175. */
  37176. set: function (value) {
  37177. this._dPadLeft = this._setDPadValue(value, this._dPadLeft, Xbox360Dpad.Left);
  37178. },
  37179. enumerable: true,
  37180. configurable: true
  37181. });
  37182. Object.defineProperty(Xbox360Pad.prototype, "dPadRight", {
  37183. /**
  37184. * Gets the value of D-pad right
  37185. */
  37186. get: function () {
  37187. return this._dPadRight;
  37188. },
  37189. /**
  37190. * Sets the value of D-pad right
  37191. */
  37192. set: function (value) {
  37193. this._dPadRight = this._setDPadValue(value, this._dPadRight, Xbox360Dpad.Right);
  37194. },
  37195. enumerable: true,
  37196. configurable: true
  37197. });
  37198. /**
  37199. * Force the gamepad to synchronize with device values
  37200. */
  37201. Xbox360Pad.prototype.update = function () {
  37202. _super.prototype.update.call(this);
  37203. if (this._isXboxOnePad) {
  37204. this.buttonA = this.browserGamepad.buttons[0].value;
  37205. this.buttonB = this.browserGamepad.buttons[1].value;
  37206. this.buttonX = this.browserGamepad.buttons[2].value;
  37207. this.buttonY = this.browserGamepad.buttons[3].value;
  37208. this.buttonLB = this.browserGamepad.buttons[4].value;
  37209. this.buttonRB = this.browserGamepad.buttons[5].value;
  37210. this.leftTrigger = this.browserGamepad.axes[2];
  37211. this.rightTrigger = this.browserGamepad.axes[5];
  37212. this.buttonBack = this.browserGamepad.buttons[9].value;
  37213. this.buttonStart = this.browserGamepad.buttons[8].value;
  37214. this.buttonLeftStick = this.browserGamepad.buttons[6].value;
  37215. this.buttonRightStick = this.browserGamepad.buttons[7].value;
  37216. this.dPadUp = this.browserGamepad.buttons[11].value;
  37217. this.dPadDown = this.browserGamepad.buttons[12].value;
  37218. this.dPadLeft = this.browserGamepad.buttons[13].value;
  37219. this.dPadRight = this.browserGamepad.buttons[14].value;
  37220. }
  37221. else {
  37222. this.buttonA = this.browserGamepad.buttons[0].value;
  37223. this.buttonB = this.browserGamepad.buttons[1].value;
  37224. this.buttonX = this.browserGamepad.buttons[2].value;
  37225. this.buttonY = this.browserGamepad.buttons[3].value;
  37226. this.buttonLB = this.browserGamepad.buttons[4].value;
  37227. this.buttonRB = this.browserGamepad.buttons[5].value;
  37228. this.leftTrigger = this.browserGamepad.buttons[6].value;
  37229. this.rightTrigger = this.browserGamepad.buttons[7].value;
  37230. this.buttonBack = this.browserGamepad.buttons[8].value;
  37231. this.buttonStart = this.browserGamepad.buttons[9].value;
  37232. this.buttonLeftStick = this.browserGamepad.buttons[10].value;
  37233. this.buttonRightStick = this.browserGamepad.buttons[11].value;
  37234. this.dPadUp = this.browserGamepad.buttons[12].value;
  37235. this.dPadDown = this.browserGamepad.buttons[13].value;
  37236. this.dPadLeft = this.browserGamepad.buttons[14].value;
  37237. this.dPadRight = this.browserGamepad.buttons[15].value;
  37238. }
  37239. };
  37240. /**
  37241. * Disposes the gamepad
  37242. */
  37243. Xbox360Pad.prototype.dispose = function () {
  37244. _super.prototype.dispose.call(this);
  37245. this.onButtonDownObservable.clear();
  37246. this.onButtonUpObservable.clear();
  37247. this.onPadDownObservable.clear();
  37248. this.onPadUpObservable.clear();
  37249. };
  37250. return Xbox360Pad;
  37251. }(_Gamepads_gamepad__WEBPACK_IMPORTED_MODULE_2__["Gamepad"]));
  37252. /***/ }),
  37253. /***/ "./Gizmos/axisDragGizmo.ts":
  37254. /*!*********************************!*\
  37255. !*** ./Gizmos/axisDragGizmo.ts ***!
  37256. \*********************************/
  37257. /*! exports provided: AxisDragGizmo */
  37258. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37259. "use strict";
  37260. __webpack_require__.r(__webpack_exports__);
  37261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return AxisDragGizmo; });
  37262. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37263. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37264. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37265. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  37266. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  37267. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37268. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37269. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37270. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37271. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37272. /**
  37273. * Single axis drag gizmo
  37274. */
  37275. var AxisDragGizmo = /** @class */ (function (_super) {
  37276. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisDragGizmo, _super);
  37277. /**
  37278. * Creates an AxisDragGizmo
  37279. * @param gizmoLayer The utility layer the gizmo will be added to
  37280. * @param dragAxis The axis which the gizmo will be able to drag on
  37281. * @param color The color of the gizmo
  37282. */
  37283. function AxisDragGizmo(dragAxis, color, gizmoLayer) {
  37284. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37285. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_8__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37286. var _this = _super.call(this, gizmoLayer) || this;
  37287. _this._pointerObserver = null;
  37288. /**
  37289. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37290. */
  37291. _this.snapDistance = 0;
  37292. /**
  37293. * Event that fires each time the gizmo snaps to a new location.
  37294. * * snapDistance is the the change in distance
  37295. */
  37296. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37297. // Create Material
  37298. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37299. coloredMaterial.disableLighting = true;
  37300. coloredMaterial.emissiveColor = color;
  37301. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_9__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37302. hoverMaterial.disableLighting = true;
  37303. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37304. // Build mesh on root node
  37305. var arrow = AxisDragGizmo._CreateArrow(gizmoLayer.utilityLayerScene, coloredMaterial);
  37306. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37307. arrow.scaling.scaleInPlace(1 / 3);
  37308. arrow.parent = _this._rootMesh;
  37309. var currentSnapDragDistance = 0;
  37310. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37311. var tmpSnapEvent = { snapDistance: 0 };
  37312. // Add drag behavior to handle events when the gizmo is dragged
  37313. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_6__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37314. _this.dragBehavior.moveAttached = false;
  37315. _this._rootMesh.addBehavior(_this.dragBehavior);
  37316. var localDelta = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37317. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  37318. _this.dragBehavior.onDragObservable.add(function (event) {
  37319. if (_this.attachedMesh) {
  37320. // Convert delta to local translation if it has a parent
  37321. if (_this.attachedMesh.parent) {
  37322. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  37323. tmpMatrix.setTranslationFromFloats(0, 0, 0);
  37324. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(event.delta, tmpMatrix, localDelta);
  37325. }
  37326. else {
  37327. localDelta.copyFrom(event.delta);
  37328. }
  37329. // Snapping logic
  37330. if (_this.snapDistance == 0) {
  37331. _this.attachedMesh.position.addInPlace(localDelta);
  37332. }
  37333. else {
  37334. currentSnapDragDistance += event.dragDistance;
  37335. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37336. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37337. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37338. localDelta.normalizeToRef(tmpVector);
  37339. tmpVector.scaleInPlace(_this.snapDistance * dragSteps);
  37340. _this.attachedMesh.position.addInPlace(tmpVector);
  37341. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37342. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37343. }
  37344. }
  37345. }
  37346. });
  37347. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37348. if (_this._customMeshSet) {
  37349. return;
  37350. }
  37351. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37352. var material = isHovered ? hoverMaterial : coloredMaterial;
  37353. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37354. m.material = material;
  37355. if (m.color) {
  37356. m.color = material.emissiveColor;
  37357. }
  37358. });
  37359. });
  37360. return _this;
  37361. }
  37362. /** @hidden */
  37363. AxisDragGizmo._CreateArrow = function (scene, material) {
  37364. var arrow = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37365. var cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder("cylinder", { diameterTop: 0, height: 1.5, diameterBottom: 0.75, tessellation: 96 }, scene);
  37366. var line = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("line", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, scene);
  37367. line.color = material.emissiveColor;
  37368. cylinder.parent = arrow;
  37369. line.parent = arrow;
  37370. // Position arrow pointing in its drag axis
  37371. cylinder.scaling.scaleInPlace(0.05);
  37372. cylinder.material = material;
  37373. cylinder.rotation.x = Math.PI / 2;
  37374. cylinder.position.z += 0.3;
  37375. line.scaling.scaleInPlace(0.26);
  37376. line.rotation.x = Math.PI / 2;
  37377. line.material = material;
  37378. return arrow;
  37379. };
  37380. /** @hidden */
  37381. AxisDragGizmo._CreateArrowInstance = function (scene, arrow) {
  37382. var instance = new _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_3__["TransformNode"]("arrow", scene);
  37383. for (var _i = 0, _a = arrow.getChildMeshes(); _i < _a.length; _i++) {
  37384. var mesh = _a[_i];
  37385. var childInstance = mesh.createInstance(mesh.name);
  37386. childInstance.parent = instance;
  37387. }
  37388. return instance;
  37389. };
  37390. AxisDragGizmo.prototype._attachedMeshChanged = function (value) {
  37391. if (this.dragBehavior) {
  37392. this.dragBehavior.enabled = value ? true : false;
  37393. }
  37394. };
  37395. /**
  37396. * Disposes of the gizmo
  37397. */
  37398. AxisDragGizmo.prototype.dispose = function () {
  37399. this.onSnapObservable.clear();
  37400. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37401. this.dragBehavior.detach();
  37402. _super.prototype.dispose.call(this);
  37403. };
  37404. return AxisDragGizmo;
  37405. }(_gizmo__WEBPACK_IMPORTED_MODULE_7__["Gizmo"]));
  37406. /***/ }),
  37407. /***/ "./Gizmos/axisScaleGizmo.ts":
  37408. /*!**********************************!*\
  37409. !*** ./Gizmos/axisScaleGizmo.ts ***!
  37410. \**********************************/
  37411. /*! exports provided: AxisScaleGizmo */
  37412. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37413. "use strict";
  37414. __webpack_require__.r(__webpack_exports__);
  37415. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return AxisScaleGizmo; });
  37416. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37417. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37418. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37419. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37420. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37421. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37422. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37423. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37424. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37425. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37426. /**
  37427. * Single axis scale gizmo
  37428. */
  37429. var AxisScaleGizmo = /** @class */ (function (_super) {
  37430. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AxisScaleGizmo, _super);
  37431. /**
  37432. * Creates an AxisScaleGizmo
  37433. * @param gizmoLayer The utility layer the gizmo will be added to
  37434. * @param dragAxis The axis which the gizmo will be able to scale on
  37435. * @param color The color of the gizmo
  37436. */
  37437. function AxisScaleGizmo(dragAxis, color, gizmoLayer) {
  37438. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  37439. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  37440. var _this = _super.call(this, gizmoLayer) || this;
  37441. _this._pointerObserver = null;
  37442. /**
  37443. * Scale distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  37444. */
  37445. _this.snapDistance = 0;
  37446. /**
  37447. * Event that fires each time the gizmo snaps to a new location.
  37448. * * snapDistance is the the change in distance
  37449. */
  37450. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37451. /**
  37452. * If the scaling operation should be done on all axis (default: false)
  37453. */
  37454. _this.uniformScaling = false;
  37455. // Create Material
  37456. _this._coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37457. _this._coloredMaterial.disableLighting = true;
  37458. _this._coloredMaterial.emissiveColor = color;
  37459. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_6__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37460. hoverMaterial.disableLighting = true;
  37461. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  37462. // Build mesh on root node
  37463. var arrow = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37464. var arrowMesh = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_4__["BoxBuilder"].CreateBox("yPosMesh", { size: 0.4 }, gizmoLayer.utilityLayerScene);
  37465. var arrowTail = _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_5__["LinesBuilder"].CreateLines("yPosMesh", { points: [new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 0, 0), new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1.1, 0)] }, gizmoLayer.utilityLayerScene);
  37466. arrowTail.color = _this._coloredMaterial.emissiveColor;
  37467. arrow.addChild(arrowMesh);
  37468. arrow.addChild(arrowTail);
  37469. // Position arrow pointing in its drag axis
  37470. arrowMesh.scaling.scaleInPlace(0.1);
  37471. arrowMesh.material = _this._coloredMaterial;
  37472. arrowMesh.rotation.x = Math.PI / 2;
  37473. arrowMesh.position.z += 0.3;
  37474. arrowTail.scaling.scaleInPlace(0.26);
  37475. arrowTail.rotation.x = Math.PI / 2;
  37476. arrowTail.material = _this._coloredMaterial;
  37477. arrow.lookAt(_this._rootMesh.position.add(dragAxis));
  37478. _this._rootMesh.addChild(arrow);
  37479. arrow.scaling.scaleInPlace(1 / 3);
  37480. // Add drag behavior to handle events when the gizmo is dragged
  37481. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_7__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37482. _this.dragBehavior.moveAttached = false;
  37483. _this._rootMesh.addBehavior(_this.dragBehavior);
  37484. var currentSnapDragDistance = 0;
  37485. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  37486. var tmpSnapEvent = { snapDistance: 0 };
  37487. _this.dragBehavior.onDragObservable.add(function (event) {
  37488. if (_this.attachedMesh) {
  37489. // Snapping logic
  37490. var snapped = false;
  37491. var dragSteps = 0;
  37492. if (_this.uniformScaling) {
  37493. _this.attachedMesh.scaling.normalizeToRef(tmpVector);
  37494. if (tmpVector.y < 0) {
  37495. tmpVector.scaleInPlace(-1);
  37496. }
  37497. }
  37498. else {
  37499. tmpVector.copyFrom(dragAxis);
  37500. }
  37501. if (_this.snapDistance == 0) {
  37502. tmpVector.scaleToRef(event.dragDistance, tmpVector);
  37503. }
  37504. else {
  37505. currentSnapDragDistance += event.dragDistance;
  37506. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  37507. dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  37508. if (currentSnapDragDistance < 0) {
  37509. dragSteps *= -1;
  37510. }
  37511. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  37512. tmpVector.scaleToRef(_this.snapDistance * dragSteps, tmpVector);
  37513. snapped = true;
  37514. }
  37515. else {
  37516. tmpVector.scaleInPlace(0);
  37517. }
  37518. }
  37519. _this.attachedMesh.scaling.addInPlace(tmpVector);
  37520. if (snapped) {
  37521. tmpSnapEvent.snapDistance = _this.snapDistance * dragSteps;
  37522. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  37523. }
  37524. }
  37525. });
  37526. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37527. if (_this._customMeshSet) {
  37528. return;
  37529. }
  37530. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  37531. var material = isHovered ? hoverMaterial : _this._coloredMaterial;
  37532. _this._rootMesh.getChildMeshes().forEach(function (m) {
  37533. m.material = material;
  37534. if (m.color) {
  37535. m.color = material.emissiveColor;
  37536. }
  37537. });
  37538. });
  37539. return _this;
  37540. }
  37541. AxisScaleGizmo.prototype._attachedMeshChanged = function (value) {
  37542. if (this.dragBehavior) {
  37543. this.dragBehavior.enabled = value ? true : false;
  37544. }
  37545. };
  37546. /**
  37547. * Disposes of the gizmo
  37548. */
  37549. AxisScaleGizmo.prototype.dispose = function () {
  37550. this.onSnapObservable.clear();
  37551. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  37552. this.dragBehavior.detach();
  37553. _super.prototype.dispose.call(this);
  37554. };
  37555. /**
  37556. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  37557. * @param mesh The mesh to replace the default mesh of the gizmo
  37558. * @param useGizmoMaterial If the gizmo's default material should be used (default: false)
  37559. */
  37560. AxisScaleGizmo.prototype.setCustomMesh = function (mesh, useGizmoMaterial) {
  37561. var _this = this;
  37562. if (useGizmoMaterial === void 0) { useGizmoMaterial = false; }
  37563. _super.prototype.setCustomMesh.call(this, mesh);
  37564. if (useGizmoMaterial) {
  37565. this._rootMesh.getChildMeshes().forEach(function (m) {
  37566. m.material = _this._coloredMaterial;
  37567. if (m.color) {
  37568. m.color = _this._coloredMaterial.emissiveColor;
  37569. }
  37570. });
  37571. this._customMeshSet = false;
  37572. }
  37573. };
  37574. return AxisScaleGizmo;
  37575. }(_gizmo__WEBPACK_IMPORTED_MODULE_8__["Gizmo"]));
  37576. /***/ }),
  37577. /***/ "./Gizmos/boundingBoxGizmo.ts":
  37578. /*!************************************!*\
  37579. !*** ./Gizmos/boundingBoxGizmo.ts ***!
  37580. \************************************/
  37581. /*! exports provided: BoundingBoxGizmo */
  37582. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  37583. "use strict";
  37584. __webpack_require__.r(__webpack_exports__);
  37585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return BoundingBoxGizmo; });
  37586. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  37587. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  37588. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  37589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  37590. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  37591. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  37592. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  37593. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  37594. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  37595. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  37596. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  37597. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  37598. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  37599. /* harmony import */ var _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Misc/pivotTools */ "./Misc/pivotTools.ts");
  37600. /**
  37601. * Bounding box gizmo
  37602. */
  37603. var BoundingBoxGizmo = /** @class */ (function (_super) {
  37604. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BoundingBoxGizmo, _super);
  37605. /**
  37606. * Creates an BoundingBoxGizmo
  37607. * @param gizmoLayer The utility layer the gizmo will be added to
  37608. * @param color The color of the gizmo
  37609. */
  37610. function BoundingBoxGizmo(color, gizmoLayer) {
  37611. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Gray(); }
  37612. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_11__["UtilityLayerRenderer"].DefaultKeepDepthUtilityLayer; }
  37613. var _this = _super.call(this, gizmoLayer) || this;
  37614. _this._boundingDimensions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 1, 1);
  37615. _this._renderObserver = null;
  37616. _this._pointerObserver = null;
  37617. _this._scaleDragSpeed = 0.2;
  37618. _this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37619. _this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  37620. _this._tmpRotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  37621. /**
  37622. * 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)
  37623. */
  37624. _this.ignoreChildren = false;
  37625. /**
  37626. * 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)
  37627. */
  37628. _this.includeChildPredicate = null;
  37629. /**
  37630. * The size of the rotation spheres attached to the bounding box (Default: 0.1)
  37631. */
  37632. _this.rotationSphereSize = 0.1;
  37633. /**
  37634. * The size of the scale boxes attached to the bounding box (Default: 0.1)
  37635. */
  37636. _this.scaleBoxSize = 0.1;
  37637. /**
  37638. * 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)
  37639. */
  37640. _this.fixedDragMeshScreenSize = false;
  37641. /**
  37642. * The distance away from the object which the draggable meshes should appear world sized when fixedDragMeshScreenSize is set to true (default: 10)
  37643. */
  37644. _this.fixedDragMeshScreenSizeDistanceFactor = 10;
  37645. /**
  37646. * Fired when a rotation sphere or scale box is dragged
  37647. */
  37648. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37649. /**
  37650. * Fired when a scale box is dragged
  37651. */
  37652. _this.onScaleBoxDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37653. /**
  37654. * Fired when a scale box drag is ended
  37655. */
  37656. _this.onScaleBoxDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37657. /**
  37658. * Fired when a rotation sphere is dragged
  37659. */
  37660. _this.onRotationSphereDragObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37661. /**
  37662. * Fired when a rotation sphere drag is ended
  37663. */
  37664. _this.onRotationSphereDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  37665. /**
  37666. * 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)
  37667. */
  37668. _this.scalePivot = null;
  37669. _this._existingMeshScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  37670. // Dragging
  37671. _this._dragMesh = null;
  37672. _this.pointerDragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]();
  37673. // Do not update the gizmo's scale so it has a fixed size to the object its attached to
  37674. _this._updateScale = false;
  37675. _this._anchorMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("anchor", gizmoLayer.utilityLayerScene);
  37676. // Create Materials
  37677. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37678. coloredMaterial.disableLighting = true;
  37679. coloredMaterial.emissiveColor = color;
  37680. var hoverColoredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  37681. hoverColoredMaterial.disableLighting = true;
  37682. hoverColoredMaterial.emissiveColor = color.clone().add(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.3, 0.3, 0.3));
  37683. // Build bounding box out of lines
  37684. _this._lineBoundingBox = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37685. _this._lineBoundingBox.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37686. var lines = [];
  37687. 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));
  37688. 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));
  37689. 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));
  37690. 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));
  37691. 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));
  37692. 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));
  37693. 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));
  37694. 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));
  37695. 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));
  37696. 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));
  37697. 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));
  37698. 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));
  37699. lines.forEach(function (l) {
  37700. l.color = color;
  37701. l.position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-_this._boundingDimensions.x / 2, -_this._boundingDimensions.y / 2, -_this._boundingDimensions.z / 2));
  37702. l.isPickable = false;
  37703. _this._lineBoundingBox.addChild(l);
  37704. });
  37705. _this._rootMesh.addChild(_this._lineBoundingBox);
  37706. // Create rotation spheres
  37707. _this._rotateSpheresParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37708. _this._rotateSpheresParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37709. var _loop_1 = function (i_1) {
  37710. var sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__["SphereBuilder"].CreateSphere("", { diameter: 1 }, gizmoLayer.utilityLayerScene);
  37711. sphere.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37712. sphere.material = coloredMaterial;
  37713. // Drag behavior
  37714. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({});
  37715. _dragBehavior.moveAttached = false;
  37716. _dragBehavior.updateDragPlane = false;
  37717. sphere.addBehavior(_dragBehavior);
  37718. var startingTurnDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  37719. var totalTurnAmountOfDrag = 0;
  37720. _dragBehavior.onDragStartObservable.add(function () {
  37721. startingTurnDirection.copyFrom(sphere.forward);
  37722. totalTurnAmountOfDrag = 0;
  37723. });
  37724. _dragBehavior.onDragObservable.add(function (event) {
  37725. _this.onRotationSphereDragObservable.notifyObservers({});
  37726. if (_this.attachedMesh) {
  37727. var originalParent = _this.attachedMesh.parent;
  37728. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37729. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37730. return;
  37731. }
  37732. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37733. var worldDragDirection = startingTurnDirection;
  37734. // Project the world right on to the drag plane
  37735. var toSub = event.dragPlaneNormal.scale(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(event.dragPlaneNormal, worldDragDirection));
  37736. var dragAxis = worldDragDirection.subtract(toSub).normalizeToNew();
  37737. // project drag delta on to the resulting drag axis and rotate based on that
  37738. var projectDist = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Dot(dragAxis, event.delta) < 0 ? Math.abs(event.delta.length()) : -Math.abs(event.delta.length());
  37739. // Make rotation relative to size of mesh.
  37740. projectDist = (projectDist / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37741. // Rotate based on axis
  37742. if (!_this.attachedMesh.rotationQuaternion) {
  37743. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  37744. }
  37745. if (!_this._anchorMesh.rotationQuaternion) {
  37746. _this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(_this._anchorMesh.rotation.y, _this._anchorMesh.rotation.x, _this._anchorMesh.rotation.z);
  37747. }
  37748. // Do not allow the object to turn more than a full circle
  37749. totalTurnAmountOfDrag += projectDist;
  37750. if (Math.abs(totalTurnAmountOfDrag) <= 2 * Math.PI) {
  37751. if (i_1 >= 8) {
  37752. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, 0, projectDist, _this._tmpQuaternion);
  37753. }
  37754. else if (i_1 >= 4) {
  37755. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(projectDist, 0, 0, _this._tmpQuaternion);
  37756. }
  37757. else {
  37758. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(0, projectDist, 0, _this._tmpQuaternion);
  37759. }
  37760. // Rotate around center of bounding box
  37761. _this._anchorMesh.addChild(_this.attachedMesh);
  37762. _this._anchorMesh.rotationQuaternion.multiplyToRef(_this._tmpQuaternion, _this._anchorMesh.rotationQuaternion);
  37763. _this._anchorMesh.removeChild(_this.attachedMesh);
  37764. _this.attachedMesh.setParent(originalParent);
  37765. }
  37766. _this.updateBoundingBox();
  37767. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37768. }
  37769. _this._updateDummy();
  37770. });
  37771. // Selection/deselection
  37772. _dragBehavior.onDragStartObservable.add(function () {
  37773. _this.onDragStartObservable.notifyObservers({});
  37774. _this._selectNode(sphere);
  37775. });
  37776. _dragBehavior.onDragEndObservable.add(function () {
  37777. _this.onRotationSphereDragEndObservable.notifyObservers({});
  37778. _this._selectNode(null);
  37779. _this._updateDummy();
  37780. });
  37781. this_1._rotateSpheresParent.addChild(sphere);
  37782. };
  37783. var this_1 = this, _dragBehavior;
  37784. for (var i_1 = 0; i_1 < 12; i_1++) {
  37785. _loop_1(i_1);
  37786. }
  37787. _this._rootMesh.addChild(_this._rotateSpheresParent);
  37788. // Create scale cubes
  37789. _this._scaleBoxesParent = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_4__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  37790. _this._scaleBoxesParent.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  37791. for (var i = 0; i < 2; i++) {
  37792. for (var j = 0; j < 2; j++) {
  37793. var _loop_2 = function () {
  37794. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("", { size: 1 }, gizmoLayer.utilityLayerScene);
  37795. box.material = coloredMaterial;
  37796. // Dragging logic
  37797. var dragAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](i == 0 ? -1 : 1, j == 0 ? -1 : 1, k == 0 ? -1 : 1);
  37798. _dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_9__["PointerDragBehavior"]({ dragAxis: dragAxis });
  37799. _dragBehavior.moveAttached = false;
  37800. box.addBehavior(_dragBehavior);
  37801. _dragBehavior.onDragObservable.add(function (event) {
  37802. _this.onScaleBoxDragObservable.notifyObservers({});
  37803. if (_this.attachedMesh) {
  37804. var originalParent = _this.attachedMesh.parent;
  37805. if (originalParent && (originalParent.scaling && originalParent.scaling.isNonUniformWithinEpsilon(0.001))) {
  37806. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("BoundingBoxGizmo controls are not supported on child meshes with non-uniform parent scaling");
  37807. return;
  37808. }
  37809. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(_this.attachedMesh);
  37810. var relativeDragDistance = (event.dragDistance / _this._boundingDimensions.length()) * _this._anchorMesh.scaling.length();
  37811. var deltaScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](relativeDragDistance, relativeDragDistance, relativeDragDistance);
  37812. deltaScale.scaleInPlace(_this._scaleDragSpeed);
  37813. _this.updateBoundingBox();
  37814. if (_this.scalePivot) {
  37815. _this.attachedMesh.getWorldMatrix().getRotationMatrixToRef(_this._tmpRotationMatrix);
  37816. // Move anchor to desired pivot point (Bottom left corner + dimension/2)
  37817. _this._boundingDimensions.scaleToRef(0.5, _this._tmpVector);
  37818. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37819. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37820. _this._boundingDimensions.multiplyToRef(_this.scalePivot, _this._tmpVector);
  37821. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_this._tmpVector, _this._tmpRotationMatrix, _this._tmpVector);
  37822. _this._anchorMesh.position.addInPlace(_this._tmpVector);
  37823. }
  37824. else {
  37825. // Scale from the position of the opposite corner
  37826. box.absolutePosition.subtractToRef(_this._anchorMesh.position, _this._tmpVector);
  37827. _this._anchorMesh.position.subtractInPlace(_this._tmpVector);
  37828. }
  37829. _this._anchorMesh.addChild(_this.attachedMesh);
  37830. _this._anchorMesh.scaling.addInPlace(deltaScale);
  37831. if (_this._anchorMesh.scaling.x < 0 || _this._anchorMesh.scaling.y < 0 || _this._anchorMesh.scaling.z < 0) {
  37832. _this._anchorMesh.scaling.subtractInPlace(deltaScale);
  37833. }
  37834. _this._anchorMesh.removeChild(_this.attachedMesh);
  37835. _this.attachedMesh.setParent(originalParent);
  37836. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(_this.attachedMesh);
  37837. }
  37838. _this._updateDummy();
  37839. });
  37840. // Selection/deselection
  37841. _dragBehavior.onDragStartObservable.add(function () {
  37842. _this.onDragStartObservable.notifyObservers({});
  37843. _this._selectNode(box);
  37844. });
  37845. _dragBehavior.onDragEndObservable.add(function () {
  37846. _this.onScaleBoxDragEndObservable.notifyObservers({});
  37847. _this._selectNode(null);
  37848. _this._updateDummy();
  37849. });
  37850. this_2._scaleBoxesParent.addChild(box);
  37851. };
  37852. var this_2 = this, _dragBehavior;
  37853. for (var k = 0; k < 2; k++) {
  37854. _loop_2();
  37855. }
  37856. }
  37857. }
  37858. _this._rootMesh.addChild(_this._scaleBoxesParent);
  37859. // Hover color change
  37860. var pointerIds = new Array();
  37861. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  37862. if (!pointerIds[pointerInfo.event.pointerId]) {
  37863. _this._rotateSpheresParent.getChildMeshes().concat(_this._scaleBoxesParent.getChildMeshes()).forEach(function (mesh) {
  37864. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh == mesh) {
  37865. pointerIds[pointerInfo.event.pointerId] = mesh;
  37866. mesh.material = hoverColoredMaterial;
  37867. }
  37868. });
  37869. }
  37870. else {
  37871. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh != pointerIds[pointerInfo.event.pointerId]) {
  37872. pointerIds[pointerInfo.event.pointerId].material = coloredMaterial;
  37873. delete pointerIds[pointerInfo.event.pointerId];
  37874. }
  37875. }
  37876. });
  37877. // Update bounding box positions
  37878. _this._renderObserver = _this.gizmoLayer.originalScene.onBeforeRenderObservable.add(function () {
  37879. // Only update the bouding box if scaling has changed
  37880. if (_this.attachedMesh && !_this._existingMeshScale.equals(_this.attachedMesh.scaling)) {
  37881. _this.updateBoundingBox();
  37882. }
  37883. else if (_this.fixedDragMeshScreenSize) {
  37884. _this._updateRotationSpheres();
  37885. _this._updateScaleBoxes();
  37886. }
  37887. // If dragg mesh is enabled and dragging, update the attached mesh pose to match the drag mesh
  37888. if (_this._dragMesh && _this.attachedMesh && _this.pointerDragBehavior.dragging) {
  37889. _this._lineBoundingBox.position.rotateByQuaternionToRef(_this._rootMesh.rotationQuaternion, _this._tmpVector);
  37890. _this.attachedMesh.setAbsolutePosition(_this._dragMesh.position.add(_this._tmpVector.scale(-1)));
  37891. }
  37892. });
  37893. _this.updateBoundingBox();
  37894. return _this;
  37895. }
  37896. BoundingBoxGizmo.prototype._attachedMeshChanged = function (value) {
  37897. var _this = this;
  37898. if (value) {
  37899. // Reset anchor mesh to match attached mesh's scale
  37900. // This is needed to avoid invalid box/sphere position on first drag
  37901. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(value);
  37902. var originalParent = value.parent;
  37903. this._anchorMesh.addChild(value);
  37904. this._anchorMesh.removeChild(value);
  37905. value.setParent(originalParent);
  37906. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(value);
  37907. this.updateBoundingBox();
  37908. value.getChildMeshes(false).forEach(function (m) {
  37909. m.markAsDirty("scaling");
  37910. });
  37911. this.gizmoLayer.utilityLayerScene.onAfterRenderObservable.addOnce(function () {
  37912. _this._updateDummy();
  37913. });
  37914. }
  37915. };
  37916. BoundingBoxGizmo.prototype._selectNode = function (selectedMesh) {
  37917. this._rotateSpheresParent.getChildMeshes()
  37918. .concat(this._scaleBoxesParent.getChildMeshes()).forEach(function (m) {
  37919. m.isVisible = (!selectedMesh || m == selectedMesh);
  37920. });
  37921. };
  37922. /**
  37923. * Updates the bounding box information for the Gizmo
  37924. */
  37925. BoundingBoxGizmo.prototype.updateBoundingBox = function () {
  37926. if (this.attachedMesh) {
  37927. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RemoveAndStorePivotPoint(this.attachedMesh);
  37928. var originalParent = this.attachedMesh.parent;
  37929. this.attachedMesh.setParent(null);
  37930. this._update();
  37931. // Rotate based on axis
  37932. if (!this.attachedMesh.rotationQuaternion) {
  37933. this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.attachedMesh.rotation.y, this.attachedMesh.rotation.x, this.attachedMesh.rotation.z);
  37934. }
  37935. if (!this._anchorMesh.rotationQuaternion) {
  37936. this._anchorMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this._anchorMesh.rotation.y, this._anchorMesh.rotation.x, this._anchorMesh.rotation.z);
  37937. }
  37938. this._anchorMesh.rotationQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37939. // Store original position and reset mesh to origin before computing the bounding box
  37940. this._tmpQuaternion.copyFrom(this.attachedMesh.rotationQuaternion);
  37941. this._tmpVector.copyFrom(this.attachedMesh.position);
  37942. this.attachedMesh.rotationQuaternion.set(0, 0, 0, 1);
  37943. this.attachedMesh.position.set(0, 0, 0);
  37944. // Update bounding dimensions/positions
  37945. var boundingMinMax = this.attachedMesh.getHierarchyBoundingVectors(!this.ignoreChildren, this.includeChildPredicate);
  37946. boundingMinMax.max.subtractToRef(boundingMinMax.min, this._boundingDimensions);
  37947. // Update gizmo to match bounding box scaling and rotation
  37948. this._lineBoundingBox.scaling.copyFrom(this._boundingDimensions);
  37949. 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);
  37950. this._rotateSpheresParent.position.copyFrom(this._lineBoundingBox.position);
  37951. this._scaleBoxesParent.position.copyFrom(this._lineBoundingBox.position);
  37952. this._lineBoundingBox.computeWorldMatrix();
  37953. this._anchorMesh.position.copyFrom(this._lineBoundingBox.absolutePosition);
  37954. // restore position/rotation values
  37955. this.attachedMesh.rotationQuaternion.copyFrom(this._tmpQuaternion);
  37956. this.attachedMesh.position.copyFrom(this._tmpVector);
  37957. this.attachedMesh.setParent(originalParent);
  37958. }
  37959. this._updateRotationSpheres();
  37960. this._updateScaleBoxes();
  37961. if (this.attachedMesh) {
  37962. this._existingMeshScale.copyFrom(this.attachedMesh.scaling);
  37963. _Misc_pivotTools__WEBPACK_IMPORTED_MODULE_13__["PivotTools"]._RestorePivotPoint(this.attachedMesh);
  37964. }
  37965. };
  37966. BoundingBoxGizmo.prototype._updateRotationSpheres = function () {
  37967. var rotateSpheres = this._rotateSpheresParent.getChildMeshes();
  37968. for (var i = 0; i < 3; i++) {
  37969. for (var j = 0; j < 2; j++) {
  37970. for (var k = 0; k < 2; k++) {
  37971. var index = ((i * 4) + (j * 2)) + k;
  37972. if (i == 0) {
  37973. rotateSpheres[index].position.set(this._boundingDimensions.x / 2, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  37974. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37975. 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));
  37976. }
  37977. if (i == 1) {
  37978. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y / 2, this._boundingDimensions.z * k);
  37979. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37980. 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));
  37981. }
  37982. if (i == 2) {
  37983. rotateSpheres[index].position.set(this._boundingDimensions.x * j, this._boundingDimensions.y * k, this._boundingDimensions.z / 2);
  37984. rotateSpheres[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  37985. 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));
  37986. }
  37987. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  37988. rotateSpheres[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  37989. var distanceFromCamera = this.rotationSphereSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  37990. rotateSpheres[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  37991. }
  37992. else {
  37993. rotateSpheres[index].scaling.set(this.rotationSphereSize, this.rotationSphereSize, this.rotationSphereSize);
  37994. }
  37995. }
  37996. }
  37997. }
  37998. };
  37999. BoundingBoxGizmo.prototype._updateScaleBoxes = function () {
  38000. var scaleBoxes = this._scaleBoxesParent.getChildMeshes();
  38001. for (var i = 0; i < 2; i++) {
  38002. for (var j = 0; j < 2; j++) {
  38003. for (var k = 0; k < 2; k++) {
  38004. var index = ((i * 4) + (j * 2)) + k;
  38005. if (scaleBoxes[index]) {
  38006. scaleBoxes[index].position.set(this._boundingDimensions.x * i, this._boundingDimensions.y * j, this._boundingDimensions.z * k);
  38007. scaleBoxes[index].position.addInPlace(new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-this._boundingDimensions.x / 2, -this._boundingDimensions.y / 2, -this._boundingDimensions.z / 2));
  38008. if (this.fixedDragMeshScreenSize && this.gizmoLayer.utilityLayerScene.activeCamera) {
  38009. scaleBoxes[index].absolutePosition.subtractToRef(this.gizmoLayer.utilityLayerScene.activeCamera.position, this._tmpVector);
  38010. var distanceFromCamera = this.scaleBoxSize * this._tmpVector.length() / this.fixedDragMeshScreenSizeDistanceFactor;
  38011. scaleBoxes[index].scaling.set(distanceFromCamera, distanceFromCamera, distanceFromCamera);
  38012. }
  38013. else {
  38014. scaleBoxes[index].scaling.set(this.scaleBoxSize, this.scaleBoxSize, this.scaleBoxSize);
  38015. }
  38016. }
  38017. }
  38018. }
  38019. }
  38020. };
  38021. /**
  38022. * Enables rotation on the specified axis and disables rotation on the others
  38023. * @param axis The list of axis that should be enabled (eg. "xy" or "xyz")
  38024. */
  38025. BoundingBoxGizmo.prototype.setEnabledRotationAxis = function (axis) {
  38026. this._rotateSpheresParent.getChildMeshes().forEach(function (m, i) {
  38027. if (i < 4) {
  38028. m.setEnabled(axis.indexOf("x") != -1);
  38029. }
  38030. else if (i < 8) {
  38031. m.setEnabled(axis.indexOf("y") != -1);
  38032. }
  38033. else {
  38034. m.setEnabled(axis.indexOf("z") != -1);
  38035. }
  38036. });
  38037. };
  38038. /**
  38039. * Enables/disables scaling
  38040. * @param enable if scaling should be enabled
  38041. */
  38042. BoundingBoxGizmo.prototype.setEnabledScaling = function (enable) {
  38043. this._scaleBoxesParent.getChildMeshes().forEach(function (m, i) {
  38044. m.setEnabled(enable);
  38045. });
  38046. };
  38047. BoundingBoxGizmo.prototype._updateDummy = function () {
  38048. if (this._dragMesh) {
  38049. this._dragMesh.position.copyFrom(this._lineBoundingBox.getAbsolutePosition());
  38050. this._dragMesh.scaling.copyFrom(this._lineBoundingBox.scaling);
  38051. this._dragMesh.rotationQuaternion.copyFrom(this._rootMesh.rotationQuaternion);
  38052. }
  38053. };
  38054. /**
  38055. * Enables a pointer drag behavior on the bounding box of the gizmo
  38056. */
  38057. BoundingBoxGizmo.prototype.enableDragBehavior = function () {
  38058. this._dragMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_5__["Mesh"].CreateBox("dummy", 1, this.gizmoLayer.utilityLayerScene);
  38059. this._dragMesh.visibility = 0;
  38060. this._dragMesh.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  38061. this.pointerDragBehavior.useObjectOrienationForDragging = false;
  38062. this._dragMesh.addBehavior(this.pointerDragBehavior);
  38063. };
  38064. /**
  38065. * Disposes of the gizmo
  38066. */
  38067. BoundingBoxGizmo.prototype.dispose = function () {
  38068. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38069. this.gizmoLayer.originalScene.onBeforeRenderObservable.remove(this._renderObserver);
  38070. this._lineBoundingBox.dispose();
  38071. this._rotateSpheresParent.dispose();
  38072. this._scaleBoxesParent.dispose();
  38073. if (this._dragMesh) {
  38074. this._dragMesh.dispose();
  38075. }
  38076. _super.prototype.dispose.call(this);
  38077. };
  38078. /**
  38079. * 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)
  38080. * @param mesh the mesh to wrap in the bounding box mesh and make not pickable
  38081. * @returns the bounding box mesh with the passed in mesh as a child
  38082. */
  38083. BoundingBoxGizmo.MakeNotPickableAndWrapInBoundingBox = function (mesh) {
  38084. var makeNotPickable = function (root) {
  38085. root.isPickable = false;
  38086. root.getChildMeshes().forEach(function (c) {
  38087. makeNotPickable(c);
  38088. });
  38089. };
  38090. makeNotPickable(mesh);
  38091. // Reset position to get boudning box from origin with no rotation
  38092. if (!mesh.rotationQuaternion) {
  38093. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(mesh.rotation.y, mesh.rotation.x, mesh.rotation.z);
  38094. }
  38095. var oldPos = mesh.position.clone();
  38096. var oldRot = mesh.rotationQuaternion.clone();
  38097. mesh.rotationQuaternion.set(0, 0, 0, 1);
  38098. mesh.position.set(0, 0, 0);
  38099. // Update bounding dimensions/positions
  38100. var box = _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_7__["BoxBuilder"].CreateBox("box", { size: 1 }, mesh.getScene());
  38101. var boundingMinMax = mesh.getHierarchyBoundingVectors();
  38102. boundingMinMax.max.subtractToRef(boundingMinMax.min, box.scaling);
  38103. // Adjust scale to avoid undefined behavior when adding child
  38104. if (box.scaling.y === 0) {
  38105. box.scaling.y = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38106. }
  38107. if (box.scaling.x === 0) {
  38108. box.scaling.x = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38109. }
  38110. if (box.scaling.z === 0) {
  38111. box.scaling.z = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Epsilon"];
  38112. }
  38113. box.position.set((boundingMinMax.max.x + boundingMinMax.min.x) / 2, (boundingMinMax.max.y + boundingMinMax.min.y) / 2, (boundingMinMax.max.z + boundingMinMax.min.z) / 2);
  38114. // Restore original positions
  38115. mesh.addChild(box);
  38116. mesh.rotationQuaternion.copyFrom(oldRot);
  38117. mesh.position.copyFrom(oldPos);
  38118. // Reverse parenting
  38119. mesh.removeChild(box);
  38120. box.addChild(mesh);
  38121. box.visibility = 0;
  38122. return box;
  38123. };
  38124. /**
  38125. * CustomMeshes are not supported by this gizmo
  38126. * @param mesh The mesh to replace the default mesh of the gizmo
  38127. */
  38128. BoundingBoxGizmo.prototype.setCustomMesh = function (mesh) {
  38129. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("Custom meshes are not supported on this gizmo");
  38130. };
  38131. return BoundingBoxGizmo;
  38132. }(_gizmo__WEBPACK_IMPORTED_MODULE_10__["Gizmo"]));
  38133. /***/ }),
  38134. /***/ "./Gizmos/gizmo.ts":
  38135. /*!*************************!*\
  38136. !*** ./Gizmos/gizmo.ts ***!
  38137. \*************************/
  38138. /*! exports provided: Gizmo */
  38139. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38140. "use strict";
  38141. __webpack_require__.r(__webpack_exports__);
  38142. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return Gizmo; });
  38143. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38144. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38145. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38146. /**
  38147. * Renders gizmos on top of an existing scene which provide controls for position, rotation, etc.
  38148. */
  38149. var Gizmo = /** @class */ (function () {
  38150. /**
  38151. * Creates a gizmo
  38152. * @param gizmoLayer The utility layer the gizmo will be added to
  38153. */
  38154. function Gizmo(
  38155. /** The utility layer the gizmo will be added to */
  38156. gizmoLayer) {
  38157. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_2__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38158. var _this = this;
  38159. this.gizmoLayer = gizmoLayer;
  38160. /**
  38161. * Ratio for the scale of the gizmo (Default: 1)
  38162. */
  38163. this.scaleRatio = 1;
  38164. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  38165. /**
  38166. * If a custom mesh has been set (Default: false)
  38167. */
  38168. this._customMeshSet = false;
  38169. /**
  38170. * If set the gizmo's rotation will be updated to match the attached mesh each frame (Default: true)
  38171. */
  38172. this.updateGizmoRotationToMatchAttachedMesh = true;
  38173. /**
  38174. * If set the gizmo's position will be updated to match the attached mesh each frame (Default: true)
  38175. */
  38176. this.updateGizmoPositionToMatchAttachedMesh = true;
  38177. /**
  38178. * When set, the gizmo will always appear the same size no matter where the camera is (default: false)
  38179. */
  38180. this._updateScale = true;
  38181. this._interactionsEnabled = true;
  38182. this._tempVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  38183. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]("gizmoRootNode", gizmoLayer.utilityLayerScene);
  38184. this._beforeRenderObserver = this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.add(function () {
  38185. _this._update();
  38186. });
  38187. this.attachedMesh = null;
  38188. }
  38189. Object.defineProperty(Gizmo.prototype, "attachedMesh", {
  38190. /**
  38191. * Mesh that the gizmo will be attached to. (eg. on a drag gizmo the mesh that will be dragged)
  38192. * * When set, interactions will be enabled
  38193. */
  38194. get: function () {
  38195. return this._attachedMesh;
  38196. },
  38197. set: function (value) {
  38198. this._attachedMesh = value;
  38199. this._rootMesh.setEnabled(value ? true : false);
  38200. this._attachedMeshChanged(value);
  38201. },
  38202. enumerable: true,
  38203. configurable: true
  38204. });
  38205. /**
  38206. * Disposes and replaces the current meshes in the gizmo with the specified mesh
  38207. * @param mesh The mesh to replace the default mesh of the gizmo
  38208. */
  38209. Gizmo.prototype.setCustomMesh = function (mesh) {
  38210. if (mesh.getScene() != this.gizmoLayer.utilityLayerScene) {
  38211. throw "When setting a custom mesh on a gizmo, the custom meshes scene must be the same as the gizmos (eg. gizmo.gizmoLayer.utilityLayerScene)";
  38212. }
  38213. this._rootMesh.getChildMeshes().forEach(function (c) {
  38214. c.dispose();
  38215. });
  38216. mesh.parent = this._rootMesh;
  38217. this._customMeshSet = true;
  38218. };
  38219. Gizmo.prototype._attachedMeshChanged = function (value) {
  38220. };
  38221. /**
  38222. * @hidden
  38223. * Updates the gizmo to match the attached mesh's position/rotation
  38224. */
  38225. Gizmo.prototype._update = function () {
  38226. if (this.attachedMesh) {
  38227. if (this.updateGizmoRotationToMatchAttachedMesh) {
  38228. if (!this._rootMesh.rotationQuaternion) {
  38229. this._rootMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRoll(this._rootMesh.rotation.y, this._rootMesh.rotation.x, this._rootMesh.rotation.z);
  38230. }
  38231. // Remove scaling before getting rotation matrix to get rotation matrix unmodified by scale
  38232. this._tempVector.copyFrom(this.attachedMesh.scaling);
  38233. if (this.attachedMesh.scaling.x < 0) {
  38234. this.attachedMesh.scaling.x *= -1;
  38235. }
  38236. if (this.attachedMesh.scaling.y < 0) {
  38237. this.attachedMesh.scaling.y *= -1;
  38238. }
  38239. if (this.attachedMesh.scaling.z < 0) {
  38240. this.attachedMesh.scaling.z *= -1;
  38241. }
  38242. this.attachedMesh.computeWorldMatrix().getRotationMatrixToRef(this._tmpMatrix);
  38243. this.attachedMesh.scaling.copyFrom(this._tempVector);
  38244. this.attachedMesh.computeWorldMatrix();
  38245. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].FromRotationMatrixToRef(this._tmpMatrix, this._rootMesh.rotationQuaternion);
  38246. }
  38247. else if (this._rootMesh.rotationQuaternion) {
  38248. this._rootMesh.rotationQuaternion.set(0, 0, 0, 1);
  38249. }
  38250. if (this.updateGizmoPositionToMatchAttachedMesh) {
  38251. this._rootMesh.position.copyFrom(this.attachedMesh.absolutePosition);
  38252. }
  38253. if (this._updateScale && this.gizmoLayer.utilityLayerScene.activeCamera && this.attachedMesh) {
  38254. var cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.globalPosition;
  38255. if (this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition) {
  38256. cameraPosition = this.gizmoLayer.utilityLayerScene.activeCamera.devicePosition;
  38257. }
  38258. this._rootMesh.position.subtractToRef(cameraPosition, this._tempVector);
  38259. var dist = this._tempVector.length() * this.scaleRatio;
  38260. this._rootMesh.scaling.set(dist, dist, dist);
  38261. }
  38262. }
  38263. };
  38264. /**
  38265. * Disposes of the gizmo
  38266. */
  38267. Gizmo.prototype.dispose = function () {
  38268. this._rootMesh.dispose();
  38269. if (this._beforeRenderObserver) {
  38270. this.gizmoLayer.utilityLayerScene.onBeforeRenderObservable.remove(this._beforeRenderObserver);
  38271. }
  38272. };
  38273. return Gizmo;
  38274. }());
  38275. /***/ }),
  38276. /***/ "./Gizmos/gizmoManager.ts":
  38277. /*!********************************!*\
  38278. !*** ./Gizmos/gizmoManager.ts ***!
  38279. \********************************/
  38280. /*! exports provided: GizmoManager */
  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__, "GizmoManager", function() { return GizmoManager; });
  38285. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38286. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  38287. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38288. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38290. /* harmony import */ var _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/sixDofDragBehavior */ "./Behaviors/Meshes/sixDofDragBehavior.ts");
  38291. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38292. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38293. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38294. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38295. /**
  38296. * Helps setup gizmo's in the scene to rotate/scale/position meshes
  38297. */
  38298. var GizmoManager = /** @class */ (function () {
  38299. /**
  38300. * Instatiates a gizmo manager
  38301. * @param scene the scene to overlay the gizmos on top of
  38302. */
  38303. function GizmoManager(scene) {
  38304. var _this = this;
  38305. this.scene = scene;
  38306. /** When true, the gizmo will be detached from the current object when a pointer down occurs with an empty picked mesh */
  38307. this.clearGizmoOnEmptyPointerEvent = false;
  38308. /** Fires an event when the manager is attached to a mesh */
  38309. this.onAttachedToMeshObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  38310. this._gizmosEnabled = { positionGizmo: false, rotationGizmo: false, scaleGizmo: false, boundingBoxGizmo: false };
  38311. this._pointerObserver = null;
  38312. this._attachedMesh = null;
  38313. this._boundingBoxColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromHexString("#0984e3");
  38314. /**
  38315. * When bounding box gizmo is enabled, this can be used to track drag/end events
  38316. */
  38317. this.boundingBoxDragBehavior = new _Behaviors_Meshes_sixDofDragBehavior__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]();
  38318. /**
  38319. * Array of meshes which will have the gizmo attached when a pointer selected them. If null, all meshes are attachable. (Default: null)
  38320. */
  38321. this.attachableMeshes = null;
  38322. /**
  38323. * If pointer events should perform attaching/detaching a gizmo, if false this can be done manually via attachToMesh. (Default: true)
  38324. */
  38325. this.usePointerToAttachGizmos = true;
  38326. this._defaultKeepDepthUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38327. this._defaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  38328. this._defaultUtilityLayer = new _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_3__["UtilityLayerRenderer"](scene);
  38329. this.gizmos = { positionGizmo: null, rotationGizmo: null, scaleGizmo: null, boundingBoxGizmo: null };
  38330. // Instatiate/dispose gizmos based on pointer actions
  38331. this._pointerObserver = scene.onPointerObservable.add(function (pointerInfo) {
  38332. if (!_this.usePointerToAttachGizmos) {
  38333. return;
  38334. }
  38335. if (pointerInfo.type == _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_1__["PointerEventTypes"].POINTERDOWN) {
  38336. if (pointerInfo.pickInfo && pointerInfo.pickInfo.pickedMesh) {
  38337. var node = pointerInfo.pickInfo.pickedMesh;
  38338. if (_this.attachableMeshes == null) {
  38339. // Attach to the most parent node
  38340. while (node && node.parent != null) {
  38341. node = node.parent;
  38342. }
  38343. }
  38344. else {
  38345. // Attach to the parent node that is an attachableMesh
  38346. var found = false;
  38347. _this.attachableMeshes.forEach(function (mesh) {
  38348. if (node && (node == mesh || node.isDescendantOf(mesh))) {
  38349. node = mesh;
  38350. found = true;
  38351. }
  38352. });
  38353. if (!found) {
  38354. node = null;
  38355. }
  38356. }
  38357. if (node instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]) {
  38358. if (_this._attachedMesh != node) {
  38359. _this.attachToMesh(node);
  38360. }
  38361. }
  38362. else {
  38363. if (_this.clearGizmoOnEmptyPointerEvent) {
  38364. _this.attachToMesh(null);
  38365. }
  38366. }
  38367. }
  38368. else {
  38369. if (_this.clearGizmoOnEmptyPointerEvent) {
  38370. _this.attachToMesh(null);
  38371. }
  38372. }
  38373. }
  38374. });
  38375. }
  38376. /**
  38377. * Attaches a set of gizmos to the specified mesh
  38378. * @param mesh The mesh the gizmo's should be attached to
  38379. */
  38380. GizmoManager.prototype.attachToMesh = function (mesh) {
  38381. if (this._attachedMesh) {
  38382. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38383. }
  38384. this._attachedMesh = mesh;
  38385. for (var key in this.gizmos) {
  38386. var gizmo = (this.gizmos[key]);
  38387. if (gizmo && this._gizmosEnabled[key]) {
  38388. gizmo.attachedMesh = mesh;
  38389. }
  38390. }
  38391. if (this.boundingBoxGizmoEnabled && this._attachedMesh) {
  38392. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38393. }
  38394. this.onAttachedToMeshObservable.notifyObservers(mesh);
  38395. };
  38396. Object.defineProperty(GizmoManager.prototype, "positionGizmoEnabled", {
  38397. get: function () {
  38398. return this._gizmosEnabled.positionGizmo;
  38399. },
  38400. /**
  38401. * If the position gizmo is enabled
  38402. */
  38403. set: function (value) {
  38404. if (value) {
  38405. if (!this.gizmos.positionGizmo) {
  38406. this.gizmos.positionGizmo = new _positionGizmo__WEBPACK_IMPORTED_MODULE_7__["PositionGizmo"](this._defaultUtilityLayer);
  38407. }
  38408. this.gizmos.positionGizmo.attachedMesh = this._attachedMesh;
  38409. }
  38410. else if (this.gizmos.positionGizmo) {
  38411. this.gizmos.positionGizmo.attachedMesh = null;
  38412. }
  38413. this._gizmosEnabled.positionGizmo = value;
  38414. },
  38415. enumerable: true,
  38416. configurable: true
  38417. });
  38418. Object.defineProperty(GizmoManager.prototype, "rotationGizmoEnabled", {
  38419. get: function () {
  38420. return this._gizmosEnabled.rotationGizmo;
  38421. },
  38422. /**
  38423. * If the rotation gizmo is enabled
  38424. */
  38425. set: function (value) {
  38426. if (value) {
  38427. if (!this.gizmos.rotationGizmo) {
  38428. this.gizmos.rotationGizmo = new _rotationGizmo__WEBPACK_IMPORTED_MODULE_6__["RotationGizmo"](this._defaultUtilityLayer);
  38429. }
  38430. this.gizmos.rotationGizmo.attachedMesh = this._attachedMesh;
  38431. }
  38432. else if (this.gizmos.rotationGizmo) {
  38433. this.gizmos.rotationGizmo.attachedMesh = null;
  38434. }
  38435. this._gizmosEnabled.rotationGizmo = value;
  38436. },
  38437. enumerable: true,
  38438. configurable: true
  38439. });
  38440. Object.defineProperty(GizmoManager.prototype, "scaleGizmoEnabled", {
  38441. get: function () {
  38442. return this._gizmosEnabled.scaleGizmo;
  38443. },
  38444. /**
  38445. * If the scale gizmo is enabled
  38446. */
  38447. set: function (value) {
  38448. if (value) {
  38449. this.gizmos.scaleGizmo = this.gizmos.scaleGizmo || new _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"](this._defaultUtilityLayer);
  38450. this.gizmos.scaleGizmo.attachedMesh = this._attachedMesh;
  38451. }
  38452. else if (this.gizmos.scaleGizmo) {
  38453. this.gizmos.scaleGizmo.attachedMesh = null;
  38454. }
  38455. this._gizmosEnabled.scaleGizmo = value;
  38456. },
  38457. enumerable: true,
  38458. configurable: true
  38459. });
  38460. Object.defineProperty(GizmoManager.prototype, "boundingBoxGizmoEnabled", {
  38461. get: function () {
  38462. return this._gizmosEnabled.boundingBoxGizmo;
  38463. },
  38464. /**
  38465. * If the boundingBox gizmo is enabled
  38466. */
  38467. set: function (value) {
  38468. if (value) {
  38469. this.gizmos.boundingBoxGizmo = this.gizmos.boundingBoxGizmo || new _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_9__["BoundingBoxGizmo"](this._boundingBoxColor, this._defaultKeepDepthUtilityLayer);
  38470. this.gizmos.boundingBoxGizmo.attachedMesh = this._attachedMesh;
  38471. if (this._attachedMesh) {
  38472. this._attachedMesh.removeBehavior(this.boundingBoxDragBehavior);
  38473. this._attachedMesh.addBehavior(this.boundingBoxDragBehavior);
  38474. }
  38475. }
  38476. else if (this.gizmos.boundingBoxGizmo) {
  38477. this.gizmos.boundingBoxGizmo.attachedMesh = null;
  38478. }
  38479. this._gizmosEnabled.boundingBoxGizmo = value;
  38480. },
  38481. enumerable: true,
  38482. configurable: true
  38483. });
  38484. /**
  38485. * Disposes of the gizmo manager
  38486. */
  38487. GizmoManager.prototype.dispose = function () {
  38488. this.scene.onPointerObservable.remove(this._pointerObserver);
  38489. for (var key in this.gizmos) {
  38490. var gizmo = (this.gizmos[key]);
  38491. if (gizmo) {
  38492. gizmo.dispose();
  38493. }
  38494. }
  38495. this._defaultKeepDepthUtilityLayer.dispose();
  38496. this._defaultUtilityLayer.dispose();
  38497. this.boundingBoxDragBehavior.detach();
  38498. this.onAttachedToMeshObservable.clear();
  38499. };
  38500. return GizmoManager;
  38501. }());
  38502. /***/ }),
  38503. /***/ "./Gizmos/index.ts":
  38504. /*!*************************!*\
  38505. !*** ./Gizmos/index.ts ***!
  38506. \*************************/
  38507. /*! exports provided: AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo */
  38508. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38509. "use strict";
  38510. __webpack_require__.r(__webpack_exports__);
  38511. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _axisDragGizmo__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  38513. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  38514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_1__["AxisScaleGizmo"]; });
  38515. /* harmony import */ var _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./boundingBoxGizmo */ "./Gizmos/boundingBoxGizmo.ts");
  38516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _boundingBoxGizmo__WEBPACK_IMPORTED_MODULE_2__["BoundingBoxGizmo"]; });
  38517. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _gizmo__WEBPACK_IMPORTED_MODULE_3__["Gizmo"]; });
  38519. /* harmony import */ var _gizmoManager__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmoManager */ "./Gizmos/gizmoManager.ts");
  38520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _gizmoManager__WEBPACK_IMPORTED_MODULE_4__["GizmoManager"]; });
  38521. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__["PlaneRotationGizmo"]; });
  38523. /* harmony import */ var _positionGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./positionGizmo */ "./Gizmos/positionGizmo.ts");
  38524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _positionGizmo__WEBPACK_IMPORTED_MODULE_6__["PositionGizmo"]; });
  38525. /* harmony import */ var _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./rotationGizmo */ "./Gizmos/rotationGizmo.ts");
  38526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _rotationGizmo__WEBPACK_IMPORTED_MODULE_7__["RotationGizmo"]; });
  38527. /* harmony import */ var _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./scaleGizmo */ "./Gizmos/scaleGizmo.ts");
  38528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _scaleGizmo__WEBPACK_IMPORTED_MODULE_8__["ScaleGizmo"]; });
  38529. /* harmony import */ var _lightGizmo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./lightGizmo */ "./Gizmos/lightGizmo.ts");
  38530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _lightGizmo__WEBPACK_IMPORTED_MODULE_9__["LightGizmo"]; });
  38531. /***/ }),
  38532. /***/ "./Gizmos/lightGizmo.ts":
  38533. /*!******************************!*\
  38534. !*** ./Gizmos/lightGizmo.ts ***!
  38535. \******************************/
  38536. /*! exports provided: LightGizmo */
  38537. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38538. "use strict";
  38539. __webpack_require__.r(__webpack_exports__);
  38540. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return LightGizmo; });
  38541. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38542. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38543. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38544. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38545. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38546. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38547. /**
  38548. * Gizmo that enables viewing a light
  38549. */
  38550. var LightGizmo = /** @class */ (function (_super) {
  38551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LightGizmo, _super);
  38552. /**
  38553. * Creates a LightGizmo
  38554. * @param gizmoLayer The utility layer the gizmo will be added to
  38555. */
  38556. function LightGizmo(gizmoLayer) {
  38557. var _this = _super.call(this, gizmoLayer) || this;
  38558. _this._light = null;
  38559. _this._box = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateCylinder("light", 0.02, 0, 0.02, 16, 1, _this.gizmoLayer.utilityLayerScene);
  38560. _this._box.rotation.x = -Math.PI / 2;
  38561. _this._box.bakeCurrentTransformIntoVertices();
  38562. _this._box.material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("", _this.gizmoLayer.utilityLayerScene);
  38563. _this._box.material.emissiveColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Yellow();
  38564. _this._rootMesh.addChild(_this._box);
  38565. _this.attachedMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]("", _this.gizmoLayer.utilityLayerScene);
  38566. return _this;
  38567. }
  38568. Object.defineProperty(LightGizmo.prototype, "light", {
  38569. get: function () {
  38570. return this._light;
  38571. },
  38572. /**
  38573. * The light that the gizmo is attached to
  38574. */
  38575. set: function (light) {
  38576. this._light = light;
  38577. if (light.position) {
  38578. this.attachedMesh.position.copyFrom(light.position);
  38579. }
  38580. if (light.direction) {
  38581. this._box.setDirection(light.direction);
  38582. }
  38583. },
  38584. enumerable: true,
  38585. configurable: true
  38586. });
  38587. /**
  38588. * @hidden
  38589. * Updates the gizmo to match the attached mesh's position/rotation
  38590. */
  38591. LightGizmo.prototype._update = function () {
  38592. _super.prototype._update.call(this);
  38593. if (!this._light) {
  38594. return;
  38595. }
  38596. if (this._light.position) {
  38597. this._light.position.copyFrom(this.attachedMesh.position);
  38598. }
  38599. if (this._light.direction) {
  38600. this._light.direction.copyFrom(this._box.forward);
  38601. }
  38602. if (!this._light.isEnabled()) {
  38603. this._box.material.emissiveColor.set(0, 0, 0);
  38604. }
  38605. else {
  38606. this._box.material.emissiveColor.set(1, 1, 1);
  38607. }
  38608. };
  38609. return LightGizmo;
  38610. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38611. /***/ }),
  38612. /***/ "./Gizmos/planeRotationGizmo.ts":
  38613. /*!**************************************!*\
  38614. !*** ./Gizmos/planeRotationGizmo.ts ***!
  38615. \**************************************/
  38616. /*! exports provided: PlaneRotationGizmo */
  38617. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38618. "use strict";
  38619. __webpack_require__.r(__webpack_exports__);
  38620. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return PlaneRotationGizmo; });
  38621. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38622. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38623. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38624. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  38625. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  38626. /* harmony import */ var _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Behaviors/Meshes/pointerDragBehavior */ "./Behaviors/Meshes/pointerDragBehavior.ts");
  38627. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38628. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38629. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  38630. /* harmony import */ var _Meshes_Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  38631. /**
  38632. * Single plane rotation gizmo
  38633. */
  38634. var PlaneRotationGizmo = /** @class */ (function (_super) {
  38635. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PlaneRotationGizmo, _super);
  38636. /**
  38637. * Creates a PlaneRotationGizmo
  38638. * @param gizmoLayer The utility layer the gizmo will be added to
  38639. * @param planeNormal The normal of the plane which the gizmo will be able to rotate on
  38640. * @param color The color of the gizmo
  38641. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38642. */
  38643. function PlaneRotationGizmo(planeNormal, color, gizmoLayer, tessellation) {
  38644. if (color === void 0) { color = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Gray(); }
  38645. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38646. if (tessellation === void 0) { tessellation = 32; }
  38647. var _this = _super.call(this, gizmoLayer) || this;
  38648. _this._pointerObserver = null;
  38649. /**
  38650. * Rotation distance in radians that the gizmo will snap to (Default: 0)
  38651. */
  38652. _this.snapDistance = 0;
  38653. /**
  38654. * Event that fires each time the gizmo snaps to a new location.
  38655. * * snapDistance is the the change in distance
  38656. */
  38657. _this.onSnapObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  38658. // Create Material
  38659. var coloredMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38660. coloredMaterial.disableLighting = true;
  38661. coloredMaterial.emissiveColor = color;
  38662. var hoverMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"]("", gizmoLayer.utilityLayerScene);
  38663. hoverMaterial.disableLighting = true;
  38664. hoverMaterial.emissiveColor = color.add(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.3, 0.3, 0.3));
  38665. // Build mesh on root node
  38666. var parentMesh = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]("", gizmoLayer.utilityLayerScene);
  38667. // Create circle out of lines
  38668. var radius = 0.8;
  38669. var points = new Array();
  38670. for (var i = 0; i < tessellation; i++) {
  38671. var radian = (2 * Math.PI) * (i / (tessellation - 1));
  38672. points.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](radius * Math.sin(radian), 0, radius * Math.cos(radian)));
  38673. }
  38674. var rotationMesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateLines("", points, gizmoLayer.utilityLayerScene);
  38675. rotationMesh.color = coloredMaterial.emissiveColor;
  38676. // Position arrow pointing in its drag axis
  38677. rotationMesh.scaling.scaleInPlace(0.26);
  38678. rotationMesh.material = coloredMaterial;
  38679. rotationMesh.rotation.x = Math.PI / 2;
  38680. parentMesh.addChild(rotationMesh);
  38681. parentMesh.lookAt(_this._rootMesh.position.add(planeNormal));
  38682. _this._rootMesh.addChild(parentMesh);
  38683. parentMesh.scaling.scaleInPlace(1 / 3);
  38684. // Add drag behavior to handle events when the gizmo is dragged
  38685. _this.dragBehavior = new _Behaviors_Meshes_pointerDragBehavior__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]({ dragPlaneNormal: planeNormal });
  38686. _this.dragBehavior.moveAttached = false;
  38687. _this.dragBehavior.maxDragAngle = Math.PI * 9 / 20;
  38688. _this.dragBehavior._useAlternatePickedPointAboveMaxDragAngle = true;
  38689. _this._rootMesh.addBehavior(_this.dragBehavior);
  38690. var lastDragPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38691. _this.dragBehavior.onDragStartObservable.add(function (e) {
  38692. if (_this.attachedMesh) {
  38693. lastDragPosition.copyFrom(e.dragPlanePoint);
  38694. }
  38695. });
  38696. var rotationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38697. var planeNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38698. var localPlaneNormalTowardsCamera = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38699. var tmpSnapEvent = { snapDistance: 0 };
  38700. var currentSnapDragDistance = 0;
  38701. var tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  38702. var tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"]();
  38703. var amountToRotate = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  38704. _this.dragBehavior.onDragObservable.add(function (event) {
  38705. if (_this.attachedMesh) {
  38706. if (!_this.attachedMesh.rotationQuaternion) {
  38707. _this.attachedMesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(_this.attachedMesh.rotation.y, _this.attachedMesh.rotation.x, _this.attachedMesh.rotation.z);
  38708. }
  38709. // Calc angle over full 360 degree (https://stackoverflow.com/questions/43493711/the-angle-between-two-3d-vectors-with-a-result-range-0-360)
  38710. var newVector = event.dragPlanePoint.subtract(_this.attachedMesh.absolutePosition).normalize();
  38711. var originalVector = lastDragPosition.subtract(_this.attachedMesh.absolutePosition).normalize();
  38712. var cross = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(newVector, originalVector);
  38713. var dot = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(newVector, originalVector);
  38714. var angle = Math.atan2(cross.length(), dot);
  38715. planeNormalTowardsCamera.copyFrom(planeNormal);
  38716. localPlaneNormalTowardsCamera.copyFrom(planeNormal);
  38717. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38718. _this.attachedMesh.rotationQuaternion.toRotationMatrix(rotationMatrix);
  38719. localPlaneNormalTowardsCamera = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinates(planeNormalTowardsCamera, rotationMatrix);
  38720. }
  38721. // Flip up vector depending on which side the camera is on
  38722. if (gizmoLayer.utilityLayerScene.activeCamera) {
  38723. var camVec = gizmoLayer.utilityLayerScene.activeCamera.position.subtract(_this.attachedMesh.position);
  38724. if (_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(camVec, localPlaneNormalTowardsCamera) > 0) {
  38725. planeNormalTowardsCamera.scaleInPlace(-1);
  38726. localPlaneNormalTowardsCamera.scaleInPlace(-1);
  38727. }
  38728. }
  38729. var halfCircleSide = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Dot(localPlaneNormalTowardsCamera, cross) > 0.0;
  38730. if (halfCircleSide) {
  38731. angle = -angle;
  38732. }
  38733. // Snapping logic
  38734. var snapped = false;
  38735. if (_this.snapDistance != 0) {
  38736. currentSnapDragDistance += angle;
  38737. if (Math.abs(currentSnapDragDistance) > _this.snapDistance) {
  38738. var dragSteps = Math.floor(Math.abs(currentSnapDragDistance) / _this.snapDistance);
  38739. if (currentSnapDragDistance < 0) {
  38740. dragSteps *= -1;
  38741. }
  38742. currentSnapDragDistance = currentSnapDragDistance % _this.snapDistance;
  38743. angle = _this.snapDistance * dragSteps;
  38744. snapped = true;
  38745. }
  38746. else {
  38747. angle = 0;
  38748. }
  38749. }
  38750. // If the mesh has a parent, convert needed world rotation to local rotation
  38751. tmpMatrix.reset();
  38752. if (_this.attachedMesh.parent) {
  38753. _this.attachedMesh.parent.computeWorldMatrix().invertToRef(tmpMatrix);
  38754. tmpMatrix.getRotationMatrixToRef(tmpMatrix);
  38755. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(planeNormalTowardsCamera, tmpMatrix, planeNormalTowardsCamera);
  38756. }
  38757. // Convert angle and axis to quaternion (http://www.euclideanspace.com/maths/geometry/rotations/conversions/angleToQuaternion/index.htm)
  38758. var quaternionCoefficient = Math.sin(angle / 2);
  38759. amountToRotate.set(planeNormalTowardsCamera.x * quaternionCoefficient, planeNormalTowardsCamera.y * quaternionCoefficient, planeNormalTowardsCamera.z * quaternionCoefficient, Math.cos(angle / 2));
  38760. // 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
  38761. if (tmpMatrix.determinant() > 0) {
  38762. amountToRotate.toEulerAnglesToRef(tmpVector);
  38763. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(tmpVector.y, -tmpVector.x, -tmpVector.z, amountToRotate);
  38764. }
  38765. if (_this.updateGizmoRotationToMatchAttachedMesh) {
  38766. // Rotate selected mesh quaternion over fixed axis
  38767. _this.attachedMesh.rotationQuaternion.multiplyToRef(amountToRotate, _this.attachedMesh.rotationQuaternion);
  38768. }
  38769. else {
  38770. // Rotate selected mesh quaternion over rotated axis
  38771. amountToRotate.multiplyToRef(_this.attachedMesh.rotationQuaternion, _this.attachedMesh.rotationQuaternion);
  38772. }
  38773. lastDragPosition.copyFrom(event.dragPlanePoint);
  38774. if (snapped) {
  38775. tmpSnapEvent.snapDistance = angle;
  38776. _this.onSnapObservable.notifyObservers(tmpSnapEvent);
  38777. }
  38778. }
  38779. });
  38780. _this._pointerObserver = gizmoLayer.utilityLayerScene.onPointerObservable.add(function (pointerInfo) {
  38781. if (_this._customMeshSet) {
  38782. return;
  38783. }
  38784. var isHovered = pointerInfo.pickInfo && (_this._rootMesh.getChildMeshes().indexOf(pointerInfo.pickInfo.pickedMesh) != -1);
  38785. var material = isHovered ? hoverMaterial : coloredMaterial;
  38786. _this._rootMesh.getChildMeshes().forEach(function (m) {
  38787. m.material = material;
  38788. if (m.color) {
  38789. m.color = material.emissiveColor;
  38790. }
  38791. });
  38792. });
  38793. return _this;
  38794. }
  38795. PlaneRotationGizmo.prototype._attachedMeshChanged = function (value) {
  38796. if (this.dragBehavior) {
  38797. this.dragBehavior.enabled = value ? true : false;
  38798. }
  38799. };
  38800. /**
  38801. * Disposes of the gizmo
  38802. */
  38803. PlaneRotationGizmo.prototype.dispose = function () {
  38804. this.onSnapObservable.clear();
  38805. this.gizmoLayer.utilityLayerScene.onPointerObservable.remove(this._pointerObserver);
  38806. this.dragBehavior.detach();
  38807. _super.prototype.dispose.call(this);
  38808. };
  38809. return PlaneRotationGizmo;
  38810. }(_gizmo__WEBPACK_IMPORTED_MODULE_6__["Gizmo"]));
  38811. /***/ }),
  38812. /***/ "./Gizmos/positionGizmo.ts":
  38813. /*!*********************************!*\
  38814. !*** ./Gizmos/positionGizmo.ts ***!
  38815. \*********************************/
  38816. /*! exports provided: PositionGizmo */
  38817. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38818. "use strict";
  38819. __webpack_require__.r(__webpack_exports__);
  38820. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return PositionGizmo; });
  38821. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38822. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38823. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38824. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38825. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38826. /* harmony import */ var _axisDragGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./axisDragGizmo */ "./Gizmos/axisDragGizmo.ts");
  38827. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38828. /**
  38829. * Gizmo that enables dragging a mesh along 3 axis
  38830. */
  38831. var PositionGizmo = /** @class */ (function (_super) {
  38832. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PositionGizmo, _super);
  38833. /**
  38834. * Creates a PositionGizmo
  38835. * @param gizmoLayer The utility layer the gizmo will be added to
  38836. */
  38837. function PositionGizmo(gizmoLayer) {
  38838. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38839. var _this = _super.call(this, gizmoLayer) || this;
  38840. /** Fires an event when any of it's sub gizmos are dragged */
  38841. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38842. /** Fires an event when any of it's sub gizmos are released from dragging */
  38843. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38844. _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);
  38845. _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);
  38846. _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);
  38847. // Relay drag events
  38848. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38849. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38850. _this.onDragStartObservable.notifyObservers({});
  38851. });
  38852. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38853. _this.onDragEndObservable.notifyObservers({});
  38854. });
  38855. });
  38856. _this.attachedMesh = null;
  38857. return _this;
  38858. }
  38859. Object.defineProperty(PositionGizmo.prototype, "attachedMesh", {
  38860. set: function (mesh) {
  38861. if (this.xGizmo) {
  38862. this.xGizmo.attachedMesh = mesh;
  38863. this.yGizmo.attachedMesh = mesh;
  38864. this.zGizmo.attachedMesh = mesh;
  38865. }
  38866. },
  38867. enumerable: true,
  38868. configurable: true
  38869. });
  38870. Object.defineProperty(PositionGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38871. get: function () {
  38872. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  38873. },
  38874. set: function (value) {
  38875. if (this.xGizmo) {
  38876. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38877. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38878. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  38879. }
  38880. },
  38881. enumerable: true,
  38882. configurable: true
  38883. });
  38884. Object.defineProperty(PositionGizmo.prototype, "snapDistance", {
  38885. get: function () {
  38886. return this.xGizmo.snapDistance;
  38887. },
  38888. /**
  38889. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  38890. */
  38891. set: function (value) {
  38892. if (this.xGizmo) {
  38893. this.xGizmo.snapDistance = value;
  38894. this.yGizmo.snapDistance = value;
  38895. this.zGizmo.snapDistance = value;
  38896. }
  38897. },
  38898. enumerable: true,
  38899. configurable: true
  38900. });
  38901. Object.defineProperty(PositionGizmo.prototype, "scaleRatio", {
  38902. get: function () {
  38903. return this.xGizmo.scaleRatio;
  38904. },
  38905. /**
  38906. * Ratio for the scale of the gizmo (Default: 1)
  38907. */
  38908. set: function (value) {
  38909. if (this.xGizmo) {
  38910. this.xGizmo.scaleRatio = value;
  38911. this.yGizmo.scaleRatio = value;
  38912. this.zGizmo.scaleRatio = value;
  38913. }
  38914. },
  38915. enumerable: true,
  38916. configurable: true
  38917. });
  38918. /**
  38919. * Disposes of the gizmo
  38920. */
  38921. PositionGizmo.prototype.dispose = function () {
  38922. this.xGizmo.dispose();
  38923. this.yGizmo.dispose();
  38924. this.zGizmo.dispose();
  38925. this.onDragStartObservable.clear();
  38926. this.onDragEndObservable.clear();
  38927. };
  38928. /**
  38929. * CustomMeshes are not supported by this gizmo
  38930. * @param mesh The mesh to replace the default mesh of the gizmo
  38931. */
  38932. PositionGizmo.prototype.setCustomMesh = function (mesh) {
  38933. _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)");
  38934. };
  38935. return PositionGizmo;
  38936. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  38937. /***/ }),
  38938. /***/ "./Gizmos/rotationGizmo.ts":
  38939. /*!*********************************!*\
  38940. !*** ./Gizmos/rotationGizmo.ts ***!
  38941. \*********************************/
  38942. /*! exports provided: RotationGizmo */
  38943. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  38944. "use strict";
  38945. __webpack_require__.r(__webpack_exports__);
  38946. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return RotationGizmo; });
  38947. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  38948. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  38949. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  38950. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  38951. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  38952. /* harmony import */ var _planeRotationGizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./planeRotationGizmo */ "./Gizmos/planeRotationGizmo.ts");
  38953. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  38954. /**
  38955. * Gizmo that enables rotating a mesh along 3 axis
  38956. */
  38957. var RotationGizmo = /** @class */ (function (_super) {
  38958. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RotationGizmo, _super);
  38959. /**
  38960. * Creates a RotationGizmo
  38961. * @param gizmoLayer The utility layer the gizmo will be added to
  38962. * @param tessellation Amount of tessellation to be used when creating rotation circles
  38963. */
  38964. function RotationGizmo(gizmoLayer, tessellation) {
  38965. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_6__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  38966. if (tessellation === void 0) { tessellation = 32; }
  38967. var _this = _super.call(this, gizmoLayer) || this;
  38968. /** Fires an event when any of it's sub gizmos are dragged */
  38969. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38970. /** Fires an event when any of it's sub gizmos are released from dragging */
  38971. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  38972. _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);
  38973. _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);
  38974. _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);
  38975. // Relay drag events
  38976. [_this.xGizmo, _this.yGizmo, _this.zGizmo].forEach(function (gizmo) {
  38977. gizmo.dragBehavior.onDragStartObservable.add(function () {
  38978. _this.onDragStartObservable.notifyObservers({});
  38979. });
  38980. gizmo.dragBehavior.onDragEndObservable.add(function () {
  38981. _this.onDragEndObservable.notifyObservers({});
  38982. });
  38983. });
  38984. _this.attachedMesh = null;
  38985. return _this;
  38986. }
  38987. Object.defineProperty(RotationGizmo.prototype, "attachedMesh", {
  38988. set: function (mesh) {
  38989. if (this.xGizmo) {
  38990. this.xGizmo.attachedMesh = mesh;
  38991. this.yGizmo.attachedMesh = mesh;
  38992. this.zGizmo.attachedMesh = mesh;
  38993. }
  38994. },
  38995. enumerable: true,
  38996. configurable: true
  38997. });
  38998. Object.defineProperty(RotationGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  38999. get: function () {
  39000. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39001. },
  39002. set: function (value) {
  39003. if (this.xGizmo) {
  39004. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39005. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39006. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39007. }
  39008. },
  39009. enumerable: true,
  39010. configurable: true
  39011. });
  39012. Object.defineProperty(RotationGizmo.prototype, "snapDistance", {
  39013. get: function () {
  39014. return this.xGizmo.snapDistance;
  39015. },
  39016. /**
  39017. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39018. */
  39019. set: function (value) {
  39020. if (this.xGizmo) {
  39021. this.xGizmo.snapDistance = value;
  39022. this.yGizmo.snapDistance = value;
  39023. this.zGizmo.snapDistance = value;
  39024. }
  39025. },
  39026. enumerable: true,
  39027. configurable: true
  39028. });
  39029. Object.defineProperty(RotationGizmo.prototype, "scaleRatio", {
  39030. get: function () {
  39031. return this.xGizmo.scaleRatio;
  39032. },
  39033. /**
  39034. * Ratio for the scale of the gizmo (Default: 1)
  39035. */
  39036. set: function (value) {
  39037. if (this.xGizmo) {
  39038. this.xGizmo.scaleRatio = value;
  39039. this.yGizmo.scaleRatio = value;
  39040. this.zGizmo.scaleRatio = value;
  39041. }
  39042. },
  39043. enumerable: true,
  39044. configurable: true
  39045. });
  39046. /**
  39047. * Disposes of the gizmo
  39048. */
  39049. RotationGizmo.prototype.dispose = function () {
  39050. this.xGizmo.dispose();
  39051. this.yGizmo.dispose();
  39052. this.zGizmo.dispose();
  39053. this.onDragStartObservable.clear();
  39054. this.onDragEndObservable.clear();
  39055. };
  39056. /**
  39057. * CustomMeshes are not supported by this gizmo
  39058. * @param mesh The mesh to replace the default mesh of the gizmo
  39059. */
  39060. RotationGizmo.prototype.setCustomMesh = function (mesh) {
  39061. _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)");
  39062. };
  39063. return RotationGizmo;
  39064. }(_gizmo__WEBPACK_IMPORTED_MODULE_4__["Gizmo"]));
  39065. /***/ }),
  39066. /***/ "./Gizmos/scaleGizmo.ts":
  39067. /*!******************************!*\
  39068. !*** ./Gizmos/scaleGizmo.ts ***!
  39069. \******************************/
  39070. /*! exports provided: ScaleGizmo */
  39071. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39072. "use strict";
  39073. __webpack_require__.r(__webpack_exports__);
  39074. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return ScaleGizmo; });
  39075. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39076. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39077. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39078. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39079. /* harmony import */ var _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  39080. /* harmony import */ var _gizmo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./gizmo */ "./Gizmos/gizmo.ts");
  39081. /* harmony import */ var _axisScaleGizmo__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./axisScaleGizmo */ "./Gizmos/axisScaleGizmo.ts");
  39082. /* harmony import */ var _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Rendering/utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  39083. /**
  39084. * Gizmo that enables scaling a mesh along 3 axis
  39085. */
  39086. var ScaleGizmo = /** @class */ (function (_super) {
  39087. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ScaleGizmo, _super);
  39088. /**
  39089. * Creates a ScaleGizmo
  39090. * @param gizmoLayer The utility layer the gizmo will be added to
  39091. */
  39092. function ScaleGizmo(gizmoLayer) {
  39093. if (gizmoLayer === void 0) { gizmoLayer = _Rendering_utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_7__["UtilityLayerRenderer"].DefaultUtilityLayer; }
  39094. var _this = _super.call(this, gizmoLayer) || this;
  39095. /** Fires an event when any of it's sub gizmos are dragged */
  39096. _this.onDragStartObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39097. /** Fires an event when any of it's sub gizmos are released from dragging */
  39098. _this.onDragEndObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  39099. _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);
  39100. _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);
  39101. _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);
  39102. // Create uniform scale gizmo
  39103. _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);
  39104. _this.uniformScaleGizmo.updateGizmoRotationToMatchAttachedMesh = false;
  39105. _this.uniformScaleGizmo.uniformScaling = true;
  39106. var uniformScalingMesh = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39107. uniformScalingMesh.scaling.scaleInPlace(0.02);
  39108. uniformScalingMesh.visibility = 0;
  39109. var octahedron = _Meshes_Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_4__["PolyhedronBuilder"].CreatePolyhedron("", { type: 1 }, _this.uniformScaleGizmo.gizmoLayer.utilityLayerScene);
  39110. octahedron.scaling.scaleInPlace(0.007);
  39111. uniformScalingMesh.addChild(octahedron);
  39112. _this.uniformScaleGizmo.setCustomMesh(uniformScalingMesh, true);
  39113. // Relay drag events
  39114. [_this.xGizmo, _this.yGizmo, _this.zGizmo, _this.uniformScaleGizmo].forEach(function (gizmo) {
  39115. gizmo.dragBehavior.onDragStartObservable.add(function () {
  39116. _this.onDragStartObservable.notifyObservers({});
  39117. });
  39118. gizmo.dragBehavior.onDragEndObservable.add(function () {
  39119. _this.onDragEndObservable.notifyObservers({});
  39120. });
  39121. });
  39122. _this.attachedMesh = null;
  39123. return _this;
  39124. }
  39125. Object.defineProperty(ScaleGizmo.prototype, "attachedMesh", {
  39126. set: function (mesh) {
  39127. if (this.xGizmo) {
  39128. this.xGizmo.attachedMesh = mesh;
  39129. this.yGizmo.attachedMesh = mesh;
  39130. this.zGizmo.attachedMesh = mesh;
  39131. this.uniformScaleGizmo.attachedMesh = mesh;
  39132. }
  39133. },
  39134. enumerable: true,
  39135. configurable: true
  39136. });
  39137. Object.defineProperty(ScaleGizmo.prototype, "updateGizmoRotationToMatchAttachedMesh", {
  39138. get: function () {
  39139. return this.xGizmo.updateGizmoRotationToMatchAttachedMesh;
  39140. },
  39141. set: function (value) {
  39142. if (!value) {
  39143. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Setting updateGizmoRotationToMatchAttachedMesh = false on scaling gizmo is not supported.");
  39144. }
  39145. if (this.xGizmo) {
  39146. this.xGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39147. this.yGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39148. this.zGizmo.updateGizmoRotationToMatchAttachedMesh = value;
  39149. }
  39150. },
  39151. enumerable: true,
  39152. configurable: true
  39153. });
  39154. Object.defineProperty(ScaleGizmo.prototype, "snapDistance", {
  39155. get: function () {
  39156. return this.xGizmo.snapDistance;
  39157. },
  39158. /**
  39159. * Drag distance in babylon units that the gizmo will snap to when dragged (Default: 0)
  39160. */
  39161. set: function (value) {
  39162. if (this.xGizmo) {
  39163. this.xGizmo.snapDistance = value;
  39164. this.yGizmo.snapDistance = value;
  39165. this.zGizmo.snapDistance = value;
  39166. this.uniformScaleGizmo.snapDistance = value;
  39167. }
  39168. },
  39169. enumerable: true,
  39170. configurable: true
  39171. });
  39172. Object.defineProperty(ScaleGizmo.prototype, "scaleRatio", {
  39173. get: function () {
  39174. return this.xGizmo.scaleRatio;
  39175. },
  39176. /**
  39177. * Ratio for the scale of the gizmo (Default: 1)
  39178. */
  39179. set: function (value) {
  39180. if (this.xGizmo) {
  39181. this.xGizmo.scaleRatio = value;
  39182. this.yGizmo.scaleRatio = value;
  39183. this.zGizmo.scaleRatio = value;
  39184. this.uniformScaleGizmo.scaleRatio = value;
  39185. }
  39186. },
  39187. enumerable: true,
  39188. configurable: true
  39189. });
  39190. /**
  39191. * Disposes of the gizmo
  39192. */
  39193. ScaleGizmo.prototype.dispose = function () {
  39194. this.xGizmo.dispose();
  39195. this.yGizmo.dispose();
  39196. this.zGizmo.dispose();
  39197. this.uniformScaleGizmo.dispose();
  39198. this.onDragStartObservable.clear();
  39199. this.onDragEndObservable.clear();
  39200. };
  39201. return ScaleGizmo;
  39202. }(_gizmo__WEBPACK_IMPORTED_MODULE_5__["Gizmo"]));
  39203. /***/ }),
  39204. /***/ "./Helpers/environmentHelper.ts":
  39205. /*!**************************************!*\
  39206. !*** ./Helpers/environmentHelper.ts ***!
  39207. \**************************************/
  39208. /*! exports provided: EnvironmentHelper */
  39209. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39210. "use strict";
  39211. __webpack_require__.r(__webpack_exports__);
  39212. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return EnvironmentHelper; });
  39213. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39214. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39215. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39216. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39217. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39218. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  39219. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39220. /* harmony import */ var _Materials_Textures_mirrorTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  39221. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  39222. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39223. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  39224. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  39225. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39226. /**
  39227. * The Environment helper class can be used to add a fully featuread none expensive background to your scene.
  39228. * It includes by default a skybox and a ground relying on the BackgroundMaterial.
  39229. * It also helps with the default setup of your imageProcessing configuration.
  39230. */
  39231. var EnvironmentHelper = /** @class */ (function () {
  39232. /**
  39233. * constructor
  39234. * @param options Defines the options we want to customize the helper
  39235. * @param scene The scene to add the material to
  39236. */
  39237. function EnvironmentHelper(options, scene) {
  39238. var _this = this;
  39239. this._errorHandler = function (message, exception) {
  39240. _this.onErrorObservable.notifyObservers({ message: message, exception: exception });
  39241. };
  39242. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, EnvironmentHelper._getDefaultOptions(), options);
  39243. this._scene = scene;
  39244. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39245. this._setupBackground();
  39246. this._setupImageProcessing();
  39247. }
  39248. /**
  39249. * Creates the default options for the helper.
  39250. */
  39251. EnvironmentHelper._getDefaultOptions = function () {
  39252. return {
  39253. createGround: true,
  39254. groundSize: 15,
  39255. groundTexture: this._groundTextureCDNUrl,
  39256. groundColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39257. groundOpacity: 0.9,
  39258. enableGroundShadow: true,
  39259. groundShadowLevel: 0.5,
  39260. enableGroundMirror: false,
  39261. groundMirrorSizeRatio: 0.3,
  39262. groundMirrorBlurKernel: 64,
  39263. groundMirrorAmount: 1,
  39264. groundMirrorFresnelWeight: 1,
  39265. groundMirrorFallOffDistance: 0,
  39266. groundMirrorTextureType: _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT,
  39267. groundYBias: 0.00001,
  39268. createSkybox: true,
  39269. skyboxSize: 20,
  39270. skyboxTexture: this._skyboxTextureCDNUrl,
  39271. skyboxColor: new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0.2, 0.2, 0.3).toLinearSpace().scale(3),
  39272. backgroundYRotation: 0,
  39273. sizeAuto: true,
  39274. rootPosition: _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(),
  39275. setupImageProcessing: true,
  39276. environmentTexture: this._environmentTextureCDNUrl,
  39277. cameraExposure: 0.8,
  39278. cameraContrast: 1.2,
  39279. toneMappingEnabled: true,
  39280. };
  39281. };
  39282. Object.defineProperty(EnvironmentHelper.prototype, "rootMesh", {
  39283. /**
  39284. * Gets the root mesh created by the helper.
  39285. */
  39286. get: function () {
  39287. return this._rootMesh;
  39288. },
  39289. enumerable: true,
  39290. configurable: true
  39291. });
  39292. Object.defineProperty(EnvironmentHelper.prototype, "skybox", {
  39293. /**
  39294. * Gets the skybox created by the helper.
  39295. */
  39296. get: function () {
  39297. return this._skybox;
  39298. },
  39299. enumerable: true,
  39300. configurable: true
  39301. });
  39302. Object.defineProperty(EnvironmentHelper.prototype, "skyboxTexture", {
  39303. /**
  39304. * Gets the skybox texture created by the helper.
  39305. */
  39306. get: function () {
  39307. return this._skyboxTexture;
  39308. },
  39309. enumerable: true,
  39310. configurable: true
  39311. });
  39312. Object.defineProperty(EnvironmentHelper.prototype, "skyboxMaterial", {
  39313. /**
  39314. * Gets the skybox material created by the helper.
  39315. */
  39316. get: function () {
  39317. return this._skyboxMaterial;
  39318. },
  39319. enumerable: true,
  39320. configurable: true
  39321. });
  39322. Object.defineProperty(EnvironmentHelper.prototype, "ground", {
  39323. /**
  39324. * Gets the ground mesh created by the helper.
  39325. */
  39326. get: function () {
  39327. return this._ground;
  39328. },
  39329. enumerable: true,
  39330. configurable: true
  39331. });
  39332. Object.defineProperty(EnvironmentHelper.prototype, "groundTexture", {
  39333. /**
  39334. * Gets the ground texture created by the helper.
  39335. */
  39336. get: function () {
  39337. return this._groundTexture;
  39338. },
  39339. enumerable: true,
  39340. configurable: true
  39341. });
  39342. Object.defineProperty(EnvironmentHelper.prototype, "groundMirror", {
  39343. /**
  39344. * Gets the ground mirror created by the helper.
  39345. */
  39346. get: function () {
  39347. return this._groundMirror;
  39348. },
  39349. enumerable: true,
  39350. configurable: true
  39351. });
  39352. Object.defineProperty(EnvironmentHelper.prototype, "groundMirrorRenderList", {
  39353. /**
  39354. * Gets the ground mirror render list to helps pushing the meshes
  39355. * you wish in the ground reflection.
  39356. */
  39357. get: function () {
  39358. if (this._groundMirror) {
  39359. return this._groundMirror.renderList;
  39360. }
  39361. return null;
  39362. },
  39363. enumerable: true,
  39364. configurable: true
  39365. });
  39366. Object.defineProperty(EnvironmentHelper.prototype, "groundMaterial", {
  39367. /**
  39368. * Gets the ground material created by the helper.
  39369. */
  39370. get: function () {
  39371. return this._groundMaterial;
  39372. },
  39373. enumerable: true,
  39374. configurable: true
  39375. });
  39376. /**
  39377. * Updates the background according to the new options
  39378. * @param options
  39379. */
  39380. EnvironmentHelper.prototype.updateOptions = function (options) {
  39381. var newOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, this._options, options);
  39382. if (this._ground && !newOptions.createGround) {
  39383. this._ground.dispose();
  39384. this._ground = null;
  39385. }
  39386. if (this._groundMaterial && !newOptions.createGround) {
  39387. this._groundMaterial.dispose();
  39388. this._groundMaterial = null;
  39389. }
  39390. if (this._groundTexture) {
  39391. if (this._options.groundTexture != newOptions.groundTexture) {
  39392. this._groundTexture.dispose();
  39393. this._groundTexture = null;
  39394. }
  39395. }
  39396. if (this._skybox && !newOptions.createSkybox) {
  39397. this._skybox.dispose();
  39398. this._skybox = null;
  39399. }
  39400. if (this._skyboxMaterial && !newOptions.createSkybox) {
  39401. this._skyboxMaterial.dispose();
  39402. this._skyboxMaterial = null;
  39403. }
  39404. if (this._skyboxTexture) {
  39405. if (this._options.skyboxTexture != newOptions.skyboxTexture) {
  39406. this._skyboxTexture.dispose();
  39407. this._skyboxTexture = null;
  39408. }
  39409. }
  39410. if (this._groundMirror && !newOptions.enableGroundMirror) {
  39411. this._groundMirror.dispose();
  39412. this._groundMirror = null;
  39413. }
  39414. if (this._scene.environmentTexture) {
  39415. if (this._options.environmentTexture != newOptions.environmentTexture) {
  39416. this._scene.environmentTexture.dispose();
  39417. }
  39418. }
  39419. this._options = newOptions;
  39420. this._setupBackground();
  39421. this._setupImageProcessing();
  39422. };
  39423. /**
  39424. * Sets the primary color of all the available elements.
  39425. * @param color the main color to affect to the ground and the background
  39426. */
  39427. EnvironmentHelper.prototype.setMainColor = function (color) {
  39428. if (this.groundMaterial) {
  39429. this.groundMaterial.primaryColor = color;
  39430. }
  39431. if (this.skyboxMaterial) {
  39432. this.skyboxMaterial.primaryColor = color;
  39433. }
  39434. if (this.groundMirror) {
  39435. this.groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](color.r, color.g, color.b, 1.0);
  39436. }
  39437. };
  39438. /**
  39439. * Setup the image processing according to the specified options.
  39440. */
  39441. EnvironmentHelper.prototype._setupImageProcessing = function () {
  39442. if (this._options.setupImageProcessing) {
  39443. this._scene.imageProcessingConfiguration.contrast = this._options.cameraContrast;
  39444. this._scene.imageProcessingConfiguration.exposure = this._options.cameraExposure;
  39445. this._scene.imageProcessingConfiguration.toneMappingEnabled = this._options.toneMappingEnabled;
  39446. this._setupEnvironmentTexture();
  39447. }
  39448. };
  39449. /**
  39450. * Setup the environment texture according to the specified options.
  39451. */
  39452. EnvironmentHelper.prototype._setupEnvironmentTexture = function () {
  39453. if (this._scene.environmentTexture) {
  39454. return;
  39455. }
  39456. if (this._options.environmentTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39457. this._scene.environmentTexture = this._options.environmentTexture;
  39458. return;
  39459. }
  39460. var environmentTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(this._options.environmentTexture, this._scene);
  39461. this._scene.environmentTexture = environmentTexture;
  39462. };
  39463. /**
  39464. * Setup the background according to the specified options.
  39465. */
  39466. EnvironmentHelper.prototype._setupBackground = function () {
  39467. if (!this._rootMesh) {
  39468. this._rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]("BackgroundHelper", this._scene);
  39469. }
  39470. this._rootMesh.rotation.y = this._options.backgroundYRotation;
  39471. var sceneSize = this._getSceneSize();
  39472. if (this._options.createGround) {
  39473. this._setupGround(sceneSize);
  39474. this._setupGroundMaterial();
  39475. this._setupGroundDiffuseTexture();
  39476. if (this._options.enableGroundMirror) {
  39477. this._setupGroundMirrorTexture(sceneSize);
  39478. }
  39479. this._setupMirrorInGroundMaterial();
  39480. }
  39481. if (this._options.createSkybox) {
  39482. this._setupSkybox(sceneSize);
  39483. this._setupSkyboxMaterial();
  39484. this._setupSkyboxReflectionTexture();
  39485. }
  39486. this._rootMesh.position.x = sceneSize.rootPosition.x;
  39487. this._rootMesh.position.z = sceneSize.rootPosition.z;
  39488. this._rootMesh.position.y = sceneSize.rootPosition.y;
  39489. };
  39490. /**
  39491. * Get the scene sizes according to the setup.
  39492. */
  39493. EnvironmentHelper.prototype._getSceneSize = function () {
  39494. var _this = this;
  39495. var groundSize = this._options.groundSize;
  39496. var skyboxSize = this._options.skyboxSize;
  39497. var rootPosition = this._options.rootPosition;
  39498. if (!this._scene.meshes || this._scene.meshes.length === 1) { // 1 only means the root of the helper.
  39499. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39500. }
  39501. var sceneExtends = this._scene.getWorldExtends(function (mesh) {
  39502. return (mesh !== _this._ground && mesh !== _this._rootMesh && mesh !== _this._skybox);
  39503. });
  39504. var sceneDiagonal = sceneExtends.max.subtract(sceneExtends.min);
  39505. if (this._options.sizeAuto) {
  39506. if (this._scene.activeCamera instanceof _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_2__["ArcRotateCamera"] &&
  39507. this._scene.activeCamera.upperRadiusLimit) {
  39508. groundSize = this._scene.activeCamera.upperRadiusLimit * 2;
  39509. skyboxSize = groundSize;
  39510. }
  39511. var sceneDiagonalLenght = sceneDiagonal.length();
  39512. if (sceneDiagonalLenght > groundSize) {
  39513. groundSize = sceneDiagonalLenght * 2;
  39514. skyboxSize = groundSize;
  39515. }
  39516. // 10 % bigger.
  39517. groundSize *= 1.1;
  39518. skyboxSize *= 1.5;
  39519. rootPosition = sceneExtends.min.add(sceneDiagonal.scale(0.5));
  39520. rootPosition.y = sceneExtends.min.y - this._options.groundYBias;
  39521. }
  39522. return { groundSize: groundSize, skyboxSize: skyboxSize, rootPosition: rootPosition };
  39523. };
  39524. /**
  39525. * Setup the ground according to the specified options.
  39526. */
  39527. EnvironmentHelper.prototype._setupGround = function (sceneSize) {
  39528. var _this = this;
  39529. if (!this._ground || this._ground.isDisposed()) {
  39530. this._ground = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreatePlane("BackgroundPlane", sceneSize.groundSize, this._scene);
  39531. this._ground.rotation.x = Math.PI / 2; // Face up by default.
  39532. this._ground.parent = this._rootMesh;
  39533. this._ground.onDisposeObservable.add(function () { _this._ground = null; });
  39534. }
  39535. this._ground.receiveShadows = this._options.enableGroundShadow;
  39536. };
  39537. /**
  39538. * Setup the ground material according to the specified options.
  39539. */
  39540. EnvironmentHelper.prototype._setupGroundMaterial = function () {
  39541. if (!this._groundMaterial) {
  39542. this._groundMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundPlaneMaterial", this._scene);
  39543. }
  39544. this._groundMaterial.alpha = this._options.groundOpacity;
  39545. this._groundMaterial.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF;
  39546. this._groundMaterial.shadowLevel = this._options.groundShadowLevel;
  39547. this._groundMaterial.primaryColor = this._options.groundColor;
  39548. this._groundMaterial.useRGBColor = false;
  39549. this._groundMaterial.enableNoise = true;
  39550. if (this._ground) {
  39551. this._ground.material = this._groundMaterial;
  39552. }
  39553. };
  39554. /**
  39555. * Setup the ground diffuse texture according to the specified options.
  39556. */
  39557. EnvironmentHelper.prototype._setupGroundDiffuseTexture = function () {
  39558. if (!this._groundMaterial) {
  39559. return;
  39560. }
  39561. if (this._groundTexture) {
  39562. return;
  39563. }
  39564. if (this._options.groundTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39565. this._groundMaterial.diffuseTexture = this._options.groundTexture;
  39566. return;
  39567. }
  39568. var diffuseTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](this._options.groundTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39569. diffuseTexture.gammaSpace = false;
  39570. diffuseTexture.hasAlpha = true;
  39571. this._groundMaterial.diffuseTexture = diffuseTexture;
  39572. };
  39573. /**
  39574. * Setup the ground mirror texture according to the specified options.
  39575. */
  39576. EnvironmentHelper.prototype._setupGroundMirrorTexture = function (sceneSize) {
  39577. var wrapping = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  39578. if (!this._groundMirror) {
  39579. 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);
  39580. this._groundMirror.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Plane"](0, -1, 0, sceneSize.rootPosition.y);
  39581. this._groundMirror.anisotropicFilteringLevel = 1;
  39582. this._groundMirror.wrapU = wrapping;
  39583. this._groundMirror.wrapV = wrapping;
  39584. this._groundMirror.gammaSpace = false;
  39585. if (this._groundMirror.renderList) {
  39586. for (var i = 0; i < this._scene.meshes.length; i++) {
  39587. var mesh = this._scene.meshes[i];
  39588. if (mesh !== this._ground &&
  39589. mesh !== this._skybox &&
  39590. mesh !== this._rootMesh) {
  39591. this._groundMirror.renderList.push(mesh);
  39592. }
  39593. }
  39594. }
  39595. }
  39596. this._groundMirror.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](this._options.groundColor.r, this._options.groundColor.g, this._options.groundColor.b, 1);
  39597. this._groundMirror.adaptiveBlurKernel = this._options.groundMirrorBlurKernel;
  39598. };
  39599. /**
  39600. * Setup the ground to receive the mirror texture.
  39601. */
  39602. EnvironmentHelper.prototype._setupMirrorInGroundMaterial = function () {
  39603. if (this._groundMaterial) {
  39604. this._groundMaterial.reflectionTexture = this._groundMirror;
  39605. this._groundMaterial.reflectionFresnel = true;
  39606. this._groundMaterial.reflectionAmount = this._options.groundMirrorAmount;
  39607. this._groundMaterial.reflectionStandardFresnelWeight = this._options.groundMirrorFresnelWeight;
  39608. this._groundMaterial.reflectionFalloffDistance = this._options.groundMirrorFallOffDistance;
  39609. }
  39610. };
  39611. /**
  39612. * Setup the skybox according to the specified options.
  39613. */
  39614. EnvironmentHelper.prototype._setupSkybox = function (sceneSize) {
  39615. var _this = this;
  39616. if (!this._skybox || this._skybox.isDisposed()) {
  39617. this._skybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].CreateBox("BackgroundSkybox", sceneSize.skyboxSize, this._scene, undefined, _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"].BACKSIDE);
  39618. this._skybox.onDisposeObservable.add(function () { _this._skybox = null; });
  39619. }
  39620. this._skybox.parent = this._rootMesh;
  39621. };
  39622. /**
  39623. * Setup the skybox material according to the specified options.
  39624. */
  39625. EnvironmentHelper.prototype._setupSkyboxMaterial = function () {
  39626. if (!this._skybox) {
  39627. return;
  39628. }
  39629. if (!this._skyboxMaterial) {
  39630. this._skyboxMaterial = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_9__["BackgroundMaterial"]("BackgroundSkyboxMaterial", this._scene);
  39631. }
  39632. this._skyboxMaterial.useRGBColor = false;
  39633. this._skyboxMaterial.primaryColor = this._options.skyboxColor;
  39634. this._skyboxMaterial.enableNoise = true;
  39635. this._skybox.material = this._skyboxMaterial;
  39636. };
  39637. /**
  39638. * Setup the skybox reflection texture according to the specified options.
  39639. */
  39640. EnvironmentHelper.prototype._setupSkyboxReflectionTexture = function () {
  39641. if (!this._skyboxMaterial) {
  39642. return;
  39643. }
  39644. if (this._skyboxTexture) {
  39645. return;
  39646. }
  39647. if (this._options.skyboxTexture instanceof _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]) {
  39648. this._skyboxMaterial.reflectionTexture = this._options.skyboxTexture;
  39649. return;
  39650. }
  39651. this._skyboxTexture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"](this._options.skyboxTexture, this._scene, undefined, undefined, undefined, undefined, this._errorHandler);
  39652. this._skyboxTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].SKYBOX_MODE;
  39653. this._skyboxTexture.gammaSpace = false;
  39654. this._skyboxMaterial.reflectionTexture = this._skyboxTexture;
  39655. };
  39656. /**
  39657. * Dispose all the elements created by the Helper.
  39658. */
  39659. EnvironmentHelper.prototype.dispose = function () {
  39660. if (this._groundMaterial) {
  39661. this._groundMaterial.dispose(true, true);
  39662. }
  39663. if (this._skyboxMaterial) {
  39664. this._skyboxMaterial.dispose(true, true);
  39665. }
  39666. this._rootMesh.dispose(false);
  39667. };
  39668. /**
  39669. * Default ground texture URL.
  39670. */
  39671. EnvironmentHelper._groundTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundGround.png";
  39672. /**
  39673. * Default skybox texture URL.
  39674. */
  39675. EnvironmentHelper._skyboxTextureCDNUrl = "https://assets.babylonjs.com/environments/backgroundSkybox.dds";
  39676. /**
  39677. * Default environment texture URL.
  39678. */
  39679. EnvironmentHelper._environmentTextureCDNUrl = "https://assets.babylonjs.com/environments/environmentSpecular.env";
  39680. return EnvironmentHelper;
  39681. }());
  39682. /***/ }),
  39683. /***/ "./Helpers/index.ts":
  39684. /*!**************************!*\
  39685. !*** ./Helpers/index.ts ***!
  39686. \**************************/
  39687. /*! exports provided: EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome */
  39688. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39689. "use strict";
  39690. __webpack_require__.r(__webpack_exports__);
  39691. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _environmentHelper__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  39693. /* harmony import */ var _photoDome__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./photoDome */ "./Helpers/photoDome.ts");
  39694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _photoDome__WEBPACK_IMPORTED_MODULE_1__["PhotoDome"]; });
  39695. /* harmony import */ var _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneHelpers */ "./Helpers/sceneHelpers.ts");
  39696. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _sceneHelpers__WEBPACK_IMPORTED_MODULE_2__["_forceSceneHelpersToBundle"]; });
  39697. /* harmony import */ var _videoDome__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./videoDome */ "./Helpers/videoDome.ts");
  39698. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _videoDome__WEBPACK_IMPORTED_MODULE_3__["VideoDome"]; });
  39699. /***/ }),
  39700. /***/ "./Helpers/photoDome.ts":
  39701. /*!******************************!*\
  39702. !*** ./Helpers/photoDome.ts ***!
  39703. \******************************/
  39704. /*! exports provided: PhotoDome */
  39705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39706. "use strict";
  39707. __webpack_require__.r(__webpack_exports__);
  39708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return PhotoDome; });
  39709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39710. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  39711. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39712. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39713. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39714. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  39715. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  39716. /**
  39717. * Display a 360 degree photo on an approximately spherical surface, useful for VR applications or skyboxes.
  39718. * As a subclass of TransformNode, this allow parenting to the camera with different locations in the scene.
  39719. * This class achieves its effect with a Texture and a correctly configured BackgroundMaterial on an inverted sphere.
  39720. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  39721. */
  39722. var PhotoDome = /** @class */ (function (_super) {
  39723. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PhotoDome, _super);
  39724. /**
  39725. * Create an instance of this class and pass through the parameters to the relevant classes, Texture, StandardMaterial, and Mesh.
  39726. * @param name Element's name, child elements will append suffixes for their own names.
  39727. * @param urlsOfPhoto defines the url of the photo to display
  39728. * @param options defines an object containing optional or exposed sub element properties
  39729. * @param onError defines a callback called when an error occured while loading the texture
  39730. */
  39731. function PhotoDome(name, urlOfPhoto, options, scene, onError) {
  39732. if (onError === void 0) { onError = null; }
  39733. var _this = _super.call(this, name, scene) || this;
  39734. _this._useDirectMapping = false;
  39735. /**
  39736. * Observable raised when an error occured while loading the 360 image
  39737. */
  39738. _this.onLoadErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  39739. // set defaults and manage values
  39740. name = name || "photoDome";
  39741. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  39742. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  39743. if (options.useDirectMapping === undefined) {
  39744. _this._useDirectMapping = true;
  39745. }
  39746. else {
  39747. _this._useDirectMapping = options.useDirectMapping;
  39748. }
  39749. _this._setReady(false);
  39750. // create
  39751. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  39752. _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);
  39753. // configure material
  39754. material.opacityFresnel = false;
  39755. material.useEquirectangularFOV = true;
  39756. material.fovMultiplier = 1.0;
  39757. _this.photoTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](urlOfPhoto, scene, true, !_this._useDirectMapping, undefined, undefined, function (message, exception) {
  39758. _this.onLoadErrorObservable.notifyObservers(message || "Unknown error occured");
  39759. if (onError) {
  39760. onError(message, exception);
  39761. }
  39762. });
  39763. _this.photoTexture.onLoadObservable.addOnce(function () {
  39764. _this._setReady(true);
  39765. });
  39766. // configure mesh
  39767. _this._mesh.material = material;
  39768. _this._mesh.parent = _this;
  39769. return _this;
  39770. }
  39771. Object.defineProperty(PhotoDome.prototype, "photoTexture", {
  39772. /**
  39773. * Gets or sets the texture being displayed on the sphere
  39774. */
  39775. get: function () {
  39776. return this._photoTexture;
  39777. },
  39778. set: function (value) {
  39779. if (this._photoTexture === value) {
  39780. return;
  39781. }
  39782. this._photoTexture = value;
  39783. if (this._useDirectMapping) {
  39784. this._photoTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39785. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39786. this._material.diffuseTexture = this._photoTexture;
  39787. }
  39788. else {
  39789. this._photoTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  39790. this._photoTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  39791. this._material.reflectionTexture = this._photoTexture;
  39792. }
  39793. },
  39794. enumerable: true,
  39795. configurable: true
  39796. });
  39797. Object.defineProperty(PhotoDome.prototype, "fovMultiplier", {
  39798. /**
  39799. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  39800. * Also see the options.resolution property.
  39801. */
  39802. get: function () {
  39803. return this._material.fovMultiplier;
  39804. },
  39805. set: function (value) {
  39806. this._material.fovMultiplier = value;
  39807. },
  39808. enumerable: true,
  39809. configurable: true
  39810. });
  39811. /**
  39812. * Releases resources associated with this node.
  39813. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  39814. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  39815. */
  39816. PhotoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  39817. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  39818. this._photoTexture.dispose();
  39819. this._mesh.dispose();
  39820. this._material.dispose();
  39821. this.onLoadErrorObservable.clear();
  39822. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  39823. };
  39824. return PhotoDome;
  39825. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_2__["TransformNode"]));
  39826. /***/ }),
  39827. /***/ "./Helpers/sceneHelpers.ts":
  39828. /*!*********************************!*\
  39829. !*** ./Helpers/sceneHelpers.ts ***!
  39830. \*********************************/
  39831. /*! exports provided: _forceSceneHelpersToBundle */
  39832. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39833. "use strict";
  39834. __webpack_require__.r(__webpack_exports__);
  39835. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _forceSceneHelpersToBundle; });
  39836. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  39837. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  39838. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  39839. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39840. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39841. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  39842. /* harmony import */ var _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/PBR/pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  39843. /* harmony import */ var _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Lights/hemisphericLight */ "./Lights/hemisphericLight.ts");
  39844. /* harmony import */ var _environmentHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./environmentHelper */ "./Helpers/environmentHelper.ts");
  39845. /* harmony import */ var _Cameras_freeCamera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Cameras/freeCamera */ "./Cameras/freeCamera.ts");
  39846. /* harmony import */ var _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Cameras/arcRotateCamera */ "./Cameras/arcRotateCamera.ts");
  39847. /* harmony import */ var _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Cameras/XR/webXRManagedOutputCanvas */ "./Cameras/XR/webXRManagedOutputCanvas.ts");
  39848. /* harmony import */ var _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Cameras/XR/webXRInput */ "./Cameras/XR/webXRInput.ts");
  39849. /* harmony import */ var _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Cameras/XR/webXREnterExitUI */ "./Cameras/XR/webXREnterExitUI.ts");
  39850. /* harmony import */ var _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Cameras/XR/webXRExperienceHelper */ "./Cameras/XR/webXRExperienceHelper.ts");
  39851. /* harmony import */ var _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Cameras/VR/vrExperienceHelper */ "./Cameras/VR/vrExperienceHelper.ts");
  39852. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  39853. /** @hidden */
  39854. var _forceSceneHelpersToBundle = true;
  39855. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultLight = function (replace) {
  39856. if (replace === void 0) { replace = false; }
  39857. // Dispose existing light in replace mode.
  39858. if (replace) {
  39859. if (this.lights) {
  39860. for (var i = 0; i < this.lights.length; i++) {
  39861. this.lights[i].dispose();
  39862. }
  39863. }
  39864. }
  39865. // Light
  39866. if (this.lights.length === 0) {
  39867. new _Lights_hemisphericLight__WEBPACK_IMPORTED_MODULE_7__["HemisphericLight"]("default light", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up(), this);
  39868. }
  39869. };
  39870. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCamera = function (createArcRotateCamera, replace, attachCameraControls) {
  39871. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39872. if (replace === void 0) { replace = false; }
  39873. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39874. // Dispose existing camera in replace mode.
  39875. if (replace) {
  39876. if (this.activeCamera) {
  39877. this.activeCamera.dispose();
  39878. this.activeCamera = null;
  39879. }
  39880. }
  39881. // Camera
  39882. if (!this.activeCamera) {
  39883. var worldExtends = this.getWorldExtends();
  39884. var worldSize = worldExtends.max.subtract(worldExtends.min);
  39885. var worldCenter = worldExtends.min.add(worldSize.scale(0.5));
  39886. var camera;
  39887. var radius = worldSize.length() * 1.5;
  39888. // empty scene scenario!
  39889. if (!isFinite(radius)) {
  39890. radius = 1;
  39891. worldCenter.copyFromFloats(0, 0, 0);
  39892. }
  39893. if (createArcRotateCamera) {
  39894. var arcRotateCamera = new _Cameras_arcRotateCamera__WEBPACK_IMPORTED_MODULE_10__["ArcRotateCamera"]("default camera", -(Math.PI / 2), Math.PI / 2, radius, worldCenter, this);
  39895. arcRotateCamera.lowerRadiusLimit = radius * 0.01;
  39896. arcRotateCamera.wheelPrecision = 100 / radius;
  39897. camera = arcRotateCamera;
  39898. }
  39899. else {
  39900. 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);
  39901. freeCamera.setTarget(worldCenter);
  39902. camera = freeCamera;
  39903. }
  39904. camera.minZ = radius * 0.01;
  39905. camera.maxZ = radius * 1000;
  39906. camera.speed = radius * 0.2;
  39907. this.activeCamera = camera;
  39908. var canvas = this.getEngine().getRenderingCanvas();
  39909. if (attachCameraControls && canvas) {
  39910. camera.attachControl(canvas);
  39911. }
  39912. }
  39913. };
  39914. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultCameraOrLight = function (createArcRotateCamera, replace, attachCameraControls) {
  39915. if (createArcRotateCamera === void 0) { createArcRotateCamera = false; }
  39916. if (replace === void 0) { replace = false; }
  39917. if (attachCameraControls === void 0) { attachCameraControls = false; }
  39918. this.createDefaultLight(replace);
  39919. this.createDefaultCamera(createArcRotateCamera, replace, attachCameraControls);
  39920. };
  39921. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultSkybox = function (environmentTexture, pbr, scale, blur, setGlobalEnvTexture) {
  39922. if (pbr === void 0) { pbr = false; }
  39923. if (scale === void 0) { scale = 1000; }
  39924. if (blur === void 0) { blur = 0; }
  39925. if (setGlobalEnvTexture === void 0) { setGlobalEnvTexture = true; }
  39926. if (!environmentTexture) {
  39927. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Can not create default skybox without environment texture.");
  39928. return null;
  39929. }
  39930. if (setGlobalEnvTexture) {
  39931. if (environmentTexture) {
  39932. this.environmentTexture = environmentTexture;
  39933. }
  39934. }
  39935. // Skybox
  39936. var hdrSkybox = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].CreateBox("hdrSkyBox", scale, this);
  39937. if (pbr) {
  39938. var hdrSkyboxMaterial = new _Materials_PBR_pbrMaterial__WEBPACK_IMPORTED_MODULE_6__["PBRMaterial"]("skyBox", this);
  39939. hdrSkyboxMaterial.backFaceCulling = false;
  39940. hdrSkyboxMaterial.reflectionTexture = environmentTexture.clone();
  39941. if (hdrSkyboxMaterial.reflectionTexture) {
  39942. hdrSkyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39943. }
  39944. hdrSkyboxMaterial.microSurface = 1.0 - blur;
  39945. hdrSkyboxMaterial.disableLighting = true;
  39946. hdrSkyboxMaterial.twoSidedLighting = true;
  39947. hdrSkybox.infiniteDistance = true;
  39948. hdrSkybox.material = hdrSkyboxMaterial;
  39949. }
  39950. else {
  39951. var skyboxMaterial = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("skyBox", this);
  39952. skyboxMaterial.backFaceCulling = false;
  39953. skyboxMaterial.reflectionTexture = environmentTexture.clone();
  39954. if (skyboxMaterial.reflectionTexture) {
  39955. skyboxMaterial.reflectionTexture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].SKYBOX_MODE;
  39956. }
  39957. skyboxMaterial.disableLighting = true;
  39958. hdrSkybox.infiniteDistance = true;
  39959. hdrSkybox.material = skyboxMaterial;
  39960. }
  39961. hdrSkybox.isPickable = false;
  39962. return hdrSkybox;
  39963. };
  39964. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultEnvironment = function (options) {
  39965. if (_environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"]) {
  39966. return new _environmentHelper__WEBPACK_IMPORTED_MODULE_8__["EnvironmentHelper"](options, this);
  39967. }
  39968. return null;
  39969. };
  39970. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultVRExperience = function (webVROptions) {
  39971. if (webVROptions === void 0) { webVROptions = {}; }
  39972. return new _Cameras_VR_vrExperienceHelper__WEBPACK_IMPORTED_MODULE_15__["VRExperienceHelper"](this, webVROptions);
  39973. };
  39974. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.createDefaultXRExperienceAsync = function () {
  39975. var _this = this;
  39976. return _Cameras_XR_webXRExperienceHelper__WEBPACK_IMPORTED_MODULE_14__["WebXRExperienceHelper"].CreateAsync(this).then(function (helper) {
  39977. var outputCanvas = new _Cameras_XR_webXRManagedOutputCanvas__WEBPACK_IMPORTED_MODULE_11__["WebXRManagedOutputCanvas"](helper);
  39978. return _Cameras_XR_webXREnterExitUI__WEBPACK_IMPORTED_MODULE_13__["WebXREnterExitUI"].CreateAsync(_this, helper, { outputCanvasContext: outputCanvas.canvasContext })
  39979. .then(function (ui) {
  39980. new _Cameras_XR_webXRInput__WEBPACK_IMPORTED_MODULE_12__["WebXRInput"](helper);
  39981. return helper;
  39982. });
  39983. });
  39984. };
  39985. /***/ }),
  39986. /***/ "./Helpers/videoDome.ts":
  39987. /*!******************************!*\
  39988. !*** ./Helpers/videoDome.ts ***!
  39989. \******************************/
  39990. /*! exports provided: VideoDome */
  39991. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  39992. "use strict";
  39993. __webpack_require__.r(__webpack_exports__);
  39994. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return VideoDome; });
  39995. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  39996. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  39997. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  39998. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  39999. /* harmony import */ var _Materials_Textures_videoTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/videoTexture */ "./Materials/Textures/videoTexture.ts");
  40000. /* harmony import */ var _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Background/backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  40001. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  40002. /**
  40003. * Display a 360 degree video on an approximately spherical surface, useful for VR applications or skyboxes.
  40004. * As a subclass of TransformNode, this allow parenting to the camera or multiple videos with different locations in the scene.
  40005. * This class achieves its effect with a VideoTexture and a correctly configured BackgroundMaterial on an inverted sphere.
  40006. * Potential additions to this helper include zoom and and non-infinite distance rendering effects.
  40007. */
  40008. var VideoDome = /** @class */ (function (_super) {
  40009. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoDome, _super);
  40010. /**
  40011. * Create an instance of this class and pass through the parameters to the relevant classes, VideoTexture, StandardMaterial, and Mesh.
  40012. * @param name Element's name, child elements will append suffixes for their own names.
  40013. * @param urlsOrVideo defines the url(s) or the video element to use
  40014. * @param options An object containing optional or exposed sub element properties
  40015. */
  40016. function VideoDome(name, urlsOrVideo, options, scene) {
  40017. var _this = _super.call(this, name, scene) || this;
  40018. _this._useDirectMapping = false;
  40019. // set defaults and manage values
  40020. name = name || "videoDome";
  40021. options.resolution = (Math.abs(options.resolution) | 0) || 32;
  40022. options.clickToPlay = Boolean(options.clickToPlay);
  40023. options.autoPlay = options.autoPlay === undefined ? true : Boolean(options.autoPlay);
  40024. options.loop = options.loop === undefined ? true : Boolean(options.loop);
  40025. options.size = Math.abs(options.size) || (scene.activeCamera ? scene.activeCamera.maxZ * 0.48 : 1000);
  40026. if (options.useDirectMapping === undefined) {
  40027. _this._useDirectMapping = true;
  40028. }
  40029. else {
  40030. _this._useDirectMapping = options.useDirectMapping;
  40031. }
  40032. _this._setReady(false);
  40033. // create
  40034. var tempOptions = { loop: options.loop, autoPlay: options.autoPlay, autoUpdateTexture: true, poster: options.poster };
  40035. var material = _this._material = new _Materials_Background_backgroundMaterial__WEBPACK_IMPORTED_MODULE_5__["BackgroundMaterial"](name + "_material", scene);
  40036. 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);
  40037. _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);
  40038. texture.onLoadObservable.addOnce(function () {
  40039. _this._setReady(true);
  40040. });
  40041. // configure material
  40042. material.useEquirectangularFOV = true;
  40043. material.fovMultiplier = 1.0;
  40044. material.opacityFresnel = false;
  40045. if (_this._useDirectMapping) {
  40046. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40047. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40048. material.diffuseTexture = texture;
  40049. }
  40050. else {
  40051. texture.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE; // matches orientation
  40052. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  40053. material.reflectionTexture = texture;
  40054. }
  40055. // configure mesh
  40056. _this._mesh.material = material;
  40057. _this._mesh.parent = _this;
  40058. // optional configuration
  40059. if (options.clickToPlay) {
  40060. scene.onPointerUp = function () {
  40061. _this._videoTexture.video.play();
  40062. };
  40063. }
  40064. return _this;
  40065. }
  40066. Object.defineProperty(VideoDome.prototype, "videoTexture", {
  40067. /**
  40068. * Gets the video texture being displayed on the sphere
  40069. */
  40070. get: function () {
  40071. return this._videoTexture;
  40072. },
  40073. enumerable: true,
  40074. configurable: true
  40075. });
  40076. Object.defineProperty(VideoDome.prototype, "fovMultiplier", {
  40077. /**
  40078. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  40079. * Also see the options.resolution property.
  40080. */
  40081. get: function () {
  40082. return this._material.fovMultiplier;
  40083. },
  40084. set: function (value) {
  40085. this._material.fovMultiplier = value;
  40086. },
  40087. enumerable: true,
  40088. configurable: true
  40089. });
  40090. /**
  40091. * Releases resources associated with this node.
  40092. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  40093. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  40094. */
  40095. VideoDome.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  40096. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  40097. this._videoTexture.dispose();
  40098. this._mesh.dispose();
  40099. this._material.dispose();
  40100. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  40101. };
  40102. return VideoDome;
  40103. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_1__["TransformNode"]));
  40104. /***/ }),
  40105. /***/ "./Instrumentation/engineInstrumentation.ts":
  40106. /*!**************************************************!*\
  40107. !*** ./Instrumentation/engineInstrumentation.ts ***!
  40108. \**************************************************/
  40109. /*! exports provided: EngineInstrumentation */
  40110. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40111. "use strict";
  40112. __webpack_require__.r(__webpack_exports__);
  40113. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return EngineInstrumentation; });
  40114. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40115. /**
  40116. * This class can be used to get instrumentation data from a Babylon engine
  40117. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40118. */
  40119. var EngineInstrumentation = /** @class */ (function () {
  40120. /**
  40121. * Instantiates a new engine instrumentation.
  40122. * This class can be used to get instrumentation data from a Babylon engine
  40123. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#engineinstrumentation
  40124. * @param engine Defines the engine to instrument
  40125. */
  40126. function EngineInstrumentation(
  40127. /**
  40128. * Define the instrumented engine.
  40129. */
  40130. engine) {
  40131. this.engine = engine;
  40132. this._captureGPUFrameTime = false;
  40133. this._gpuFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40134. this._captureShaderCompilationTime = false;
  40135. this._shaderCompilationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40136. // Observers
  40137. this._onBeginFrameObserver = null;
  40138. this._onEndFrameObserver = null;
  40139. this._onBeforeShaderCompilationObserver = null;
  40140. this._onAfterShaderCompilationObserver = null;
  40141. }
  40142. Object.defineProperty(EngineInstrumentation.prototype, "gpuFrameTimeCounter", {
  40143. // Properties
  40144. /**
  40145. * Gets the perf counter used for GPU frame time
  40146. */
  40147. get: function () {
  40148. return this._gpuFrameTime;
  40149. },
  40150. enumerable: true,
  40151. configurable: true
  40152. });
  40153. Object.defineProperty(EngineInstrumentation.prototype, "captureGPUFrameTime", {
  40154. /**
  40155. * Gets the GPU frame time capture status
  40156. */
  40157. get: function () {
  40158. return this._captureGPUFrameTime;
  40159. },
  40160. /**
  40161. * Enable or disable the GPU frame time capture
  40162. */
  40163. set: function (value) {
  40164. var _this = this;
  40165. if (value === this._captureGPUFrameTime) {
  40166. return;
  40167. }
  40168. this._captureGPUFrameTime = value;
  40169. if (value) {
  40170. this._onBeginFrameObserver = this.engine.onBeginFrameObservable.add(function () {
  40171. if (!_this._gpuFrameTimeToken) {
  40172. _this._gpuFrameTimeToken = _this.engine.startTimeQuery();
  40173. }
  40174. });
  40175. this._onEndFrameObserver = this.engine.onEndFrameObservable.add(function () {
  40176. if (!_this._gpuFrameTimeToken) {
  40177. return;
  40178. }
  40179. var time = _this.engine.endTimeQuery(_this._gpuFrameTimeToken);
  40180. if (time > -1) {
  40181. _this._gpuFrameTimeToken = null;
  40182. _this._gpuFrameTime.fetchNewFrame();
  40183. _this._gpuFrameTime.addCount(time, true);
  40184. }
  40185. });
  40186. }
  40187. else {
  40188. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40189. this._onBeginFrameObserver = null;
  40190. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40191. this._onEndFrameObserver = null;
  40192. }
  40193. },
  40194. enumerable: true,
  40195. configurable: true
  40196. });
  40197. Object.defineProperty(EngineInstrumentation.prototype, "shaderCompilationTimeCounter", {
  40198. /**
  40199. * Gets the perf counter used for shader compilation time
  40200. */
  40201. get: function () {
  40202. return this._shaderCompilationTime;
  40203. },
  40204. enumerable: true,
  40205. configurable: true
  40206. });
  40207. Object.defineProperty(EngineInstrumentation.prototype, "captureShaderCompilationTime", {
  40208. /**
  40209. * Gets the shader compilation time capture status
  40210. */
  40211. get: function () {
  40212. return this._captureShaderCompilationTime;
  40213. },
  40214. /**
  40215. * Enable or disable the shader compilation time capture
  40216. */
  40217. set: function (value) {
  40218. var _this = this;
  40219. if (value === this._captureShaderCompilationTime) {
  40220. return;
  40221. }
  40222. this._captureShaderCompilationTime = value;
  40223. if (value) {
  40224. this._onBeforeShaderCompilationObserver = this.engine.onBeforeShaderCompilationObservable.add(function () {
  40225. _this._shaderCompilationTime.fetchNewFrame();
  40226. _this._shaderCompilationTime.beginMonitoring();
  40227. });
  40228. this._onAfterShaderCompilationObserver = this.engine.onAfterShaderCompilationObservable.add(function () {
  40229. _this._shaderCompilationTime.endMonitoring();
  40230. });
  40231. }
  40232. else {
  40233. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40234. this._onBeforeShaderCompilationObserver = null;
  40235. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40236. this._onAfterShaderCompilationObserver = null;
  40237. }
  40238. },
  40239. enumerable: true,
  40240. configurable: true
  40241. });
  40242. /**
  40243. * Dispose and release associated resources.
  40244. */
  40245. EngineInstrumentation.prototype.dispose = function () {
  40246. this.engine.onBeginFrameObservable.remove(this._onBeginFrameObserver);
  40247. this._onBeginFrameObserver = null;
  40248. this.engine.onEndFrameObservable.remove(this._onEndFrameObserver);
  40249. this._onEndFrameObserver = null;
  40250. this.engine.onBeforeShaderCompilationObservable.remove(this._onBeforeShaderCompilationObserver);
  40251. this._onBeforeShaderCompilationObserver = null;
  40252. this.engine.onAfterShaderCompilationObservable.remove(this._onAfterShaderCompilationObserver);
  40253. this._onAfterShaderCompilationObserver = null;
  40254. this.engine = null;
  40255. };
  40256. return EngineInstrumentation;
  40257. }());
  40258. /***/ }),
  40259. /***/ "./Instrumentation/index.ts":
  40260. /*!**********************************!*\
  40261. !*** ./Instrumentation/index.ts ***!
  40262. \**********************************/
  40263. /*! exports provided: EngineInstrumentation, SceneInstrumentation, _TimeToken */
  40264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40265. "use strict";
  40266. __webpack_require__.r(__webpack_exports__);
  40267. /* harmony import */ var _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engineInstrumentation */ "./Instrumentation/engineInstrumentation.ts");
  40268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _engineInstrumentation__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  40269. /* harmony import */ var _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./sceneInstrumentation */ "./Instrumentation/sceneInstrumentation.ts");
  40270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _sceneInstrumentation__WEBPACK_IMPORTED_MODULE_1__["SceneInstrumentation"]; });
  40271. /* harmony import */ var _timeToken__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./timeToken */ "./Instrumentation/timeToken.ts");
  40272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _timeToken__WEBPACK_IMPORTED_MODULE_2__["_TimeToken"]; });
  40273. /***/ }),
  40274. /***/ "./Instrumentation/sceneInstrumentation.ts":
  40275. /*!*************************************************!*\
  40276. !*** ./Instrumentation/sceneInstrumentation.ts ***!
  40277. \*************************************************/
  40278. /*! exports provided: SceneInstrumentation */
  40279. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40280. "use strict";
  40281. __webpack_require__.r(__webpack_exports__);
  40282. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return SceneInstrumentation; });
  40283. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40284. /**
  40285. * This class can be used to get instrumentation data from a Babylon engine
  40286. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40287. */
  40288. var SceneInstrumentation = /** @class */ (function () {
  40289. /**
  40290. * Instantiates a new scene instrumentation.
  40291. * This class can be used to get instrumentation data from a Babylon engine
  40292. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#sceneinstrumentation
  40293. * @param scene Defines the scene to instrument
  40294. */
  40295. function SceneInstrumentation(
  40296. /**
  40297. * Defines the scene to instrument
  40298. */
  40299. scene) {
  40300. var _this = this;
  40301. this.scene = scene;
  40302. this._captureActiveMeshesEvaluationTime = false;
  40303. this._activeMeshesEvaluationTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40304. this._captureRenderTargetsRenderTime = false;
  40305. this._renderTargetsRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40306. this._captureFrameTime = false;
  40307. this._frameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40308. this._captureRenderTime = false;
  40309. this._renderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40310. this._captureInterFrameTime = false;
  40311. this._interFrameTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40312. this._captureParticlesRenderTime = false;
  40313. this._particlesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40314. this._captureSpritesRenderTime = false;
  40315. this._spritesRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40316. this._capturePhysicsTime = false;
  40317. this._physicsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40318. this._captureAnimationsTime = false;
  40319. this._animationsTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40320. this._captureCameraRenderTime = false;
  40321. this._cameraRenderTime = new _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]();
  40322. // Observers
  40323. this._onBeforeActiveMeshesEvaluationObserver = null;
  40324. this._onAfterActiveMeshesEvaluationObserver = null;
  40325. this._onBeforeRenderTargetsRenderObserver = null;
  40326. this._onAfterRenderTargetsRenderObserver = null;
  40327. this._onAfterRenderObserver = null;
  40328. this._onBeforeDrawPhaseObserver = null;
  40329. this._onAfterDrawPhaseObserver = null;
  40330. this._onBeforeAnimationsObserver = null;
  40331. this._onBeforeParticlesRenderingObserver = null;
  40332. this._onAfterParticlesRenderingObserver = null;
  40333. this._onBeforeSpritesRenderingObserver = null;
  40334. this._onAfterSpritesRenderingObserver = null;
  40335. this._onBeforePhysicsObserver = null;
  40336. this._onAfterPhysicsObserver = null;
  40337. this._onAfterAnimationsObserver = null;
  40338. this._onBeforeCameraRenderObserver = null;
  40339. this._onAfterCameraRenderObserver = null;
  40340. // Before render
  40341. this._onBeforeAnimationsObserver = scene.onBeforeAnimationsObservable.add(function () {
  40342. if (_this._captureActiveMeshesEvaluationTime) {
  40343. _this._activeMeshesEvaluationTime.fetchNewFrame();
  40344. }
  40345. if (_this._captureRenderTargetsRenderTime) {
  40346. _this._renderTargetsRenderTime.fetchNewFrame();
  40347. }
  40348. if (_this._captureFrameTime) {
  40349. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Scene rendering");
  40350. _this._frameTime.beginMonitoring();
  40351. }
  40352. if (_this._captureInterFrameTime) {
  40353. _this._interFrameTime.endMonitoring();
  40354. }
  40355. if (_this._captureParticlesRenderTime) {
  40356. _this._particlesRenderTime.fetchNewFrame();
  40357. }
  40358. if (_this._captureSpritesRenderTime) {
  40359. _this._spritesRenderTime.fetchNewFrame();
  40360. }
  40361. if (_this._captureAnimationsTime) {
  40362. _this._animationsTime.beginMonitoring();
  40363. }
  40364. _this.scene.getEngine()._drawCalls.fetchNewFrame();
  40365. _this.scene.getEngine()._textureCollisions.fetchNewFrame();
  40366. });
  40367. // After render
  40368. this._onAfterRenderObserver = scene.onAfterRenderObservable.add(function () {
  40369. if (_this._captureFrameTime) {
  40370. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Scene rendering");
  40371. _this._frameTime.endMonitoring();
  40372. }
  40373. if (_this._captureRenderTime) {
  40374. _this._renderTime.endMonitoring(false);
  40375. }
  40376. if (_this._captureInterFrameTime) {
  40377. _this._interFrameTime.beginMonitoring();
  40378. }
  40379. });
  40380. }
  40381. Object.defineProperty(SceneInstrumentation.prototype, "activeMeshesEvaluationTimeCounter", {
  40382. // Properties
  40383. /**
  40384. * Gets the perf counter used for active meshes evaluation time
  40385. */
  40386. get: function () {
  40387. return this._activeMeshesEvaluationTime;
  40388. },
  40389. enumerable: true,
  40390. configurable: true
  40391. });
  40392. Object.defineProperty(SceneInstrumentation.prototype, "captureActiveMeshesEvaluationTime", {
  40393. /**
  40394. * Gets the active meshes evaluation time capture status
  40395. */
  40396. get: function () {
  40397. return this._captureActiveMeshesEvaluationTime;
  40398. },
  40399. /**
  40400. * Enable or disable the active meshes evaluation time capture
  40401. */
  40402. set: function (value) {
  40403. var _this = this;
  40404. if (value === this._captureActiveMeshesEvaluationTime) {
  40405. return;
  40406. }
  40407. this._captureActiveMeshesEvaluationTime = value;
  40408. if (value) {
  40409. this._onBeforeActiveMeshesEvaluationObserver = this.scene.onBeforeActiveMeshesEvaluationObservable.add(function () {
  40410. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Active meshes evaluation");
  40411. _this._activeMeshesEvaluationTime.beginMonitoring();
  40412. });
  40413. this._onAfterActiveMeshesEvaluationObserver = this.scene.onAfterActiveMeshesEvaluationObservable.add(function () {
  40414. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Active meshes evaluation");
  40415. _this._activeMeshesEvaluationTime.endMonitoring();
  40416. });
  40417. }
  40418. else {
  40419. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40420. this._onBeforeActiveMeshesEvaluationObserver = null;
  40421. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40422. this._onAfterActiveMeshesEvaluationObserver = null;
  40423. }
  40424. },
  40425. enumerable: true,
  40426. configurable: true
  40427. });
  40428. Object.defineProperty(SceneInstrumentation.prototype, "renderTargetsRenderTimeCounter", {
  40429. /**
  40430. * Gets the perf counter used for render targets render time
  40431. */
  40432. get: function () {
  40433. return this._renderTargetsRenderTime;
  40434. },
  40435. enumerable: true,
  40436. configurable: true
  40437. });
  40438. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTargetsRenderTime", {
  40439. /**
  40440. * Gets the render targets render time capture status
  40441. */
  40442. get: function () {
  40443. return this._captureRenderTargetsRenderTime;
  40444. },
  40445. /**
  40446. * Enable or disable the render targets render time capture
  40447. */
  40448. set: function (value) {
  40449. var _this = this;
  40450. if (value === this._captureRenderTargetsRenderTime) {
  40451. return;
  40452. }
  40453. this._captureRenderTargetsRenderTime = value;
  40454. if (value) {
  40455. this._onBeforeRenderTargetsRenderObserver = this.scene.onBeforeRenderTargetsRenderObservable.add(function () {
  40456. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Render targets rendering");
  40457. _this._renderTargetsRenderTime.beginMonitoring();
  40458. });
  40459. this._onAfterRenderTargetsRenderObserver = this.scene.onAfterRenderTargetsRenderObservable.add(function () {
  40460. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Render targets rendering");
  40461. _this._renderTargetsRenderTime.endMonitoring(false);
  40462. });
  40463. }
  40464. else {
  40465. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40466. this._onBeforeRenderTargetsRenderObserver = null;
  40467. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40468. this._onAfterRenderTargetsRenderObserver = null;
  40469. }
  40470. },
  40471. enumerable: true,
  40472. configurable: true
  40473. });
  40474. Object.defineProperty(SceneInstrumentation.prototype, "particlesRenderTimeCounter", {
  40475. /**
  40476. * Gets the perf counter used for particles render time
  40477. */
  40478. get: function () {
  40479. return this._particlesRenderTime;
  40480. },
  40481. enumerable: true,
  40482. configurable: true
  40483. });
  40484. Object.defineProperty(SceneInstrumentation.prototype, "captureParticlesRenderTime", {
  40485. /**
  40486. * Gets the particles render time capture status
  40487. */
  40488. get: function () {
  40489. return this._captureParticlesRenderTime;
  40490. },
  40491. /**
  40492. * Enable or disable the particles render time capture
  40493. */
  40494. set: function (value) {
  40495. var _this = this;
  40496. if (value === this._captureParticlesRenderTime) {
  40497. return;
  40498. }
  40499. this._captureParticlesRenderTime = value;
  40500. if (value) {
  40501. this._onBeforeParticlesRenderingObserver = this.scene.onBeforeParticlesRenderingObservable.add(function () {
  40502. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Particles");
  40503. _this._particlesRenderTime.beginMonitoring();
  40504. });
  40505. this._onAfterParticlesRenderingObserver = this.scene.onAfterParticlesRenderingObservable.add(function () {
  40506. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Particles");
  40507. _this._particlesRenderTime.endMonitoring(false);
  40508. });
  40509. }
  40510. else {
  40511. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40512. this._onBeforeParticlesRenderingObserver = null;
  40513. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40514. this._onAfterParticlesRenderingObserver = null;
  40515. }
  40516. },
  40517. enumerable: true,
  40518. configurable: true
  40519. });
  40520. Object.defineProperty(SceneInstrumentation.prototype, "spritesRenderTimeCounter", {
  40521. /**
  40522. * Gets the perf counter used for sprites render time
  40523. */
  40524. get: function () {
  40525. return this._spritesRenderTime;
  40526. },
  40527. enumerable: true,
  40528. configurable: true
  40529. });
  40530. Object.defineProperty(SceneInstrumentation.prototype, "captureSpritesRenderTime", {
  40531. /**
  40532. * Gets the sprites render time capture status
  40533. */
  40534. get: function () {
  40535. return this._captureSpritesRenderTime;
  40536. },
  40537. /**
  40538. * Enable or disable the sprites render time capture
  40539. */
  40540. set: function (value) {
  40541. var _this = this;
  40542. if (value === this._captureSpritesRenderTime) {
  40543. return;
  40544. }
  40545. this._captureSpritesRenderTime = value;
  40546. if (!this.scene.spriteManagers) {
  40547. return;
  40548. }
  40549. if (value) {
  40550. this._onBeforeSpritesRenderingObserver = this.scene.onBeforeSpritesRenderingObservable.add(function () {
  40551. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Sprites");
  40552. _this._spritesRenderTime.beginMonitoring();
  40553. });
  40554. this._onAfterSpritesRenderingObserver = this.scene.onAfterSpritesRenderingObservable.add(function () {
  40555. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Sprites");
  40556. _this._spritesRenderTime.endMonitoring(false);
  40557. });
  40558. }
  40559. else {
  40560. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40561. this._onBeforeSpritesRenderingObserver = null;
  40562. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40563. this._onAfterSpritesRenderingObserver = null;
  40564. }
  40565. },
  40566. enumerable: true,
  40567. configurable: true
  40568. });
  40569. Object.defineProperty(SceneInstrumentation.prototype, "physicsTimeCounter", {
  40570. /**
  40571. * Gets the perf counter used for physics time
  40572. */
  40573. get: function () {
  40574. return this._physicsTime;
  40575. },
  40576. enumerable: true,
  40577. configurable: true
  40578. });
  40579. Object.defineProperty(SceneInstrumentation.prototype, "capturePhysicsTime", {
  40580. /**
  40581. * Gets the physics time capture status
  40582. */
  40583. get: function () {
  40584. return this._capturePhysicsTime;
  40585. },
  40586. /**
  40587. * Enable or disable the physics time capture
  40588. */
  40589. set: function (value) {
  40590. var _this = this;
  40591. if (value === this._capturePhysicsTime) {
  40592. return;
  40593. }
  40594. if (!this.scene.onBeforePhysicsObservable) {
  40595. return;
  40596. }
  40597. this._capturePhysicsTime = value;
  40598. if (value) {
  40599. this._onBeforePhysicsObserver = this.scene.onBeforePhysicsObservable.add(function () {
  40600. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Physics");
  40601. _this._physicsTime.beginMonitoring();
  40602. });
  40603. this._onAfterPhysicsObserver = this.scene.onAfterPhysicsObservable.add(function () {
  40604. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Physics");
  40605. _this._physicsTime.endMonitoring();
  40606. });
  40607. }
  40608. else {
  40609. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40610. this._onBeforePhysicsObserver = null;
  40611. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40612. this._onAfterPhysicsObserver = null;
  40613. }
  40614. },
  40615. enumerable: true,
  40616. configurable: true
  40617. });
  40618. Object.defineProperty(SceneInstrumentation.prototype, "animationsTimeCounter", {
  40619. /**
  40620. * Gets the perf counter used for animations time
  40621. */
  40622. get: function () {
  40623. return this._animationsTime;
  40624. },
  40625. enumerable: true,
  40626. configurable: true
  40627. });
  40628. Object.defineProperty(SceneInstrumentation.prototype, "captureAnimationsTime", {
  40629. /**
  40630. * Gets the animations time capture status
  40631. */
  40632. get: function () {
  40633. return this._captureAnimationsTime;
  40634. },
  40635. /**
  40636. * Enable or disable the animations time capture
  40637. */
  40638. set: function (value) {
  40639. var _this = this;
  40640. if (value === this._captureAnimationsTime) {
  40641. return;
  40642. }
  40643. this._captureAnimationsTime = value;
  40644. if (value) {
  40645. this._onAfterAnimationsObserver = this.scene.onAfterAnimationsObservable.add(function () {
  40646. _this._animationsTime.endMonitoring();
  40647. });
  40648. }
  40649. else {
  40650. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40651. this._onAfterAnimationsObserver = null;
  40652. }
  40653. },
  40654. enumerable: true,
  40655. configurable: true
  40656. });
  40657. Object.defineProperty(SceneInstrumentation.prototype, "frameTimeCounter", {
  40658. /**
  40659. * Gets the perf counter used for frame time capture
  40660. */
  40661. get: function () {
  40662. return this._frameTime;
  40663. },
  40664. enumerable: true,
  40665. configurable: true
  40666. });
  40667. Object.defineProperty(SceneInstrumentation.prototype, "captureFrameTime", {
  40668. /**
  40669. * Gets the frame time capture status
  40670. */
  40671. get: function () {
  40672. return this._captureFrameTime;
  40673. },
  40674. /**
  40675. * Enable or disable the frame time capture
  40676. */
  40677. set: function (value) {
  40678. this._captureFrameTime = value;
  40679. },
  40680. enumerable: true,
  40681. configurable: true
  40682. });
  40683. Object.defineProperty(SceneInstrumentation.prototype, "interFrameTimeCounter", {
  40684. /**
  40685. * Gets the perf counter used for inter-frames time capture
  40686. */
  40687. get: function () {
  40688. return this._interFrameTime;
  40689. },
  40690. enumerable: true,
  40691. configurable: true
  40692. });
  40693. Object.defineProperty(SceneInstrumentation.prototype, "captureInterFrameTime", {
  40694. /**
  40695. * Gets the inter-frames time capture status
  40696. */
  40697. get: function () {
  40698. return this._captureInterFrameTime;
  40699. },
  40700. /**
  40701. * Enable or disable the inter-frames time capture
  40702. */
  40703. set: function (value) {
  40704. this._captureInterFrameTime = value;
  40705. },
  40706. enumerable: true,
  40707. configurable: true
  40708. });
  40709. Object.defineProperty(SceneInstrumentation.prototype, "renderTimeCounter", {
  40710. /**
  40711. * Gets the perf counter used for render time capture
  40712. */
  40713. get: function () {
  40714. return this._renderTime;
  40715. },
  40716. enumerable: true,
  40717. configurable: true
  40718. });
  40719. Object.defineProperty(SceneInstrumentation.prototype, "captureRenderTime", {
  40720. /**
  40721. * Gets the render time capture status
  40722. */
  40723. get: function () {
  40724. return this._captureRenderTime;
  40725. },
  40726. /**
  40727. * Enable or disable the render time capture
  40728. */
  40729. set: function (value) {
  40730. var _this = this;
  40731. if (value === this._captureRenderTime) {
  40732. return;
  40733. }
  40734. this._captureRenderTime = value;
  40735. if (value) {
  40736. this._onBeforeDrawPhaseObserver = this.scene.onBeforeDrawPhaseObservable.add(function () {
  40737. _this._renderTime.beginMonitoring();
  40738. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Main render");
  40739. });
  40740. this._onAfterDrawPhaseObserver = this.scene.onAfterDrawPhaseObservable.add(function () {
  40741. _this._renderTime.endMonitoring(false);
  40742. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Main render");
  40743. });
  40744. }
  40745. else {
  40746. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40747. this._onBeforeDrawPhaseObserver = null;
  40748. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40749. this._onAfterDrawPhaseObserver = null;
  40750. }
  40751. },
  40752. enumerable: true,
  40753. configurable: true
  40754. });
  40755. Object.defineProperty(SceneInstrumentation.prototype, "cameraRenderTimeCounter", {
  40756. /**
  40757. * Gets the perf counter used for camera render time capture
  40758. */
  40759. get: function () {
  40760. return this._cameraRenderTime;
  40761. },
  40762. enumerable: true,
  40763. configurable: true
  40764. });
  40765. Object.defineProperty(SceneInstrumentation.prototype, "captureCameraRenderTime", {
  40766. /**
  40767. * Gets the camera render time capture status
  40768. */
  40769. get: function () {
  40770. return this._captureCameraRenderTime;
  40771. },
  40772. /**
  40773. * Enable or disable the camera render time capture
  40774. */
  40775. set: function (value) {
  40776. var _this = this;
  40777. if (value === this._captureCameraRenderTime) {
  40778. return;
  40779. }
  40780. this._captureCameraRenderTime = value;
  40781. if (value) {
  40782. this._onBeforeCameraRenderObserver = this.scene.onBeforeCameraRenderObservable.add(function (camera) {
  40783. _this._cameraRenderTime.beginMonitoring();
  40784. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Rendering camera " + camera.name);
  40785. });
  40786. this._onAfterCameraRenderObserver = this.scene.onAfterCameraRenderObservable.add(function (camera) {
  40787. _this._cameraRenderTime.endMonitoring(false);
  40788. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Rendering camera " + camera.name);
  40789. });
  40790. }
  40791. else {
  40792. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40793. this._onBeforeCameraRenderObserver = null;
  40794. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40795. this._onAfterCameraRenderObserver = null;
  40796. }
  40797. },
  40798. enumerable: true,
  40799. configurable: true
  40800. });
  40801. Object.defineProperty(SceneInstrumentation.prototype, "drawCallsCounter", {
  40802. /**
  40803. * Gets the perf counter used for draw calls
  40804. */
  40805. get: function () {
  40806. return this.scene.getEngine()._drawCalls;
  40807. },
  40808. enumerable: true,
  40809. configurable: true
  40810. });
  40811. Object.defineProperty(SceneInstrumentation.prototype, "textureCollisionsCounter", {
  40812. /**
  40813. * Gets the perf counter used for texture collisions
  40814. */
  40815. get: function () {
  40816. return this.scene.getEngine()._textureCollisions;
  40817. },
  40818. enumerable: true,
  40819. configurable: true
  40820. });
  40821. /**
  40822. * Dispose and release associated resources.
  40823. */
  40824. SceneInstrumentation.prototype.dispose = function () {
  40825. this.scene.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  40826. this._onAfterRenderObserver = null;
  40827. this.scene.onBeforeActiveMeshesEvaluationObservable.remove(this._onBeforeActiveMeshesEvaluationObserver);
  40828. this._onBeforeActiveMeshesEvaluationObserver = null;
  40829. this.scene.onAfterActiveMeshesEvaluationObservable.remove(this._onAfterActiveMeshesEvaluationObserver);
  40830. this._onAfterActiveMeshesEvaluationObserver = null;
  40831. this.scene.onBeforeRenderTargetsRenderObservable.remove(this._onBeforeRenderTargetsRenderObserver);
  40832. this._onBeforeRenderTargetsRenderObserver = null;
  40833. this.scene.onAfterRenderTargetsRenderObservable.remove(this._onAfterRenderTargetsRenderObserver);
  40834. this._onAfterRenderTargetsRenderObserver = null;
  40835. this.scene.onBeforeAnimationsObservable.remove(this._onBeforeAnimationsObserver);
  40836. this._onBeforeAnimationsObserver = null;
  40837. this.scene.onBeforeParticlesRenderingObservable.remove(this._onBeforeParticlesRenderingObserver);
  40838. this._onBeforeParticlesRenderingObserver = null;
  40839. this.scene.onAfterParticlesRenderingObservable.remove(this._onAfterParticlesRenderingObserver);
  40840. this._onAfterParticlesRenderingObserver = null;
  40841. if (this._onBeforeSpritesRenderingObserver) {
  40842. this.scene.onBeforeSpritesRenderingObservable.remove(this._onBeforeSpritesRenderingObserver);
  40843. this._onBeforeSpritesRenderingObserver = null;
  40844. }
  40845. if (this._onAfterSpritesRenderingObserver) {
  40846. this.scene.onAfterSpritesRenderingObservable.remove(this._onAfterSpritesRenderingObserver);
  40847. this._onAfterSpritesRenderingObserver = null;
  40848. }
  40849. this.scene.onBeforeDrawPhaseObservable.remove(this._onBeforeDrawPhaseObserver);
  40850. this._onBeforeDrawPhaseObserver = null;
  40851. this.scene.onAfterDrawPhaseObservable.remove(this._onAfterDrawPhaseObserver);
  40852. this._onAfterDrawPhaseObserver = null;
  40853. if (this._onBeforePhysicsObserver) {
  40854. this.scene.onBeforePhysicsObservable.remove(this._onBeforePhysicsObserver);
  40855. this._onBeforePhysicsObserver = null;
  40856. }
  40857. if (this._onAfterPhysicsObserver) {
  40858. this.scene.onAfterPhysicsObservable.remove(this._onAfterPhysicsObserver);
  40859. this._onAfterPhysicsObserver = null;
  40860. }
  40861. this.scene.onAfterAnimationsObservable.remove(this._onAfterAnimationsObserver);
  40862. this._onAfterAnimationsObserver = null;
  40863. this.scene.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  40864. this._onBeforeCameraRenderObserver = null;
  40865. this.scene.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  40866. this._onAfterCameraRenderObserver = null;
  40867. this.scene = null;
  40868. };
  40869. return SceneInstrumentation;
  40870. }());
  40871. /***/ }),
  40872. /***/ "./Instrumentation/timeToken.ts":
  40873. /*!**************************************!*\
  40874. !*** ./Instrumentation/timeToken.ts ***!
  40875. \**************************************/
  40876. /*! exports provided: _TimeToken */
  40877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40878. "use strict";
  40879. __webpack_require__.r(__webpack_exports__);
  40880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _TimeToken; });
  40881. /**
  40882. * @hidden
  40883. **/
  40884. var _TimeToken = /** @class */ (function () {
  40885. function _TimeToken() {
  40886. this._timeElapsedQueryEnded = false;
  40887. }
  40888. return _TimeToken;
  40889. }());
  40890. /***/ }),
  40891. /***/ "./Layers/effectLayer.ts":
  40892. /*!*******************************!*\
  40893. !*** ./Layers/effectLayer.ts ***!
  40894. \*******************************/
  40895. /*! exports provided: EffectLayer */
  40896. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  40897. "use strict";
  40898. __webpack_require__.r(__webpack_exports__);
  40899. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return EffectLayer; });
  40900. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  40901. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  40902. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  40903. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  40904. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  40905. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  40906. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  40907. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  40908. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  40909. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  40910. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  40911. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  40912. /* harmony import */ var _Shaders_glowMapGeneration_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.fragment */ "./Shaders/glowMapGeneration.fragment.ts");
  40913. /* harmony import */ var _Shaders_glowMapGeneration_vertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapGeneration.vertex */ "./Shaders/glowMapGeneration.vertex.ts");
  40914. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  40915. /**
  40916. * The effect layer Helps adding post process effect blended with the main pass.
  40917. *
  40918. * This can be for instance use to generate glow or higlight effects on the scene.
  40919. *
  40920. * The effect layer class can not be used directly and is intented to inherited from to be
  40921. * customized per effects.
  40922. */
  40923. var EffectLayer = /** @class */ (function () {
  40924. /**
  40925. * Instantiates a new effect Layer and references it in the scene.
  40926. * @param name The name of the layer
  40927. * @param scene The scene to use the layer in
  40928. */
  40929. function EffectLayer(
  40930. /** The Friendly of the effect in the scene */
  40931. name, scene) {
  40932. this._vertexBuffers = {};
  40933. this._maxSize = 0;
  40934. this._mainTextureDesiredSize = { width: 0, height: 0 };
  40935. this._shouldRender = true;
  40936. this._postProcesses = [];
  40937. this._textures = [];
  40938. this._emissiveTextureAndColor = { texture: null, color: new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]() };
  40939. /**
  40940. * The clear color of the texture used to generate the glow map.
  40941. */
  40942. this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"]();
  40943. /**
  40944. * Specifies wether the highlight layer is enabled or not.
  40945. */
  40946. this.isEnabled = true;
  40947. /**
  40948. * An event triggered when the effect layer has been disposed.
  40949. */
  40950. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40951. /**
  40952. * An event triggered when the effect layer is about rendering the main texture with the glowy parts.
  40953. */
  40954. this.onBeforeRenderMainTextureObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40955. /**
  40956. * An event triggered when the generated texture is being merged in the scene.
  40957. */
  40958. this.onBeforeComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40959. /**
  40960. * An event triggered when the generated texture has been merged in the scene.
  40961. */
  40962. this.onAfterComposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40963. /**
  40964. * An event triggered when the efffect layer changes its size.
  40965. */
  40966. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  40967. this.name = name;
  40968. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  40969. EffectLayer._SceneComponentInitialization(this._scene);
  40970. this._engine = this._scene.getEngine();
  40971. this._maxSize = this._engine.getCaps().maxTextureSize;
  40972. this._scene.effectLayers.push(this);
  40973. // Generate Buffers
  40974. this._generateIndexBuffer();
  40975. this._genrateVertexBuffer();
  40976. }
  40977. Object.defineProperty(EffectLayer.prototype, "camera", {
  40978. /**
  40979. * Gets the camera attached to the layer.
  40980. */
  40981. get: function () {
  40982. return this._effectLayerOptions.camera;
  40983. },
  40984. enumerable: true,
  40985. configurable: true
  40986. });
  40987. Object.defineProperty(EffectLayer.prototype, "renderingGroupId", {
  40988. /**
  40989. * Gets the rendering group id the layer should render in.
  40990. */
  40991. get: function () {
  40992. return this._effectLayerOptions.renderingGroupId;
  40993. },
  40994. enumerable: true,
  40995. configurable: true
  40996. });
  40997. /**
  40998. * Initializes the effect layer with the required options.
  40999. * @param options Sets of none mandatory options to use with the layer (see IEffectLayerOptions for more information)
  41000. */
  41001. EffectLayer.prototype._init = function (options) {
  41002. // Adapt options
  41003. 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);
  41004. this._setMainTextureSize();
  41005. this._createMainTexture();
  41006. this._createTextureAndPostProcesses();
  41007. this._mergeEffect = this._createMergeEffect();
  41008. };
  41009. /**
  41010. * Generates the index buffer of the full screen quad blending to the main canvas.
  41011. */
  41012. EffectLayer.prototype._generateIndexBuffer = function () {
  41013. // Indices
  41014. var indices = [];
  41015. indices.push(0);
  41016. indices.push(1);
  41017. indices.push(2);
  41018. indices.push(0);
  41019. indices.push(2);
  41020. indices.push(3);
  41021. this._indexBuffer = this._engine.createIndexBuffer(indices);
  41022. };
  41023. /**
  41024. * Generates the vertex buffer of the full screen quad blending to the main canvas.
  41025. */
  41026. EffectLayer.prototype._genrateVertexBuffer = function () {
  41027. // VBO
  41028. var vertices = [];
  41029. vertices.push(1, 1);
  41030. vertices.push(-1, 1);
  41031. vertices.push(-1, -1);
  41032. vertices.push(1, -1);
  41033. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"](this._engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind, false, false, 2);
  41034. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = vertexBuffer;
  41035. };
  41036. /**
  41037. * Sets the main texture desired size which is the closest power of two
  41038. * of the engine canvas size.
  41039. */
  41040. EffectLayer.prototype._setMainTextureSize = function () {
  41041. if (this._effectLayerOptions.mainTextureFixedSize) {
  41042. this._mainTextureDesiredSize.width = this._effectLayerOptions.mainTextureFixedSize;
  41043. this._mainTextureDesiredSize.height = this._effectLayerOptions.mainTextureFixedSize;
  41044. }
  41045. else {
  41046. this._mainTextureDesiredSize.width = this._engine.getRenderWidth() * this._effectLayerOptions.mainTextureRatio;
  41047. this._mainTextureDesiredSize.height = this._engine.getRenderHeight() * this._effectLayerOptions.mainTextureRatio;
  41048. this._mainTextureDesiredSize.width = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.width, this._maxSize) : this._mainTextureDesiredSize.width;
  41049. this._mainTextureDesiredSize.height = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(this._mainTextureDesiredSize.height, this._maxSize) : this._mainTextureDesiredSize.height;
  41050. }
  41051. this._mainTextureDesiredSize.width = Math.floor(this._mainTextureDesiredSize.width);
  41052. this._mainTextureDesiredSize.height = Math.floor(this._mainTextureDesiredSize.height);
  41053. };
  41054. /**
  41055. * Creates the main texture for the effect layer.
  41056. */
  41057. EffectLayer.prototype._createMainTexture = function () {
  41058. var _this = this;
  41059. this._mainTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerMainRTT", {
  41060. width: this._mainTextureDesiredSize.width,
  41061. height: this._mainTextureDesiredSize.height
  41062. }, this._scene, false, true, _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  41063. this._mainTexture.activeCamera = this._effectLayerOptions.camera;
  41064. this._mainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41065. this._mainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  41066. this._mainTexture.anisotropicFilteringLevel = 1;
  41067. this._mainTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE);
  41068. this._mainTexture.renderParticles = false;
  41069. this._mainTexture.renderList = null;
  41070. this._mainTexture.ignoreCameraViewport = true;
  41071. // Custom render function
  41072. this._mainTexture.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  41073. _this.onBeforeRenderMainTextureObservable.notifyObservers(_this);
  41074. var index;
  41075. var engine = _this._scene.getEngine();
  41076. if (depthOnlySubMeshes.length) {
  41077. engine.setColorWrite(false);
  41078. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  41079. _this._renderSubMesh(depthOnlySubMeshes.data[index]);
  41080. }
  41081. engine.setColorWrite(true);
  41082. }
  41083. for (index = 0; index < opaqueSubMeshes.length; index++) {
  41084. _this._renderSubMesh(opaqueSubMeshes.data[index]);
  41085. }
  41086. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  41087. _this._renderSubMesh(alphaTestSubMeshes.data[index]);
  41088. }
  41089. for (index = 0; index < transparentSubMeshes.length; index++) {
  41090. _this._renderSubMesh(transparentSubMeshes.data[index]);
  41091. }
  41092. };
  41093. this._mainTexture.onClearObservable.add(function (engine) {
  41094. engine.clear(_this.neutralColor, true, true, true);
  41095. });
  41096. };
  41097. /**
  41098. * Adds specific effects defines.
  41099. * @param defines The defines to add specifics to.
  41100. */
  41101. EffectLayer.prototype._addCustomEffectDefines = function (defines) {
  41102. // Nothing to add by default.
  41103. };
  41104. /**
  41105. * Checks for the readiness of the element composing the layer.
  41106. * @param subMesh the mesh to check for
  41107. * @param useInstances specify wether or not to use instances to render the mesh
  41108. * @param emissiveTexture the associated emissive texture used to generate the glow
  41109. * @return true if ready otherwise, false
  41110. */
  41111. EffectLayer.prototype._isReady = function (subMesh, useInstances, emissiveTexture) {
  41112. var material = subMesh.getMaterial();
  41113. if (!material) {
  41114. return false;
  41115. }
  41116. if (!material.isReadyForSubMesh(subMesh.getMesh(), subMesh, useInstances)) {
  41117. return false;
  41118. }
  41119. var defines = [];
  41120. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41121. var mesh = subMesh.getMesh();
  41122. var uv1 = false;
  41123. var uv2 = false;
  41124. // Diffuse
  41125. if (material) {
  41126. var needAlphaTest = material.needAlphaTesting();
  41127. var diffuseTexture = material.getAlphaTestTexture();
  41128. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41129. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41130. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41131. defines.push("#define DIFFUSE");
  41132. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41133. diffuseTexture.coordinatesIndex === 1) {
  41134. defines.push("#define DIFFUSEUV2");
  41135. uv2 = true;
  41136. }
  41137. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41138. defines.push("#define DIFFUSEUV1");
  41139. uv1 = true;
  41140. }
  41141. if (needAlphaTest) {
  41142. defines.push("#define ALPHATEST");
  41143. defines.push("#define ALPHATESTVALUE 0.4");
  41144. }
  41145. }
  41146. var opacityTexture = material.opacityTexture;
  41147. if (opacityTexture) {
  41148. defines.push("#define OPACITY");
  41149. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41150. opacityTexture.coordinatesIndex === 1) {
  41151. defines.push("#define OPACITYUV2");
  41152. uv2 = true;
  41153. }
  41154. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41155. defines.push("#define OPACITYUV1");
  41156. uv1 = true;
  41157. }
  41158. }
  41159. }
  41160. // Emissive
  41161. if (emissiveTexture) {
  41162. defines.push("#define EMISSIVE");
  41163. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind) &&
  41164. emissiveTexture.coordinatesIndex === 1) {
  41165. defines.push("#define EMISSIVEUV2");
  41166. uv2 = true;
  41167. }
  41168. else if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind)) {
  41169. defines.push("#define EMISSIVEUV1");
  41170. uv1 = true;
  41171. }
  41172. }
  41173. // Vertex
  41174. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind) && mesh.hasVertexAlpha) {
  41175. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].ColorKind);
  41176. defines.push("#define VERTEXALPHA");
  41177. }
  41178. if (uv1) {
  41179. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UVKind);
  41180. defines.push("#define UV1");
  41181. }
  41182. if (uv2) {
  41183. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].UV2Kind);
  41184. defines.push("#define UV2");
  41185. }
  41186. // Bones
  41187. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  41188. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesKind);
  41189. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsKind);
  41190. if (mesh.numBoneInfluencers > 4) {
  41191. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesIndicesExtraKind);
  41192. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].MatricesWeightsExtraKind);
  41193. }
  41194. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  41195. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  41196. }
  41197. else {
  41198. defines.push("#define NUM_BONE_INFLUENCERS 0");
  41199. }
  41200. // Morph targets
  41201. var manager = mesh.morphTargetManager;
  41202. var morphInfluencers = 0;
  41203. if (manager) {
  41204. if (manager.numInfluencers > 0) {
  41205. defines.push("#define MORPHTARGETS");
  41206. morphInfluencers = manager.numInfluencers;
  41207. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  41208. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  41209. }
  41210. }
  41211. // Instances
  41212. if (useInstances) {
  41213. defines.push("#define INSTANCES");
  41214. attribs.push("world0");
  41215. attribs.push("world1");
  41216. attribs.push("world2");
  41217. attribs.push("world3");
  41218. }
  41219. this._addCustomEffectDefines(defines);
  41220. // Get correct effect
  41221. var join = defines.join("\n");
  41222. if (this._cachedDefines !== join) {
  41223. this._cachedDefines = join;
  41224. this._effectLayerMapGenerationEffect = this._scene.getEngine().createEffect("glowMapGeneration", attribs, ["world", "mBones", "viewProjection",
  41225. "color", "morphTargetInfluences",
  41226. "diffuseMatrix", "emissiveMatrix", "opacityMatrix", "opacityIntensity"], ["diffuseSampler", "emissiveSampler", "opacitySampler"], join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  41227. }
  41228. return this._effectLayerMapGenerationEffect.isReady();
  41229. };
  41230. /**
  41231. * Renders the glowing part of the scene by blending the blurred glowing meshes on top of the rendered scene.
  41232. */
  41233. EffectLayer.prototype.render = function () {
  41234. var currentEffect = this._mergeEffect;
  41235. // Check
  41236. if (!currentEffect.isReady()) {
  41237. return;
  41238. }
  41239. for (var i = 0; i < this._postProcesses.length; i++) {
  41240. if (!this._postProcesses[i].isReady()) {
  41241. return;
  41242. }
  41243. }
  41244. var engine = this._scene.getEngine();
  41245. this.onBeforeComposeObservable.notifyObservers(this);
  41246. // Render
  41247. engine.enableEffect(currentEffect);
  41248. engine.setState(false);
  41249. // VBOs
  41250. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  41251. // Cache
  41252. var previousAlphaMode = engine.getAlphaMode();
  41253. // Go Blend.
  41254. engine.setAlphaMode(this._effectLayerOptions.alphaBlendingMode);
  41255. // Blends the map on the main canvas.
  41256. this._internalRender(currentEffect);
  41257. // Restore Alpha
  41258. engine.setAlphaMode(previousAlphaMode);
  41259. this.onAfterComposeObservable.notifyObservers(this);
  41260. // Handle size changes.
  41261. var size = this._mainTexture.getSize();
  41262. this._setMainTextureSize();
  41263. if (size.width !== this._mainTextureDesiredSize.width || size.height !== this._mainTextureDesiredSize.height) {
  41264. // Recreate RTT and post processes on size change.
  41265. this.onSizeChangedObservable.notifyObservers(this);
  41266. this._disposeTextureAndPostProcesses();
  41267. this._createMainTexture();
  41268. this._createTextureAndPostProcesses();
  41269. }
  41270. };
  41271. /**
  41272. * Determine if a given mesh will be used in the current effect.
  41273. * @param mesh mesh to test
  41274. * @returns true if the mesh will be used
  41275. */
  41276. EffectLayer.prototype.hasMesh = function (mesh) {
  41277. if (this.renderingGroupId === -1 || mesh.renderingGroupId === this.renderingGroupId) {
  41278. return true;
  41279. }
  41280. return false;
  41281. };
  41282. /**
  41283. * Returns true if the layer contains information to display, otherwise false.
  41284. * @returns true if the glow layer should be rendered
  41285. */
  41286. EffectLayer.prototype.shouldRender = function () {
  41287. return this.isEnabled && this._shouldRender;
  41288. };
  41289. /**
  41290. * Returns true if the mesh should render, otherwise false.
  41291. * @param mesh The mesh to render
  41292. * @returns true if it should render otherwise false
  41293. */
  41294. EffectLayer.prototype._shouldRenderMesh = function (mesh) {
  41295. return true;
  41296. };
  41297. /**
  41298. * Returns true if the mesh can be rendered, otherwise false.
  41299. * @param mesh The mesh to render
  41300. * @param material The material used on the mesh
  41301. * @returns true if it can be rendered otherwise false
  41302. */
  41303. EffectLayer.prototype._canRenderMesh = function (mesh, material) {
  41304. return !material.needAlphaBlendingForMesh(mesh);
  41305. };
  41306. /**
  41307. * Returns true if the mesh should render, otherwise false.
  41308. * @param mesh The mesh to render
  41309. * @returns true if it should render otherwise false
  41310. */
  41311. EffectLayer.prototype._shouldRenderEmissiveTextureForMesh = function () {
  41312. return true;
  41313. };
  41314. /**
  41315. * Renders the submesh passed in parameter to the generation map.
  41316. */
  41317. EffectLayer.prototype._renderSubMesh = function (subMesh) {
  41318. var _this = this;
  41319. if (!this.shouldRender()) {
  41320. return;
  41321. }
  41322. var material = subMesh.getMaterial();
  41323. var mesh = subMesh.getRenderingMesh();
  41324. var scene = this._scene;
  41325. var engine = scene.getEngine();
  41326. if (!material) {
  41327. return;
  41328. }
  41329. // Do not block in blend mode.
  41330. if (!this._canRenderMesh(mesh, material)) {
  41331. return;
  41332. }
  41333. // Culling
  41334. engine.setState(material.backFaceCulling);
  41335. // Managing instances
  41336. var batch = mesh._getInstancesRenderList(subMesh._id);
  41337. if (batch.mustReturn) {
  41338. return;
  41339. }
  41340. // Early Exit per mesh
  41341. if (!this._shouldRenderMesh(mesh)) {
  41342. return;
  41343. }
  41344. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  41345. this._setEmissiveTextureAndColor(mesh, subMesh, material);
  41346. if (this._isReady(subMesh, hardwareInstancedRendering, this._emissiveTextureAndColor.texture)) {
  41347. engine.enableEffect(this._effectLayerMapGenerationEffect);
  41348. mesh._bind(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode);
  41349. this._effectLayerMapGenerationEffect.setMatrix("viewProjection", scene.getTransformMatrix());
  41350. this._effectLayerMapGenerationEffect.setFloat4("color", this._emissiveTextureAndColor.color.r, this._emissiveTextureAndColor.color.g, this._emissiveTextureAndColor.color.b, this._emissiveTextureAndColor.color.a);
  41351. var needAlphaTest = material.needAlphaTesting();
  41352. var diffuseTexture = material.getAlphaTestTexture();
  41353. var needAlphaBlendFromDiffuse = diffuseTexture && diffuseTexture.hasAlpha &&
  41354. (material.useAlphaFromDiffuseTexture || material._useAlphaFromAlbedoTexture);
  41355. if (diffuseTexture && (needAlphaTest || needAlphaBlendFromDiffuse)) {
  41356. this._effectLayerMapGenerationEffect.setTexture("diffuseSampler", diffuseTexture);
  41357. var textureMatrix = diffuseTexture.getTextureMatrix();
  41358. if (textureMatrix) {
  41359. this._effectLayerMapGenerationEffect.setMatrix("diffuseMatrix", textureMatrix);
  41360. }
  41361. }
  41362. var opacityTexture = material.opacityTexture;
  41363. if (opacityTexture) {
  41364. this._effectLayerMapGenerationEffect.setTexture("opacitySampler", opacityTexture);
  41365. this._effectLayerMapGenerationEffect.setFloat("opacityIntensity", opacityTexture.level);
  41366. var textureMatrix = opacityTexture.getTextureMatrix();
  41367. if (textureMatrix) {
  41368. this._effectLayerMapGenerationEffect.setMatrix("opacityMatrix", textureMatrix);
  41369. }
  41370. }
  41371. // Glow emissive only
  41372. if (this._emissiveTextureAndColor.texture) {
  41373. this._effectLayerMapGenerationEffect.setTexture("emissiveSampler", this._emissiveTextureAndColor.texture);
  41374. this._effectLayerMapGenerationEffect.setMatrix("emissiveMatrix", this._emissiveTextureAndColor.texture.getTextureMatrix());
  41375. }
  41376. // Bones
  41377. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  41378. this._effectLayerMapGenerationEffect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  41379. }
  41380. // Morph targets
  41381. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effectLayerMapGenerationEffect);
  41382. // Draw
  41383. mesh._processRendering(subMesh, this._effectLayerMapGenerationEffect, _Materials_material__WEBPACK_IMPORTED_MODULE_9__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effectLayerMapGenerationEffect.setMatrix("world", world); });
  41384. }
  41385. else {
  41386. // Need to reset refresh rate of the main map
  41387. this._mainTexture.resetRefreshCounter();
  41388. }
  41389. };
  41390. /**
  41391. * Rebuild the required buffers.
  41392. * @hidden Internal use only.
  41393. */
  41394. EffectLayer.prototype._rebuild = function () {
  41395. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41396. if (vb) {
  41397. vb._rebuild();
  41398. }
  41399. this._generateIndexBuffer();
  41400. };
  41401. /**
  41402. * Dispose only the render target textures and post process.
  41403. */
  41404. EffectLayer.prototype._disposeTextureAndPostProcesses = function () {
  41405. this._mainTexture.dispose();
  41406. for (var i = 0; i < this._postProcesses.length; i++) {
  41407. if (this._postProcesses[i]) {
  41408. this._postProcesses[i].dispose();
  41409. }
  41410. }
  41411. this._postProcesses = [];
  41412. for (var i = 0; i < this._textures.length; i++) {
  41413. if (this._textures[i]) {
  41414. this._textures[i].dispose();
  41415. }
  41416. }
  41417. this._textures = [];
  41418. };
  41419. /**
  41420. * Dispose the highlight layer and free resources.
  41421. */
  41422. EffectLayer.prototype.dispose = function () {
  41423. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind];
  41424. if (vertexBuffer) {
  41425. vertexBuffer.dispose();
  41426. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_6__["VertexBuffer"].PositionKind] = null;
  41427. }
  41428. if (this._indexBuffer) {
  41429. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  41430. this._indexBuffer = null;
  41431. }
  41432. // Clean textures and post processes
  41433. this._disposeTextureAndPostProcesses();
  41434. // Remove from scene
  41435. var index = this._scene.effectLayers.indexOf(this, 0);
  41436. if (index > -1) {
  41437. this._scene.effectLayers.splice(index, 1);
  41438. }
  41439. // Callback
  41440. this.onDisposeObservable.notifyObservers(this);
  41441. this.onDisposeObservable.clear();
  41442. this.onBeforeRenderMainTextureObservable.clear();
  41443. this.onBeforeComposeObservable.clear();
  41444. this.onAfterComposeObservable.clear();
  41445. this.onSizeChangedObservable.clear();
  41446. };
  41447. /**
  41448. * Gets the class name of the effect layer
  41449. * @returns the string with the class name of the effect layer
  41450. */
  41451. EffectLayer.prototype.getClassName = function () {
  41452. return "EffectLayer";
  41453. };
  41454. /**
  41455. * Creates an effect layer from parsed effect layer data
  41456. * @param parsedEffectLayer defines effect layer data
  41457. * @param scene defines the current scene
  41458. * @param rootUrl defines the root URL containing the effect layer information
  41459. * @returns a parsed effect Layer
  41460. */
  41461. EffectLayer.Parse = function (parsedEffectLayer, scene, rootUrl) {
  41462. var effectLayerType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedEffectLayer.customType);
  41463. return effectLayerType.Parse(parsedEffectLayer, scene, rootUrl);
  41464. };
  41465. /** @hidden */
  41466. EffectLayer._SceneComponentInitialization = function (_) {
  41467. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_14__["_DevTools"].WarnImport("EffectLayerSceneComponent");
  41468. };
  41469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41471. ], EffectLayer.prototype, "name", void 0);
  41472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  41474. ], EffectLayer.prototype, "neutralColor", void 0);
  41475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41477. ], EffectLayer.prototype, "isEnabled", void 0);
  41478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsCameraReference"])()
  41480. ], EffectLayer.prototype, "camera", null);
  41481. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  41482. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  41483. ], EffectLayer.prototype, "renderingGroupId", null);
  41484. return EffectLayer;
  41485. }());
  41486. /***/ }),
  41487. /***/ "./Layers/effectLayerSceneComponent.ts":
  41488. /*!*********************************************!*\
  41489. !*** ./Layers/effectLayerSceneComponent.ts ***!
  41490. \*********************************************/
  41491. /*! exports provided: EffectLayerSceneComponent */
  41492. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41493. "use strict";
  41494. __webpack_require__.r(__webpack_exports__);
  41495. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return EffectLayerSceneComponent; });
  41496. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  41497. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  41498. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41499. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41500. // Adds the parser to the scene parsers.
  41501. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER, function (parsedData, scene, container, rootUrl) {
  41502. if (parsedData.effectLayers) {
  41503. if (!container.effectLayers) {
  41504. container.effectLayers = new Array();
  41505. }
  41506. for (var index = 0; index < parsedData.effectLayers.length; index++) {
  41507. var effectLayer = _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"].Parse(parsedData.effectLayers[index], scene, rootUrl);
  41508. container.effectLayers.push(effectLayer);
  41509. }
  41510. }
  41511. });
  41512. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.removeEffectLayer = function (toRemove) {
  41513. var index = this.effectLayers.indexOf(toRemove);
  41514. if (index !== -1) {
  41515. this.effectLayers.splice(index, 1);
  41516. }
  41517. return index;
  41518. };
  41519. _abstractScene__WEBPACK_IMPORTED_MODULE_3__["AbstractScene"].prototype.addEffectLayer = function (newEffectLayer) {
  41520. this.effectLayers.push(newEffectLayer);
  41521. };
  41522. /**
  41523. * Defines the layer scene component responsible to manage any effect layers
  41524. * in a given scene.
  41525. */
  41526. var EffectLayerSceneComponent = /** @class */ (function () {
  41527. /**
  41528. * Creates a new instance of the component for the given scene
  41529. * @param scene Defines the scene to register the component in
  41530. */
  41531. function EffectLayerSceneComponent(scene) {
  41532. /**
  41533. * The component name helpfull to identify the component in the list of scene components.
  41534. */
  41535. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER;
  41536. this._renderEffects = false;
  41537. this._needStencil = false;
  41538. this._previousStencilState = false;
  41539. this.scene = scene;
  41540. this._engine = scene.getEngine();
  41541. scene.effectLayers = new Array();
  41542. }
  41543. /**
  41544. * Registers the component in a given scene
  41545. */
  41546. EffectLayerSceneComponent.prototype.register = function () {
  41547. this.scene._isReadyForMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_ISREADYFORMESH_EFFECTLAYER, this, this._isReadyForMesh);
  41548. this.scene._cameraDrawRenderTargetStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER, this, this._renderMainTexture);
  41549. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_EFFECTLAYER, this, this._setStencil);
  41550. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW, this, this._drawRenderingGroup);
  41551. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER, this, this._setStencilBack);
  41552. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW, this, this._drawCamera);
  41553. };
  41554. /**
  41555. * Rebuilds the elements related to this component in case of
  41556. * context lost for instance.
  41557. */
  41558. EffectLayerSceneComponent.prototype.rebuild = function () {
  41559. var layers = this.scene.effectLayers;
  41560. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  41561. var effectLayer = layers_1[_i];
  41562. effectLayer._rebuild();
  41563. }
  41564. };
  41565. /**
  41566. * Serializes the component data to the specified json object
  41567. * @param serializationObject The object to serialize to
  41568. */
  41569. EffectLayerSceneComponent.prototype.serialize = function (serializationObject) {
  41570. // Effect layers
  41571. serializationObject.effectLayers = [];
  41572. var layers = this.scene.effectLayers;
  41573. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  41574. var effectLayer = layers_2[_i];
  41575. if (effectLayer.serialize) {
  41576. serializationObject.effectLayers.push(effectLayer.serialize());
  41577. }
  41578. }
  41579. };
  41580. /**
  41581. * Adds all the element from the container to the scene
  41582. * @param container the container holding the elements
  41583. */
  41584. EffectLayerSceneComponent.prototype.addFromContainer = function (container) {
  41585. var _this = this;
  41586. if (!container.effectLayers) {
  41587. return;
  41588. }
  41589. container.effectLayers.forEach(function (o) {
  41590. _this.scene.addEffectLayer(o);
  41591. });
  41592. };
  41593. /**
  41594. * Removes all the elements in the container from the scene
  41595. * @param container contains the elements to remove
  41596. */
  41597. EffectLayerSceneComponent.prototype.removeFromContainer = function (container) {
  41598. var _this = this;
  41599. if (!container.effectLayers) {
  41600. return;
  41601. }
  41602. container.effectLayers.forEach(function (o) {
  41603. _this.scene.removeEffectLayer(o);
  41604. });
  41605. };
  41606. /**
  41607. * Disposes the component and the associated ressources.
  41608. */
  41609. EffectLayerSceneComponent.prototype.dispose = function () {
  41610. var layers = this.scene.effectLayers;
  41611. while (layers.length) {
  41612. layers[0].dispose();
  41613. }
  41614. };
  41615. EffectLayerSceneComponent.prototype._isReadyForMesh = function (mesh, hardwareInstancedRendering) {
  41616. var layers = this.scene.effectLayers;
  41617. for (var _i = 0, layers_3 = layers; _i < layers_3.length; _i++) {
  41618. var layer = layers_3[_i];
  41619. if (!layer.hasMesh(mesh)) {
  41620. continue;
  41621. }
  41622. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  41623. var subMesh = _b[_a];
  41624. if (!layer.isReady(subMesh, hardwareInstancedRendering)) {
  41625. return false;
  41626. }
  41627. }
  41628. }
  41629. return true;
  41630. };
  41631. EffectLayerSceneComponent.prototype._renderMainTexture = function (camera) {
  41632. this._renderEffects = false;
  41633. this._needStencil = false;
  41634. var layers = this.scene.effectLayers;
  41635. if (layers && layers.length > 0) {
  41636. this._previousStencilState = this._engine.getStencilBuffer();
  41637. for (var _i = 0, layers_4 = layers; _i < layers_4.length; _i++) {
  41638. var effectLayer = layers_4[_i];
  41639. if (effectLayer.shouldRender() &&
  41640. (!effectLayer.camera ||
  41641. (effectLayer.camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && camera === effectLayer.camera) ||
  41642. (effectLayer.camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_0__["Camera"].RIG_MODE_NONE && effectLayer.camera._rigCameras.indexOf(camera) > -1))) {
  41643. this._renderEffects = true;
  41644. this._needStencil = this._needStencil || effectLayer.needStencil();
  41645. var renderTarget = effectLayer._mainTexture;
  41646. if (renderTarget._shouldRender()) {
  41647. this.scene.incrementRenderId();
  41648. renderTarget.render(false, false);
  41649. }
  41650. }
  41651. }
  41652. this.scene.incrementRenderId();
  41653. }
  41654. };
  41655. EffectLayerSceneComponent.prototype._setStencil = function () {
  41656. // Activate effect Layer stencil
  41657. if (this._needStencil) {
  41658. this._engine.setStencilBuffer(true);
  41659. }
  41660. };
  41661. EffectLayerSceneComponent.prototype._setStencilBack = function () {
  41662. // Restore effect Layer stencil
  41663. if (this._needStencil) {
  41664. this._engine.setStencilBuffer(this._previousStencilState);
  41665. }
  41666. };
  41667. EffectLayerSceneComponent.prototype._draw = function (renderingGroupId) {
  41668. if (this._renderEffects) {
  41669. this._engine.setDepthBuffer(false);
  41670. var layers = this.scene.effectLayers;
  41671. for (var i = 0; i < layers.length; i++) {
  41672. var effectLayer = layers[i];
  41673. if (effectLayer.renderingGroupId === renderingGroupId) {
  41674. if (effectLayer.shouldRender()) {
  41675. effectLayer.render();
  41676. }
  41677. }
  41678. }
  41679. this._engine.setDepthBuffer(true);
  41680. }
  41681. };
  41682. EffectLayerSceneComponent.prototype._drawCamera = function () {
  41683. if (this._renderEffects) {
  41684. this._draw(-1);
  41685. }
  41686. };
  41687. EffectLayerSceneComponent.prototype._drawRenderingGroup = function (index) {
  41688. if (!this.scene._isInIntermediateRendering() && this._renderEffects) {
  41689. this._draw(index);
  41690. }
  41691. };
  41692. return EffectLayerSceneComponent;
  41693. }());
  41694. _effectLayer__WEBPACK_IMPORTED_MODULE_2__["EffectLayer"]._SceneComponentInitialization = function (scene) {
  41695. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_EFFECTLAYER);
  41696. if (!component) {
  41697. component = new EffectLayerSceneComponent(scene);
  41698. scene._addComponent(component);
  41699. }
  41700. };
  41701. /***/ }),
  41702. /***/ "./Layers/glowLayer.ts":
  41703. /*!*****************************!*\
  41704. !*** ./Layers/glowLayer.ts ***!
  41705. \*****************************/
  41706. /*! exports provided: GlowLayer */
  41707. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  41708. "use strict";
  41709. __webpack_require__.r(__webpack_exports__);
  41710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return GlowLayer; });
  41711. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  41712. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  41713. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  41714. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  41715. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  41716. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  41717. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  41718. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  41719. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  41720. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  41721. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  41722. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  41723. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  41724. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  41725. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  41726. _abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"].prototype.getGlowLayerByName = function (name) {
  41727. for (var index = 0; index < this.effectLayers.length; index++) {
  41728. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === GlowLayer.EffectName) {
  41729. return this.effectLayers[index];
  41730. }
  41731. }
  41732. return null;
  41733. };
  41734. /**
  41735. * The glow layer Helps adding a glow effect around the emissive parts of a mesh.
  41736. *
  41737. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  41738. * glowy meshes to your scene.
  41739. *
  41740. * Documentation: https://doc.babylonjs.com/how_to/glow_layer
  41741. */
  41742. var GlowLayer = /** @class */ (function (_super) {
  41743. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowLayer, _super);
  41744. /**
  41745. * Instantiates a new glow Layer and references it to the scene.
  41746. * @param name The name of the layer
  41747. * @param scene The scene to use the layer in
  41748. * @param options Sets of none mandatory options to use with the layer (see IGlowLayerOptions for more information)
  41749. */
  41750. function GlowLayer(name, scene, options) {
  41751. var _this = _super.call(this, name, scene) || this;
  41752. _this._intensity = 1.0;
  41753. _this._includedOnlyMeshes = [];
  41754. _this._excludedMeshes = [];
  41755. _this.neutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 1);
  41756. // Adapt options
  41757. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ mainTextureRatio: GlowLayer.DefaultTextureRatio, blurKernelSize: 32, mainTextureFixedSize: undefined, camera: null, mainTextureSamples: 1, renderingGroupId: -1 }, options);
  41758. // Initialize the layer
  41759. _this._init({
  41760. alphaBlendingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].ALPHA_ADD,
  41761. camera: _this._options.camera,
  41762. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  41763. mainTextureRatio: _this._options.mainTextureRatio,
  41764. renderingGroupId: _this._options.renderingGroupId
  41765. });
  41766. return _this;
  41767. }
  41768. Object.defineProperty(GlowLayer.prototype, "blurKernelSize", {
  41769. /**
  41770. * Gets the kernel size of the blur.
  41771. */
  41772. get: function () {
  41773. return this._horizontalBlurPostprocess1.kernel;
  41774. },
  41775. /**
  41776. * Sets the kernel size of the blur.
  41777. */
  41778. set: function (value) {
  41779. this._horizontalBlurPostprocess1.kernel = value;
  41780. this._verticalBlurPostprocess1.kernel = value;
  41781. this._horizontalBlurPostprocess2.kernel = value;
  41782. this._verticalBlurPostprocess2.kernel = value;
  41783. },
  41784. enumerable: true,
  41785. configurable: true
  41786. });
  41787. Object.defineProperty(GlowLayer.prototype, "intensity", {
  41788. /**
  41789. * Gets the glow intensity.
  41790. */
  41791. get: function () {
  41792. return this._intensity;
  41793. },
  41794. /**
  41795. * Sets the glow intensity.
  41796. */
  41797. set: function (value) {
  41798. this._intensity = value;
  41799. },
  41800. enumerable: true,
  41801. configurable: true
  41802. });
  41803. /**
  41804. * Get the effect name of the layer.
  41805. * @return The effect name
  41806. */
  41807. GlowLayer.prototype.getEffectName = function () {
  41808. return GlowLayer.EffectName;
  41809. };
  41810. /**
  41811. * Create the merge effect. This is the shader use to blit the information back
  41812. * to the main canvas at the end of the scene rendering.
  41813. */
  41814. GlowLayer.prototype._createMergeEffect = function () {
  41815. // Effect
  41816. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler", "textureSampler2"], "#define EMISSIVE \n");
  41817. };
  41818. /**
  41819. * Creates the render target textures and post processes used in the glow layer.
  41820. */
  41821. GlowLayer.prototype._createTextureAndPostProcesses = function () {
  41822. var _this = this;
  41823. var blurTextureWidth = this._mainTextureDesiredSize.width;
  41824. var blurTextureHeight = this._mainTextureDesiredSize.height;
  41825. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  41826. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  41827. var textureType = 0;
  41828. if (this._engine.getCaps().textureHalfFloatRender) {
  41829. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_HALF_FLOAT;
  41830. }
  41831. else {
  41832. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  41833. }
  41834. this._blurTexture1 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT", {
  41835. width: blurTextureWidth,
  41836. height: blurTextureHeight
  41837. }, this._scene, false, true, textureType);
  41838. this._blurTexture1.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41839. this._blurTexture1.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41840. this._blurTexture1.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41841. this._blurTexture1.renderParticles = false;
  41842. this._blurTexture1.ignoreCameraViewport = true;
  41843. var blurTextureWidth2 = Math.floor(blurTextureWidth / 2);
  41844. var blurTextureHeight2 = Math.floor(blurTextureHeight / 2);
  41845. this._blurTexture2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_6__["RenderTargetTexture"]("GlowLayerBlurRTT2", {
  41846. width: blurTextureWidth2,
  41847. height: blurTextureHeight2
  41848. }, this._scene, false, true, textureType);
  41849. this._blurTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41850. this._blurTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CLAMP_ADDRESSMODE;
  41851. this._blurTexture2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE);
  41852. this._blurTexture2.renderParticles = false;
  41853. this._blurTexture2.ignoreCameraViewport = true;
  41854. this._textures = [this._blurTexture1, this._blurTexture2];
  41855. 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, {
  41856. width: blurTextureWidth,
  41857. height: blurTextureHeight
  41858. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41859. this._horizontalBlurPostprocess1.width = blurTextureWidth;
  41860. this._horizontalBlurPostprocess1.height = blurTextureHeight;
  41861. this._horizontalBlurPostprocess1.onApplyObservable.add(function (effect) {
  41862. effect.setTexture("textureSampler", _this._mainTexture);
  41863. });
  41864. 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, {
  41865. width: blurTextureWidth,
  41866. height: blurTextureHeight
  41867. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41868. 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, {
  41869. width: blurTextureWidth2,
  41870. height: blurTextureHeight2
  41871. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41872. this._horizontalBlurPostprocess2.width = blurTextureWidth2;
  41873. this._horizontalBlurPostprocess2.height = blurTextureHeight2;
  41874. this._horizontalBlurPostprocess2.onApplyObservable.add(function (effect) {
  41875. effect.setTexture("textureSampler", _this._blurTexture1);
  41876. });
  41877. 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, {
  41878. width: blurTextureWidth2,
  41879. height: blurTextureHeight2
  41880. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  41881. this._postProcesses = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1, this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41882. this._postProcesses1 = [this._horizontalBlurPostprocess1, this._verticalBlurPostprocess1];
  41883. this._postProcesses2 = [this._horizontalBlurPostprocess2, this._verticalBlurPostprocess2];
  41884. this._mainTexture.samples = this._options.mainTextureSamples;
  41885. this._mainTexture.onAfterUnbindObservable.add(function () {
  41886. var internalTexture = _this._blurTexture1.getInternalTexture();
  41887. if (internalTexture) {
  41888. _this._scene.postProcessManager.directRender(_this._postProcesses1, internalTexture, true);
  41889. internalTexture = _this._blurTexture2.getInternalTexture();
  41890. if (internalTexture) {
  41891. _this._scene.postProcessManager.directRender(_this._postProcesses2, internalTexture, true);
  41892. }
  41893. }
  41894. });
  41895. // Prevent autoClear.
  41896. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  41897. };
  41898. /**
  41899. * Checks for the readiness of the element composing the layer.
  41900. * @param subMesh the mesh to check for
  41901. * @param useInstances specify wether or not to use instances to render the mesh
  41902. * @param emissiveTexture the associated emissive texture used to generate the glow
  41903. * @return true if ready otherwise, false
  41904. */
  41905. GlowLayer.prototype.isReady = function (subMesh, useInstances) {
  41906. var material = subMesh.getMaterial();
  41907. var mesh = subMesh.getRenderingMesh();
  41908. if (!material || !mesh) {
  41909. return false;
  41910. }
  41911. var emissiveTexture = material.emissiveTexture;
  41912. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  41913. };
  41914. /**
  41915. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  41916. */
  41917. GlowLayer.prototype.needStencil = function () {
  41918. return false;
  41919. };
  41920. /**
  41921. * Returns true if the mesh can be rendered, otherwise false.
  41922. * @param mesh The mesh to render
  41923. * @param material The material used on the mesh
  41924. * @returns true if it can be rendered otherwise false
  41925. */
  41926. GlowLayer.prototype._canRenderMesh = function (mesh, material) {
  41927. return true;
  41928. };
  41929. /**
  41930. * Implementation specific of rendering the generating effect on the main canvas.
  41931. * @param effect The effect used to render through
  41932. */
  41933. GlowLayer.prototype._internalRender = function (effect) {
  41934. // Texture
  41935. effect.setTexture("textureSampler", this._blurTexture1);
  41936. effect.setTexture("textureSampler2", this._blurTexture2);
  41937. effect.setFloat("offset", this._intensity);
  41938. // Cache
  41939. var engine = this._engine;
  41940. var previousStencilBuffer = engine.getStencilBuffer();
  41941. // Draw order
  41942. engine.setStencilBuffer(false);
  41943. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, 6);
  41944. // Draw order
  41945. engine.setStencilBuffer(previousStencilBuffer);
  41946. };
  41947. /**
  41948. * Sets the required values for both the emissive texture and and the main color.
  41949. */
  41950. GlowLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  41951. var textureLevel = 1.0;
  41952. if (this.customEmissiveTextureSelector) {
  41953. this._emissiveTextureAndColor.texture = this.customEmissiveTextureSelector(mesh, subMesh, material);
  41954. }
  41955. else {
  41956. if (material) {
  41957. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  41958. if (this._emissiveTextureAndColor.texture) {
  41959. textureLevel = this._emissiveTextureAndColor.texture.level;
  41960. }
  41961. }
  41962. else {
  41963. this._emissiveTextureAndColor.texture = null;
  41964. }
  41965. }
  41966. if (this.customEmissiveColorSelector) {
  41967. this.customEmissiveColorSelector(mesh, subMesh, material, this._emissiveTextureAndColor.color);
  41968. }
  41969. else {
  41970. if (material.emissiveColor) {
  41971. this._emissiveTextureAndColor.color.set(material.emissiveColor.r * textureLevel, material.emissiveColor.g * textureLevel, material.emissiveColor.b * textureLevel, material.alpha);
  41972. }
  41973. else {
  41974. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  41975. }
  41976. }
  41977. };
  41978. /**
  41979. * Returns true if the mesh should render, otherwise false.
  41980. * @param mesh The mesh to render
  41981. * @returns true if it should render otherwise false
  41982. */
  41983. GlowLayer.prototype._shouldRenderMesh = function (mesh) {
  41984. return this.hasMesh(mesh);
  41985. };
  41986. /**
  41987. * Adds specific effects defines.
  41988. * @param defines The defines to add specifics to.
  41989. */
  41990. GlowLayer.prototype._addCustomEffectDefines = function (defines) {
  41991. defines.push("#define GLOW");
  41992. };
  41993. /**
  41994. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the glow layer.
  41995. * @param mesh The mesh to exclude from the glow layer
  41996. */
  41997. GlowLayer.prototype.addExcludedMesh = function (mesh) {
  41998. if (this._excludedMeshes.indexOf(mesh.uniqueId) === -1) {
  41999. this._excludedMeshes.push(mesh.uniqueId);
  42000. }
  42001. };
  42002. /**
  42003. * Remove a mesh from the exclusion list to let it impact or being impacted by the glow layer.
  42004. * @param mesh The mesh to remove
  42005. */
  42006. GlowLayer.prototype.removeExcludedMesh = function (mesh) {
  42007. var index = this._excludedMeshes.indexOf(mesh.uniqueId);
  42008. if (index !== -1) {
  42009. this._excludedMeshes.splice(index, 1);
  42010. }
  42011. };
  42012. /**
  42013. * Add a mesh in the inclusion list to impact or being impacted by the glow layer.
  42014. * @param mesh The mesh to include in the glow layer
  42015. */
  42016. GlowLayer.prototype.addIncludedOnlyMesh = function (mesh) {
  42017. if (this._includedOnlyMeshes.indexOf(mesh.uniqueId) === -1) {
  42018. this._includedOnlyMeshes.push(mesh.uniqueId);
  42019. }
  42020. };
  42021. /**
  42022. * Remove a mesh from the Inclusion list to prevent it to impact or being impacted by the glow layer.
  42023. * @param mesh The mesh to remove
  42024. */
  42025. GlowLayer.prototype.removeIncludedOnlyMesh = function (mesh) {
  42026. var index = this._includedOnlyMeshes.indexOf(mesh.uniqueId);
  42027. if (index !== -1) {
  42028. this._includedOnlyMeshes.splice(index, 1);
  42029. }
  42030. };
  42031. /**
  42032. * Determine if a given mesh will be used in the glow layer
  42033. * @param mesh The mesh to test
  42034. * @returns true if the mesh will be highlighted by the current glow layer
  42035. */
  42036. GlowLayer.prototype.hasMesh = function (mesh) {
  42037. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42038. return false;
  42039. }
  42040. // Included Mesh
  42041. if (this._includedOnlyMeshes.length) {
  42042. return this._includedOnlyMeshes.indexOf(mesh.uniqueId) !== -1;
  42043. }
  42044. // Excluded Mesh
  42045. if (this._excludedMeshes.length) {
  42046. return this._excludedMeshes.indexOf(mesh.uniqueId) === -1;
  42047. }
  42048. return true;
  42049. };
  42050. /**
  42051. * Free any resources and references associated to a mesh.
  42052. * Internal use
  42053. * @param mesh The mesh to free.
  42054. * @hidden
  42055. */
  42056. GlowLayer.prototype._disposeMesh = function (mesh) {
  42057. this.removeIncludedOnlyMesh(mesh);
  42058. this.removeExcludedMesh(mesh);
  42059. };
  42060. /**
  42061. * Gets the class name of the effect layer
  42062. * @returns the string with the class name of the effect layer
  42063. */
  42064. GlowLayer.prototype.getClassName = function () {
  42065. return "GlowLayer";
  42066. };
  42067. /**
  42068. * Serializes this glow layer
  42069. * @returns a serialized glow layer object
  42070. */
  42071. GlowLayer.prototype.serialize = function () {
  42072. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42073. serializationObject.customType = "BABYLON.GlowLayer";
  42074. var index;
  42075. // Included meshes
  42076. serializationObject.includedMeshes = [];
  42077. if (this._includedOnlyMeshes.length) {
  42078. for (index = 0; index < this._includedOnlyMeshes.length; index++) {
  42079. var mesh = this._scene.getMeshByUniqueID(this._includedOnlyMeshes[index]);
  42080. if (mesh) {
  42081. serializationObject.includedMeshes.push(mesh.id);
  42082. }
  42083. }
  42084. }
  42085. // Excluded meshes
  42086. serializationObject.excludedMeshes = [];
  42087. if (this._excludedMeshes.length) {
  42088. for (index = 0; index < this._excludedMeshes.length; index++) {
  42089. var mesh = this._scene.getMeshByUniqueID(this._excludedMeshes[index]);
  42090. if (mesh) {
  42091. serializationObject.excludedMeshes.push(mesh.id);
  42092. }
  42093. }
  42094. }
  42095. return serializationObject;
  42096. };
  42097. /**
  42098. * Creates a Glow Layer from parsed glow layer data
  42099. * @param parsedGlowLayer defines glow layer data
  42100. * @param scene defines the current scene
  42101. * @param rootUrl defines the root URL containing the glow layer information
  42102. * @returns a parsed Glow Layer
  42103. */
  42104. GlowLayer.Parse = function (parsedGlowLayer, scene, rootUrl) {
  42105. var gl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new GlowLayer(parsedGlowLayer.name, scene, parsedGlowLayer.options); }, parsedGlowLayer, scene, rootUrl);
  42106. var index;
  42107. // Excluded meshes
  42108. for (index = 0; index < parsedGlowLayer.excludedMeshes.length; index++) {
  42109. var mesh = scene.getMeshByID(parsedGlowLayer.excludedMeshes[index]);
  42110. if (mesh) {
  42111. gl.addExcludedMesh(mesh);
  42112. }
  42113. }
  42114. // Included meshes
  42115. for (index = 0; index < parsedGlowLayer.includedMeshes.length; index++) {
  42116. var mesh = scene.getMeshByID(parsedGlowLayer.includedMeshes[index]);
  42117. if (mesh) {
  42118. gl.addIncludedOnlyMesh(mesh);
  42119. }
  42120. }
  42121. return gl;
  42122. };
  42123. /**
  42124. * Effect Name of the layer.
  42125. */
  42126. GlowLayer.EffectName = "GlowLayer";
  42127. /**
  42128. * The default blur kernel size used for the glow.
  42129. */
  42130. GlowLayer.DefaultBlurKernelSize = 32;
  42131. /**
  42132. * The default texture size ratio used for the glow.
  42133. */
  42134. GlowLayer.DefaultTextureRatio = 0.5;
  42135. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42136. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42137. ], GlowLayer.prototype, "blurKernelSize", null);
  42138. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42139. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42140. ], GlowLayer.prototype, "intensity", null);
  42141. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42142. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42143. ], GlowLayer.prototype, "_options", void 0);
  42144. return GlowLayer;
  42145. }(_effectLayer__WEBPACK_IMPORTED_MODULE_9__["EffectLayer"]));
  42146. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.GlowLayer"] = GlowLayer;
  42147. /***/ }),
  42148. /***/ "./Layers/highlightLayer.ts":
  42149. /*!**********************************!*\
  42150. !*** ./Layers/highlightLayer.ts ***!
  42151. \**********************************/
  42152. /*! exports provided: HighlightLayer */
  42153. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42154. "use strict";
  42155. __webpack_require__.r(__webpack_exports__);
  42156. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return HighlightLayer; });
  42157. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  42158. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  42159. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42160. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  42161. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42162. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42163. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42164. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42165. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  42166. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  42167. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  42168. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  42169. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42170. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  42171. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42172. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  42173. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  42174. /* harmony import */ var _Shaders_glowMapMerge_fragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Shaders/glowMapMerge.fragment */ "./Shaders/glowMapMerge.fragment.ts");
  42175. /* harmony import */ var _Shaders_glowMapMerge_vertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/glowMapMerge.vertex */ "./Shaders/glowMapMerge.vertex.ts");
  42176. /* harmony import */ var _Shaders_glowBlurPostProcess_fragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/glowBlurPostProcess.fragment */ "./Shaders/glowBlurPostProcess.fragment.ts");
  42177. _abstractScene__WEBPACK_IMPORTED_MODULE_13__["AbstractScene"].prototype.getHighlightLayerByName = function (name) {
  42178. for (var index = 0; index < this.effectLayers.length; index++) {
  42179. if (this.effectLayers[index].name === name && this.effectLayers[index].getEffectName() === HighlightLayer.EffectName) {
  42180. return this.effectLayers[index];
  42181. }
  42182. }
  42183. return null;
  42184. };
  42185. /**
  42186. * Special Glow Blur post process only blurring the alpha channel
  42187. * It enforces keeping the most luminous color in the color channel.
  42188. */
  42189. var GlowBlurPostProcess = /** @class */ (function (_super) {
  42190. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GlowBlurPostProcess, _super);
  42191. function GlowBlurPostProcess(name, direction, kernel, options, camera, samplingMode, engine, reusable) {
  42192. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE; }
  42193. var _this = _super.call(this, name, "glowBlurPostProcess", ["screenSize", "direction", "blurWidth"], null, options, camera, samplingMode, engine, reusable) || this;
  42194. _this.direction = direction;
  42195. _this.kernel = kernel;
  42196. _this.onApplyObservable.add(function (effect) {
  42197. effect.setFloat2("screenSize", _this.width, _this.height);
  42198. effect.setVector2("direction", _this.direction);
  42199. effect.setFloat("blurWidth", _this.kernel);
  42200. });
  42201. return _this;
  42202. }
  42203. return GlowBlurPostProcess;
  42204. }(_PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_9__["PostProcess"]));
  42205. /**
  42206. * The highlight layer Helps adding a glow effect around a mesh.
  42207. *
  42208. * Once instantiated in a scene, simply use the pushMesh or removeMesh method to add or remove
  42209. * glowy meshes to your scene.
  42210. *
  42211. * !!! THIS REQUIRES AN ACTIVE STENCIL BUFFER ON THE CANVAS !!!
  42212. */
  42213. var HighlightLayer = /** @class */ (function (_super) {
  42214. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightLayer, _super);
  42215. /**
  42216. * Instantiates a new highlight Layer and references it to the scene..
  42217. * @param name The name of the layer
  42218. * @param scene The scene to use the layer in
  42219. * @param options Sets of none mandatory options to use with the layer (see IHighlightLayerOptions for more information)
  42220. */
  42221. function HighlightLayer(name, scene, options) {
  42222. var _this = _super.call(this, name, scene) || this;
  42223. _this.name = name;
  42224. /**
  42225. * Specifies whether or not the inner glow is ACTIVE in the layer.
  42226. */
  42227. _this.innerGlow = true;
  42228. /**
  42229. * Specifies whether or not the outer glow is ACTIVE in the layer.
  42230. */
  42231. _this.outerGlow = true;
  42232. /**
  42233. * An event triggered when the highlight layer is being blurred.
  42234. */
  42235. _this.onBeforeBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42236. /**
  42237. * An event triggered when the highlight layer has been blurred.
  42238. */
  42239. _this.onAfterBlurObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  42240. _this._instanceGlowingMeshStencilReference = HighlightLayer.GlowingMeshStencilReference++;
  42241. _this._meshes = {};
  42242. _this._excludedMeshes = {};
  42243. _this.neutralColor = HighlightLayer.NeutralColor;
  42244. // Warn on stencil
  42245. if (!_this._engine.isStencilEnable) {
  42246. _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 }");
  42247. }
  42248. // Adapt options
  42249. _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);
  42250. // Initialize the layer
  42251. _this._init({
  42252. alphaBlendingMode: _this._options.alphaBlendingMode,
  42253. camera: _this._options.camera,
  42254. mainTextureFixedSize: _this._options.mainTextureFixedSize,
  42255. mainTextureRatio: _this._options.mainTextureRatio,
  42256. renderingGroupId: _this._options.renderingGroupId
  42257. });
  42258. // Do not render as long as no meshes have been added
  42259. _this._shouldRender = false;
  42260. return _this;
  42261. }
  42262. Object.defineProperty(HighlightLayer.prototype, "blurHorizontalSize", {
  42263. /**
  42264. * Gets the horizontal size of the blur.
  42265. */
  42266. get: function () {
  42267. return this._horizontalBlurPostprocess.kernel;
  42268. },
  42269. /**
  42270. * Specifies the horizontal size of the blur.
  42271. */
  42272. set: function (value) {
  42273. this._horizontalBlurPostprocess.kernel = value;
  42274. },
  42275. enumerable: true,
  42276. configurable: true
  42277. });
  42278. Object.defineProperty(HighlightLayer.prototype, "blurVerticalSize", {
  42279. /**
  42280. * Gets the vertical size of the blur.
  42281. */
  42282. get: function () {
  42283. return this._verticalBlurPostprocess.kernel;
  42284. },
  42285. /**
  42286. * Specifies the vertical size of the blur.
  42287. */
  42288. set: function (value) {
  42289. this._verticalBlurPostprocess.kernel = value;
  42290. },
  42291. enumerable: true,
  42292. configurable: true
  42293. });
  42294. /**
  42295. * Get the effect name of the layer.
  42296. * @return The effect name
  42297. */
  42298. HighlightLayer.prototype.getEffectName = function () {
  42299. return HighlightLayer.EffectName;
  42300. };
  42301. /**
  42302. * Create the merge effect. This is the shader use to blit the information back
  42303. * to the main canvas at the end of the scene rendering.
  42304. */
  42305. HighlightLayer.prototype._createMergeEffect = function () {
  42306. // Effect
  42307. return this._engine.createEffect("glowMapMerge", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind], ["offset"], ["textureSampler"], this._options.isStroke ? "#define STROKE \n" : undefined);
  42308. };
  42309. /**
  42310. * Creates the render target textures and post processes used in the highlight layer.
  42311. */
  42312. HighlightLayer.prototype._createTextureAndPostProcesses = function () {
  42313. var _this = this;
  42314. var blurTextureWidth = this._mainTextureDesiredSize.width * this._options.blurTextureSizeRatio;
  42315. var blurTextureHeight = this._mainTextureDesiredSize.height * this._options.blurTextureSizeRatio;
  42316. blurTextureWidth = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureWidth, this._maxSize) : blurTextureWidth;
  42317. blurTextureHeight = this._engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].GetExponentOfTwo(blurTextureHeight, this._maxSize) : blurTextureHeight;
  42318. var textureType = 0;
  42319. if (this._engine.getCaps().textureHalfFloatRender) {
  42320. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_HALF_FLOAT;
  42321. }
  42322. else {
  42323. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  42324. }
  42325. this._blurTexture = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_8__["RenderTargetTexture"]("HighlightLayerBlurRTT", {
  42326. width: blurTextureWidth,
  42327. height: blurTextureHeight
  42328. }, this._scene, false, true, textureType);
  42329. this._blurTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42330. this._blurTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].CLAMP_ADDRESSMODE;
  42331. this._blurTexture.anisotropicFilteringLevel = 16;
  42332. this._blurTexture.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].TRILINEAR_SAMPLINGMODE);
  42333. this._blurTexture.renderParticles = false;
  42334. this._blurTexture.ignoreCameraViewport = true;
  42335. this._textures = [this._blurTexture];
  42336. if (this._options.alphaBlendingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].ALPHA_COMBINE) {
  42337. 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());
  42338. this._downSamplePostprocess.onApplyObservable.add(function (effect) {
  42339. effect.setTexture("textureSampler", _this._mainTexture);
  42340. });
  42341. 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());
  42342. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42343. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42344. });
  42345. 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());
  42346. this._verticalBlurPostprocess.onApplyObservable.add(function (effect) {
  42347. effect.setFloat2("screenSize", blurTextureWidth, blurTextureHeight);
  42348. });
  42349. this._postProcesses = [this._downSamplePostprocess, this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42350. }
  42351. else {
  42352. 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, {
  42353. width: blurTextureWidth,
  42354. height: blurTextureHeight
  42355. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42356. this._horizontalBlurPostprocess.width = blurTextureWidth;
  42357. this._horizontalBlurPostprocess.height = blurTextureHeight;
  42358. this._horizontalBlurPostprocess.onApplyObservable.add(function (effect) {
  42359. effect.setTexture("textureSampler", _this._mainTexture);
  42360. });
  42361. 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, {
  42362. width: blurTextureWidth,
  42363. height: blurTextureHeight
  42364. }, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_7__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, textureType);
  42365. this._postProcesses = [this._horizontalBlurPostprocess, this._verticalBlurPostprocess];
  42366. }
  42367. this._mainTexture.onAfterUnbindObservable.add(function () {
  42368. _this.onBeforeBlurObservable.notifyObservers(_this);
  42369. var internalTexture = _this._blurTexture.getInternalTexture();
  42370. if (internalTexture) {
  42371. _this._scene.postProcessManager.directRender(_this._postProcesses, internalTexture, true);
  42372. }
  42373. _this.onAfterBlurObservable.notifyObservers(_this);
  42374. });
  42375. // Prevent autoClear.
  42376. this._postProcesses.map(function (pp) { pp.autoClear = false; });
  42377. };
  42378. /**
  42379. * Returns wether or nood the layer needs stencil enabled during the mesh rendering.
  42380. */
  42381. HighlightLayer.prototype.needStencil = function () {
  42382. return true;
  42383. };
  42384. /**
  42385. * Checks for the readiness of the element composing the layer.
  42386. * @param subMesh the mesh to check for
  42387. * @param useInstances specify wether or not to use instances to render the mesh
  42388. * @param emissiveTexture the associated emissive texture used to generate the glow
  42389. * @return true if ready otherwise, false
  42390. */
  42391. HighlightLayer.prototype.isReady = function (subMesh, useInstances) {
  42392. var material = subMesh.getMaterial();
  42393. var mesh = subMesh.getRenderingMesh();
  42394. if (!material || !mesh || !this._meshes) {
  42395. return false;
  42396. }
  42397. var emissiveTexture = null;
  42398. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42399. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42400. emissiveTexture = material.emissiveTexture;
  42401. }
  42402. return _super.prototype._isReady.call(this, subMesh, useInstances, emissiveTexture);
  42403. };
  42404. /**
  42405. * Implementation specific of rendering the generating effect on the main canvas.
  42406. * @param effect The effect used to render through
  42407. */
  42408. HighlightLayer.prototype._internalRender = function (effect) {
  42409. // Texture
  42410. effect.setTexture("textureSampler", this._blurTexture);
  42411. // Cache
  42412. var engine = this._engine;
  42413. var previousStencilBuffer = engine.getStencilBuffer();
  42414. var previousStencilFunction = engine.getStencilFunction();
  42415. var previousStencilMask = engine.getStencilMask();
  42416. var previousStencilOperationPass = engine.getStencilOperationPass();
  42417. var previousStencilOperationFail = engine.getStencilOperationFail();
  42418. var previousStencilOperationDepthFail = engine.getStencilOperationDepthFail();
  42419. var previousStencilReference = engine.getStencilFunctionReference();
  42420. // Stencil operations
  42421. engine.setStencilOperationPass(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].REPLACE);
  42422. engine.setStencilOperationFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42423. engine.setStencilOperationDepthFail(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].KEEP);
  42424. // Draw order
  42425. engine.setStencilMask(0x00);
  42426. engine.setStencilBuffer(true);
  42427. engine.setStencilFunctionReference(this._instanceGlowingMeshStencilReference);
  42428. // 2 passes inner outer
  42429. if (this.outerGlow) {
  42430. effect.setFloat("offset", 0);
  42431. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].NOTEQUAL);
  42432. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42433. }
  42434. if (this.innerGlow) {
  42435. effect.setFloat("offset", 1);
  42436. engine.setStencilFunction(_Engines_constants__WEBPACK_IMPORTED_MODULE_14__["Constants"].EQUAL);
  42437. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  42438. }
  42439. // Restore Cache
  42440. engine.setStencilFunction(previousStencilFunction);
  42441. engine.setStencilMask(previousStencilMask);
  42442. engine.setStencilBuffer(previousStencilBuffer);
  42443. engine.setStencilOperationPass(previousStencilOperationPass);
  42444. engine.setStencilOperationFail(previousStencilOperationFail);
  42445. engine.setStencilOperationDepthFail(previousStencilOperationDepthFail);
  42446. engine.setStencilFunctionReference(previousStencilReference);
  42447. };
  42448. /**
  42449. * Returns true if the layer contains information to display, otherwise false.
  42450. */
  42451. HighlightLayer.prototype.shouldRender = function () {
  42452. if (_super.prototype.shouldRender.call(this)) {
  42453. return this._meshes ? true : false;
  42454. }
  42455. return false;
  42456. };
  42457. /**
  42458. * Returns true if the mesh should render, otherwise false.
  42459. * @param mesh The mesh to render
  42460. * @returns true if it should render otherwise false
  42461. */
  42462. HighlightLayer.prototype._shouldRenderMesh = function (mesh) {
  42463. // Excluded Mesh
  42464. if (this._excludedMeshes && this._excludedMeshes[mesh.uniqueId]) {
  42465. return false;
  42466. }
  42467. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42468. return false;
  42469. }
  42470. return true;
  42471. };
  42472. /**
  42473. * Sets the required values for both the emissive texture and and the main color.
  42474. */
  42475. HighlightLayer.prototype._setEmissiveTextureAndColor = function (mesh, subMesh, material) {
  42476. var highlightLayerMesh = this._meshes[mesh.uniqueId];
  42477. if (highlightLayerMesh) {
  42478. this._emissiveTextureAndColor.color.set(highlightLayerMesh.color.r, highlightLayerMesh.color.g, highlightLayerMesh.color.b, 1.0);
  42479. }
  42480. else {
  42481. this._emissiveTextureAndColor.color.set(this.neutralColor.r, this.neutralColor.g, this.neutralColor.b, this.neutralColor.a);
  42482. }
  42483. if (highlightLayerMesh && highlightLayerMesh.glowEmissiveOnly && material) {
  42484. this._emissiveTextureAndColor.texture = material.emissiveTexture;
  42485. this._emissiveTextureAndColor.color.set(1.0, 1.0, 1.0, 1.0);
  42486. }
  42487. else {
  42488. this._emissiveTextureAndColor.texture = null;
  42489. }
  42490. };
  42491. /**
  42492. * Add a mesh in the exclusion list to prevent it to impact or being impacted by the highlight layer.
  42493. * @param mesh The mesh to exclude from the highlight layer
  42494. */
  42495. HighlightLayer.prototype.addExcludedMesh = function (mesh) {
  42496. if (!this._excludedMeshes) {
  42497. return;
  42498. }
  42499. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42500. if (!meshExcluded) {
  42501. this._excludedMeshes[mesh.uniqueId] = {
  42502. mesh: mesh,
  42503. beforeBind: mesh.onBeforeBindObservable.add(function (mesh) {
  42504. mesh.getEngine().setStencilBuffer(false);
  42505. }),
  42506. afterRender: mesh.onAfterRenderObservable.add(function (mesh) {
  42507. mesh.getEngine().setStencilBuffer(true);
  42508. }),
  42509. };
  42510. }
  42511. };
  42512. /**
  42513. * Remove a mesh from the exclusion list to let it impact or being impacted by the highlight layer.
  42514. * @param mesh The mesh to highlight
  42515. */
  42516. HighlightLayer.prototype.removeExcludedMesh = function (mesh) {
  42517. if (!this._excludedMeshes) {
  42518. return;
  42519. }
  42520. var meshExcluded = this._excludedMeshes[mesh.uniqueId];
  42521. if (meshExcluded) {
  42522. if (meshExcluded.beforeBind) {
  42523. mesh.onBeforeBindObservable.remove(meshExcluded.beforeBind);
  42524. }
  42525. if (meshExcluded.afterRender) {
  42526. mesh.onAfterRenderObservable.remove(meshExcluded.afterRender);
  42527. }
  42528. }
  42529. this._excludedMeshes[mesh.uniqueId] = null;
  42530. };
  42531. /**
  42532. * Determine if a given mesh will be highlighted by the current HighlightLayer
  42533. * @param mesh mesh to test
  42534. * @returns true if the mesh will be highlighted by the current HighlightLayer
  42535. */
  42536. HighlightLayer.prototype.hasMesh = function (mesh) {
  42537. if (!this._meshes) {
  42538. return false;
  42539. }
  42540. if (!_super.prototype.hasMesh.call(this, mesh)) {
  42541. return false;
  42542. }
  42543. return this._meshes[mesh.uniqueId] !== undefined && this._meshes[mesh.uniqueId] !== null;
  42544. };
  42545. /**
  42546. * Add a mesh in the highlight layer in order to make it glow with the chosen color.
  42547. * @param mesh The mesh to highlight
  42548. * @param color The color of the highlight
  42549. * @param glowEmissiveOnly Extract the glow from the emissive texture
  42550. */
  42551. HighlightLayer.prototype.addMesh = function (mesh, color, glowEmissiveOnly) {
  42552. var _this = this;
  42553. if (glowEmissiveOnly === void 0) { glowEmissiveOnly = false; }
  42554. if (!this._meshes) {
  42555. return;
  42556. }
  42557. var meshHighlight = this._meshes[mesh.uniqueId];
  42558. if (meshHighlight) {
  42559. meshHighlight.color = color;
  42560. }
  42561. else {
  42562. this._meshes[mesh.uniqueId] = {
  42563. mesh: mesh,
  42564. color: color,
  42565. // Lambda required for capture due to Observable this context
  42566. observerHighlight: mesh.onBeforeBindObservable.add(function (mesh) {
  42567. if (_this._excludedMeshes && _this._excludedMeshes[mesh.uniqueId]) {
  42568. _this._defaultStencilReference(mesh);
  42569. }
  42570. else {
  42571. mesh.getScene().getEngine().setStencilFunctionReference(_this._instanceGlowingMeshStencilReference);
  42572. }
  42573. }),
  42574. observerDefault: mesh.onAfterRenderObservable.add(this._defaultStencilReference),
  42575. glowEmissiveOnly: glowEmissiveOnly
  42576. };
  42577. mesh.onDisposeObservable.add(function () {
  42578. _this._disposeMesh(mesh);
  42579. });
  42580. }
  42581. this._shouldRender = true;
  42582. };
  42583. /**
  42584. * Remove a mesh from the highlight layer in order to make it stop glowing.
  42585. * @param mesh The mesh to highlight
  42586. */
  42587. HighlightLayer.prototype.removeMesh = function (mesh) {
  42588. if (!this._meshes) {
  42589. return;
  42590. }
  42591. var meshHighlight = this._meshes[mesh.uniqueId];
  42592. if (meshHighlight) {
  42593. if (meshHighlight.observerHighlight) {
  42594. mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42595. }
  42596. if (meshHighlight.observerDefault) {
  42597. mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42598. }
  42599. delete this._meshes[mesh.uniqueId];
  42600. }
  42601. this._shouldRender = false;
  42602. for (var meshHighlightToCheck in this._meshes) {
  42603. if (this._meshes[meshHighlightToCheck]) {
  42604. this._shouldRender = true;
  42605. break;
  42606. }
  42607. }
  42608. };
  42609. /**
  42610. * Force the stencil to the normal expected value for none glowing parts
  42611. */
  42612. HighlightLayer.prototype._defaultStencilReference = function (mesh) {
  42613. mesh.getScene().getEngine().setStencilFunctionReference(HighlightLayer.NormalMeshStencilReference);
  42614. };
  42615. /**
  42616. * Free any resources and references associated to a mesh.
  42617. * Internal use
  42618. * @param mesh The mesh to free.
  42619. * @hidden
  42620. */
  42621. HighlightLayer.prototype._disposeMesh = function (mesh) {
  42622. this.removeMesh(mesh);
  42623. this.removeExcludedMesh(mesh);
  42624. };
  42625. /**
  42626. * Dispose the highlight layer and free resources.
  42627. */
  42628. HighlightLayer.prototype.dispose = function () {
  42629. if (this._meshes) {
  42630. // Clean mesh references
  42631. for (var id in this._meshes) {
  42632. var meshHighlight = this._meshes[id];
  42633. if (meshHighlight && meshHighlight.mesh) {
  42634. if (meshHighlight.observerHighlight) {
  42635. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.observerHighlight);
  42636. }
  42637. if (meshHighlight.observerDefault) {
  42638. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.observerDefault);
  42639. }
  42640. }
  42641. }
  42642. this._meshes = null;
  42643. }
  42644. if (this._excludedMeshes) {
  42645. for (var id in this._excludedMeshes) {
  42646. var meshHighlight = this._excludedMeshes[id];
  42647. if (meshHighlight) {
  42648. if (meshHighlight.beforeBind) {
  42649. meshHighlight.mesh.onBeforeBindObservable.remove(meshHighlight.beforeBind);
  42650. }
  42651. if (meshHighlight.afterRender) {
  42652. meshHighlight.mesh.onAfterRenderObservable.remove(meshHighlight.afterRender);
  42653. }
  42654. }
  42655. }
  42656. this._excludedMeshes = null;
  42657. }
  42658. _super.prototype.dispose.call(this);
  42659. };
  42660. /**
  42661. * Gets the class name of the effect layer
  42662. * @returns the string with the class name of the effect layer
  42663. */
  42664. HighlightLayer.prototype.getClassName = function () {
  42665. return "HighlightLayer";
  42666. };
  42667. /**
  42668. * Serializes this Highlight layer
  42669. * @returns a serialized Highlight layer object
  42670. */
  42671. HighlightLayer.prototype.serialize = function () {
  42672. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  42673. serializationObject.customType = "BABYLON.HighlightLayer";
  42674. // Highlighted meshes
  42675. serializationObject.meshes = [];
  42676. if (this._meshes) {
  42677. for (var m in this._meshes) {
  42678. var mesh = this._meshes[m];
  42679. if (mesh) {
  42680. serializationObject.meshes.push({
  42681. glowEmissiveOnly: mesh.glowEmissiveOnly,
  42682. color: mesh.color.asArray(),
  42683. meshId: mesh.mesh.id
  42684. });
  42685. }
  42686. }
  42687. }
  42688. // Excluded meshes
  42689. serializationObject.excludedMeshes = [];
  42690. if (this._excludedMeshes) {
  42691. for (var e in this._excludedMeshes) {
  42692. var excludedMesh = this._excludedMeshes[e];
  42693. if (excludedMesh) {
  42694. serializationObject.excludedMeshes.push(excludedMesh.mesh.id);
  42695. }
  42696. }
  42697. }
  42698. return serializationObject;
  42699. };
  42700. /**
  42701. * Creates a Highlight layer from parsed Highlight layer data
  42702. * @param parsedHightlightLayer defines the Highlight layer data
  42703. * @param scene defines the current scene
  42704. * @param rootUrl defines the root URL containing the Highlight layer information
  42705. * @returns a parsed Highlight layer
  42706. */
  42707. HighlightLayer.Parse = function (parsedHightlightLayer, scene, rootUrl) {
  42708. var hl = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new HighlightLayer(parsedHightlightLayer.name, scene, parsedHightlightLayer.options); }, parsedHightlightLayer, scene, rootUrl);
  42709. var index;
  42710. // Excluded meshes
  42711. for (index = 0; index < parsedHightlightLayer.excludedMeshes.length; index++) {
  42712. var mesh = scene.getMeshByID(parsedHightlightLayer.excludedMeshes[index]);
  42713. if (mesh) {
  42714. hl.addExcludedMesh(mesh);
  42715. }
  42716. }
  42717. // Included meshes
  42718. for (index = 0; index < parsedHightlightLayer.meshes.length; index++) {
  42719. var highlightedMesh = parsedHightlightLayer.meshes[index];
  42720. var mesh = scene.getMeshByID(highlightedMesh.meshId);
  42721. if (mesh) {
  42722. hl.addMesh(mesh, _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].FromArray(highlightedMesh.color), highlightedMesh.glowEmissiveOnly);
  42723. }
  42724. }
  42725. return hl;
  42726. };
  42727. /**
  42728. * Effect Name of the highlight layer.
  42729. */
  42730. HighlightLayer.EffectName = "HighlightLayer";
  42731. /**
  42732. * The neutral color used during the preparation of the glow effect.
  42733. * This is black by default as the blend operation is a blend operation.
  42734. */
  42735. HighlightLayer.NeutralColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  42736. /**
  42737. * Stencil value used for glowing meshes.
  42738. */
  42739. HighlightLayer.GlowingMeshStencilReference = 0x02;
  42740. /**
  42741. * Stencil value used for the other meshes in the scene.
  42742. */
  42743. HighlightLayer.NormalMeshStencilReference = 0x01;
  42744. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42745. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42746. ], HighlightLayer.prototype, "innerGlow", void 0);
  42747. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42748. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42749. ], HighlightLayer.prototype, "outerGlow", void 0);
  42750. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42751. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42752. ], HighlightLayer.prototype, "blurHorizontalSize", null);
  42753. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42754. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  42755. ], HighlightLayer.prototype, "blurVerticalSize", null);
  42756. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  42757. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("options")
  42758. ], HighlightLayer.prototype, "_options", void 0);
  42759. return HighlightLayer;
  42760. }(_effectLayer__WEBPACK_IMPORTED_MODULE_12__["EffectLayer"]));
  42761. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_16__["_TypeStore"].RegisteredTypes["BABYLON.HighlightLayer"] = HighlightLayer;
  42762. /***/ }),
  42763. /***/ "./Layers/index.ts":
  42764. /*!*************************!*\
  42765. !*** ./Layers/index.ts ***!
  42766. \*************************/
  42767. /*! exports provided: EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent */
  42768. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42769. "use strict";
  42770. __webpack_require__.r(__webpack_exports__);
  42771. /* harmony import */ var _effectLayer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./effectLayer */ "./Layers/effectLayer.ts");
  42772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _effectLayer__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  42773. /* harmony import */ var _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./effectLayerSceneComponent */ "./Layers/effectLayerSceneComponent.ts");
  42774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _effectLayerSceneComponent__WEBPACK_IMPORTED_MODULE_1__["EffectLayerSceneComponent"]; });
  42775. /* harmony import */ var _glowLayer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./glowLayer */ "./Layers/glowLayer.ts");
  42776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _glowLayer__WEBPACK_IMPORTED_MODULE_2__["GlowLayer"]; });
  42777. /* harmony import */ var _highlightLayer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./highlightLayer */ "./Layers/highlightLayer.ts");
  42778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _highlightLayer__WEBPACK_IMPORTED_MODULE_3__["HighlightLayer"]; });
  42779. /* harmony import */ var _layer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./layer */ "./Layers/layer.ts");
  42780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _layer__WEBPACK_IMPORTED_MODULE_4__["Layer"]; });
  42781. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _layerSceneComponent__WEBPACK_IMPORTED_MODULE_5__["LayerSceneComponent"]; });
  42783. /***/ }),
  42784. /***/ "./Layers/layer.ts":
  42785. /*!*************************!*\
  42786. !*** ./Layers/layer.ts ***!
  42787. \*************************/
  42788. /*! exports provided: Layer */
  42789. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  42790. "use strict";
  42791. __webpack_require__.r(__webpack_exports__);
  42792. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return Layer; });
  42793. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  42794. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  42795. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  42796. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  42797. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  42798. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  42799. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  42800. /* harmony import */ var _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./layerSceneComponent */ "./Layers/layerSceneComponent.ts");
  42801. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  42802. /* harmony import */ var _Shaders_layer_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/layer.fragment */ "./Shaders/layer.fragment.ts");
  42803. /* harmony import */ var _Shaders_layer_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/layer.vertex */ "./Shaders/layer.vertex.ts");
  42804. /**
  42805. * This represents a full screen 2d layer.
  42806. * This can be useful to display a picture in the background of your scene for instance.
  42807. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42808. */
  42809. var Layer = /** @class */ (function () {
  42810. /**
  42811. * Instantiates a new layer.
  42812. * This represents a full screen 2d layer.
  42813. * This can be useful to display a picture in the background of your scene for instance.
  42814. * @see https://www.babylonjs-playground.com/#08A2BS#1
  42815. * @param name Define the name of the layer in the scene
  42816. * @param imgUrl Define the url of the texture to display in the layer
  42817. * @param scene Define the scene the layer belongs to
  42818. * @param isBackground Defines whether the layer is displayed in front or behind the scene
  42819. * @param color Defines a color for the layer
  42820. */
  42821. function Layer(
  42822. /**
  42823. * Define the name of the layer.
  42824. */
  42825. name, imgUrl, scene, isBackground, color) {
  42826. this.name = name;
  42827. /**
  42828. * Define the scale of the layer in order to zoom in out of the texture.
  42829. */
  42830. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1, 1);
  42831. /**
  42832. * Define an offset for the layer in order to shift the texture.
  42833. */
  42834. this.offset = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0, 0);
  42835. /**
  42836. * Define the alpha blending mode used in the layer in case the texture or color has an alpha.
  42837. */
  42838. this.alphaBlendingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  42839. /**
  42840. * Define a mask to restrict the layer to only some of the scene cameras.
  42841. */
  42842. this.layerMask = 0x0FFFFFFF;
  42843. /**
  42844. * Define the list of render target the layer is visible into.
  42845. */
  42846. this.renderTargetTextures = [];
  42847. /**
  42848. * Define if the layer is only used in renderTarget or if it also
  42849. * renders in the main frame buffer of the canvas.
  42850. */
  42851. this.renderOnlyInRenderTargetTextures = false;
  42852. this._vertexBuffers = {};
  42853. /**
  42854. * An event triggered when the layer is disposed.
  42855. */
  42856. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42857. /**
  42858. * An event triggered before rendering the scene
  42859. */
  42860. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42861. /**
  42862. * An event triggered after rendering the scene
  42863. */
  42864. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  42865. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"](imgUrl, scene, true) : null;
  42866. this.isBackground = isBackground === undefined ? true : isBackground;
  42867. this.color = color === undefined ? new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1, 1, 1, 1) : color;
  42868. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene);
  42869. var layerComponent = this._scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_LAYER);
  42870. if (!layerComponent) {
  42871. layerComponent = new _layerSceneComponent__WEBPACK_IMPORTED_MODULE_7__["LayerSceneComponent"](this._scene);
  42872. this._scene._addComponent(layerComponent);
  42873. }
  42874. this._scene.layers.push(this);
  42875. var engine = this._scene.getEngine();
  42876. // VBO
  42877. var vertices = [];
  42878. vertices.push(1, 1);
  42879. vertices.push(-1, 1);
  42880. vertices.push(-1, -1);
  42881. vertices.push(1, -1);
  42882. var vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"](engine, vertices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, false, false, 2);
  42883. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = vertexBuffer;
  42884. this._createIndexBuffer();
  42885. // Effects
  42886. this._effect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "");
  42887. this._alphaTestEffect = engine.createEffect("layer", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], ["textureMatrix", "color", "scale", "offset"], ["textureSampler"], "#define ALPHATEST");
  42888. }
  42889. Object.defineProperty(Layer.prototype, "onDispose", {
  42890. /**
  42891. * Back compatibility with callback before the onDisposeObservable existed.
  42892. * The set callback will be triggered when the layer has been disposed.
  42893. */
  42894. set: function (callback) {
  42895. if (this._onDisposeObserver) {
  42896. this.onDisposeObservable.remove(this._onDisposeObserver);
  42897. }
  42898. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  42899. },
  42900. enumerable: true,
  42901. configurable: true
  42902. });
  42903. Object.defineProperty(Layer.prototype, "onBeforeRender", {
  42904. /**
  42905. * Back compatibility with callback before the onBeforeRenderObservable existed.
  42906. * The set callback will be triggered just before rendering the layer.
  42907. */
  42908. set: function (callback) {
  42909. if (this._onBeforeRenderObserver) {
  42910. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  42911. }
  42912. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  42913. },
  42914. enumerable: true,
  42915. configurable: true
  42916. });
  42917. Object.defineProperty(Layer.prototype, "onAfterRender", {
  42918. /**
  42919. * Back compatibility with callback before the onAfterRenderObservable existed.
  42920. * The set callback will be triggered just after rendering the layer.
  42921. */
  42922. set: function (callback) {
  42923. if (this._onAfterRenderObserver) {
  42924. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  42925. }
  42926. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  42927. },
  42928. enumerable: true,
  42929. configurable: true
  42930. });
  42931. Layer.prototype._createIndexBuffer = function () {
  42932. var engine = this._scene.getEngine();
  42933. // Indices
  42934. var indices = [];
  42935. indices.push(0);
  42936. indices.push(1);
  42937. indices.push(2);
  42938. indices.push(0);
  42939. indices.push(2);
  42940. indices.push(3);
  42941. this._indexBuffer = engine.createIndexBuffer(indices);
  42942. };
  42943. /** @hidden */
  42944. Layer.prototype._rebuild = function () {
  42945. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42946. if (vb) {
  42947. vb._rebuild();
  42948. }
  42949. this._createIndexBuffer();
  42950. };
  42951. /**
  42952. * Renders the layer in the scene.
  42953. */
  42954. Layer.prototype.render = function () {
  42955. var currentEffect = this.alphaTest ? this._alphaTestEffect : this._effect;
  42956. // Check
  42957. if (!currentEffect.isReady() || !this.texture || !this.texture.isReady()) {
  42958. return;
  42959. }
  42960. var engine = this._scene.getEngine();
  42961. this.onBeforeRenderObservable.notifyObservers(this);
  42962. // Render
  42963. engine.enableEffect(currentEffect);
  42964. engine.setState(false);
  42965. // Texture
  42966. currentEffect.setTexture("textureSampler", this.texture);
  42967. currentEffect.setMatrix("textureMatrix", this.texture.getTextureMatrix());
  42968. // Color
  42969. currentEffect.setFloat4("color", this.color.r, this.color.g, this.color.b, this.color.a);
  42970. // Scale / offset
  42971. currentEffect.setVector2("offset", this.offset);
  42972. currentEffect.setVector2("scale", this.scale);
  42973. // VBOs
  42974. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, currentEffect);
  42975. // Draw order
  42976. if (!this.alphaTest) {
  42977. engine.setAlphaMode(this.alphaBlendingMode);
  42978. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42979. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  42980. }
  42981. else {
  42982. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, 0, 6);
  42983. }
  42984. this.onAfterRenderObservable.notifyObservers(this);
  42985. };
  42986. /**
  42987. * Disposes and releases the associated ressources.
  42988. */
  42989. Layer.prototype.dispose = function () {
  42990. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  42991. if (vertexBuffer) {
  42992. vertexBuffer.dispose();
  42993. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  42994. }
  42995. if (this._indexBuffer) {
  42996. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  42997. this._indexBuffer = null;
  42998. }
  42999. if (this.texture) {
  43000. this.texture.dispose();
  43001. this.texture = null;
  43002. }
  43003. // Clean RTT list
  43004. this.renderTargetTextures = [];
  43005. // Remove from scene
  43006. var index = this._scene.layers.indexOf(this);
  43007. this._scene.layers.splice(index, 1);
  43008. // Callback
  43009. this.onDisposeObservable.notifyObservers(this);
  43010. this.onDisposeObservable.clear();
  43011. this.onAfterRenderObservable.clear();
  43012. this.onBeforeRenderObservable.clear();
  43013. };
  43014. return Layer;
  43015. }());
  43016. /***/ }),
  43017. /***/ "./Layers/layerSceneComponent.ts":
  43018. /*!***************************************!*\
  43019. !*** ./Layers/layerSceneComponent.ts ***!
  43020. \***************************************/
  43021. /*! exports provided: LayerSceneComponent */
  43022. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43023. "use strict";
  43024. __webpack_require__.r(__webpack_exports__);
  43025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return LayerSceneComponent; });
  43026. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  43027. /**
  43028. * Defines the layer scene component responsible to manage any layers
  43029. * in a given scene.
  43030. */
  43031. var LayerSceneComponent = /** @class */ (function () {
  43032. /**
  43033. * Creates a new instance of the component for the given scene
  43034. * @param scene Defines the scene to register the component in
  43035. */
  43036. function LayerSceneComponent(scene) {
  43037. /**
  43038. * The component name helpfull to identify the component in the list of scene components.
  43039. */
  43040. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_LAYER;
  43041. this.scene = scene;
  43042. this._engine = scene.getEngine();
  43043. scene.layers = new Array();
  43044. }
  43045. /**
  43046. * Registers the component in a given scene
  43047. */
  43048. LayerSceneComponent.prototype.register = function () {
  43049. this.scene._beforeCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORECAMERADRAW_LAYER, this, this._drawCameraBackground);
  43050. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LAYER, this, this._drawCameraForeground);
  43051. this.scene._beforeRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_BEFORERENDERTARGETDRAW_LAYER, this, this._drawRenderTargetBackground);
  43052. this.scene._afterRenderTargetDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_AFTERRENDERTARGETDRAW_LAYER, this, this._drawRenderTargetForeground);
  43053. };
  43054. /**
  43055. * Rebuilds the elements related to this component in case of
  43056. * context lost for instance.
  43057. */
  43058. LayerSceneComponent.prototype.rebuild = function () {
  43059. var layers = this.scene.layers;
  43060. for (var _i = 0, layers_1 = layers; _i < layers_1.length; _i++) {
  43061. var layer = layers_1[_i];
  43062. layer._rebuild();
  43063. }
  43064. };
  43065. /**
  43066. * Disposes the component and the associated ressources.
  43067. */
  43068. LayerSceneComponent.prototype.dispose = function () {
  43069. var layers = this.scene.layers;
  43070. while (layers.length) {
  43071. layers[0].dispose();
  43072. }
  43073. };
  43074. LayerSceneComponent.prototype._draw = function (predicate) {
  43075. var layers = this.scene.layers;
  43076. if (layers.length) {
  43077. this._engine.setDepthBuffer(false);
  43078. for (var _i = 0, layers_2 = layers; _i < layers_2.length; _i++) {
  43079. var layer = layers_2[_i];
  43080. if (predicate(layer)) {
  43081. layer.render();
  43082. }
  43083. }
  43084. this._engine.setDepthBuffer(true);
  43085. }
  43086. };
  43087. LayerSceneComponent.prototype._drawCameraPredicate = function (layer, isBackground, cameraLayerMask) {
  43088. return !layer.renderOnlyInRenderTargetTextures &&
  43089. layer.isBackground === isBackground &&
  43090. ((layer.layerMask & cameraLayerMask) !== 0);
  43091. };
  43092. LayerSceneComponent.prototype._drawCameraBackground = function (camera) {
  43093. var _this = this;
  43094. this._draw(function (layer) {
  43095. return _this._drawCameraPredicate(layer, true, camera.layerMask);
  43096. });
  43097. };
  43098. LayerSceneComponent.prototype._drawCameraForeground = function (camera) {
  43099. var _this = this;
  43100. this._draw(function (layer) {
  43101. return _this._drawCameraPredicate(layer, false, camera.layerMask);
  43102. });
  43103. };
  43104. LayerSceneComponent.prototype._drawRenderTargetPredicate = function (layer, isBackground, cameraLayerMask, renderTargetTexture) {
  43105. return (layer.renderTargetTextures.length > 0) &&
  43106. layer.isBackground === isBackground &&
  43107. (layer.renderTargetTextures.indexOf(renderTargetTexture) > -1) &&
  43108. ((layer.layerMask & cameraLayerMask) !== 0);
  43109. };
  43110. LayerSceneComponent.prototype._drawRenderTargetBackground = function (renderTarget) {
  43111. var _this = this;
  43112. this._draw(function (layer) {
  43113. return _this._drawRenderTargetPredicate(layer, true, _this.scene.activeCamera.layerMask, renderTarget);
  43114. });
  43115. };
  43116. LayerSceneComponent.prototype._drawRenderTargetForeground = function (renderTarget) {
  43117. var _this = this;
  43118. this._draw(function (layer) {
  43119. return _this._drawRenderTargetPredicate(layer, false, _this.scene.activeCamera.layerMask, renderTarget);
  43120. });
  43121. };
  43122. return LayerSceneComponent;
  43123. }());
  43124. /***/ }),
  43125. /***/ "./Legacy/legacy.ts":
  43126. /*!**************************!*\
  43127. !*** ./Legacy/legacy.ts ***!
  43128. \**************************/
  43129. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, 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, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  43130. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43131. "use strict";
  43132. __webpack_require__.r(__webpack_exports__);
  43133. /* WEBPACK VAR INJECTION */(function(global) {/* harmony import */ var _index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../index */ "./index.ts");
  43134. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Debug/index */ "./Debug/index.ts");
  43135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  43136. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeepAssets"]; });
  43137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetContainer"]; });
  43138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Node"]; });
  43139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scene"]; });
  43140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"]; });
  43141. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Stage"]; });
  43142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Action"]; });
  43143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionEvent"]; });
  43144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ActionManager"]; });
  43145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Condition"]; });
  43146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ValueCondition"]; });
  43147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PredicateCondition"]; });
  43148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StateCondition"]; });
  43149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SwitchBooleanAction"]; });
  43150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetStateAction"]; });
  43151. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetValueAction"]; });
  43152. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IncrementValueAction"]; });
  43153. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlayAnimationAction"]; });
  43154. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopAnimationAction"]; });
  43155. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DoNothingAction"]; });
  43156. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CombineAction"]; });
  43157. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExecuteCodeAction"]; });
  43158. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SetParentAction"]; });
  43159. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaySoundAction"]; });
  43160. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StopSoundAction"]; });
  43161. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InterpolateValueAction"]; });
  43162. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animatable"]; });
  43163. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Animation"]; });
  43164. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetedAnimation"]; });
  43165. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationGroup"]; });
  43166. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationPropertiesOverride"]; });
  43167. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EasingFunction"]; });
  43168. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleEase"]; });
  43169. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackEase"]; });
  43170. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BounceEase"]; });
  43171. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubicEase"]; });
  43172. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ElasticEase"]; });
  43173. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExponentialEase"]; });
  43174. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PowerEase"]; });
  43175. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuadraticEase"]; });
  43176. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuarticEase"]; });
  43177. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["QuinticEase"]; });
  43178. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SineEase"]; });
  43179. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurveEase"]; });
  43180. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RuntimeAnimation"]; });
  43181. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationEvent"]; });
  43182. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationKeyInterpolation"]; });
  43183. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnimationRange"]; });
  43184. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Analyser"]; });
  43185. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioEngine"]; });
  43186. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AudioSceneComponent"]; });
  43187. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sound"]; });
  43188. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SoundTrack"]; });
  43189. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WeightedSound"]; });
  43190. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Bone"]; });
  43191. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneIKController"]; });
  43192. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneLookController"]; });
  43193. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Skeleton"]; });
  43194. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputTypes"]; });
  43195. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CameraInputsManager"]; });
  43196. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Camera"]; });
  43197. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TargetCamera"]; });
  43198. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCamera"]; });
  43199. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraInputsManager"]; });
  43200. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TouchCamera"]; });
  43201. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCamera"]; });
  43202. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraInputsManager"]; });
  43203. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeviceOrientationCamera"]; });
  43204. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCamera"]; });
  43205. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraInputsManager"]; });
  43206. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FollowCamera"]; });
  43207. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcFollowCamera"]; });
  43208. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadCamera"]; });
  43209. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniversalCamera"]; });
  43210. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoysticksCamera"]; });
  43211. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Collider"]; });
  43212. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultCollisionCoordinator"]; });
  43213. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PickingInfo"]; });
  43214. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IntersectionInfo"]; });
  43215. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBox"]; });
  43216. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingInfo"]; });
  43217. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingSphere"]; });
  43218. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Ray"]; });
  43219. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxesViewer"]; });
  43220. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoneAxesViewer"]; });
  43221. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DebugLayer"]; });
  43222. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsViewer"]; });
  43223. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RayHelper"]; });
  43224. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SkeletonViewer"]; });
  43225. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Constants"]; });
  43226. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancingAttributeInfo"]; });
  43227. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthTextureCreationOptions"]; });
  43228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineCapabilities"]; });
  43229. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Engine"]; });
  43230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineStore"]; });
  43231. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngineOptions"]; });
  43232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NullEngine"]; });
  43233. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardEventTypes"]; });
  43234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfo"]; });
  43235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KeyboardInfoPre"]; });
  43236. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerEventTypes"]; });
  43237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoBase"]; });
  43238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfoPre"]; });
  43239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerInfo"]; });
  43240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardEventTypes"]; });
  43241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ClipboardInfo"]; });
  43242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DaydreamController"]; });
  43243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GearVRController"]; });
  43244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericController"]; });
  43245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OculusTouchController"]; });
  43246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerType"]; });
  43247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledControllerHelper"]; });
  43248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PoseEnabledController"]; });
  43249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ViveController"]; });
  43250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRController"]; });
  43251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WindowsMotionController"]; });
  43252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StickValues"]; });
  43253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gamepad"]; });
  43254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GenericPad"]; });
  43255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadManager"]; });
  43256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GamepadSystemSceneComponent"]; });
  43257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Button"]; });
  43258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Dpad"]; });
  43259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Xbox360Pad"]; });
  43260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisDragGizmo"]; });
  43261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AxisScaleGizmo"]; });
  43262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxGizmo"]; });
  43263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Gizmo"]; });
  43264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GizmoManager"]; });
  43265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneRotationGizmo"]; });
  43266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionGizmo"]; });
  43267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RotationGizmo"]; });
  43268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScaleGizmo"]; });
  43269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LightGizmo"]; });
  43270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentHelper"]; });
  43271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhotoDome"]; });
  43272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceSceneHelpersToBundle"]; });
  43273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoDome"]; });
  43274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EngineInstrumentation"]; });
  43275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneInstrumentation"]; });
  43276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TimeToken"]; });
  43277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayer"]; });
  43278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectLayerSceneComponent"]; });
  43279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GlowLayer"]; });
  43280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightLayer"]; });
  43281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Layer"]; });
  43282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LayerSceneComponent"]; });
  43283. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystem"]; });
  43285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlareSystemSceneComponent"]; });
  43286. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  43287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowLight"]; });
  43288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DirectionalLight"]; });
  43289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericLight"]; });
  43290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointLight"]; });
  43291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpotLight"]; });
  43292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  43293. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderProgressEvent"]; });
  43294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"]; });
  43295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneLoaderFlags"]; });
  43296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCurves"]; });
  43297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectFallbacks"]; });
  43298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EffectCreationOptions"]; });
  43299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Effect"]; });
  43300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FresnelParameters"]; });
  43301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfigurationDefines"]; });
  43302. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingConfiguration"]; });
  43303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Material"]; });
  43304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialDefines"]; });
  43305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialHelper"]; });
  43306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiMaterial"]; });
  43307. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PushMaterial"]; });
  43308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShaderMaterial"]; });
  43309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterialDefines"]; });
  43310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardMaterial"]; });
  43311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  43312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTexture"]; });
  43313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTexture"]; });
  43314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InternalTexture"]; });
  43315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DummyInternalTextureTracker"]; });
  43316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MirrorTexture"]; });
  43317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiRenderTarget"]; });
  43318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture"]; });
  43319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetTexture"]; });
  43320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Texture"]; });
  43321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UniformBuffer"]; });
  43322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MaterialFlags"]; });
  43323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  43324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToGammaSpace"]; });
  43325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]; });
  43326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; });
  43327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3"]; });
  43328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color4"]; });
  43329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector2"]; });
  43330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector3"]; });
  43331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Vector4"]; });
  43332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Size"]; });
  43333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]; });
  43334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Matrix"]; });
  43335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Plane"]; });
  43336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Viewport"]; });
  43337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Frustum"]; });
  43338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Space"]; });
  43339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Axis"]; });
  43340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BezierCurve"]; });
  43341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Orientation"]; });
  43342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Angle"]; });
  43343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Arc2"]; });
  43344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path2"]; });
  43345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Path3D"]; });
  43346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Curve3"]; });
  43347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]; });
  43348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PositionNormalTextureVertex"]; });
  43349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tmp"]; });
  43350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]; });
  43351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphericalHarmonics"]; });
  43352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  43353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Buffer"]; });
  43354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"]; });
  43355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CSG"]; });
  43356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Geometry"]; });
  43357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundMesh"]; });
  43358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TrailMesh"]; });
  43359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedMesh"]; });
  43360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesMesh"]; });
  43361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["InstancedLinesMesh"]; });
  43362. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshLODLevel"]; });
  43363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_CreationDataStorage"]; });
  43364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_InstancesBatch"]; });
  43365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Mesh"]; });
  43366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VertexData"]; });
  43367. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshBuilder"]; });
  43368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationSettings"]; });
  43369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationQueue"]; });
  43370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplificationType"]; });
  43371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SimplicationQueueSceneComponent"]; });
  43372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Polygon"]; });
  43373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonMeshBuilder"]; });
  43374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseSubMesh"]; });
  43375. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubMesh"]; });
  43376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TransformNode"]; });
  43377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  43378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereBuilder"]; });
  43379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderBuilder"]; });
  43380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LinesBuilder"]; });
  43381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PlaneBuilder"]; });
  43382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  43383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MorphTargetManager"]; });
  43384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  43385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  43386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GPUParticleSystem"]; });
  43387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Particle"]; });
  43388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleHelper"]; });
  43389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystem"]; });
  43390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_IDoNeedToBeInTheBuild"]; });
  43391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticleSystemSet"]; });
  43392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticle"]; });
  43393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ModelShape"]; });
  43394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthSortedParticle"]; });
  43395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SolidParticleSystem"]; });
  43396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitterType"]; });
  43397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SubEmitter"]; });
  43398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  43399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngineSceneComponent"]; });
  43400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsHelper"]; });
  43401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialExplosionEvent"]; });
  43402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsGravitationalFieldEvent"]; });
  43403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftEvent"]; });
  43404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsVortexEvent"]; });
  43405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsRadialImpulseFalloff"]; });
  43406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsUpdraftMode"]; });
  43407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"]; });
  43408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PhysicsJoint"]; });
  43409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DistanceJoint"]; });
  43410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotorEnabledJoint"]; });
  43411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HingeJoint"]; });
  43412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Hinge2Joint"]; });
  43413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  43414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlackAndWhitePostProcess"]; });
  43415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomEffect"]; });
  43416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BloomMergePostProcess"]; });
  43417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BlurPostProcess"]; });
  43418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ChromaticAberrationPostProcess"]; });
  43419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CircleOfConfusionPostProcess"]; });
  43420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorCorrectionPostProcess"]; });
  43421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConvolutionPostProcess"]; });
  43422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldBlurPostProcess"]; });
  43423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffectBlurLevel"]; });
  43424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldEffect"]; });
  43425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcessOptions"]; });
  43426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthOfFieldMergePostProcess"]; });
  43427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DisplayPassPostProcess"]; });
  43428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ExtractHighlightsPostProcess"]; });
  43429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilterPostProcess"]; });
  43430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FxaaPostProcess"]; });
  43431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GrainPostProcess"]; });
  43432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HighlightsPostProcess"]; });
  43433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageProcessingPostProcess"]; });
  43434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MotionBlurPostProcess"]; });
  43435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassPostProcess"]; });
  43436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PassCubePostProcess"]; });
  43437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcess"]; });
  43438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessManager"]; });
  43439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionPostProcess"]; });
  43440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SharpenPostProcess"]; });
  43441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicInterlacePostProcess"]; });
  43442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemappingOperator"]; });
  43443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TonemapPostProcess"]; });
  43444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VolumetricLightScatteringPostProcess"]; });
  43445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDistortionCorrectionPostProcess"]; });
  43446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  43447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  43448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRenderer"]; });
  43449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DepthRendererSceneComponent"]; });
  43450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EdgesRenderer"]; });
  43451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LineEdgesRenderer"]; });
  43452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRenderer"]; });
  43453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GeometryBufferRendererSceneComponent"]; });
  43454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OutlineRenderer"]; });
  43455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"]; });
  43456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingGroupInfo"]; });
  43457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderingManager"]; });
  43458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["UtilityLayerRenderer"]; });
  43459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  43460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteManager"]; });
  43461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SpriteSceneComponent"]; });
  43462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  43463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DepthCullingState"]; });
  43464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_StencilState"]; });
  43465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  43466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetTaskState"]; });
  43467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AbstractAssetTask"]; });
  43468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsProgressEvent"]; });
  43469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MeshAssetTask"]; });
  43470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextFileAssetTask"]; });
  43471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BinaryFileAssetTask"]; });
  43472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ImageAssetTask"]; });
  43473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureAssetTask"]; });
  43474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeTextureAssetTask"]; });
  43475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRCubeTextureAssetTask"]; });
  43476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AssetsManager"]; });
  43477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DDSTools"]; });
  43478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["expandToProperty"]; });
  43479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serialize"]; });
  43480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsTexture"]; });
  43481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor3"]; });
  43482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsFresnelParameters"]; });
  43483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector2"]; });
  43484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsVector3"]; });
  43485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsMeshReference"]; });
  43486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColorCurves"]; });
  43487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsColor4"]; });
  43488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsImageProcessingConfiguration"]; });
  43489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsQuaternion"]; });
  43490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["serializeAsCameraReference"]; });
  43491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SerializationHelper"]; });
  43492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Deferred"]; });
  43493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"]; });
  43494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInput"]; });
  43495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"]; });
  43496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["EventState"]; });
  43497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observer"]; });
  43498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiObserver"]; });
  43499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Observable"]; });
  43500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerformanceMonitor"]; });
  43501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RollingAverage"]; });
  43502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PromisePolyfill"]; });
  43503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimization"]; });
  43504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureOptimization"]; });
  43505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HardwareScalingOptimization"]; });
  43506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowsOptimization"]; });
  43507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessesOptimization"]; });
  43508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensFlaresOptimization"]; });
  43509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomOptimization"]; });
  43510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ParticlesOptimization"]; });
  43511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RenderTargetsOptimization"]; });
  43512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MergeMeshesOptimization"]; });
  43513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizerOptions"]; });
  43514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneOptimizer"]; });
  43515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SceneSerializer"]; });
  43516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArray"]; });
  43517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SmartArrayNoDuplicate"]; });
  43518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StringDictionary"]; });
  43519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tags"]; });
  43520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TextureTools"]; });
  43521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TGATools"]; });
  43522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradient"]; });
  43523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Color3Gradient"]; });
  43524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FactorGradient"]; });
  43525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LoadFileError"]; });
  43526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RetryStrategy"]; });
  43527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Tools"]; });
  43528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PerfCounter"]; });
  43529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["className"]; });
  43530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AsyncLoop"]; });
  43531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoRecorder"]; });
  43532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["JoystickAxis"]; });
  43533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VirtualJoystick"]; });
  43534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WorkerPool"]; });
  43535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Logger"]; });
  43536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TypeStore"]; });
  43537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FilesInputStore"]; });
  43538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"]; });
  43539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PivotTools"]; });
  43540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"]; });
  43541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ScreenshotTools"]; });
  43542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AutoRotationBehavior"]; });
  43543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BouncingBehavior"]; });
  43544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FramingBehavior"]; });
  43545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AttachToBoxBehavior"]; });
  43546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FadeInOutBehavior"]; });
  43547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["MultiPointerScaleBehavior"]; });
  43548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointerDragBehavior"]; });
  43549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SixDofDragBehavior"]; });
  43550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraGamepadInput"]; });
  43551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraKeyboardMoveInput"]; });
  43552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraMouseWheelInput"]; });
  43553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraPointersInput"]; });
  43554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ArcRotateCameraVRDeviceOrientationInput"]; });
  43555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraKeyboardInput"]; });
  43556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FlyCameraMouseInput"]; });
  43557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraDeviceOrientationInput"]; });
  43558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraGamepadInput"]; });
  43559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraKeyboardMoveInput"]; });
  43560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraMouseInput"]; });
  43561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraTouchInput"]; });
  43562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["FreeCameraVirtualJoystickInput"]; });
  43563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphArcRotateCamera"]; });
  43564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphFreeCamera"]; });
  43565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphGamepadCamera"]; });
  43566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AnaglyphUniversalCamera"]; });
  43567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicArcRotateCamera"]; });
  43568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicFreeCamera"]; });
  43569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicGamepadCamera"]; });
  43570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StereoscopicUniversalCamera"]; });
  43571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRCameraMetrics"]; });
  43572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationArcRotateCamera"]; });
  43573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationFreeCamera"]; });
  43574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRDeviceOrientationGamepadCamera"]; });
  43575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VRExperienceHelper"]; });
  43576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebVRFreeCamera"]; });
  43577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRCamera"]; });
  43578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIButton"]; });
  43579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUIOptions"]; });
  43580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXREnterExitUI"]; });
  43581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRState"]; });
  43582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRExperienceHelper"]; });
  43583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRController"]; });
  43584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRInput"]; });
  43585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRManagedOutputCanvas"]; });
  43586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["WebXRSessionManager"]; });
  43587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["Octree"]; });
  43588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeBlock"]; });
  43589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OctreeSceneComponent"]; });
  43590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_OcclusionDataStorage"]; });
  43591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_forceTransformFeedbackToBundle"]; });
  43592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  43593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShadowGeneratorSceneComponent"]; });
  43594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  43595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  43596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  43597. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRBaseSimpleMaterial"]; });
  43598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMaterial"]; });
  43599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRMetallicRoughnessMaterial"]; });
  43600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PBRSpecularGlossinessMaterial"]; });
  43601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ColorGradingTexture"]; });
  43602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DynamicTexture"]; });
  43603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTexture"]; });
  43604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawCubeTexture"]; });
  43605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RawTexture3D"]; });
  43606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RefractionTexture"]; });
  43607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["VideoTexture"]; });
  43608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  43609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DiscBuilder"]; });
  43610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"]; });
  43611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusBuilder"]; });
  43612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TorusKnotBuilder"]; });
  43613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolygonBuilder"]; });
  43614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ShapeBuilder"]; });
  43615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LatheBuilder"]; });
  43616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["GroundBuilder"]; });
  43617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["TubeBuilder"]; });
  43618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PolyhedronBuilder"]; });
  43619. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["IcoSphereBuilder"]; });
  43620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DecalBuilder"]; });
  43621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  43622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ConeParticleEmitter"]; });
  43623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderParticleEmitter"]; });
  43624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CylinderDirectedParticleEmitter"]; });
  43625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HemisphericParticleEmitter"]; });
  43626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PointParticleEmitter"]; });
  43627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereParticleEmitter"]; });
  43628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SphereDirectedParticleEmitter"]; });
  43629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  43630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["AmmoJSPlugin"]; });
  43631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["OimoJSPlugin"]; });
  43632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderEffect"]; });
  43633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipeline"]; });
  43634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManager"]; });
  43635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PostProcessRenderPipelineManagerSceneComponent"]; });
  43636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  43637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["HDRTools"]; });
  43638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"]; });
  43639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  43640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_ENVTextureLoader"]; });
  43641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_KTXTextureLoader"]; });
  43642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["_TGATextureLoader"]; });
  43643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  43644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["NoiseProceduralTexture"]; });
  43645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["ProceduralTextureSceneComponent"]; });
  43646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  43647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  43648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  43649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  43650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  43651. /**
  43652. * Legacy support, defining window.BABYLON (global variable).
  43653. *
  43654. * This is the entry point for the UMD module.
  43655. * The entry point for a future ESM package should be index.ts
  43656. */
  43657. var globalObject = (typeof global !== 'undefined') ? global : ((typeof window !== 'undefined') ? window : undefined);
  43658. if (typeof globalObject !== "undefined") {
  43659. globalObject.BABYLON = BABYLON;
  43660. globalObject.BABYLON = globalObject.BABYLON || {};
  43661. var BABYLON = globalObject.BABYLON;
  43662. BABYLON.Debug = BABYLON.Debug || {};
  43663. var keys = [];
  43664. for (var key in _Debug_index__WEBPACK_IMPORTED_MODULE_1__) {
  43665. BABYLON.Debug[key] = _Debug_index__WEBPACK_IMPORTED_MODULE_1__[key];
  43666. keys.push(key);
  43667. }
  43668. for (var key in _index__WEBPACK_IMPORTED_MODULE_0__) {
  43669. // Prevent Reassignment.
  43670. // if (keys.indexOf(key) > -1) {
  43671. // continue;
  43672. // }
  43673. BABYLON[key] = _index__WEBPACK_IMPORTED_MODULE_0__[key];
  43674. }
  43675. }
  43676. /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! ./../../node_modules/webpack/buildin/global.js */ "../node_modules/webpack/buildin/global.js")))
  43677. /***/ }),
  43678. /***/ "./LensFlares/index.ts":
  43679. /*!*****************************!*\
  43680. !*** ./LensFlares/index.ts ***!
  43681. \*****************************/
  43682. /*! exports provided: LensFlare, LensFlareSystem, LensFlareSystemSceneComponent */
  43683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43684. "use strict";
  43685. __webpack_require__.r(__webpack_exports__);
  43686. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _lensFlare__WEBPACK_IMPORTED_MODULE_0__["LensFlare"]; });
  43688. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  43689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _lensFlareSystem__WEBPACK_IMPORTED_MODULE_1__["LensFlareSystem"]; });
  43690. /* harmony import */ var _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./lensFlareSystemSceneComponent */ "./LensFlares/lensFlareSystemSceneComponent.ts");
  43691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _lensFlareSystemSceneComponent__WEBPACK_IMPORTED_MODULE_2__["LensFlareSystemSceneComponent"]; });
  43692. /***/ }),
  43693. /***/ "./LensFlares/lensFlare.ts":
  43694. /*!*********************************!*\
  43695. !*** ./LensFlares/lensFlare.ts ***!
  43696. \*********************************/
  43697. /*! exports provided: LensFlare */
  43698. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43699. "use strict";
  43700. __webpack_require__.r(__webpack_exports__);
  43701. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return LensFlare; });
  43702. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43703. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  43704. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43705. /**
  43706. * This represents one of the lens effect in a `lensFlareSystem`.
  43707. * It controls one of the indiviual texture used in the effect.
  43708. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43709. */
  43710. var LensFlare = /** @class */ (function () {
  43711. /**
  43712. * Instantiates a new Lens Flare.
  43713. * This represents one of the lens effect in a `lensFlareSystem`.
  43714. * It controls one of the indiviual texture used in the effect.
  43715. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43716. * @param size Define the size of the lens flare in the system (a floating value between 0 and 1)
  43717. * @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.
  43718. * @param color Define the lens color
  43719. * @param imgUrl Define the lens texture url
  43720. * @param system Define the `lensFlareSystem` this flare is part of
  43721. */
  43722. function LensFlare(
  43723. /**
  43724. * Define the size of the lens flare in the system (a floating value between 0 and 1)
  43725. */
  43726. size,
  43727. /**
  43728. * 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.
  43729. */
  43730. position, color, imgUrl, system) {
  43731. this.size = size;
  43732. this.position = position;
  43733. /**
  43734. * Define the alpha mode to render this particular lens.
  43735. */
  43736. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_ONEONE;
  43737. this.color = color || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](1, 1, 1);
  43738. this.texture = imgUrl ? new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](imgUrl, system.getScene(), true) : null;
  43739. this._system = system;
  43740. system.lensFlares.push(this);
  43741. }
  43742. /**
  43743. * Creates a new Lens Flare.
  43744. * This represents one of the lens effect in a `lensFlareSystem`.
  43745. * It controls one of the indiviual texture used in the effect.
  43746. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43747. * @param size Define the size of the lens flare (a floating value between 0 and 1)
  43748. * @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.
  43749. * @param color Define the lens color
  43750. * @param imgUrl Define the lens texture url
  43751. * @param system Define the `lensFlareSystem` this flare is part of
  43752. * @returns The newly created Lens Flare
  43753. */
  43754. LensFlare.AddFlare = function (size, position, color, imgUrl, system) {
  43755. return new LensFlare(size, position, color, imgUrl, system);
  43756. };
  43757. /**
  43758. * Dispose and release the lens flare with its associated resources.
  43759. */
  43760. LensFlare.prototype.dispose = function () {
  43761. if (this.texture) {
  43762. this.texture.dispose();
  43763. }
  43764. // Remove from scene
  43765. var index = this._system.lensFlares.indexOf(this);
  43766. this._system.lensFlares.splice(index, 1);
  43767. };
  43768. return LensFlare;
  43769. }());
  43770. /***/ }),
  43771. /***/ "./LensFlares/lensFlareSystem.ts":
  43772. /*!***************************************!*\
  43773. !*** ./LensFlares/lensFlareSystem.ts ***!
  43774. \***************************************/
  43775. /*! exports provided: LensFlareSystem */
  43776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  43777. "use strict";
  43778. __webpack_require__.r(__webpack_exports__);
  43779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return LensFlareSystem; });
  43780. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  43781. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  43782. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  43783. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  43784. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  43785. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  43786. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  43787. /* harmony import */ var _lensFlare__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./lensFlare */ "./LensFlares/lensFlare.ts");
  43788. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  43789. /* harmony import */ var _Shaders_lensFlare_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/lensFlare.fragment */ "./Shaders/lensFlare.fragment.ts");
  43790. /* harmony import */ var _Shaders_lensFlare_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/lensFlare.vertex */ "./Shaders/lensFlare.vertex.ts");
  43791. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  43792. /**
  43793. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43794. * It is usually composed of several `lensFlare`.
  43795. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43796. */
  43797. var LensFlareSystem = /** @class */ (function () {
  43798. /**
  43799. * Instantiates a lens flare system.
  43800. * This represents a Lens Flare System or the shiny effect created by the light reflection on the camera lenses.
  43801. * It is usually composed of several `lensFlare`.
  43802. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  43803. * @param name Define the name of the lens flare system in the scene
  43804. * @param emitter Define the source (the emitter) of the lens flares (it can be a camera, a light or a mesh).
  43805. * @param scene Define the scene the lens flare system belongs to
  43806. */
  43807. function LensFlareSystem(
  43808. /**
  43809. * Define the name of the lens flare system
  43810. */
  43811. name, emitter, scene) {
  43812. this.name = name;
  43813. /**
  43814. * List of lens flares used in this system.
  43815. */
  43816. this.lensFlares = new Array();
  43817. /**
  43818. * Define a limit from the border the lens flare can be visible.
  43819. */
  43820. this.borderLimit = 300;
  43821. /**
  43822. * Define a viewport border we do not want to see the lens flare in.
  43823. */
  43824. this.viewportBorder = 0;
  43825. /**
  43826. * Restricts the rendering of the effect to only the camera rendering this layer mask.
  43827. */
  43828. this.layerMask = 0x0FFFFFFF;
  43829. this._vertexBuffers = {};
  43830. this._isEnabled = true;
  43831. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  43832. LensFlareSystem._SceneComponentInitialization(this._scene);
  43833. this._emitter = emitter;
  43834. this.id = name;
  43835. scene.lensFlareSystems.push(this);
  43836. this.meshesSelectionPredicate = function (m) { return (scene.activeCamera && m.material && m.isVisible && m.isEnabled() && m.isBlocker && ((m.layerMask & scene.activeCamera.layerMask) != 0)); };
  43837. var engine = scene.getEngine();
  43838. // VBO
  43839. var vertices = [];
  43840. vertices.push(1, 1);
  43841. vertices.push(-1, 1);
  43842. vertices.push(-1, -1);
  43843. vertices.push(1, -1);
  43844. 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);
  43845. // Indices
  43846. var indices = [];
  43847. indices.push(0);
  43848. indices.push(1);
  43849. indices.push(2);
  43850. indices.push(0);
  43851. indices.push(2);
  43852. indices.push(3);
  43853. this._indexBuffer = engine.createIndexBuffer(indices);
  43854. // Effects
  43855. this._effect = engine.createEffect("lensFlare", [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind], ["color", "viewportMatrix"], ["textureSampler"], "");
  43856. }
  43857. Object.defineProperty(LensFlareSystem.prototype, "isEnabled", {
  43858. /**
  43859. * Define if the lens flare system is enabled.
  43860. */
  43861. get: function () {
  43862. return this._isEnabled;
  43863. },
  43864. set: function (value) {
  43865. this._isEnabled = value;
  43866. },
  43867. enumerable: true,
  43868. configurable: true
  43869. });
  43870. /**
  43871. * Get the scene the effects belongs to.
  43872. * @returns the scene holding the lens flare system
  43873. */
  43874. LensFlareSystem.prototype.getScene = function () {
  43875. return this._scene;
  43876. };
  43877. /**
  43878. * Get the emitter of the lens flare system.
  43879. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43880. * @returns the emitter of the lens flare system
  43881. */
  43882. LensFlareSystem.prototype.getEmitter = function () {
  43883. return this._emitter;
  43884. };
  43885. /**
  43886. * Set the emitter of the lens flare system.
  43887. * It defines the source of the lens flares (it can be a camera, a light or a mesh).
  43888. * @param newEmitter Define the new emitter of the system
  43889. */
  43890. LensFlareSystem.prototype.setEmitter = function (newEmitter) {
  43891. this._emitter = newEmitter;
  43892. };
  43893. /**
  43894. * Get the lens flare system emitter position.
  43895. * The emitter defines the source of the lens flares (it can be a camera, a light or a mesh).
  43896. * @returns the position
  43897. */
  43898. LensFlareSystem.prototype.getEmitterPosition = function () {
  43899. return this._emitter.getAbsolutePosition ? this._emitter.getAbsolutePosition() : this._emitter.position;
  43900. };
  43901. /**
  43902. * @hidden
  43903. */
  43904. LensFlareSystem.prototype.computeEffectivePosition = function (globalViewport) {
  43905. var position = this.getEmitterPosition();
  43906. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Project(position, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity(), this._scene.getTransformMatrix(), globalViewport);
  43907. this._positionX = position.x;
  43908. this._positionY = position.y;
  43909. position = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(this.getEmitterPosition(), this._scene.getViewMatrix());
  43910. if (this.viewportBorder > 0) {
  43911. globalViewport.x -= this.viewportBorder;
  43912. globalViewport.y -= this.viewportBorder;
  43913. globalViewport.width += this.viewportBorder * 2;
  43914. globalViewport.height += this.viewportBorder * 2;
  43915. position.x += this.viewportBorder;
  43916. position.y += this.viewportBorder;
  43917. this._positionX += this.viewportBorder;
  43918. this._positionY += this.viewportBorder;
  43919. }
  43920. if (position.z > 0) {
  43921. if ((this._positionX > globalViewport.x) && (this._positionX < globalViewport.x + globalViewport.width)) {
  43922. if ((this._positionY > globalViewport.y) && (this._positionY < globalViewport.y + globalViewport.height)) {
  43923. return true;
  43924. }
  43925. }
  43926. return true;
  43927. }
  43928. return false;
  43929. };
  43930. /** @hidden */
  43931. LensFlareSystem.prototype._isVisible = function () {
  43932. if (!this._isEnabled || !this._scene.activeCamera) {
  43933. return false;
  43934. }
  43935. var emitterPosition = this.getEmitterPosition();
  43936. var direction = emitterPosition.subtract(this._scene.activeCamera.globalPosition);
  43937. var distance = direction.length();
  43938. direction.normalize();
  43939. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_5__["Ray"](this._scene.activeCamera.globalPosition, direction);
  43940. var pickInfo = this._scene.pickWithRay(ray, this.meshesSelectionPredicate, true);
  43941. return !pickInfo || !pickInfo.hit || pickInfo.distance > distance;
  43942. };
  43943. /**
  43944. * @hidden
  43945. */
  43946. LensFlareSystem.prototype.render = function () {
  43947. if (!this._effect.isReady() || !this._scene.activeCamera) {
  43948. return false;
  43949. }
  43950. var engine = this._scene.getEngine();
  43951. var viewport = this._scene.activeCamera.viewport;
  43952. var globalViewport = viewport.toGlobal(engine.getRenderWidth(true), engine.getRenderHeight(true));
  43953. // Position
  43954. if (!this.computeEffectivePosition(globalViewport)) {
  43955. return false;
  43956. }
  43957. // Visibility
  43958. if (!this._isVisible()) {
  43959. return false;
  43960. }
  43961. // Intensity
  43962. var awayX;
  43963. var awayY;
  43964. if (this._positionX < this.borderLimit + globalViewport.x) {
  43965. awayX = this.borderLimit + globalViewport.x - this._positionX;
  43966. }
  43967. else if (this._positionX > globalViewport.x + globalViewport.width - this.borderLimit) {
  43968. awayX = this._positionX - globalViewport.x - globalViewport.width + this.borderLimit;
  43969. }
  43970. else {
  43971. awayX = 0;
  43972. }
  43973. if (this._positionY < this.borderLimit + globalViewport.y) {
  43974. awayY = this.borderLimit + globalViewport.y - this._positionY;
  43975. }
  43976. else if (this._positionY > globalViewport.y + globalViewport.height - this.borderLimit) {
  43977. awayY = this._positionY - globalViewport.y - globalViewport.height + this.borderLimit;
  43978. }
  43979. else {
  43980. awayY = 0;
  43981. }
  43982. var away = (awayX > awayY) ? awayX : awayY;
  43983. away -= this.viewportBorder;
  43984. if (away > this.borderLimit) {
  43985. away = this.borderLimit;
  43986. }
  43987. var intensity = 1.0 - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Clamp(away / this.borderLimit, 0, 1);
  43988. if (intensity < 0) {
  43989. return false;
  43990. }
  43991. if (intensity > 1.0) {
  43992. intensity = 1.0;
  43993. }
  43994. if (this.viewportBorder > 0) {
  43995. globalViewport.x += this.viewportBorder;
  43996. globalViewport.y += this.viewportBorder;
  43997. globalViewport.width -= this.viewportBorder * 2;
  43998. globalViewport.height -= this.viewportBorder * 2;
  43999. this._positionX -= this.viewportBorder;
  44000. this._positionY -= this.viewportBorder;
  44001. }
  44002. // Position
  44003. var centerX = globalViewport.x + globalViewport.width / 2;
  44004. var centerY = globalViewport.y + globalViewport.height / 2;
  44005. var distX = centerX - this._positionX;
  44006. var distY = centerY - this._positionY;
  44007. // Effects
  44008. engine.enableEffect(this._effect);
  44009. engine.setState(false);
  44010. engine.setDepthBuffer(false);
  44011. // VBOs
  44012. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  44013. // Flares
  44014. for (var index = 0; index < this.lensFlares.length; index++) {
  44015. var flare = this.lensFlares[index];
  44016. engine.setAlphaMode(flare.alphaMode);
  44017. var x = centerX - (distX * flare.position);
  44018. var y = centerY - (distY * flare.position);
  44019. var cw = flare.size;
  44020. var ch = flare.size * engine.getAspectRatio(this._scene.activeCamera, true);
  44021. var cx = 2 * (x / (globalViewport.width + globalViewport.x * 2)) - 1.0;
  44022. var cy = 1.0 - 2 * (y / (globalViewport.height + globalViewport.y * 2));
  44023. 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);
  44024. this._effect.setMatrix("viewportMatrix", viewportMatrix);
  44025. // Texture
  44026. this._effect.setTexture("textureSampler", flare.texture);
  44027. // Color
  44028. this._effect.setFloat4("color", flare.color.r * intensity, flare.color.g * intensity, flare.color.b * intensity, 1.0);
  44029. // Draw order
  44030. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].TriangleFillMode, 0, 6);
  44031. }
  44032. engine.setDepthBuffer(true);
  44033. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  44034. return true;
  44035. };
  44036. /**
  44037. * Dispose and release the lens flare with its associated resources.
  44038. */
  44039. LensFlareSystem.prototype.dispose = function () {
  44040. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  44041. if (vertexBuffer) {
  44042. vertexBuffer.dispose();
  44043. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind] = null;
  44044. }
  44045. if (this._indexBuffer) {
  44046. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  44047. this._indexBuffer = null;
  44048. }
  44049. while (this.lensFlares.length) {
  44050. this.lensFlares[0].dispose();
  44051. }
  44052. // Remove from scene
  44053. var index = this._scene.lensFlareSystems.indexOf(this);
  44054. this._scene.lensFlareSystems.splice(index, 1);
  44055. };
  44056. /**
  44057. * Parse a lens flare system from a JSON repressentation
  44058. * @param parsedLensFlareSystem Define the JSON to parse
  44059. * @param scene Define the scene the parsed system should be instantiated in
  44060. * @param rootUrl Define the rootUrl of the load sequence to easily find a load relative dependencies such as textures
  44061. * @returns the parsed system
  44062. */
  44063. LensFlareSystem.Parse = function (parsedLensFlareSystem, scene, rootUrl) {
  44064. var emitter = scene.getLastEntryByID(parsedLensFlareSystem.emitterId);
  44065. var name = parsedLensFlareSystem.name || "lensFlareSystem#" + parsedLensFlareSystem.emitterId;
  44066. var lensFlareSystem = new LensFlareSystem(name, emitter, scene);
  44067. lensFlareSystem.id = parsedLensFlareSystem.id || name;
  44068. lensFlareSystem.borderLimit = parsedLensFlareSystem.borderLimit;
  44069. for (var index = 0; index < parsedLensFlareSystem.flares.length; index++) {
  44070. var parsedFlare = parsedLensFlareSystem.flares[index];
  44071. _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);
  44072. }
  44073. return lensFlareSystem;
  44074. };
  44075. /**
  44076. * Serialize the current Lens Flare System into a JSON representation.
  44077. * @returns the serialized JSON
  44078. */
  44079. LensFlareSystem.prototype.serialize = function () {
  44080. var serializationObject = {};
  44081. serializationObject.id = this.id;
  44082. serializationObject.name = this.name;
  44083. serializationObject.emitterId = this.getEmitter().id;
  44084. serializationObject.borderLimit = this.borderLimit;
  44085. serializationObject.flares = [];
  44086. for (var index = 0; index < this.lensFlares.length; index++) {
  44087. var flare = this.lensFlares[index];
  44088. serializationObject.flares.push({
  44089. size: flare.size,
  44090. position: flare.position,
  44091. color: flare.color.asArray(),
  44092. textureName: _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(flare.texture ? flare.texture.name : "")
  44093. });
  44094. }
  44095. return serializationObject;
  44096. };
  44097. /** @hidden */
  44098. LensFlareSystem._SceneComponentInitialization = function (_) {
  44099. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("LensFlareSystemSceneComponent");
  44100. };
  44101. return LensFlareSystem;
  44102. }());
  44103. /***/ }),
  44104. /***/ "./LensFlares/lensFlareSystemSceneComponent.ts":
  44105. /*!*****************************************************!*\
  44106. !*** ./LensFlares/lensFlareSystemSceneComponent.ts ***!
  44107. \*****************************************************/
  44108. /*! exports provided: LensFlareSystemSceneComponent */
  44109. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44110. "use strict";
  44111. __webpack_require__.r(__webpack_exports__);
  44112. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return LensFlareSystemSceneComponent; });
  44113. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  44114. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  44115. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  44116. /* harmony import */ var _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./lensFlareSystem */ "./LensFlares/lensFlareSystem.ts");
  44117. // Adds the parser to the scene parsers.
  44118. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM, function (parsedData, scene, container, rootUrl) {
  44119. // Lens flares
  44120. if (parsedData.lensFlareSystems !== undefined && parsedData.lensFlareSystems !== null) {
  44121. if (!container.lensFlareSystems) {
  44122. container.lensFlareSystems = new Array();
  44123. }
  44124. for (var index = 0, cache = parsedData.lensFlareSystems.length; index < cache; index++) {
  44125. var parsedLensFlareSystem = parsedData.lensFlareSystems[index];
  44126. var lf = _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"].Parse(parsedLensFlareSystem, scene, rootUrl);
  44127. container.lensFlareSystems.push(lf);
  44128. }
  44129. }
  44130. });
  44131. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByName = function (name) {
  44132. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44133. if (this.lensFlareSystems[index].name === name) {
  44134. return this.lensFlareSystems[index];
  44135. }
  44136. }
  44137. return null;
  44138. };
  44139. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.getLensFlareSystemByID = function (id) {
  44140. for (var index = 0; index < this.lensFlareSystems.length; index++) {
  44141. if (this.lensFlareSystems[index].id === id) {
  44142. return this.lensFlareSystems[index];
  44143. }
  44144. }
  44145. return null;
  44146. };
  44147. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.removeLensFlareSystem = function (toRemove) {
  44148. var index = this.lensFlareSystems.indexOf(toRemove);
  44149. if (index !== -1) {
  44150. this.lensFlareSystems.splice(index, 1);
  44151. }
  44152. return index;
  44153. };
  44154. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].prototype.addLensFlareSystem = function (newLensFlareSystem) {
  44155. this.lensFlareSystems.push(newLensFlareSystem);
  44156. };
  44157. /**
  44158. * Defines the lens flare scene component responsible to manage any lens flares
  44159. * in a given scene.
  44160. */
  44161. var LensFlareSystemSceneComponent = /** @class */ (function () {
  44162. /**
  44163. * Creates a new instance of the component for the given scene
  44164. * @param scene Defines the scene to register the component in
  44165. */
  44166. function LensFlareSystemSceneComponent(scene) {
  44167. /**
  44168. * The component name helpfull to identify the component in the list of scene components.
  44169. */
  44170. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM;
  44171. this.scene = scene;
  44172. scene.lensFlareSystems = new Array();
  44173. }
  44174. /**
  44175. * Registers the component in a given scene
  44176. */
  44177. LensFlareSystemSceneComponent.prototype.register = function () {
  44178. this.scene._afterCameraDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_AFTERCAMERADRAW_LENSFLARESYSTEM, this, this._draw);
  44179. };
  44180. /**
  44181. * Rebuilds the elements related to this component in case of
  44182. * context lost for instance.
  44183. */
  44184. LensFlareSystemSceneComponent.prototype.rebuild = function () {
  44185. // Nothing to do for lens flare
  44186. };
  44187. /**
  44188. * Adds all the element from the container to the scene
  44189. * @param container the container holding the elements
  44190. */
  44191. LensFlareSystemSceneComponent.prototype.addFromContainer = function (container) {
  44192. var _this = this;
  44193. if (!container.lensFlareSystems) {
  44194. return;
  44195. }
  44196. container.lensFlareSystems.forEach(function (o) {
  44197. _this.scene.addLensFlareSystem(o);
  44198. });
  44199. };
  44200. /**
  44201. * Removes all the elements in the container from the scene
  44202. * @param container contains the elements to remove
  44203. */
  44204. LensFlareSystemSceneComponent.prototype.removeFromContainer = function (container) {
  44205. var _this = this;
  44206. if (!container.lensFlareSystems) {
  44207. return;
  44208. }
  44209. container.lensFlareSystems.forEach(function (o) {
  44210. _this.scene.removeLensFlareSystem(o);
  44211. });
  44212. };
  44213. /**
  44214. * Serializes the component data to the specified json object
  44215. * @param serializationObject The object to serialize to
  44216. */
  44217. LensFlareSystemSceneComponent.prototype.serialize = function (serializationObject) {
  44218. // Lens flares
  44219. serializationObject.lensFlareSystems = [];
  44220. var lensFlareSystems = this.scene.lensFlareSystems;
  44221. for (var _i = 0, lensFlareSystems_1 = lensFlareSystems; _i < lensFlareSystems_1.length; _i++) {
  44222. var lensFlareSystem = lensFlareSystems_1[_i];
  44223. serializationObject.lensFlareSystems.push(lensFlareSystem.serialize());
  44224. }
  44225. };
  44226. /**
  44227. * Disposes the component and the associated ressources.
  44228. */
  44229. LensFlareSystemSceneComponent.prototype.dispose = function () {
  44230. var lensFlareSystems = this.scene.lensFlareSystems;
  44231. while (lensFlareSystems.length) {
  44232. lensFlareSystems[0].dispose();
  44233. }
  44234. };
  44235. LensFlareSystemSceneComponent.prototype._draw = function (camera) {
  44236. // Lens flares
  44237. if (this.scene.lensFlaresEnabled) {
  44238. var lensFlareSystems = this.scene.lensFlareSystems;
  44239. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44240. for (var _i = 0, lensFlareSystems_2 = lensFlareSystems; _i < lensFlareSystems_2.length; _i++) {
  44241. var lensFlareSystem = lensFlareSystems_2[_i];
  44242. if ((camera.layerMask & lensFlareSystem.layerMask) !== 0) {
  44243. lensFlareSystem.render();
  44244. }
  44245. }
  44246. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Lens flares", lensFlareSystems.length > 0);
  44247. }
  44248. };
  44249. return LensFlareSystemSceneComponent;
  44250. }());
  44251. _lensFlareSystem__WEBPACK_IMPORTED_MODULE_3__["LensFlareSystem"]._SceneComponentInitialization = function (scene) {
  44252. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_LENSFLARESYSTEM);
  44253. if (!component) {
  44254. component = new LensFlareSystemSceneComponent(scene);
  44255. scene._addComponent(component);
  44256. }
  44257. };
  44258. /***/ }),
  44259. /***/ "./Lights/Shadows/index.ts":
  44260. /*!*********************************!*\
  44261. !*** ./Lights/Shadows/index.ts ***!
  44262. \*********************************/
  44263. /*! exports provided: ShadowGenerator, ShadowGeneratorSceneComponent */
  44264. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44265. "use strict";
  44266. __webpack_require__.r(__webpack_exports__);
  44267. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  44268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]; });
  44269. /* harmony import */ var _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowGeneratorSceneComponent */ "./Lights/Shadows/shadowGeneratorSceneComponent.ts");
  44270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _shadowGeneratorSceneComponent__WEBPACK_IMPORTED_MODULE_1__["ShadowGeneratorSceneComponent"]; });
  44271. /***/ }),
  44272. /***/ "./Lights/Shadows/shadowGenerator.ts":
  44273. /*!*******************************************!*\
  44274. !*** ./Lights/Shadows/shadowGenerator.ts ***!
  44275. \*******************************************/
  44276. /*! exports provided: ShadowGenerator */
  44277. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  44278. "use strict";
  44279. __webpack_require__.r(__webpack_exports__);
  44280. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return ShadowGenerator; });
  44281. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  44282. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  44283. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  44284. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  44285. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  44286. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  44287. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  44288. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  44289. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  44290. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  44291. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  44292. /* harmony import */ var _Shaders_shadowMap_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Shaders/shadowMap.fragment */ "./Shaders/shadowMap.fragment.ts");
  44293. /* harmony import */ var _Shaders_shadowMap_vertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Shaders/shadowMap.vertex */ "./Shaders/shadowMap.vertex.ts");
  44294. /* harmony import */ var _Shaders_depthBoxBlur_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Shaders/depthBoxBlur.fragment */ "./Shaders/depthBoxBlur.fragment.ts");
  44295. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  44296. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  44297. /**
  44298. * Default implementation IShadowGenerator.
  44299. * This is the main object responsible of generating shadows in the framework.
  44300. * Documentation: https://doc.babylonjs.com/babylon101/shadows
  44301. */
  44302. var ShadowGenerator = /** @class */ (function () {
  44303. /**
  44304. * Creates a ShadowGenerator object.
  44305. * A ShadowGenerator is the required tool to use the shadows.
  44306. * Each light casting shadows needs to use its own ShadowGenerator.
  44307. * Documentation : https://doc.babylonjs.com/babylon101/shadows
  44308. * @param mapSize The size of the texture what stores the shadows. Example : 1024.
  44309. * @param light The light object generating the shadows.
  44310. * @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.
  44311. */
  44312. function ShadowGenerator(mapSize, light, usefulFloatFirst) {
  44313. /**
  44314. * Observable triggered before the shadow is rendered. Can be used to update internal effect state
  44315. */
  44316. this.onBeforeShadowMapRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_14__["Observable"]();
  44317. this._bias = 0.00005;
  44318. this._normalBias = 0;
  44319. this._blurBoxOffset = 1;
  44320. this._blurScale = 2;
  44321. this._blurKernel = 1;
  44322. this._useKernelBlur = false;
  44323. this._filter = ShadowGenerator.FILTER_NONE;
  44324. this._filteringQuality = ShadowGenerator.QUALITY_HIGH;
  44325. this._contactHardeningLightSizeUVRatio = 0.1;
  44326. this._darkness = 0;
  44327. this._transparencyShadow = false;
  44328. /**
  44329. * Controls the extent to which the shadows fade out at the edge of the frustum
  44330. * Used only by directionals and spots
  44331. */
  44332. this.frustumEdgeFalloff = 0;
  44333. /**
  44334. * If true the shadow map is generated by rendering the back face of the mesh instead of the front face.
  44335. * This can help with self-shadowing as the geometry making up the back of objects is slightly offset.
  44336. * It might on the other hand introduce peter panning.
  44337. */
  44338. this.forceBackFacesOnly = false;
  44339. this._lightDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  44340. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44341. this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44342. this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  44343. this._cachedPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44344. this._cachedDirection = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  44345. this._currentFaceIndex = 0;
  44346. this._currentFaceIndexCache = 0;
  44347. this._defaultTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  44348. this._mapSize = mapSize;
  44349. this._light = light;
  44350. this._scene = light.getScene();
  44351. light._shadowGenerator = this;
  44352. ShadowGenerator._SceneComponentInitialization(this._scene);
  44353. // Texture type fallback from float to int if not supported.
  44354. var caps = this._scene.getEngine().getCaps();
  44355. if (!usefulFloatFirst) {
  44356. if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44357. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44358. }
  44359. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44360. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44361. }
  44362. else {
  44363. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44364. }
  44365. }
  44366. else {
  44367. if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  44368. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_FLOAT;
  44369. }
  44370. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  44371. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_HALF_FLOAT;
  44372. }
  44373. else {
  44374. this._textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  44375. }
  44376. }
  44377. this._initializeGenerator();
  44378. this._applyFilterValues();
  44379. }
  44380. Object.defineProperty(ShadowGenerator.prototype, "bias", {
  44381. /**
  44382. * Gets the bias: offset applied on the depth preventing acnea (in light direction).
  44383. */
  44384. get: function () {
  44385. return this._bias;
  44386. },
  44387. /**
  44388. * Sets the bias: offset applied on the depth preventing acnea (in light direction).
  44389. */
  44390. set: function (bias) {
  44391. this._bias = bias;
  44392. },
  44393. enumerable: true,
  44394. configurable: true
  44395. });
  44396. Object.defineProperty(ShadowGenerator.prototype, "normalBias", {
  44397. /**
  44398. * Gets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44399. */
  44400. get: function () {
  44401. return this._normalBias;
  44402. },
  44403. /**
  44404. * Sets the normalBias: offset applied on the depth preventing acnea (along side the normal direction and proportinal to the light/normal angle).
  44405. */
  44406. set: function (normalBias) {
  44407. this._normalBias = normalBias;
  44408. },
  44409. enumerable: true,
  44410. configurable: true
  44411. });
  44412. Object.defineProperty(ShadowGenerator.prototype, "blurBoxOffset", {
  44413. /**
  44414. * Gets the blur box offset: offset applied during the blur pass.
  44415. * Only useful if useKernelBlur = false
  44416. */
  44417. get: function () {
  44418. return this._blurBoxOffset;
  44419. },
  44420. /**
  44421. * Sets the blur box offset: offset applied during the blur pass.
  44422. * Only useful if useKernelBlur = false
  44423. */
  44424. set: function (value) {
  44425. if (this._blurBoxOffset === value) {
  44426. return;
  44427. }
  44428. this._blurBoxOffset = value;
  44429. this._disposeBlurPostProcesses();
  44430. },
  44431. enumerable: true,
  44432. configurable: true
  44433. });
  44434. Object.defineProperty(ShadowGenerator.prototype, "blurScale", {
  44435. /**
  44436. * Gets the blur scale: scale of the blurred texture compared to the main shadow map.
  44437. * 2 means half of the size.
  44438. */
  44439. get: function () {
  44440. return this._blurScale;
  44441. },
  44442. /**
  44443. * Sets the blur scale: scale of the blurred texture compared to the main shadow map.
  44444. * 2 means half of the size.
  44445. */
  44446. set: function (value) {
  44447. if (this._blurScale === value) {
  44448. return;
  44449. }
  44450. this._blurScale = value;
  44451. this._disposeBlurPostProcesses();
  44452. },
  44453. enumerable: true,
  44454. configurable: true
  44455. });
  44456. Object.defineProperty(ShadowGenerator.prototype, "blurKernel", {
  44457. /**
  44458. * Gets the blur kernel: kernel size of the blur pass.
  44459. * Only useful if useKernelBlur = true
  44460. */
  44461. get: function () {
  44462. return this._blurKernel;
  44463. },
  44464. /**
  44465. * Sets the blur kernel: kernel size of the blur pass.
  44466. * Only useful if useKernelBlur = true
  44467. */
  44468. set: function (value) {
  44469. if (this._blurKernel === value) {
  44470. return;
  44471. }
  44472. this._blurKernel = value;
  44473. this._disposeBlurPostProcesses();
  44474. },
  44475. enumerable: true,
  44476. configurable: true
  44477. });
  44478. Object.defineProperty(ShadowGenerator.prototype, "useKernelBlur", {
  44479. /**
  44480. * Gets whether the blur pass is a kernel blur (if true) or box blur.
  44481. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44482. */
  44483. get: function () {
  44484. return this._useKernelBlur;
  44485. },
  44486. /**
  44487. * Sets whether the blur pass is a kernel blur (if true) or box blur.
  44488. * Only useful in filtered mode (useBlurExponentialShadowMap...)
  44489. */
  44490. set: function (value) {
  44491. if (this._useKernelBlur === value) {
  44492. return;
  44493. }
  44494. this._useKernelBlur = value;
  44495. this._disposeBlurPostProcesses();
  44496. },
  44497. enumerable: true,
  44498. configurable: true
  44499. });
  44500. Object.defineProperty(ShadowGenerator.prototype, "depthScale", {
  44501. /**
  44502. * Gets the depth scale used in ESM mode.
  44503. */
  44504. get: function () {
  44505. return this._depthScale !== undefined ? this._depthScale : this._light.getDepthScale();
  44506. },
  44507. /**
  44508. * Sets the depth scale used in ESM mode.
  44509. * This can override the scale stored on the light.
  44510. */
  44511. set: function (value) {
  44512. this._depthScale = value;
  44513. },
  44514. enumerable: true,
  44515. configurable: true
  44516. });
  44517. Object.defineProperty(ShadowGenerator.prototype, "filter", {
  44518. /**
  44519. * Gets the current mode of the shadow generator (normal, PCF, ESM...).
  44520. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44521. */
  44522. get: function () {
  44523. return this._filter;
  44524. },
  44525. /**
  44526. * Sets the current mode of the shadow generator (normal, PCF, ESM...).
  44527. * The returned value is a number equal to one of the available mode defined in ShadowMap.FILTER_x like _FILTER_NONE
  44528. */
  44529. set: function (value) {
  44530. // Blurring the cubemap is going to be too expensive. Reverting to unblurred version
  44531. if (this._light.needCube()) {
  44532. if (value === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44533. this.useExponentialShadowMap = true;
  44534. return;
  44535. }
  44536. else if (value === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44537. this.useCloseExponentialShadowMap = true;
  44538. return;
  44539. }
  44540. // PCF on cubemap would also be expensive
  44541. else if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44542. this.usePoissonSampling = true;
  44543. return;
  44544. }
  44545. }
  44546. // Weblg1 fallback for PCF.
  44547. if (value === ShadowGenerator.FILTER_PCF || value === ShadowGenerator.FILTER_PCSS) {
  44548. if (this._scene.getEngine().webGLVersion === 1) {
  44549. this.usePoissonSampling = true;
  44550. return;
  44551. }
  44552. }
  44553. if (this._filter === value) {
  44554. return;
  44555. }
  44556. this._filter = value;
  44557. this._disposeBlurPostProcesses();
  44558. this._applyFilterValues();
  44559. this._light._markMeshesAsLightDirty();
  44560. },
  44561. enumerable: true,
  44562. configurable: true
  44563. });
  44564. Object.defineProperty(ShadowGenerator.prototype, "usePoissonSampling", {
  44565. /**
  44566. * Gets if the current filter is set to Poisson Sampling.
  44567. */
  44568. get: function () {
  44569. return this.filter === ShadowGenerator.FILTER_POISSONSAMPLING;
  44570. },
  44571. /**
  44572. * Sets the current filter to Poisson Sampling.
  44573. */
  44574. set: function (value) {
  44575. if (!value && this.filter !== ShadowGenerator.FILTER_POISSONSAMPLING) {
  44576. return;
  44577. }
  44578. this.filter = (value ? ShadowGenerator.FILTER_POISSONSAMPLING : ShadowGenerator.FILTER_NONE);
  44579. },
  44580. enumerable: true,
  44581. configurable: true
  44582. });
  44583. Object.defineProperty(ShadowGenerator.prototype, "useExponentialShadowMap", {
  44584. /**
  44585. * Gets if the current filter is set to ESM.
  44586. */
  44587. get: function () {
  44588. return this.filter === ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP;
  44589. },
  44590. /**
  44591. * Sets the current filter is to ESM.
  44592. */
  44593. set: function (value) {
  44594. if (!value && this.filter !== ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP) {
  44595. return;
  44596. }
  44597. this.filter = (value ? ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44598. },
  44599. enumerable: true,
  44600. configurable: true
  44601. });
  44602. Object.defineProperty(ShadowGenerator.prototype, "useBlurExponentialShadowMap", {
  44603. /**
  44604. * Gets if the current filter is set to filtered ESM.
  44605. */
  44606. get: function () {
  44607. return this.filter === ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP;
  44608. },
  44609. /**
  44610. * Gets if the current filter is set to filtered ESM.
  44611. */
  44612. set: function (value) {
  44613. if (!value && this.filter !== ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP) {
  44614. return;
  44615. }
  44616. this.filter = (value ? ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44617. },
  44618. enumerable: true,
  44619. configurable: true
  44620. });
  44621. Object.defineProperty(ShadowGenerator.prototype, "useCloseExponentialShadowMap", {
  44622. /**
  44623. * Gets if the current filter is set to "close ESM" (using the inverse of the
  44624. * exponential to prevent steep falloff artifacts).
  44625. */
  44626. get: function () {
  44627. return this.filter === ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP;
  44628. },
  44629. /**
  44630. * Sets the current filter to "close ESM" (using the inverse of the
  44631. * exponential to prevent steep falloff artifacts).
  44632. */
  44633. set: function (value) {
  44634. if (!value && this.filter !== ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP) {
  44635. return;
  44636. }
  44637. this.filter = (value ? ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44638. },
  44639. enumerable: true,
  44640. configurable: true
  44641. });
  44642. Object.defineProperty(ShadowGenerator.prototype, "useBlurCloseExponentialShadowMap", {
  44643. /**
  44644. * Gets if the current filter is set to filtered "close ESM" (using the inverse of the
  44645. * exponential to prevent steep falloff artifacts).
  44646. */
  44647. get: function () {
  44648. return this.filter === ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP;
  44649. },
  44650. /**
  44651. * Sets the current filter to filtered "close ESM" (using the inverse of the
  44652. * exponential to prevent steep falloff artifacts).
  44653. */
  44654. set: function (value) {
  44655. if (!value && this.filter !== ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP) {
  44656. return;
  44657. }
  44658. this.filter = (value ? ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP : ShadowGenerator.FILTER_NONE);
  44659. },
  44660. enumerable: true,
  44661. configurable: true
  44662. });
  44663. Object.defineProperty(ShadowGenerator.prototype, "usePercentageCloserFiltering", {
  44664. /**
  44665. * Gets if the current filter is set to "PCF" (percentage closer filtering).
  44666. */
  44667. get: function () {
  44668. return this.filter === ShadowGenerator.FILTER_PCF;
  44669. },
  44670. /**
  44671. * Sets the current filter to "PCF" (percentage closer filtering).
  44672. */
  44673. set: function (value) {
  44674. if (!value && this.filter !== ShadowGenerator.FILTER_PCF) {
  44675. return;
  44676. }
  44677. this.filter = (value ? ShadowGenerator.FILTER_PCF : ShadowGenerator.FILTER_NONE);
  44678. },
  44679. enumerable: true,
  44680. configurable: true
  44681. });
  44682. Object.defineProperty(ShadowGenerator.prototype, "filteringQuality", {
  44683. /**
  44684. * Gets the PCF or PCSS Quality.
  44685. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44686. */
  44687. get: function () {
  44688. return this._filteringQuality;
  44689. },
  44690. /**
  44691. * Sets the PCF or PCSS Quality.
  44692. * Only valid if usePercentageCloserFiltering or usePercentageCloserFiltering is true.
  44693. */
  44694. set: function (filteringQuality) {
  44695. this._filteringQuality = filteringQuality;
  44696. },
  44697. enumerable: true,
  44698. configurable: true
  44699. });
  44700. Object.defineProperty(ShadowGenerator.prototype, "useContactHardeningShadow", {
  44701. /**
  44702. * Gets if the current filter is set to "PCSS" (contact hardening).
  44703. */
  44704. get: function () {
  44705. return this.filter === ShadowGenerator.FILTER_PCSS;
  44706. },
  44707. /**
  44708. * Sets the current filter to "PCSS" (contact hardening).
  44709. */
  44710. set: function (value) {
  44711. if (!value && this.filter !== ShadowGenerator.FILTER_PCSS) {
  44712. return;
  44713. }
  44714. this.filter = (value ? ShadowGenerator.FILTER_PCSS : ShadowGenerator.FILTER_NONE);
  44715. },
  44716. enumerable: true,
  44717. configurable: true
  44718. });
  44719. Object.defineProperty(ShadowGenerator.prototype, "contactHardeningLightSizeUVRatio", {
  44720. /**
  44721. * Gets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44722. * Using a ratio helps keeping shape stability independently of the map size.
  44723. *
  44724. * It does not account for the light projection as it was having too much
  44725. * instability during the light setup or during light position changes.
  44726. *
  44727. * Only valid if useContactHardeningShadow is true.
  44728. */
  44729. get: function () {
  44730. return this._contactHardeningLightSizeUVRatio;
  44731. },
  44732. /**
  44733. * Sets the Light Size (in shadow map uv unit) used in PCSS to determine the blocker search area and the penumbra size.
  44734. * Using a ratio helps keeping shape stability independently of the map size.
  44735. *
  44736. * It does not account for the light projection as it was having too much
  44737. * instability during the light setup or during light position changes.
  44738. *
  44739. * Only valid if useContactHardeningShadow is true.
  44740. */
  44741. set: function (contactHardeningLightSizeUVRatio) {
  44742. this._contactHardeningLightSizeUVRatio = contactHardeningLightSizeUVRatio;
  44743. },
  44744. enumerable: true,
  44745. configurable: true
  44746. });
  44747. /**
  44748. * Returns the darkness value (float). This can only decrease the actual darkness of a shadow.
  44749. * 0 means strongest and 1 would means no shadow.
  44750. * @returns the darkness.
  44751. */
  44752. ShadowGenerator.prototype.getDarkness = function () {
  44753. return this._darkness;
  44754. };
  44755. /**
  44756. * Sets the darkness value (float). This can only decrease the actual darkness of a shadow.
  44757. * @param darkness The darkness value 0 means strongest and 1 would means no shadow.
  44758. * @returns the shadow generator allowing fluent coding.
  44759. */
  44760. ShadowGenerator.prototype.setDarkness = function (darkness) {
  44761. if (darkness >= 1.0) {
  44762. this._darkness = 1.0;
  44763. }
  44764. else if (darkness <= 0.0) {
  44765. this._darkness = 0.0;
  44766. }
  44767. else {
  44768. this._darkness = darkness;
  44769. }
  44770. return this;
  44771. };
  44772. /**
  44773. * Sets the ability to have transparent shadow (boolean).
  44774. * @param transparent True if transparent else False
  44775. * @returns the shadow generator allowing fluent coding
  44776. */
  44777. ShadowGenerator.prototype.setTransparencyShadow = function (transparent) {
  44778. this._transparencyShadow = transparent;
  44779. return this;
  44780. };
  44781. /**
  44782. * Gets the main RTT containing the shadow map (usually storing depth from the light point of view).
  44783. * @returns The render target texture if present otherwise, null
  44784. */
  44785. ShadowGenerator.prototype.getShadowMap = function () {
  44786. return this._shadowMap;
  44787. };
  44788. /**
  44789. * Gets the RTT used during rendering (can be a blurred version of the shadow map or the shadow map itself).
  44790. * @returns The render target texture if the shadow map is present otherwise, null
  44791. */
  44792. ShadowGenerator.prototype.getShadowMapForRendering = function () {
  44793. if (this._shadowMap2) {
  44794. return this._shadowMap2;
  44795. }
  44796. return this._shadowMap;
  44797. };
  44798. /**
  44799. * Helper function to add a mesh and its descendants to the list of shadow casters.
  44800. * @param mesh Mesh to add
  44801. * @param includeDescendants boolean indicating if the descendants should be added. Default to true
  44802. * @returns the Shadow Generator itself
  44803. */
  44804. ShadowGenerator.prototype.addShadowCaster = function (mesh, includeDescendants) {
  44805. if (includeDescendants === void 0) { includeDescendants = true; }
  44806. var _a;
  44807. if (!this._shadowMap) {
  44808. return this;
  44809. }
  44810. if (!this._shadowMap.renderList) {
  44811. this._shadowMap.renderList = [];
  44812. }
  44813. this._shadowMap.renderList.push(mesh);
  44814. if (includeDescendants) {
  44815. (_a = this._shadowMap.renderList).push.apply(_a, mesh.getChildMeshes());
  44816. }
  44817. return this;
  44818. };
  44819. /**
  44820. * Helper function to remove a mesh and its descendants from the list of shadow casters
  44821. * @param mesh Mesh to remove
  44822. * @param includeDescendants boolean indicating if the descendants should be removed. Default to true
  44823. * @returns the Shadow Generator itself
  44824. */
  44825. ShadowGenerator.prototype.removeShadowCaster = function (mesh, includeDescendants) {
  44826. if (includeDescendants === void 0) { includeDescendants = true; }
  44827. if (!this._shadowMap || !this._shadowMap.renderList) {
  44828. return this;
  44829. }
  44830. var index = this._shadowMap.renderList.indexOf(mesh);
  44831. if (index !== -1) {
  44832. this._shadowMap.renderList.splice(index, 1);
  44833. }
  44834. if (includeDescendants) {
  44835. for (var _i = 0, _a = mesh.getChildren(); _i < _a.length; _i++) {
  44836. var child = _a[_i];
  44837. this.removeShadowCaster(child);
  44838. }
  44839. }
  44840. return this;
  44841. };
  44842. /**
  44843. * Returns the associated light object.
  44844. * @returns the light generating the shadow
  44845. */
  44846. ShadowGenerator.prototype.getLight = function () {
  44847. return this._light;
  44848. };
  44849. ShadowGenerator.prototype._initializeGenerator = function () {
  44850. this._light._markMeshesAsLightDirty();
  44851. this._initializeShadowMap();
  44852. };
  44853. ShadowGenerator.prototype._initializeShadowMap = function () {
  44854. var _this = this;
  44855. // Render target
  44856. var engine = this._scene.getEngine();
  44857. if (engine.webGLVersion > 1) {
  44858. 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);
  44859. this._shadowMap.createDepthStencilTexture(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].LESS, true);
  44860. }
  44861. else {
  44862. 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());
  44863. }
  44864. this._shadowMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44865. this._shadowMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44866. this._shadowMap.anisotropicFilteringLevel = 1;
  44867. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44868. this._shadowMap.renderParticles = false;
  44869. this._shadowMap.ignoreCameraViewport = true;
  44870. // Record Face Index before render.
  44871. this._shadowMap.onBeforeRenderObservable.add(function (faceIndex) {
  44872. _this._currentFaceIndex = faceIndex;
  44873. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44874. engine.setColorWrite(false);
  44875. }
  44876. });
  44877. // Custom render function.
  44878. this._shadowMap.customRenderFunction = this._renderForShadowMap.bind(this);
  44879. // Blur if required afer render.
  44880. this._shadowMap.onAfterUnbindObservable.add(function () {
  44881. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44882. engine.setColorWrite(true);
  44883. }
  44884. if (!_this.useBlurExponentialShadowMap && !_this.useBlurCloseExponentialShadowMap) {
  44885. return;
  44886. }
  44887. var shadowMap = _this.getShadowMapForRendering();
  44888. if (shadowMap) {
  44889. _this._scene.postProcessManager.directRender(_this._blurPostProcesses, shadowMap.getInternalTexture(), true);
  44890. }
  44891. });
  44892. // Clear according to the chosen filter.
  44893. var clearZero = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](0, 0, 0, 0);
  44894. var clearOne = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  44895. this._shadowMap.onClearObservable.add(function (engine) {
  44896. if (_this._filter === ShadowGenerator.FILTER_PCF) {
  44897. engine.clear(clearOne, false, true, false);
  44898. }
  44899. else if (_this.useExponentialShadowMap || _this.useBlurExponentialShadowMap) {
  44900. engine.clear(clearZero, true, true, false);
  44901. }
  44902. else {
  44903. engine.clear(clearOne, true, true, false);
  44904. }
  44905. });
  44906. };
  44907. ShadowGenerator.prototype._initializeBlurRTTAndPostProcesses = function () {
  44908. var _this = this;
  44909. var engine = this._scene.getEngine();
  44910. var targetSize = this._mapSize / this.blurScale;
  44911. if (!this.useKernelBlur || this.blurScale !== 1.0) {
  44912. this._shadowMap2 = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"](this._light.name + "_shadowMap2", targetSize, this._scene, false, true, this._textureType);
  44913. this._shadowMap2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44914. this._shadowMap2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  44915. this._shadowMap2.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  44916. }
  44917. if (this.useKernelBlur) {
  44918. 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);
  44919. this._kernelBlurXPostprocess.width = targetSize;
  44920. this._kernelBlurXPostprocess.height = targetSize;
  44921. this._kernelBlurXPostprocess.onApplyObservable.add(function (effect) {
  44922. effect.setTexture("textureSampler", _this._shadowMap);
  44923. });
  44924. 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);
  44925. this._kernelBlurXPostprocess.autoClear = false;
  44926. this._kernelBlurYPostprocess.autoClear = false;
  44927. if (this._textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  44928. this._kernelBlurXPostprocess.packedFloat = true;
  44929. this._kernelBlurYPostprocess.packedFloat = true;
  44930. }
  44931. this._blurPostProcesses = [this._kernelBlurXPostprocess, this._kernelBlurYPostprocess];
  44932. }
  44933. else {
  44934. 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);
  44935. this._boxBlurPostprocess.onApplyObservable.add(function (effect) {
  44936. effect.setFloat2("screenSize", targetSize, targetSize);
  44937. effect.setTexture("textureSampler", _this._shadowMap);
  44938. });
  44939. this._boxBlurPostprocess.autoClear = false;
  44940. this._blurPostProcesses = [this._boxBlurPostprocess];
  44941. }
  44942. };
  44943. ShadowGenerator.prototype._renderForShadowMap = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  44944. var index;
  44945. var engine = this._scene.getEngine();
  44946. if (depthOnlySubMeshes.length) {
  44947. engine.setColorWrite(false);
  44948. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  44949. this._renderSubMeshForShadowMap(depthOnlySubMeshes.data[index]);
  44950. }
  44951. engine.setColorWrite(true);
  44952. }
  44953. for (index = 0; index < opaqueSubMeshes.length; index++) {
  44954. this._renderSubMeshForShadowMap(opaqueSubMeshes.data[index]);
  44955. }
  44956. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  44957. this._renderSubMeshForShadowMap(alphaTestSubMeshes.data[index]);
  44958. }
  44959. if (this._transparencyShadow) {
  44960. for (index = 0; index < transparentSubMeshes.length; index++) {
  44961. this._renderSubMeshForShadowMap(transparentSubMeshes.data[index]);
  44962. }
  44963. }
  44964. };
  44965. ShadowGenerator.prototype._renderSubMeshForShadowMap = function (subMesh) {
  44966. var _this = this;
  44967. var mesh = subMesh.getRenderingMesh();
  44968. var scene = this._scene;
  44969. var engine = scene.getEngine();
  44970. var material = subMesh.getMaterial();
  44971. if (!material || subMesh.verticesCount === 0) {
  44972. return;
  44973. }
  44974. // Culling
  44975. engine.setState(material.backFaceCulling);
  44976. // Managing instances
  44977. var batch = mesh._getInstancesRenderList(subMesh._id);
  44978. if (batch.mustReturn) {
  44979. return;
  44980. }
  44981. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  44982. if (this.isReady(subMesh, hardwareInstancedRendering)) {
  44983. engine.enableEffect(this._effect);
  44984. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  44985. this._effect.setFloat3("biasAndScale", this.bias, this.normalBias, this.depthScale);
  44986. this._effect.setMatrix("viewProjection", this.getTransformMatrix());
  44987. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  44988. this._effect.setVector3("lightData", this._cachedDirection);
  44989. }
  44990. else {
  44991. this._effect.setVector3("lightData", this._cachedPosition);
  44992. }
  44993. if (scene.activeCamera) {
  44994. this._effect.setFloat2("depthValues", this.getLight().getDepthMinZ(scene.activeCamera), this.getLight().getDepthMinZ(scene.activeCamera) + this.getLight().getDepthMaxZ(scene.activeCamera));
  44995. }
  44996. // Alpha test
  44997. if (material && material.needAlphaTesting()) {
  44998. var alphaTexture = material.getAlphaTestTexture();
  44999. if (alphaTexture) {
  45000. this._effect.setTexture("diffuseSampler", alphaTexture);
  45001. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix() || this._defaultTextureMatrix);
  45002. }
  45003. }
  45004. // Bones
  45005. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45006. var skeleton = mesh.skeleton;
  45007. if (skeleton.isUsingTextureForMatrices) {
  45008. var boneTexture = skeleton.getTransformMatrixTexture();
  45009. if (!boneTexture) {
  45010. return;
  45011. }
  45012. this._effect.setTexture("boneSampler", boneTexture);
  45013. this._effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  45014. }
  45015. else {
  45016. this._effect.setMatrices("mBones", skeleton.getTransformMatrices((mesh)));
  45017. }
  45018. }
  45019. // Morph targets
  45020. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindMorphTargetParameters(mesh, this._effect);
  45021. if (this.forceBackFacesOnly) {
  45022. engine.setState(true, 0, false, true);
  45023. }
  45024. // Observable
  45025. this.onBeforeShadowMapRenderObservable.notifyObservers(this._effect);
  45026. // Draw
  45027. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  45028. if (this.forceBackFacesOnly) {
  45029. engine.setState(true, 0, false, false);
  45030. }
  45031. }
  45032. else {
  45033. // Need to reset refresh rate of the shadowMap
  45034. if (this._shadowMap) {
  45035. this._shadowMap.resetRefreshCounter();
  45036. }
  45037. }
  45038. };
  45039. ShadowGenerator.prototype._applyFilterValues = function () {
  45040. if (!this._shadowMap) {
  45041. return;
  45042. }
  45043. if (this.filter === ShadowGenerator.FILTER_NONE || this.filter === ShadowGenerator.FILTER_PCSS) {
  45044. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].NEAREST_SAMPLINGMODE);
  45045. }
  45046. else {
  45047. this._shadowMap.updateSamplingMode(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].BILINEAR_SAMPLINGMODE);
  45048. }
  45049. };
  45050. /**
  45051. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45052. * @param onCompiled Callback triggered at the and of the effects compilation
  45053. * @param options Sets of optional options forcing the compilation with different modes
  45054. */
  45055. ShadowGenerator.prototype.forceCompilation = function (onCompiled, options) {
  45056. var _this = this;
  45057. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ useInstances: false }, options);
  45058. var shadowMap = this.getShadowMap();
  45059. if (!shadowMap) {
  45060. if (onCompiled) {
  45061. onCompiled(this);
  45062. }
  45063. return;
  45064. }
  45065. var renderList = shadowMap.renderList;
  45066. if (!renderList) {
  45067. if (onCompiled) {
  45068. onCompiled(this);
  45069. }
  45070. return;
  45071. }
  45072. var subMeshes = new Array();
  45073. for (var _i = 0, renderList_1 = renderList; _i < renderList_1.length; _i++) {
  45074. var mesh = renderList_1[_i];
  45075. subMeshes.push.apply(subMeshes, mesh.subMeshes);
  45076. }
  45077. if (subMeshes.length === 0) {
  45078. if (onCompiled) {
  45079. onCompiled(this);
  45080. }
  45081. return;
  45082. }
  45083. var currentIndex = 0;
  45084. var checkReady = function () {
  45085. if (!_this._scene || !_this._scene.getEngine()) {
  45086. return;
  45087. }
  45088. while (_this.isReady(subMeshes[currentIndex], localOptions.useInstances)) {
  45089. currentIndex++;
  45090. if (currentIndex >= subMeshes.length) {
  45091. if (onCompiled) {
  45092. onCompiled(_this);
  45093. }
  45094. return;
  45095. }
  45096. }
  45097. setTimeout(checkReady, 16);
  45098. };
  45099. checkReady();
  45100. };
  45101. /**
  45102. * Forces all the attached effect to compile to enable rendering only once ready vs. lazyly compiling effects.
  45103. * @param options Sets of optional options forcing the compilation with different modes
  45104. * @returns A promise that resolves when the compilation completes
  45105. */
  45106. ShadowGenerator.prototype.forceCompilationAsync = function (options) {
  45107. var _this = this;
  45108. return new Promise(function (resolve) {
  45109. _this.forceCompilation(function () {
  45110. resolve();
  45111. }, options);
  45112. });
  45113. };
  45114. /**
  45115. * Determine wheter the shadow generator is ready or not (mainly all effects and related post processes needs to be ready).
  45116. * @param subMesh The submesh we want to render in the shadow map
  45117. * @param useInstances Defines wether will draw in the map using instances
  45118. * @returns true if ready otherwise, false
  45119. */
  45120. ShadowGenerator.prototype.isReady = function (subMesh, useInstances) {
  45121. var defines = [];
  45122. if (this._textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  45123. defines.push("#define FLOAT");
  45124. }
  45125. if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45126. defines.push("#define ESM");
  45127. }
  45128. else if (this.usePercentageCloserFiltering || this.useContactHardeningShadow) {
  45129. defines.push("#define DEPTHTEXTURE");
  45130. }
  45131. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind];
  45132. var mesh = subMesh.getMesh();
  45133. var material = subMesh.getMaterial();
  45134. // Normal bias.
  45135. if (this.normalBias && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  45136. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  45137. defines.push("#define NORMAL");
  45138. if (mesh.nonUniformScaling) {
  45139. defines.push("#define NONUNIFORMSCALING");
  45140. }
  45141. if (this.getLight().getTypeID() === _Lights_light__WEBPACK_IMPORTED_MODULE_3__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT) {
  45142. defines.push("#define DIRECTIONINLIGHTDATA");
  45143. }
  45144. }
  45145. // Alpha test
  45146. if (material && material.needAlphaTesting()) {
  45147. var alphaTexture = material.getAlphaTestTexture();
  45148. if (alphaTexture) {
  45149. defines.push("#define ALPHATEST");
  45150. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  45151. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  45152. defines.push("#define UV1");
  45153. }
  45154. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  45155. if (alphaTexture.coordinatesIndex === 1) {
  45156. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  45157. defines.push("#define UV2");
  45158. }
  45159. }
  45160. }
  45161. }
  45162. // Bones
  45163. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  45164. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  45165. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  45166. if (mesh.numBoneInfluencers > 4) {
  45167. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  45168. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind);
  45169. }
  45170. var skeleton = mesh.skeleton;
  45171. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  45172. if (skeleton.isUsingTextureForMatrices) {
  45173. defines.push("#define BONETEXTURE");
  45174. }
  45175. else {
  45176. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  45177. }
  45178. }
  45179. else {
  45180. defines.push("#define NUM_BONE_INFLUENCERS 0");
  45181. }
  45182. // Morph targets
  45183. var manager = mesh.morphTargetManager;
  45184. var morphInfluencers = 0;
  45185. if (manager) {
  45186. if (manager.numInfluencers > 0) {
  45187. defines.push("#define MORPHTARGETS");
  45188. morphInfluencers = manager.numInfluencers;
  45189. defines.push("#define NUM_MORPH_INFLUENCERS " + morphInfluencers);
  45190. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, { "NUM_MORPH_INFLUENCERS": morphInfluencers });
  45191. }
  45192. }
  45193. // Instances
  45194. if (useInstances) {
  45195. defines.push("#define INSTANCES");
  45196. attribs.push("world0");
  45197. attribs.push("world1");
  45198. attribs.push("world2");
  45199. attribs.push("world3");
  45200. }
  45201. if (this.customShaderOptions) {
  45202. if (this.customShaderOptions.defines) {
  45203. for (var _i = 0, _a = this.customShaderOptions.defines; _i < _a.length; _i++) {
  45204. var define = _a[_i];
  45205. if (defines.indexOf(define) === -1) {
  45206. defines.push(define);
  45207. }
  45208. }
  45209. }
  45210. }
  45211. // Get correct effect
  45212. var join = defines.join("\n");
  45213. if (this._cachedDefines !== join) {
  45214. this._cachedDefines = join;
  45215. var shaderName = "shadowMap";
  45216. var uniforms = ["world", "mBones", "viewProjection", "diffuseMatrix", "lightData", "depthValues", "biasAndScale", "morphTargetInfluences", "boneTextureWidth"];
  45217. var samplers = ["diffuseSampler", "boneSampler"];
  45218. // Custom shader?
  45219. if (this.customShaderOptions) {
  45220. shaderName = this.customShaderOptions.shaderName;
  45221. if (this.customShaderOptions.attributes) {
  45222. for (var _b = 0, _c = this.customShaderOptions.attributes; _b < _c.length; _b++) {
  45223. var attrib = _c[_b];
  45224. if (attribs.indexOf(attrib) === -1) {
  45225. attribs.push(attrib);
  45226. }
  45227. }
  45228. }
  45229. if (this.customShaderOptions.uniforms) {
  45230. for (var _d = 0, _e = this.customShaderOptions.uniforms; _d < _e.length; _d++) {
  45231. var uniform = _e[_d];
  45232. if (uniforms.indexOf(uniform) === -1) {
  45233. uniforms.push(uniform);
  45234. }
  45235. }
  45236. }
  45237. if (this.customShaderOptions.samplers) {
  45238. for (var _f = 0, _g = this.customShaderOptions.samplers; _f < _g.length; _f++) {
  45239. var sampler = _g[_f];
  45240. if (samplers.indexOf(sampler) === -1) {
  45241. samplers.push(sampler);
  45242. }
  45243. }
  45244. }
  45245. }
  45246. this._effect = this._scene.getEngine().createEffect(shaderName, attribs, uniforms, samplers, join, undefined, undefined, undefined, { maxSimultaneousMorphTargets: morphInfluencers });
  45247. }
  45248. if (!this._effect.isReady()) {
  45249. return false;
  45250. }
  45251. if (this.useBlurExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45252. if (!this._blurPostProcesses || !this._blurPostProcesses.length) {
  45253. this._initializeBlurRTTAndPostProcesses();
  45254. }
  45255. }
  45256. if (this._kernelBlurXPostprocess && !this._kernelBlurXPostprocess.isReady()) {
  45257. return false;
  45258. }
  45259. if (this._kernelBlurYPostprocess && !this._kernelBlurYPostprocess.isReady()) {
  45260. return false;
  45261. }
  45262. if (this._boxBlurPostprocess && !this._boxBlurPostprocess.isReady()) {
  45263. return false;
  45264. }
  45265. return true;
  45266. };
  45267. /**
  45268. * Prepare all the defines in a material relying on a shadow map at the specified light index.
  45269. * @param defines Defines of the material we want to update
  45270. * @param lightIndex Index of the light in the enabled light list of the material
  45271. */
  45272. ShadowGenerator.prototype.prepareDefines = function (defines, lightIndex) {
  45273. var scene = this._scene;
  45274. var light = this._light;
  45275. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45276. return;
  45277. }
  45278. defines["SHADOW" + lightIndex] = true;
  45279. if (this.useContactHardeningShadow) {
  45280. defines["SHADOWPCSS" + lightIndex] = true;
  45281. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45282. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45283. }
  45284. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45285. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45286. }
  45287. // else default to high.
  45288. }
  45289. if (this.usePercentageCloserFiltering) {
  45290. defines["SHADOWPCF" + lightIndex] = true;
  45291. if (this._filteringQuality === ShadowGenerator.QUALITY_LOW) {
  45292. defines["SHADOWLOWQUALITY" + lightIndex] = true;
  45293. }
  45294. else if (this._filteringQuality === ShadowGenerator.QUALITY_MEDIUM) {
  45295. defines["SHADOWMEDIUMQUALITY" + lightIndex] = true;
  45296. }
  45297. // else default to high.
  45298. }
  45299. else if (this.usePoissonSampling) {
  45300. defines["SHADOWPOISSON" + lightIndex] = true;
  45301. }
  45302. else if (this.useExponentialShadowMap || this.useBlurExponentialShadowMap) {
  45303. defines["SHADOWESM" + lightIndex] = true;
  45304. }
  45305. else if (this.useCloseExponentialShadowMap || this.useBlurCloseExponentialShadowMap) {
  45306. defines["SHADOWCLOSEESM" + lightIndex] = true;
  45307. }
  45308. if (light.needCube()) {
  45309. defines["SHADOWCUBE" + lightIndex] = true;
  45310. }
  45311. };
  45312. /**
  45313. * Binds the shadow related information inside of an effect (information like near, far, darkness...
  45314. * defined in the generator but impacting the effect).
  45315. * @param lightIndex Index of the light in the enabled light list of the material owning the effect
  45316. * @param effect The effect we are binfing the information for
  45317. */
  45318. ShadowGenerator.prototype.bindShadowLight = function (lightIndex, effect) {
  45319. var light = this._light;
  45320. var scene = this._scene;
  45321. if (!scene.shadowsEnabled || !light.shadowEnabled) {
  45322. return;
  45323. }
  45324. var camera = scene.activeCamera;
  45325. if (!camera) {
  45326. return;
  45327. }
  45328. var shadowMap = this.getShadowMap();
  45329. if (!shadowMap) {
  45330. return;
  45331. }
  45332. if (!light.needCube()) {
  45333. effect.setMatrix("lightMatrix" + lightIndex, this.getTransformMatrix());
  45334. }
  45335. // Only PCF uses depth stencil texture.
  45336. if (this._filter === ShadowGenerator.FILTER_PCF) {
  45337. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45338. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), shadowMap.getSize().width, 1 / shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45339. }
  45340. else if (this._filter === ShadowGenerator.FILTER_PCSS) {
  45341. effect.setDepthStencilTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45342. effect.setTexture("depthSampler" + lightIndex, this.getShadowMapForRendering());
  45343. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), 1 / shadowMap.getSize().width, this._contactHardeningLightSizeUVRatio * shadowMap.getSize().width, this.frustumEdgeFalloff, lightIndex);
  45344. }
  45345. else {
  45346. effect.setTexture("shadowSampler" + lightIndex, this.getShadowMapForRendering());
  45347. light._uniformBuffer.updateFloat4("shadowsInfo", this.getDarkness(), this.blurScale / shadowMap.getSize().width, this.depthScale, this.frustumEdgeFalloff, lightIndex);
  45348. }
  45349. light._uniformBuffer.updateFloat2("depthValues", this.getLight().getDepthMinZ(camera), this.getLight().getDepthMinZ(camera) + this.getLight().getDepthMaxZ(camera), lightIndex);
  45350. };
  45351. /**
  45352. * Gets the transformation matrix used to project the meshes into the map from the light point of view.
  45353. * (eq to shadow prjection matrix * light transform matrix)
  45354. * @returns The transform matrix used to create the shadow map
  45355. */
  45356. ShadowGenerator.prototype.getTransformMatrix = function () {
  45357. var scene = this._scene;
  45358. if (this._currentRenderID === scene.getRenderId() && this._currentFaceIndexCache === this._currentFaceIndex) {
  45359. return this._transformMatrix;
  45360. }
  45361. this._currentRenderID = scene.getRenderId();
  45362. this._currentFaceIndexCache = this._currentFaceIndex;
  45363. var lightPosition = this._light.position;
  45364. if (this._light.computeTransformedInformation()) {
  45365. lightPosition = this._light.transformedPosition;
  45366. }
  45367. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].NormalizeToRef(this._light.getShadowDirection(this._currentFaceIndex), this._lightDirection);
  45368. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Dot(this._lightDirection, _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up())) === 1.0) {
  45369. this._lightDirection.z = 0.0000000000001; // Required to avoid perfectly perpendicular light
  45370. }
  45371. if (this._light.needProjectionMatrixCompute() || !this._cachedPosition || !this._cachedDirection || !lightPosition.equals(this._cachedPosition) || !this._lightDirection.equals(this._cachedDirection)) {
  45372. this._cachedPosition.copyFrom(lightPosition);
  45373. this._cachedDirection.copyFrom(this._lightDirection);
  45374. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].LookAtLHToRef(lightPosition, lightPosition.add(this._lightDirection), _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Up(), this._viewMatrix);
  45375. var shadowMap = this.getShadowMap();
  45376. if (shadowMap) {
  45377. var renderList = shadowMap.renderList;
  45378. if (renderList) {
  45379. this._light.setShadowProjectionMatrix(this._projectionMatrix, this._viewMatrix, renderList);
  45380. }
  45381. }
  45382. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  45383. }
  45384. return this._transformMatrix;
  45385. };
  45386. /**
  45387. * Recreates the shadow map dependencies like RTT and post processes. This can be used during the switch between
  45388. * Cube and 2D textures for instance.
  45389. */
  45390. ShadowGenerator.prototype.recreateShadowMap = function () {
  45391. var shadowMap = this._shadowMap;
  45392. if (!shadowMap) {
  45393. return;
  45394. }
  45395. // Track render list.
  45396. var renderList = shadowMap.renderList;
  45397. // Clean up existing data.
  45398. this._disposeRTTandPostProcesses();
  45399. // Reinitializes.
  45400. this._initializeGenerator();
  45401. // Reaffect the filter to ensure a correct fallback if necessary.
  45402. this.filter = this.filter;
  45403. // Reaffect the filter.
  45404. this._applyFilterValues();
  45405. // Reaffect Render List.
  45406. this._shadowMap.renderList = renderList;
  45407. };
  45408. ShadowGenerator.prototype._disposeBlurPostProcesses = function () {
  45409. if (this._shadowMap2) {
  45410. this._shadowMap2.dispose();
  45411. this._shadowMap2 = null;
  45412. }
  45413. if (this._boxBlurPostprocess) {
  45414. this._boxBlurPostprocess.dispose();
  45415. this._boxBlurPostprocess = null;
  45416. }
  45417. if (this._kernelBlurXPostprocess) {
  45418. this._kernelBlurXPostprocess.dispose();
  45419. this._kernelBlurXPostprocess = null;
  45420. }
  45421. if (this._kernelBlurYPostprocess) {
  45422. this._kernelBlurYPostprocess.dispose();
  45423. this._kernelBlurYPostprocess = null;
  45424. }
  45425. this._blurPostProcesses = [];
  45426. };
  45427. ShadowGenerator.prototype._disposeRTTandPostProcesses = function () {
  45428. if (this._shadowMap) {
  45429. this._shadowMap.dispose();
  45430. this._shadowMap = null;
  45431. }
  45432. this._disposeBlurPostProcesses();
  45433. };
  45434. /**
  45435. * Disposes the ShadowGenerator.
  45436. * Returns nothing.
  45437. */
  45438. ShadowGenerator.prototype.dispose = function () {
  45439. this._disposeRTTandPostProcesses();
  45440. if (this._light) {
  45441. this._light._shadowGenerator = null;
  45442. this._light._markMeshesAsLightDirty();
  45443. }
  45444. };
  45445. /**
  45446. * Serializes the shadow generator setup to a json object.
  45447. * @returns The serialized JSON object
  45448. */
  45449. ShadowGenerator.prototype.serialize = function () {
  45450. var serializationObject = {};
  45451. var shadowMap = this.getShadowMap();
  45452. if (!shadowMap) {
  45453. return serializationObject;
  45454. }
  45455. serializationObject.lightId = this._light.id;
  45456. serializationObject.mapSize = shadowMap.getRenderSize();
  45457. serializationObject.useExponentialShadowMap = this.useExponentialShadowMap;
  45458. serializationObject.useBlurExponentialShadowMap = this.useBlurExponentialShadowMap;
  45459. serializationObject.useCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45460. serializationObject.useBlurCloseExponentialShadowMap = this.useBlurExponentialShadowMap;
  45461. serializationObject.usePoissonSampling = this.usePoissonSampling;
  45462. serializationObject.forceBackFacesOnly = this.forceBackFacesOnly;
  45463. serializationObject.depthScale = this.depthScale;
  45464. serializationObject.darkness = this.getDarkness();
  45465. serializationObject.blurBoxOffset = this.blurBoxOffset;
  45466. serializationObject.blurKernel = this.blurKernel;
  45467. serializationObject.blurScale = this.blurScale;
  45468. serializationObject.useKernelBlur = this.useKernelBlur;
  45469. serializationObject.transparencyShadow = this._transparencyShadow;
  45470. serializationObject.frustumEdgeFalloff = this.frustumEdgeFalloff;
  45471. serializationObject.bias = this.bias;
  45472. serializationObject.normalBias = this.normalBias;
  45473. serializationObject.usePercentageCloserFiltering = this.usePercentageCloserFiltering;
  45474. serializationObject.useContactHardeningShadow = this.useContactHardeningShadow;
  45475. serializationObject.filteringQuality = this.filteringQuality;
  45476. serializationObject.contactHardeningLightSizeUVRatio = this.contactHardeningLightSizeUVRatio;
  45477. serializationObject.renderList = [];
  45478. if (shadowMap.renderList) {
  45479. for (var meshIndex = 0; meshIndex < shadowMap.renderList.length; meshIndex++) {
  45480. var mesh = shadowMap.renderList[meshIndex];
  45481. serializationObject.renderList.push(mesh.id);
  45482. }
  45483. }
  45484. return serializationObject;
  45485. };
  45486. /**
  45487. * Parses a serialized ShadowGenerator and returns a new ShadowGenerator.
  45488. * @param parsedShadowGenerator The JSON object to parse
  45489. * @param scene The scene to create the shadow map for
  45490. * @returns The parsed shadow generator
  45491. */
  45492. ShadowGenerator.Parse = function (parsedShadowGenerator, scene) {
  45493. var light = scene.getLightByID(parsedShadowGenerator.lightId);
  45494. var shadowGenerator = new ShadowGenerator(parsedShadowGenerator.mapSize, light);
  45495. var shadowMap = shadowGenerator.getShadowMap();
  45496. for (var meshIndex = 0; meshIndex < parsedShadowGenerator.renderList.length; meshIndex++) {
  45497. var meshes = scene.getMeshesByID(parsedShadowGenerator.renderList[meshIndex]);
  45498. meshes.forEach(function (mesh) {
  45499. if (!shadowMap) {
  45500. return;
  45501. }
  45502. if (!shadowMap.renderList) {
  45503. shadowMap.renderList = [];
  45504. }
  45505. shadowMap.renderList.push(mesh);
  45506. });
  45507. }
  45508. if (parsedShadowGenerator.usePoissonSampling) {
  45509. shadowGenerator.usePoissonSampling = true;
  45510. }
  45511. else if (parsedShadowGenerator.useExponentialShadowMap) {
  45512. shadowGenerator.useExponentialShadowMap = true;
  45513. }
  45514. else if (parsedShadowGenerator.useBlurExponentialShadowMap) {
  45515. shadowGenerator.useBlurExponentialShadowMap = true;
  45516. }
  45517. else if (parsedShadowGenerator.useCloseExponentialShadowMap) {
  45518. shadowGenerator.useCloseExponentialShadowMap = true;
  45519. }
  45520. else if (parsedShadowGenerator.useBlurCloseExponentialShadowMap) {
  45521. shadowGenerator.useBlurCloseExponentialShadowMap = true;
  45522. }
  45523. else if (parsedShadowGenerator.usePercentageCloserFiltering) {
  45524. shadowGenerator.usePercentageCloserFiltering = true;
  45525. }
  45526. else if (parsedShadowGenerator.useContactHardeningShadow) {
  45527. shadowGenerator.useContactHardeningShadow = true;
  45528. }
  45529. if (parsedShadowGenerator.filteringQuality) {
  45530. shadowGenerator.filteringQuality = parsedShadowGenerator.filteringQuality;
  45531. }
  45532. if (parsedShadowGenerator.contactHardeningLightSizeUVRatio) {
  45533. shadowGenerator.contactHardeningLightSizeUVRatio = parsedShadowGenerator.contactHardeningLightSizeUVRatio;
  45534. }
  45535. // Backward compat
  45536. else if (parsedShadowGenerator.useVarianceShadowMap) {
  45537. shadowGenerator.useExponentialShadowMap = true;
  45538. }
  45539. else if (parsedShadowGenerator.useBlurVarianceShadowMap) {
  45540. shadowGenerator.useBlurExponentialShadowMap = true;
  45541. }
  45542. if (parsedShadowGenerator.depthScale) {
  45543. shadowGenerator.depthScale = parsedShadowGenerator.depthScale;
  45544. }
  45545. if (parsedShadowGenerator.blurScale) {
  45546. shadowGenerator.blurScale = parsedShadowGenerator.blurScale;
  45547. }
  45548. if (parsedShadowGenerator.blurBoxOffset) {
  45549. shadowGenerator.blurBoxOffset = parsedShadowGenerator.blurBoxOffset;
  45550. }
  45551. if (parsedShadowGenerator.useKernelBlur) {
  45552. shadowGenerator.useKernelBlur = parsedShadowGenerator.useKernelBlur;
  45553. }
  45554. if (parsedShadowGenerator.blurKernel) {
  45555. shadowGenerator.blurKernel = parsedShadowGenerator.blurKernel;
  45556. }
  45557. if (parsedShadowGenerator.bias !== undefined) {
  45558. shadowGenerator.bias = parsedShadowGenerator.bias;
  45559. }
  45560. if (parsedShadowGenerator.normalBias !== undefined) {
  45561. shadowGenerator.normalBias = parsedShadowGenerator.normalBias;
  45562. }
  45563. if (parsedShadowGenerator.frustumEdgeFalloff !== undefined) {
  45564. shadowGenerator.frustumEdgeFalloff = parsedShadowGenerator.frustumEdgeFalloff;
  45565. }
  45566. if (parsedShadowGenerator.darkness) {
  45567. shadowGenerator.setDarkness(parsedShadowGenerator.darkness);
  45568. }
  45569. if (parsedShadowGenerator.transparencyShadow) {
  45570. shadowGenerator.setTransparencyShadow(true);
  45571. }
  45572. shadowGenerator.forceBackFacesOnly = parsedShadowGenerator.forceBackFacesOnly;
  45573. return shadowGenerator;
  45574. };
  45575. /**
  45576. * Shadow generator mode None: no filtering applied.
  45577. */
  45578. ShadowGenerator.FILTER_NONE = 0;
  45579. /**
  45580. * Shadow generator mode ESM: Exponential Shadow Mapping.
  45581. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45582. */
  45583. ShadowGenerator.FILTER_EXPONENTIALSHADOWMAP = 1;
  45584. /**
  45585. * Shadow generator mode Poisson Sampling: Percentage Closer Filtering.
  45586. * (Multiple Tap around evenly distributed around the pixel are used to evaluate the shadow strength)
  45587. */
  45588. ShadowGenerator.FILTER_POISSONSAMPLING = 2;
  45589. /**
  45590. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping.
  45591. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45592. */
  45593. ShadowGenerator.FILTER_BLUREXPONENTIALSHADOWMAP = 3;
  45594. /**
  45595. * Shadow generator mode ESM: Exponential Shadow Mapping using the inverse of the exponential preventing
  45596. * edge artifacts on steep falloff.
  45597. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45598. */
  45599. ShadowGenerator.FILTER_CLOSEEXPONENTIALSHADOWMAP = 4;
  45600. /**
  45601. * Shadow generator mode ESM: Blurred Exponential Shadow Mapping using the inverse of the exponential preventing
  45602. * edge artifacts on steep falloff.
  45603. * (http://developer.download.nvidia.com/presentations/2008/GDC/GDC08_SoftShadowMapping.pdf)
  45604. */
  45605. ShadowGenerator.FILTER_BLURCLOSEEXPONENTIALSHADOWMAP = 5;
  45606. /**
  45607. * Shadow generator mode PCF: Percentage Closer Filtering
  45608. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45609. * (https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch11.html)
  45610. */
  45611. ShadowGenerator.FILTER_PCF = 6;
  45612. /**
  45613. * Shadow generator mode PCSS: Percentage Closering Soft Shadow.
  45614. * benefits from Webgl 2 shadow samplers. Fallback to Poisson Sampling in Webgl 1
  45615. * Contact Hardening
  45616. */
  45617. ShadowGenerator.FILTER_PCSS = 7;
  45618. /**
  45619. * Reserved for PCF and PCSS
  45620. * Highest Quality.
  45621. *
  45622. * Execute PCF on a 5*5 kernel improving a lot the shadow aliasing artifacts.
  45623. *
  45624. * Execute PCSS with 32 taps blocker search and 64 taps PCF.
  45625. */
  45626. ShadowGenerator.QUALITY_HIGH = 0;
  45627. /**
  45628. * Reserved for PCF and PCSS
  45629. * Good tradeoff for quality/perf cross devices
  45630. *
  45631. * Execute PCF on a 3*3 kernel.
  45632. *
  45633. * Execute PCSS with 16 taps blocker search and 32 taps PCF.
  45634. */
  45635. ShadowGenerator.QUALITY_MEDIUM = 1;
  45636. /**
  45637. * Reserved for PCF and PCSS
  45638. * The lowest quality but the fastest.
  45639. *
  45640. * Execute PCF on a 1*1 kernel.
  45641. *
  45642. * Execute PCSS with 16 taps blocker search and 16 taps PCF.
  45643. */
  45644. ShadowGenerator.QUALITY_LOW = 2;
  45645. /** @hidden */
  45646. ShadowGenerator._SceneComponentInitialization = function (_) {
  45647. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_15__["_DevTools"].WarnImport("ShadowGeneratorSceneComponent");
  45648. };
  45649. return ShadowGenerator;
  45650. }());
  45651. /***/ }),
  45652. /***/ "./Lights/Shadows/shadowGeneratorSceneComponent.ts":
  45653. /*!*********************************************************!*\
  45654. !*** ./Lights/Shadows/shadowGeneratorSceneComponent.ts ***!
  45655. \*********************************************************/
  45656. /*! exports provided: ShadowGeneratorSceneComponent */
  45657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45658. "use strict";
  45659. __webpack_require__.r(__webpack_exports__);
  45660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return ShadowGeneratorSceneComponent; });
  45661. /* harmony import */ var _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./shadowGenerator */ "./Lights/Shadows/shadowGenerator.ts");
  45662. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  45663. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  45664. // Adds the parser to the scene parsers.
  45665. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR, function (parsedData, scene) {
  45666. // Shadows
  45667. if (parsedData.shadowGenerators !== undefined && parsedData.shadowGenerators !== null) {
  45668. for (var index = 0, cache = parsedData.shadowGenerators.length; index < cache; index++) {
  45669. var parsedShadowGenerator = parsedData.shadowGenerators[index];
  45670. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"].Parse(parsedShadowGenerator, scene);
  45671. // SG would be available on their associated lights
  45672. }
  45673. }
  45674. });
  45675. /**
  45676. * Defines the shadow generator component responsible to manage any shadow generators
  45677. * in a given scene.
  45678. */
  45679. var ShadowGeneratorSceneComponent = /** @class */ (function () {
  45680. /**
  45681. * Creates a new instance of the component for the given scene
  45682. * @param scene Defines the scene to register the component in
  45683. */
  45684. function ShadowGeneratorSceneComponent(scene) {
  45685. /**
  45686. * The component name helpfull to identify the component in the list of scene components.
  45687. */
  45688. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR;
  45689. this.scene = scene;
  45690. }
  45691. /**
  45692. * Registers the component in a given scene
  45693. */
  45694. ShadowGeneratorSceneComponent.prototype.register = function () {
  45695. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_SHADOWGENERATOR, this, this._gatherRenderTargets);
  45696. };
  45697. /**
  45698. * Rebuilds the elements related to this component in case of
  45699. * context lost for instance.
  45700. */
  45701. ShadowGeneratorSceneComponent.prototype.rebuild = function () {
  45702. // Nothing To Do Here.
  45703. };
  45704. /**
  45705. * Serializes the component data to the specified json object
  45706. * @param serializationObject The object to serialize to
  45707. */
  45708. ShadowGeneratorSceneComponent.prototype.serialize = function (serializationObject) {
  45709. // Shadows
  45710. serializationObject.shadowGenerators = [];
  45711. var lights = this.scene.lights;
  45712. for (var _i = 0, lights_1 = lights; _i < lights_1.length; _i++) {
  45713. var light = lights_1[_i];
  45714. var shadowGenerator = light.getShadowGenerator();
  45715. if (shadowGenerator) {
  45716. serializationObject.shadowGenerators.push(shadowGenerator.serialize());
  45717. }
  45718. }
  45719. };
  45720. /**
  45721. * Adds all the element from the container to the scene
  45722. * @param container the container holding the elements
  45723. */
  45724. ShadowGeneratorSceneComponent.prototype.addFromContainer = function (container) {
  45725. // Nothing To Do Here. (directly attached to a light)
  45726. };
  45727. /**
  45728. * Removes all the elements in the container from the scene
  45729. * @param container contains the elements to remove
  45730. */
  45731. ShadowGeneratorSceneComponent.prototype.removeFromContainer = function (container) {
  45732. // Nothing To Do Here. (directly attached to a light)
  45733. };
  45734. /**
  45735. * Rebuilds the elements related to this component in case of
  45736. * context lost for instance.
  45737. */
  45738. ShadowGeneratorSceneComponent.prototype.dispose = function () {
  45739. // Nothing To Do Here.
  45740. };
  45741. ShadowGeneratorSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  45742. // Shadows
  45743. var scene = this.scene;
  45744. if (this.scene.shadowsEnabled) {
  45745. for (var lightIndex = 0; lightIndex < scene.lights.length; lightIndex++) {
  45746. var light = scene.lights[lightIndex];
  45747. var shadowGenerator = light.getShadowGenerator();
  45748. if (light.isEnabled() && light.shadowEnabled && shadowGenerator) {
  45749. var shadowMap = (shadowGenerator.getShadowMap());
  45750. if (scene.textures.indexOf(shadowMap) !== -1) {
  45751. renderTargets.push(shadowMap);
  45752. }
  45753. }
  45754. }
  45755. }
  45756. };
  45757. return ShadowGeneratorSceneComponent;
  45758. }());
  45759. _shadowGenerator__WEBPACK_IMPORTED_MODULE_0__["ShadowGenerator"]._SceneComponentInitialization = function (scene) {
  45760. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_SHADOWGENERATOR);
  45761. if (!component) {
  45762. component = new ShadowGeneratorSceneComponent(scene);
  45763. scene._addComponent(component);
  45764. }
  45765. };
  45766. /***/ }),
  45767. /***/ "./Lights/directionalLight.ts":
  45768. /*!************************************!*\
  45769. !*** ./Lights/directionalLight.ts ***!
  45770. \************************************/
  45771. /*! exports provided: DirectionalLight */
  45772. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  45773. "use strict";
  45774. __webpack_require__.r(__webpack_exports__);
  45775. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return DirectionalLight; });
  45776. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  45777. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  45778. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  45779. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  45780. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  45781. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  45782. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_1", function (name, scene) {
  45783. return function () { return new DirectionalLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  45784. });
  45785. /**
  45786. * A directional light is defined by a direction (what a surprise!).
  45787. * The light is emitted from everywhere in the specified direction, and has an infinite range.
  45788. * 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.
  45789. * Documentation: https://doc.babylonjs.com/babylon101/lights
  45790. */
  45791. var DirectionalLight = /** @class */ (function (_super) {
  45792. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DirectionalLight, _super);
  45793. /**
  45794. * Creates a DirectionalLight object in the scene, oriented towards the passed direction (Vector3).
  45795. * The directional light is emitted from everywhere in the given direction.
  45796. * It can cast shadows.
  45797. * Documentation : https://doc.babylonjs.com/babylon101/lights
  45798. * @param name The friendly name of the light
  45799. * @param direction The direction of the light
  45800. * @param scene The scene the light belongs to
  45801. */
  45802. function DirectionalLight(name, direction, scene) {
  45803. var _this = _super.call(this, name, scene) || this;
  45804. _this._shadowFrustumSize = 0;
  45805. _this._shadowOrthoScale = 0.1;
  45806. /**
  45807. * Automatically compute the projection matrix to best fit (including all the casters)
  45808. * on each frame.
  45809. */
  45810. _this.autoUpdateExtends = true;
  45811. // Cache
  45812. _this._orthoLeft = Number.MAX_VALUE;
  45813. _this._orthoRight = Number.MIN_VALUE;
  45814. _this._orthoTop = Number.MIN_VALUE;
  45815. _this._orthoBottom = Number.MAX_VALUE;
  45816. _this.position = direction.scale(-1.0);
  45817. _this.direction = direction;
  45818. return _this;
  45819. }
  45820. Object.defineProperty(DirectionalLight.prototype, "shadowFrustumSize", {
  45821. /**
  45822. * Fix frustum size for the shadow generation. This is disabled if the value is 0.
  45823. */
  45824. get: function () {
  45825. return this._shadowFrustumSize;
  45826. },
  45827. /**
  45828. * Specifies a fix frustum size for the shadow generation.
  45829. */
  45830. set: function (value) {
  45831. this._shadowFrustumSize = value;
  45832. this.forceProjectionMatrixCompute();
  45833. },
  45834. enumerable: true,
  45835. configurable: true
  45836. });
  45837. Object.defineProperty(DirectionalLight.prototype, "shadowOrthoScale", {
  45838. /**
  45839. * Gets the shadow projection scale against the optimal computed one.
  45840. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45841. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45842. */
  45843. get: function () {
  45844. return this._shadowOrthoScale;
  45845. },
  45846. /**
  45847. * Sets the shadow projection scale against the optimal computed one.
  45848. * 0.1 by default which means that the projection window is increase by 10% from the optimal size.
  45849. * This does not impact in fixed frustum size (shadowFrustumSize being set)
  45850. */
  45851. set: function (value) {
  45852. this._shadowOrthoScale = value;
  45853. this.forceProjectionMatrixCompute();
  45854. },
  45855. enumerable: true,
  45856. configurable: true
  45857. });
  45858. /**
  45859. * Returns the string "DirectionalLight".
  45860. * @return The class name
  45861. */
  45862. DirectionalLight.prototype.getClassName = function () {
  45863. return "DirectionalLight";
  45864. };
  45865. /**
  45866. * Returns the integer 1.
  45867. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  45868. */
  45869. DirectionalLight.prototype.getTypeID = function () {
  45870. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_DIRECTIONALLIGHT;
  45871. };
  45872. /**
  45873. * Sets the passed matrix "matrix" as projection matrix for the shadows cast by the light according to the passed view matrix.
  45874. * Returns the DirectionalLight Shadow projection matrix.
  45875. */
  45876. DirectionalLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45877. if (this.shadowFrustumSize > 0) {
  45878. this._setDefaultFixedFrustumShadowProjectionMatrix(matrix);
  45879. }
  45880. else {
  45881. this._setDefaultAutoExtendShadowProjectionMatrix(matrix, viewMatrix, renderList);
  45882. }
  45883. };
  45884. /**
  45885. * Sets the passed matrix "matrix" as fixed frustum projection matrix for the shadows cast by the light according to the passed view matrix.
  45886. * Returns the DirectionalLight Shadow projection matrix.
  45887. */
  45888. DirectionalLight.prototype._setDefaultFixedFrustumShadowProjectionMatrix = function (matrix) {
  45889. var activeCamera = this.getScene().activeCamera;
  45890. if (!activeCamera) {
  45891. return;
  45892. }
  45893. _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);
  45894. };
  45895. /**
  45896. * Sets the passed matrix "matrix" as auto extend projection matrix for the shadows cast by the light according to the passed view matrix.
  45897. * Returns the DirectionalLight Shadow projection matrix.
  45898. */
  45899. DirectionalLight.prototype._setDefaultAutoExtendShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  45900. var activeCamera = this.getScene().activeCamera;
  45901. if (!activeCamera) {
  45902. return;
  45903. }
  45904. // Check extends
  45905. if (this.autoUpdateExtends || this._orthoLeft === Number.MAX_VALUE) {
  45906. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  45907. this._orthoLeft = Number.MAX_VALUE;
  45908. this._orthoRight = Number.MIN_VALUE;
  45909. this._orthoTop = Number.MIN_VALUE;
  45910. this._orthoBottom = Number.MAX_VALUE;
  45911. for (var meshIndex = 0; meshIndex < renderList.length; meshIndex++) {
  45912. var mesh = renderList[meshIndex];
  45913. if (!mesh) {
  45914. continue;
  45915. }
  45916. var boundingInfo = mesh.getBoundingInfo();
  45917. var boundingBox = boundingInfo.boundingBox;
  45918. for (var index = 0; index < boundingBox.vectorsWorld.length; index++) {
  45919. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(boundingBox.vectorsWorld[index], viewMatrix, tempVector3);
  45920. if (tempVector3.x < this._orthoLeft) {
  45921. this._orthoLeft = tempVector3.x;
  45922. }
  45923. if (tempVector3.y < this._orthoBottom) {
  45924. this._orthoBottom = tempVector3.y;
  45925. }
  45926. if (tempVector3.x > this._orthoRight) {
  45927. this._orthoRight = tempVector3.x;
  45928. }
  45929. if (tempVector3.y > this._orthoTop) {
  45930. this._orthoTop = tempVector3.y;
  45931. }
  45932. }
  45933. }
  45934. }
  45935. var xOffset = this._orthoRight - this._orthoLeft;
  45936. var yOffset = this._orthoTop - this._orthoBottom;
  45937. _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);
  45938. };
  45939. DirectionalLight.prototype._buildUniformLayout = function () {
  45940. this._uniformBuffer.addUniform("vLightData", 4);
  45941. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  45942. this._uniformBuffer.addUniform("vLightSpecular", 3);
  45943. this._uniformBuffer.addUniform("shadowsInfo", 3);
  45944. this._uniformBuffer.addUniform("depthValues", 2);
  45945. this._uniformBuffer.create();
  45946. };
  45947. /**
  45948. * Sets the passed Effect object with the DirectionalLight transformed position (or position if not parented) and the passed name.
  45949. * @param effect The effect to update
  45950. * @param lightIndex The index of the light in the effect to update
  45951. * @returns The directional light
  45952. */
  45953. DirectionalLight.prototype.transferToEffect = function (effect, lightIndex) {
  45954. if (this.computeTransformedInformation()) {
  45955. this._uniformBuffer.updateFloat4("vLightData", this.transformedDirection.x, this.transformedDirection.y, this.transformedDirection.z, 1, lightIndex);
  45956. return this;
  45957. }
  45958. this._uniformBuffer.updateFloat4("vLightData", this.direction.x, this.direction.y, this.direction.z, 1, lightIndex);
  45959. return this;
  45960. };
  45961. /**
  45962. * Gets the minZ used for shadow according to both the scene and the light.
  45963. *
  45964. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45965. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45966. * @param activeCamera The camera we are returning the min for
  45967. * @returns the depth min z
  45968. */
  45969. DirectionalLight.prototype.getDepthMinZ = function (activeCamera) {
  45970. return 1;
  45971. };
  45972. /**
  45973. * Gets the maxZ used for shadow according to both the scene and the light.
  45974. *
  45975. * Values are fixed on directional lights as it relies on an ortho projection hence the need to convert being
  45976. * -1 and 1 to 0 and 1 doing (depth + min) / (min + max) -> (depth + 1) / (1 + 1) -> (depth * 0.5) + 0.5.
  45977. * @param activeCamera The camera we are returning the max for
  45978. * @returns the depth max z
  45979. */
  45980. DirectionalLight.prototype.getDepthMaxZ = function (activeCamera) {
  45981. return 1;
  45982. };
  45983. /**
  45984. * Prepares the list of defines specific to the light type.
  45985. * @param defines the list of defines
  45986. * @param lightIndex defines the index of the light for the effect
  45987. */
  45988. DirectionalLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  45989. defines["DIRLIGHT" + lightIndex] = true;
  45990. };
  45991. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45992. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45993. ], DirectionalLight.prototype, "shadowFrustumSize", null);
  45994. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45995. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45996. ], DirectionalLight.prototype, "shadowOrthoScale", null);
  45997. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  45998. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  45999. ], DirectionalLight.prototype, "autoUpdateExtends", void 0);
  46000. return DirectionalLight;
  46001. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  46002. /***/ }),
  46003. /***/ "./Lights/hemisphericLight.ts":
  46004. /*!************************************!*\
  46005. !*** ./Lights/hemisphericLight.ts ***!
  46006. \************************************/
  46007. /*! exports provided: HemisphericLight */
  46008. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46009. "use strict";
  46010. __webpack_require__.r(__webpack_exports__);
  46011. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return HemisphericLight; });
  46012. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46013. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46014. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46015. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46016. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46017. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_3", function (name, scene) {
  46018. return function () { return new HemisphericLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46019. });
  46020. /**
  46021. * The HemisphericLight simulates the ambient environment light,
  46022. * so the passed direction is the light reflection direction, not the incoming direction.
  46023. */
  46024. var HemisphericLight = /** @class */ (function (_super) {
  46025. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HemisphericLight, _super);
  46026. /**
  46027. * Creates a HemisphericLight object in the scene according to the passed direction (Vector3).
  46028. * The HemisphericLight simulates the ambient environment light, so the passed direction is the light reflection direction, not the incoming direction.
  46029. * The HemisphericLight can't cast shadows.
  46030. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46031. * @param name The friendly name of the light
  46032. * @param direction The direction of the light reflection
  46033. * @param scene The scene the light belongs to
  46034. */
  46035. function HemisphericLight(name, direction, scene) {
  46036. var _this = _super.call(this, name, scene) || this;
  46037. /**
  46038. * The groundColor is the light in the opposite direction to the one specified during creation.
  46039. * 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.
  46040. */
  46041. _this.groundColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0.0, 0.0, 0.0);
  46042. _this.direction = direction || _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  46043. return _this;
  46044. }
  46045. HemisphericLight.prototype._buildUniformLayout = function () {
  46046. this._uniformBuffer.addUniform("vLightData", 4);
  46047. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  46048. this._uniformBuffer.addUniform("vLightSpecular", 3);
  46049. this._uniformBuffer.addUniform("vLightGround", 3);
  46050. this._uniformBuffer.addUniform("shadowsInfo", 3);
  46051. this._uniformBuffer.addUniform("depthValues", 2);
  46052. this._uniformBuffer.create();
  46053. };
  46054. /**
  46055. * Returns the string "HemisphericLight".
  46056. * @return The class name
  46057. */
  46058. HemisphericLight.prototype.getClassName = function () {
  46059. return "HemisphericLight";
  46060. };
  46061. /**
  46062. * Sets the HemisphericLight direction towards the passed target (Vector3).
  46063. * Returns the updated direction.
  46064. * @param target The target the direction should point to
  46065. * @return The computed direction
  46066. */
  46067. HemisphericLight.prototype.setDirectionToTarget = function (target) {
  46068. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero()));
  46069. return this.direction;
  46070. };
  46071. /**
  46072. * Returns the shadow generator associated to the light.
  46073. * @returns Always null for hemispheric lights because it does not support shadows.
  46074. */
  46075. HemisphericLight.prototype.getShadowGenerator = function () {
  46076. return null;
  46077. };
  46078. /**
  46079. * Sets the passed Effect object with the HemisphericLight normalized direction and color and the passed name (string).
  46080. * @param effect The effect to update
  46081. * @param lightIndex The index of the light in the effect to update
  46082. * @returns The hemispheric light
  46083. */
  46084. HemisphericLight.prototype.transferToEffect = function (effect, lightIndex) {
  46085. var normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  46086. this._uniformBuffer.updateFloat4("vLightData", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, 0.0, lightIndex);
  46087. this._uniformBuffer.updateColor3("vLightGround", this.groundColor.scale(this.intensity), lightIndex);
  46088. return this;
  46089. };
  46090. /**
  46091. * Computes the world matrix of the node
  46092. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  46093. * @param useWasUpdatedFlag defines a reserved property
  46094. * @returns the world matrix
  46095. */
  46096. HemisphericLight.prototype.computeWorldMatrix = function () {
  46097. if (!this._worldMatrix) {
  46098. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  46099. }
  46100. return this._worldMatrix;
  46101. };
  46102. /**
  46103. * Returns the integer 3.
  46104. * @return The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46105. */
  46106. HemisphericLight.prototype.getTypeID = function () {
  46107. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_HEMISPHERICLIGHT;
  46108. };
  46109. /**
  46110. * Prepares the list of defines specific to the light type.
  46111. * @param defines the list of defines
  46112. * @param lightIndex defines the index of the light for the effect
  46113. */
  46114. HemisphericLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  46115. defines["HEMILIGHT" + lightIndex] = true;
  46116. };
  46117. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46118. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46119. ], HemisphericLight.prototype, "groundColor", void 0);
  46120. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46121. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  46122. ], HemisphericLight.prototype, "direction", void 0);
  46123. return HemisphericLight;
  46124. }(_light__WEBPACK_IMPORTED_MODULE_4__["Light"]));
  46125. /***/ }),
  46126. /***/ "./Lights/index.ts":
  46127. /*!*************************!*\
  46128. !*** ./Lights/index.ts ***!
  46129. \*************************/
  46130. /*! exports provided: Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, ShadowGenerator, ShadowGeneratorSceneComponent */
  46131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46132. "use strict";
  46133. __webpack_require__.r(__webpack_exports__);
  46134. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46135. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _light__WEBPACK_IMPORTED_MODULE_0__["Light"]; });
  46136. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46137. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _shadowLight__WEBPACK_IMPORTED_MODULE_1__["ShadowLight"]; });
  46138. /* harmony import */ var _Shadows_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Shadows/index */ "./Lights/Shadows/index.ts");
  46139. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGenerator"]; });
  46140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Shadows_index__WEBPACK_IMPORTED_MODULE_2__["ShadowGeneratorSceneComponent"]; });
  46141. /* harmony import */ var _directionalLight__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./directionalLight */ "./Lights/directionalLight.ts");
  46142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _directionalLight__WEBPACK_IMPORTED_MODULE_3__["DirectionalLight"]; });
  46143. /* harmony import */ var _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hemisphericLight */ "./Lights/hemisphericLight.ts");
  46144. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _hemisphericLight__WEBPACK_IMPORTED_MODULE_4__["HemisphericLight"]; });
  46145. /* harmony import */ var _pointLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./pointLight */ "./Lights/pointLight.ts");
  46146. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _pointLight__WEBPACK_IMPORTED_MODULE_5__["PointLight"]; });
  46147. /* harmony import */ var _spotLight__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./spotLight */ "./Lights/spotLight.ts");
  46148. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _spotLight__WEBPACK_IMPORTED_MODULE_6__["SpotLight"]; });
  46149. /***/ }),
  46150. /***/ "./Lights/light.ts":
  46151. /*!*************************!*\
  46152. !*** ./Lights/light.ts ***!
  46153. \*************************/
  46154. /*! exports provided: Light */
  46155. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46156. "use strict";
  46157. __webpack_require__.r(__webpack_exports__);
  46158. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return Light; });
  46159. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46160. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46161. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46162. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46163. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  46164. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  46165. /**
  46166. * Base class of all the lights in Babylon. It groups all the generic information about lights.
  46167. * Lights are used, as you would expect, to affect how meshes are seen, in terms of both illumination and colour.
  46168. * 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.
  46169. */
  46170. var Light = /** @class */ (function (_super) {
  46171. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Light, _super);
  46172. /**
  46173. * Creates a Light object in the scene.
  46174. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46175. * @param name The firendly name of the light
  46176. * @param scene The scene the light belongs too
  46177. */
  46178. function Light(name, scene) {
  46179. var _this = _super.call(this, name, scene) || this;
  46180. /**
  46181. * Diffuse gives the basic color to an object.
  46182. */
  46183. _this.diffuse = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46184. /**
  46185. * Specular produces a highlight color on an object.
  46186. * Note: This is note affecting PBR materials.
  46187. */
  46188. _this.specular = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](1.0, 1.0, 1.0);
  46189. /**
  46190. * Defines the falloff type for this light. This lets overrriding how punctual light are
  46191. * falling off base on range or angle.
  46192. * This can be set to any values in Light.FALLOFF_x.
  46193. *
  46194. * Note: This is only useful for PBR Materials at the moment. This could be extended if required to
  46195. * other types of materials.
  46196. */
  46197. _this.falloffType = Light.FALLOFF_DEFAULT;
  46198. /**
  46199. * Strength of the light.
  46200. * Note: By default it is define in the framework own unit.
  46201. * Note: In PBR materials the intensityMode can be use to chose what unit the intensity is defined in.
  46202. */
  46203. _this.intensity = 1.0;
  46204. _this._range = Number.MAX_VALUE;
  46205. _this._inverseSquaredRange = 0;
  46206. /**
  46207. * Cached photometric scale default to 1.0 as the automatic intensity mode defaults to 1.0 for every type
  46208. * of light.
  46209. */
  46210. _this._photometricScale = 1.0;
  46211. _this._intensityMode = Light.INTENSITYMODE_AUTOMATIC;
  46212. _this._radius = 0.00001;
  46213. /**
  46214. * Defines the rendering priority of the lights. It can help in case of fallback or number of lights
  46215. * exceeding the number allowed of the materials.
  46216. */
  46217. _this.renderPriority = 0;
  46218. _this._shadowEnabled = true;
  46219. _this._excludeWithLayerMask = 0;
  46220. _this._includeOnlyWithLayerMask = 0;
  46221. _this._lightmapMode = 0;
  46222. /**
  46223. * @hidden Internal use only.
  46224. */
  46225. _this._excludedMeshesIds = new Array();
  46226. /**
  46227. * @hidden Internal use only.
  46228. */
  46229. _this._includedOnlyMeshesIds = new Array();
  46230. /** @hidden */
  46231. _this._isLight = true;
  46232. _this.getScene().addLight(_this);
  46233. _this._uniformBuffer = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_4__["UniformBuffer"](_this.getScene().getEngine());
  46234. _this._buildUniformLayout();
  46235. _this.includedOnlyMeshes = new Array();
  46236. _this.excludedMeshes = new Array();
  46237. _this._resyncMeshes();
  46238. return _this;
  46239. }
  46240. Object.defineProperty(Light.prototype, "range", {
  46241. /**
  46242. * Defines how far from the source the light is impacting in scene units.
  46243. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46244. */
  46245. get: function () {
  46246. return this._range;
  46247. },
  46248. /**
  46249. * Defines how far from the source the light is impacting in scene units.
  46250. * Note: Unused in PBR material as the distance light falloff is defined following the inverse squared falloff.
  46251. */
  46252. set: function (value) {
  46253. this._range = value;
  46254. this._inverseSquaredRange = 1.0 / (this.range * this.range);
  46255. },
  46256. enumerable: true,
  46257. configurable: true
  46258. });
  46259. Object.defineProperty(Light.prototype, "intensityMode", {
  46260. /**
  46261. * Gets the photometric scale used to interpret the intensity.
  46262. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46263. */
  46264. get: function () {
  46265. return this._intensityMode;
  46266. },
  46267. /**
  46268. * Sets the photometric scale used to interpret the intensity.
  46269. * This is only relevant with PBR Materials where the light intensity can be defined in a physical way.
  46270. */
  46271. set: function (value) {
  46272. this._intensityMode = value;
  46273. this._computePhotometricScale();
  46274. },
  46275. enumerable: true,
  46276. configurable: true
  46277. });
  46278. Object.defineProperty(Light.prototype, "radius", {
  46279. /**
  46280. * Gets the light radius used by PBR Materials to simulate soft area lights.
  46281. */
  46282. get: function () {
  46283. return this._radius;
  46284. },
  46285. /**
  46286. * sets the light radius used by PBR Materials to simulate soft area lights.
  46287. */
  46288. set: function (value) {
  46289. this._radius = value;
  46290. this._computePhotometricScale();
  46291. },
  46292. enumerable: true,
  46293. configurable: true
  46294. });
  46295. Object.defineProperty(Light.prototype, "shadowEnabled", {
  46296. /**
  46297. * Gets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46298. * the current shadow generator.
  46299. */
  46300. get: function () {
  46301. return this._shadowEnabled;
  46302. },
  46303. /**
  46304. * Sets wether or not the shadows are enabled for this light. This can help turning off/on shadow without detaching
  46305. * the current shadow generator.
  46306. */
  46307. set: function (value) {
  46308. if (this._shadowEnabled === value) {
  46309. return;
  46310. }
  46311. this._shadowEnabled = value;
  46312. this._markMeshesAsLightDirty();
  46313. },
  46314. enumerable: true,
  46315. configurable: true
  46316. });
  46317. Object.defineProperty(Light.prototype, "includedOnlyMeshes", {
  46318. /**
  46319. * Gets the only meshes impacted by this light.
  46320. */
  46321. get: function () {
  46322. return this._includedOnlyMeshes;
  46323. },
  46324. /**
  46325. * Sets the only meshes impacted by this light.
  46326. */
  46327. set: function (value) {
  46328. this._includedOnlyMeshes = value;
  46329. this._hookArrayForIncludedOnly(value);
  46330. },
  46331. enumerable: true,
  46332. configurable: true
  46333. });
  46334. Object.defineProperty(Light.prototype, "excludedMeshes", {
  46335. /**
  46336. * Gets the meshes not impacted by this light.
  46337. */
  46338. get: function () {
  46339. return this._excludedMeshes;
  46340. },
  46341. /**
  46342. * Sets the meshes not impacted by this light.
  46343. */
  46344. set: function (value) {
  46345. this._excludedMeshes = value;
  46346. this._hookArrayForExcluded(value);
  46347. },
  46348. enumerable: true,
  46349. configurable: true
  46350. });
  46351. Object.defineProperty(Light.prototype, "excludeWithLayerMask", {
  46352. /**
  46353. * Gets the layer id use to find what meshes are not impacted by the light.
  46354. * Inactive if 0
  46355. */
  46356. get: function () {
  46357. return this._excludeWithLayerMask;
  46358. },
  46359. /**
  46360. * Sets the layer id use to find what meshes are not impacted by the light.
  46361. * Inactive if 0
  46362. */
  46363. set: function (value) {
  46364. this._excludeWithLayerMask = value;
  46365. this._resyncMeshes();
  46366. },
  46367. enumerable: true,
  46368. configurable: true
  46369. });
  46370. Object.defineProperty(Light.prototype, "includeOnlyWithLayerMask", {
  46371. /**
  46372. * Gets the layer id use to find what meshes are impacted by the light.
  46373. * Inactive if 0
  46374. */
  46375. get: function () {
  46376. return this._includeOnlyWithLayerMask;
  46377. },
  46378. /**
  46379. * Sets the layer id use to find what meshes are impacted by the light.
  46380. * Inactive if 0
  46381. */
  46382. set: function (value) {
  46383. this._includeOnlyWithLayerMask = value;
  46384. this._resyncMeshes();
  46385. },
  46386. enumerable: true,
  46387. configurable: true
  46388. });
  46389. Object.defineProperty(Light.prototype, "lightmapMode", {
  46390. /**
  46391. * Gets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46392. */
  46393. get: function () {
  46394. return this._lightmapMode;
  46395. },
  46396. /**
  46397. * Sets the lightmap mode of this light (should be one of the constants defined by Light.LIGHTMAP_x)
  46398. */
  46399. set: function (value) {
  46400. if (this._lightmapMode === value) {
  46401. return;
  46402. }
  46403. this._lightmapMode = value;
  46404. this._markMeshesAsLightDirty();
  46405. },
  46406. enumerable: true,
  46407. configurable: true
  46408. });
  46409. /**
  46410. * Returns the string "Light".
  46411. * @returns the class name
  46412. */
  46413. Light.prototype.getClassName = function () {
  46414. return "Light";
  46415. };
  46416. /**
  46417. * Converts the light information to a readable string for debug purpose.
  46418. * @param fullDetails Supports for multiple levels of logging within scene loading
  46419. * @returns the human readable light info
  46420. */
  46421. Light.prototype.toString = function (fullDetails) {
  46422. var ret = "Name: " + this.name;
  46423. ret += ", type: " + (["Point", "Directional", "Spot", "Hemispheric"])[this.getTypeID()];
  46424. if (this.animations) {
  46425. for (var i = 0; i < this.animations.length; i++) {
  46426. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  46427. }
  46428. }
  46429. if (fullDetails) {
  46430. }
  46431. return ret;
  46432. };
  46433. /** @hidden */
  46434. Light.prototype._syncParentEnabledState = function () {
  46435. _super.prototype._syncParentEnabledState.call(this);
  46436. this._resyncMeshes();
  46437. };
  46438. /**
  46439. * Set the enabled state of this node.
  46440. * @param value - the new enabled state
  46441. */
  46442. Light.prototype.setEnabled = function (value) {
  46443. _super.prototype.setEnabled.call(this, value);
  46444. this._resyncMeshes();
  46445. };
  46446. /**
  46447. * Returns the Light associated shadow generator if any.
  46448. * @return the associated shadow generator.
  46449. */
  46450. Light.prototype.getShadowGenerator = function () {
  46451. return this._shadowGenerator;
  46452. };
  46453. /**
  46454. * Returns a Vector3, the absolute light position in the World.
  46455. * @returns the world space position of the light
  46456. */
  46457. Light.prototype.getAbsolutePosition = function () {
  46458. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  46459. };
  46460. /**
  46461. * Specifies if the light will affect the passed mesh.
  46462. * @param mesh The mesh to test against the light
  46463. * @return true the mesh is affected otherwise, false.
  46464. */
  46465. Light.prototype.canAffectMesh = function (mesh) {
  46466. if (!mesh) {
  46467. return true;
  46468. }
  46469. if (this.includedOnlyMeshes && this.includedOnlyMeshes.length > 0 && this.includedOnlyMeshes.indexOf(mesh) === -1) {
  46470. return false;
  46471. }
  46472. if (this.excludedMeshes && this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  46473. return false;
  46474. }
  46475. if (this.includeOnlyWithLayerMask !== 0 && (this.includeOnlyWithLayerMask & mesh.layerMask) === 0) {
  46476. return false;
  46477. }
  46478. if (this.excludeWithLayerMask !== 0 && this.excludeWithLayerMask & mesh.layerMask) {
  46479. return false;
  46480. }
  46481. return true;
  46482. };
  46483. /**
  46484. * Sort function to order lights for rendering.
  46485. * @param a First Light object to compare to second.
  46486. * @param b Second Light object to compare first.
  46487. * @return -1 to reduce's a's index relative to be, 0 for no change, 1 to increase a's index relative to b.
  46488. */
  46489. Light.CompareLightsPriority = function (a, b) {
  46490. //shadow-casting lights have priority over non-shadow-casting lights
  46491. //the renderPrioirty is a secondary sort criterion
  46492. if (a.shadowEnabled !== b.shadowEnabled) {
  46493. return (b.shadowEnabled ? 1 : 0) - (a.shadowEnabled ? 1 : 0);
  46494. }
  46495. return b.renderPriority - a.renderPriority;
  46496. };
  46497. /**
  46498. * Releases resources associated with this node.
  46499. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  46500. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  46501. */
  46502. Light.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  46503. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  46504. if (this._shadowGenerator) {
  46505. this._shadowGenerator.dispose();
  46506. this._shadowGenerator = null;
  46507. }
  46508. // Animations
  46509. this.getScene().stopAnimation(this);
  46510. // Remove from meshes
  46511. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46512. var mesh = _a[_i];
  46513. mesh._removeLightSource(this);
  46514. }
  46515. this._uniformBuffer.dispose();
  46516. // Remove from scene
  46517. this.getScene().removeLight(this);
  46518. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  46519. };
  46520. /**
  46521. * Returns the light type ID (integer).
  46522. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46523. */
  46524. Light.prototype.getTypeID = function () {
  46525. return 0;
  46526. };
  46527. /**
  46528. * Returns the intensity scaled by the Photometric Scale according to the light type and intensity mode.
  46529. * @returns the scaled intensity in intensity mode unit
  46530. */
  46531. Light.prototype.getScaledIntensity = function () {
  46532. return this._photometricScale * this.intensity;
  46533. };
  46534. /**
  46535. * Returns a new Light object, named "name", from the current one.
  46536. * @param name The name of the cloned light
  46537. * @returns the new created light
  46538. */
  46539. Light.prototype.clone = function (name) {
  46540. var constructor = Light.GetConstructorFromName(this.getTypeID(), name, this.getScene());
  46541. if (!constructor) {
  46542. return null;
  46543. }
  46544. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(constructor, this);
  46545. };
  46546. /**
  46547. * Serializes the current light into a Serialization object.
  46548. * @returns the serialized object.
  46549. */
  46550. Light.prototype.serialize = function () {
  46551. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  46552. // Type
  46553. serializationObject.type = this.getTypeID();
  46554. // Parent
  46555. if (this.parent) {
  46556. serializationObject.parentId = this.parent.id;
  46557. }
  46558. // Inclusion / exclusions
  46559. if (this.excludedMeshes.length > 0) {
  46560. serializationObject.excludedMeshesIds = [];
  46561. this.excludedMeshes.forEach(function (mesh) {
  46562. serializationObject.excludedMeshesIds.push(mesh.id);
  46563. });
  46564. }
  46565. if (this.includedOnlyMeshes.length > 0) {
  46566. serializationObject.includedOnlyMeshesIds = [];
  46567. this.includedOnlyMeshes.forEach(function (mesh) {
  46568. serializationObject.includedOnlyMeshesIds.push(mesh.id);
  46569. });
  46570. }
  46571. // Animations
  46572. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  46573. serializationObject.ranges = this.serializeAnimationRanges();
  46574. return serializationObject;
  46575. };
  46576. /**
  46577. * Creates a new typed light from the passed type (integer) : point light = 0, directional light = 1, spot light = 2, hemispheric light = 3.
  46578. * This new light is named "name" and added to the passed scene.
  46579. * @param type Type according to the types available in Light.LIGHTTYPEID_x
  46580. * @param name The friendly name of the light
  46581. * @param scene The scene the new light will belong to
  46582. * @returns the constructor function
  46583. */
  46584. Light.GetConstructorFromName = function (type, name, scene) {
  46585. var constructorFunc = _node__WEBPACK_IMPORTED_MODULE_3__["Node"].Construct("Light_Type_" + type, name, scene);
  46586. if (constructorFunc) {
  46587. return constructorFunc;
  46588. }
  46589. // Default to no light for none present once.
  46590. return null;
  46591. };
  46592. /**
  46593. * Parses the passed "parsedLight" and returns a new instanced Light from this parsing.
  46594. * @param parsedLight The JSON representation of the light
  46595. * @param scene The scene to create the parsed light in
  46596. * @returns the created light after parsing
  46597. */
  46598. Light.Parse = function (parsedLight, scene) {
  46599. var constructor = Light.GetConstructorFromName(parsedLight.type, parsedLight.name, scene);
  46600. if (!constructor) {
  46601. return null;
  46602. }
  46603. var light = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(constructor, parsedLight, scene);
  46604. // Inclusion / exclusions
  46605. if (parsedLight.excludedMeshesIds) {
  46606. light._excludedMeshesIds = parsedLight.excludedMeshesIds;
  46607. }
  46608. if (parsedLight.includedOnlyMeshesIds) {
  46609. light._includedOnlyMeshesIds = parsedLight.includedOnlyMeshesIds;
  46610. }
  46611. // Parent
  46612. if (parsedLight.parentId) {
  46613. light._waitingParentId = parsedLight.parentId;
  46614. }
  46615. // Animations
  46616. if (parsedLight.animations) {
  46617. for (var animationIndex = 0; animationIndex < parsedLight.animations.length; animationIndex++) {
  46618. var parsedAnimation = parsedLight.animations[animationIndex];
  46619. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  46620. if (internalClass) {
  46621. light.animations.push(internalClass.Parse(parsedAnimation));
  46622. }
  46623. }
  46624. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].ParseAnimationRanges(light, parsedLight, scene);
  46625. }
  46626. if (parsedLight.autoAnimate) {
  46627. scene.beginAnimation(light, parsedLight.autoAnimateFrom, parsedLight.autoAnimateTo, parsedLight.autoAnimateLoop, parsedLight.autoAnimateSpeed || 1.0);
  46628. }
  46629. return light;
  46630. };
  46631. Light.prototype._hookArrayForExcluded = function (array) {
  46632. var _this = this;
  46633. var oldPush = array.push;
  46634. array.push = function () {
  46635. var items = [];
  46636. for (var _i = 0; _i < arguments.length; _i++) {
  46637. items[_i] = arguments[_i];
  46638. }
  46639. var result = oldPush.apply(array, items);
  46640. for (var _a = 0, items_1 = items; _a < items_1.length; _a++) {
  46641. var item = items_1[_a];
  46642. item._resyncLighSource(_this);
  46643. }
  46644. return result;
  46645. };
  46646. var oldSplice = array.splice;
  46647. array.splice = function (index, deleteCount) {
  46648. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46649. for (var _i = 0, deleted_1 = deleted; _i < deleted_1.length; _i++) {
  46650. var item = deleted_1[_i];
  46651. item._resyncLighSource(_this);
  46652. }
  46653. return deleted;
  46654. };
  46655. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  46656. var item = array_1[_i];
  46657. item._resyncLighSource(this);
  46658. }
  46659. };
  46660. Light.prototype._hookArrayForIncludedOnly = function (array) {
  46661. var _this = this;
  46662. var oldPush = array.push;
  46663. array.push = function () {
  46664. var items = [];
  46665. for (var _i = 0; _i < arguments.length; _i++) {
  46666. items[_i] = arguments[_i];
  46667. }
  46668. var result = oldPush.apply(array, items);
  46669. _this._resyncMeshes();
  46670. return result;
  46671. };
  46672. var oldSplice = array.splice;
  46673. array.splice = function (index, deleteCount) {
  46674. var deleted = oldSplice.apply(array, [index, deleteCount]);
  46675. _this._resyncMeshes();
  46676. return deleted;
  46677. };
  46678. this._resyncMeshes();
  46679. };
  46680. Light.prototype._resyncMeshes = function () {
  46681. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46682. var mesh = _a[_i];
  46683. mesh._resyncLighSource(this);
  46684. }
  46685. };
  46686. /**
  46687. * Forces the meshes to update their light related information in their rendering used effects
  46688. * @hidden Internal Use Only
  46689. */
  46690. Light.prototype._markMeshesAsLightDirty = function () {
  46691. for (var _i = 0, _a = this.getScene().meshes; _i < _a.length; _i++) {
  46692. var mesh = _a[_i];
  46693. if (mesh._lightSources.indexOf(this) !== -1) {
  46694. mesh._markSubMeshesAsLightDirty();
  46695. }
  46696. }
  46697. };
  46698. /**
  46699. * Recomputes the cached photometric scale if needed.
  46700. */
  46701. Light.prototype._computePhotometricScale = function () {
  46702. this._photometricScale = this._getPhotometricScale();
  46703. this.getScene().resetCachedMaterial();
  46704. };
  46705. /**
  46706. * Returns the Photometric Scale according to the light type and intensity mode.
  46707. */
  46708. Light.prototype._getPhotometricScale = function () {
  46709. var photometricScale = 0.0;
  46710. var lightTypeID = this.getTypeID();
  46711. //get photometric mode
  46712. var photometricMode = this.intensityMode;
  46713. if (photometricMode === Light.INTENSITYMODE_AUTOMATIC) {
  46714. if (lightTypeID === Light.LIGHTTYPEID_DIRECTIONALLIGHT) {
  46715. photometricMode = Light.INTENSITYMODE_ILLUMINANCE;
  46716. }
  46717. else {
  46718. photometricMode = Light.INTENSITYMODE_LUMINOUSINTENSITY;
  46719. }
  46720. }
  46721. //compute photometric scale
  46722. switch (lightTypeID) {
  46723. case Light.LIGHTTYPEID_POINTLIGHT:
  46724. case Light.LIGHTTYPEID_SPOTLIGHT:
  46725. switch (photometricMode) {
  46726. case Light.INTENSITYMODE_LUMINOUSPOWER:
  46727. photometricScale = 1.0 / (4.0 * Math.PI);
  46728. break;
  46729. case Light.INTENSITYMODE_LUMINOUSINTENSITY:
  46730. photometricScale = 1.0;
  46731. break;
  46732. case Light.INTENSITYMODE_LUMINANCE:
  46733. photometricScale = this.radius * this.radius;
  46734. break;
  46735. }
  46736. break;
  46737. case Light.LIGHTTYPEID_DIRECTIONALLIGHT:
  46738. switch (photometricMode) {
  46739. case Light.INTENSITYMODE_ILLUMINANCE:
  46740. photometricScale = 1.0;
  46741. break;
  46742. case Light.INTENSITYMODE_LUMINANCE:
  46743. // When radius (and therefore solid angle) is non-zero a directional lights brightness can be specified via central (peak) luminance.
  46744. // For a directional light the 'radius' defines the angular radius (in radians) rather than world-space radius (e.g. in metres).
  46745. var apexAngleRadians = this.radius;
  46746. // Impose a minimum light angular size to avoid the light becoming an infinitely small angular light source (i.e. a dirac delta function).
  46747. apexAngleRadians = Math.max(apexAngleRadians, 0.001);
  46748. var solidAngle = 2.0 * Math.PI * (1.0 - Math.cos(apexAngleRadians));
  46749. photometricScale = solidAngle;
  46750. break;
  46751. }
  46752. break;
  46753. case Light.LIGHTTYPEID_HEMISPHERICLIGHT:
  46754. // No fall off in hemisperic light.
  46755. photometricScale = 1.0;
  46756. break;
  46757. }
  46758. return photometricScale;
  46759. };
  46760. /**
  46761. * Reorder the light in the scene according to their defined priority.
  46762. * @hidden Internal Use Only
  46763. */
  46764. Light.prototype._reorderLightsInScene = function () {
  46765. var scene = this.getScene();
  46766. if (this._renderPriority != 0) {
  46767. scene.requireLightSorting = true;
  46768. }
  46769. this.getScene().sortLightsByPriority();
  46770. };
  46771. /**
  46772. * Falloff Default: light is falling off following the material specification:
  46773. * standard material is using standard falloff whereas pbr material can request special falloff per materials.
  46774. */
  46775. Light.FALLOFF_DEFAULT = 0;
  46776. /**
  46777. * Falloff Physical: light is falling off following the inverse squared distance law.
  46778. */
  46779. Light.FALLOFF_PHYSICAL = 1;
  46780. /**
  46781. * Falloff gltf: light is falling off as described in the gltf moving to PBR document
  46782. * to enhance interoperability with other engines.
  46783. */
  46784. Light.FALLOFF_GLTF = 2;
  46785. /**
  46786. * Falloff Standard: light is falling off like in the standard material
  46787. * to enhance interoperability with other materials.
  46788. */
  46789. Light.FALLOFF_STANDARD = 3;
  46790. //lightmapMode Consts
  46791. /**
  46792. * If every light affecting the material is in this lightmapMode,
  46793. * material.lightmapTexture adds or multiplies
  46794. * (depends on material.useLightmapAsShadowmap)
  46795. * after every other light calculations.
  46796. */
  46797. Light.LIGHTMAP_DEFAULT = 0;
  46798. /**
  46799. * material.lightmapTexture as only diffuse lighting from this light
  46800. * adds only specular lighting from this light
  46801. * adds dynamic shadows
  46802. */
  46803. Light.LIGHTMAP_SPECULAR = 1;
  46804. /**
  46805. * material.lightmapTexture as only lighting
  46806. * no light calculation from this light
  46807. * only adds dynamic shadows from this light
  46808. */
  46809. Light.LIGHTMAP_SHADOWSONLY = 2;
  46810. // Intensity Mode Consts
  46811. /**
  46812. * Each light type uses the default quantity according to its type:
  46813. * point/spot lights use luminous intensity
  46814. * directional lights use illuminance
  46815. */
  46816. Light.INTENSITYMODE_AUTOMATIC = 0;
  46817. /**
  46818. * lumen (lm)
  46819. */
  46820. Light.INTENSITYMODE_LUMINOUSPOWER = 1;
  46821. /**
  46822. * candela (lm/sr)
  46823. */
  46824. Light.INTENSITYMODE_LUMINOUSINTENSITY = 2;
  46825. /**
  46826. * lux (lm/m^2)
  46827. */
  46828. Light.INTENSITYMODE_ILLUMINANCE = 3;
  46829. /**
  46830. * nit (cd/m^2)
  46831. */
  46832. Light.INTENSITYMODE_LUMINANCE = 4;
  46833. // Light types ids const.
  46834. /**
  46835. * Light type const id of the point light.
  46836. */
  46837. Light.LIGHTTYPEID_POINTLIGHT = 0;
  46838. /**
  46839. * Light type const id of the directional light.
  46840. */
  46841. Light.LIGHTTYPEID_DIRECTIONALLIGHT = 1;
  46842. /**
  46843. * Light type const id of the spot light.
  46844. */
  46845. Light.LIGHTTYPEID_SPOTLIGHT = 2;
  46846. /**
  46847. * Light type const id of the hemispheric light.
  46848. */
  46849. Light.LIGHTTYPEID_HEMISPHERICLIGHT = 3;
  46850. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46851. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46852. ], Light.prototype, "diffuse", void 0);
  46853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  46855. ], Light.prototype, "specular", void 0);
  46856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46858. ], Light.prototype, "falloffType", void 0);
  46859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46861. ], Light.prototype, "intensity", void 0);
  46862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46864. ], Light.prototype, "range", null);
  46865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46867. ], Light.prototype, "intensityMode", null);
  46868. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46869. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46870. ], Light.prototype, "radius", null);
  46871. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46872. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  46873. ], Light.prototype, "_renderPriority", void 0);
  46874. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46875. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_reorderLightsInScene")
  46876. ], Light.prototype, "renderPriority", void 0);
  46877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("shadowEnabled")
  46879. ], Light.prototype, "_shadowEnabled", void 0);
  46880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("excludeWithLayerMask")
  46882. ], Light.prototype, "_excludeWithLayerMask", void 0);
  46883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("includeOnlyWithLayerMask")
  46885. ], Light.prototype, "_includeOnlyWithLayerMask", void 0);
  46886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  46887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("lightmapMode")
  46888. ], Light.prototype, "_lightmapMode", void 0);
  46889. return Light;
  46890. }(_node__WEBPACK_IMPORTED_MODULE_3__["Node"]));
  46891. /***/ }),
  46892. /***/ "./Lights/pointLight.ts":
  46893. /*!******************************!*\
  46894. !*** ./Lights/pointLight.ts ***!
  46895. \******************************/
  46896. /*! exports provided: PointLight */
  46897. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  46898. "use strict";
  46899. __webpack_require__.r(__webpack_exports__);
  46900. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return PointLight; });
  46901. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  46902. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  46903. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  46904. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  46905. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  46906. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  46907. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_0", function (name, scene) {
  46908. return function () { return new PointLight(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero(), scene); };
  46909. });
  46910. /**
  46911. * A point light is a light defined by an unique point in world space.
  46912. * The light is emitted in every direction from this point.
  46913. * A good example of a point light is a standard light bulb.
  46914. * Documentation: https://doc.babylonjs.com/babylon101/lights
  46915. */
  46916. var PointLight = /** @class */ (function (_super) {
  46917. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PointLight, _super);
  46918. /**
  46919. * Creates a PointLight object from the passed name and position (Vector3) and adds it in the scene.
  46920. * A PointLight emits the light in every direction.
  46921. * It can cast shadows.
  46922. * If the scene camera is already defined and you want to set your PointLight at the camera position, just set it :
  46923. * ```javascript
  46924. * var pointLight = new PointLight("pl", camera.position, scene);
  46925. * ```
  46926. * Documentation : https://doc.babylonjs.com/babylon101/lights
  46927. * @param name The light friendly name
  46928. * @param position The position of the point light in the scene
  46929. * @param scene The scene the lights belongs to
  46930. */
  46931. function PointLight(name, position, scene) {
  46932. var _this = _super.call(this, name, scene) || this;
  46933. _this._shadowAngle = Math.PI / 2;
  46934. _this.position = position;
  46935. return _this;
  46936. }
  46937. Object.defineProperty(PointLight.prototype, "shadowAngle", {
  46938. /**
  46939. * Getter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46940. * This specifies what angle the shadow will use to be created.
  46941. *
  46942. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46943. */
  46944. get: function () {
  46945. return this._shadowAngle;
  46946. },
  46947. /**
  46948. * Setter: In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46949. * This specifies what angle the shadow will use to be created.
  46950. *
  46951. * It default to 90 degrees to work nicely with the cube texture generation for point lights shadow maps.
  46952. */
  46953. set: function (value) {
  46954. this._shadowAngle = value;
  46955. this.forceProjectionMatrixCompute();
  46956. },
  46957. enumerable: true,
  46958. configurable: true
  46959. });
  46960. Object.defineProperty(PointLight.prototype, "direction", {
  46961. /**
  46962. * Gets the direction if it has been set.
  46963. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46964. */
  46965. get: function () {
  46966. return this._direction;
  46967. },
  46968. /**
  46969. * In case of direction provided, the shadow will not use a cube texture but simulate a spot shadow as a fallback
  46970. */
  46971. set: function (value) {
  46972. var previousNeedCube = this.needCube();
  46973. this._direction = value;
  46974. if (this.needCube() !== previousNeedCube && this._shadowGenerator) {
  46975. this._shadowGenerator.recreateShadowMap();
  46976. }
  46977. },
  46978. enumerable: true,
  46979. configurable: true
  46980. });
  46981. /**
  46982. * Returns the string "PointLight"
  46983. * @returns the class name
  46984. */
  46985. PointLight.prototype.getClassName = function () {
  46986. return "PointLight";
  46987. };
  46988. /**
  46989. * Returns the integer 0.
  46990. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  46991. */
  46992. PointLight.prototype.getTypeID = function () {
  46993. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_POINTLIGHT;
  46994. };
  46995. /**
  46996. * Specifies wether or not the shadowmap should be a cube texture.
  46997. * @returns true if the shadowmap needs to be a cube texture.
  46998. */
  46999. PointLight.prototype.needCube = function () {
  47000. return !this.direction;
  47001. };
  47002. /**
  47003. * Returns a new Vector3 aligned with the PointLight cube system according to the passed cube face index (integer).
  47004. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47005. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47006. */
  47007. PointLight.prototype.getShadowDirection = function (faceIndex) {
  47008. if (this.direction) {
  47009. return _super.prototype.getShadowDirection.call(this, faceIndex);
  47010. }
  47011. else {
  47012. switch (faceIndex) {
  47013. case 0:
  47014. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1.0, 0.0, 0.0);
  47015. case 1:
  47016. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](-1.0, 0.0, 0.0);
  47017. case 2:
  47018. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, -1.0, 0.0);
  47019. case 3:
  47020. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 1.0, 0.0);
  47021. case 4:
  47022. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, 1.0);
  47023. case 5:
  47024. return new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0.0, 0.0, -1.0);
  47025. }
  47026. }
  47027. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47028. };
  47029. /**
  47030. * Sets the passed matrix "matrix" as a left-handed perspective projection matrix with the following settings :
  47031. * - fov = PI / 2
  47032. * - aspect ratio : 1.0
  47033. * - z-near and far equal to the active camera minZ and maxZ.
  47034. * Returns the PointLight.
  47035. */
  47036. PointLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47037. var activeCamera = this.getScene().activeCamera;
  47038. if (!activeCamera) {
  47039. return;
  47040. }
  47041. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(this.shadowAngle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47042. };
  47043. PointLight.prototype._buildUniformLayout = function () {
  47044. this._uniformBuffer.addUniform("vLightData", 4);
  47045. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47046. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47047. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47048. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47049. this._uniformBuffer.addUniform("depthValues", 2);
  47050. this._uniformBuffer.create();
  47051. };
  47052. /**
  47053. * Sets the passed Effect "effect" with the PointLight transformed position (or position, if none) and passed name (string).
  47054. * @param effect The effect to update
  47055. * @param lightIndex The index of the light in the effect to update
  47056. * @returns The point light
  47057. */
  47058. PointLight.prototype.transferToEffect = function (effect, lightIndex) {
  47059. if (this.computeTransformedInformation()) {
  47060. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, 0.0, lightIndex);
  47061. }
  47062. else {
  47063. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, 0, lightIndex);
  47064. }
  47065. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, 0, 0, lightIndex);
  47066. return this;
  47067. };
  47068. /**
  47069. * Prepares the list of defines specific to the light type.
  47070. * @param defines the list of defines
  47071. * @param lightIndex defines the index of the light for the effect
  47072. */
  47073. PointLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47074. defines["POINTLIGHT" + lightIndex] = true;
  47075. };
  47076. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47077. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47078. ], PointLight.prototype, "shadowAngle", null);
  47079. return PointLight;
  47080. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47081. /***/ }),
  47082. /***/ "./Lights/shadowLight.ts":
  47083. /*!*******************************!*\
  47084. !*** ./Lights/shadowLight.ts ***!
  47085. \*******************************/
  47086. /*! exports provided: ShadowLight */
  47087. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47088. "use strict";
  47089. __webpack_require__.r(__webpack_exports__);
  47090. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return ShadowLight; });
  47091. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47092. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47093. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47094. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47095. /**
  47096. * Base implementation IShadowLight
  47097. * It groups all the common behaviour in order to reduce dupplication and better follow the DRY pattern.
  47098. */
  47099. var ShadowLight = /** @class */ (function (_super) {
  47100. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowLight, _super);
  47101. function ShadowLight() {
  47102. var _this = _super !== null && _super.apply(this, arguments) || this;
  47103. _this._needProjectionMatrixCompute = true;
  47104. return _this;
  47105. }
  47106. ShadowLight.prototype._setPosition = function (value) {
  47107. this._position = value;
  47108. };
  47109. Object.defineProperty(ShadowLight.prototype, "position", {
  47110. /**
  47111. * Sets the position the shadow will be casted from. Also use as the light position for both
  47112. * point and spot lights.
  47113. */
  47114. get: function () {
  47115. return this._position;
  47116. },
  47117. /**
  47118. * Sets the position the shadow will be casted from. Also use as the light position for both
  47119. * point and spot lights.
  47120. */
  47121. set: function (value) {
  47122. this._setPosition(value);
  47123. },
  47124. enumerable: true,
  47125. configurable: true
  47126. });
  47127. ShadowLight.prototype._setDirection = function (value) {
  47128. this._direction = value;
  47129. };
  47130. Object.defineProperty(ShadowLight.prototype, "direction", {
  47131. /**
  47132. * In 2d mode (needCube being false), gets the direction used to cast the shadow.
  47133. * Also use as the light direction on spot and directional lights.
  47134. */
  47135. get: function () {
  47136. return this._direction;
  47137. },
  47138. /**
  47139. * In 2d mode (needCube being false), sets the direction used to cast the shadow.
  47140. * Also use as the light direction on spot and directional lights.
  47141. */
  47142. set: function (value) {
  47143. this._setDirection(value);
  47144. },
  47145. enumerable: true,
  47146. configurable: true
  47147. });
  47148. Object.defineProperty(ShadowLight.prototype, "shadowMinZ", {
  47149. /**
  47150. * Gets the shadow projection clipping minimum z value.
  47151. */
  47152. get: function () {
  47153. return this._shadowMinZ;
  47154. },
  47155. /**
  47156. * Sets the shadow projection clipping minimum z value.
  47157. */
  47158. set: function (value) {
  47159. this._shadowMinZ = value;
  47160. this.forceProjectionMatrixCompute();
  47161. },
  47162. enumerable: true,
  47163. configurable: true
  47164. });
  47165. Object.defineProperty(ShadowLight.prototype, "shadowMaxZ", {
  47166. /**
  47167. * Sets the shadow projection clipping maximum z value.
  47168. */
  47169. get: function () {
  47170. return this._shadowMaxZ;
  47171. },
  47172. /**
  47173. * Gets the shadow projection clipping maximum z value.
  47174. */
  47175. set: function (value) {
  47176. this._shadowMaxZ = value;
  47177. this.forceProjectionMatrixCompute();
  47178. },
  47179. enumerable: true,
  47180. configurable: true
  47181. });
  47182. /**
  47183. * Computes the transformed information (transformedPosition and transformedDirection in World space) of the current light
  47184. * @returns true if the information has been computed, false if it does not need to (no parenting)
  47185. */
  47186. ShadowLight.prototype.computeTransformedInformation = function () {
  47187. if (this.parent && this.parent.getWorldMatrix) {
  47188. if (!this.transformedPosition) {
  47189. this.transformedPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47190. }
  47191. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), this.transformedPosition);
  47192. // In case the direction is present.
  47193. if (this.direction) {
  47194. if (!this.transformedDirection) {
  47195. this.transformedDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47196. }
  47197. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this.direction, this.parent.getWorldMatrix(), this.transformedDirection);
  47198. }
  47199. return true;
  47200. }
  47201. return false;
  47202. };
  47203. /**
  47204. * Return the depth scale used for the shadow map.
  47205. * @returns the depth scale.
  47206. */
  47207. ShadowLight.prototype.getDepthScale = function () {
  47208. return 50.0;
  47209. };
  47210. /**
  47211. * Get the direction to use to render the shadow map. In case of cube texture, the face index can be passed.
  47212. * @param faceIndex The index of the face we are computed the direction to generate shadow
  47213. * @returns The set direction in 2d mode otherwise the direction to the cubemap face if needCube() is true
  47214. */
  47215. ShadowLight.prototype.getShadowDirection = function (faceIndex) {
  47216. return this.transformedDirection ? this.transformedDirection : this.direction;
  47217. };
  47218. /**
  47219. * Returns the ShadowLight absolute position in the World.
  47220. * @returns the position vector in world space
  47221. */
  47222. ShadowLight.prototype.getAbsolutePosition = function () {
  47223. return this.transformedPosition ? this.transformedPosition : this.position;
  47224. };
  47225. /**
  47226. * Sets the ShadowLight direction toward the passed target.
  47227. * @param target The point to target in local space
  47228. * @returns the updated ShadowLight direction
  47229. */
  47230. ShadowLight.prototype.setDirectionToTarget = function (target) {
  47231. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(target.subtract(this.position));
  47232. return this.direction;
  47233. };
  47234. /**
  47235. * Returns the light rotation in euler definition.
  47236. * @returns the x y z rotation in local space.
  47237. */
  47238. ShadowLight.prototype.getRotation = function () {
  47239. this.direction.normalize();
  47240. var xaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Axis"].Y);
  47241. var yaxis = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(xaxis, this.direction);
  47242. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].RotationFromAxis(xaxis, yaxis, this.direction);
  47243. };
  47244. /**
  47245. * Returns whether or not the shadow generation require a cube texture or a 2d texture.
  47246. * @returns true if a cube texture needs to be use
  47247. */
  47248. ShadowLight.prototype.needCube = function () {
  47249. return false;
  47250. };
  47251. /**
  47252. * Detects if the projection matrix requires to be recomputed this frame.
  47253. * @returns true if it requires to be recomputed otherwise, false.
  47254. */
  47255. ShadowLight.prototype.needProjectionMatrixCompute = function () {
  47256. return this._needProjectionMatrixCompute;
  47257. };
  47258. /**
  47259. * Forces the shadow generator to recompute the projection matrix even if position and direction did not changed.
  47260. */
  47261. ShadowLight.prototype.forceProjectionMatrixCompute = function () {
  47262. this._needProjectionMatrixCompute = true;
  47263. };
  47264. /** @hidden */
  47265. ShadowLight.prototype._initCache = function () {
  47266. _super.prototype._initCache.call(this);
  47267. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47268. };
  47269. /** @hidden */
  47270. ShadowLight.prototype._isSynchronized = function () {
  47271. if (!this._cache.position.equals(this.position)) {
  47272. return false;
  47273. }
  47274. return true;
  47275. };
  47276. /**
  47277. * Computes the world matrix of the node
  47278. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  47279. * @returns the world matrix
  47280. */
  47281. ShadowLight.prototype.computeWorldMatrix = function (force) {
  47282. if (!force && this.isSynchronized()) {
  47283. this._currentRenderId = this.getScene().getRenderId();
  47284. return this._worldMatrix;
  47285. }
  47286. this._updateCache();
  47287. this._cache.position.copyFrom(this.position);
  47288. if (!this._worldMatrix) {
  47289. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Identity();
  47290. }
  47291. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, this._worldMatrix);
  47292. if (this.parent && this.parent.getWorldMatrix) {
  47293. this._worldMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  47294. this._markSyncedWithParent();
  47295. }
  47296. // Cache the determinant
  47297. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  47298. return this._worldMatrix;
  47299. };
  47300. /**
  47301. * Gets the minZ used for shadow according to both the scene and the light.
  47302. * @param activeCamera The camera we are returning the min for
  47303. * @returns the depth min z
  47304. */
  47305. ShadowLight.prototype.getDepthMinZ = function (activeCamera) {
  47306. return this.shadowMinZ !== undefined ? this.shadowMinZ : activeCamera.minZ;
  47307. };
  47308. /**
  47309. * Gets the maxZ used for shadow according to both the scene and the light.
  47310. * @param activeCamera The camera we are returning the max for
  47311. * @returns the depth max z
  47312. */
  47313. ShadowLight.prototype.getDepthMaxZ = function (activeCamera) {
  47314. return this.shadowMaxZ !== undefined ? this.shadowMaxZ : activeCamera.maxZ;
  47315. };
  47316. /**
  47317. * Sets the shadow projection matrix in parameter to the generated projection matrix.
  47318. * @param matrix The materix to updated with the projection information
  47319. * @param viewMatrix The transform matrix of the light
  47320. * @param renderList The list of mesh to render in the map
  47321. * @returns The current light
  47322. */
  47323. ShadowLight.prototype.setShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47324. if (this.customProjectionMatrixBuilder) {
  47325. this.customProjectionMatrixBuilder(viewMatrix, renderList, matrix);
  47326. }
  47327. else {
  47328. this._setDefaultShadowProjectionMatrix(matrix, viewMatrix, renderList);
  47329. }
  47330. return this;
  47331. };
  47332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47334. ], ShadowLight.prototype, "position", null);
  47335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  47337. ], ShadowLight.prototype, "direction", null);
  47338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47340. ], ShadowLight.prototype, "shadowMinZ", null);
  47341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47343. ], ShadowLight.prototype, "shadowMaxZ", null);
  47344. return ShadowLight;
  47345. }(_light__WEBPACK_IMPORTED_MODULE_3__["Light"]));
  47346. /***/ }),
  47347. /***/ "./Lights/spotLight.ts":
  47348. /*!*****************************!*\
  47349. !*** ./Lights/spotLight.ts ***!
  47350. \*****************************/
  47351. /*! exports provided: SpotLight */
  47352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47353. "use strict";
  47354. __webpack_require__.r(__webpack_exports__);
  47355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return SpotLight; });
  47356. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  47357. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  47358. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  47359. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../node */ "./node.ts");
  47360. /* harmony import */ var _light__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./light */ "./Lights/light.ts");
  47361. /* harmony import */ var _shadowLight__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./shadowLight */ "./Lights/shadowLight.ts");
  47362. _node__WEBPACK_IMPORTED_MODULE_3__["Node"].AddNodeConstructor("Light_Type_2", function (name, scene) {
  47363. 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); };
  47364. });
  47365. /**
  47366. * A spot light is defined by a position, a direction, an angle, and an exponent.
  47367. * These values define a cone of light starting from the position, emitting toward the direction.
  47368. * The angle, in radians, defines the size (field of illumination) of the spotlight's conical beam,
  47369. * and the exponent defines the speed of the decay of the light with distance (reach).
  47370. * Documentation: https://doc.babylonjs.com/babylon101/lights
  47371. */
  47372. var SpotLight = /** @class */ (function (_super) {
  47373. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SpotLight, _super);
  47374. /**
  47375. * Creates a SpotLight object in the scene. A spot light is a simply light oriented cone.
  47376. * It can cast shadows.
  47377. * Documentation : https://doc.babylonjs.com/babylon101/lights
  47378. * @param name The light friendly name
  47379. * @param position The position of the spot light in the scene
  47380. * @param direction The direction of the light in the scene
  47381. * @param angle The cone angle of the light in Radians
  47382. * @param exponent The light decay speed with the distance from the emission spot
  47383. * @param scene The scene the lights belongs to
  47384. */
  47385. function SpotLight(name, position, direction, angle, exponent, scene) {
  47386. var _this = _super.call(this, name, scene) || this;
  47387. _this._innerAngle = 0;
  47388. _this._projectionTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47389. _this._projectionTextureLightNear = 1e-6;
  47390. _this._projectionTextureLightFar = 1000.0;
  47391. _this._projectionTextureUpDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Up();
  47392. _this._projectionTextureViewLightDirty = true;
  47393. _this._projectionTextureProjectionLightDirty = true;
  47394. _this._projectionTextureDirty = true;
  47395. _this._projectionTextureViewTargetVector = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  47396. _this._projectionTextureViewLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47397. _this._projectionTextureProjectionLightMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].Zero();
  47398. _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);
  47399. _this.position = position;
  47400. _this.direction = direction;
  47401. _this.angle = angle;
  47402. _this.exponent = exponent;
  47403. return _this;
  47404. }
  47405. Object.defineProperty(SpotLight.prototype, "angle", {
  47406. /**
  47407. * Gets the cone angle of the spot light in Radians.
  47408. */
  47409. get: function () {
  47410. return this._angle;
  47411. },
  47412. /**
  47413. * Sets the cone angle of the spot light in Radians.
  47414. */
  47415. set: function (value) {
  47416. this._angle = value;
  47417. this._cosHalfAngle = Math.cos(value * 0.5);
  47418. this._projectionTextureProjectionLightDirty = true;
  47419. this.forceProjectionMatrixCompute();
  47420. this._computeAngleValues();
  47421. },
  47422. enumerable: true,
  47423. configurable: true
  47424. });
  47425. Object.defineProperty(SpotLight.prototype, "innerAngle", {
  47426. /**
  47427. * Only used in gltf falloff mode, this defines the angle where
  47428. * the directional falloff will start before cutting at angle which could be seen
  47429. * as outer angle.
  47430. */
  47431. get: function () {
  47432. return this._innerAngle;
  47433. },
  47434. /**
  47435. * Only used in gltf falloff mode, this defines the angle where
  47436. * the directional falloff will start before cutting at angle which could be seen
  47437. * as outer angle.
  47438. */
  47439. set: function (value) {
  47440. this._innerAngle = value;
  47441. this._computeAngleValues();
  47442. },
  47443. enumerable: true,
  47444. configurable: true
  47445. });
  47446. Object.defineProperty(SpotLight.prototype, "shadowAngleScale", {
  47447. /**
  47448. * Allows scaling the angle of the light for shadow generation only.
  47449. */
  47450. get: function () {
  47451. return this._shadowAngleScale;
  47452. },
  47453. /**
  47454. * Allows scaling the angle of the light for shadow generation only.
  47455. */
  47456. set: function (value) {
  47457. this._shadowAngleScale = value;
  47458. this.forceProjectionMatrixCompute();
  47459. },
  47460. enumerable: true,
  47461. configurable: true
  47462. });
  47463. Object.defineProperty(SpotLight.prototype, "projectionTextureMatrix", {
  47464. /**
  47465. * Allows reading the projecton texture
  47466. */
  47467. get: function () {
  47468. return this._projectionTextureMatrix;
  47469. },
  47470. enumerable: true,
  47471. configurable: true
  47472. });
  47473. Object.defineProperty(SpotLight.prototype, "projectionTextureLightNear", {
  47474. /**
  47475. * Gets the near clip of the Spotlight for texture projection.
  47476. */
  47477. get: function () {
  47478. return this._projectionTextureLightNear;
  47479. },
  47480. /**
  47481. * Sets the near clip of the Spotlight for texture projection.
  47482. */
  47483. set: function (value) {
  47484. this._projectionTextureLightNear = value;
  47485. this._projectionTextureProjectionLightDirty = true;
  47486. },
  47487. enumerable: true,
  47488. configurable: true
  47489. });
  47490. Object.defineProperty(SpotLight.prototype, "projectionTextureLightFar", {
  47491. /**
  47492. * Gets the far clip of the Spotlight for texture projection.
  47493. */
  47494. get: function () {
  47495. return this._projectionTextureLightFar;
  47496. },
  47497. /**
  47498. * Sets the far clip of the Spotlight for texture projection.
  47499. */
  47500. set: function (value) {
  47501. this._projectionTextureLightFar = value;
  47502. this._projectionTextureProjectionLightDirty = true;
  47503. },
  47504. enumerable: true,
  47505. configurable: true
  47506. });
  47507. Object.defineProperty(SpotLight.prototype, "projectionTextureUpDirection", {
  47508. /**
  47509. * Gets the Up vector of the Spotlight for texture projection.
  47510. */
  47511. get: function () {
  47512. return this._projectionTextureUpDirection;
  47513. },
  47514. /**
  47515. * Sets the Up vector of the Spotlight for texture projection.
  47516. */
  47517. set: function (value) {
  47518. this._projectionTextureUpDirection = value;
  47519. this._projectionTextureProjectionLightDirty = true;
  47520. },
  47521. enumerable: true,
  47522. configurable: true
  47523. });
  47524. Object.defineProperty(SpotLight.prototype, "projectionTexture", {
  47525. /**
  47526. * Gets the projection texture of the light.
  47527. */
  47528. get: function () {
  47529. return this._projectionTexture;
  47530. },
  47531. /**
  47532. * Sets the projection texture of the light.
  47533. */
  47534. set: function (value) {
  47535. this._projectionTexture = value;
  47536. this._projectionTextureDirty = true;
  47537. },
  47538. enumerable: true,
  47539. configurable: true
  47540. });
  47541. /**
  47542. * Returns the string "SpotLight".
  47543. * @returns the class name
  47544. */
  47545. SpotLight.prototype.getClassName = function () {
  47546. return "SpotLight";
  47547. };
  47548. /**
  47549. * Returns the integer 2.
  47550. * @returns The light Type id as a constant defines in Light.LIGHTTYPEID_x
  47551. */
  47552. SpotLight.prototype.getTypeID = function () {
  47553. return _light__WEBPACK_IMPORTED_MODULE_4__["Light"].LIGHTTYPEID_SPOTLIGHT;
  47554. };
  47555. /**
  47556. * Overrides the direction setter to recompute the projection texture view light Matrix.
  47557. */
  47558. SpotLight.prototype._setDirection = function (value) {
  47559. _super.prototype._setDirection.call(this, value);
  47560. this._projectionTextureViewLightDirty = true;
  47561. };
  47562. /**
  47563. * Overrides the position setter to recompute the projection texture view light Matrix.
  47564. */
  47565. SpotLight.prototype._setPosition = function (value) {
  47566. _super.prototype._setPosition.call(this, value);
  47567. this._projectionTextureViewLightDirty = true;
  47568. };
  47569. /**
  47570. * 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.
  47571. * Returns the SpotLight.
  47572. */
  47573. SpotLight.prototype._setDefaultShadowProjectionMatrix = function (matrix, viewMatrix, renderList) {
  47574. var activeCamera = this.getScene().activeCamera;
  47575. if (!activeCamera) {
  47576. return;
  47577. }
  47578. this._shadowAngleScale = this._shadowAngleScale || 1;
  47579. var angle = this._shadowAngleScale * this._angle;
  47580. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].PerspectiveFovLHToRef(angle, 1.0, this.getDepthMinZ(activeCamera), this.getDepthMaxZ(activeCamera), matrix);
  47581. };
  47582. SpotLight.prototype._computeProjectionTextureViewLightMatrix = function () {
  47583. this._projectionTextureViewLightDirty = false;
  47584. this._projectionTextureDirty = true;
  47585. this.position.addToRef(this.direction, this._projectionTextureViewTargetVector);
  47586. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].LookAtLHToRef(this.position, this._projectionTextureViewTargetVector, this._projectionTextureUpDirection, this._projectionTextureViewLightMatrix);
  47587. };
  47588. SpotLight.prototype._computeProjectionTextureProjectionLightMatrix = function () {
  47589. this._projectionTextureProjectionLightDirty = false;
  47590. this._projectionTextureDirty = true;
  47591. var light_far = this.projectionTextureLightFar;
  47592. var light_near = this.projectionTextureLightNear;
  47593. var P = light_far / (light_far - light_near);
  47594. var Q = -P * light_near;
  47595. var S = 1.0 / Math.tan(this._angle / 2.0);
  47596. var A = 1.0;
  47597. _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);
  47598. };
  47599. /**
  47600. * Main function for light texture projection matrix computing.
  47601. */
  47602. SpotLight.prototype._computeProjectionTextureMatrix = function () {
  47603. this._projectionTextureDirty = false;
  47604. this._projectionTextureViewLightMatrix.multiplyToRef(this._projectionTextureProjectionLightMatrix, this._projectionTextureMatrix);
  47605. this._projectionTextureMatrix.multiplyToRef(this._projectionTextureScalingMatrix, this._projectionTextureMatrix);
  47606. };
  47607. SpotLight.prototype._buildUniformLayout = function () {
  47608. this._uniformBuffer.addUniform("vLightData", 4);
  47609. this._uniformBuffer.addUniform("vLightDiffuse", 4);
  47610. this._uniformBuffer.addUniform("vLightSpecular", 3);
  47611. this._uniformBuffer.addUniform("vLightDirection", 3);
  47612. this._uniformBuffer.addUniform("vLightFalloff", 4);
  47613. this._uniformBuffer.addUniform("shadowsInfo", 3);
  47614. this._uniformBuffer.addUniform("depthValues", 2);
  47615. this._uniformBuffer.create();
  47616. };
  47617. SpotLight.prototype._computeAngleValues = function () {
  47618. this._lightAngleScale = 1.0 / Math.max(0.001, (Math.cos(this._innerAngle * 0.5) - this._cosHalfAngle));
  47619. this._lightAngleOffset = -this._cosHalfAngle * this._lightAngleScale;
  47620. };
  47621. /**
  47622. * Sets the passed Effect object with the SpotLight transfomed position (or position if not parented) and normalized direction.
  47623. * @param effect The effect to update
  47624. * @param lightIndex The index of the light in the effect to update
  47625. * @returns The spot light
  47626. */
  47627. SpotLight.prototype.transferToEffect = function (effect, lightIndex) {
  47628. var normalizeDirection;
  47629. if (this.computeTransformedInformation()) {
  47630. this._uniformBuffer.updateFloat4("vLightData", this.transformedPosition.x, this.transformedPosition.y, this.transformedPosition.z, this.exponent, lightIndex);
  47631. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.transformedDirection);
  47632. }
  47633. else {
  47634. this._uniformBuffer.updateFloat4("vLightData", this.position.x, this.position.y, this.position.z, this.exponent, lightIndex);
  47635. normalizeDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Normalize(this.direction);
  47636. }
  47637. this._uniformBuffer.updateFloat4("vLightDirection", normalizeDirection.x, normalizeDirection.y, normalizeDirection.z, this._cosHalfAngle, lightIndex);
  47638. this._uniformBuffer.updateFloat4("vLightFalloff", this.range, this._inverseSquaredRange, this._lightAngleScale, this._lightAngleOffset, lightIndex);
  47639. if (this.projectionTexture && this.projectionTexture.isReady()) {
  47640. if (this._projectionTextureViewLightDirty) {
  47641. this._computeProjectionTextureViewLightMatrix();
  47642. }
  47643. if (this._projectionTextureProjectionLightDirty) {
  47644. this._computeProjectionTextureProjectionLightMatrix();
  47645. }
  47646. if (this._projectionTextureDirty) {
  47647. this._computeProjectionTextureMatrix();
  47648. }
  47649. effect.setMatrix("textureProjectionMatrix" + lightIndex, this._projectionTextureMatrix);
  47650. effect.setTexture("projectionLightSampler" + lightIndex, this.projectionTexture);
  47651. }
  47652. return this;
  47653. };
  47654. /**
  47655. * Disposes the light and the associated resources.
  47656. */
  47657. SpotLight.prototype.dispose = function () {
  47658. _super.prototype.dispose.call(this);
  47659. if (this._projectionTexture) {
  47660. this._projectionTexture.dispose();
  47661. }
  47662. };
  47663. /**
  47664. * Prepares the list of defines specific to the light type.
  47665. * @param defines the list of defines
  47666. * @param lightIndex defines the index of the light for the effect
  47667. */
  47668. SpotLight.prototype.prepareLightSpecificDefines = function (defines, lightIndex) {
  47669. defines["SPOTLIGHT" + lightIndex] = true;
  47670. defines["PROJECTEDLIGHTTEXTURE" + lightIndex] = this.projectionTexture ? true : false;
  47671. };
  47672. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47673. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47674. ], SpotLight.prototype, "angle", null);
  47675. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47676. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47677. ], SpotLight.prototype, "innerAngle", null);
  47678. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47679. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47680. ], SpotLight.prototype, "shadowAngleScale", null);
  47681. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47682. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47683. ], SpotLight.prototype, "exponent", void 0);
  47684. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47685. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47686. ], SpotLight.prototype, "projectionTextureLightNear", null);
  47687. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47688. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47689. ], SpotLight.prototype, "projectionTextureLightFar", null);
  47690. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47691. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  47692. ], SpotLight.prototype, "projectionTextureUpDirection", null);
  47693. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  47694. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("projectedLightTexture")
  47695. ], SpotLight.prototype, "_projectionTexture", void 0);
  47696. return SpotLight;
  47697. }(_shadowLight__WEBPACK_IMPORTED_MODULE_5__["ShadowLight"]));
  47698. /***/ }),
  47699. /***/ "./Loading/Plugins/babylonFileLoader.ts":
  47700. /*!**********************************************!*\
  47701. !*** ./Loading/Plugins/babylonFileLoader.ts ***!
  47702. \**********************************************/
  47703. /*! exports provided: _BabylonLoaderRegistered */
  47704. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  47705. "use strict";
  47706. __webpack_require__.r(__webpack_exports__);
  47707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _BabylonLoaderRegistered; });
  47708. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  47709. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Cameras/camera */ "./Cameras/camera.ts");
  47710. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  47711. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/mesh */ "./Meshes/mesh.ts");
  47712. /* harmony import */ var _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/geometry */ "./Meshes/geometry.ts");
  47713. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/transformNode */ "./Meshes/transformNode.ts");
  47714. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/material */ "./Materials/material.ts");
  47715. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  47716. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  47717. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  47718. /* harmony import */ var _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Animations/animationGroup */ "./Animations/animationGroup.ts");
  47719. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Lights/light */ "./Lights/light.ts");
  47720. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  47721. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  47722. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../abstractScene */ "./abstractScene.ts");
  47723. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../assetContainer */ "./assetContainer.ts");
  47724. /* harmony import */ var _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Actions/actionManager */ "./Actions/actionManager.ts");
  47725. /* harmony import */ var _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Bones/skeleton */ "./Bones/skeleton.ts");
  47726. /* harmony import */ var _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Morph/morphTargetManager */ "./Morph/morphTargetManager.ts");
  47727. /* harmony import */ var _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Physics/Plugins/cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  47728. /* harmony import */ var _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../Physics/Plugins/oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  47729. /* harmony import */ var _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../Probes/reflectionProbe */ "./Probes/reflectionProbe.ts");
  47730. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  47731. /** @hidden */
  47732. var _BabylonLoaderRegistered = true;
  47733. var parseMaterialById = function (id, parsedData, scene, rootUrl) {
  47734. for (var index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47735. var parsedMaterial = parsedData.materials[index];
  47736. if (parsedMaterial.id === id) {
  47737. return _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47738. }
  47739. }
  47740. return null;
  47741. };
  47742. var isDescendantOf = function (mesh, names, hierarchyIds) {
  47743. for (var i in names) {
  47744. if (mesh.name === names[i]) {
  47745. hierarchyIds.push(mesh.id);
  47746. return true;
  47747. }
  47748. }
  47749. if (mesh.parentId && hierarchyIds.indexOf(mesh.parentId) !== -1) {
  47750. hierarchyIds.push(mesh.id);
  47751. return true;
  47752. }
  47753. return false;
  47754. };
  47755. var logOperation = function (operation, producer) {
  47756. return operation + " of " + (producer ? producer.file + " from " + producer.name + " version: " + producer.version + ", exporter version: " + producer.exporter_version : "unknown");
  47757. };
  47758. var loadAssetContainer = function (scene, data, rootUrl, onError, addToScene) {
  47759. if (addToScene === void 0) { addToScene = false; }
  47760. var container = new _assetContainer__WEBPACK_IMPORTED_MODULE_15__["AssetContainer"](scene);
  47761. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  47762. // when SceneLoader.debugLogging = true (default), or exception encountered.
  47763. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  47764. // and avoid problems with multiple concurrent .babylon loads.
  47765. var log = "importScene has failed JSON parse";
  47766. try {
  47767. var parsedData = JSON.parse(data);
  47768. log = "";
  47769. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  47770. var index;
  47771. var cache;
  47772. // Lights
  47773. if (parsedData.lights !== undefined && parsedData.lights !== null) {
  47774. for (index = 0, cache = parsedData.lights.length; index < cache; index++) {
  47775. var parsedLight = parsedData.lights[index];
  47776. var light = _Lights_light__WEBPACK_IMPORTED_MODULE_11__["Light"].Parse(parsedLight, scene);
  47777. if (light) {
  47778. container.lights.push(light);
  47779. log += (index === 0 ? "\n\tLights:" : "");
  47780. log += "\n\t\t" + light.toString(fullDetails);
  47781. }
  47782. }
  47783. }
  47784. // Reflection probes
  47785. if (parsedData.reflectionProbes !== undefined && parsedData.reflectionProbes !== null) {
  47786. for (index = 0, cache = parsedData.reflectionProbes.length; index < cache; index++) {
  47787. var parsedReflectionProbe = parsedData.reflectionProbes[index];
  47788. var reflectionProbe = _Probes_reflectionProbe__WEBPACK_IMPORTED_MODULE_21__["ReflectionProbe"].Parse(parsedReflectionProbe, scene, rootUrl);
  47789. if (reflectionProbe) {
  47790. container.reflectionProbes.push(reflectionProbe);
  47791. log += (index === 0 ? "\n\tReflection Probes:" : "");
  47792. log += "\n\t\t" + reflectionProbe.toString(fullDetails);
  47793. }
  47794. }
  47795. }
  47796. // Animations
  47797. if (parsedData.animations !== undefined && parsedData.animations !== null) {
  47798. for (index = 0, cache = parsedData.animations.length; index < cache; index++) {
  47799. var parsedAnimation = parsedData.animations[index];
  47800. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_22__["_TypeStore"].GetClass("BABYLON.Animation");
  47801. if (internalClass) {
  47802. var animation = internalClass.Parse(parsedAnimation);
  47803. scene.animations.push(animation);
  47804. container.animations.push(animation);
  47805. log += (index === 0 ? "\n\tAnimations:" : "");
  47806. log += "\n\t\t" + animation.toString(fullDetails);
  47807. }
  47808. }
  47809. }
  47810. // Materials
  47811. if (parsedData.materials !== undefined && parsedData.materials !== null) {
  47812. for (index = 0, cache = parsedData.materials.length; index < cache; index++) {
  47813. var parsedMaterial = parsedData.materials[index];
  47814. var mat = _Materials_material__WEBPACK_IMPORTED_MODULE_6__["Material"].Parse(parsedMaterial, scene, rootUrl);
  47815. container.materials.push(mat);
  47816. log += (index === 0 ? "\n\tMaterials:" : "");
  47817. log += "\n\t\t" + mat.toString(fullDetails);
  47818. }
  47819. }
  47820. if (parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  47821. for (index = 0, cache = parsedData.multiMaterials.length; index < cache; index++) {
  47822. var parsedMultiMaterial = parsedData.multiMaterials[index];
  47823. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  47824. container.multiMaterials.push(mmat);
  47825. log += (index === 0 ? "\n\tMultiMaterials:" : "");
  47826. log += "\n\t\t" + mmat.toString(fullDetails);
  47827. }
  47828. }
  47829. // Morph targets
  47830. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  47831. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  47832. var managerData = _a[_i];
  47833. container.morphTargetManagers.push(_Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene));
  47834. }
  47835. }
  47836. // Skeletons
  47837. if (parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  47838. for (index = 0, cache = parsedData.skeletons.length; index < cache; index++) {
  47839. var parsedSkeleton = parsedData.skeletons[index];
  47840. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  47841. container.skeletons.push(skeleton);
  47842. log += (index === 0 ? "\n\tSkeletons:" : "");
  47843. log += "\n\t\t" + skeleton.toString(fullDetails);
  47844. }
  47845. }
  47846. // Geometries
  47847. var geometries = parsedData.geometries;
  47848. if (geometries !== undefined && geometries !== null) {
  47849. var addedGeometry = new Array();
  47850. // VertexData
  47851. var vertexData = geometries.vertexData;
  47852. if (vertexData !== undefined && vertexData !== null) {
  47853. for (index = 0, cache = vertexData.length; index < cache; index++) {
  47854. var parsedVertexData = vertexData[index];
  47855. addedGeometry.push(_Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedVertexData, scene, rootUrl));
  47856. }
  47857. }
  47858. addedGeometry.forEach(function (g) {
  47859. if (g) {
  47860. container.geometries.push(g);
  47861. }
  47862. });
  47863. }
  47864. // Transform nodes
  47865. if (parsedData.transformNodes !== undefined && parsedData.transformNodes !== null) {
  47866. for (index = 0, cache = parsedData.transformNodes.length; index < cache; index++) {
  47867. var parsedTransformNode = parsedData.transformNodes[index];
  47868. var node = _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_5__["TransformNode"].Parse(parsedTransformNode, scene, rootUrl);
  47869. container.transformNodes.push(node);
  47870. }
  47871. }
  47872. // Meshes
  47873. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  47874. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  47875. var parsedMesh = parsedData.meshes[index];
  47876. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  47877. container.meshes.push(mesh);
  47878. log += (index === 0 ? "\n\tMeshes:" : "");
  47879. log += "\n\t\t" + mesh.toString(fullDetails);
  47880. }
  47881. }
  47882. // Cameras
  47883. if (parsedData.cameras !== undefined && parsedData.cameras !== null) {
  47884. for (index = 0, cache = parsedData.cameras.length; index < cache; index++) {
  47885. var parsedCamera = parsedData.cameras[index];
  47886. var camera = _Cameras_camera__WEBPACK_IMPORTED_MODULE_1__["Camera"].Parse(parsedCamera, scene);
  47887. container.cameras.push(camera);
  47888. log += (index === 0 ? "\n\tCameras:" : "");
  47889. log += "\n\t\t" + camera.toString(fullDetails);
  47890. }
  47891. }
  47892. // Animation Groups
  47893. if (parsedData.animationGroups !== undefined && parsedData.animationGroups !== null) {
  47894. for (index = 0, cache = parsedData.animationGroups.length; index < cache; index++) {
  47895. var parsedAnimationGroup = parsedData.animationGroups[index];
  47896. var animationGroup = _Animations_animationGroup__WEBPACK_IMPORTED_MODULE_10__["AnimationGroup"].Parse(parsedAnimationGroup, scene);
  47897. container.animationGroups.push(animationGroup);
  47898. log += (index === 0 ? "\n\tAnimationGroups:" : "");
  47899. log += "\n\t\t" + animationGroup.toString(fullDetails);
  47900. }
  47901. }
  47902. // Browsing all the graph to connect the dots
  47903. for (index = 0, cache = scene.cameras.length; index < cache; index++) {
  47904. var camera = scene.cameras[index];
  47905. if (camera._waitingParentId) {
  47906. camera.parent = scene.getLastEntryByID(camera._waitingParentId);
  47907. camera._waitingParentId = null;
  47908. }
  47909. }
  47910. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47911. var light_1 = scene.lights[index];
  47912. if (light_1 && light_1._waitingParentId) {
  47913. light_1.parent = scene.getLastEntryByID(light_1._waitingParentId);
  47914. light_1._waitingParentId = null;
  47915. }
  47916. }
  47917. // Connect parents & children and parse actions
  47918. for (index = 0, cache = scene.transformNodes.length; index < cache; index++) {
  47919. var transformNode = scene.transformNodes[index];
  47920. if (transformNode._waitingParentId) {
  47921. transformNode.parent = scene.getLastEntryByID(transformNode._waitingParentId);
  47922. transformNode._waitingParentId = null;
  47923. }
  47924. }
  47925. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47926. var mesh = scene.meshes[index];
  47927. if (mesh._waitingParentId) {
  47928. mesh.parent = scene.getLastEntryByID(mesh._waitingParentId);
  47929. mesh._waitingParentId = null;
  47930. }
  47931. }
  47932. // freeze world matrix application
  47933. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47934. var currentMesh = scene.meshes[index];
  47935. if (currentMesh._waitingFreezeWorldMatrix) {
  47936. currentMesh.freezeWorldMatrix();
  47937. currentMesh._waitingFreezeWorldMatrix = null;
  47938. }
  47939. else {
  47940. currentMesh.computeWorldMatrix(true);
  47941. }
  47942. }
  47943. // Lights exclusions / inclusions
  47944. for (index = 0, cache = scene.lights.length; index < cache; index++) {
  47945. var light_2 = scene.lights[index];
  47946. // Excluded check
  47947. if (light_2._excludedMeshesIds.length > 0) {
  47948. for (var excludedIndex = 0; excludedIndex < light_2._excludedMeshesIds.length; excludedIndex++) {
  47949. var excludedMesh = scene.getMeshByID(light_2._excludedMeshesIds[excludedIndex]);
  47950. if (excludedMesh) {
  47951. light_2.excludedMeshes.push(excludedMesh);
  47952. }
  47953. }
  47954. light_2._excludedMeshesIds = [];
  47955. }
  47956. // Included check
  47957. if (light_2._includedOnlyMeshesIds.length > 0) {
  47958. for (var includedOnlyIndex = 0; includedOnlyIndex < light_2._includedOnlyMeshesIds.length; includedOnlyIndex++) {
  47959. var includedOnlyMesh = scene.getMeshByID(light_2._includedOnlyMeshesIds[includedOnlyIndex]);
  47960. if (includedOnlyMesh) {
  47961. light_2.includedOnlyMeshes.push(includedOnlyMesh);
  47962. }
  47963. }
  47964. light_2._includedOnlyMeshesIds = [];
  47965. }
  47966. }
  47967. _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].Parse(parsedData, scene, container, rootUrl);
  47968. // Actions (scene) Done last as it can access other objects.
  47969. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  47970. var mesh = scene.meshes[index];
  47971. if (mesh._waitingActions) {
  47972. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(mesh._waitingActions, mesh, scene);
  47973. mesh._waitingActions = null;
  47974. }
  47975. }
  47976. if (parsedData.actions !== undefined && parsedData.actions !== null) {
  47977. _Actions_actionManager__WEBPACK_IMPORTED_MODULE_16__["ActionManager"].Parse(parsedData.actions, null, scene);
  47978. }
  47979. if (!addToScene) {
  47980. container.removeAllFromScene();
  47981. }
  47982. }
  47983. catch (err) {
  47984. var msg = logOperation("loadAssets", parsedData ? parsedData.producer : "Unknown") + log;
  47985. if (onError) {
  47986. onError(msg, err);
  47987. }
  47988. else {
  47989. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  47990. throw err;
  47991. }
  47992. }
  47993. finally {
  47994. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  47995. _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 : ""));
  47996. }
  47997. }
  47998. return container;
  47999. };
  48000. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].RegisterPlugin({
  48001. name: "babylon.js",
  48002. extensions: ".babylon",
  48003. canDirectLoad: function (data) {
  48004. if (data.indexOf("babylon") !== -1) { // We consider that the producer string is filled
  48005. return true;
  48006. }
  48007. return false;
  48008. },
  48009. importMesh: function (meshesNames, scene, data, rootUrl, meshes, particleSystems, skeletons, onError) {
  48010. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48011. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48012. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48013. // and avoid problems with multiple concurrent .babylon loads.
  48014. var log = "importMesh has failed JSON parse";
  48015. try {
  48016. var parsedData = JSON.parse(data);
  48017. log = "";
  48018. var fullDetails = _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel === _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].DETAILED_LOGGING;
  48019. if (!meshesNames) {
  48020. meshesNames = null;
  48021. }
  48022. else if (!Array.isArray(meshesNames)) {
  48023. meshesNames = [meshesNames];
  48024. }
  48025. var hierarchyIds = new Array();
  48026. if (parsedData.meshes !== undefined && parsedData.meshes !== null) {
  48027. var loadedSkeletonsIds = [];
  48028. var loadedMaterialsIds = [];
  48029. var index;
  48030. var cache;
  48031. for (index = 0, cache = parsedData.meshes.length; index < cache; index++) {
  48032. var parsedMesh = parsedData.meshes[index];
  48033. if (meshesNames === null || isDescendantOf(parsedMesh, meshesNames, hierarchyIds)) {
  48034. if (meshesNames !== null) {
  48035. // Remove found mesh name from list.
  48036. delete meshesNames[meshesNames.indexOf(parsedMesh.name)];
  48037. }
  48038. //Geometry?
  48039. if (parsedMesh.geometryId !== undefined && parsedMesh.geometryId !== null) {
  48040. //does the file contain geometries?
  48041. if (parsedData.geometries !== undefined && parsedData.geometries !== null) {
  48042. //find the correct geometry and add it to the scene
  48043. var found = false;
  48044. ["boxes", "spheres", "cylinders", "toruses", "grounds", "planes", "torusKnots", "vertexData"].forEach(function (geometryType) {
  48045. if (found === true || !parsedData.geometries[geometryType] || !(Array.isArray(parsedData.geometries[geometryType]))) {
  48046. return;
  48047. }
  48048. else {
  48049. parsedData.geometries[geometryType].forEach(function (parsedGeometryData) {
  48050. if (parsedGeometryData.id === parsedMesh.geometryId) {
  48051. switch (geometryType) {
  48052. case "vertexData":
  48053. _Meshes_geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"].Parse(parsedGeometryData, scene, rootUrl);
  48054. break;
  48055. }
  48056. found = true;
  48057. }
  48058. });
  48059. }
  48060. });
  48061. if (found === false) {
  48062. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Geometry not found for mesh " + parsedMesh.id);
  48063. }
  48064. }
  48065. }
  48066. // Material ?
  48067. if (parsedMesh.materialId) {
  48068. var materialFound = (loadedMaterialsIds.indexOf(parsedMesh.materialId) !== -1);
  48069. if (materialFound === false && parsedData.multiMaterials !== undefined && parsedData.multiMaterials !== null) {
  48070. for (var multimatIndex = 0, multimatCache = parsedData.multiMaterials.length; multimatIndex < multimatCache; multimatIndex++) {
  48071. var parsedMultiMaterial = parsedData.multiMaterials[multimatIndex];
  48072. if (parsedMultiMaterial.id === parsedMesh.materialId) {
  48073. for (var matIndex = 0, matCache = parsedMultiMaterial.materials.length; matIndex < matCache; matIndex++) {
  48074. var subMatId = parsedMultiMaterial.materials[matIndex];
  48075. loadedMaterialsIds.push(subMatId);
  48076. var mat = parseMaterialById(subMatId, parsedData, scene, rootUrl);
  48077. if (mat) {
  48078. log += "\n\tMaterial " + mat.toString(fullDetails);
  48079. }
  48080. }
  48081. loadedMaterialsIds.push(parsedMultiMaterial.id);
  48082. var mmat = _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_7__["MultiMaterial"].ParseMultiMaterial(parsedMultiMaterial, scene);
  48083. if (mmat) {
  48084. materialFound = true;
  48085. log += "\n\tMulti-Material " + mmat.toString(fullDetails);
  48086. }
  48087. break;
  48088. }
  48089. }
  48090. }
  48091. if (materialFound === false) {
  48092. loadedMaterialsIds.push(parsedMesh.materialId);
  48093. var mat = parseMaterialById(parsedMesh.materialId, parsedData, scene, rootUrl);
  48094. if (!mat) {
  48095. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Material not found for mesh " + parsedMesh.id);
  48096. }
  48097. else {
  48098. log += "\n\tMaterial " + mat.toString(fullDetails);
  48099. }
  48100. }
  48101. }
  48102. // Skeleton ?
  48103. if (parsedMesh.skeletonId > -1 && parsedData.skeletons !== undefined && parsedData.skeletons !== null) {
  48104. var skeletonAlreadyLoaded = (loadedSkeletonsIds.indexOf(parsedMesh.skeletonId) > -1);
  48105. if (skeletonAlreadyLoaded === false) {
  48106. for (var skeletonIndex = 0, skeletonCache = parsedData.skeletons.length; skeletonIndex < skeletonCache; skeletonIndex++) {
  48107. var parsedSkeleton = parsedData.skeletons[skeletonIndex];
  48108. if (parsedSkeleton.id === parsedMesh.skeletonId) {
  48109. var skeleton = _Bones_skeleton__WEBPACK_IMPORTED_MODULE_17__["Skeleton"].Parse(parsedSkeleton, scene);
  48110. skeletons.push(skeleton);
  48111. loadedSkeletonsIds.push(parsedSkeleton.id);
  48112. log += "\n\tSkeleton " + skeleton.toString(fullDetails);
  48113. }
  48114. }
  48115. }
  48116. }
  48117. // Morph targets ?
  48118. if (parsedData.morphTargetManagers !== undefined && parsedData.morphTargetManagers !== null) {
  48119. for (var _i = 0, _a = parsedData.morphTargetManagers; _i < _a.length; _i++) {
  48120. var managerData = _a[_i];
  48121. _Morph_morphTargetManager__WEBPACK_IMPORTED_MODULE_18__["MorphTargetManager"].Parse(managerData, scene);
  48122. }
  48123. }
  48124. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"].Parse(parsedMesh, scene, rootUrl);
  48125. meshes.push(mesh);
  48126. log += "\n\tMesh " + mesh.toString(fullDetails);
  48127. }
  48128. }
  48129. // Connecting parents
  48130. var currentMesh;
  48131. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48132. currentMesh = scene.meshes[index];
  48133. if (currentMesh._waitingParentId) {
  48134. currentMesh.parent = scene.getLastEntryByID(currentMesh._waitingParentId);
  48135. currentMesh._waitingParentId = null;
  48136. }
  48137. }
  48138. // freeze and compute world matrix application
  48139. for (index = 0, cache = scene.meshes.length; index < cache; index++) {
  48140. currentMesh = scene.meshes[index];
  48141. if (currentMesh._waitingFreezeWorldMatrix) {
  48142. currentMesh.freezeWorldMatrix();
  48143. currentMesh._waitingFreezeWorldMatrix = null;
  48144. }
  48145. else {
  48146. currentMesh.computeWorldMatrix(true);
  48147. }
  48148. }
  48149. }
  48150. // Particles
  48151. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  48152. var parser = _abstractScene__WEBPACK_IMPORTED_MODULE_14__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_12__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  48153. if (parser) {
  48154. for (index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  48155. var parsedParticleSystem = parsedData.particleSystems[index];
  48156. if (hierarchyIds.indexOf(parsedParticleSystem.emitterId) !== -1) {
  48157. particleSystems.push(parser(parsedParticleSystem, scene, rootUrl));
  48158. }
  48159. }
  48160. }
  48161. }
  48162. return true;
  48163. }
  48164. catch (err) {
  48165. var msg = logOperation("importMesh", parsedData ? parsedData.producer : "Unknown") + log;
  48166. if (onError) {
  48167. onError(msg, err);
  48168. }
  48169. else {
  48170. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48171. throw err;
  48172. }
  48173. }
  48174. finally {
  48175. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48176. _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 : ""));
  48177. }
  48178. }
  48179. return false;
  48180. },
  48181. load: function (scene, data, rootUrl, onError) {
  48182. // Entire method running in try block, so ALWAYS logs as far as it got, only actually writes details
  48183. // when SceneLoader.debugLogging = true (default), or exception encountered.
  48184. // Everything stored in var log instead of writing separate lines to support only writing in exception,
  48185. // and avoid problems with multiple concurrent .babylon loads.
  48186. var log = "importScene has failed JSON parse";
  48187. try {
  48188. var parsedData = JSON.parse(data);
  48189. log = "";
  48190. // Scene
  48191. if (parsedData.useDelayedTextureLoading !== undefined && parsedData.useDelayedTextureLoading !== null) {
  48192. scene.useDelayedTextureLoading = parsedData.useDelayedTextureLoading && !_Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].ForceFullSceneLoadingForIncremental;
  48193. }
  48194. if (parsedData.autoClear !== undefined && parsedData.autoClear !== null) {
  48195. scene.autoClear = parsedData.autoClear;
  48196. }
  48197. if (parsedData.clearColor !== undefined && parsedData.clearColor !== null) {
  48198. scene.clearColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(parsedData.clearColor);
  48199. }
  48200. if (parsedData.ambientColor !== undefined && parsedData.ambientColor !== null) {
  48201. scene.ambientColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.ambientColor);
  48202. }
  48203. if (parsedData.gravity !== undefined && parsedData.gravity !== null) {
  48204. scene.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.gravity);
  48205. }
  48206. // Fog
  48207. if (parsedData.fogMode && parsedData.fogMode !== 0) {
  48208. scene.fogMode = parsedData.fogMode;
  48209. scene.fogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(parsedData.fogColor);
  48210. scene.fogStart = parsedData.fogStart;
  48211. scene.fogEnd = parsedData.fogEnd;
  48212. scene.fogDensity = parsedData.fogDensity;
  48213. log += "\tFog mode for scene: ";
  48214. switch (scene.fogMode) {
  48215. // getters not compiling, so using hardcoded
  48216. case 1:
  48217. log += "exp\n";
  48218. break;
  48219. case 2:
  48220. log += "exp2\n";
  48221. break;
  48222. case 3:
  48223. log += "linear\n";
  48224. break;
  48225. }
  48226. }
  48227. //Physics
  48228. if (parsedData.physicsEnabled) {
  48229. var physicsPlugin;
  48230. if (parsedData.physicsEngine === "cannon") {
  48231. physicsPlugin = new _Physics_Plugins_cannonJSPlugin__WEBPACK_IMPORTED_MODULE_19__["CannonJSPlugin"]();
  48232. }
  48233. else if (parsedData.physicsEngine === "oimo") {
  48234. physicsPlugin = new _Physics_Plugins_oimoJSPlugin__WEBPACK_IMPORTED_MODULE_20__["OimoJSPlugin"]();
  48235. }
  48236. log = "\tPhysics engine " + (parsedData.physicsEngine ? parsedData.physicsEngine : "oimo") + " enabled\n";
  48237. //else - default engine, which is currently oimo
  48238. var physicsGravity = parsedData.physicsGravity ? _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(parsedData.physicsGravity) : null;
  48239. scene.enablePhysics(physicsGravity, physicsPlugin);
  48240. }
  48241. // Metadata
  48242. if (parsedData.metadata !== undefined && parsedData.metadata !== null) {
  48243. scene.metadata = parsedData.metadata;
  48244. }
  48245. //collisions, if defined. otherwise, default is true
  48246. if (parsedData.collisionsEnabled !== undefined && parsedData.collisionsEnabled !== null) {
  48247. scene.collisionsEnabled = parsedData.collisionsEnabled;
  48248. }
  48249. var container = loadAssetContainer(scene, data, rootUrl, onError, true);
  48250. if (!container) {
  48251. return false;
  48252. }
  48253. if (parsedData.autoAnimate) {
  48254. scene.beginAnimation(scene, parsedData.autoAnimateFrom, parsedData.autoAnimateTo, parsedData.autoAnimateLoop, parsedData.autoAnimateSpeed || 1.0);
  48255. }
  48256. if (parsedData.activeCameraID !== undefined && parsedData.activeCameraID !== null) {
  48257. scene.setActiveCameraByID(parsedData.activeCameraID);
  48258. }
  48259. // Environment texture
  48260. if (parsedData.environmentTexture !== undefined && parsedData.environmentTexture !== null) {
  48261. // PBR needed for both HDR texture (gamma space) & a sky box
  48262. var isPBR = parsedData.isPBR !== undefined ? parsedData.isPBR : true;
  48263. if (parsedData.environmentTextureType && parsedData.environmentTextureType === "BABYLON.HDRCubeTexture") {
  48264. var hdrSize = (parsedData.environmentTextureSize) ? parsedData.environmentTextureSize : 128;
  48265. var hdrTexture = new _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_9__["HDRCubeTexture"](rootUrl + parsedData.environmentTexture, scene, hdrSize, true, !isPBR);
  48266. if (parsedData.environmentTextureRotationY) {
  48267. hdrTexture.rotationY = parsedData.environmentTextureRotationY;
  48268. }
  48269. scene.environmentTexture = hdrTexture;
  48270. }
  48271. else {
  48272. var cubeTexture = _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_8__["CubeTexture"].CreateFromPrefilteredData(rootUrl + parsedData.environmentTexture, scene);
  48273. if (parsedData.environmentTextureRotationY) {
  48274. cubeTexture.rotationY = parsedData.environmentTextureRotationY;
  48275. }
  48276. scene.environmentTexture = cubeTexture;
  48277. }
  48278. if (parsedData.createDefaultSkybox === true) {
  48279. var skyboxScale = (scene.activeCamera !== undefined && scene.activeCamera !== null) ? (scene.activeCamera.maxZ - scene.activeCamera.minZ) / 2 : 1000;
  48280. var skyboxBlurLevel = parsedData.skyboxBlurLevel || 0;
  48281. scene.createDefaultSkybox(scene.environmentTexture, isPBR, skyboxScale, skyboxBlurLevel);
  48282. }
  48283. }
  48284. // Finish
  48285. return true;
  48286. }
  48287. catch (err) {
  48288. var msg = logOperation("importScene", parsedData ? parsedData.producer : "Unknown") + log;
  48289. if (onError) {
  48290. onError(msg, err);
  48291. }
  48292. else {
  48293. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Log(msg);
  48294. throw err;
  48295. }
  48296. }
  48297. finally {
  48298. if (log !== null && _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].loggingLevel !== _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_13__["SceneLoader"].NO_LOGGING) {
  48299. _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 : ""));
  48300. }
  48301. }
  48302. return false;
  48303. },
  48304. loadAssetContainer: function (scene, data, rootUrl, onError) {
  48305. var container = loadAssetContainer(scene, data, rootUrl, onError);
  48306. return container;
  48307. }
  48308. });
  48309. /***/ }),
  48310. /***/ "./Loading/Plugins/index.ts":
  48311. /*!**********************************!*\
  48312. !*** ./Loading/Plugins/index.ts ***!
  48313. \**********************************/
  48314. /*! exports provided: _BabylonLoaderRegistered */
  48315. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48316. "use strict";
  48317. __webpack_require__.r(__webpack_exports__);
  48318. /* harmony import */ var _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./babylonFileLoader */ "./Loading/Plugins/babylonFileLoader.ts");
  48319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _babylonFileLoader__WEBPACK_IMPORTED_MODULE_0__["_BabylonLoaderRegistered"]; });
  48320. /***/ }),
  48321. /***/ "./Loading/index.ts":
  48322. /*!**************************!*\
  48323. !*** ./Loading/index.ts ***!
  48324. \**************************/
  48325. /*! exports provided: DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, _BabylonLoaderRegistered */
  48326. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48327. "use strict";
  48328. __webpack_require__.r(__webpack_exports__);
  48329. /* harmony import */ var _loadingScreen__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./loadingScreen */ "./Loading/loadingScreen.ts");
  48330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _loadingScreen__WEBPACK_IMPORTED_MODULE_0__["DefaultLoadingScreen"]; });
  48331. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Plugins/index */ "./Loading/Plugins/index.ts");
  48332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_1__["_BabylonLoaderRegistered"]; });
  48333. /* harmony import */ var _sceneLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sceneLoader */ "./Loading/sceneLoader.ts");
  48334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoaderProgressEvent"]; });
  48335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _sceneLoader__WEBPACK_IMPORTED_MODULE_2__["SceneLoader"]; });
  48336. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_3__["SceneLoaderFlags"]; });
  48338. /***/ }),
  48339. /***/ "./Loading/loadingScreen.ts":
  48340. /*!**********************************!*\
  48341. !*** ./Loading/loadingScreen.ts ***!
  48342. \**********************************/
  48343. /*! exports provided: DefaultLoadingScreen */
  48344. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48345. "use strict";
  48346. __webpack_require__.r(__webpack_exports__);
  48347. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return DefaultLoadingScreen; });
  48348. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48349. /**
  48350. * Class used for the default loading screen
  48351. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  48352. */
  48353. var DefaultLoadingScreen = /** @class */ (function () {
  48354. /**
  48355. * Creates a new default loading screen
  48356. * @param _renderingCanvas defines the canvas used to render the scene
  48357. * @param _loadingText defines the default text to display
  48358. * @param _loadingDivBackgroundColor defines the default background color
  48359. */
  48360. function DefaultLoadingScreen(_renderingCanvas, _loadingText, _loadingDivBackgroundColor) {
  48361. if (_loadingText === void 0) { _loadingText = ""; }
  48362. if (_loadingDivBackgroundColor === void 0) { _loadingDivBackgroundColor = "black"; }
  48363. var _this = this;
  48364. this._renderingCanvas = _renderingCanvas;
  48365. this._loadingText = _loadingText;
  48366. this._loadingDivBackgroundColor = _loadingDivBackgroundColor;
  48367. // Resize
  48368. this._resizeLoadingUI = function () {
  48369. var canvasRect = _this._renderingCanvas.getBoundingClientRect();
  48370. var canvasPositioning = window.getComputedStyle(_this._renderingCanvas).position;
  48371. if (!_this._loadingDiv) {
  48372. return;
  48373. }
  48374. _this._loadingDiv.style.position = (canvasPositioning === "fixed") ? "fixed" : "absolute";
  48375. _this._loadingDiv.style.left = canvasRect.left + "px";
  48376. _this._loadingDiv.style.top = canvasRect.top + "px";
  48377. _this._loadingDiv.style.width = canvasRect.width + "px";
  48378. _this._loadingDiv.style.height = canvasRect.height + "px";
  48379. };
  48380. }
  48381. /**
  48382. * Function called to display the loading screen
  48383. */
  48384. DefaultLoadingScreen.prototype.displayLoadingUI = function () {
  48385. if (this._loadingDiv) {
  48386. // Do not add a loading screen if there is already one
  48387. return;
  48388. }
  48389. this._loadingDiv = document.createElement("div");
  48390. this._loadingDiv.id = "babylonjsLoadingDiv";
  48391. this._loadingDiv.style.opacity = "0";
  48392. this._loadingDiv.style.transition = "opacity 1.5s ease";
  48393. this._loadingDiv.style.pointerEvents = "none";
  48394. // Loading text
  48395. this._loadingTextDiv = document.createElement("div");
  48396. this._loadingTextDiv.style.position = "absolute";
  48397. this._loadingTextDiv.style.left = "0";
  48398. this._loadingTextDiv.style.top = "50%";
  48399. this._loadingTextDiv.style.marginTop = "80px";
  48400. this._loadingTextDiv.style.width = "100%";
  48401. this._loadingTextDiv.style.height = "20px";
  48402. this._loadingTextDiv.style.fontFamily = "Arial";
  48403. this._loadingTextDiv.style.fontSize = "14px";
  48404. this._loadingTextDiv.style.color = "white";
  48405. this._loadingTextDiv.style.textAlign = "center";
  48406. this._loadingTextDiv.innerHTML = "Loading";
  48407. this._loadingDiv.appendChild(this._loadingTextDiv);
  48408. //set the predefined text
  48409. this._loadingTextDiv.innerHTML = this._loadingText;
  48410. // Generating keyframes
  48411. var style = document.createElement('style');
  48412. style.type = 'text/css';
  48413. 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 }";
  48414. style.innerHTML = keyFrames;
  48415. document.getElementsByTagName('head')[0].appendChild(style);
  48416. // Loading img
  48417. var imgBack = new Image();
  48418. 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";
  48419. imgBack.style.position = "absolute";
  48420. imgBack.style.left = "50%";
  48421. imgBack.style.top = "50%";
  48422. imgBack.style.marginLeft = "-60px";
  48423. imgBack.style.marginTop = "-60px";
  48424. imgBack.style.animation = "spin1 2s infinite ease-in-out";
  48425. imgBack.style.webkitAnimation = "spin1 2s infinite ease-in-out";
  48426. imgBack.style.transformOrigin = "50% 50%";
  48427. imgBack.style.webkitTransformOrigin = "50% 50%";
  48428. this._loadingDiv.appendChild(imgBack);
  48429. this._resizeLoadingUI();
  48430. window.addEventListener("resize", this._resizeLoadingUI);
  48431. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48432. document.body.appendChild(this._loadingDiv);
  48433. this._loadingDiv.style.opacity = "1";
  48434. };
  48435. /**
  48436. * Function called to hide the loading screen
  48437. */
  48438. DefaultLoadingScreen.prototype.hideLoadingUI = function () {
  48439. var _this = this;
  48440. if (!this._loadingDiv) {
  48441. return;
  48442. }
  48443. var onTransitionEnd = function () {
  48444. if (!_this._loadingDiv) {
  48445. return;
  48446. }
  48447. if (_this._loadingDiv.parentElement) {
  48448. _this._loadingDiv.parentElement.removeChild(_this._loadingDiv);
  48449. }
  48450. window.removeEventListener("resize", _this._resizeLoadingUI);
  48451. _this._loadingDiv = null;
  48452. };
  48453. this._loadingDiv.style.opacity = "0";
  48454. this._loadingDiv.addEventListener("transitionend", onTransitionEnd);
  48455. };
  48456. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIText", {
  48457. get: function () {
  48458. return this._loadingText;
  48459. },
  48460. /**
  48461. * Gets or sets the text to display while loading
  48462. */
  48463. set: function (text) {
  48464. this._loadingText = text;
  48465. if (this._loadingTextDiv) {
  48466. this._loadingTextDiv.innerHTML = this._loadingText;
  48467. }
  48468. },
  48469. enumerable: true,
  48470. configurable: true
  48471. });
  48472. Object.defineProperty(DefaultLoadingScreen.prototype, "loadingUIBackgroundColor", {
  48473. /**
  48474. * Gets or sets the color to use for the background
  48475. */
  48476. get: function () {
  48477. return this._loadingDivBackgroundColor;
  48478. },
  48479. set: function (color) {
  48480. this._loadingDivBackgroundColor = color;
  48481. if (!this._loadingDiv) {
  48482. return;
  48483. }
  48484. this._loadingDiv.style.backgroundColor = this._loadingDivBackgroundColor;
  48485. },
  48486. enumerable: true,
  48487. configurable: true
  48488. });
  48489. return DefaultLoadingScreen;
  48490. }());
  48491. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].DefaultLoadingScreenFactory = function (canvas) { return new DefaultLoadingScreen(canvas); };
  48492. /***/ }),
  48493. /***/ "./Loading/sceneLoader.ts":
  48494. /*!********************************!*\
  48495. !*** ./Loading/sceneLoader.ts ***!
  48496. \********************************/
  48497. /*! exports provided: SceneLoaderProgressEvent, SceneLoader */
  48498. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  48499. "use strict";
  48500. __webpack_require__.r(__webpack_exports__);
  48501. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return SceneLoaderProgressEvent; });
  48502. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return SceneLoader; });
  48503. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  48504. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  48505. /* harmony import */ var _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/filesInputStore */ "./Misc/filesInputStore.ts");
  48506. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  48507. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  48508. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  48509. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  48510. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  48511. /* harmony import */ var _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  48512. /**
  48513. * Class used to represent data loading progression
  48514. */
  48515. var SceneLoaderProgressEvent = /** @class */ (function () {
  48516. /**
  48517. * Create a new progress event
  48518. * @param lengthComputable defines if data length to load can be evaluated
  48519. * @param loaded defines the loaded data length
  48520. * @param total defines the data length to load
  48521. */
  48522. function SceneLoaderProgressEvent(
  48523. /** defines if data length to load can be evaluated */
  48524. lengthComputable,
  48525. /** defines the loaded data length */
  48526. loaded,
  48527. /** defines the data length to load */
  48528. total) {
  48529. this.lengthComputable = lengthComputable;
  48530. this.loaded = loaded;
  48531. this.total = total;
  48532. }
  48533. /**
  48534. * Creates a new SceneLoaderProgressEvent from a ProgressEvent
  48535. * @param event defines the source event
  48536. * @returns a new SceneLoaderProgressEvent
  48537. */
  48538. SceneLoaderProgressEvent.FromProgressEvent = function (event) {
  48539. return new SceneLoaderProgressEvent(event.lengthComputable, event.loaded, event.total);
  48540. };
  48541. return SceneLoaderProgressEvent;
  48542. }());
  48543. /**
  48544. * Class used to load scene from various file formats using registered plugins
  48545. * @see http://doc.babylonjs.com/how_to/load_from_any_file_type
  48546. */
  48547. var SceneLoader = /** @class */ (function () {
  48548. function SceneLoader() {
  48549. }
  48550. Object.defineProperty(SceneLoader, "ForceFullSceneLoadingForIncremental", {
  48551. /**
  48552. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  48553. */
  48554. get: function () {
  48555. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental;
  48556. },
  48557. set: function (value) {
  48558. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental = value;
  48559. },
  48560. enumerable: true,
  48561. configurable: true
  48562. });
  48563. Object.defineProperty(SceneLoader, "ShowLoadingScreen", {
  48564. /**
  48565. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  48566. */
  48567. get: function () {
  48568. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen;
  48569. },
  48570. set: function (value) {
  48571. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].ShowLoadingScreen = value;
  48572. },
  48573. enumerable: true,
  48574. configurable: true
  48575. });
  48576. Object.defineProperty(SceneLoader, "loggingLevel", {
  48577. /**
  48578. * Defines the current logging level (while loading the scene)
  48579. * @ignorenaming
  48580. */
  48581. get: function () {
  48582. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel;
  48583. },
  48584. set: function (value) {
  48585. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].loggingLevel = value;
  48586. },
  48587. enumerable: true,
  48588. configurable: true
  48589. });
  48590. Object.defineProperty(SceneLoader, "CleanBoneMatrixWeights", {
  48591. /**
  48592. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  48593. */
  48594. get: function () {
  48595. return _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights;
  48596. },
  48597. set: function (value) {
  48598. _sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_8__["SceneLoaderFlags"].CleanBoneMatrixWeights = value;
  48599. },
  48600. enumerable: true,
  48601. configurable: true
  48602. });
  48603. SceneLoader._getDefaultPlugin = function () {
  48604. return SceneLoader._registeredPlugins[".babylon"];
  48605. };
  48606. SceneLoader._getPluginForExtension = function (extension) {
  48607. var registeredPlugin = SceneLoader._registeredPlugins[extension];
  48608. if (registeredPlugin) {
  48609. return registeredPlugin;
  48610. }
  48611. _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");
  48612. return SceneLoader._getDefaultPlugin();
  48613. };
  48614. SceneLoader._getPluginForDirectLoad = function (data) {
  48615. for (var extension in SceneLoader._registeredPlugins) {
  48616. var plugin = SceneLoader._registeredPlugins[extension].plugin;
  48617. if (plugin.canDirectLoad && plugin.canDirectLoad(data)) {
  48618. return SceneLoader._registeredPlugins[extension];
  48619. }
  48620. }
  48621. return SceneLoader._getDefaultPlugin();
  48622. };
  48623. SceneLoader._getPluginForFilename = function (sceneFilename) {
  48624. var queryStringPosition = sceneFilename.indexOf("?");
  48625. if (queryStringPosition !== -1) {
  48626. sceneFilename = sceneFilename.substring(0, queryStringPosition);
  48627. }
  48628. var dotPosition = sceneFilename.lastIndexOf(".");
  48629. var extension = sceneFilename.substring(dotPosition, sceneFilename.length).toLowerCase();
  48630. return SceneLoader._getPluginForExtension(extension);
  48631. };
  48632. // use babylon file loader directly if sceneFilename is prefixed with "data:"
  48633. SceneLoader._getDirectLoad = function (sceneFilename) {
  48634. if (sceneFilename.substr(0, 5) === "data:") {
  48635. return sceneFilename.substr(5);
  48636. }
  48637. return null;
  48638. };
  48639. SceneLoader._loadData = function (fileInfo, scene, onSuccess, onProgress, onError, onDispose, pluginExtension) {
  48640. var directLoad = SceneLoader._getDirectLoad(fileInfo.name);
  48641. var registeredPlugin = pluginExtension ? SceneLoader._getPluginForExtension(pluginExtension) : (directLoad ? SceneLoader._getPluginForDirectLoad(fileInfo.name) : SceneLoader._getPluginForFilename(fileInfo.name));
  48642. var plugin;
  48643. if (registeredPlugin.plugin.createPlugin) {
  48644. plugin = registeredPlugin.plugin.createPlugin();
  48645. }
  48646. else {
  48647. plugin = registeredPlugin.plugin;
  48648. }
  48649. if (!plugin) {
  48650. 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.";
  48651. }
  48652. var useArrayBuffer = registeredPlugin.isBinary;
  48653. var offlineProvider;
  48654. SceneLoader.OnPluginActivatedObservable.notifyObservers(plugin);
  48655. var dataCallback = function (data, responseURL) {
  48656. if (scene.isDisposed) {
  48657. onError("Scene has been disposed");
  48658. return;
  48659. }
  48660. scene.offlineProvider = offlineProvider;
  48661. onSuccess(plugin, data, responseURL);
  48662. };
  48663. var request = null;
  48664. var pluginDisposed = false;
  48665. var onDisposeObservable = plugin.onDisposeObservable;
  48666. if (onDisposeObservable) {
  48667. onDisposeObservable.add(function () {
  48668. pluginDisposed = true;
  48669. if (request) {
  48670. request.abort();
  48671. request = null;
  48672. }
  48673. onDispose();
  48674. });
  48675. }
  48676. var manifestChecked = function () {
  48677. if (pluginDisposed) {
  48678. return;
  48679. }
  48680. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(fileInfo.url, dataCallback, onProgress ? function (event) {
  48681. onProgress(SceneLoaderProgressEvent.FromProgressEvent(event));
  48682. } : undefined, offlineProvider, useArrayBuffer, function (request, exception) {
  48683. onError("Failed to load scene." + (exception ? " " + exception.message : ""), exception);
  48684. });
  48685. };
  48686. if (directLoad) {
  48687. dataCallback(directLoad);
  48688. return plugin;
  48689. }
  48690. var file = fileInfo.file || _Misc_filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad[fileInfo.name.toLowerCase()];
  48691. if (fileInfo.rootUrl.indexOf("file:") === -1 || (fileInfo.rootUrl.indexOf("file:") !== -1 && !file)) {
  48692. var engine = scene.getEngine();
  48693. var canUseOfflineSupport = engine.enableOfflineSupport;
  48694. if (canUseOfflineSupport) {
  48695. // Also check for exceptions
  48696. var exceptionFound = false;
  48697. for (var _i = 0, _a = scene.disableOfflineSupportExceptionRules; _i < _a.length; _i++) {
  48698. var regex = _a[_i];
  48699. if (regex.test(fileInfo.url)) {
  48700. exceptionFound = true;
  48701. break;
  48702. }
  48703. }
  48704. canUseOfflineSupport = !exceptionFound;
  48705. }
  48706. if (canUseOfflineSupport && _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory) {
  48707. // Checking if a manifest file has been set for this scene and if offline mode has been requested
  48708. offlineProvider = _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].OfflineProviderFactory(fileInfo.url, manifestChecked, engine.disableManifestCheck);
  48709. }
  48710. else {
  48711. manifestChecked();
  48712. }
  48713. }
  48714. // Loading file from disk via input file or drag'n'drop
  48715. else {
  48716. if (file) {
  48717. request = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ReadFile(file, dataCallback, onProgress, useArrayBuffer);
  48718. }
  48719. else {
  48720. onError("Unable to find file named " + fileInfo.name);
  48721. }
  48722. }
  48723. return plugin;
  48724. };
  48725. SceneLoader._getFileInfo = function (rootUrl, sceneFilename) {
  48726. var url;
  48727. var name;
  48728. var file = null;
  48729. if (!sceneFilename) {
  48730. url = rootUrl;
  48731. name = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFilename(rootUrl);
  48732. rootUrl = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetFolderPath(rootUrl);
  48733. }
  48734. else if (sceneFilename.name) {
  48735. var sceneFile = sceneFilename;
  48736. url = rootUrl + sceneFile.name;
  48737. name = sceneFile.name;
  48738. file = sceneFile;
  48739. }
  48740. else {
  48741. var filename = sceneFilename;
  48742. if (filename.substr(0, 1) === "/") {
  48743. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("Wrong sceneFilename parameter");
  48744. return null;
  48745. }
  48746. url = rootUrl + filename;
  48747. name = filename;
  48748. }
  48749. return {
  48750. url: url,
  48751. rootUrl: rootUrl,
  48752. name: name,
  48753. file: file
  48754. };
  48755. };
  48756. // Public functions
  48757. /**
  48758. * Gets a plugin that can load the given extension
  48759. * @param extension defines the extension to load
  48760. * @returns a plugin or null if none works
  48761. */
  48762. SceneLoader.GetPluginForExtension = function (extension) {
  48763. return SceneLoader._getPluginForExtension(extension).plugin;
  48764. };
  48765. /**
  48766. * Gets a boolean indicating that the given extension can be loaded
  48767. * @param extension defines the extension to load
  48768. * @returns true if the extension is supported
  48769. */
  48770. SceneLoader.IsPluginForExtensionAvailable = function (extension) {
  48771. return !!SceneLoader._registeredPlugins[extension];
  48772. };
  48773. /**
  48774. * Adds a new plugin to the list of registered plugins
  48775. * @param plugin defines the plugin to add
  48776. */
  48777. SceneLoader.RegisterPlugin = function (plugin) {
  48778. if (typeof plugin.extensions === "string") {
  48779. var extension = plugin.extensions;
  48780. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48781. plugin: plugin,
  48782. isBinary: false
  48783. };
  48784. }
  48785. else {
  48786. var extensions = plugin.extensions;
  48787. Object.keys(extensions).forEach(function (extension) {
  48788. SceneLoader._registeredPlugins[extension.toLowerCase()] = {
  48789. plugin: plugin,
  48790. isBinary: extensions[extension].isBinary
  48791. };
  48792. });
  48793. }
  48794. };
  48795. /**
  48796. * Import meshes into a scene
  48797. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48798. * @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)
  48799. * @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)
  48800. * @param scene the instance of BABYLON.Scene to append to
  48801. * @param onSuccess a callback with a list of imported meshes, particleSystems, and skeletons when import succeeds
  48802. * @param onProgress a callback with a progress event for each file being loaded
  48803. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48804. * @param pluginExtension the extension used to determine the plugin
  48805. * @returns The loaded plugin
  48806. */
  48807. SceneLoader.ImportMesh = function (meshNames, rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48808. if (sceneFilename === void 0) { sceneFilename = ""; }
  48809. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48810. if (onSuccess === void 0) { onSuccess = null; }
  48811. if (onProgress === void 0) { onProgress = null; }
  48812. if (onError === void 0) { onError = null; }
  48813. if (pluginExtension === void 0) { pluginExtension = null; }
  48814. if (!scene) {
  48815. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to import mesh to");
  48816. return null;
  48817. }
  48818. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48819. if (!fileInfo) {
  48820. return null;
  48821. }
  48822. var loadingToken = {};
  48823. scene._addPendingData(loadingToken);
  48824. var disposeHandler = function () {
  48825. scene._removePendingData(loadingToken);
  48826. };
  48827. var errorHandler = function (message, exception) {
  48828. var errorMessage = "Unable to import meshes from " + fileInfo.url + ": " + message;
  48829. if (onError) {
  48830. onError(scene, errorMessage, exception);
  48831. }
  48832. else {
  48833. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  48834. // should the exception be thrown?
  48835. }
  48836. disposeHandler();
  48837. };
  48838. var progressHandler = onProgress ? function (event) {
  48839. try {
  48840. onProgress(event);
  48841. }
  48842. catch (e) {
  48843. errorHandler("Error in onProgress callback", e);
  48844. }
  48845. } : undefined;
  48846. var successHandler = function (meshes, particleSystems, skeletons, animationGroups) {
  48847. scene.importedMeshesFiles.push(fileInfo.url);
  48848. if (onSuccess) {
  48849. try {
  48850. onSuccess(meshes, particleSystems, skeletons, animationGroups);
  48851. }
  48852. catch (e) {
  48853. errorHandler("Error in onSuccess callback", e);
  48854. }
  48855. }
  48856. scene._removePendingData(loadingToken);
  48857. };
  48858. return SceneLoader._loadData(fileInfo, scene, function (plugin, data, responseURL) {
  48859. if (plugin.rewriteRootURL) {
  48860. fileInfo.rootUrl = plugin.rewriteRootURL(fileInfo.rootUrl, responseURL);
  48861. }
  48862. if (plugin.importMesh) {
  48863. var syncedPlugin = plugin;
  48864. var meshes = new Array();
  48865. var particleSystems = new Array();
  48866. var skeletons = new Array();
  48867. if (!syncedPlugin.importMesh(meshNames, scene, data, fileInfo.rootUrl, meshes, particleSystems, skeletons, errorHandler)) {
  48868. return;
  48869. }
  48870. scene.loadingPluginName = plugin.name;
  48871. successHandler(meshes, particleSystems, skeletons, []);
  48872. }
  48873. else {
  48874. var asyncedPlugin = plugin;
  48875. asyncedPlugin.importMeshAsync(meshNames, scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (result) {
  48876. scene.loadingPluginName = plugin.name;
  48877. successHandler(result.meshes, result.particleSystems, result.skeletons, result.animationGroups);
  48878. }).catch(function (error) {
  48879. errorHandler(error.message, error);
  48880. });
  48881. }
  48882. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  48883. };
  48884. /**
  48885. * Import meshes into a scene
  48886. * @param meshNames an array of mesh names, a single mesh name, or empty string for all meshes that filter what meshes are imported
  48887. * @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)
  48888. * @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)
  48889. * @param scene the instance of BABYLON.Scene to append to
  48890. * @param onProgress a callback with a progress event for each file being loaded
  48891. * @param pluginExtension the extension used to determine the plugin
  48892. * @returns The loaded list of imported meshes, particle systems, skeletons, and animation groups
  48893. */
  48894. SceneLoader.ImportMeshAsync = function (meshNames, rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  48895. if (sceneFilename === void 0) { sceneFilename = ""; }
  48896. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48897. if (onProgress === void 0) { onProgress = null; }
  48898. if (pluginExtension === void 0) { pluginExtension = null; }
  48899. return new Promise(function (resolve, reject) {
  48900. SceneLoader.ImportMesh(meshNames, rootUrl, sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  48901. resolve({
  48902. meshes: meshes,
  48903. particleSystems: particleSystems,
  48904. skeletons: skeletons,
  48905. animationGroups: animationGroups
  48906. });
  48907. }, onProgress, function (scene, message, exception) {
  48908. reject(exception || new Error(message));
  48909. }, pluginExtension);
  48910. });
  48911. };
  48912. /**
  48913. * Load a scene
  48914. * @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)
  48915. * @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)
  48916. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48917. * @param onSuccess a callback with the scene when import succeeds
  48918. * @param onProgress a callback with a progress event for each file being loaded
  48919. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48920. * @param pluginExtension the extension used to determine the plugin
  48921. * @returns The loaded plugin
  48922. */
  48923. SceneLoader.Load = function (rootUrl, sceneFilename, engine, onSuccess, onProgress, onError, pluginExtension) {
  48924. if (sceneFilename === void 0) { sceneFilename = ""; }
  48925. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48926. if (onSuccess === void 0) { onSuccess = null; }
  48927. if (onProgress === void 0) { onProgress = null; }
  48928. if (onError === void 0) { onError = null; }
  48929. if (pluginExtension === void 0) { pluginExtension = null; }
  48930. if (!engine) {
  48931. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].Error("No engine available");
  48932. return null;
  48933. }
  48934. return SceneLoader.Append(rootUrl, sceneFilename, new _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"](engine), onSuccess, onProgress, onError, pluginExtension);
  48935. };
  48936. /**
  48937. * Load a scene
  48938. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  48939. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  48940. * @param engine is the instance of BABYLON.Engine to use to create the scene
  48941. * @param onProgress a callback with a progress event for each file being loaded
  48942. * @param pluginExtension the extension used to determine the plugin
  48943. * @returns The loaded scene
  48944. */
  48945. SceneLoader.LoadAsync = function (rootUrl, sceneFilename, engine, onProgress, pluginExtension) {
  48946. if (sceneFilename === void 0) { sceneFilename = ""; }
  48947. if (engine === void 0) { engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedEngine; }
  48948. if (onProgress === void 0) { onProgress = null; }
  48949. if (pluginExtension === void 0) { pluginExtension = null; }
  48950. return new Promise(function (resolve, reject) {
  48951. SceneLoader.Load(rootUrl, sceneFilename, engine, function (scene) {
  48952. resolve(scene);
  48953. }, onProgress, function (scene, message, exception) {
  48954. reject(exception || new Error(message));
  48955. }, pluginExtension);
  48956. });
  48957. };
  48958. /**
  48959. * Append a scene
  48960. * @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)
  48961. * @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)
  48962. * @param scene is the instance of BABYLON.Scene to append to
  48963. * @param onSuccess a callback with the scene when import succeeds
  48964. * @param onProgress a callback with a progress event for each file being loaded
  48965. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  48966. * @param pluginExtension the extension used to determine the plugin
  48967. * @returns The loaded plugin
  48968. */
  48969. SceneLoader.Append = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  48970. if (sceneFilename === void 0) { sceneFilename = ""; }
  48971. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  48972. if (onSuccess === void 0) { onSuccess = null; }
  48973. if (onProgress === void 0) { onProgress = null; }
  48974. if (onError === void 0) { onError = null; }
  48975. if (pluginExtension === void 0) { pluginExtension = null; }
  48976. if (!scene) {
  48977. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to append to");
  48978. return null;
  48979. }
  48980. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  48981. if (!fileInfo) {
  48982. return null;
  48983. }
  48984. if (SceneLoader.ShowLoadingScreen) {
  48985. scene.getEngine().displayLoadingUI();
  48986. }
  48987. var loadingToken = {};
  48988. scene._addPendingData(loadingToken);
  48989. var disposeHandler = function () {
  48990. scene._removePendingData(loadingToken);
  48991. scene.getEngine().hideLoadingUI();
  48992. };
  48993. var errorHandler = function (message, exception) {
  48994. var errorMessage = "Unable to load from " + fileInfo.url + (message ? ": " + message : "");
  48995. if (onError) {
  48996. onError(scene, errorMessage, exception);
  48997. }
  48998. else {
  48999. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49000. // should the exception be thrown?
  49001. }
  49002. disposeHandler();
  49003. };
  49004. var progressHandler = onProgress ? function (event) {
  49005. try {
  49006. onProgress(event);
  49007. }
  49008. catch (e) {
  49009. errorHandler("Error in onProgress callback", e);
  49010. }
  49011. } : undefined;
  49012. var successHandler = function () {
  49013. if (onSuccess) {
  49014. try {
  49015. onSuccess(scene);
  49016. }
  49017. catch (e) {
  49018. errorHandler("Error in onSuccess callback", e);
  49019. }
  49020. }
  49021. scene._removePendingData(loadingToken);
  49022. };
  49023. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49024. if (plugin.load) {
  49025. var syncedPlugin = plugin;
  49026. if (!syncedPlugin.load(scene, data, fileInfo.rootUrl, errorHandler)) {
  49027. return;
  49028. }
  49029. scene.loadingPluginName = plugin.name;
  49030. successHandler();
  49031. }
  49032. else {
  49033. var asyncedPlugin = plugin;
  49034. asyncedPlugin.loadAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function () {
  49035. scene.loadingPluginName = plugin.name;
  49036. successHandler();
  49037. }).catch(function (error) {
  49038. errorHandler(error.message, error);
  49039. });
  49040. }
  49041. if (SceneLoader.ShowLoadingScreen) {
  49042. scene.executeWhenReady(function () {
  49043. scene.getEngine().hideLoadingUI();
  49044. });
  49045. }
  49046. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49047. };
  49048. /**
  49049. * Append a scene
  49050. * @param rootUrl a string that defines the root url for the scene and resources or the concatenation of rootURL and filename (e.g. http://example.com/test.glb)
  49051. * @param sceneFilename a string that defines the name of the scene file or starts with "data:" following by the stringified version of the scene or a File object (default: empty string)
  49052. * @param scene is the instance of BABYLON.Scene to append to
  49053. * @param onProgress a callback with a progress event for each file being loaded
  49054. * @param pluginExtension the extension used to determine the plugin
  49055. * @returns The given scene
  49056. */
  49057. SceneLoader.AppendAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49058. if (sceneFilename === void 0) { sceneFilename = ""; }
  49059. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49060. if (onProgress === void 0) { onProgress = null; }
  49061. if (pluginExtension === void 0) { pluginExtension = null; }
  49062. return new Promise(function (resolve, reject) {
  49063. SceneLoader.Append(rootUrl, sceneFilename, scene, function (scene) {
  49064. resolve(scene);
  49065. }, onProgress, function (scene, message, exception) {
  49066. reject(exception || new Error(message));
  49067. }, pluginExtension);
  49068. });
  49069. };
  49070. /**
  49071. * Load a scene into an asset container
  49072. * @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)
  49073. * @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)
  49074. * @param scene is the instance of BABYLON.Scene to append to (default: last created scene)
  49075. * @param onSuccess a callback with the scene when import succeeds
  49076. * @param onProgress a callback with a progress event for each file being loaded
  49077. * @param onError a callback with the scene, a message, and possibly an exception when import fails
  49078. * @param pluginExtension the extension used to determine the plugin
  49079. * @returns The loaded plugin
  49080. */
  49081. SceneLoader.LoadAssetContainer = function (rootUrl, sceneFilename, scene, onSuccess, onProgress, onError, pluginExtension) {
  49082. if (sceneFilename === void 0) { sceneFilename = ""; }
  49083. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49084. if (onSuccess === void 0) { onSuccess = null; }
  49085. if (onProgress === void 0) { onProgress = null; }
  49086. if (onError === void 0) { onError = null; }
  49087. if (pluginExtension === void 0) { pluginExtension = null; }
  49088. if (!scene) {
  49089. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error("No scene available to load asset container to");
  49090. return null;
  49091. }
  49092. var fileInfo = SceneLoader._getFileInfo(rootUrl, sceneFilename);
  49093. if (!fileInfo) {
  49094. return null;
  49095. }
  49096. var loadingToken = {};
  49097. scene._addPendingData(loadingToken);
  49098. var disposeHandler = function () {
  49099. scene._removePendingData(loadingToken);
  49100. };
  49101. var errorHandler = function (message, exception) {
  49102. var errorMessage = "Unable to load assets from " + fileInfo.url + (message ? ": " + message : "");
  49103. if (onError) {
  49104. onError(scene, errorMessage, exception);
  49105. }
  49106. else {
  49107. _Misc_logger__WEBPACK_IMPORTED_MODULE_6__["Logger"].Error(errorMessage);
  49108. // should the exception be thrown?
  49109. }
  49110. disposeHandler();
  49111. };
  49112. var progressHandler = onProgress ? function (event) {
  49113. try {
  49114. onProgress(event);
  49115. }
  49116. catch (e) {
  49117. errorHandler("Error in onProgress callback", e);
  49118. }
  49119. } : undefined;
  49120. var successHandler = function (assets) {
  49121. if (onSuccess) {
  49122. try {
  49123. onSuccess(assets);
  49124. }
  49125. catch (e) {
  49126. errorHandler("Error in onSuccess callback", e);
  49127. }
  49128. }
  49129. scene._removePendingData(loadingToken);
  49130. };
  49131. return SceneLoader._loadData(fileInfo, scene, function (plugin, data) {
  49132. if (plugin.loadAssetContainer) {
  49133. var syncedPlugin = plugin;
  49134. var assetContainer = syncedPlugin.loadAssetContainer(scene, data, fileInfo.rootUrl, errorHandler);
  49135. if (!assetContainer) {
  49136. return;
  49137. }
  49138. scene.loadingPluginName = plugin.name;
  49139. successHandler(assetContainer);
  49140. }
  49141. else if (plugin.loadAssetContainerAsync) {
  49142. var asyncedPlugin = plugin;
  49143. asyncedPlugin.loadAssetContainerAsync(scene, data, fileInfo.rootUrl, progressHandler, fileInfo.name).then(function (assetContainer) {
  49144. scene.loadingPluginName = plugin.name;
  49145. successHandler(assetContainer);
  49146. }).catch(function (error) {
  49147. errorHandler(error.message, error);
  49148. });
  49149. }
  49150. else {
  49151. errorHandler("LoadAssetContainer is not supported by this plugin. Plugin did not provide a loadAssetContainer or loadAssetContainerAsync method.");
  49152. }
  49153. if (SceneLoader.ShowLoadingScreen) {
  49154. scene.executeWhenReady(function () {
  49155. scene.getEngine().hideLoadingUI();
  49156. });
  49157. }
  49158. }, progressHandler, errorHandler, disposeHandler, pluginExtension);
  49159. };
  49160. /**
  49161. * Load a scene into an asset container
  49162. * @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)
  49163. * @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)
  49164. * @param scene is the instance of Scene to append to
  49165. * @param onProgress a callback with a progress event for each file being loaded
  49166. * @param pluginExtension the extension used to determine the plugin
  49167. * @returns The loaded asset container
  49168. */
  49169. SceneLoader.LoadAssetContainerAsync = function (rootUrl, sceneFilename, scene, onProgress, pluginExtension) {
  49170. if (sceneFilename === void 0) { sceneFilename = ""; }
  49171. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene; }
  49172. if (onProgress === void 0) { onProgress = null; }
  49173. if (pluginExtension === void 0) { pluginExtension = null; }
  49174. return new Promise(function (resolve, reject) {
  49175. SceneLoader.LoadAssetContainer(rootUrl, sceneFilename, scene, function (assetContainer) {
  49176. resolve(assetContainer);
  49177. }, onProgress, function (scene, message, exception) {
  49178. reject(exception || new Error(message));
  49179. }, pluginExtension);
  49180. });
  49181. };
  49182. /**
  49183. * No logging while loading
  49184. */
  49185. SceneLoader.NO_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_NO_LOGGING;
  49186. /**
  49187. * Minimal logging while loading
  49188. */
  49189. SceneLoader.MINIMAL_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_MINIMAL_LOGGING;
  49190. /**
  49191. * Summary logging while loading
  49192. */
  49193. SceneLoader.SUMMARY_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_SUMMARY_LOGGING;
  49194. /**
  49195. * Detailled logging while loading
  49196. */
  49197. SceneLoader.DETAILED_LOGGING = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].SCENELOADER_DETAILED_LOGGING;
  49198. // Members
  49199. /**
  49200. * Event raised when a plugin is used to load a scene
  49201. */
  49202. SceneLoader.OnPluginActivatedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  49203. SceneLoader._registeredPlugins = {};
  49204. return SceneLoader;
  49205. }());
  49206. /***/ }),
  49207. /***/ "./Loading/sceneLoaderFlags.ts":
  49208. /*!*************************************!*\
  49209. !*** ./Loading/sceneLoaderFlags.ts ***!
  49210. \*************************************/
  49211. /*! exports provided: SceneLoaderFlags */
  49212. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49213. "use strict";
  49214. __webpack_require__.r(__webpack_exports__);
  49215. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return SceneLoaderFlags; });
  49216. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  49217. /**
  49218. * Class used to represent data loading progression
  49219. */
  49220. var SceneLoaderFlags = /** @class */ (function () {
  49221. function SceneLoaderFlags() {
  49222. }
  49223. Object.defineProperty(SceneLoaderFlags, "ForceFullSceneLoadingForIncremental", {
  49224. /**
  49225. * Gets or sets a boolean indicating if entire scene must be loaded even if scene contains incremental data
  49226. */
  49227. get: function () {
  49228. return SceneLoaderFlags._ForceFullSceneLoadingForIncremental;
  49229. },
  49230. set: function (value) {
  49231. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = value;
  49232. },
  49233. enumerable: true,
  49234. configurable: true
  49235. });
  49236. Object.defineProperty(SceneLoaderFlags, "ShowLoadingScreen", {
  49237. /**
  49238. * Gets or sets a boolean indicating if loading screen must be displayed while loading a scene
  49239. */
  49240. get: function () {
  49241. return SceneLoaderFlags._ShowLoadingScreen;
  49242. },
  49243. set: function (value) {
  49244. SceneLoaderFlags._ShowLoadingScreen = value;
  49245. },
  49246. enumerable: true,
  49247. configurable: true
  49248. });
  49249. Object.defineProperty(SceneLoaderFlags, "loggingLevel", {
  49250. /**
  49251. * Defines the current logging level (while loading the scene)
  49252. * @ignorenaming
  49253. */
  49254. get: function () {
  49255. return SceneLoaderFlags._loggingLevel;
  49256. },
  49257. set: function (value) {
  49258. SceneLoaderFlags._loggingLevel = value;
  49259. },
  49260. enumerable: true,
  49261. configurable: true
  49262. });
  49263. Object.defineProperty(SceneLoaderFlags, "CleanBoneMatrixWeights", {
  49264. /**
  49265. * Gets or set a boolean indicating if matrix weights must be cleaned upon loading
  49266. */
  49267. get: function () {
  49268. return SceneLoaderFlags._CleanBoneMatrixWeights;
  49269. },
  49270. set: function (value) {
  49271. SceneLoaderFlags._CleanBoneMatrixWeights = value;
  49272. },
  49273. enumerable: true,
  49274. configurable: true
  49275. });
  49276. // Flags
  49277. SceneLoaderFlags._ForceFullSceneLoadingForIncremental = false;
  49278. SceneLoaderFlags._ShowLoadingScreen = true;
  49279. SceneLoaderFlags._CleanBoneMatrixWeights = false;
  49280. SceneLoaderFlags._loggingLevel = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].SCENELOADER_NO_LOGGING;
  49281. return SceneLoaderFlags;
  49282. }());
  49283. /***/ }),
  49284. /***/ "./Materials/Background/backgroundMaterial.ts":
  49285. /*!****************************************************!*\
  49286. !*** ./Materials/Background/backgroundMaterial.ts ***!
  49287. \****************************************************/
  49288. /*! exports provided: BackgroundMaterial */
  49289. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  49290. "use strict";
  49291. __webpack_require__.r(__webpack_exports__);
  49292. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return BackgroundMaterial; });
  49293. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  49294. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  49295. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  49296. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  49297. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  49298. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  49299. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  49300. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  49301. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  49302. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  49303. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  49304. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  49305. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  49306. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  49307. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  49308. /* harmony import */ var _Shaders_background_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Shaders/background.fragment */ "./Shaders/background.fragment.ts");
  49309. /* harmony import */ var _Shaders_background_vertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../Shaders/background.vertex */ "./Shaders/background.vertex.ts");
  49310. /**
  49311. * Background material defines definition.
  49312. * @hidden Mainly internal Use
  49313. */
  49314. var BackgroundMaterialDefines = /** @class */ (function (_super) {
  49315. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterialDefines, _super);
  49316. /**
  49317. * Constructor of the defines.
  49318. */
  49319. function BackgroundMaterialDefines() {
  49320. var _this = _super.call(this) || this;
  49321. /**
  49322. * True if the diffuse texture is in use.
  49323. */
  49324. _this.DIFFUSE = false;
  49325. /**
  49326. * The direct UV channel to use.
  49327. */
  49328. _this.DIFFUSEDIRECTUV = 0;
  49329. /**
  49330. * True if the diffuse texture is in gamma space.
  49331. */
  49332. _this.GAMMADIFFUSE = false;
  49333. /**
  49334. * True if the diffuse texture has opacity in the alpha channel.
  49335. */
  49336. _this.DIFFUSEHASALPHA = false;
  49337. /**
  49338. * True if you want the material to fade to transparent at grazing angle.
  49339. */
  49340. _this.OPACITYFRESNEL = false;
  49341. /**
  49342. * True if an extra blur needs to be added in the reflection.
  49343. */
  49344. _this.REFLECTIONBLUR = false;
  49345. /**
  49346. * True if you want the material to fade to reflection at grazing angle.
  49347. */
  49348. _this.REFLECTIONFRESNEL = false;
  49349. /**
  49350. * True if you want the material to falloff as far as you move away from the scene center.
  49351. */
  49352. _this.REFLECTIONFALLOFF = false;
  49353. /**
  49354. * False if the current Webgl implementation does not support the texture lod extension.
  49355. */
  49356. _this.TEXTURELODSUPPORT = false;
  49357. /**
  49358. * True to ensure the data are premultiplied.
  49359. */
  49360. _this.PREMULTIPLYALPHA = false;
  49361. /**
  49362. * True if the texture contains cooked RGB values and not gray scaled multipliers.
  49363. */
  49364. _this.USERGBCOLOR = false;
  49365. /**
  49366. * True if highlight and shadow levels have been specified. It can help ensuring the main perceived color
  49367. * stays aligned with the desired configuration.
  49368. */
  49369. _this.USEHIGHLIGHTANDSHADOWCOLORS = false;
  49370. /**
  49371. * True to add noise in order to reduce the banding effect.
  49372. */
  49373. _this.NOISE = false;
  49374. /**
  49375. * is the reflection texture in BGR color scheme?
  49376. * Mainly used to solve a bug in ios10 video tag
  49377. */
  49378. _this.REFLECTIONBGR = false;
  49379. _this.IMAGEPROCESSING = false;
  49380. _this.VIGNETTE = false;
  49381. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  49382. _this.VIGNETTEBLENDMODEOPAQUE = false;
  49383. _this.TONEMAPPING = false;
  49384. _this.TONEMAPPING_ACES = false;
  49385. _this.CONTRAST = false;
  49386. _this.COLORCURVES = false;
  49387. _this.COLORGRADING = false;
  49388. _this.COLORGRADING3D = false;
  49389. _this.SAMPLER3DGREENDEPTH = false;
  49390. _this.SAMPLER3DBGRMAP = false;
  49391. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  49392. _this.EXPOSURE = false;
  49393. // Reflection.
  49394. _this.REFLECTION = false;
  49395. _this.REFLECTIONMAP_3D = false;
  49396. _this.REFLECTIONMAP_SPHERICAL = false;
  49397. _this.REFLECTIONMAP_PLANAR = false;
  49398. _this.REFLECTIONMAP_CUBIC = false;
  49399. _this.REFLECTIONMAP_PROJECTION = false;
  49400. _this.REFLECTIONMAP_SKYBOX = false;
  49401. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49402. _this.REFLECTIONMAP_EXPLICIT = false;
  49403. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49404. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49405. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49406. _this.INVERTCUBICMAP = false;
  49407. _this.REFLECTIONMAP_OPPOSITEZ = false;
  49408. _this.LODINREFLECTIONALPHA = false;
  49409. _this.GAMMAREFLECTION = false;
  49410. _this.RGBDREFLECTION = false;
  49411. _this.EQUIRECTANGULAR_RELFECTION_FOV = false;
  49412. // Default BJS.
  49413. _this.MAINUV1 = false;
  49414. _this.MAINUV2 = false;
  49415. _this.UV1 = false;
  49416. _this.UV2 = false;
  49417. _this.CLIPPLANE = false;
  49418. _this.CLIPPLANE2 = false;
  49419. _this.CLIPPLANE3 = false;
  49420. _this.CLIPPLANE4 = false;
  49421. _this.POINTSIZE = false;
  49422. _this.FOG = false;
  49423. _this.NORMAL = false;
  49424. _this.NUM_BONE_INFLUENCERS = 0;
  49425. _this.BonesPerMesh = 0;
  49426. _this.INSTANCES = false;
  49427. _this.SHADOWFLOAT = false;
  49428. _this.rebuild();
  49429. return _this;
  49430. }
  49431. return BackgroundMaterialDefines;
  49432. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  49433. /**
  49434. * Background material used to create an efficient environement around your scene.
  49435. */
  49436. var BackgroundMaterial = /** @class */ (function (_super) {
  49437. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BackgroundMaterial, _super);
  49438. /**
  49439. * Instantiates a Background Material in the given scene
  49440. * @param name The friendly name of the material
  49441. * @param scene The scene to add the material to
  49442. */
  49443. function BackgroundMaterial(name, scene) {
  49444. var _this = _super.call(this, name, scene) || this;
  49445. /**
  49446. * Key light Color (multiply against the environement texture)
  49447. */
  49448. _this.primaryColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49449. _this._primaryColorShadowLevel = 0;
  49450. _this._primaryColorHighlightLevel = 0;
  49451. /**
  49452. * Reflection Texture used in the material.
  49453. * Should be author in a specific way for the best result (refer to the documentation).
  49454. */
  49455. _this.reflectionTexture = null;
  49456. /**
  49457. * Reflection Texture level of blur.
  49458. *
  49459. * Can be use to reuse an existing HDR Texture and target a specific LOD to prevent authoring the
  49460. * texture twice.
  49461. */
  49462. _this.reflectionBlur = 0;
  49463. /**
  49464. * Diffuse Texture used in the material.
  49465. * Should be author in a specific way for the best result (refer to the documentation).
  49466. */
  49467. _this.diffuseTexture = null;
  49468. _this._shadowLights = null;
  49469. /**
  49470. * Specify the list of lights casting shadow on the material.
  49471. * All scene shadow lights will be included if null.
  49472. */
  49473. _this.shadowLights = null;
  49474. /**
  49475. * Helps adjusting the shadow to a softer level if required.
  49476. * 0 means black shadows and 1 means no shadows.
  49477. */
  49478. _this.shadowLevel = 0;
  49479. /**
  49480. * In case of opacity Fresnel or reflection falloff, this is use as a scene center.
  49481. * It is usually zero but might be interesting to modify according to your setup.
  49482. */
  49483. _this.sceneCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  49484. /**
  49485. * This helps specifying that the material is falling off to the sky box at grazing angle.
  49486. * This helps ensuring a nice transition when the camera goes under the ground.
  49487. */
  49488. _this.opacityFresnel = true;
  49489. /**
  49490. * This helps specifying that the material is falling off from diffuse to the reflection texture at grazing angle.
  49491. * This helps adding a mirror texture on the ground.
  49492. */
  49493. _this.reflectionFresnel = false;
  49494. /**
  49495. * This helps specifying the falloff radius off the reflection texture from the sceneCenter.
  49496. * This helps adding a nice falloff effect to the reflection if used as a mirror for instance.
  49497. */
  49498. _this.reflectionFalloffDistance = 0.0;
  49499. /**
  49500. * This specifies the weight of the reflection against the background in case of reflection Fresnel.
  49501. */
  49502. _this.reflectionAmount = 1.0;
  49503. /**
  49504. * This specifies the weight of the reflection at grazing angle.
  49505. */
  49506. _this.reflectionReflectance0 = 0.05;
  49507. /**
  49508. * This specifies the weight of the reflection at a perpendicular point of view.
  49509. */
  49510. _this.reflectionReflectance90 = 0.5;
  49511. /**
  49512. * Helps to directly use the maps channels instead of their level.
  49513. */
  49514. _this.useRGBColor = true;
  49515. /**
  49516. * This helps reducing the banding effect that could occur on the background.
  49517. */
  49518. _this.enableNoise = false;
  49519. _this._fovMultiplier = 1.0;
  49520. /**
  49521. * Enable the FOV adjustment feature controlled by fovMultiplier.
  49522. */
  49523. _this.useEquirectangularFOV = false;
  49524. _this._maxSimultaneousLights = 4;
  49525. /**
  49526. * Number of Simultaneous lights allowed on the material.
  49527. */
  49528. _this.maxSimultaneousLights = 4;
  49529. /**
  49530. * Keep track of the image processing observer to allow dispose and replace.
  49531. */
  49532. _this._imageProcessingObserver = null;
  49533. /**
  49534. * Due to a bug in iOS10, video tags (which are using the background material) are in BGR and not RGB.
  49535. * Setting this flag to true (not done automatically!) will convert it back to RGB.
  49536. */
  49537. _this.switchToBGR = false;
  49538. // Temp values kept as cache in the material.
  49539. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  49540. _this._reflectionControls = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector4"].Zero();
  49541. _this._white = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].White();
  49542. _this._primaryShadowColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49543. _this._primaryHighlightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].Black();
  49544. // Setup the default processing configuration to the scene.
  49545. _this._attachImageProcessingConfiguration(null);
  49546. _this.getRenderTargetTextures = function () {
  49547. _this._renderTargets.reset();
  49548. if (_this._diffuseTexture && _this._diffuseTexture.isRenderTarget) {
  49549. _this._renderTargets.push(_this._diffuseTexture);
  49550. }
  49551. if (_this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  49552. _this._renderTargets.push(_this._reflectionTexture);
  49553. }
  49554. return _this._renderTargets;
  49555. };
  49556. return _this;
  49557. }
  49558. Object.defineProperty(BackgroundMaterial.prototype, "_perceptualColor", {
  49559. /**
  49560. * Experimental Internal Use Only.
  49561. *
  49562. * Key light Color in "perceptual value" meaning the color you would like to see on screen.
  49563. * This acts as a helper to set the primary color to a more "human friendly" value.
  49564. * Conversion to linear space as well as exposure and tone mapping correction will be applied to keep the
  49565. * output color as close as possible from the chosen value.
  49566. * (This does not account for contrast color grading and color curves as they are considered post effect and not directly
  49567. * part of lighting setup.)
  49568. */
  49569. get: function () {
  49570. return this.__perceptualColor;
  49571. },
  49572. set: function (value) {
  49573. this.__perceptualColor = value;
  49574. this._computePrimaryColorFromPerceptualColor();
  49575. this._markAllSubMeshesAsLightsDirty();
  49576. },
  49577. enumerable: true,
  49578. configurable: true
  49579. });
  49580. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorShadowLevel", {
  49581. /**
  49582. * Defines the level of the shadows (dark area of the reflection map) in order to help scaling the colors.
  49583. * The color opposite to the primary color is used at the level chosen to define what the black area would look.
  49584. */
  49585. get: function () {
  49586. return this._primaryColorShadowLevel;
  49587. },
  49588. set: function (value) {
  49589. this._primaryColorShadowLevel = value;
  49590. this._computePrimaryColors();
  49591. this._markAllSubMeshesAsLightsDirty();
  49592. },
  49593. enumerable: true,
  49594. configurable: true
  49595. });
  49596. Object.defineProperty(BackgroundMaterial.prototype, "primaryColorHighlightLevel", {
  49597. /**
  49598. * Defines the level of the highliights (highlight area of the reflection map) in order to help scaling the colors.
  49599. * The primary color is used at the level chosen to define what the white area would look.
  49600. */
  49601. get: function () {
  49602. return this._primaryColorHighlightLevel;
  49603. },
  49604. set: function (value) {
  49605. this._primaryColorHighlightLevel = value;
  49606. this._computePrimaryColors();
  49607. this._markAllSubMeshesAsLightsDirty();
  49608. },
  49609. enumerable: true,
  49610. configurable: true
  49611. });
  49612. Object.defineProperty(BackgroundMaterial.prototype, "reflectionStandardFresnelWeight", {
  49613. /**
  49614. * Sets the reflection reflectance fresnel values according to the default standard
  49615. * empirically know to work well :-)
  49616. */
  49617. set: function (value) {
  49618. var reflectionWeight = value;
  49619. if (reflectionWeight < 0.5) {
  49620. reflectionWeight = reflectionWeight * 2.0;
  49621. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 * reflectionWeight;
  49622. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 * reflectionWeight;
  49623. }
  49624. else {
  49625. reflectionWeight = reflectionWeight * 2.0 - 1.0;
  49626. this.reflectionReflectance0 = BackgroundMaterial.StandardReflectance0 + (1.0 - BackgroundMaterial.StandardReflectance0) * reflectionWeight;
  49627. this.reflectionReflectance90 = BackgroundMaterial.StandardReflectance90 + (1.0 - BackgroundMaterial.StandardReflectance90) * reflectionWeight;
  49628. }
  49629. },
  49630. enumerable: true,
  49631. configurable: true
  49632. });
  49633. Object.defineProperty(BackgroundMaterial.prototype, "fovMultiplier", {
  49634. /**
  49635. * The current fov(field of view) multiplier, 0.0 - 2.0. Defaults to 1.0. Lower values "zoom in" and higher values "zoom out".
  49636. * Best used when trying to implement visual zoom effects like fish-eye or binoculars while not adjusting camera fov.
  49637. * Recommended to be keep at 1.0 except for special cases.
  49638. */
  49639. get: function () {
  49640. return this._fovMultiplier;
  49641. },
  49642. set: function (value) {
  49643. if (isNaN(value)) {
  49644. value = 1.0;
  49645. }
  49646. this._fovMultiplier = Math.max(0.0, Math.min(2.0, value));
  49647. },
  49648. enumerable: true,
  49649. configurable: true
  49650. });
  49651. /**
  49652. * Attaches a new image processing configuration to the PBR Material.
  49653. * @param configuration (if null the scene configuration will be use)
  49654. */
  49655. BackgroundMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  49656. var _this = this;
  49657. if (configuration === this._imageProcessingConfiguration) {
  49658. return;
  49659. }
  49660. // Detaches observer.
  49661. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  49662. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  49663. }
  49664. // Pick the scene configuration if needed.
  49665. if (!configuration) {
  49666. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  49667. }
  49668. else {
  49669. this._imageProcessingConfiguration = configuration;
  49670. }
  49671. // Attaches observer.
  49672. if (this._imageProcessingConfiguration) {
  49673. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  49674. _this._computePrimaryColorFromPerceptualColor();
  49675. _this._markAllSubMeshesAsImageProcessingDirty();
  49676. });
  49677. }
  49678. };
  49679. Object.defineProperty(BackgroundMaterial.prototype, "imageProcessingConfiguration", {
  49680. /**
  49681. * Gets the image processing configuration used either in this material.
  49682. */
  49683. get: function () {
  49684. return this._imageProcessingConfiguration;
  49685. },
  49686. /**
  49687. * Sets the Default image processing configuration used either in the this material.
  49688. *
  49689. * If sets to null, the scene one is in use.
  49690. */
  49691. set: function (value) {
  49692. this._attachImageProcessingConfiguration(value);
  49693. // Ensure the effect will be rebuilt.
  49694. this._markAllSubMeshesAsTexturesDirty();
  49695. },
  49696. enumerable: true,
  49697. configurable: true
  49698. });
  49699. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurvesEnabled", {
  49700. /**
  49701. * Gets wether the color curves effect is enabled.
  49702. */
  49703. get: function () {
  49704. return this.imageProcessingConfiguration.colorCurvesEnabled;
  49705. },
  49706. /**
  49707. * Sets wether the color curves effect is enabled.
  49708. */
  49709. set: function (value) {
  49710. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  49711. },
  49712. enumerable: true,
  49713. configurable: true
  49714. });
  49715. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingEnabled", {
  49716. /**
  49717. * Gets wether the color grading effect is enabled.
  49718. */
  49719. get: function () {
  49720. return this.imageProcessingConfiguration.colorGradingEnabled;
  49721. },
  49722. /**
  49723. * Gets wether the color grading effect is enabled.
  49724. */
  49725. set: function (value) {
  49726. this.imageProcessingConfiguration.colorGradingEnabled = value;
  49727. },
  49728. enumerable: true,
  49729. configurable: true
  49730. });
  49731. Object.defineProperty(BackgroundMaterial.prototype, "cameraToneMappingEnabled", {
  49732. /**
  49733. * Gets wether tonemapping is enabled or not.
  49734. */
  49735. get: function () {
  49736. return this._imageProcessingConfiguration.toneMappingEnabled;
  49737. },
  49738. /**
  49739. * Sets wether tonemapping is enabled or not
  49740. */
  49741. set: function (value) {
  49742. this._imageProcessingConfiguration.toneMappingEnabled = value;
  49743. },
  49744. enumerable: true,
  49745. configurable: true
  49746. });
  49747. Object.defineProperty(BackgroundMaterial.prototype, "cameraExposure", {
  49748. /**
  49749. * The camera exposure used on this material.
  49750. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49751. * This corresponds to a photographic exposure.
  49752. */
  49753. get: function () {
  49754. return this._imageProcessingConfiguration.exposure;
  49755. },
  49756. /**
  49757. * The camera exposure used on this material.
  49758. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  49759. * This corresponds to a photographic exposure.
  49760. */
  49761. set: function (value) {
  49762. this._imageProcessingConfiguration.exposure = value;
  49763. },
  49764. enumerable: true,
  49765. configurable: true
  49766. });
  49767. Object.defineProperty(BackgroundMaterial.prototype, "cameraContrast", {
  49768. /**
  49769. * Gets The camera contrast used on this material.
  49770. */
  49771. get: function () {
  49772. return this._imageProcessingConfiguration.contrast;
  49773. },
  49774. /**
  49775. * Sets The camera contrast used on this material.
  49776. */
  49777. set: function (value) {
  49778. this._imageProcessingConfiguration.contrast = value;
  49779. },
  49780. enumerable: true,
  49781. configurable: true
  49782. });
  49783. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorGradingTexture", {
  49784. /**
  49785. * Gets the Color Grading 2D Lookup Texture.
  49786. */
  49787. get: function () {
  49788. return this._imageProcessingConfiguration.colorGradingTexture;
  49789. },
  49790. /**
  49791. * Sets the Color Grading 2D Lookup Texture.
  49792. */
  49793. set: function (value) {
  49794. this.imageProcessingConfiguration.colorGradingTexture = value;
  49795. },
  49796. enumerable: true,
  49797. configurable: true
  49798. });
  49799. Object.defineProperty(BackgroundMaterial.prototype, "cameraColorCurves", {
  49800. /**
  49801. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49802. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49803. * 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;
  49804. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49805. */
  49806. get: function () {
  49807. return this.imageProcessingConfiguration.colorCurves;
  49808. },
  49809. /**
  49810. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  49811. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  49812. * 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;
  49813. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  49814. */
  49815. set: function (value) {
  49816. this.imageProcessingConfiguration.colorCurves = value;
  49817. },
  49818. enumerable: true,
  49819. configurable: true
  49820. });
  49821. Object.defineProperty(BackgroundMaterial.prototype, "hasRenderTargetTextures", {
  49822. /**
  49823. * Gets a boolean indicating that current material needs to register RTT
  49824. */
  49825. get: function () {
  49826. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  49827. return true;
  49828. }
  49829. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  49830. return true;
  49831. }
  49832. return false;
  49833. },
  49834. enumerable: true,
  49835. configurable: true
  49836. });
  49837. /**
  49838. * The entire material has been created in order to prevent overdraw.
  49839. * @returns false
  49840. */
  49841. BackgroundMaterial.prototype.needAlphaTesting = function () {
  49842. return true;
  49843. };
  49844. /**
  49845. * The entire material has been created in order to prevent overdraw.
  49846. * @returns true if blending is enable
  49847. */
  49848. BackgroundMaterial.prototype.needAlphaBlending = function () {
  49849. return ((this.alpha < 0) || (this._diffuseTexture != null && this._diffuseTexture.hasAlpha));
  49850. };
  49851. /**
  49852. * Checks wether the material is ready to be rendered for a given mesh.
  49853. * @param mesh The mesh to render
  49854. * @param subMesh The submesh to check against
  49855. * @param useInstances Specify wether or not the material is used with instances
  49856. * @returns true if all the dependencies are ready (Textures, Effects...)
  49857. */
  49858. BackgroundMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  49859. var _this = this;
  49860. if (useInstances === void 0) { useInstances = false; }
  49861. if (subMesh.effect && this.isFrozen) {
  49862. if (this._wasPreviouslyReady) {
  49863. return true;
  49864. }
  49865. }
  49866. if (!subMesh._materialDefines) {
  49867. subMesh._materialDefines = new BackgroundMaterialDefines();
  49868. }
  49869. var scene = this.getScene();
  49870. var defines = subMesh._materialDefines;
  49871. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  49872. if (defines._renderId === scene.getRenderId()) {
  49873. return true;
  49874. }
  49875. }
  49876. var engine = scene.getEngine();
  49877. // Lights
  49878. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, false, this._maxSimultaneousLights);
  49879. defines._needNormals = true;
  49880. // Textures
  49881. if (defines._areTexturesDirty) {
  49882. defines._needUVs = false;
  49883. if (scene.texturesEnabled) {
  49884. if (scene.getEngine().getCaps().textureLOD) {
  49885. defines.TEXTURELODSUPPORT = true;
  49886. }
  49887. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  49888. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  49889. return false;
  49890. }
  49891. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  49892. defines.DIFFUSEHASALPHA = this._diffuseTexture.hasAlpha;
  49893. defines.GAMMADIFFUSE = this._diffuseTexture.gammaSpace;
  49894. defines.OPACITYFRESNEL = this._opacityFresnel;
  49895. }
  49896. else {
  49897. defines.DIFFUSE = false;
  49898. defines.DIFFUSEHASALPHA = false;
  49899. defines.GAMMADIFFUSE = false;
  49900. defines.OPACITYFRESNEL = false;
  49901. }
  49902. var reflectionTexture = this._reflectionTexture;
  49903. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  49904. if (!reflectionTexture.isReadyOrNotBlocking()) {
  49905. return false;
  49906. }
  49907. defines.REFLECTION = true;
  49908. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  49909. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  49910. defines.REFLECTIONBLUR = this._reflectionBlur > 0;
  49911. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  49912. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  49913. defines.EQUIRECTANGULAR_RELFECTION_FOV = this.useEquirectangularFOV;
  49914. defines.REFLECTIONBGR = this.switchToBGR;
  49915. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE) {
  49916. defines.INVERTCUBICMAP = true;
  49917. }
  49918. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  49919. switch (reflectionTexture.coordinatesMode) {
  49920. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  49921. defines.REFLECTIONMAP_EXPLICIT = true;
  49922. break;
  49923. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  49924. defines.REFLECTIONMAP_PLANAR = true;
  49925. break;
  49926. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  49927. defines.REFLECTIONMAP_PROJECTION = true;
  49928. break;
  49929. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  49930. defines.REFLECTIONMAP_SKYBOX = true;
  49931. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  49932. break;
  49933. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  49934. defines.REFLECTIONMAP_SPHERICAL = true;
  49935. break;
  49936. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  49937. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  49938. break;
  49939. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  49940. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  49941. break;
  49942. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  49943. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  49944. break;
  49945. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  49946. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  49947. default:
  49948. defines.REFLECTIONMAP_CUBIC = true;
  49949. break;
  49950. }
  49951. if (this.reflectionFresnel) {
  49952. defines.REFLECTIONFRESNEL = true;
  49953. defines.REFLECTIONFALLOFF = this.reflectionFalloffDistance > 0;
  49954. this._reflectionControls.x = this.reflectionAmount;
  49955. this._reflectionControls.y = this.reflectionReflectance0;
  49956. this._reflectionControls.z = this.reflectionReflectance90;
  49957. this._reflectionControls.w = 1 / this.reflectionFalloffDistance;
  49958. }
  49959. else {
  49960. defines.REFLECTIONFRESNEL = false;
  49961. defines.REFLECTIONFALLOFF = false;
  49962. }
  49963. }
  49964. else {
  49965. defines.REFLECTION = false;
  49966. defines.REFLECTIONFRESNEL = false;
  49967. defines.REFLECTIONFALLOFF = false;
  49968. defines.REFLECTIONBLUR = false;
  49969. defines.REFLECTIONMAP_3D = false;
  49970. defines.REFLECTIONMAP_SPHERICAL = false;
  49971. defines.REFLECTIONMAP_PLANAR = false;
  49972. defines.REFLECTIONMAP_CUBIC = false;
  49973. defines.REFLECTIONMAP_PROJECTION = false;
  49974. defines.REFLECTIONMAP_SKYBOX = false;
  49975. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  49976. defines.REFLECTIONMAP_EXPLICIT = false;
  49977. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  49978. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  49979. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  49980. defines.INVERTCUBICMAP = false;
  49981. defines.REFLECTIONMAP_OPPOSITEZ = false;
  49982. defines.LODINREFLECTIONALPHA = false;
  49983. defines.GAMMAREFLECTION = false;
  49984. defines.RGBDREFLECTION = false;
  49985. }
  49986. }
  49987. 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);
  49988. defines.USERGBCOLOR = this._useRGBColor;
  49989. defines.NOISE = this._enableNoise;
  49990. }
  49991. if (defines._areLightsDirty) {
  49992. defines.USEHIGHLIGHTANDSHADOWCOLORS = !this._useRGBColor && (this._primaryColorShadowLevel !== 0 || this._primaryColorHighlightLevel !== 0);
  49993. }
  49994. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  49995. if (!this._imageProcessingConfiguration.isReady()) {
  49996. return false;
  49997. }
  49998. this._imageProcessingConfiguration.prepareDefines(defines);
  49999. }
  50000. // Misc.
  50001. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, false, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  50002. // Values that need to be evaluated on every frame
  50003. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  50004. // Attribs
  50005. if (_Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, false, true, false)) {
  50006. if (mesh) {
  50007. if (!scene.getEngine().getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  50008. mesh.createNormals(true);
  50009. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Warn("BackgroundMaterial: Normals have been created for the mesh: " + mesh.name);
  50010. }
  50011. }
  50012. }
  50013. // Get correct effect
  50014. if (defines.isDirty) {
  50015. defines.markAsProcessed();
  50016. scene.resetCachedMaterial();
  50017. // Fallbacks
  50018. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  50019. if (defines.FOG) {
  50020. fallbacks.addFallback(0, "FOG");
  50021. }
  50022. if (defines.POINTSIZE) {
  50023. fallbacks.addFallback(1, "POINTSIZE");
  50024. }
  50025. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  50026. if (defines.NUM_BONE_INFLUENCERS > 0) {
  50027. fallbacks.addCPUSkinningFallback(0, mesh);
  50028. }
  50029. //Attributes
  50030. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  50031. if (defines.NORMAL) {
  50032. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  50033. }
  50034. if (defines.UV1) {
  50035. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  50036. }
  50037. if (defines.UV2) {
  50038. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  50039. }
  50040. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  50041. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  50042. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType",
  50043. "vFogInfos", "vFogColor", "pointSize",
  50044. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "mBones",
  50045. "vPrimaryColor", "vPrimaryColorShadow",
  50046. "vReflectionInfos", "reflectionMatrix", "vReflectionMicrosurfaceInfos", "fFovMultiplier",
  50047. "shadowLevel", "alpha",
  50048. "vBackgroundCenter", "vReflectionControl",
  50049. "vDiffuseInfos", "diffuseMatrix",
  50050. ];
  50051. var samplers = ["diffuseSampler", "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh"];
  50052. var uniformBuffers = ["Material", "Scene"];
  50053. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  50054. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  50055. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  50056. }
  50057. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].PrepareUniformsAndSamplersList({
  50058. uniformsNames: uniforms,
  50059. uniformBuffersNames: uniformBuffers,
  50060. samplers: samplers,
  50061. defines: defines,
  50062. maxSimultaneousLights: this._maxSimultaneousLights
  50063. });
  50064. var onCompiled = function (effect) {
  50065. if (_this.onCompiled) {
  50066. _this.onCompiled(effect);
  50067. }
  50068. _this.bindSceneUniformBuffer(effect, scene.getSceneUniformBuffer());
  50069. };
  50070. var join = defines.toString();
  50071. subMesh.setEffect(scene.getEngine().createEffect("background", {
  50072. attributes: attribs,
  50073. uniformsNames: uniforms,
  50074. uniformBuffersNames: uniformBuffers,
  50075. samplers: samplers,
  50076. defines: join,
  50077. fallbacks: fallbacks,
  50078. onCompiled: onCompiled,
  50079. onError: this.onError,
  50080. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights }
  50081. }, engine), defines);
  50082. this.buildUniformLayout();
  50083. }
  50084. if (!subMesh.effect || !subMesh.effect.isReady()) {
  50085. return false;
  50086. }
  50087. defines._renderId = scene.getRenderId();
  50088. this._wasPreviouslyReady = true;
  50089. return true;
  50090. };
  50091. /**
  50092. * Compute the primary color according to the chosen perceptual color.
  50093. */
  50094. BackgroundMaterial.prototype._computePrimaryColorFromPerceptualColor = function () {
  50095. if (!this.__perceptualColor) {
  50096. return;
  50097. }
  50098. this._primaryColor.copyFrom(this.__perceptualColor);
  50099. // Revert gamma space.
  50100. this._primaryColor.toLinearSpaceToRef(this._primaryColor);
  50101. // Revert image processing configuration.
  50102. if (this._imageProcessingConfiguration) {
  50103. // Revert Exposure.
  50104. this._primaryColor.scaleToRef(1 / this._imageProcessingConfiguration.exposure, this._primaryColor);
  50105. }
  50106. this._computePrimaryColors();
  50107. };
  50108. /**
  50109. * Compute the highlights and shadow colors according to their chosen levels.
  50110. */
  50111. BackgroundMaterial.prototype._computePrimaryColors = function () {
  50112. if (this._primaryColorShadowLevel === 0 && this._primaryColorHighlightLevel === 0) {
  50113. return;
  50114. }
  50115. // Find the highlight color based on the configuration.
  50116. this._primaryColor.scaleToRef(this._primaryColorShadowLevel, this._primaryShadowColor);
  50117. this._primaryColor.subtractToRef(this._primaryShadowColor, this._primaryShadowColor);
  50118. // Find the shadow color based on the configuration.
  50119. this._white.subtractToRef(this._primaryColor, this._primaryHighlightColor);
  50120. this._primaryHighlightColor.scaleToRef(this._primaryColorHighlightLevel, this._primaryHighlightColor);
  50121. this._primaryColor.addToRef(this._primaryHighlightColor, this._primaryHighlightColor);
  50122. };
  50123. /**
  50124. * Build the uniform buffer used in the material.
  50125. */
  50126. BackgroundMaterial.prototype.buildUniformLayout = function () {
  50127. // Order is important !
  50128. this._uniformBuffer.addUniform("vPrimaryColor", 4);
  50129. this._uniformBuffer.addUniform("vPrimaryColorShadow", 4);
  50130. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  50131. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  50132. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  50133. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  50134. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  50135. this._uniformBuffer.addUniform("fFovMultiplier", 1);
  50136. this._uniformBuffer.addUniform("pointSize", 1);
  50137. this._uniformBuffer.addUniform("shadowLevel", 1);
  50138. this._uniformBuffer.addUniform("alpha", 1);
  50139. this._uniformBuffer.addUniform("vBackgroundCenter", 3);
  50140. this._uniformBuffer.addUniform("vReflectionControl", 4);
  50141. this._uniformBuffer.create();
  50142. };
  50143. /**
  50144. * Unbind the material.
  50145. */
  50146. BackgroundMaterial.prototype.unbind = function () {
  50147. if (this._diffuseTexture && this._diffuseTexture.isRenderTarget) {
  50148. this._uniformBuffer.setTexture("diffuseSampler", null);
  50149. }
  50150. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  50151. this._uniformBuffer.setTexture("reflectionSampler", null);
  50152. }
  50153. _super.prototype.unbind.call(this);
  50154. };
  50155. /**
  50156. * Bind only the world matrix to the material.
  50157. * @param world The world matrix to bind.
  50158. */
  50159. BackgroundMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  50160. this._activeEffect.setMatrix("world", world);
  50161. };
  50162. /**
  50163. * Bind the material for a dedicated submeh (every used meshes will be considered opaque).
  50164. * @param world The world matrix to bind.
  50165. * @param subMesh The submesh to bind for.
  50166. */
  50167. BackgroundMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  50168. var scene = this.getScene();
  50169. var defines = subMesh._materialDefines;
  50170. if (!defines) {
  50171. return;
  50172. }
  50173. var effect = subMesh.effect;
  50174. if (!effect) {
  50175. return;
  50176. }
  50177. this._activeEffect = effect;
  50178. // Matrices
  50179. this.bindOnlyWorldMatrix(world);
  50180. // Bones
  50181. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  50182. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  50183. if (mustRebind) {
  50184. this._uniformBuffer.bindToEffect(effect, "Material");
  50185. this.bindViewProjection(effect);
  50186. var reflectionTexture = this._reflectionTexture;
  50187. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  50188. // Texture uniforms
  50189. if (scene.texturesEnabled) {
  50190. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50191. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  50192. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  50193. }
  50194. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50195. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  50196. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, this._reflectionBlur);
  50197. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  50198. }
  50199. }
  50200. if (this.shadowLevel > 0) {
  50201. this._uniformBuffer.updateFloat("shadowLevel", this.shadowLevel);
  50202. }
  50203. this._uniformBuffer.updateFloat("alpha", this.alpha);
  50204. // Point size
  50205. if (this.pointsCloud) {
  50206. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  50207. }
  50208. if (defines.USEHIGHLIGHTANDSHADOWCOLORS) {
  50209. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryHighlightColor, 1.0);
  50210. this._uniformBuffer.updateColor4("vPrimaryColorShadow", this._primaryShadowColor, 1.0);
  50211. }
  50212. else {
  50213. this._uniformBuffer.updateColor4("vPrimaryColor", this._primaryColor, 1.0);
  50214. }
  50215. }
  50216. this._uniformBuffer.updateFloat("fFovMultiplier", this._fovMultiplier);
  50217. // Textures
  50218. if (scene.texturesEnabled) {
  50219. if (this._diffuseTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].DiffuseTextureEnabled) {
  50220. this._uniformBuffer.setTexture("diffuseSampler", this._diffuseTexture);
  50221. }
  50222. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_14__["MaterialFlags"].ReflectionTextureEnabled) {
  50223. if (defines.REFLECTIONBLUR && defines.TEXTURELODSUPPORT) {
  50224. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50225. }
  50226. else if (!defines.REFLECTIONBLUR) {
  50227. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  50228. }
  50229. else {
  50230. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  50231. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  50232. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  50233. }
  50234. if (defines.REFLECTIONFRESNEL) {
  50235. this._uniformBuffer.updateFloat3("vBackgroundCenter", this.sceneCenter.x, this.sceneCenter.y, this.sceneCenter.z);
  50236. this._uniformBuffer.updateFloat4("vReflectionControl", this._reflectionControls.x, this._reflectionControls.y, this._reflectionControls.z, this._reflectionControls.w);
  50237. }
  50238. }
  50239. }
  50240. // Clip plane
  50241. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  50242. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindEyePosition(effect, scene);
  50243. }
  50244. if (mustRebind || !this.isFrozen) {
  50245. if (scene.lightsEnabled) {
  50246. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, false);
  50247. }
  50248. // View
  50249. this.bindView(effect);
  50250. // Fog
  50251. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  50252. // image processing
  50253. if (this._imageProcessingConfiguration) {
  50254. this._imageProcessingConfiguration.bind(this._activeEffect);
  50255. }
  50256. }
  50257. this._uniformBuffer.update();
  50258. this._afterBind(mesh, this._activeEffect);
  50259. };
  50260. /**
  50261. * Dispose the material.
  50262. * @param forceDisposeEffect Force disposal of the associated effect.
  50263. * @param forceDisposeTextures Force disposal of the associated textures.
  50264. */
  50265. BackgroundMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  50266. if (forceDisposeEffect === void 0) { forceDisposeEffect = false; }
  50267. if (forceDisposeTextures === void 0) { forceDisposeTextures = false; }
  50268. if (forceDisposeTextures) {
  50269. if (this.diffuseTexture) {
  50270. this.diffuseTexture.dispose();
  50271. }
  50272. if (this.reflectionTexture) {
  50273. this.reflectionTexture.dispose();
  50274. }
  50275. }
  50276. this._renderTargets.dispose();
  50277. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  50278. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  50279. }
  50280. _super.prototype.dispose.call(this, forceDisposeEffect);
  50281. };
  50282. /**
  50283. * Clones the material.
  50284. * @param name The cloned name.
  50285. * @returns The cloned material.
  50286. */
  50287. BackgroundMaterial.prototype.clone = function (name) {
  50288. var _this = this;
  50289. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new BackgroundMaterial(name, _this.getScene()); }, this);
  50290. };
  50291. /**
  50292. * Serializes the current material to its JSON representation.
  50293. * @returns The JSON representation.
  50294. */
  50295. BackgroundMaterial.prototype.serialize = function () {
  50296. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50297. serializationObject.customType = "BABYLON.BackgroundMaterial";
  50298. return serializationObject;
  50299. };
  50300. /**
  50301. * Gets the class name of the material
  50302. * @returns "BackgroundMaterial"
  50303. */
  50304. BackgroundMaterial.prototype.getClassName = function () {
  50305. return "BackgroundMaterial";
  50306. };
  50307. /**
  50308. * Parse a JSON input to create back a background material.
  50309. * @param source The JSON data to parse
  50310. * @param scene The scene to create the parsed material in
  50311. * @param rootUrl The root url of the assets the material depends upon
  50312. * @returns the instantiated BackgroundMaterial.
  50313. */
  50314. BackgroundMaterial.Parse = function (source, scene, rootUrl) {
  50315. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new BackgroundMaterial(source.name, scene); }, source, scene, rootUrl);
  50316. };
  50317. /**
  50318. * Standard reflectance value at parallel view angle.
  50319. */
  50320. BackgroundMaterial.StandardReflectance0 = 0.05;
  50321. /**
  50322. * Standard reflectance value at grazing angle.
  50323. */
  50324. BackgroundMaterial.StandardReflectance90 = 0.5;
  50325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50327. ], BackgroundMaterial.prototype, "_primaryColor", void 0);
  50328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50330. ], BackgroundMaterial.prototype, "primaryColor", void 0);
  50331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])()
  50333. ], BackgroundMaterial.prototype, "__perceptualColor", void 0);
  50334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50336. ], BackgroundMaterial.prototype, "_primaryColorShadowLevel", void 0);
  50337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50339. ], BackgroundMaterial.prototype, "_primaryColorHighlightLevel", void 0);
  50340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  50342. ], BackgroundMaterial.prototype, "primaryColorHighlightLevel", null);
  50343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50345. ], BackgroundMaterial.prototype, "_reflectionTexture", void 0);
  50346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50348. ], BackgroundMaterial.prototype, "reflectionTexture", void 0);
  50349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50351. ], BackgroundMaterial.prototype, "_reflectionBlur", void 0);
  50352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50354. ], BackgroundMaterial.prototype, "reflectionBlur", void 0);
  50355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  50357. ], BackgroundMaterial.prototype, "_diffuseTexture", void 0);
  50358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50360. ], BackgroundMaterial.prototype, "diffuseTexture", void 0);
  50361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50363. ], BackgroundMaterial.prototype, "shadowLights", void 0);
  50364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50366. ], BackgroundMaterial.prototype, "_shadowLevel", void 0);
  50367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50369. ], BackgroundMaterial.prototype, "shadowLevel", void 0);
  50370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  50372. ], BackgroundMaterial.prototype, "_sceneCenter", void 0);
  50373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50375. ], BackgroundMaterial.prototype, "sceneCenter", void 0);
  50376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50378. ], BackgroundMaterial.prototype, "_opacityFresnel", void 0);
  50379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50381. ], BackgroundMaterial.prototype, "opacityFresnel", void 0);
  50382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50384. ], BackgroundMaterial.prototype, "_reflectionFresnel", void 0);
  50385. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50387. ], BackgroundMaterial.prototype, "reflectionFresnel", void 0);
  50388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50390. ], BackgroundMaterial.prototype, "_reflectionFalloffDistance", void 0);
  50391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50393. ], BackgroundMaterial.prototype, "reflectionFalloffDistance", void 0);
  50394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50396. ], BackgroundMaterial.prototype, "_reflectionAmount", void 0);
  50397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50399. ], BackgroundMaterial.prototype, "reflectionAmount", void 0);
  50400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50402. ], BackgroundMaterial.prototype, "_reflectionReflectance0", void 0);
  50403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50405. ], BackgroundMaterial.prototype, "reflectionReflectance0", void 0);
  50406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50408. ], BackgroundMaterial.prototype, "_reflectionReflectance90", void 0);
  50409. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50410. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50411. ], BackgroundMaterial.prototype, "reflectionReflectance90", void 0);
  50412. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50413. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50414. ], BackgroundMaterial.prototype, "_useRGBColor", void 0);
  50415. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50417. ], BackgroundMaterial.prototype, "useRGBColor", void 0);
  50418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50420. ], BackgroundMaterial.prototype, "_enableNoise", void 0);
  50421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50423. ], BackgroundMaterial.prototype, "enableNoise", void 0);
  50424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50426. ], BackgroundMaterial.prototype, "_maxSimultaneousLights", void 0);
  50427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  50429. ], BackgroundMaterial.prototype, "maxSimultaneousLights", void 0);
  50430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  50432. ], BackgroundMaterial.prototype, "_imageProcessingConfiguration", void 0);
  50433. return BackgroundMaterial;
  50434. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  50435. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_13__["_TypeStore"].RegisteredTypes["BABYLON.BackgroundMaterial"] = BackgroundMaterial;
  50436. /***/ }),
  50437. /***/ "./Materials/Background/index.ts":
  50438. /*!***************************************!*\
  50439. !*** ./Materials/Background/index.ts ***!
  50440. \***************************************/
  50441. /*! exports provided: BackgroundMaterial */
  50442. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50443. "use strict";
  50444. __webpack_require__.r(__webpack_exports__);
  50445. /* harmony import */ var _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./backgroundMaterial */ "./Materials/Background/backgroundMaterial.ts");
  50446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _backgroundMaterial__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  50447. /***/ }),
  50448. /***/ "./Materials/PBR/index.ts":
  50449. /*!********************************!*\
  50450. !*** ./Materials/PBR/index.ts ***!
  50451. \********************************/
  50452. /*! exports provided: PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial */
  50453. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50454. "use strict";
  50455. __webpack_require__.r(__webpack_exports__);
  50456. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  50457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_0__["PBRBaseMaterial"]; });
  50458. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  50459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_1__["PBRBaseSimpleMaterial"]; });
  50460. /* harmony import */ var _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrMaterial */ "./Materials/PBR/pbrMaterial.ts");
  50461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _pbrMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRMaterial"]; });
  50462. /* harmony import */ var _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrMetallicRoughnessMaterial */ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts");
  50463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _pbrMetallicRoughnessMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRMetallicRoughnessMaterial"]; });
  50464. /* harmony import */ var _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrSpecularGlossinessMaterial */ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts");
  50465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _pbrSpecularGlossinessMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRSpecularGlossinessMaterial"]; });
  50466. /***/ }),
  50467. /***/ "./Materials/PBR/pbrAnisotropicConfiguration.ts":
  50468. /*!******************************************************!*\
  50469. !*** ./Materials/PBR/pbrAnisotropicConfiguration.ts ***!
  50470. \******************************************************/
  50471. /*! exports provided: PBRAnisotropicConfiguration */
  50472. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50473. "use strict";
  50474. __webpack_require__.r(__webpack_exports__);
  50475. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRAnisotropicConfiguration", function() { return PBRAnisotropicConfiguration; });
  50476. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50477. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50478. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50479. /**
  50480. * Define the code related to the anisotropic parameters of the pbr material.
  50481. */
  50482. var PBRAnisotropicConfiguration = /** @class */ (function () {
  50483. /**
  50484. * Instantiate a new istance of clear coat configuration.
  50485. * @param markAllSubMeshesAsMiscDirty Callback to flag the material to dirty
  50486. */
  50487. function PBRAnisotropicConfiguration(markAllSubMeshesAsMiscDirty) {
  50488. this._isEnabled = false;
  50489. /**
  50490. * Defines if the anisotropy is enabled in the material.
  50491. */
  50492. this.isEnabled = false;
  50493. /**
  50494. * Defines the anisotropy strength (between 0 and 1) it defaults to 1.
  50495. */
  50496. this.intensity = 1;
  50497. /**
  50498. * Defines if the effect is along the tangents or bitangents.
  50499. * By default, the effect is "strectching" the highlights along the tangents.
  50500. */
  50501. this.followTangents = true;
  50502. this._internalMarkAllSubMeshesAsMiscDirty = markAllSubMeshesAsMiscDirty;
  50503. }
  50504. /** @hidden */
  50505. PBRAnisotropicConfiguration.prototype._markAllSubMeshesAsMiscDirty = function () {
  50506. this._internalMarkAllSubMeshesAsMiscDirty();
  50507. };
  50508. /**
  50509. * Checks to see if a texture is used in the material.
  50510. * @param defines the list of "defines" to update.
  50511. * @param mesh the mesh we are preparing the defines for.
  50512. */
  50513. PBRAnisotropicConfiguration.prototype.prepareDefines = function (defines, mesh) {
  50514. defines.ANISOTROPIC = this._isEnabled;
  50515. if (this._isEnabled && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  50516. defines._needUVs = true;
  50517. defines.MAINUV1 = true;
  50518. }
  50519. };
  50520. /**
  50521. * Binds the material data.
  50522. * @param uniformBuffer defines the Uniform buffer to fill in.
  50523. * @param isFrozen defines wether the material is frozen or not.
  50524. */
  50525. PBRAnisotropicConfiguration.prototype.bindForSubMesh = function (uniformBuffer, isFrozen) {
  50526. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  50527. // Clear Coat
  50528. uniformBuffer.updateFloat("anisotropy", this.followTangents ? this.intensity : -this.intensity);
  50529. }
  50530. };
  50531. /**
  50532. * Get the current class name of the texture useful for serialization or dynamic coding.
  50533. * @returns "PBRAnisotropicConfiguration"
  50534. */
  50535. PBRAnisotropicConfiguration.prototype.getClassName = function () {
  50536. return "PBRAnisotropicConfiguration";
  50537. };
  50538. /**
  50539. * Makes a duplicate of the current configuration into another one.
  50540. * @param anisotropicConfiguration define the config where to copy the info
  50541. */
  50542. PBRAnisotropicConfiguration.prototype.copyTo = function (anisotropicConfiguration) {
  50543. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return anisotropicConfiguration; }, this);
  50544. };
  50545. /**
  50546. * Serializes this clear coat configuration.
  50547. * @returns - An object with the serialized config.
  50548. */
  50549. PBRAnisotropicConfiguration.prototype.serialize = function () {
  50550. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  50551. };
  50552. /**
  50553. * Parses a Clear Coat Configuration from a serialized object.
  50554. * @param source - Serialized object.
  50555. */
  50556. PBRAnisotropicConfiguration.prototype.parse = function (source) {
  50557. var _this = this;
  50558. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  50559. };
  50560. /**
  50561. * Add fallbacks to the effect fallbacks list.
  50562. * @param defines defines the Base texture to use.
  50563. * @param fallbacks defines the current fallback list.
  50564. * @param currentRank defines the current fallback rank.
  50565. * @returns the new fallback rank.
  50566. */
  50567. PBRAnisotropicConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  50568. if (defines.ANISOTROPIC) {
  50569. fallbacks.addFallback(currentRank++, "ANISOTROPIC");
  50570. }
  50571. return currentRank;
  50572. };
  50573. /**
  50574. * Add the required uniforms to the current list.
  50575. * @param uniforms defines the current uniform list.
  50576. */
  50577. PBRAnisotropicConfiguration.AddUniforms = function (uniforms) {
  50578. uniforms.push("anisotropy");
  50579. };
  50580. /**
  50581. * Add the required uniforms to the current buffer.
  50582. * @param uniformBuffer defines the current uniform buffer.
  50583. */
  50584. PBRAnisotropicConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  50585. uniformBuffer.addUniform("anisotropy", 1);
  50586. };
  50587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50589. ], PBRAnisotropicConfiguration.prototype, "_isEnabled", void 0);
  50590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  50592. ], PBRAnisotropicConfiguration.prototype, "isEnabled", void 0);
  50593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50595. ], PBRAnisotropicConfiguration.prototype, "intensity", void 0);
  50596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  50597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  50598. ], PBRAnisotropicConfiguration.prototype, "followTangents", void 0);
  50599. return PBRAnisotropicConfiguration;
  50600. }());
  50601. /***/ }),
  50602. /***/ "./Materials/PBR/pbrBaseMaterial.ts":
  50603. /*!******************************************!*\
  50604. !*** ./Materials/PBR/pbrBaseMaterial.ts ***!
  50605. \******************************************/
  50606. /*! exports provided: PBRBaseMaterial */
  50607. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  50608. "use strict";
  50609. __webpack_require__.r(__webpack_exports__);
  50610. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return PBRBaseMaterial; });
  50611. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  50612. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  50613. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  50614. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/smartArray */ "./Misc/smartArray.ts");
  50615. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  50616. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  50617. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  50618. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  50619. /* harmony import */ var _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./pbrClearCoatConfiguration */ "./Materials/PBR/pbrClearCoatConfiguration.ts");
  50620. /* harmony import */ var _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pbrAnisotropicConfiguration */ "./Materials/PBR/pbrAnisotropicConfiguration.ts");
  50621. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  50622. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  50623. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../Materials/materialDefines */ "./Materials/materialDefines.ts");
  50624. /* harmony import */ var _Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../Materials/pushMaterial */ "./Materials/pushMaterial.ts");
  50625. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  50626. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  50627. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  50628. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  50629. /* harmony import */ var _Shaders_pbr_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../Shaders/pbr.fragment */ "./Shaders/pbr.fragment.ts");
  50630. /* harmony import */ var _Shaders_pbr_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../Shaders/pbr.vertex */ "./Shaders/pbr.vertex.ts");
  50631. /**
  50632. * Manages the defines for the PBR Material.
  50633. * @hiddenChildren
  50634. */
  50635. var PBRMaterialDefines = /** @class */ (function (_super) {
  50636. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterialDefines, _super);
  50637. /**
  50638. * Initializes the PBR Material defines.
  50639. */
  50640. function PBRMaterialDefines() {
  50641. var _this = _super.call(this) || this;
  50642. _this.PBR = true;
  50643. _this.MAINUV1 = false;
  50644. _this.MAINUV2 = false;
  50645. _this.UV1 = false;
  50646. _this.UV2 = false;
  50647. _this.ALBEDO = false;
  50648. _this.ALBEDODIRECTUV = 0;
  50649. _this.VERTEXCOLOR = false;
  50650. _this.AMBIENT = false;
  50651. _this.AMBIENTDIRECTUV = 0;
  50652. _this.AMBIENTINGRAYSCALE = false;
  50653. _this.OPACITY = false;
  50654. _this.VERTEXALPHA = false;
  50655. _this.OPACITYDIRECTUV = 0;
  50656. _this.OPACITYRGB = false;
  50657. _this.ALPHATEST = false;
  50658. _this.DEPTHPREPASS = false;
  50659. _this.ALPHABLEND = false;
  50660. _this.ALPHAFROMALBEDO = false;
  50661. _this.ALPHATESTVALUE = "0.5";
  50662. _this.SPECULAROVERALPHA = false;
  50663. _this.RADIANCEOVERALPHA = false;
  50664. _this.ALPHAFRESNEL = false;
  50665. _this.LINEARALPHAFRESNEL = false;
  50666. _this.PREMULTIPLYALPHA = false;
  50667. _this.EMISSIVE = false;
  50668. _this.EMISSIVEDIRECTUV = 0;
  50669. _this.REFLECTIVITY = false;
  50670. _this.REFLECTIVITYDIRECTUV = 0;
  50671. _this.SPECULARTERM = false;
  50672. _this.MICROSURFACEFROMREFLECTIVITYMAP = false;
  50673. _this.MICROSURFACEAUTOMATIC = false;
  50674. _this.LODBASEDMICROSFURACE = false;
  50675. _this.MICROSURFACEMAP = false;
  50676. _this.MICROSURFACEMAPDIRECTUV = 0;
  50677. _this.METALLICWORKFLOW = false;
  50678. _this.ROUGHNESSSTOREINMETALMAPALPHA = false;
  50679. _this.ROUGHNESSSTOREINMETALMAPGREEN = false;
  50680. _this.METALLNESSSTOREINMETALMAPBLUE = false;
  50681. _this.AOSTOREINMETALMAPRED = false;
  50682. _this.ENVIRONMENTBRDF = false;
  50683. _this.NORMAL = false;
  50684. _this.TANGENT = false;
  50685. _this.BUMP = false;
  50686. _this.BUMPDIRECTUV = 0;
  50687. _this.OBJECTSPACE_NORMALMAP = false;
  50688. _this.PARALLAX = false;
  50689. _this.PARALLAXOCCLUSION = false;
  50690. _this.NORMALXYSCALE = true;
  50691. _this.LIGHTMAP = false;
  50692. _this.LIGHTMAPDIRECTUV = 0;
  50693. _this.USELIGHTMAPASSHADOWMAP = false;
  50694. _this.GAMMALIGHTMAP = false;
  50695. _this.REFLECTION = false;
  50696. _this.REFLECTIONMAP_3D = false;
  50697. _this.REFLECTIONMAP_SPHERICAL = false;
  50698. _this.REFLECTIONMAP_PLANAR = false;
  50699. _this.REFLECTIONMAP_CUBIC = false;
  50700. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  50701. _this.REFLECTIONMAP_PROJECTION = false;
  50702. _this.REFLECTIONMAP_SKYBOX = false;
  50703. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  50704. _this.REFLECTIONMAP_EXPLICIT = false;
  50705. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  50706. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  50707. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  50708. _this.INVERTCUBICMAP = false;
  50709. _this.USESPHERICALFROMREFLECTIONMAP = false;
  50710. _this.USESPHERICALINVERTEX = false;
  50711. _this.REFLECTIONMAP_OPPOSITEZ = false;
  50712. _this.LODINREFLECTIONALPHA = false;
  50713. _this.GAMMAREFLECTION = false;
  50714. _this.RGBDREFLECTION = false;
  50715. _this.RADIANCEOCCLUSION = false;
  50716. _this.HORIZONOCCLUSION = false;
  50717. _this.REFRACTION = false;
  50718. _this.REFRACTIONMAP_3D = false;
  50719. _this.REFRACTIONMAP_OPPOSITEZ = false;
  50720. _this.LODINREFRACTIONALPHA = false;
  50721. _this.GAMMAREFRACTION = false;
  50722. _this.RGBDREFRACTION = false;
  50723. _this.LINKREFRACTIONTOTRANSPARENCY = false;
  50724. _this.INSTANCES = false;
  50725. _this.NUM_BONE_INFLUENCERS = 0;
  50726. _this.BonesPerMesh = 0;
  50727. _this.BONETEXTURE = false;
  50728. _this.NONUNIFORMSCALING = false;
  50729. _this.MORPHTARGETS = false;
  50730. _this.MORPHTARGETS_NORMAL = false;
  50731. _this.MORPHTARGETS_TANGENT = false;
  50732. _this.NUM_MORPH_INFLUENCERS = 0;
  50733. _this.IMAGEPROCESSING = false;
  50734. _this.VIGNETTE = false;
  50735. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  50736. _this.VIGNETTEBLENDMODEOPAQUE = false;
  50737. _this.TONEMAPPING = false;
  50738. _this.TONEMAPPING_ACES = false;
  50739. _this.CONTRAST = false;
  50740. _this.COLORCURVES = false;
  50741. _this.COLORGRADING = false;
  50742. _this.COLORGRADING3D = false;
  50743. _this.SAMPLER3DGREENDEPTH = false;
  50744. _this.SAMPLER3DBGRMAP = false;
  50745. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  50746. _this.EXPOSURE = false;
  50747. _this.USEPHYSICALLIGHTFALLOFF = false;
  50748. _this.USEGLTFLIGHTFALLOFF = false;
  50749. _this.TWOSIDEDLIGHTING = false;
  50750. _this.SHADOWFLOAT = false;
  50751. _this.CLIPPLANE = false;
  50752. _this.CLIPPLANE2 = false;
  50753. _this.CLIPPLANE3 = false;
  50754. _this.CLIPPLANE4 = false;
  50755. _this.POINTSIZE = false;
  50756. _this.FOG = false;
  50757. _this.LOGARITHMICDEPTH = false;
  50758. _this.FORCENORMALFORWARD = false;
  50759. _this.SPECULARAA = false;
  50760. _this.CLEARCOAT = false;
  50761. _this.CLEARCOAT_TEXTURE = false;
  50762. _this.CLEARCOAT_TEXTUREDIRECTUV = 0;
  50763. _this.CLEARCOAT_BUMP = false;
  50764. _this.CLEARCOAT_BUMPDIRECTUV = 0;
  50765. _this.ANISOTROPIC = false;
  50766. _this.UNLIT = false;
  50767. _this.rebuild();
  50768. return _this;
  50769. }
  50770. /**
  50771. * Resets the PBR Material defines.
  50772. */
  50773. PBRMaterialDefines.prototype.reset = function () {
  50774. _super.prototype.reset.call(this);
  50775. this.ALPHATESTVALUE = "0.5";
  50776. this.PBR = true;
  50777. };
  50778. return PBRMaterialDefines;
  50779. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_12__["MaterialDefines"]));
  50780. /**
  50781. * The Physically based material base class of BJS.
  50782. *
  50783. * This offers the main features of a standard PBR material.
  50784. * For more information, please refer to the documentation :
  50785. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  50786. */
  50787. var PBRBaseMaterial = /** @class */ (function (_super) {
  50788. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseMaterial, _super);
  50789. /**
  50790. * Instantiates a new PBRMaterial instance.
  50791. *
  50792. * @param name The material name
  50793. * @param scene The scene the material will be use in.
  50794. */
  50795. function PBRBaseMaterial(name, scene) {
  50796. var _this = _super.call(this, name, scene) || this;
  50797. /**
  50798. * Intensity of the direct lights e.g. the four lights available in your scene.
  50799. * This impacts both the direct diffuse and specular highlights.
  50800. */
  50801. _this._directIntensity = 1.0;
  50802. /**
  50803. * Intensity of the emissive part of the material.
  50804. * This helps controlling the emissive effect without modifying the emissive color.
  50805. */
  50806. _this._emissiveIntensity = 1.0;
  50807. /**
  50808. * Intensity of the environment e.g. how much the environment will light the object
  50809. * either through harmonics for rough material or through the refelction for shiny ones.
  50810. */
  50811. _this._environmentIntensity = 1.0;
  50812. /**
  50813. * This is a special control allowing the reduction of the specular highlights coming from the
  50814. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  50815. */
  50816. _this._specularIntensity = 1.0;
  50817. /**
  50818. * This stores the direct, emissive, environment, and specular light intensities into a Vector4.
  50819. */
  50820. _this._lightingInfos = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Vector4"](_this._directIntensity, _this._emissiveIntensity, _this._environmentIntensity, _this._specularIntensity);
  50821. /**
  50822. * Debug Control allowing disabling the bump map on this material.
  50823. */
  50824. _this._disableBumpMap = false;
  50825. /**
  50826. * AKA Occlusion Texture Intensity in other nomenclature.
  50827. */
  50828. _this._ambientTextureStrength = 1.0;
  50829. /**
  50830. * Defines how much the AO map is occluding the analytical lights (point spot...).
  50831. * 1 means it completely occludes it
  50832. * 0 mean it has no impact
  50833. */
  50834. _this._ambientTextureImpactOnAnalyticalLights = PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  50835. /**
  50836. * The color of a material in ambient lighting.
  50837. */
  50838. _this._ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50839. /**
  50840. * AKA Diffuse Color in other nomenclature.
  50841. */
  50842. _this._albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50843. /**
  50844. * AKA Specular Color in other nomenclature.
  50845. */
  50846. _this._reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50847. /**
  50848. * The color applied when light is reflected from a material.
  50849. */
  50850. _this._reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](1, 1, 1);
  50851. /**
  50852. * The color applied when light is emitted from a material.
  50853. */
  50854. _this._emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  50855. /**
  50856. * AKA Glossiness in other nomenclature.
  50857. */
  50858. _this._microSurface = 0.9;
  50859. /**
  50860. * source material index of refraction (IOR)' / 'destination material IOR.
  50861. */
  50862. _this._indexOfRefraction = 0.66;
  50863. /**
  50864. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  50865. */
  50866. _this._invertRefractionY = false;
  50867. /**
  50868. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  50869. * Materials half opaque for instance using refraction could benefit from this control.
  50870. */
  50871. _this._linkRefractionWithTransparency = false;
  50872. /**
  50873. * Specifies that the material will use the light map as a show map.
  50874. */
  50875. _this._useLightmapAsShadowmap = false;
  50876. /**
  50877. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  50878. * makes the reflect vector face the model (under horizon).
  50879. */
  50880. _this._useHorizonOcclusion = true;
  50881. /**
  50882. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  50883. * too much the area relying on ambient texture to define their ambient occlusion.
  50884. */
  50885. _this._useRadianceOcclusion = true;
  50886. /**
  50887. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  50888. */
  50889. _this._useAlphaFromAlbedoTexture = false;
  50890. /**
  50891. * Specifies that the material will keeps the specular highlights over a transparent surface (only the most limunous ones).
  50892. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  50893. */
  50894. _this._useSpecularOverAlpha = true;
  50895. /**
  50896. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  50897. */
  50898. _this._useMicroSurfaceFromReflectivityMapAlpha = false;
  50899. /**
  50900. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  50901. */
  50902. _this._useRoughnessFromMetallicTextureAlpha = true;
  50903. /**
  50904. * Specifies if the metallic texture contains the roughness information in its green channel.
  50905. */
  50906. _this._useRoughnessFromMetallicTextureGreen = false;
  50907. /**
  50908. * Specifies if the metallic texture contains the metallness information in its blue channel.
  50909. */
  50910. _this._useMetallnessFromMetallicTextureBlue = false;
  50911. /**
  50912. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  50913. */
  50914. _this._useAmbientOcclusionFromMetallicTextureRed = false;
  50915. /**
  50916. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  50917. */
  50918. _this._useAmbientInGrayScale = false;
  50919. /**
  50920. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  50921. * The material will try to infer what glossiness each pixel should be.
  50922. */
  50923. _this._useAutoMicroSurfaceFromReflectivityMap = false;
  50924. /**
  50925. * Defines the falloff type used in this material.
  50926. * It by default is Physical.
  50927. */
  50928. _this._lightFalloff = PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL;
  50929. /**
  50930. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  50931. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  50932. */
  50933. _this._useRadianceOverAlpha = true;
  50934. /**
  50935. * Allows using an object space normal map (instead of tangent space).
  50936. */
  50937. _this._useObjectSpaceNormalMap = false;
  50938. /**
  50939. * Allows using the bump map in parallax mode.
  50940. */
  50941. _this._useParallax = false;
  50942. /**
  50943. * Allows using the bump map in parallax occlusion mode.
  50944. */
  50945. _this._useParallaxOcclusion = false;
  50946. /**
  50947. * Controls the scale bias of the parallax mode.
  50948. */
  50949. _this._parallaxScaleBias = 0.05;
  50950. /**
  50951. * If sets to true, disables all the lights affecting the material.
  50952. */
  50953. _this._disableLighting = false;
  50954. /**
  50955. * Number of Simultaneous lights allowed on the material.
  50956. */
  50957. _this._maxSimultaneousLights = 4;
  50958. /**
  50959. * If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  50960. */
  50961. _this._invertNormalMapX = false;
  50962. /**
  50963. * If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  50964. */
  50965. _this._invertNormalMapY = false;
  50966. /**
  50967. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  50968. */
  50969. _this._twoSidedLighting = false;
  50970. /**
  50971. * Defines the alpha limits in alpha test mode.
  50972. */
  50973. _this._alphaCutOff = 0.4;
  50974. /**
  50975. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  50976. */
  50977. _this._forceAlphaTest = false;
  50978. /**
  50979. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50980. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  50981. */
  50982. _this._useAlphaFresnel = false;
  50983. /**
  50984. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  50985. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  50986. */
  50987. _this._useLinearAlphaFresnel = false;
  50988. /**
  50989. * The transparency mode of the material.
  50990. */
  50991. _this._transparencyMode = null;
  50992. /**
  50993. * Specifies the environment BRDF texture used to comput the scale and offset roughness values
  50994. * from cos thetav and roughness:
  50995. * http://blog.selfshadow.com/publications/s2013-shading-course/karis/s2013_pbs_epic_notes_v2.pdf
  50996. */
  50997. _this._environmentBRDFTexture = null;
  50998. /**
  50999. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  51000. */
  51001. _this._forceIrradianceInFragment = false;
  51002. /**
  51003. * Force normal to face away from face.
  51004. */
  51005. _this._forceNormalForward = false;
  51006. /**
  51007. * Enables specular anti aliasing in the PBR shader.
  51008. * It will both interacts on the Geometry for analytical and IBL lighting.
  51009. * It also prefilter the roughness map based on the bump values.
  51010. */
  51011. _this._enableSpecularAntiAliasing = false;
  51012. /**
  51013. * Stores the available render targets.
  51014. */
  51015. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_3__["SmartArray"](16);
  51016. /**
  51017. * Sets the global ambient color for the material used in lighting calculations.
  51018. */
  51019. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"](0, 0, 0);
  51020. /**
  51021. * If set to true, no lighting calculations will be applied.
  51022. */
  51023. _this._unlit = false;
  51024. /**
  51025. * Defines the clear coat layer parameters for the material.
  51026. */
  51027. _this.clearCoat = new _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"](_this._markAllSubMeshesAsTexturesDirty.bind(_this));
  51028. /**
  51029. * Defines the anisotropic parameters for the material.
  51030. */
  51031. _this.anisotropy = new _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"](_this._markAllSubMeshesAsMiscDirty.bind(_this));
  51032. // Setup the default processing configuration to the scene.
  51033. _this._attachImageProcessingConfiguration(null);
  51034. _this.getRenderTargetTextures = function () {
  51035. _this._renderTargets.reset();
  51036. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  51037. _this._renderTargets.push(_this._reflectionTexture);
  51038. }
  51039. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  51040. _this._renderTargets.push(_this._refractionTexture);
  51041. }
  51042. return _this._renderTargets;
  51043. };
  51044. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_4__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  51045. return _this;
  51046. }
  51047. /**
  51048. * Attaches a new image processing configuration to the PBR Material.
  51049. * @param configuration
  51050. */
  51051. PBRBaseMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  51052. var _this = this;
  51053. if (configuration === this._imageProcessingConfiguration) {
  51054. return;
  51055. }
  51056. // Detaches observer.
  51057. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  51058. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  51059. }
  51060. // Pick the scene configuration if needed.
  51061. if (!configuration) {
  51062. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  51063. }
  51064. else {
  51065. this._imageProcessingConfiguration = configuration;
  51066. }
  51067. // Attaches observer.
  51068. if (this._imageProcessingConfiguration) {
  51069. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  51070. _this._markAllSubMeshesAsImageProcessingDirty();
  51071. });
  51072. }
  51073. };
  51074. Object.defineProperty(PBRBaseMaterial.prototype, "hasRenderTargetTextures", {
  51075. /**
  51076. * Gets a boolean indicating that current material needs to register RTT
  51077. */
  51078. get: function () {
  51079. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51080. return true;
  51081. }
  51082. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51083. return true;
  51084. }
  51085. return false;
  51086. },
  51087. enumerable: true,
  51088. configurable: true
  51089. });
  51090. /**
  51091. * Gets the name of the material class.
  51092. */
  51093. PBRBaseMaterial.prototype.getClassName = function () {
  51094. return "PBRBaseMaterial";
  51095. };
  51096. Object.defineProperty(PBRBaseMaterial.prototype, "useLogarithmicDepth", {
  51097. /**
  51098. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51099. */
  51100. get: function () {
  51101. return this._useLogarithmicDepth;
  51102. },
  51103. /**
  51104. * Enabled the use of logarithmic depth buffers, which is good for wide depth buffers.
  51105. */
  51106. set: function (value) {
  51107. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  51108. },
  51109. enumerable: true,
  51110. configurable: true
  51111. });
  51112. Object.defineProperty(PBRBaseMaterial.prototype, "transparencyMode", {
  51113. /**
  51114. * Gets the current transparency mode.
  51115. */
  51116. get: function () {
  51117. return this._transparencyMode;
  51118. },
  51119. /**
  51120. * Sets the transparency mode of the material.
  51121. *
  51122. * | Value | Type | Description |
  51123. * | ----- | ----------------------------------- | ----------- |
  51124. * | 0 | OPAQUE | |
  51125. * | 1 | ALPHATEST | |
  51126. * | 2 | ALPHABLEND | |
  51127. * | 3 | ALPHATESTANDBLEND | |
  51128. *
  51129. */
  51130. set: function (value) {
  51131. if (this._transparencyMode === value) {
  51132. return;
  51133. }
  51134. this._transparencyMode = value;
  51135. this._forceAlphaTest = (value === PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND);
  51136. this._markAllSubMeshesAsTexturesAndMiscDirty();
  51137. },
  51138. enumerable: true,
  51139. configurable: true
  51140. });
  51141. Object.defineProperty(PBRBaseMaterial.prototype, "_disableAlphaBlending", {
  51142. /**
  51143. * Returns true if alpha blending should be disabled.
  51144. */
  51145. get: function () {
  51146. return (this._linkRefractionWithTransparency ||
  51147. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_OPAQUE ||
  51148. this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51149. },
  51150. enumerable: true,
  51151. configurable: true
  51152. });
  51153. /**
  51154. * Specifies whether or not this material should be rendered in alpha blend mode.
  51155. */
  51156. PBRBaseMaterial.prototype.needAlphaBlending = function () {
  51157. if (this._disableAlphaBlending) {
  51158. return false;
  51159. }
  51160. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromAlbedoTexture();
  51161. };
  51162. /**
  51163. * Specifies if the mesh will require alpha blending.
  51164. * @param mesh - BJS mesh.
  51165. */
  51166. PBRBaseMaterial.prototype.needAlphaBlendingForMesh = function (mesh) {
  51167. if (this._disableAlphaBlending) {
  51168. return false;
  51169. }
  51170. return _super.prototype.needAlphaBlendingForMesh.call(this, mesh);
  51171. };
  51172. /**
  51173. * Specifies whether or not this material should be rendered in alpha test mode.
  51174. */
  51175. PBRBaseMaterial.prototype.needAlphaTesting = function () {
  51176. if (this._forceAlphaTest) {
  51177. return true;
  51178. }
  51179. if (this._linkRefractionWithTransparency) {
  51180. return false;
  51181. }
  51182. return this._albedoTexture != null && this._albedoTexture.hasAlpha && (this._transparencyMode == null || this._transparencyMode === PBRBaseMaterial.PBRMATERIAL_ALPHATEST);
  51183. };
  51184. /**
  51185. * Specifies whether or not the alpha value of the albedo texture should be used for alpha blending.
  51186. */
  51187. PBRBaseMaterial.prototype._shouldUseAlphaFromAlbedoTexture = function () {
  51188. return this._albedoTexture != null && this._albedoTexture.hasAlpha && this._useAlphaFromAlbedoTexture && this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE;
  51189. };
  51190. /**
  51191. * Gets the texture used for the alpha test.
  51192. */
  51193. PBRBaseMaterial.prototype.getAlphaTestTexture = function () {
  51194. return this._albedoTexture;
  51195. };
  51196. /**
  51197. * Specifies that the submesh is ready to be used.
  51198. * @param mesh - BJS mesh.
  51199. * @param subMesh - A submesh of the BJS mesh. Used to check if it is ready.
  51200. * @param useInstances - Specifies that instances should be used.
  51201. * @returns - boolean indicating that the submesh is ready or not.
  51202. */
  51203. PBRBaseMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  51204. if (subMesh.effect && this.isFrozen) {
  51205. if (this._wasPreviouslyReady) {
  51206. return true;
  51207. }
  51208. }
  51209. if (!subMesh._materialDefines) {
  51210. subMesh._materialDefines = new PBRMaterialDefines();
  51211. }
  51212. var defines = subMesh._materialDefines;
  51213. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  51214. if (defines._renderId === this.getScene().getRenderId()) {
  51215. return true;
  51216. }
  51217. }
  51218. var scene = this.getScene();
  51219. var engine = scene.getEngine();
  51220. if (defines._areTexturesDirty) {
  51221. if (scene.texturesEnabled) {
  51222. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].DiffuseTextureEnabled) {
  51223. if (!this._albedoTexture.isReadyOrNotBlocking()) {
  51224. return false;
  51225. }
  51226. }
  51227. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].AmbientTextureEnabled) {
  51228. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  51229. return false;
  51230. }
  51231. }
  51232. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].OpacityTextureEnabled) {
  51233. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  51234. return false;
  51235. }
  51236. }
  51237. var reflectionTexture = this._getReflectionTexture();
  51238. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51239. if (!reflectionTexture.isReadyOrNotBlocking()) {
  51240. return false;
  51241. }
  51242. }
  51243. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].LightmapTextureEnabled) {
  51244. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  51245. return false;
  51246. }
  51247. }
  51248. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].EmissiveTextureEnabled) {
  51249. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  51250. return false;
  51251. }
  51252. }
  51253. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].SpecularTextureEnabled) {
  51254. if (this._metallicTexture) {
  51255. if (!this._metallicTexture.isReadyOrNotBlocking()) {
  51256. return false;
  51257. }
  51258. }
  51259. else if (this._reflectivityTexture) {
  51260. if (!this._reflectivityTexture.isReadyOrNotBlocking()) {
  51261. return false;
  51262. }
  51263. }
  51264. if (this._microSurfaceTexture) {
  51265. if (!this._microSurfaceTexture.isReadyOrNotBlocking()) {
  51266. return false;
  51267. }
  51268. }
  51269. }
  51270. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51271. // Bump texture cannot be not blocking.
  51272. if (!this._bumpTexture.isReady()) {
  51273. return false;
  51274. }
  51275. }
  51276. var refractionTexture = this._getRefractionTexture();
  51277. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled) {
  51278. if (!refractionTexture.isReadyOrNotBlocking()) {
  51279. return false;
  51280. }
  51281. }
  51282. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51283. // This is blocking.
  51284. if (!this._environmentBRDFTexture.isReady()) {
  51285. return false;
  51286. }
  51287. }
  51288. }
  51289. }
  51290. if (!this.clearCoat.isReadyForSubMesh(defines, scene, engine, this._disableBumpMap)) {
  51291. return false;
  51292. }
  51293. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51294. if (!this._imageProcessingConfiguration.isReady()) {
  51295. return false;
  51296. }
  51297. }
  51298. if (!engine.getCaps().standardDerivatives && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  51299. mesh.createNormals(true);
  51300. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("PBRMaterial: Normals have been created for the mesh: " + mesh.name);
  51301. }
  51302. var previousEffect = subMesh.effect;
  51303. var effect = this._prepareEffect(mesh, defines, this.onCompiled, this.onError, useInstances);
  51304. if (effect) {
  51305. // Use previous effect while new one is compiling
  51306. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  51307. effect = previousEffect;
  51308. defines.markAsUnprocessed();
  51309. }
  51310. else {
  51311. scene.resetCachedMaterial();
  51312. subMesh.setEffect(effect, defines);
  51313. this.buildUniformLayout();
  51314. }
  51315. }
  51316. if (!subMesh.effect || !subMesh.effect.isReady()) {
  51317. return false;
  51318. }
  51319. defines._renderId = scene.getRenderId();
  51320. this._wasPreviouslyReady = true;
  51321. return true;
  51322. };
  51323. /**
  51324. * Specifies if the material uses metallic roughness workflow.
  51325. * @returns boolean specifiying if the material uses metallic roughness workflow.
  51326. */
  51327. PBRBaseMaterial.prototype.isMetallicWorkflow = function () {
  51328. if (this._metallic != null || this._roughness != null || this._metallicTexture) {
  51329. return true;
  51330. }
  51331. return false;
  51332. };
  51333. PBRBaseMaterial.prototype._prepareEffect = function (mesh, defines, onCompiled, onError, useInstances, useClipPlane) {
  51334. if (onCompiled === void 0) { onCompiled = null; }
  51335. if (onError === void 0) { onError = null; }
  51336. if (useInstances === void 0) { useInstances = null; }
  51337. if (useClipPlane === void 0) { useClipPlane = null; }
  51338. this._prepareDefines(mesh, defines, useInstances, useClipPlane);
  51339. if (!defines.isDirty) {
  51340. return null;
  51341. }
  51342. defines.markAsProcessed();
  51343. var scene = this.getScene();
  51344. var engine = scene.getEngine();
  51345. // Fallbacks
  51346. var fallbacks = new _Materials_effect__WEBPACK_IMPORTED_MODULE_11__["EffectFallbacks"]();
  51347. var fallbackRank = 0;
  51348. if (defines.USESPHERICALINVERTEX) {
  51349. fallbacks.addFallback(fallbackRank++, "USESPHERICALINVERTEX");
  51350. }
  51351. if (defines.FOG) {
  51352. fallbacks.addFallback(fallbackRank, "FOG");
  51353. }
  51354. if (defines.SPECULARAA) {
  51355. fallbacks.addFallback(fallbackRank, "SPECULARAA");
  51356. }
  51357. if (defines.POINTSIZE) {
  51358. fallbacks.addFallback(fallbackRank, "POINTSIZE");
  51359. }
  51360. if (defines.LOGARITHMICDEPTH) {
  51361. fallbacks.addFallback(fallbackRank, "LOGARITHMICDEPTH");
  51362. }
  51363. if (defines.PARALLAX) {
  51364. fallbacks.addFallback(fallbackRank, "PARALLAX");
  51365. }
  51366. if (defines.PARALLAXOCCLUSION) {
  51367. fallbacks.addFallback(fallbackRank++, "PARALLAXOCCLUSION");
  51368. }
  51369. fallbackRank = _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  51370. fallbackRank = _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddFallbacks(defines, fallbacks, fallbackRank);
  51371. if (defines.ENVIRONMENTBRDF) {
  51372. fallbacks.addFallback(fallbackRank++, "ENVIRONMENTBRDF");
  51373. }
  51374. if (defines.TANGENT) {
  51375. fallbacks.addFallback(fallbackRank++, "TANGENT");
  51376. }
  51377. if (defines.BUMP) {
  51378. fallbacks.addFallback(fallbackRank++, "BUMP");
  51379. }
  51380. fallbackRank = _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights, fallbackRank++);
  51381. if (defines.SPECULARTERM) {
  51382. fallbacks.addFallback(fallbackRank++, "SPECULARTERM");
  51383. }
  51384. if (defines.USESPHERICALFROMREFLECTIONMAP) {
  51385. fallbacks.addFallback(fallbackRank++, "USESPHERICALFROMREFLECTIONMAP");
  51386. }
  51387. if (defines.LIGHTMAP) {
  51388. fallbacks.addFallback(fallbackRank++, "LIGHTMAP");
  51389. }
  51390. if (defines.NORMAL) {
  51391. fallbacks.addFallback(fallbackRank++, "NORMAL");
  51392. }
  51393. if (defines.AMBIENT) {
  51394. fallbacks.addFallback(fallbackRank++, "AMBIENT");
  51395. }
  51396. if (defines.EMISSIVE) {
  51397. fallbacks.addFallback(fallbackRank++, "EMISSIVE");
  51398. }
  51399. if (defines.VERTEXCOLOR) {
  51400. fallbacks.addFallback(fallbackRank++, "VERTEXCOLOR");
  51401. }
  51402. if (defines.NUM_BONE_INFLUENCERS > 0) {
  51403. fallbacks.addCPUSkinningFallback(fallbackRank++, mesh);
  51404. }
  51405. if (defines.MORPHTARGETS) {
  51406. fallbacks.addFallback(fallbackRank++, "MORPHTARGETS");
  51407. }
  51408. //Attributes
  51409. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  51410. if (defines.NORMAL) {
  51411. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  51412. }
  51413. if (defines.TANGENT) {
  51414. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind);
  51415. }
  51416. if (defines.UV1) {
  51417. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  51418. }
  51419. if (defines.UV2) {
  51420. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  51421. }
  51422. if (defines.VERTEXCOLOR) {
  51423. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  51424. }
  51425. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  51426. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  51427. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  51428. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vAlbedoColor", "vReflectivityColor", "vEmissiveColor", "vReflectionColor",
  51429. "vFogInfos", "vFogColor", "pointSize",
  51430. "vAlbedoInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vReflectionPosition", "vReflectionSize", "vEmissiveInfos", "vReflectivityInfos",
  51431. "vMicroSurfaceSamplerInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  51432. "mBones",
  51433. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "albedoMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "reflectivityMatrix", "normalMatrix", "microSurfaceSamplerMatrix", "bumpMatrix", "lightmapMatrix", "refractionMatrix",
  51434. "vLightingIntensity",
  51435. "logarithmicDepthConstant",
  51436. "vSphericalX", "vSphericalY", "vSphericalZ",
  51437. "vSphericalXX", "vSphericalYY", "vSphericalZZ",
  51438. "vSphericalXY", "vSphericalYZ", "vSphericalZX",
  51439. "vReflectionMicrosurfaceInfos", "vRefractionMicrosurfaceInfos",
  51440. "vTangentSpaceParams", "boneTextureWidth"
  51441. ];
  51442. var samplers = ["albedoSampler", "reflectivitySampler", "ambientSampler", "emissiveSampler",
  51443. "bumpSampler", "lightmapSampler", "opacitySampler",
  51444. "refractionSampler", "refractionSamplerLow", "refractionSamplerHigh",
  51445. "reflectionSampler", "reflectionSamplerLow", "reflectionSamplerHigh",
  51446. "microSurfaceSampler", "environmentBrdfSampler", "boneSampler"];
  51447. var uniformBuffers = ["Material", "Scene"];
  51448. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddUniforms(uniforms);
  51449. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].AddSamplers(samplers);
  51450. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].AddUniforms(uniforms);
  51451. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"]) {
  51452. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  51453. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_10__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  51454. }
  51455. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareUniformsAndSamplersList({
  51456. uniformsNames: uniforms,
  51457. uniformBuffersNames: uniformBuffers,
  51458. samplers: samplers,
  51459. defines: defines,
  51460. maxSimultaneousLights: this._maxSimultaneousLights
  51461. });
  51462. var join = defines.toString();
  51463. return engine.createEffect("pbr", {
  51464. attributes: attribs,
  51465. uniformsNames: uniforms,
  51466. uniformBuffersNames: uniformBuffers,
  51467. samplers: samplers,
  51468. defines: join,
  51469. fallbacks: fallbacks,
  51470. onCompiled: onCompiled,
  51471. onError: onError,
  51472. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  51473. }, engine);
  51474. };
  51475. PBRBaseMaterial.prototype._prepareDefines = function (mesh, defines, useInstances, useClipPlane) {
  51476. if (useInstances === void 0) { useInstances = null; }
  51477. if (useClipPlane === void 0) { useClipPlane = null; }
  51478. var scene = this.getScene();
  51479. var engine = scene.getEngine();
  51480. // Lights
  51481. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  51482. defines._needNormals = true;
  51483. // Textures
  51484. defines.METALLICWORKFLOW = this.isMetallicWorkflow();
  51485. if (defines._areTexturesDirty) {
  51486. defines._needUVs = false;
  51487. if (scene.texturesEnabled) {
  51488. if (scene.getEngine().getCaps().textureLOD) {
  51489. defines.LODBASEDMICROSFURACE = true;
  51490. }
  51491. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].DiffuseTextureEnabled) {
  51492. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._albedoTexture, defines, "ALBEDO");
  51493. }
  51494. else {
  51495. defines.ALBEDO = false;
  51496. }
  51497. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].AmbientTextureEnabled) {
  51498. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  51499. defines.AMBIENTINGRAYSCALE = this._useAmbientInGrayScale;
  51500. }
  51501. else {
  51502. defines.AMBIENT = false;
  51503. }
  51504. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].OpacityTextureEnabled) {
  51505. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  51506. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  51507. }
  51508. else {
  51509. defines.OPACITY = false;
  51510. }
  51511. var reflectionTexture = this._getReflectionTexture();
  51512. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51513. defines.REFLECTION = true;
  51514. defines.GAMMAREFLECTION = reflectionTexture.gammaSpace;
  51515. defines.RGBDREFLECTION = reflectionTexture.isRGBD;
  51516. defines.REFLECTIONMAP_OPPOSITEZ = this.getScene().useRightHandedSystem ? !reflectionTexture.invertZ : reflectionTexture.invertZ;
  51517. defines.LODINREFLECTIONALPHA = reflectionTexture.lodLevelInAlpha;
  51518. if (reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].INVCUBIC_MODE) {
  51519. defines.INVERTCUBICMAP = true;
  51520. }
  51521. defines.REFLECTIONMAP_3D = reflectionTexture.isCube;
  51522. defines.REFLECTIONMAP_CUBIC = false;
  51523. defines.REFLECTIONMAP_EXPLICIT = false;
  51524. defines.REFLECTIONMAP_PLANAR = false;
  51525. defines.REFLECTIONMAP_PROJECTION = false;
  51526. defines.REFLECTIONMAP_SKYBOX = false;
  51527. defines.REFLECTIONMAP_SPHERICAL = false;
  51528. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51529. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51530. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51531. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51532. switch (reflectionTexture.coordinatesMode) {
  51533. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].EXPLICIT_MODE:
  51534. defines.REFLECTIONMAP_EXPLICIT = true;
  51535. break;
  51536. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].PLANAR_MODE:
  51537. defines.REFLECTIONMAP_PLANAR = true;
  51538. break;
  51539. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].PROJECTION_MODE:
  51540. defines.REFLECTIONMAP_PROJECTION = true;
  51541. break;
  51542. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].SKYBOX_MODE:
  51543. defines.REFLECTIONMAP_SKYBOX = true;
  51544. break;
  51545. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].SPHERICAL_MODE:
  51546. defines.REFLECTIONMAP_SPHERICAL = true;
  51547. break;
  51548. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].EQUIRECTANGULAR_MODE:
  51549. defines.REFLECTIONMAP_EQUIRECTANGULAR = true;
  51550. break;
  51551. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  51552. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = true;
  51553. break;
  51554. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  51555. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = true;
  51556. break;
  51557. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].CUBIC_MODE:
  51558. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].INVCUBIC_MODE:
  51559. default:
  51560. defines.REFLECTIONMAP_CUBIC = true;
  51561. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = reflectionTexture.boundingBoxSize ? true : false;
  51562. break;
  51563. }
  51564. if (reflectionTexture.coordinatesMode !== _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_15__["Texture"].SKYBOX_MODE) {
  51565. if (reflectionTexture.sphericalPolynomial) {
  51566. defines.USESPHERICALFROMREFLECTIONMAP = true;
  51567. if (this._forceIrradianceInFragment || scene.getEngine().getCaps().maxVaryingVectors <= 8) {
  51568. defines.USESPHERICALINVERTEX = false;
  51569. }
  51570. else {
  51571. defines.USESPHERICALINVERTEX = true;
  51572. }
  51573. }
  51574. }
  51575. else {
  51576. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !reflectionTexture.getReflectionTextureMatrix().isIdentity();
  51577. }
  51578. }
  51579. else {
  51580. defines.REFLECTION = false;
  51581. defines.REFLECTIONMAP_3D = false;
  51582. defines.REFLECTIONMAP_SPHERICAL = false;
  51583. defines.REFLECTIONMAP_PLANAR = false;
  51584. defines.REFLECTIONMAP_CUBIC = false;
  51585. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  51586. defines.REFLECTIONMAP_PROJECTION = false;
  51587. defines.REFLECTIONMAP_SKYBOX = false;
  51588. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  51589. defines.REFLECTIONMAP_EXPLICIT = false;
  51590. defines.REFLECTIONMAP_EQUIRECTANGULAR = false;
  51591. defines.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  51592. defines.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  51593. defines.INVERTCUBICMAP = false;
  51594. defines.USESPHERICALFROMREFLECTIONMAP = false;
  51595. defines.USESPHERICALINVERTEX = false;
  51596. defines.REFLECTIONMAP_OPPOSITEZ = false;
  51597. defines.LODINREFLECTIONALPHA = false;
  51598. defines.GAMMAREFLECTION = false;
  51599. defines.RGBDREFLECTION = false;
  51600. }
  51601. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].LightmapTextureEnabled) {
  51602. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  51603. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  51604. defines.GAMMALIGHTMAP = this._lightmapTexture.gammaSpace;
  51605. }
  51606. else {
  51607. defines.LIGHTMAP = false;
  51608. }
  51609. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].EmissiveTextureEnabled) {
  51610. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  51611. }
  51612. else {
  51613. defines.EMISSIVE = false;
  51614. }
  51615. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].SpecularTextureEnabled) {
  51616. if (this._metallicTexture) {
  51617. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._metallicTexture, defines, "REFLECTIVITY");
  51618. defines.ROUGHNESSSTOREINMETALMAPALPHA = this._useRoughnessFromMetallicTextureAlpha;
  51619. defines.ROUGHNESSSTOREINMETALMAPGREEN = !this._useRoughnessFromMetallicTextureAlpha && this._useRoughnessFromMetallicTextureGreen;
  51620. defines.METALLNESSSTOREINMETALMAPBLUE = this._useMetallnessFromMetallicTextureBlue;
  51621. defines.AOSTOREINMETALMAPRED = this._useAmbientOcclusionFromMetallicTextureRed;
  51622. }
  51623. else if (this._reflectivityTexture) {
  51624. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._reflectivityTexture, defines, "REFLECTIVITY");
  51625. defines.MICROSURFACEFROMREFLECTIVITYMAP = this._useMicroSurfaceFromReflectivityMapAlpha;
  51626. defines.MICROSURFACEAUTOMATIC = this._useAutoMicroSurfaceFromReflectivityMap;
  51627. }
  51628. else {
  51629. defines.REFLECTIVITY = false;
  51630. }
  51631. if (this._microSurfaceTexture) {
  51632. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._microSurfaceTexture, defines, "MICROSURFACEMAP");
  51633. }
  51634. else {
  51635. defines.MICROSURFACEMAP = false;
  51636. }
  51637. }
  51638. else {
  51639. defines.REFLECTIVITY = false;
  51640. defines.MICROSURFACEMAP = false;
  51641. }
  51642. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51643. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  51644. if (this._useParallax && this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].DiffuseTextureEnabled) {
  51645. defines.PARALLAX = true;
  51646. defines.PARALLAXOCCLUSION = !!this._useParallaxOcclusion;
  51647. }
  51648. else {
  51649. defines.PARALLAX = false;
  51650. }
  51651. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  51652. }
  51653. else {
  51654. defines.BUMP = false;
  51655. }
  51656. var refractionTexture = this._getRefractionTexture();
  51657. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled) {
  51658. defines.REFRACTION = true;
  51659. defines.REFRACTIONMAP_3D = refractionTexture.isCube;
  51660. defines.GAMMAREFRACTION = refractionTexture.gammaSpace;
  51661. defines.RGBDREFRACTION = refractionTexture.isRGBD;
  51662. defines.REFRACTIONMAP_OPPOSITEZ = refractionTexture.invertZ;
  51663. defines.LODINREFRACTIONALPHA = refractionTexture.lodLevelInAlpha;
  51664. if (this._linkRefractionWithTransparency) {
  51665. defines.LINKREFRACTIONTOTRANSPARENCY = true;
  51666. }
  51667. }
  51668. else {
  51669. defines.REFRACTION = false;
  51670. }
  51671. if (this._environmentBRDFTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51672. defines.ENVIRONMENTBRDF = true;
  51673. }
  51674. else {
  51675. defines.ENVIRONMENTBRDF = false;
  51676. }
  51677. if (this._shouldUseAlphaFromAlbedoTexture()) {
  51678. defines.ALPHAFROMALBEDO = true;
  51679. }
  51680. else {
  51681. defines.ALPHAFROMALBEDO = false;
  51682. }
  51683. }
  51684. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  51685. if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_STANDARD) {
  51686. defines.USEPHYSICALLIGHTFALLOFF = false;
  51687. defines.USEGLTFLIGHTFALLOFF = false;
  51688. }
  51689. else if (this._lightFalloff === PBRBaseMaterial.LIGHTFALLOFF_GLTF) {
  51690. defines.USEPHYSICALLIGHTFALLOFF = false;
  51691. defines.USEGLTFLIGHTFALLOFF = true;
  51692. }
  51693. else {
  51694. defines.USEPHYSICALLIGHTFALLOFF = true;
  51695. defines.USEGLTFLIGHTFALLOFF = false;
  51696. }
  51697. defines.RADIANCEOVERALPHA = this._useRadianceOverAlpha;
  51698. if (!this.backFaceCulling && this._twoSidedLighting) {
  51699. defines.TWOSIDEDLIGHTING = true;
  51700. }
  51701. else {
  51702. defines.TWOSIDEDLIGHTING = false;
  51703. }
  51704. defines.ALPHATESTVALUE = "" + this._alphaCutOff + (this._alphaCutOff % 1 === 0 ? "." : "");
  51705. defines.PREMULTIPLYALPHA = (this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].ALPHA_PREMULTIPLIED || this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_17__["Constants"].ALPHA_PREMULTIPLIED_PORTERDUFF);
  51706. defines.ALPHABLEND = this.needAlphaBlendingForMesh(mesh);
  51707. defines.ALPHAFRESNEL = this._useAlphaFresnel || this._useLinearAlphaFresnel;
  51708. defines.LINEARALPHAFRESNEL = this._useLinearAlphaFresnel;
  51709. defines.SPECULARAA = scene.getEngine().getCaps().standardDerivatives && this._enableSpecularAntiAliasing;
  51710. }
  51711. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  51712. this._imageProcessingConfiguration.prepareDefines(defines);
  51713. }
  51714. defines.FORCENORMALFORWARD = this._forceNormalForward;
  51715. defines.RADIANCEOCCLUSION = this._useRadianceOcclusion;
  51716. defines.HORIZONOCCLUSION = this._useHorizonOcclusion;
  51717. // Misc.
  51718. if (defines._areMiscDirty) {
  51719. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh) || this._forceAlphaTest, defines);
  51720. defines.UNLIT = this._unlit || ((this.pointsCloud || this.wireframe) && !mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind));
  51721. }
  51722. // External config
  51723. this.clearCoat.prepareDefines(defines, scene);
  51724. this.anisotropy.prepareDefines(defines, mesh);
  51725. // Values that need to be evaluated on every frame
  51726. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances ? true : false, useClipPlane);
  51727. // Attribs
  51728. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true, this._transparencyMode !== PBRBaseMaterial.PBRMATERIAL_OPAQUE);
  51729. };
  51730. /**
  51731. * Force shader compilation
  51732. */
  51733. PBRBaseMaterial.prototype.forceCompilation = function (mesh, onCompiled, options) {
  51734. var _this = this;
  51735. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  51736. var defines = new PBRMaterialDefines();
  51737. var effect = this._prepareEffect(mesh, defines, undefined, undefined, undefined, localOptions.clipPlane);
  51738. if (effect.isReady()) {
  51739. if (onCompiled) {
  51740. onCompiled(this);
  51741. }
  51742. }
  51743. else {
  51744. effect.onCompileObservable.add(function () {
  51745. if (onCompiled) {
  51746. onCompiled(_this);
  51747. }
  51748. });
  51749. }
  51750. };
  51751. /**
  51752. * Initializes the uniform buffer layout for the shader.
  51753. */
  51754. PBRBaseMaterial.prototype.buildUniformLayout = function () {
  51755. // Order is important !
  51756. this._uniformBuffer.addUniform("vAlbedoInfos", 2);
  51757. this._uniformBuffer.addUniform("vAmbientInfos", 4);
  51758. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  51759. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  51760. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  51761. this._uniformBuffer.addUniform("vReflectivityInfos", 3);
  51762. this._uniformBuffer.addUniform("vMicroSurfaceSamplerInfos", 2);
  51763. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  51764. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  51765. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  51766. this._uniformBuffer.addUniform("vReflectionSize", 3);
  51767. this._uniformBuffer.addUniform("vBumpInfos", 3);
  51768. this._uniformBuffer.addUniform("albedoMatrix", 16);
  51769. this._uniformBuffer.addUniform("ambientMatrix", 16);
  51770. this._uniformBuffer.addUniform("opacityMatrix", 16);
  51771. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  51772. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  51773. this._uniformBuffer.addUniform("reflectivityMatrix", 16);
  51774. this._uniformBuffer.addUniform("microSurfaceSamplerMatrix", 16);
  51775. this._uniformBuffer.addUniform("bumpMatrix", 16);
  51776. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  51777. this._uniformBuffer.addUniform("refractionMatrix", 16);
  51778. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  51779. this._uniformBuffer.addUniform("vReflectionColor", 3);
  51780. this._uniformBuffer.addUniform("vAlbedoColor", 4);
  51781. this._uniformBuffer.addUniform("vLightingIntensity", 4);
  51782. this._uniformBuffer.addUniform("vRefractionMicrosurfaceInfos", 3);
  51783. this._uniformBuffer.addUniform("vReflectionMicrosurfaceInfos", 3);
  51784. this._uniformBuffer.addUniform("vReflectivityColor", 4);
  51785. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  51786. this._uniformBuffer.addUniform("pointSize", 1);
  51787. _pbrClearCoatConfiguration__WEBPACK_IMPORTED_MODULE_8__["PBRClearCoatConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  51788. _pbrAnisotropicConfiguration__WEBPACK_IMPORTED_MODULE_9__["PBRAnisotropicConfiguration"].PrepareUniformBuffer(this._uniformBuffer);
  51789. this._uniformBuffer.create();
  51790. };
  51791. /**
  51792. * Unbinds the textures.
  51793. */
  51794. PBRBaseMaterial.prototype.unbind = function () {
  51795. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  51796. this._uniformBuffer.setTexture("reflectionSampler", null);
  51797. }
  51798. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  51799. this._uniformBuffer.setTexture("refractionSampler", null);
  51800. }
  51801. _super.prototype.unbind.call(this);
  51802. };
  51803. /**
  51804. * Binds the submesh data.
  51805. * @param world - The world matrix.
  51806. * @param mesh - The BJS mesh.
  51807. * @param subMesh - A submesh of the BJS mesh.
  51808. */
  51809. PBRBaseMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  51810. var scene = this.getScene();
  51811. var defines = subMesh._materialDefines;
  51812. if (!defines) {
  51813. return;
  51814. }
  51815. var effect = subMesh.effect;
  51816. if (!effect) {
  51817. return;
  51818. }
  51819. this._activeEffect = effect;
  51820. // Matrices
  51821. this.bindOnlyWorldMatrix(world);
  51822. // Normal Matrix
  51823. if (defines.OBJECTSPACE_NORMALMAP) {
  51824. world.toNormalMatrix(this._normalMatrix);
  51825. this.bindOnlyNormalMatrix(this._normalMatrix);
  51826. }
  51827. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  51828. // Bones
  51829. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindBonesParameters(mesh, this._activeEffect);
  51830. var reflectionTexture = null;
  51831. if (mustRebind) {
  51832. var engine = scene.getEngine();
  51833. this._uniformBuffer.bindToEffect(effect, "Material");
  51834. this.bindViewProjection(effect);
  51835. reflectionTexture = this._getReflectionTexture();
  51836. var refractionTexture = this._getRefractionTexture();
  51837. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  51838. // Texture uniforms
  51839. if (scene.texturesEnabled) {
  51840. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].DiffuseTextureEnabled) {
  51841. this._uniformBuffer.updateFloat2("vAlbedoInfos", this._albedoTexture.coordinatesIndex, this._albedoTexture.level);
  51842. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._albedoTexture, this._uniformBuffer, "albedo");
  51843. }
  51844. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].AmbientTextureEnabled) {
  51845. this._uniformBuffer.updateFloat4("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level, this._ambientTextureStrength, this._ambientTextureImpactOnAnalyticalLights);
  51846. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  51847. }
  51848. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].OpacityTextureEnabled) {
  51849. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  51850. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  51851. }
  51852. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51853. this._uniformBuffer.updateMatrix("reflectionMatrix", reflectionTexture.getReflectionTextureMatrix());
  51854. this._uniformBuffer.updateFloat2("vReflectionInfos", reflectionTexture.level, 0);
  51855. if (reflectionTexture.boundingBoxSize) {
  51856. var cubeTexture = reflectionTexture;
  51857. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  51858. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  51859. }
  51860. var polynomials = reflectionTexture.sphericalPolynomial;
  51861. if (defines.USESPHERICALFROMREFLECTIONMAP && polynomials) {
  51862. this._activeEffect.setFloat3("vSphericalX", polynomials.x.x, polynomials.x.y, polynomials.x.z);
  51863. this._activeEffect.setFloat3("vSphericalY", polynomials.y.x, polynomials.y.y, polynomials.y.z);
  51864. this._activeEffect.setFloat3("vSphericalZ", polynomials.z.x, polynomials.z.y, polynomials.z.z);
  51865. this._activeEffect.setFloat3("vSphericalXX_ZZ", polynomials.xx.x - polynomials.zz.x, polynomials.xx.y - polynomials.zz.y, polynomials.xx.z - polynomials.zz.z);
  51866. this._activeEffect.setFloat3("vSphericalYY_ZZ", polynomials.yy.x - polynomials.zz.x, polynomials.yy.y - polynomials.zz.y, polynomials.yy.z - polynomials.zz.z);
  51867. this._activeEffect.setFloat3("vSphericalZZ", polynomials.zz.x, polynomials.zz.y, polynomials.zz.z);
  51868. this._activeEffect.setFloat3("vSphericalXY", polynomials.xy.x, polynomials.xy.y, polynomials.xy.z);
  51869. this._activeEffect.setFloat3("vSphericalYZ", polynomials.yz.x, polynomials.yz.y, polynomials.yz.z);
  51870. this._activeEffect.setFloat3("vSphericalZX", polynomials.zx.x, polynomials.zx.y, polynomials.zx.z);
  51871. }
  51872. this._uniformBuffer.updateFloat3("vReflectionMicrosurfaceInfos", reflectionTexture.getSize().width, reflectionTexture.lodGenerationScale, reflectionTexture.lodGenerationOffset);
  51873. }
  51874. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].EmissiveTextureEnabled) {
  51875. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  51876. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  51877. }
  51878. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].LightmapTextureEnabled) {
  51879. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  51880. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  51881. }
  51882. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].SpecularTextureEnabled) {
  51883. if (this._metallicTexture) {
  51884. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._metallicTexture.coordinatesIndex, this._metallicTexture.level, this._ambientTextureStrength);
  51885. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._metallicTexture, this._uniformBuffer, "reflectivity");
  51886. }
  51887. else if (this._reflectivityTexture) {
  51888. this._uniformBuffer.updateFloat3("vReflectivityInfos", this._reflectivityTexture.coordinatesIndex, this._reflectivityTexture.level, 1.0);
  51889. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._reflectivityTexture, this._uniformBuffer, "reflectivity");
  51890. }
  51891. if (this._microSurfaceTexture) {
  51892. this._uniformBuffer.updateFloat2("vMicroSurfaceSamplerInfos", this._microSurfaceTexture.coordinatesIndex, this._microSurfaceTexture.level);
  51893. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._microSurfaceTexture, this._uniformBuffer, "microSurfaceSampler");
  51894. }
  51895. }
  51896. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51897. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level, this._parallaxScaleBias);
  51898. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  51899. if (scene._mirroredCameraPosition) {
  51900. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  51901. }
  51902. else {
  51903. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  51904. }
  51905. }
  51906. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled) {
  51907. this._uniformBuffer.updateMatrix("refractionMatrix", refractionTexture.getReflectionTextureMatrix());
  51908. var depth = 1.0;
  51909. if (!refractionTexture.isCube) {
  51910. if (refractionTexture.depth) {
  51911. depth = refractionTexture.depth;
  51912. }
  51913. }
  51914. this._uniformBuffer.updateFloat4("vRefractionInfos", refractionTexture.level, this._indexOfRefraction, depth, this._invertRefractionY ? -1 : 1);
  51915. this._uniformBuffer.updateFloat3("vRefractionMicrosurfaceInfos", refractionTexture.getSize().width, refractionTexture.lodGenerationScale, refractionTexture.lodGenerationOffset);
  51916. }
  51917. }
  51918. // Point size
  51919. if (this.pointsCloud) {
  51920. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  51921. }
  51922. // Colors
  51923. if (defines.METALLICWORKFLOW) {
  51924. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].r = (this._metallic === undefined || this._metallic === null) ? 1 : this._metallic;
  51925. _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0].g = (this._roughness === undefined || this._roughness === null) ? 1 : this._roughness;
  51926. this._uniformBuffer.updateColor4("vReflectivityColor", _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Tmp"].Color3[0], 0);
  51927. }
  51928. else {
  51929. this._uniformBuffer.updateColor4("vReflectivityColor", this._reflectivityColor, this._microSurface);
  51930. }
  51931. this._uniformBuffer.updateColor3("vEmissiveColor", _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].EmissiveTextureEnabled ? this._emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_6__["Color3"].BlackReadOnly);
  51932. this._uniformBuffer.updateColor3("vReflectionColor", this._reflectionColor);
  51933. this._uniformBuffer.updateColor4("vAlbedoColor", this._albedoColor, this.alpha * mesh.visibility);
  51934. // Misc
  51935. this._lightingInfos.x = this._directIntensity;
  51936. this._lightingInfos.y = this._emissiveIntensity;
  51937. this._lightingInfos.z = this._environmentIntensity;
  51938. this._lightingInfos.w = this._specularIntensity;
  51939. this._uniformBuffer.updateVector4("vLightingIntensity", this._lightingInfos);
  51940. }
  51941. // Textures
  51942. if (scene.texturesEnabled) {
  51943. if (this._albedoTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].DiffuseTextureEnabled) {
  51944. this._uniformBuffer.setTexture("albedoSampler", this._albedoTexture);
  51945. }
  51946. if (this._ambientTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].AmbientTextureEnabled) {
  51947. this._uniformBuffer.setTexture("ambientSampler", this._ambientTexture);
  51948. }
  51949. if (this._opacityTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].OpacityTextureEnabled) {
  51950. this._uniformBuffer.setTexture("opacitySampler", this._opacityTexture);
  51951. }
  51952. if (reflectionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].ReflectionTextureEnabled) {
  51953. if (defines.LODBASEDMICROSFURACE) {
  51954. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture);
  51955. }
  51956. else {
  51957. this._uniformBuffer.setTexture("reflectionSampler", reflectionTexture._lodTextureMid || reflectionTexture);
  51958. this._uniformBuffer.setTexture("reflectionSamplerLow", reflectionTexture._lodTextureLow || reflectionTexture);
  51959. this._uniformBuffer.setTexture("reflectionSamplerHigh", reflectionTexture._lodTextureHigh || reflectionTexture);
  51960. }
  51961. }
  51962. if (defines.ENVIRONMENTBRDF) {
  51963. this._uniformBuffer.setTexture("environmentBrdfSampler", this._environmentBRDFTexture);
  51964. }
  51965. if (refractionTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].RefractionTextureEnabled) {
  51966. if (defines.LODBASEDMICROSFURACE) {
  51967. this._uniformBuffer.setTexture("refractionSampler", refractionTexture);
  51968. }
  51969. else {
  51970. this._uniformBuffer.setTexture("refractionSampler", refractionTexture._lodTextureMid || refractionTexture);
  51971. this._uniformBuffer.setTexture("refractionSamplerLow", refractionTexture._lodTextureLow || refractionTexture);
  51972. this._uniformBuffer.setTexture("refractionSamplerHigh", refractionTexture._lodTextureHigh || refractionTexture);
  51973. }
  51974. }
  51975. if (this._emissiveTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].EmissiveTextureEnabled) {
  51976. this._uniformBuffer.setTexture("emissiveSampler", this._emissiveTexture);
  51977. }
  51978. if (this._lightmapTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].LightmapTextureEnabled) {
  51979. this._uniformBuffer.setTexture("lightmapSampler", this._lightmapTexture);
  51980. }
  51981. if (_materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].SpecularTextureEnabled) {
  51982. if (this._metallicTexture) {
  51983. this._uniformBuffer.setTexture("reflectivitySampler", this._metallicTexture);
  51984. }
  51985. else if (this._reflectivityTexture) {
  51986. this._uniformBuffer.setTexture("reflectivitySampler", this._reflectivityTexture);
  51987. }
  51988. if (this._microSurfaceTexture) {
  51989. this._uniformBuffer.setTexture("microSurfaceSampler", this._microSurfaceTexture);
  51990. }
  51991. }
  51992. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_16__["MaterialFlags"].BumpTextureEnabled && !this._disableBumpMap) {
  51993. this._uniformBuffer.setTexture("bumpSampler", this._bumpTexture);
  51994. }
  51995. }
  51996. this.clearCoat.bindForSubMesh(this._uniformBuffer, scene, engine, this._disableBumpMap, this.isFrozen, this._invertNormalMapX, this._invertNormalMapY);
  51997. this.anisotropy.bindForSubMesh(this._uniformBuffer, this.isFrozen);
  51998. // Clip plane
  51999. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindClipPlane(this._activeEffect, scene);
  52000. // Colors
  52001. scene.ambientColor.multiplyToRef(this._ambientColor, this._globalAmbientColor);
  52002. var eyePosition = scene._forcedViewPosition ? scene._forcedViewPosition : (scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  52003. var invertNormal = (scene.useRightHandedSystem === (scene._mirroredCameraPosition != null));
  52004. effect.setFloat4("vEyePosition", eyePosition.x, eyePosition.y, eyePosition.z, invertNormal ? -1 : 1);
  52005. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  52006. }
  52007. if (mustRebind || !this.isFrozen) {
  52008. // Lights
  52009. if (scene.lightsEnabled && !this._disableLighting) {
  52010. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindLights(scene, mesh, this._activeEffect, defines, this._maxSimultaneousLights, this._lightFalloff !== PBRBaseMaterial.LIGHTFALLOFF_STANDARD);
  52011. }
  52012. // View
  52013. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_5__["Scene"].FOGMODE_NONE || reflectionTexture) {
  52014. this.bindView(effect);
  52015. }
  52016. // Fog
  52017. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindFogParameters(scene, mesh, this._activeEffect, true);
  52018. // Morph targets
  52019. if (defines.NUM_MORPH_INFLUENCERS) {
  52020. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindMorphTargetParameters(mesh, this._activeEffect);
  52021. }
  52022. // image processing
  52023. this._imageProcessingConfiguration.bind(this._activeEffect);
  52024. // Log. depth
  52025. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_14__["MaterialHelper"].BindLogDepth(defines, this._activeEffect, scene);
  52026. }
  52027. this._uniformBuffer.update();
  52028. this._afterBind(mesh, this._activeEffect);
  52029. };
  52030. /**
  52031. * Returns the animatable textures.
  52032. * @returns - Array of animatable textures.
  52033. */
  52034. PBRBaseMaterial.prototype.getAnimatables = function () {
  52035. var results = [];
  52036. if (this._albedoTexture && this._albedoTexture.animations && this._albedoTexture.animations.length > 0) {
  52037. results.push(this._albedoTexture);
  52038. }
  52039. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  52040. results.push(this._ambientTexture);
  52041. }
  52042. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  52043. results.push(this._opacityTexture);
  52044. }
  52045. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  52046. results.push(this._reflectionTexture);
  52047. }
  52048. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  52049. results.push(this._emissiveTexture);
  52050. }
  52051. if (this._metallicTexture && this._metallicTexture.animations && this._metallicTexture.animations.length > 0) {
  52052. results.push(this._metallicTexture);
  52053. }
  52054. else if (this._reflectivityTexture && this._reflectivityTexture.animations && this._reflectivityTexture.animations.length > 0) {
  52055. results.push(this._reflectivityTexture);
  52056. }
  52057. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  52058. results.push(this._bumpTexture);
  52059. }
  52060. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  52061. results.push(this._lightmapTexture);
  52062. }
  52063. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  52064. results.push(this._refractionTexture);
  52065. }
  52066. this.clearCoat.getAnimatables(results);
  52067. return results;
  52068. };
  52069. /**
  52070. * Returns the texture used for reflections.
  52071. * @returns - Reflection texture if present. Otherwise, returns the environment texture.
  52072. */
  52073. PBRBaseMaterial.prototype._getReflectionTexture = function () {
  52074. if (this._reflectionTexture) {
  52075. return this._reflectionTexture;
  52076. }
  52077. return this.getScene().environmentTexture;
  52078. };
  52079. /**
  52080. * Returns the texture used for refraction or null if none is used.
  52081. * @returns - Refection texture if present. If no refraction texture and refraction
  52082. * is linked with transparency, returns environment texture. Otherwise, returns null.
  52083. */
  52084. PBRBaseMaterial.prototype._getRefractionTexture = function () {
  52085. if (this._refractionTexture) {
  52086. return this._refractionTexture;
  52087. }
  52088. if (this._linkRefractionWithTransparency) {
  52089. return this.getScene().environmentTexture;
  52090. }
  52091. return null;
  52092. };
  52093. /**
  52094. * Returns an array of the actively used textures.
  52095. * @returns - Array of BaseTextures
  52096. */
  52097. PBRBaseMaterial.prototype.getActiveTextures = function () {
  52098. var activeTextures = _super.prototype.getActiveTextures.call(this);
  52099. if (this._albedoTexture) {
  52100. activeTextures.push(this._albedoTexture);
  52101. }
  52102. if (this._ambientTexture) {
  52103. activeTextures.push(this._ambientTexture);
  52104. }
  52105. if (this._opacityTexture) {
  52106. activeTextures.push(this._opacityTexture);
  52107. }
  52108. if (this._reflectionTexture) {
  52109. activeTextures.push(this._reflectionTexture);
  52110. }
  52111. if (this._emissiveTexture) {
  52112. activeTextures.push(this._emissiveTexture);
  52113. }
  52114. if (this._reflectivityTexture) {
  52115. activeTextures.push(this._reflectivityTexture);
  52116. }
  52117. if (this._metallicTexture) {
  52118. activeTextures.push(this._metallicTexture);
  52119. }
  52120. if (this._microSurfaceTexture) {
  52121. activeTextures.push(this._microSurfaceTexture);
  52122. }
  52123. if (this._bumpTexture) {
  52124. activeTextures.push(this._bumpTexture);
  52125. }
  52126. if (this._lightmapTexture) {
  52127. activeTextures.push(this._lightmapTexture);
  52128. }
  52129. if (this._refractionTexture) {
  52130. activeTextures.push(this._refractionTexture);
  52131. }
  52132. this.clearCoat.getActiveTextures(activeTextures);
  52133. return activeTextures;
  52134. };
  52135. /**
  52136. * Checks to see if a texture is used in the material.
  52137. * @param texture - Base texture to use.
  52138. * @returns - Boolean specifying if a texture is used in the material.
  52139. */
  52140. PBRBaseMaterial.prototype.hasTexture = function (texture) {
  52141. if (_super.prototype.hasTexture.call(this, texture)) {
  52142. return true;
  52143. }
  52144. if (this._albedoTexture === texture) {
  52145. return true;
  52146. }
  52147. if (this._ambientTexture === texture) {
  52148. return true;
  52149. }
  52150. if (this._opacityTexture === texture) {
  52151. return true;
  52152. }
  52153. if (this._reflectionTexture === texture) {
  52154. return true;
  52155. }
  52156. if (this._reflectivityTexture === texture) {
  52157. return true;
  52158. }
  52159. if (this._metallicTexture === texture) {
  52160. return true;
  52161. }
  52162. if (this._microSurfaceTexture === texture) {
  52163. return true;
  52164. }
  52165. if (this._bumpTexture === texture) {
  52166. return true;
  52167. }
  52168. if (this._lightmapTexture === texture) {
  52169. return true;
  52170. }
  52171. return this.clearCoat.hasTexture(texture);
  52172. };
  52173. /**
  52174. * Disposes the resources of the material.
  52175. * @param forceDisposeEffect - Forces the disposal of effects.
  52176. * @param forceDisposeTextures - Forces the disposal of all textures.
  52177. */
  52178. PBRBaseMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  52179. if (forceDisposeTextures) {
  52180. if (this._albedoTexture) {
  52181. this._albedoTexture.dispose();
  52182. }
  52183. if (this._ambientTexture) {
  52184. this._ambientTexture.dispose();
  52185. }
  52186. if (this._opacityTexture) {
  52187. this._opacityTexture.dispose();
  52188. }
  52189. if (this._reflectionTexture) {
  52190. this._reflectionTexture.dispose();
  52191. }
  52192. if (this._environmentBRDFTexture && this.getScene()._environmentBRDFTexture !== this._environmentBRDFTexture) {
  52193. this._environmentBRDFTexture.dispose();
  52194. }
  52195. if (this._emissiveTexture) {
  52196. this._emissiveTexture.dispose();
  52197. }
  52198. if (this._metallicTexture) {
  52199. this._metallicTexture.dispose();
  52200. }
  52201. if (this._reflectivityTexture) {
  52202. this._reflectivityTexture.dispose();
  52203. }
  52204. if (this._bumpTexture) {
  52205. this._bumpTexture.dispose();
  52206. }
  52207. if (this._lightmapTexture) {
  52208. this._lightmapTexture.dispose();
  52209. }
  52210. if (this._refractionTexture) {
  52211. this._refractionTexture.dispose();
  52212. }
  52213. }
  52214. this.clearCoat.dispose(forceDisposeTextures);
  52215. this._renderTargets.dispose();
  52216. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  52217. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  52218. }
  52219. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  52220. };
  52221. /**
  52222. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  52223. */
  52224. PBRBaseMaterial.PBRMATERIAL_OPAQUE = 0;
  52225. /**
  52226. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  52227. */
  52228. PBRBaseMaterial.PBRMATERIAL_ALPHATEST = 1;
  52229. /**
  52230. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52231. */
  52232. PBRBaseMaterial.PBRMATERIAL_ALPHABLEND = 2;
  52233. /**
  52234. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  52235. * They are also discarded below the alpha cutoff threshold to improve performances.
  52236. */
  52237. PBRBaseMaterial.PBRMATERIAL_ALPHATESTANDBLEND = 3;
  52238. /**
  52239. * Defines the default value of how much AO map is occluding the analytical lights
  52240. * (point spot...).
  52241. */
  52242. PBRBaseMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = 1;
  52243. /**
  52244. * PBRMaterialLightFalloff Physical: light is falling off following the inverse squared distance law.
  52245. */
  52246. PBRBaseMaterial.LIGHTFALLOFF_PHYSICAL = 0;
  52247. /**
  52248. * PBRMaterialLightFalloff gltf: light is falling off as described in the gltf moving to PBR document
  52249. * to enhance interoperability with other engines.
  52250. */
  52251. PBRBaseMaterial.LIGHTFALLOFF_GLTF = 1;
  52252. /**
  52253. * PBRMaterialLightFalloff Standard: light is falling off like in the standard material
  52254. * to enhance interoperability with other materials.
  52255. */
  52256. PBRBaseMaterial.LIGHTFALLOFF_STANDARD = 2;
  52257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsImageProcessingConfiguration"])()
  52259. ], PBRBaseMaterial.prototype, "_imageProcessingConfiguration", void 0);
  52260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52262. ], PBRBaseMaterial.prototype, "useLogarithmicDepth", null);
  52263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52265. ], PBRBaseMaterial.prototype, "transparencyMode", null);
  52266. return PBRBaseMaterial;
  52267. }(_Materials_pushMaterial__WEBPACK_IMPORTED_MODULE_13__["PushMaterial"]));
  52268. /***/ }),
  52269. /***/ "./Materials/PBR/pbrBaseSimpleMaterial.ts":
  52270. /*!************************************************!*\
  52271. !*** ./Materials/PBR/pbrBaseSimpleMaterial.ts ***!
  52272. \************************************************/
  52273. /*! exports provided: PBRBaseSimpleMaterial */
  52274. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52275. "use strict";
  52276. __webpack_require__.r(__webpack_exports__);
  52277. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return PBRBaseSimpleMaterial; });
  52278. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52279. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52280. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52281. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52282. /**
  52283. * The Physically based simple base material of BJS.
  52284. *
  52285. * This enables better naming and convention enforcements on top of the pbrMaterial.
  52286. * It is used as the base class for both the specGloss and metalRough conventions.
  52287. */
  52288. var PBRBaseSimpleMaterial = /** @class */ (function (_super) {
  52289. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRBaseSimpleMaterial, _super);
  52290. /**
  52291. * Instantiates a new PBRMaterial instance.
  52292. *
  52293. * @param name The material name
  52294. * @param scene The scene the material will be use in.
  52295. */
  52296. function PBRBaseSimpleMaterial(name, scene) {
  52297. var _this = _super.call(this, name, scene) || this;
  52298. /**
  52299. * Number of Simultaneous lights allowed on the material.
  52300. */
  52301. _this.maxSimultaneousLights = 4;
  52302. /**
  52303. * If sets to true, disables all the lights affecting the material.
  52304. */
  52305. _this.disableLighting = false;
  52306. /**
  52307. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52308. */
  52309. _this.invertNormalMapX = false;
  52310. /**
  52311. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52312. */
  52313. _this.invertNormalMapY = false;
  52314. /**
  52315. * Emissivie color used to self-illuminate the model.
  52316. */
  52317. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"](0, 0, 0);
  52318. /**
  52319. * Occlusion Channel Strenght.
  52320. */
  52321. _this.occlusionStrength = 1.0;
  52322. /**
  52323. * If true, the light map contains occlusion information instead of lighting info.
  52324. */
  52325. _this.useLightmapAsShadowmap = false;
  52326. _this._useAlphaFromAlbedoTexture = true;
  52327. _this._useAmbientInGrayScale = true;
  52328. return _this;
  52329. }
  52330. Object.defineProperty(PBRBaseSimpleMaterial.prototype, "doubleSided", {
  52331. /**
  52332. * Gets the current double sided mode.
  52333. */
  52334. get: function () {
  52335. return this._twoSidedLighting;
  52336. },
  52337. /**
  52338. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52339. */
  52340. set: function (value) {
  52341. if (this._twoSidedLighting === value) {
  52342. return;
  52343. }
  52344. this._twoSidedLighting = value;
  52345. this.backFaceCulling = !value;
  52346. this._markAllSubMeshesAsTexturesDirty();
  52347. },
  52348. enumerable: true,
  52349. configurable: true
  52350. });
  52351. PBRBaseSimpleMaterial.prototype.getClassName = function () {
  52352. return "PBRBaseSimpleMaterial";
  52353. };
  52354. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52355. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52357. ], PBRBaseSimpleMaterial.prototype, "maxSimultaneousLights", void 0);
  52358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  52361. ], PBRBaseSimpleMaterial.prototype, "disableLighting", void 0);
  52362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52364. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectionTexture")
  52365. ], PBRBaseSimpleMaterial.prototype, "environmentTexture", void 0);
  52366. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52367. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52369. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapX", void 0);
  52370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52373. ], PBRBaseSimpleMaterial.prototype, "invertNormalMapY", void 0);
  52374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52376. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_bumpTexture")
  52377. ], PBRBaseSimpleMaterial.prototype, "normalTexture", void 0);
  52378. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52379. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  52380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52381. ], PBRBaseSimpleMaterial.prototype, "emissiveColor", void 0);
  52382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52385. ], PBRBaseSimpleMaterial.prototype, "emissiveTexture", void 0);
  52386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTextureStrength")
  52389. ], PBRBaseSimpleMaterial.prototype, "occlusionStrength", void 0);
  52390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_ambientTexture")
  52393. ], PBRBaseSimpleMaterial.prototype, "occlusionTexture", void 0);
  52394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_alphaCutOff")
  52397. ], PBRBaseSimpleMaterial.prototype, "alphaCutOff", void 0);
  52398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52400. ], PBRBaseSimpleMaterial.prototype, "doubleSided", null);
  52401. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52402. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  52403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  52404. ], PBRBaseSimpleMaterial.prototype, "lightmapTexture", void 0);
  52405. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52406. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  52407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52408. ], PBRBaseSimpleMaterial.prototype, "useLightmapAsShadowmap", void 0);
  52409. return PBRBaseSimpleMaterial;
  52410. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_3__["PBRBaseMaterial"]));
  52411. /***/ }),
  52412. /***/ "./Materials/PBR/pbrClearCoatConfiguration.ts":
  52413. /*!****************************************************!*\
  52414. !*** ./Materials/PBR/pbrClearCoatConfiguration.ts ***!
  52415. \****************************************************/
  52416. /*! exports provided: PBRClearCoatConfiguration */
  52417. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52418. "use strict";
  52419. __webpack_require__.r(__webpack_exports__);
  52420. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRClearCoatConfiguration", function() { return PBRClearCoatConfiguration; });
  52421. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52422. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52423. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../materialFlags */ "./Materials/materialFlags.ts");
  52424. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/materialHelper */ "./Materials/materialHelper.ts");
  52425. /**
  52426. * Define the code related to the clear coat parameters of the pbr material.
  52427. */
  52428. var PBRClearCoatConfiguration = /** @class */ (function () {
  52429. /**
  52430. * Instantiate a new istance of clear coat configuration.
  52431. * @param markAllSubMeshesAsTexturesDirty Callback to flag the material to dirty
  52432. */
  52433. function PBRClearCoatConfiguration(markAllSubMeshesAsTexturesDirty) {
  52434. this._isEnabled = false;
  52435. /**
  52436. * Defines if the clear coat is enabled in the material.
  52437. */
  52438. this.isEnabled = false;
  52439. /**
  52440. * Defines the clear coat layer strength (between 0 and 1) it defaults to 1.
  52441. */
  52442. this.intensity = 1;
  52443. /**
  52444. * Defines the clear coat layer roughness.
  52445. */
  52446. this.roughness = 0;
  52447. this._texture = null;
  52448. /**
  52449. * Stores the clear coat values in a texture.
  52450. */
  52451. this.texture = null;
  52452. this._bumpTexture = null;
  52453. /**
  52454. * Define the clear coat specific bump texture.
  52455. */
  52456. this.bumpTexture = null;
  52457. this._internalMarkAllSubMeshesAsTexturesDirty = markAllSubMeshesAsTexturesDirty;
  52458. }
  52459. /** @hidden */
  52460. PBRClearCoatConfiguration.prototype._markAllSubMeshesAsTexturesDirty = function () {
  52461. this._internalMarkAllSubMeshesAsTexturesDirty();
  52462. };
  52463. /**
  52464. * Specifies that the submesh is ready to be used.
  52465. * @param defines the list of "defines" to update.
  52466. * @param scene defines the scene the material belongs to.
  52467. * @param engine defines the engine the material belongs to.
  52468. * @param disableBumpMap defines wether the material disables bump or not.
  52469. * @returns - boolean indicating that the submesh is ready or not.
  52470. */
  52471. PBRClearCoatConfiguration.prototype.isReadyForSubMesh = function (defines, scene, engine, disableBumpMap) {
  52472. if (defines._areTexturesDirty) {
  52473. if (scene.texturesEnabled) {
  52474. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatTextureEnabled) {
  52475. if (!this._texture.isReadyOrNotBlocking()) {
  52476. return false;
  52477. }
  52478. }
  52479. if (engine.getCaps().standardDerivatives && this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  52480. // Bump texture cannot be not blocking.
  52481. if (!this._bumpTexture.isReady()) {
  52482. return false;
  52483. }
  52484. }
  52485. }
  52486. }
  52487. return true;
  52488. };
  52489. /**
  52490. * Checks to see if a texture is used in the material.
  52491. * @param defines the list of "defines" to update.
  52492. * @param scene defines the scene to the material belongs to.
  52493. */
  52494. PBRClearCoatConfiguration.prototype.prepareDefines = function (defines, scene) {
  52495. if (this._isEnabled) {
  52496. defines.CLEARCOAT = true;
  52497. if (defines._areTexturesDirty) {
  52498. if (scene.texturesEnabled) {
  52499. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatTextureEnabled) {
  52500. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_3__["MaterialHelper"].PrepareDefinesForMergedUV(this._texture, defines, "CLEARCOAT_TEXTURE");
  52501. }
  52502. else {
  52503. defines.CLEARCOAT_TEXTURE = false;
  52504. }
  52505. if (this._bumpTexture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatBumpTextureEnabled) {
  52506. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_3__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "CLEARCOAT_BUMP");
  52507. }
  52508. else {
  52509. defines.CLEARCOAT_BUMP = false;
  52510. }
  52511. }
  52512. }
  52513. }
  52514. else {
  52515. defines.CLEARCOAT = false;
  52516. defines.CLEARCOAT_TEXTURE = false;
  52517. defines.CLEARCOAT_BUMP = false;
  52518. }
  52519. };
  52520. /**
  52521. * Binds the material data.
  52522. * @param uniformBuffer defines the Uniform buffer to fill in.
  52523. * @param scene defines the scene the material belongs to.
  52524. * @param engine defines the engine the material belongs to.
  52525. * @param disableBumpMap defines wether the material disables bump or not.
  52526. * @param isFrozen defines wether the material is frozen or not.
  52527. * @param invertNormalMapX If sets to true, x component of normal map value will be inverted (x = 1.0 - x).
  52528. * @param invertNormalMapY If sets to true, y component of normal map value will be inverted (y = 1.0 - y).
  52529. */
  52530. PBRClearCoatConfiguration.prototype.bindForSubMesh = function (uniformBuffer, scene, engine, disableBumpMap, isFrozen, invertNormalMapX, invertNormalMapY) {
  52531. if (!uniformBuffer.useUbo || !isFrozen || !uniformBuffer.isSync) {
  52532. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatTextureEnabled) {
  52533. uniformBuffer.updateFloat2("vClearCoatInfos", this._texture.coordinatesIndex, this._texture.level);
  52534. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_3__["MaterialHelper"].BindTextureMatrix(this._texture, uniformBuffer, "clearCoat");
  52535. }
  52536. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatTextureEnabled && !disableBumpMap) {
  52537. uniformBuffer.updateFloat2("vClearCoatBumpInfos", this._bumpTexture.coordinatesIndex, this._bumpTexture.level);
  52538. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_3__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, uniformBuffer, "clearCoatBump");
  52539. if (scene._mirroredCameraPosition) {
  52540. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? 1.0 : -1.0, invertNormalMapY ? 1.0 : -1.0);
  52541. }
  52542. else {
  52543. uniformBuffer.updateFloat2("vClearCoatTangentSpaceParams", invertNormalMapX ? -1.0 : 1.0, invertNormalMapY ? -1.0 : 1.0);
  52544. }
  52545. }
  52546. // Clear Coat
  52547. uniformBuffer.updateFloat2("vClearCoatParams", this.intensity, this.roughness);
  52548. }
  52549. // Textures
  52550. if (scene.texturesEnabled) {
  52551. if (this._texture && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatTextureEnabled) {
  52552. uniformBuffer.setTexture("clearCoatSampler", this._texture);
  52553. }
  52554. if (this._bumpTexture && engine.getCaps().standardDerivatives && _materialFlags__WEBPACK_IMPORTED_MODULE_2__["MaterialFlags"].ClearCoatBumpTextureEnabled && !disableBumpMap) {
  52555. uniformBuffer.setTexture("clearCoatBumpSampler", this._bumpTexture);
  52556. }
  52557. }
  52558. };
  52559. /**
  52560. * Checks to see if a texture is used in the material.
  52561. * @param texture - Base texture to use.
  52562. * @returns - Boolean specifying if a texture is used in the material.
  52563. */
  52564. PBRClearCoatConfiguration.prototype.hasTexture = function (texture) {
  52565. if (this._texture === texture) {
  52566. return true;
  52567. }
  52568. if (this._bumpTexture === texture) {
  52569. return true;
  52570. }
  52571. return false;
  52572. };
  52573. /**
  52574. * Returns an array of the actively used textures.
  52575. * @param activeTextures Array of BaseTextures
  52576. */
  52577. PBRClearCoatConfiguration.prototype.getActiveTextures = function (activeTextures) {
  52578. if (this._texture) {
  52579. activeTextures.push(this._texture);
  52580. }
  52581. if (this._bumpTexture) {
  52582. activeTextures.push(this._bumpTexture);
  52583. }
  52584. };
  52585. /**
  52586. * Returns the animatable textures.
  52587. * @param animatables Array of animatable textures.
  52588. */
  52589. PBRClearCoatConfiguration.prototype.getAnimatables = function (animatables) {
  52590. if (this._texture && this._texture.animations && this._texture.animations.length > 0) {
  52591. animatables.push(this._texture);
  52592. }
  52593. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  52594. animatables.push(this._bumpTexture);
  52595. }
  52596. };
  52597. /**
  52598. * Disposes the resources of the material.
  52599. * @param forceDisposeTextures - Forces the disposal of all textures.
  52600. */
  52601. PBRClearCoatConfiguration.prototype.dispose = function (forceDisposeTextures) {
  52602. if (forceDisposeTextures) {
  52603. if (this._texture) {
  52604. this._texture.dispose();
  52605. }
  52606. if (this._bumpTexture) {
  52607. this._bumpTexture.dispose();
  52608. }
  52609. }
  52610. };
  52611. /**
  52612. * Get the current class name of the texture useful for serialization or dynamic coding.
  52613. * @returns "PBRClearCoatConfiguration"
  52614. */
  52615. PBRClearCoatConfiguration.prototype.getClassName = function () {
  52616. return "PBRClearCoatConfiguration";
  52617. };
  52618. /**
  52619. * Makes a duplicate of the current configuration into another one.
  52620. * @param clearCoatConfiguration define the config where to copy the info
  52621. */
  52622. PBRClearCoatConfiguration.prototype.copyTo = function (clearCoatConfiguration) {
  52623. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return clearCoatConfiguration; }, this);
  52624. };
  52625. /**
  52626. * Serializes this clear coat configuration.
  52627. * @returns - An object with the serialized config.
  52628. */
  52629. PBRClearCoatConfiguration.prototype.serialize = function () {
  52630. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  52631. };
  52632. /**
  52633. * Parses a Clear Coat Configuration from a serialized object.
  52634. * @param source - Serialized object.
  52635. */
  52636. PBRClearCoatConfiguration.prototype.parse = function (source) {
  52637. var _this = this;
  52638. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return _this; }, source, null);
  52639. };
  52640. /**
  52641. * Add fallbacks to the effect fallbacks list.
  52642. * @param defines defines the Base texture to use.
  52643. * @param fallbacks defines the current fallback list.
  52644. * @param currentRank defines the current fallback rank.
  52645. * @returns the new fallback rank.
  52646. */
  52647. PBRClearCoatConfiguration.AddFallbacks = function (defines, fallbacks, currentRank) {
  52648. if (defines.CLEARCOAT_BUMP) {
  52649. fallbacks.addFallback(currentRank++, "CLEARCOAT_BUMP");
  52650. }
  52651. if (defines.CLEARCOAT) {
  52652. fallbacks.addFallback(currentRank++, "CLEARCOAT");
  52653. }
  52654. return currentRank;
  52655. };
  52656. /**
  52657. * Add the required uniforms to the current list.
  52658. * @param uniforms defines the current uniform list.
  52659. */
  52660. PBRClearCoatConfiguration.AddUniforms = function (uniforms) {
  52661. uniforms.push("vClearCoatTangentSpaceParams", "vClearCoatParams", "clearCoatMatrix", "clearCoatBumpMatrix", "vClearCoatInfos", "vClearCoatBumpInfos");
  52662. };
  52663. /**
  52664. * Add the required samplers to the current list.
  52665. * @param samplers defines the current sampler list.
  52666. */
  52667. PBRClearCoatConfiguration.AddSamplers = function (samplers) {
  52668. samplers.push("clearCoatSampler", "clearCoatBumpSampler");
  52669. };
  52670. /**
  52671. * Add the required uniforms to the current buffer.
  52672. * @param uniformBuffer defines the current uniform buffer.
  52673. */
  52674. PBRClearCoatConfiguration.PrepareUniformBuffer = function (uniformBuffer) {
  52675. uniformBuffer.addUniform("vClearCoatParams", 2);
  52676. uniformBuffer.addUniform("vClearCoatInfos", 2);
  52677. uniformBuffer.addUniform("clearCoatMatrix", 16);
  52678. uniformBuffer.addUniform("vClearCoatBumpInfos", 2);
  52679. uniformBuffer.addUniform("vClearCoatTangentSpaceParams", 2);
  52680. uniformBuffer.addUniform("clearCoatBumpMatrix", 16);
  52681. };
  52682. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52683. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52684. ], PBRClearCoatConfiguration.prototype, "_isEnabled", void 0);
  52685. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52686. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52687. ], PBRClearCoatConfiguration.prototype, "isEnabled", void 0);
  52688. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52689. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52690. ], PBRClearCoatConfiguration.prototype, "intensity", void 0);
  52691. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52692. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  52693. ], PBRClearCoatConfiguration.prototype, "roughness", void 0);
  52694. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52695. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  52696. ], PBRClearCoatConfiguration.prototype, "_texture", void 0);
  52697. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52698. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52699. ], PBRClearCoatConfiguration.prototype, "texture", void 0);
  52700. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52701. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])()
  52702. ], PBRClearCoatConfiguration.prototype, "_bumpTexture", void 0);
  52703. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  52704. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  52705. ], PBRClearCoatConfiguration.prototype, "bumpTexture", void 0);
  52706. return PBRClearCoatConfiguration;
  52707. }());
  52708. /***/ }),
  52709. /***/ "./Materials/PBR/pbrMaterial.ts":
  52710. /*!**************************************!*\
  52711. !*** ./Materials/PBR/pbrMaterial.ts ***!
  52712. \**************************************/
  52713. /*! exports provided: PBRMaterial */
  52714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  52715. "use strict";
  52716. __webpack_require__.r(__webpack_exports__);
  52717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return PBRMaterial; });
  52718. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  52719. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  52720. /* harmony import */ var _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/textureTools */ "./Misc/textureTools.ts");
  52721. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  52722. /* harmony import */ var _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pbrBaseMaterial */ "./Materials/PBR/pbrBaseMaterial.ts");
  52723. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  52724. /**
  52725. * The Physically based material of BJS.
  52726. *
  52727. * This offers the main features of a standard PBR material.
  52728. * For more information, please refer to the documentation :
  52729. * http://doc.babylonjs.com/extensions/Physically_Based_Rendering
  52730. */
  52731. var PBRMaterial = /** @class */ (function (_super) {
  52732. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMaterial, _super);
  52733. /**
  52734. * Instantiates a new PBRMaterial instance.
  52735. *
  52736. * @param name The material name
  52737. * @param scene The scene the material will be use in.
  52738. */
  52739. function PBRMaterial(name, scene) {
  52740. var _this = _super.call(this, name, scene) || this;
  52741. /**
  52742. * Intensity of the direct lights e.g. the four lights available in your scene.
  52743. * This impacts both the direct diffuse and specular highlights.
  52744. */
  52745. _this.directIntensity = 1.0;
  52746. /**
  52747. * Intensity of the emissive part of the material.
  52748. * This helps controlling the emissive effect without modifying the emissive color.
  52749. */
  52750. _this.emissiveIntensity = 1.0;
  52751. /**
  52752. * Intensity of the environment e.g. how much the environment will light the object
  52753. * either through harmonics for rough material or through the refelction for shiny ones.
  52754. */
  52755. _this.environmentIntensity = 1.0;
  52756. /**
  52757. * This is a special control allowing the reduction of the specular highlights coming from the
  52758. * four lights of the scene. Those highlights may not be needed in full environment lighting.
  52759. */
  52760. _this.specularIntensity = 1.0;
  52761. /**
  52762. * Debug Control allowing disabling the bump map on this material.
  52763. */
  52764. _this.disableBumpMap = false;
  52765. /**
  52766. * AKA Occlusion Texture Intensity in other nomenclature.
  52767. */
  52768. _this.ambientTextureStrength = 1.0;
  52769. /**
  52770. * Defines how much the AO map is occluding the analytical lights (point spot...).
  52771. * 1 means it completely occludes it
  52772. * 0 mean it has no impact
  52773. */
  52774. _this.ambientTextureImpactOnAnalyticalLights = PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  52775. /**
  52776. * The color of a material in ambient lighting.
  52777. */
  52778. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52779. /**
  52780. * AKA Diffuse Color in other nomenclature.
  52781. */
  52782. _this.albedoColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52783. /**
  52784. * AKA Specular Color in other nomenclature.
  52785. */
  52786. _this.reflectivityColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  52787. /**
  52788. * The color reflected from the material.
  52789. */
  52790. _this.reflectionColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1.0, 1.0, 1.0);
  52791. /**
  52792. * The color emitted from the material.
  52793. */
  52794. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](0, 0, 0);
  52795. /**
  52796. * AKA Glossiness in other nomenclature.
  52797. */
  52798. _this.microSurface = 1.0;
  52799. /**
  52800. * source material index of refraction (IOR)' / 'destination material IOR.
  52801. */
  52802. _this.indexOfRefraction = 0.66;
  52803. /**
  52804. * Controls if refraction needs to be inverted on Y. This could be useful for procedural texture.
  52805. */
  52806. _this.invertRefractionY = false;
  52807. /**
  52808. * This parameters will make the material used its opacity to control how much it is refracting aginst not.
  52809. * Materials half opaque for instance using refraction could benefit from this control.
  52810. */
  52811. _this.linkRefractionWithTransparency = false;
  52812. /**
  52813. * If true, the light map contains occlusion information instead of lighting info.
  52814. */
  52815. _this.useLightmapAsShadowmap = false;
  52816. /**
  52817. * Specifies that the alpha is coming form the albedo channel alpha channel for alpha blending.
  52818. */
  52819. _this.useAlphaFromAlbedoTexture = false;
  52820. /**
  52821. * Enforces alpha test in opaque or blend mode in order to improve the performances of some situations.
  52822. */
  52823. _this.forceAlphaTest = false;
  52824. /**
  52825. * Defines the alpha limits in alpha test mode.
  52826. */
  52827. _this.alphaCutOff = 0.4;
  52828. /**
  52829. * Specifies that the material will keep the specular highlights over a transparent surface (only the most limunous ones).
  52830. * A car glass is a good exemple of that. When sun reflects on it you can not see what is behind.
  52831. */
  52832. _this.useSpecularOverAlpha = true;
  52833. /**
  52834. * Specifies if the reflectivity texture contains the glossiness information in its alpha channel.
  52835. */
  52836. _this.useMicroSurfaceFromReflectivityMapAlpha = false;
  52837. /**
  52838. * Specifies if the metallic texture contains the roughness information in its alpha channel.
  52839. */
  52840. _this.useRoughnessFromMetallicTextureAlpha = true;
  52841. /**
  52842. * Specifies if the metallic texture contains the roughness information in its green channel.
  52843. */
  52844. _this.useRoughnessFromMetallicTextureGreen = false;
  52845. /**
  52846. * Specifies if the metallic texture contains the metallness information in its blue channel.
  52847. */
  52848. _this.useMetallnessFromMetallicTextureBlue = false;
  52849. /**
  52850. * Specifies if the metallic texture contains the ambient occlusion information in its red channel.
  52851. */
  52852. _this.useAmbientOcclusionFromMetallicTextureRed = false;
  52853. /**
  52854. * Specifies if the ambient texture contains the ambient occlusion information in its red channel only.
  52855. */
  52856. _this.useAmbientInGrayScale = false;
  52857. /**
  52858. * In case the reflectivity map does not contain the microsurface information in its alpha channel,
  52859. * The material will try to infer what glossiness each pixel should be.
  52860. */
  52861. _this.useAutoMicroSurfaceFromReflectivityMap = false;
  52862. /**
  52863. * Specifies that the material will keeps the reflection highlights over a transparent surface (only the most limunous ones).
  52864. * A car glass is a good exemple of that. When the street lights reflects on it you can not see what is behind.
  52865. */
  52866. _this.useRadianceOverAlpha = true;
  52867. /**
  52868. * Allows using an object space normal map (instead of tangent space).
  52869. */
  52870. _this.useObjectSpaceNormalMap = false;
  52871. /**
  52872. * Allows using the bump map in parallax mode.
  52873. */
  52874. _this.useParallax = false;
  52875. /**
  52876. * Allows using the bump map in parallax occlusion mode.
  52877. */
  52878. _this.useParallaxOcclusion = false;
  52879. /**
  52880. * Controls the scale bias of the parallax mode.
  52881. */
  52882. _this.parallaxScaleBias = 0.05;
  52883. /**
  52884. * If sets to true, disables all the lights affecting the material.
  52885. */
  52886. _this.disableLighting = false;
  52887. /**
  52888. * Force the shader to compute irradiance in the fragment shader in order to take bump in account.
  52889. */
  52890. _this.forceIrradianceInFragment = false;
  52891. /**
  52892. * Number of Simultaneous lights allowed on the material.
  52893. */
  52894. _this.maxSimultaneousLights = 4;
  52895. /**
  52896. * If sets to true, x component of normal map value will invert (x = 1.0 - x).
  52897. */
  52898. _this.invertNormalMapX = false;
  52899. /**
  52900. * If sets to true, y component of normal map value will invert (y = 1.0 - y).
  52901. */
  52902. _this.invertNormalMapY = false;
  52903. /**
  52904. * If sets to true and backfaceCulling is false, normals will be flipped on the backside.
  52905. */
  52906. _this.twoSidedLighting = false;
  52907. /**
  52908. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52909. * And/Or occlude the blended part. (alpha is converted to gamma to compute the fresnel)
  52910. */
  52911. _this.useAlphaFresnel = false;
  52912. /**
  52913. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52914. * And/Or occlude the blended part. (alpha stays linear to compute the fresnel)
  52915. */
  52916. _this.useLinearAlphaFresnel = false;
  52917. /**
  52918. * A fresnel is applied to the alpha of the model to ensure grazing angles edges are not alpha tested.
  52919. * And/Or occlude the blended part.
  52920. */
  52921. _this.environmentBRDFTexture = null;
  52922. /**
  52923. * Force normal to face away from face.
  52924. */
  52925. _this.forceNormalForward = false;
  52926. /**
  52927. * Enables specular anti aliasing in the PBR shader.
  52928. * It will both interacts on the Geometry for analytical and IBL lighting.
  52929. * It also prefilter the roughness map based on the bump values.
  52930. */
  52931. _this.enableSpecularAntiAliasing = false;
  52932. /**
  52933. * This parameters will enable/disable Horizon occlusion to prevent normal maps to look shiny when the normal
  52934. * makes the reflect vector face the model (under horizon).
  52935. */
  52936. _this.useHorizonOcclusion = true;
  52937. /**
  52938. * This parameters will enable/disable radiance occlusion by preventing the radiance to lit
  52939. * too much the area relying on ambient texture to define their ambient occlusion.
  52940. */
  52941. _this.useRadianceOcclusion = true;
  52942. /**
  52943. * If set to true, no lighting calculations will be applied.
  52944. */
  52945. _this.unlit = false;
  52946. _this._environmentBRDFTexture = _Misc_textureTools__WEBPACK_IMPORTED_MODULE_2__["TextureTools"].GetEnvironmentBRDFTexture(scene);
  52947. return _this;
  52948. }
  52949. Object.defineProperty(PBRMaterial.prototype, "usePhysicalLightFalloff", {
  52950. /**
  52951. * BJS is using an harcoded light falloff based on a manually sets up range.
  52952. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52953. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52954. */
  52955. get: function () {
  52956. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52957. },
  52958. /**
  52959. * BJS is using an harcoded light falloff based on a manually sets up range.
  52960. * In PBR, one way to represents the fallof is to use the inverse squared root algorythm.
  52961. * This parameter can help you switch back to the BJS mode in order to create scenes using both materials.
  52962. */
  52963. set: function (value) {
  52964. if (value !== this.usePhysicalLightFalloff) {
  52965. // Ensure the effect will be rebuilt.
  52966. this._markAllSubMeshesAsTexturesDirty();
  52967. if (value) {
  52968. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_PHYSICAL;
  52969. }
  52970. else {
  52971. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52972. }
  52973. }
  52974. },
  52975. enumerable: true,
  52976. configurable: true
  52977. });
  52978. Object.defineProperty(PBRMaterial.prototype, "useGLTFLightFalloff", {
  52979. /**
  52980. * In order to support the falloff compatibility with gltf, a special mode has been added
  52981. * to reproduce the gltf light falloff.
  52982. */
  52983. get: function () {
  52984. return this._lightFalloff === _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52985. },
  52986. /**
  52987. * In order to support the falloff compatibility with gltf, a special mode has been added
  52988. * to reproduce the gltf light falloff.
  52989. */
  52990. set: function (value) {
  52991. if (value !== this.useGLTFLightFalloff) {
  52992. // Ensure the effect will be rebuilt.
  52993. this._markAllSubMeshesAsTexturesDirty();
  52994. if (value) {
  52995. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_GLTF;
  52996. }
  52997. else {
  52998. this._lightFalloff = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].LIGHTFALLOFF_STANDARD;
  52999. }
  53000. }
  53001. },
  53002. enumerable: true,
  53003. configurable: true
  53004. });
  53005. Object.defineProperty(PBRMaterial.prototype, "imageProcessingConfiguration", {
  53006. /**
  53007. * Gets the image processing configuration used either in this material.
  53008. */
  53009. get: function () {
  53010. return this._imageProcessingConfiguration;
  53011. },
  53012. /**
  53013. * Sets the Default image processing configuration used either in the this material.
  53014. *
  53015. * If sets to null, the scene one is in use.
  53016. */
  53017. set: function (value) {
  53018. this._attachImageProcessingConfiguration(value);
  53019. // Ensure the effect will be rebuilt.
  53020. this._markAllSubMeshesAsTexturesDirty();
  53021. },
  53022. enumerable: true,
  53023. configurable: true
  53024. });
  53025. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurvesEnabled", {
  53026. /**
  53027. * Gets wether the color curves effect is enabled.
  53028. */
  53029. get: function () {
  53030. return this.imageProcessingConfiguration.colorCurvesEnabled;
  53031. },
  53032. /**
  53033. * Sets wether the color curves effect is enabled.
  53034. */
  53035. set: function (value) {
  53036. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  53037. },
  53038. enumerable: true,
  53039. configurable: true
  53040. });
  53041. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingEnabled", {
  53042. /**
  53043. * Gets wether the color grading effect is enabled.
  53044. */
  53045. get: function () {
  53046. return this.imageProcessingConfiguration.colorGradingEnabled;
  53047. },
  53048. /**
  53049. * Gets wether the color grading effect is enabled.
  53050. */
  53051. set: function (value) {
  53052. this.imageProcessingConfiguration.colorGradingEnabled = value;
  53053. },
  53054. enumerable: true,
  53055. configurable: true
  53056. });
  53057. Object.defineProperty(PBRMaterial.prototype, "cameraToneMappingEnabled", {
  53058. /**
  53059. * Gets wether tonemapping is enabled or not.
  53060. */
  53061. get: function () {
  53062. return this._imageProcessingConfiguration.toneMappingEnabled;
  53063. },
  53064. /**
  53065. * Sets wether tonemapping is enabled or not
  53066. */
  53067. set: function (value) {
  53068. this._imageProcessingConfiguration.toneMappingEnabled = value;
  53069. },
  53070. enumerable: true,
  53071. configurable: true
  53072. });
  53073. Object.defineProperty(PBRMaterial.prototype, "cameraExposure", {
  53074. /**
  53075. * The camera exposure used on this material.
  53076. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53077. * This corresponds to a photographic exposure.
  53078. */
  53079. get: function () {
  53080. return this._imageProcessingConfiguration.exposure;
  53081. },
  53082. /**
  53083. * The camera exposure used on this material.
  53084. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  53085. * This corresponds to a photographic exposure.
  53086. */
  53087. set: function (value) {
  53088. this._imageProcessingConfiguration.exposure = value;
  53089. },
  53090. enumerable: true,
  53091. configurable: true
  53092. });
  53093. Object.defineProperty(PBRMaterial.prototype, "cameraContrast", {
  53094. /**
  53095. * Gets The camera contrast used on this material.
  53096. */
  53097. get: function () {
  53098. return this._imageProcessingConfiguration.contrast;
  53099. },
  53100. /**
  53101. * Sets The camera contrast used on this material.
  53102. */
  53103. set: function (value) {
  53104. this._imageProcessingConfiguration.contrast = value;
  53105. },
  53106. enumerable: true,
  53107. configurable: true
  53108. });
  53109. Object.defineProperty(PBRMaterial.prototype, "cameraColorGradingTexture", {
  53110. /**
  53111. * Gets the Color Grading 2D Lookup Texture.
  53112. */
  53113. get: function () {
  53114. return this._imageProcessingConfiguration.colorGradingTexture;
  53115. },
  53116. /**
  53117. * Sets the Color Grading 2D Lookup Texture.
  53118. */
  53119. set: function (value) {
  53120. this._imageProcessingConfiguration.colorGradingTexture = value;
  53121. },
  53122. enumerable: true,
  53123. configurable: true
  53124. });
  53125. Object.defineProperty(PBRMaterial.prototype, "cameraColorCurves", {
  53126. /**
  53127. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53128. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53129. * 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;
  53130. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53131. */
  53132. get: function () {
  53133. return this._imageProcessingConfiguration.colorCurves;
  53134. },
  53135. /**
  53136. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  53137. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  53138. * 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;
  53139. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  53140. */
  53141. set: function (value) {
  53142. this._imageProcessingConfiguration.colorCurves = value;
  53143. },
  53144. enumerable: true,
  53145. configurable: true
  53146. });
  53147. /**
  53148. * Returns the name of this material class.
  53149. */
  53150. PBRMaterial.prototype.getClassName = function () {
  53151. return "PBRMaterial";
  53152. };
  53153. /**
  53154. * Makes a duplicate of the current material.
  53155. * @param name - name to use for the new material.
  53156. */
  53157. PBRMaterial.prototype.clone = function (name) {
  53158. var _this = this;
  53159. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMaterial(name, _this.getScene()); }, this);
  53160. clone.id = name;
  53161. clone.name = name;
  53162. this.clearCoat.copyTo(clone.clearCoat);
  53163. return clone;
  53164. };
  53165. /**
  53166. * Serializes this PBR Material.
  53167. * @returns - An object with the serialized material.
  53168. */
  53169. PBRMaterial.prototype.serialize = function () {
  53170. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53171. serializationObject.customType = "BABYLON.PBRMaterial";
  53172. serializationObject.clearCoat = this.clearCoat.serialize();
  53173. return serializationObject;
  53174. };
  53175. // Statics
  53176. /**
  53177. * Parses a PBR Material from a serialized object.
  53178. * @param source - Serialized object.
  53179. * @param scene - BJS scene instance.
  53180. * @param rootUrl - url for the scene object
  53181. * @returns - PBRMaterial
  53182. */
  53183. PBRMaterial.Parse = function (source, scene, rootUrl) {
  53184. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMaterial(source.name, scene); }, source, scene, rootUrl);
  53185. if (source.clearCoat) {
  53186. material.clearCoat.parse(source.clearCoat);
  53187. }
  53188. return material;
  53189. };
  53190. /**
  53191. * PBRMaterialTransparencyMode: No transparency mode, Alpha channel is not use.
  53192. */
  53193. PBRMaterial.PBRMATERIAL_OPAQUE = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_OPAQUE;
  53194. /**
  53195. * PBRMaterialTransparencyMode: Alpha Test mode, pixel are discarded below a certain threshold defined by the alpha cutoff value.
  53196. */
  53197. PBRMaterial.PBRMATERIAL_ALPHATEST = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATEST;
  53198. /**
  53199. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53200. */
  53201. PBRMaterial.PBRMATERIAL_ALPHABLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHABLEND;
  53202. /**
  53203. * PBRMaterialTransparencyMode: Pixels are blended (according to the alpha mode) with the already drawn pixels in the current frame buffer.
  53204. * They are also discarded below the alpha cutoff threshold to improve performances.
  53205. */
  53206. PBRMaterial.PBRMATERIAL_ALPHATESTANDBLEND = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].PBRMATERIAL_ALPHATESTANDBLEND;
  53207. /**
  53208. * Defines the default value of how much AO map is occluding the analytical lights
  53209. * (point spot...).
  53210. */
  53211. PBRMaterial.DEFAULT_AO_ON_ANALYTICAL_LIGHTS = _pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"].DEFAULT_AO_ON_ANALYTICAL_LIGHTS;
  53212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53214. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53215. ], PBRMaterial.prototype, "directIntensity", void 0);
  53216. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53217. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53218. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53219. ], PBRMaterial.prototype, "emissiveIntensity", void 0);
  53220. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53221. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53223. ], PBRMaterial.prototype, "environmentIntensity", void 0);
  53224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53226. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53227. ], PBRMaterial.prototype, "specularIntensity", void 0);
  53228. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53229. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53230. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53231. ], PBRMaterial.prototype, "disableBumpMap", void 0);
  53232. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53233. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53235. ], PBRMaterial.prototype, "albedoTexture", void 0);
  53236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53238. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53239. ], PBRMaterial.prototype, "ambientTexture", void 0);
  53240. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53241. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53242. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53243. ], PBRMaterial.prototype, "ambientTextureStrength", void 0);
  53244. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53245. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53247. ], PBRMaterial.prototype, "ambientTextureImpactOnAnalyticalLights", void 0);
  53248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53250. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  53251. ], PBRMaterial.prototype, "opacityTexture", void 0);
  53252. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53253. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53254. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53255. ], PBRMaterial.prototype, "reflectionTexture", void 0);
  53256. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53257. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53259. ], PBRMaterial.prototype, "emissiveTexture", void 0);
  53260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53262. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53263. ], PBRMaterial.prototype, "reflectivityTexture", void 0);
  53264. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53265. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53266. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53267. ], PBRMaterial.prototype, "metallicTexture", void 0);
  53268. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53269. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53271. ], PBRMaterial.prototype, "metallic", void 0);
  53272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53274. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53275. ], PBRMaterial.prototype, "roughness", void 0);
  53276. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53277. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53278. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53279. ], PBRMaterial.prototype, "microSurfaceTexture", void 0);
  53280. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53281. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53283. ], PBRMaterial.prototype, "bumpTexture", void 0);
  53284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53286. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", null)
  53287. ], PBRMaterial.prototype, "lightmapTexture", void 0);
  53288. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53289. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53290. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53291. ], PBRMaterial.prototype, "refractionTexture", void 0);
  53292. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53293. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient"),
  53294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53295. ], PBRMaterial.prototype, "ambientColor", void 0);
  53296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("albedo"),
  53298. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53299. ], PBRMaterial.prototype, "albedoColor", void 0);
  53300. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53301. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflectivity"),
  53302. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53303. ], PBRMaterial.prototype, "reflectivityColor", void 0);
  53304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("reflection"),
  53306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53307. ], PBRMaterial.prototype, "reflectionColor", void 0);
  53308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive"),
  53310. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53311. ], PBRMaterial.prototype, "emissiveColor", void 0);
  53312. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53313. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53315. ], PBRMaterial.prototype, "microSurface", void 0);
  53316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53319. ], PBRMaterial.prototype, "indexOfRefraction", void 0);
  53320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53322. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53323. ], PBRMaterial.prototype, "invertRefractionY", void 0);
  53324. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53325. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53327. ], PBRMaterial.prototype, "linkRefractionWithTransparency", void 0);
  53328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53331. ], PBRMaterial.prototype, "useLightmapAsShadowmap", void 0);
  53332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53334. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  53335. ], PBRMaterial.prototype, "useAlphaFromAlbedoTexture", void 0);
  53336. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53337. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  53339. ], PBRMaterial.prototype, "forceAlphaTest", void 0);
  53340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  53343. ], PBRMaterial.prototype, "alphaCutOff", void 0);
  53344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53346. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53347. ], PBRMaterial.prototype, "useSpecularOverAlpha", void 0);
  53348. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53349. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53351. ], PBRMaterial.prototype, "useMicroSurfaceFromReflectivityMapAlpha", void 0);
  53352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53355. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureAlpha", void 0);
  53356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53358. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53359. ], PBRMaterial.prototype, "useRoughnessFromMetallicTextureGreen", void 0);
  53360. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53361. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53363. ], PBRMaterial.prototype, "useMetallnessFromMetallicTextureBlue", void 0);
  53364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53367. ], PBRMaterial.prototype, "useAmbientOcclusionFromMetallicTextureRed", void 0);
  53368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53370. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53371. ], PBRMaterial.prototype, "useAmbientInGrayScale", void 0);
  53372. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53373. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53375. ], PBRMaterial.prototype, "useAutoMicroSurfaceFromReflectivityMap", void 0);
  53376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53378. ], PBRMaterial.prototype, "usePhysicalLightFalloff", null);
  53379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  53381. ], PBRMaterial.prototype, "useGLTFLightFalloff", null);
  53382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53384. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53385. ], PBRMaterial.prototype, "useRadianceOverAlpha", void 0);
  53386. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53387. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53388. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53389. ], PBRMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  53390. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53391. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53393. ], PBRMaterial.prototype, "useParallax", void 0);
  53394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53396. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53397. ], PBRMaterial.prototype, "useParallaxOcclusion", void 0);
  53398. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53399. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53400. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53401. ], PBRMaterial.prototype, "parallaxScaleBias", void 0);
  53402. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53403. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53405. ], PBRMaterial.prototype, "disableLighting", void 0);
  53406. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53407. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53408. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53409. ], PBRMaterial.prototype, "forceIrradianceInFragment", void 0);
  53410. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53411. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53412. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  53413. ], PBRMaterial.prototype, "maxSimultaneousLights", void 0);
  53414. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53415. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53416. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53417. ], PBRMaterial.prototype, "invertNormalMapX", void 0);
  53418. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53419. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53420. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53421. ], PBRMaterial.prototype, "invertNormalMapY", void 0);
  53422. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53423. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53424. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53425. ], PBRMaterial.prototype, "twoSidedLighting", void 0);
  53426. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53427. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53429. ], PBRMaterial.prototype, "useAlphaFresnel", void 0);
  53430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53433. ], PBRMaterial.prototype, "useLinearAlphaFresnel", void 0);
  53434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53436. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53437. ], PBRMaterial.prototype, "environmentBRDFTexture", void 0);
  53438. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53439. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53441. ], PBRMaterial.prototype, "forceNormalForward", void 0);
  53442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53445. ], PBRMaterial.prototype, "enableSpecularAntiAliasing", void 0);
  53446. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53447. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53448. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53449. ], PBRMaterial.prototype, "useHorizonOcclusion", void 0);
  53450. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53451. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53453. ], PBRMaterial.prototype, "useRadianceOcclusion", void 0);
  53454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53456. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsMiscDirty")
  53457. ], PBRMaterial.prototype, "unlit", void 0);
  53458. return PBRMaterial;
  53459. }(_pbrBaseMaterial__WEBPACK_IMPORTED_MODULE_4__["PBRBaseMaterial"]));
  53460. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].RegisteredTypes["BABYLON.PBRMaterial"] = PBRMaterial;
  53461. /***/ }),
  53462. /***/ "./Materials/PBR/pbrMetallicRoughnessMaterial.ts":
  53463. /*!*******************************************************!*\
  53464. !*** ./Materials/PBR/pbrMetallicRoughnessMaterial.ts ***!
  53465. \*******************************************************/
  53466. /*! exports provided: PBRMetallicRoughnessMaterial */
  53467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53468. "use strict";
  53469. __webpack_require__.r(__webpack_exports__);
  53470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return PBRMetallicRoughnessMaterial; });
  53471. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53472. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53473. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53474. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53475. /**
  53476. * The PBR material of BJS following the metal roughness convention.
  53477. *
  53478. * This fits to the PBR convention in the GLTF definition:
  53479. * https://github.com/KhronosGroup/glTF/tree/2.0/specification/2.0
  53480. */
  53481. var PBRMetallicRoughnessMaterial = /** @class */ (function (_super) {
  53482. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRMetallicRoughnessMaterial, _super);
  53483. /**
  53484. * Instantiates a new PBRMetalRoughnessMaterial instance.
  53485. *
  53486. * @param name The material name
  53487. * @param scene The scene the material will be use in.
  53488. */
  53489. function PBRMetallicRoughnessMaterial(name, scene) {
  53490. var _this = _super.call(this, name, scene) || this;
  53491. _this._useRoughnessFromMetallicTextureAlpha = false;
  53492. _this._useRoughnessFromMetallicTextureGreen = true;
  53493. _this._useMetallnessFromMetallicTextureBlue = true;
  53494. _this.metallic = 1.0;
  53495. _this.roughness = 1.0;
  53496. return _this;
  53497. }
  53498. /**
  53499. * Return the currrent class name of the material.
  53500. */
  53501. PBRMetallicRoughnessMaterial.prototype.getClassName = function () {
  53502. return "PBRMetallicRoughnessMaterial";
  53503. };
  53504. /**
  53505. * Makes a duplicate of the current material.
  53506. * @param name - name to use for the new material.
  53507. */
  53508. PBRMetallicRoughnessMaterial.prototype.clone = function (name) {
  53509. var _this = this;
  53510. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRMetallicRoughnessMaterial(name, _this.getScene()); }, this);
  53511. clone.id = name;
  53512. clone.name = name;
  53513. this.clearCoat.copyTo(clone.clearCoat);
  53514. return clone;
  53515. };
  53516. /**
  53517. * Serialize the material to a parsable JSON object.
  53518. */
  53519. PBRMetallicRoughnessMaterial.prototype.serialize = function () {
  53520. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53521. serializationObject.customType = "BABYLON.PBRMetallicRoughnessMaterial";
  53522. serializationObject.clearCoat = this.clearCoat.serialize();
  53523. return serializationObject;
  53524. };
  53525. /**
  53526. * Parses a JSON object correponding to the serialize function.
  53527. */
  53528. PBRMetallicRoughnessMaterial.Parse = function (source, scene, rootUrl) {
  53529. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRMetallicRoughnessMaterial(source.name, scene); }, source, scene, rootUrl);
  53530. if (source.clearCoat) {
  53531. material.clearCoat.parse(source.clearCoat);
  53532. }
  53533. return material;
  53534. };
  53535. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53536. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])(),
  53537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53538. ], PBRMetallicRoughnessMaterial.prototype, "baseColor", void 0);
  53539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53541. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53542. ], PBRMetallicRoughnessMaterial.prototype, "baseTexture", void 0);
  53543. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53544. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53545. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53546. ], PBRMetallicRoughnessMaterial.prototype, "metallic", void 0);
  53547. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53548. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  53550. ], PBRMetallicRoughnessMaterial.prototype, "roughness", void 0);
  53551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53553. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_metallicTexture")
  53554. ], PBRMetallicRoughnessMaterial.prototype, "metallicRoughnessTexture", void 0);
  53555. return PBRMetallicRoughnessMaterial;
  53556. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53557. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRMetallicRoughnessMaterial"] = PBRMetallicRoughnessMaterial;
  53558. /***/ }),
  53559. /***/ "./Materials/PBR/pbrSpecularGlossinessMaterial.ts":
  53560. /*!********************************************************!*\
  53561. !*** ./Materials/PBR/pbrSpecularGlossinessMaterial.ts ***!
  53562. \********************************************************/
  53563. /*! exports provided: PBRSpecularGlossinessMaterial */
  53564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53565. "use strict";
  53566. __webpack_require__.r(__webpack_exports__);
  53567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return PBRSpecularGlossinessMaterial; });
  53568. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  53569. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  53570. /* harmony import */ var _pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./pbrBaseSimpleMaterial */ "./Materials/PBR/pbrBaseSimpleMaterial.ts");
  53571. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  53572. /**
  53573. * The PBR material of BJS following the specular glossiness convention.
  53574. *
  53575. * This fits to the PBR convention in the GLTF definition:
  53576. * https://github.com/KhronosGroup/glTF/tree/2.0/extensions/Khronos/KHR_materials_pbrSpecularGlossiness
  53577. */
  53578. var PBRSpecularGlossinessMaterial = /** @class */ (function (_super) {
  53579. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PBRSpecularGlossinessMaterial, _super);
  53580. /**
  53581. * Instantiates a new PBRSpecularGlossinessMaterial instance.
  53582. *
  53583. * @param name The material name
  53584. * @param scene The scene the material will be use in.
  53585. */
  53586. function PBRSpecularGlossinessMaterial(name, scene) {
  53587. var _this = _super.call(this, name, scene) || this;
  53588. _this._useMicroSurfaceFromReflectivityMapAlpha = true;
  53589. return _this;
  53590. }
  53591. /**
  53592. * Return the currrent class name of the material.
  53593. */
  53594. PBRSpecularGlossinessMaterial.prototype.getClassName = function () {
  53595. return "PBRSpecularGlossinessMaterial";
  53596. };
  53597. /**
  53598. * Makes a duplicate of the current material.
  53599. * @param name - name to use for the new material.
  53600. */
  53601. PBRSpecularGlossinessMaterial.prototype.clone = function (name) {
  53602. var _this = this;
  53603. var clone = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new PBRSpecularGlossinessMaterial(name, _this.getScene()); }, this);
  53604. clone.id = name;
  53605. clone.name = name;
  53606. this.clearCoat.copyTo(clone.clearCoat);
  53607. return clone;
  53608. };
  53609. /**
  53610. * Serialize the material to a parsable JSON object.
  53611. */
  53612. PBRSpecularGlossinessMaterial.prototype.serialize = function () {
  53613. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  53614. serializationObject.customType = "BABYLON.PBRSpecularGlossinessMaterial";
  53615. serializationObject.clearCoat = this.clearCoat.serialize();
  53616. return serializationObject;
  53617. };
  53618. /**
  53619. * Parses a JSON object correponding to the serialize function.
  53620. */
  53621. PBRSpecularGlossinessMaterial.Parse = function (source, scene, rootUrl) {
  53622. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new PBRSpecularGlossinessMaterial(source.name, scene); }, source, scene, rootUrl);
  53623. if (source.clearCoat) {
  53624. material.clearCoat.parse(source.clearCoat);
  53625. }
  53626. return material;
  53627. };
  53628. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53629. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse"),
  53630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoColor")
  53631. ], PBRSpecularGlossinessMaterial.prototype, "diffuseColor", void 0);
  53632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53634. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_albedoTexture")
  53635. ], PBRSpecularGlossinessMaterial.prototype, "diffuseTexture", void 0);
  53636. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53637. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular"),
  53638. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityColor")
  53639. ], PBRSpecularGlossinessMaterial.prototype, "specularColor", void 0);
  53640. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53641. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])(),
  53642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_microSurface")
  53643. ], PBRSpecularGlossinessMaterial.prototype, "glossiness", void 0);
  53644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  53645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])(),
  53646. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty", "_reflectivityTexture")
  53647. ], PBRSpecularGlossinessMaterial.prototype, "specularGlossinessTexture", void 0);
  53648. return PBRSpecularGlossinessMaterial;
  53649. }(_pbrBaseSimpleMaterial__WEBPACK_IMPORTED_MODULE_2__["PBRBaseSimpleMaterial"]));
  53650. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.PBRSpecularGlossinessMaterial"] = PBRSpecularGlossinessMaterial;
  53651. /***/ }),
  53652. /***/ "./Materials/Textures/Loaders/ddsTextureLoader.ts":
  53653. /*!********************************************************!*\
  53654. !*** ./Materials/Textures/Loaders/ddsTextureLoader.ts ***!
  53655. \********************************************************/
  53656. /*! exports provided: _DDSTextureLoader */
  53657. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53658. "use strict";
  53659. __webpack_require__.r(__webpack_exports__);
  53660. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _DDSTextureLoader; });
  53661. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  53662. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53663. /* harmony import */ var _Misc_dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/dds */ "./Misc/dds.ts");
  53664. /**
  53665. * Implementation of the DDS Texture Loader.
  53666. * @hidden
  53667. */
  53668. var _DDSTextureLoader = /** @class */ (function () {
  53669. function _DDSTextureLoader() {
  53670. /**
  53671. * Defines wether the loader supports cascade loading the different faces.
  53672. */
  53673. this.supportCascades = true;
  53674. }
  53675. /**
  53676. * This returns if the loader support the current file information.
  53677. * @param extension defines the file extension of the file being loaded
  53678. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53679. * @param fallback defines the fallback internal texture if any
  53680. * @param isBase64 defines whether the texture is encoded as a base64
  53681. * @param isBuffer defines whether the texture data are stored as a buffer
  53682. * @returns true if the loader can load the specified file
  53683. */
  53684. _DDSTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53685. return extension.indexOf(".dds") === 0;
  53686. };
  53687. /**
  53688. * Transform the url before loading if required.
  53689. * @param rootUrl the url of the texture
  53690. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53691. * @returns the transformed texture
  53692. */
  53693. _DDSTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53694. return rootUrl;
  53695. };
  53696. /**
  53697. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53698. * @param rootUrl the url of the texture
  53699. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53700. * @returns the fallback texture
  53701. */
  53702. _DDSTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53703. return null;
  53704. };
  53705. /**
  53706. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53707. * @param data contains the texture data
  53708. * @param texture defines the BabylonJS internal texture
  53709. * @param createPolynomials will be true if polynomials have been requested
  53710. * @param onLoad defines the callback to trigger once the texture is ready
  53711. * @param onError defines the callback to trigger in case of error
  53712. */
  53713. _DDSTextureLoader.prototype.loadCubeData = function (imgs, texture, createPolynomials, onLoad, onError) {
  53714. var engine = texture.getEngine();
  53715. var info;
  53716. var loadMipmap = false;
  53717. if (Array.isArray(imgs)) {
  53718. for (var index = 0; index < imgs.length; index++) {
  53719. var data_1 = imgs[index];
  53720. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data_1);
  53721. texture.width = info.width;
  53722. texture.height = info.height;
  53723. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53724. engine._unpackFlipY(info.isCompressed);
  53725. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data_1, info, loadMipmap, 6, -1, index);
  53726. if (!info.isFourCC && info.mipmapCount === 1) {
  53727. engine.generateMipMapsForCubemap(texture);
  53728. }
  53729. }
  53730. }
  53731. else {
  53732. var data = imgs;
  53733. info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53734. texture.width = info.width;
  53735. texture.height = info.height;
  53736. if (createPolynomials) {
  53737. info.sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["SphericalPolynomial"]();
  53738. }
  53739. loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps;
  53740. engine._unpackFlipY(info.isCompressed);
  53741. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(engine, texture, data, info, loadMipmap, 6);
  53742. if (!info.isFourCC && info.mipmapCount === 1) {
  53743. engine.generateMipMapsForCubemap(texture);
  53744. }
  53745. }
  53746. engine._setCubeMapTextureParams(loadMipmap);
  53747. texture.isReady = true;
  53748. if (onLoad) {
  53749. onLoad({ isDDS: true, width: texture.width, info: info, data: imgs, texture: texture });
  53750. }
  53751. };
  53752. /**
  53753. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53754. * @param data contains the texture data
  53755. * @param texture defines the BabylonJS internal texture
  53756. * @param callback defines the method to call once ready to upload
  53757. */
  53758. _DDSTextureLoader.prototype.loadData = function (data, texture, callback) {
  53759. var info = _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].GetDDSInfo(data);
  53760. var loadMipmap = (info.isRGB || info.isLuminance || info.mipmapCount > 1) && texture.generateMipMaps && ((info.width >> (info.mipmapCount - 1)) === 1);
  53761. callback(info.width, info.height, loadMipmap, info.isFourCC, function () {
  53762. _Misc_dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"].UploadDDSLevels(texture.getEngine(), texture, data, info, loadMipmap, 1);
  53763. });
  53764. };
  53765. return _DDSTextureLoader;
  53766. }());
  53767. // Register the loader.
  53768. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _DDSTextureLoader());
  53769. /***/ }),
  53770. /***/ "./Materials/Textures/Loaders/envTextureLoader.ts":
  53771. /*!********************************************************!*\
  53772. !*** ./Materials/Textures/Loaders/envTextureLoader.ts ***!
  53773. \********************************************************/
  53774. /*! exports provided: _ENVTextureLoader */
  53775. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53776. "use strict";
  53777. __webpack_require__.r(__webpack_exports__);
  53778. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _ENVTextureLoader; });
  53779. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  53780. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53781. /**
  53782. * Implementation of the ENV Texture Loader.
  53783. * @hidden
  53784. */
  53785. var _ENVTextureLoader = /** @class */ (function () {
  53786. function _ENVTextureLoader() {
  53787. /**
  53788. * Defines wether the loader supports cascade loading the different faces.
  53789. */
  53790. this.supportCascades = false;
  53791. }
  53792. /**
  53793. * This returns if the loader support the current file information.
  53794. * @param extension defines the file extension of the file being loaded
  53795. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53796. * @param fallback defines the fallback internal texture if any
  53797. * @param isBase64 defines whether the texture is encoded as a base64
  53798. * @param isBuffer defines whether the texture data are stored as a buffer
  53799. * @returns true if the loader can load the specified file
  53800. */
  53801. _ENVTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53802. return extension.indexOf(".env") === 0;
  53803. };
  53804. /**
  53805. * Transform the url before loading if required.
  53806. * @param rootUrl the url of the texture
  53807. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53808. * @returns the transformed texture
  53809. */
  53810. _ENVTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53811. return rootUrl;
  53812. };
  53813. /**
  53814. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53815. * @param rootUrl the url of the texture
  53816. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53817. * @returns the fallback texture
  53818. */
  53819. _ENVTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53820. return null;
  53821. };
  53822. /**
  53823. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53824. * @param data contains the texture data
  53825. * @param texture defines the BabylonJS internal texture
  53826. * @param createPolynomials will be true if polynomials have been requested
  53827. * @param onLoad defines the callback to trigger once the texture is ready
  53828. * @param onError defines the callback to trigger in case of error
  53829. */
  53830. _ENVTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53831. if (Array.isArray(data)) {
  53832. return;
  53833. }
  53834. data = data;
  53835. var info = _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].GetEnvInfo(data);
  53836. if (info) {
  53837. texture.width = info.width;
  53838. texture.height = info.width;
  53839. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvSpherical(texture, info);
  53840. _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_0__["EnvironmentTextureTools"].UploadEnvLevelsAsync(texture, data, info).then(function () {
  53841. texture.isReady = true;
  53842. if (onLoad) {
  53843. onLoad();
  53844. }
  53845. });
  53846. }
  53847. else if (onError) {
  53848. onError("Can not parse the environment file", null);
  53849. }
  53850. };
  53851. /**
  53852. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53853. * @param data contains the texture data
  53854. * @param texture defines the BabylonJS internal texture
  53855. * @param callback defines the method to call once ready to upload
  53856. */
  53857. _ENVTextureLoader.prototype.loadData = function (data, texture, callback) {
  53858. throw ".env not supported in 2d.";
  53859. };
  53860. return _ENVTextureLoader;
  53861. }());
  53862. // Register the loader.
  53863. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _ENVTextureLoader());
  53864. /***/ }),
  53865. /***/ "./Materials/Textures/Loaders/index.ts":
  53866. /*!*********************************************!*\
  53867. !*** ./Materials/Textures/Loaders/index.ts ***!
  53868. \*********************************************/
  53869. /*! exports provided: _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader */
  53870. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53871. "use strict";
  53872. __webpack_require__.r(__webpack_exports__);
  53873. /* harmony import */ var _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ddsTextureLoader */ "./Materials/Textures/Loaders/ddsTextureLoader.ts");
  53874. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _ddsTextureLoader__WEBPACK_IMPORTED_MODULE_0__["_DDSTextureLoader"]; });
  53875. /* harmony import */ var _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./envTextureLoader */ "./Materials/Textures/Loaders/envTextureLoader.ts");
  53876. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _envTextureLoader__WEBPACK_IMPORTED_MODULE_1__["_ENVTextureLoader"]; });
  53877. /* harmony import */ var _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ktxTextureLoader */ "./Materials/Textures/Loaders/ktxTextureLoader.ts");
  53878. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _ktxTextureLoader__WEBPACK_IMPORTED_MODULE_2__["_KTXTextureLoader"]; });
  53879. /* harmony import */ var _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./tgaTextureLoader */ "./Materials/Textures/Loaders/tgaTextureLoader.ts");
  53880. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _tgaTextureLoader__WEBPACK_IMPORTED_MODULE_3__["_TGATextureLoader"]; });
  53881. /***/ }),
  53882. /***/ "./Materials/Textures/Loaders/ktxTextureLoader.ts":
  53883. /*!********************************************************!*\
  53884. !*** ./Materials/Textures/Loaders/ktxTextureLoader.ts ***!
  53885. \********************************************************/
  53886. /*! exports provided: _KTXTextureLoader */
  53887. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53888. "use strict";
  53889. __webpack_require__.r(__webpack_exports__);
  53890. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _KTXTextureLoader; });
  53891. /* harmony import */ var _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  53892. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53893. /**
  53894. * Implementation of the KTX Texture Loader.
  53895. * @hidden
  53896. */
  53897. var _KTXTextureLoader = /** @class */ (function () {
  53898. function _KTXTextureLoader() {
  53899. /**
  53900. * Defines wether the loader supports cascade loading the different faces.
  53901. */
  53902. this.supportCascades = false;
  53903. }
  53904. /**
  53905. * This returns if the loader support the current file information.
  53906. * @param extension defines the file extension of the file being loaded
  53907. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53908. * @param fallback defines the fallback internal texture if any
  53909. * @param isBase64 defines whether the texture is encoded as a base64
  53910. * @param isBuffer defines whether the texture data are stored as a buffer
  53911. * @returns true if the loader can load the specified file
  53912. */
  53913. _KTXTextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  53914. if (textureFormatInUse && !isBase64 && !fallback && !isBuffer) {
  53915. return true;
  53916. }
  53917. return false;
  53918. };
  53919. /**
  53920. * Transform the url before loading if required.
  53921. * @param rootUrl the url of the texture
  53922. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53923. * @returns the transformed texture
  53924. */
  53925. _KTXTextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  53926. var lastDot = rootUrl.lastIndexOf('.');
  53927. if (lastDot != -1 && rootUrl.substring(lastDot + 1) == "ktx") {
  53928. // Already transformed
  53929. return rootUrl;
  53930. }
  53931. return (lastDot > -1 ? rootUrl.substring(0, lastDot) : rootUrl) + textureFormatInUse;
  53932. };
  53933. /**
  53934. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  53935. * @param rootUrl the url of the texture
  53936. * @param textureFormatInUse defines the current compressed format in use iun the engine
  53937. * @returns the fallback texture
  53938. */
  53939. _KTXTextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  53940. // remove the format appended to the rootUrl in the original createCubeTexture call.
  53941. var exp = new RegExp("" + textureFormatInUse + "$");
  53942. return rootUrl.replace(exp, "");
  53943. };
  53944. /**
  53945. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  53946. * @param data contains the texture data
  53947. * @param texture defines the BabylonJS internal texture
  53948. * @param createPolynomials will be true if polynomials have been requested
  53949. * @param onLoad defines the callback to trigger once the texture is ready
  53950. * @param onError defines the callback to trigger in case of error
  53951. */
  53952. _KTXTextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  53953. if (Array.isArray(data)) {
  53954. return;
  53955. }
  53956. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53957. texture._invertVScale = !texture.invertY;
  53958. var engine = texture.getEngine();
  53959. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 6);
  53960. var loadMipmap = ktx.numberOfMipmapLevels > 1 && texture.generateMipMaps;
  53961. engine._unpackFlipY(true);
  53962. ktx.uploadLevels(texture, texture.generateMipMaps);
  53963. texture.width = ktx.pixelWidth;
  53964. texture.height = ktx.pixelHeight;
  53965. engine._setCubeMapTextureParams(loadMipmap);
  53966. texture.isReady = true;
  53967. };
  53968. /**
  53969. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  53970. * @param data contains the texture data
  53971. * @param texture defines the BabylonJS internal texture
  53972. * @param callback defines the method to call once ready to upload
  53973. */
  53974. _KTXTextureLoader.prototype.loadData = function (data, texture, callback) {
  53975. // Need to invert vScale as invertY via UNPACK_FLIP_Y_WEBGL is not supported by compressed texture
  53976. texture._invertVScale = !texture.invertY;
  53977. var ktx = new _Misc_khronosTextureContainer__WEBPACK_IMPORTED_MODULE_0__["KhronosTextureContainer"](data, 1);
  53978. callback(ktx.pixelWidth, ktx.pixelHeight, false, true, function () {
  53979. ktx.uploadLevels(texture, texture.generateMipMaps);
  53980. }, ktx.isInvalid);
  53981. };
  53982. return _KTXTextureLoader;
  53983. }());
  53984. // Register the loader.
  53985. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.unshift(new _KTXTextureLoader());
  53986. /***/ }),
  53987. /***/ "./Materials/Textures/Loaders/tgaTextureLoader.ts":
  53988. /*!********************************************************!*\
  53989. !*** ./Materials/Textures/Loaders/tgaTextureLoader.ts ***!
  53990. \********************************************************/
  53991. /*! exports provided: _TGATextureLoader */
  53992. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  53993. "use strict";
  53994. __webpack_require__.r(__webpack_exports__);
  53995. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _TGATextureLoader; });
  53996. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tga */ "./Misc/tga.ts");
  53997. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engine */ "./Engines/engine.ts");
  53998. /**
  53999. * Implementation of the TGA Texture Loader.
  54000. * @hidden
  54001. */
  54002. var _TGATextureLoader = /** @class */ (function () {
  54003. function _TGATextureLoader() {
  54004. /**
  54005. * Defines wether the loader supports cascade loading the different faces.
  54006. */
  54007. this.supportCascades = false;
  54008. }
  54009. /**
  54010. * This returns if the loader support the current file information.
  54011. * @param extension defines the file extension of the file being loaded
  54012. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54013. * @param fallback defines the fallback internal texture if any
  54014. * @param isBase64 defines whether the texture is encoded as a base64
  54015. * @param isBuffer defines whether the texture data are stored as a buffer
  54016. * @returns true if the loader can load the specified file
  54017. */
  54018. _TGATextureLoader.prototype.canLoad = function (extension, textureFormatInUse, fallback, isBase64, isBuffer) {
  54019. return extension.indexOf(".tga") === 0;
  54020. };
  54021. /**
  54022. * Transform the url before loading if required.
  54023. * @param rootUrl the url of the texture
  54024. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54025. * @returns the transformed texture
  54026. */
  54027. _TGATextureLoader.prototype.transformUrl = function (rootUrl, textureFormatInUse) {
  54028. return rootUrl;
  54029. };
  54030. /**
  54031. * Gets the fallback url in case the load fail. This can return null to allow the default fallback mecanism to work
  54032. * @param rootUrl the url of the texture
  54033. * @param textureFormatInUse defines the current compressed format in use iun the engine
  54034. * @returns the fallback texture
  54035. */
  54036. _TGATextureLoader.prototype.getFallbackTextureUrl = function (rootUrl, textureFormatInUse) {
  54037. return null;
  54038. };
  54039. /**
  54040. * Uploads the cube texture data to the WebGl Texture. It has alreday been bound.
  54041. * @param data contains the texture data
  54042. * @param texture defines the BabylonJS internal texture
  54043. * @param createPolynomials will be true if polynomials have been requested
  54044. * @param onLoad defines the callback to trigger once the texture is ready
  54045. * @param onError defines the callback to trigger in case of error
  54046. */
  54047. _TGATextureLoader.prototype.loadCubeData = function (data, texture, createPolynomials, onLoad, onError) {
  54048. throw ".env not supported in Cube.";
  54049. };
  54050. /**
  54051. * Uploads the 2D texture data to the WebGl Texture. It has alreday been bound once in the callback.
  54052. * @param data contains the texture data
  54053. * @param texture defines the BabylonJS internal texture
  54054. * @param callback defines the method to call once ready to upload
  54055. */
  54056. _TGATextureLoader.prototype.loadData = function (data, texture, callback) {
  54057. var uintData = new Uint8Array(data);
  54058. var header = _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].GetTGAHeader(uintData);
  54059. callback(header.width, header.height, texture.generateMipMaps, false, function () {
  54060. _Misc_tga__WEBPACK_IMPORTED_MODULE_0__["TGATools"].UploadContent(texture, uintData);
  54061. });
  54062. };
  54063. return _TGATextureLoader;
  54064. }());
  54065. // Register the loader.
  54066. _Engines_engine__WEBPACK_IMPORTED_MODULE_1__["Engine"]._TextureLoaders.push(new _TGATextureLoader());
  54067. /***/ }),
  54068. /***/ "./Materials/Textures/Procedurals/customProceduralTexture.ts":
  54069. /*!*******************************************************************!*\
  54070. !*** ./Materials/Textures/Procedurals/customProceduralTexture.ts ***!
  54071. \*******************************************************************/
  54072. /*! exports provided: CustomProceduralTexture */
  54073. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54074. "use strict";
  54075. __webpack_require__.r(__webpack_exports__);
  54076. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return CustomProceduralTexture; });
  54077. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54078. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54079. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  54080. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  54081. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54082. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  54083. /**
  54084. * 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.
  54085. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54086. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54087. */
  54088. var CustomProceduralTexture = /** @class */ (function (_super) {
  54089. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomProceduralTexture, _super);
  54090. /**
  54091. * Instantiates a new Custom Procedural Texture.
  54092. * 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.
  54093. * Custom Procedural textures are the easiest way to create your own procedural in your application.
  54094. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures#creating-custom-procedural-textures
  54095. * @param name Define the name of the texture
  54096. * @param texturePath Define the folder path containing all the cutom texture related files (config, shaders...)
  54097. * @param size Define the size of the texture to create
  54098. * @param scene Define the scene the texture belongs to
  54099. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54100. * @param generateMipMaps Define if the texture should creates mip maps or not
  54101. */
  54102. function CustomProceduralTexture(name, texturePath, size, scene, fallbackTexture, generateMipMaps) {
  54103. var _this = _super.call(this, name, size, null, scene, fallbackTexture, generateMipMaps) || this;
  54104. _this._animate = true;
  54105. _this._time = 0;
  54106. _this._texturePath = texturePath;
  54107. //Try to load json
  54108. _this._loadJson(texturePath);
  54109. _this.refreshRate = 1;
  54110. return _this;
  54111. }
  54112. CustomProceduralTexture.prototype._loadJson = function (jsonUrl) {
  54113. var _this = this;
  54114. var noConfigFile = function () {
  54115. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Log("No config file found in " + jsonUrl + " trying to use ShadersStore or DOM element");
  54116. try {
  54117. _this.setFragment(_this._texturePath);
  54118. }
  54119. catch (ex) {
  54120. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("No json or ShaderStore or DOM element found for CustomProceduralTexture");
  54121. }
  54122. };
  54123. var configFileUrl = jsonUrl + "/config.json";
  54124. var xhr = new XMLHttpRequest();
  54125. xhr.open("GET", configFileUrl, true);
  54126. xhr.addEventListener("load", function () {
  54127. if (xhr.status === 200 || (xhr.responseText && xhr.responseText.length > 0)) {
  54128. try {
  54129. _this._config = JSON.parse(xhr.response);
  54130. _this.updateShaderUniforms();
  54131. _this.updateTextures();
  54132. _this.setFragment(_this._texturePath + "/custom");
  54133. _this._animate = _this._config.animate;
  54134. _this.refreshRate = _this._config.refreshrate;
  54135. }
  54136. catch (ex) {
  54137. noConfigFile();
  54138. }
  54139. }
  54140. else {
  54141. noConfigFile();
  54142. }
  54143. }, false);
  54144. xhr.addEventListener("error", function () {
  54145. noConfigFile();
  54146. }, false);
  54147. try {
  54148. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].UseCustomRequestHeaders) {
  54149. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].InjectCustomRequestHeaders(xhr);
  54150. }
  54151. xhr.send();
  54152. }
  54153. catch (ex) {
  54154. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Error("CustomProceduralTexture: Error on XHR send request.");
  54155. }
  54156. };
  54157. /**
  54158. * Is the texture ready to be used ? (rendered at least once)
  54159. * @returns true if ready, otherwise, false.
  54160. */
  54161. CustomProceduralTexture.prototype.isReady = function () {
  54162. if (!_super.prototype.isReady.call(this)) {
  54163. return false;
  54164. }
  54165. for (var name in this._textures) {
  54166. var texture = this._textures[name];
  54167. if (!texture.isReady()) {
  54168. return false;
  54169. }
  54170. }
  54171. return true;
  54172. };
  54173. /**
  54174. * Render the texture to its associated render target.
  54175. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54176. */
  54177. CustomProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54178. var scene = this.getScene();
  54179. if (this._animate && scene) {
  54180. this._time += scene.getAnimationRatio() * 0.03;
  54181. this.updateShaderUniforms();
  54182. }
  54183. _super.prototype.render.call(this, useCameraPostProcess);
  54184. };
  54185. /**
  54186. * Update the list of dependant textures samplers in the shader.
  54187. */
  54188. CustomProceduralTexture.prototype.updateTextures = function () {
  54189. for (var i = 0; i < this._config.sampler2Ds.length; i++) {
  54190. this.setTexture(this._config.sampler2Ds[i].sample2Dname, new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this._texturePath + "/" + this._config.sampler2Ds[i].textureRelativeUrl, this.getScene()));
  54191. }
  54192. };
  54193. /**
  54194. * Update the uniform values of the procedural texture in the shader.
  54195. */
  54196. CustomProceduralTexture.prototype.updateShaderUniforms = function () {
  54197. if (this._config) {
  54198. for (var j = 0; j < this._config.uniforms.length; j++) {
  54199. var uniform = this._config.uniforms[j];
  54200. switch (uniform.type) {
  54201. case "float":
  54202. this.setFloat(uniform.name, uniform.value);
  54203. break;
  54204. case "color3":
  54205. this.setColor3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](uniform.r, uniform.g, uniform.b));
  54206. break;
  54207. case "color4":
  54208. this.setColor4(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](uniform.r, uniform.g, uniform.b, uniform.a));
  54209. break;
  54210. case "vector2":
  54211. this.setVector2(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](uniform.x, uniform.y));
  54212. break;
  54213. case "vector3":
  54214. this.setVector3(uniform.name, new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](uniform.x, uniform.y, uniform.z));
  54215. break;
  54216. }
  54217. }
  54218. }
  54219. this.setFloat("time", this._time);
  54220. };
  54221. Object.defineProperty(CustomProceduralTexture.prototype, "animate", {
  54222. /**
  54223. * Define if the texture animates or not.
  54224. */
  54225. get: function () {
  54226. return this._animate;
  54227. },
  54228. set: function (value) {
  54229. this._animate = value;
  54230. },
  54231. enumerable: true,
  54232. configurable: true
  54233. });
  54234. return CustomProceduralTexture;
  54235. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_5__["ProceduralTexture"]));
  54236. /***/ }),
  54237. /***/ "./Materials/Textures/Procedurals/index.ts":
  54238. /*!*************************************************!*\
  54239. !*** ./Materials/Textures/Procedurals/index.ts ***!
  54240. \*************************************************/
  54241. /*! exports provided: ProceduralTexture, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  54242. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54243. "use strict";
  54244. __webpack_require__.r(__webpack_exports__);
  54245. /* harmony import */ var _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./customProceduralTexture */ "./Materials/Textures/Procedurals/customProceduralTexture.ts");
  54246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _customProceduralTexture__WEBPACK_IMPORTED_MODULE_0__["CustomProceduralTexture"]; });
  54247. /* harmony import */ var _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./noiseProceduralTexture */ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts");
  54248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _noiseProceduralTexture__WEBPACK_IMPORTED_MODULE_1__["NoiseProceduralTexture"]; });
  54249. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  54250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]; });
  54251. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  54252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_3__["ProceduralTextureSceneComponent"]; });
  54253. /***/ }),
  54254. /***/ "./Materials/Textures/Procedurals/noiseProceduralTexture.ts":
  54255. /*!******************************************************************!*\
  54256. !*** ./Materials/Textures/Procedurals/noiseProceduralTexture.ts ***!
  54257. \******************************************************************/
  54258. /*! exports provided: NoiseProceduralTexture */
  54259. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54260. "use strict";
  54261. __webpack_require__.r(__webpack_exports__);
  54262. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return NoiseProceduralTexture; });
  54263. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54264. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  54265. /* harmony import */ var _proceduralTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  54266. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  54267. /* harmony import */ var _Shaders_noise_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Shaders/noise.fragment */ "./Shaders/noise.fragment.ts");
  54268. /**
  54269. * Class used to generate noise procedural textures
  54270. */
  54271. var NoiseProceduralTexture = /** @class */ (function (_super) {
  54272. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](NoiseProceduralTexture, _super);
  54273. /**
  54274. * Creates a new NoiseProceduralTexture
  54275. * @param name defines the name fo the texture
  54276. * @param size defines the size of the texture (default is 256)
  54277. * @param scene defines the hosting scene
  54278. * @param fallbackTexture defines the texture to use if the NoiseProceduralTexture can't be created
  54279. * @param generateMipMaps defines if mipmaps must be generated (true by default)
  54280. */
  54281. function NoiseProceduralTexture(name, size, scene, fallbackTexture, generateMipMaps) {
  54282. if (size === void 0) { size = 256; }
  54283. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene; }
  54284. var _this = _super.call(this, name, size, "noise", scene, fallbackTexture, generateMipMaps) || this;
  54285. _this._time = 0;
  54286. /** Gets or sets a value between 0 and 1 indicating the overall brightness of the texture (default is 0.2) */
  54287. _this.brightness = 0.2;
  54288. /** Defines the number of octaves to process */
  54289. _this.octaves = 3;
  54290. /** Defines the level of persistence (0.8 by default) */
  54291. _this.persistence = 0.8;
  54292. /** Gets or sets animation speed factor (default is 1) */
  54293. _this.animationSpeedFactor = 1;
  54294. _this.autoClear = false;
  54295. _this._updateShaderUniforms();
  54296. return _this;
  54297. }
  54298. NoiseProceduralTexture.prototype._updateShaderUniforms = function () {
  54299. var scene = this.getScene();
  54300. if (!scene) {
  54301. return;
  54302. }
  54303. this._time += scene.getAnimationRatio() * this.animationSpeedFactor * 0.01;
  54304. this.setFloat("brightness", this.brightness);
  54305. this.setFloat("persistence", this.persistence);
  54306. this.setFloat("timeScale", this._time);
  54307. };
  54308. NoiseProceduralTexture.prototype._getDefines = function () {
  54309. return "#define OCTAVES " + (this.octaves | 0);
  54310. };
  54311. /** Generate the current state of the procedural texture */
  54312. NoiseProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54313. this._updateShaderUniforms();
  54314. _super.prototype.render.call(this, useCameraPostProcess);
  54315. };
  54316. /**
  54317. * Serializes this noise procedural texture
  54318. * @returns a serialized noise procedural texture object
  54319. */
  54320. NoiseProceduralTexture.prototype.serialize = function () {
  54321. var serializationObject = {};
  54322. serializationObject.customType = "BABYLON.NoiseProceduralTexture";
  54323. serializationObject.brightness = this.brightness;
  54324. serializationObject.octaves = this.octaves;
  54325. serializationObject.persistence = this.persistence;
  54326. serializationObject.animationSpeedFactor = this.animationSpeedFactor;
  54327. serializationObject.size = this.getSize().width;
  54328. serializationObject.generateMipMaps = this._generateMipMaps;
  54329. return serializationObject;
  54330. };
  54331. /**
  54332. * Creates a NoiseProceduralTexture from parsed noise procedural texture data
  54333. * @param parsedTexture defines parsed texture data
  54334. * @param scene defines the current scene
  54335. * @param rootUrl defines the root URL containing noise procedural texture information
  54336. * @returns a parsed NoiseProceduralTexture
  54337. */
  54338. NoiseProceduralTexture.Parse = function (parsedTexture, scene) {
  54339. var texture = new NoiseProceduralTexture(parsedTexture.name, parsedTexture.size, scene, undefined, parsedTexture.generateMipMaps);
  54340. texture.brightness = parsedTexture.brightness;
  54341. texture.octaves = parsedTexture.octaves;
  54342. texture.persistence = parsedTexture.persistence;
  54343. texture.animationSpeedFactor = parsedTexture.animationSpeedFactor;
  54344. return texture;
  54345. };
  54346. return NoiseProceduralTexture;
  54347. }(_proceduralTexture__WEBPACK_IMPORTED_MODULE_2__["ProceduralTexture"]));
  54348. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.NoiseProceduralTexture"] = NoiseProceduralTexture;
  54349. /***/ }),
  54350. /***/ "./Materials/Textures/Procedurals/proceduralTexture.ts":
  54351. /*!*************************************************************!*\
  54352. !*** ./Materials/Textures/Procedurals/proceduralTexture.ts ***!
  54353. \*************************************************************/
  54354. /*! exports provided: ProceduralTexture */
  54355. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54356. "use strict";
  54357. __webpack_require__.r(__webpack_exports__);
  54358. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return ProceduralTexture; });
  54359. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54360. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  54361. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/observable */ "./Misc/observable.ts");
  54362. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Meshes/buffer */ "./Meshes/buffer.ts");
  54363. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54364. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/material */ "./Materials/material.ts");
  54365. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  54366. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  54367. /* harmony import */ var _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./proceduralTextureSceneComponent */ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts");
  54368. /* harmony import */ var _Shaders_procedural_vertex__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Shaders/procedural.vertex */ "./Shaders/procedural.vertex.ts");
  54369. /**
  54370. * 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.
  54371. * This is the base class of any Procedural texture and contains most of the shareable code.
  54372. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  54373. */
  54374. var ProceduralTexture = /** @class */ (function (_super) {
  54375. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ProceduralTexture, _super);
  54376. /**
  54377. * Instantiates a new procedural texture.
  54378. * 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.
  54379. * This is the base class of any Procedural texture and contains most of the shareable code.
  54380. * @see http://doc.babylonjs.com/how_to/how_to_use_procedural_textures
  54381. * @param name Define the name of the texture
  54382. * @param size Define the size of the texture to create
  54383. * @param fragment Define the fragment shader to use to generate the texture or null if it is defined later
  54384. * @param scene Define the scene the texture belongs to
  54385. * @param fallbackTexture Define a fallback texture in case there were issues to create the custom texture
  54386. * @param generateMipMaps Define if the texture should creates mip maps or not
  54387. * @param isCube Define if the texture is a cube texture or not (this will render each faces of the cube)
  54388. */
  54389. function ProceduralTexture(name, size, fragment, scene, fallbackTexture, generateMipMaps, isCube) {
  54390. if (fallbackTexture === void 0) { fallbackTexture = null; }
  54391. if (generateMipMaps === void 0) { generateMipMaps = true; }
  54392. if (isCube === void 0) { isCube = false; }
  54393. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  54394. _this.isCube = isCube;
  54395. /**
  54396. * Define if the texture is enabled or not (disabled texture will not render)
  54397. */
  54398. _this.isEnabled = true;
  54399. /**
  54400. * Define if the texture must be cleared before rendering (default is true)
  54401. */
  54402. _this.autoClear = true;
  54403. /**
  54404. * Event raised when the texture is generated
  54405. */
  54406. _this.onGeneratedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  54407. /** @hidden */
  54408. _this._textures = {};
  54409. _this._currentRefreshId = -1;
  54410. _this._refreshRate = 1;
  54411. _this._vertexBuffers = {};
  54412. _this._uniforms = new Array();
  54413. _this._samplers = new Array();
  54414. _this._floats = {};
  54415. _this._ints = {};
  54416. _this._floatsArrays = {};
  54417. _this._colors3 = {};
  54418. _this._colors4 = {};
  54419. _this._vectors2 = {};
  54420. _this._vectors3 = {};
  54421. _this._matrices = {};
  54422. _this._fallbackTextureUsed = false;
  54423. _this._cachedDefines = "";
  54424. _this._contentUpdateId = -1;
  54425. scene = _this.getScene();
  54426. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE);
  54427. if (!component) {
  54428. component = new _proceduralTextureSceneComponent__WEBPACK_IMPORTED_MODULE_8__["ProceduralTextureSceneComponent"](scene);
  54429. scene._addComponent(component);
  54430. }
  54431. scene.proceduralTextures.push(_this);
  54432. _this._engine = scene.getEngine();
  54433. _this.name = name;
  54434. _this.isRenderTarget = true;
  54435. _this._size = size;
  54436. _this._generateMipMaps = generateMipMaps;
  54437. _this.setFragment(fragment);
  54438. _this._fallbackTexture = fallbackTexture;
  54439. if (isCube) {
  54440. _this._texture = _this._engine.createRenderTargetCubeTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54441. _this.setFloat("face", 0);
  54442. }
  54443. else {
  54444. _this._texture = _this._engine.createRenderTargetTexture(size, { generateMipMaps: generateMipMaps, generateDepthBuffer: false, generateStencilBuffer: false });
  54445. }
  54446. // VBO
  54447. var vertices = [];
  54448. vertices.push(1, 1);
  54449. vertices.push(-1, 1);
  54450. vertices.push(-1, -1);
  54451. vertices.push(1, -1);
  54452. _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);
  54453. _this._createIndexBuffer();
  54454. return _this;
  54455. }
  54456. /**
  54457. * The effect that is created when initializing the post process.
  54458. * @returns The created effect corrisponding the the postprocess.
  54459. */
  54460. ProceduralTexture.prototype.getEffect = function () {
  54461. return this._effect;
  54462. };
  54463. /**
  54464. * Gets texture content (Use this function wisely as reading from a texture can be slow)
  54465. * @returns an ArrayBufferView (Uint8Array or Float32Array)
  54466. */
  54467. ProceduralTexture.prototype.getContent = function () {
  54468. if (this._contentData && this._currentRefreshId == this._contentUpdateId) {
  54469. return this._contentData;
  54470. }
  54471. this._contentData = this.readPixels(0, 0, this._contentData);
  54472. this._contentUpdateId = this._currentRefreshId;
  54473. return this._contentData;
  54474. };
  54475. ProceduralTexture.prototype._createIndexBuffer = function () {
  54476. var engine = this._engine;
  54477. // Indices
  54478. var indices = [];
  54479. indices.push(0);
  54480. indices.push(1);
  54481. indices.push(2);
  54482. indices.push(0);
  54483. indices.push(2);
  54484. indices.push(3);
  54485. this._indexBuffer = engine.createIndexBuffer(indices);
  54486. };
  54487. /** @hidden */
  54488. ProceduralTexture.prototype._rebuild = function () {
  54489. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54490. if (vb) {
  54491. vb._rebuild();
  54492. }
  54493. this._createIndexBuffer();
  54494. if (this.refreshRate === _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE) {
  54495. this.refreshRate = _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_7__["RenderTargetTexture"].REFRESHRATE_RENDER_ONCE;
  54496. }
  54497. };
  54498. /**
  54499. * Resets the texture in order to recreate its associated resources.
  54500. * This can be called in case of context loss
  54501. */
  54502. ProceduralTexture.prototype.reset = function () {
  54503. if (this._effect === undefined) {
  54504. return;
  54505. }
  54506. var engine = this._engine;
  54507. engine._releaseEffect(this._effect);
  54508. };
  54509. ProceduralTexture.prototype._getDefines = function () {
  54510. return "";
  54511. };
  54512. /**
  54513. * Is the texture ready to be used ? (rendered at least once)
  54514. * @returns true if ready, otherwise, false.
  54515. */
  54516. ProceduralTexture.prototype.isReady = function () {
  54517. var _this = this;
  54518. var engine = this._engine;
  54519. var shaders;
  54520. if (!this._fragment) {
  54521. return false;
  54522. }
  54523. if (this._fallbackTextureUsed) {
  54524. return true;
  54525. }
  54526. var defines = this._getDefines();
  54527. if (this._effect && defines === this._cachedDefines && this._effect.isReady()) {
  54528. return true;
  54529. }
  54530. if (this._fragment.fragmentElement !== undefined) {
  54531. shaders = { vertex: "procedural", fragmentElement: this._fragment.fragmentElement };
  54532. }
  54533. else {
  54534. shaders = { vertex: "procedural", fragment: this._fragment };
  54535. }
  54536. this._cachedDefines = defines;
  54537. this._effect = engine.createEffect(shaders, [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind], this._uniforms, this._samplers, defines, undefined, undefined, function () {
  54538. _this.releaseInternalTexture();
  54539. if (_this._fallbackTexture) {
  54540. _this._texture = _this._fallbackTexture._texture;
  54541. if (_this._texture) {
  54542. _this._texture.incrementReferences();
  54543. }
  54544. }
  54545. _this._fallbackTextureUsed = true;
  54546. });
  54547. return this._effect.isReady();
  54548. };
  54549. /**
  54550. * Resets the refresh counter of the texture and start bak from scratch.
  54551. * Could be useful to regenerate the texture if it is setup to render only once.
  54552. */
  54553. ProceduralTexture.prototype.resetRefreshCounter = function () {
  54554. this._currentRefreshId = -1;
  54555. };
  54556. /**
  54557. * Set the fragment shader to use in order to render the texture.
  54558. * @param fragment This can be set to a path (into the shader store) or to a json object containing a fragmentElement property.
  54559. */
  54560. ProceduralTexture.prototype.setFragment = function (fragment) {
  54561. this._fragment = fragment;
  54562. };
  54563. Object.defineProperty(ProceduralTexture.prototype, "refreshRate", {
  54564. /**
  54565. * Define the refresh rate of the texture or the rendering frequency.
  54566. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  54567. */
  54568. get: function () {
  54569. return this._refreshRate;
  54570. },
  54571. set: function (value) {
  54572. this._refreshRate = value;
  54573. this.resetRefreshCounter();
  54574. },
  54575. enumerable: true,
  54576. configurable: true
  54577. });
  54578. /** @hidden */
  54579. ProceduralTexture.prototype._shouldRender = function () {
  54580. if (!this.isEnabled || !this.isReady() || !this._texture) {
  54581. if (this._texture) {
  54582. this._texture.isReady = false;
  54583. }
  54584. return false;
  54585. }
  54586. if (this._fallbackTextureUsed) {
  54587. return false;
  54588. }
  54589. if (this._currentRefreshId === -1) { // At least render once
  54590. this._currentRefreshId = 1;
  54591. return true;
  54592. }
  54593. if (this.refreshRate === this._currentRefreshId) {
  54594. this._currentRefreshId = 1;
  54595. return true;
  54596. }
  54597. this._currentRefreshId++;
  54598. return false;
  54599. };
  54600. /**
  54601. * Get the size the texture is rendering at.
  54602. * @returns the size (texture is always squared)
  54603. */
  54604. ProceduralTexture.prototype.getRenderSize = function () {
  54605. return this._size;
  54606. };
  54607. /**
  54608. * Resize the texture to new value.
  54609. * @param size Define the new size the texture should have
  54610. * @param generateMipMaps Define whether the new texture should create mip maps
  54611. */
  54612. ProceduralTexture.prototype.resize = function (size, generateMipMaps) {
  54613. if (this._fallbackTextureUsed) {
  54614. return;
  54615. }
  54616. this.releaseInternalTexture();
  54617. this._texture = this._engine.createRenderTargetTexture(size, generateMipMaps);
  54618. // Update properties
  54619. this._size = size;
  54620. this._generateMipMaps = generateMipMaps;
  54621. };
  54622. ProceduralTexture.prototype._checkUniform = function (uniformName) {
  54623. if (this._uniforms.indexOf(uniformName) === -1) {
  54624. this._uniforms.push(uniformName);
  54625. }
  54626. };
  54627. /**
  54628. * Set a texture in the shader program used to render.
  54629. * @param name Define the name of the uniform samplers as defined in the shader
  54630. * @param texture Define the texture to bind to this sampler
  54631. * @return the texture itself allowing "fluent" like uniform updates
  54632. */
  54633. ProceduralTexture.prototype.setTexture = function (name, texture) {
  54634. if (this._samplers.indexOf(name) === -1) {
  54635. this._samplers.push(name);
  54636. }
  54637. this._textures[name] = texture;
  54638. return this;
  54639. };
  54640. /**
  54641. * Set a float in the shader.
  54642. * @param name Define the name of the uniform as defined in the shader
  54643. * @param value Define the value to give to the uniform
  54644. * @return the texture itself allowing "fluent" like uniform updates
  54645. */
  54646. ProceduralTexture.prototype.setFloat = function (name, value) {
  54647. this._checkUniform(name);
  54648. this._floats[name] = value;
  54649. return this;
  54650. };
  54651. /**
  54652. * Set a int in the shader.
  54653. * @param name Define the name of the uniform as defined in the shader
  54654. * @param value Define the value to give to the uniform
  54655. * @return the texture itself allowing "fluent" like uniform updates
  54656. */
  54657. ProceduralTexture.prototype.setInt = function (name, value) {
  54658. this._checkUniform(name);
  54659. this._ints[name] = value;
  54660. return this;
  54661. };
  54662. /**
  54663. * Set an array of floats in the shader.
  54664. * @param name Define the name of the uniform as defined in the shader
  54665. * @param value Define the value to give to the uniform
  54666. * @return the texture itself allowing "fluent" like uniform updates
  54667. */
  54668. ProceduralTexture.prototype.setFloats = function (name, value) {
  54669. this._checkUniform(name);
  54670. this._floatsArrays[name] = value;
  54671. return this;
  54672. };
  54673. /**
  54674. * Set a vec3 in the shader from a Color3.
  54675. * @param name Define the name of the uniform as defined in the shader
  54676. * @param value Define the value to give to the uniform
  54677. * @return the texture itself allowing "fluent" like uniform updates
  54678. */
  54679. ProceduralTexture.prototype.setColor3 = function (name, value) {
  54680. this._checkUniform(name);
  54681. this._colors3[name] = value;
  54682. return this;
  54683. };
  54684. /**
  54685. * Set a vec4 in the shader from a Color4.
  54686. * @param name Define the name of the uniform as defined in the shader
  54687. * @param value Define the value to give to the uniform
  54688. * @return the texture itself allowing "fluent" like uniform updates
  54689. */
  54690. ProceduralTexture.prototype.setColor4 = function (name, value) {
  54691. this._checkUniform(name);
  54692. this._colors4[name] = value;
  54693. return this;
  54694. };
  54695. /**
  54696. * Set a vec2 in the shader from a Vector2.
  54697. * @param name Define the name of the uniform as defined in the shader
  54698. * @param value Define the value to give to the uniform
  54699. * @return the texture itself allowing "fluent" like uniform updates
  54700. */
  54701. ProceduralTexture.prototype.setVector2 = function (name, value) {
  54702. this._checkUniform(name);
  54703. this._vectors2[name] = value;
  54704. return this;
  54705. };
  54706. /**
  54707. * Set a vec3 in the shader from a Vector3.
  54708. * @param name Define the name of the uniform as defined in the shader
  54709. * @param value Define the value to give to the uniform
  54710. * @return the texture itself allowing "fluent" like uniform updates
  54711. */
  54712. ProceduralTexture.prototype.setVector3 = function (name, value) {
  54713. this._checkUniform(name);
  54714. this._vectors3[name] = value;
  54715. return this;
  54716. };
  54717. /**
  54718. * Set a mat4 in the shader from a MAtrix.
  54719. * @param name Define the name of the uniform as defined in the shader
  54720. * @param value Define the value to give to the uniform
  54721. * @return the texture itself allowing "fluent" like uniform updates
  54722. */
  54723. ProceduralTexture.prototype.setMatrix = function (name, value) {
  54724. this._checkUniform(name);
  54725. this._matrices[name] = value;
  54726. return this;
  54727. };
  54728. /**
  54729. * Render the texture to its associated render target.
  54730. * @param useCameraPostProcess Define if camera post process should be applied to the texture
  54731. */
  54732. ProceduralTexture.prototype.render = function (useCameraPostProcess) {
  54733. var scene = this.getScene();
  54734. if (!scene) {
  54735. return;
  54736. }
  54737. var engine = this._engine;
  54738. // Render
  54739. engine.enableEffect(this._effect);
  54740. engine.setState(false);
  54741. // Texture
  54742. for (var name in this._textures) {
  54743. this._effect.setTexture(name, this._textures[name]);
  54744. }
  54745. // Float
  54746. for (name in this._ints) {
  54747. this._effect.setInt(name, this._ints[name]);
  54748. }
  54749. // Float
  54750. for (name in this._floats) {
  54751. this._effect.setFloat(name, this._floats[name]);
  54752. }
  54753. // Floats
  54754. for (name in this._floatsArrays) {
  54755. this._effect.setArray(name, this._floatsArrays[name]);
  54756. }
  54757. // Color3
  54758. for (name in this._colors3) {
  54759. this._effect.setColor3(name, this._colors3[name]);
  54760. }
  54761. // Color4
  54762. for (name in this._colors4) {
  54763. var color = this._colors4[name];
  54764. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  54765. }
  54766. // Vector2
  54767. for (name in this._vectors2) {
  54768. this._effect.setVector2(name, this._vectors2[name]);
  54769. }
  54770. // Vector3
  54771. for (name in this._vectors3) {
  54772. this._effect.setVector3(name, this._vectors3[name]);
  54773. }
  54774. // Matrix
  54775. for (name in this._matrices) {
  54776. this._effect.setMatrix(name, this._matrices[name]);
  54777. }
  54778. if (!this._texture) {
  54779. return;
  54780. }
  54781. if (this.isCube) {
  54782. for (var face = 0; face < 6; face++) {
  54783. engine.bindFramebuffer(this._texture, face, undefined, undefined, true);
  54784. // VBOs
  54785. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54786. this._effect.setFloat("face", face);
  54787. // Clear
  54788. if (this.autoClear) {
  54789. engine.clear(scene.clearColor, true, false, false);
  54790. }
  54791. // Draw order
  54792. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54793. // Mipmaps
  54794. if (face === 5) {
  54795. engine.generateMipMapsForCubemap(this._texture);
  54796. }
  54797. }
  54798. }
  54799. else {
  54800. engine.bindFramebuffer(this._texture, 0, undefined, undefined, true);
  54801. // VBOs
  54802. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._effect);
  54803. // Clear
  54804. if (this.autoClear) {
  54805. engine.clear(scene.clearColor, true, false, false);
  54806. }
  54807. // Draw order
  54808. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, 6);
  54809. }
  54810. // Unbind
  54811. engine.unBindFramebuffer(this._texture, this.isCube);
  54812. if (this.onGenerated) {
  54813. this.onGenerated();
  54814. }
  54815. this.onGeneratedObservable.notifyObservers(this);
  54816. };
  54817. /**
  54818. * Clone the texture.
  54819. * @returns the cloned texture
  54820. */
  54821. ProceduralTexture.prototype.clone = function () {
  54822. var textureSize = this.getSize();
  54823. var newTexture = new ProceduralTexture(this.name, textureSize.width, this._fragment, this.getScene(), this._fallbackTexture, this._generateMipMaps);
  54824. // Base texture
  54825. newTexture.hasAlpha = this.hasAlpha;
  54826. newTexture.level = this.level;
  54827. // RenderTarget Texture
  54828. newTexture.coordinatesMode = this.coordinatesMode;
  54829. return newTexture;
  54830. };
  54831. /**
  54832. * Dispose the texture and release its asoociated resources.
  54833. */
  54834. ProceduralTexture.prototype.dispose = function () {
  54835. var scene = this.getScene();
  54836. if (!scene) {
  54837. return;
  54838. }
  54839. var index = scene.proceduralTextures.indexOf(this);
  54840. if (index >= 0) {
  54841. scene.proceduralTextures.splice(index, 1);
  54842. }
  54843. var vertexBuffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind];
  54844. if (vertexBuffer) {
  54845. vertexBuffer.dispose();
  54846. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind] = null;
  54847. }
  54848. if (this._indexBuffer && this._engine._releaseBuffer(this._indexBuffer)) {
  54849. this._indexBuffer = null;
  54850. }
  54851. _super.prototype.dispose.call(this);
  54852. };
  54853. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54854. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54855. ], ProceduralTexture.prototype, "isEnabled", void 0);
  54856. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54857. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54858. ], ProceduralTexture.prototype, "autoClear", void 0);
  54859. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54860. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54861. ], ProceduralTexture.prototype, "_generateMipMaps", void 0);
  54862. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54863. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54864. ], ProceduralTexture.prototype, "_size", void 0);
  54865. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  54866. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  54867. ], ProceduralTexture.prototype, "refreshRate", null);
  54868. return ProceduralTexture;
  54869. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"]));
  54870. /***/ }),
  54871. /***/ "./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts":
  54872. /*!***************************************************************************!*\
  54873. !*** ./Materials/Textures/Procedurals/proceduralTextureSceneComponent.ts ***!
  54874. \***************************************************************************/
  54875. /*! exports provided: ProceduralTextureSceneComponent */
  54876. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54877. "use strict";
  54878. __webpack_require__.r(__webpack_exports__);
  54879. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return ProceduralTextureSceneComponent; });
  54880. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../../Misc/tools */ "./Misc/tools.ts");
  54881. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../sceneComponent */ "./sceneComponent.ts");
  54882. /**
  54883. * Defines the Procedural Texture scene component responsible to manage any Procedural Texture
  54884. * in a given scene.
  54885. */
  54886. var ProceduralTextureSceneComponent = /** @class */ (function () {
  54887. /**
  54888. * Creates a new instance of the component for the given scene
  54889. * @param scene Defines the scene to register the component in
  54890. */
  54891. function ProceduralTextureSceneComponent(scene) {
  54892. /**
  54893. * The component name helpfull to identify the component in the list of scene components.
  54894. */
  54895. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_PROCEDURALTEXTURE;
  54896. this.scene = scene;
  54897. this.scene.proceduralTextures = new Array();
  54898. scene.layers = new Array();
  54899. }
  54900. /**
  54901. * Registers the component in a given scene
  54902. */
  54903. ProceduralTextureSceneComponent.prototype.register = function () {
  54904. this.scene._beforeClearStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_BEFORECLEAR_PROCEDURALTEXTURE, this, this._beforeClear);
  54905. };
  54906. /**
  54907. * Rebuilds the elements related to this component in case of
  54908. * context lost for instance.
  54909. */
  54910. ProceduralTextureSceneComponent.prototype.rebuild = function () {
  54911. // Nothing to do here.
  54912. };
  54913. /**
  54914. * Disposes the component and the associated ressources.
  54915. */
  54916. ProceduralTextureSceneComponent.prototype.dispose = function () {
  54917. // Nothing to do here.
  54918. };
  54919. ProceduralTextureSceneComponent.prototype._beforeClear = function () {
  54920. if (this.scene.proceduralTexturesEnabled) {
  54921. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].StartPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54922. for (var proceduralIndex = 0; proceduralIndex < this.scene.proceduralTextures.length; proceduralIndex++) {
  54923. var proceduralTexture = this.scene.proceduralTextures[proceduralIndex];
  54924. if (proceduralTexture._shouldRender()) {
  54925. proceduralTexture.render();
  54926. }
  54927. }
  54928. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].EndPerformanceCounter("Procedural textures", this.scene.proceduralTextures.length > 0);
  54929. }
  54930. };
  54931. return ProceduralTextureSceneComponent;
  54932. }());
  54933. /***/ }),
  54934. /***/ "./Materials/Textures/baseTexture.ts":
  54935. /*!*******************************************!*\
  54936. !*** ./Materials/Textures/baseTexture.ts ***!
  54937. \*******************************************/
  54938. /*! exports provided: BaseTexture */
  54939. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  54940. "use strict";
  54941. __webpack_require__.r(__webpack_exports__);
  54942. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return BaseTexture; });
  54943. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  54944. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  54945. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  54946. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  54947. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  54948. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  54949. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/engineStore */ "./Engines/engineStore.ts");
  54950. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  54951. /**
  54952. * Base class of all the textures in babylon.
  54953. * It groups all the common properties the materials, post process, lights... might need
  54954. * in order to make a correct use of the texture.
  54955. */
  54956. var BaseTexture = /** @class */ (function () {
  54957. /**
  54958. * Instantiates a new BaseTexture.
  54959. * Base class of all the textures in babylon.
  54960. * It groups all the common properties the materials, post process, lights... might need
  54961. * in order to make a correct use of the texture.
  54962. * @param scene Define the scene the texture blongs to
  54963. */
  54964. function BaseTexture(scene) {
  54965. /**
  54966. * Gets or sets an object used to store user defined information.
  54967. */
  54968. this.metadata = null;
  54969. /**
  54970. * For internal use only. Please do not use.
  54971. */
  54972. this.reservedDataStore = null;
  54973. this._hasAlpha = false;
  54974. /**
  54975. * Defines if the alpha value should be determined via the rgb values.
  54976. * If true the luminance of the pixel might be used to find the corresponding alpha value.
  54977. */
  54978. this.getAlphaFromRGB = false;
  54979. /**
  54980. * Intensity or strength of the texture.
  54981. * It is commonly used by materials to fine tune the intensity of the texture
  54982. */
  54983. this.level = 1;
  54984. /**
  54985. * Define the UV chanel to use starting from 0 and defaulting to 0.
  54986. * This is part of the texture as textures usually maps to one uv set.
  54987. */
  54988. this.coordinatesIndex = 0;
  54989. this._coordinatesMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_EXPLICIT_MODE;
  54990. /**
  54991. * | Value | Type | Description |
  54992. * | ----- | ------------------ | ----------- |
  54993. * | 0 | CLAMP_ADDRESSMODE | |
  54994. * | 1 | WRAP_ADDRESSMODE | |
  54995. * | 2 | MIRROR_ADDRESSMODE | |
  54996. */
  54997. this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  54998. /**
  54999. * | Value | Type | Description |
  55000. * | ----- | ------------------ | ----------- |
  55001. * | 0 | CLAMP_ADDRESSMODE | |
  55002. * | 1 | WRAP_ADDRESSMODE | |
  55003. * | 2 | MIRROR_ADDRESSMODE | |
  55004. */
  55005. this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  55006. /**
  55007. * | Value | Type | Description |
  55008. * | ----- | ------------------ | ----------- |
  55009. * | 0 | CLAMP_ADDRESSMODE | |
  55010. * | 1 | WRAP_ADDRESSMODE | |
  55011. * | 2 | MIRROR_ADDRESSMODE | |
  55012. */
  55013. this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  55014. /**
  55015. * With compliant hardware and browser (supporting anisotropic filtering)
  55016. * this defines the level of anisotropic filtering in the texture.
  55017. * The higher the better but the slower. This defaults to 4 as it seems to be the best tradeoff.
  55018. */
  55019. this.anisotropicFilteringLevel = BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL;
  55020. /**
  55021. * Define if the texture contains data in gamma space (most of the png/jpg aside bump).
  55022. * HDR texture are usually stored in linear space.
  55023. * This only impacts the PBR and Background materials
  55024. */
  55025. this.gammaSpace = true;
  55026. /**
  55027. * Is Z inverted in the texture (useful in a cube texture).
  55028. */
  55029. this.invertZ = false;
  55030. /**
  55031. * @hidden
  55032. */
  55033. this.lodLevelInAlpha = false;
  55034. /**
  55035. * Define if the texture is a render target.
  55036. */
  55037. this.isRenderTarget = false;
  55038. /**
  55039. * Define the list of animation attached to the texture.
  55040. */
  55041. this.animations = new Array();
  55042. /**
  55043. * An event triggered when the texture is disposed.
  55044. */
  55045. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  55046. /**
  55047. * Define the current state of the loading sequence when in delayed load mode.
  55048. */
  55049. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NONE;
  55050. this._cachedSize = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  55051. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_6__["EngineStore"].LastCreatedScene;
  55052. if (this._scene) {
  55053. this.uniqueId = this._scene.getUniqueId();
  55054. this._scene.addTexture(this);
  55055. }
  55056. this._uid = null;
  55057. }
  55058. Object.defineProperty(BaseTexture.prototype, "hasAlpha", {
  55059. get: function () {
  55060. return this._hasAlpha;
  55061. },
  55062. /**
  55063. * Define if the texture is having a usable alpha value (can be use for transparency or glossiness for instance).
  55064. */
  55065. set: function (value) {
  55066. if (this._hasAlpha === value) {
  55067. return;
  55068. }
  55069. this._hasAlpha = value;
  55070. if (this._scene) {
  55071. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag | _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_MiscDirtyFlag);
  55072. }
  55073. },
  55074. enumerable: true,
  55075. configurable: true
  55076. });
  55077. Object.defineProperty(BaseTexture.prototype, "coordinatesMode", {
  55078. get: function () {
  55079. return this._coordinatesMode;
  55080. },
  55081. /**
  55082. * How a texture is mapped.
  55083. *
  55084. * | Value | Type | Description |
  55085. * | ----- | ----------------------------------- | ----------- |
  55086. * | 0 | EXPLICIT_MODE | |
  55087. * | 1 | SPHERICAL_MODE | |
  55088. * | 2 | PLANAR_MODE | |
  55089. * | 3 | CUBIC_MODE | |
  55090. * | 4 | PROJECTION_MODE | |
  55091. * | 5 | SKYBOX_MODE | |
  55092. * | 6 | INVCUBIC_MODE | |
  55093. * | 7 | EQUIRECTANGULAR_MODE | |
  55094. * | 8 | FIXED_EQUIRECTANGULAR_MODE | |
  55095. * | 9 | FIXED_EQUIRECTANGULAR_MIRRORED_MODE | |
  55096. */
  55097. set: function (value) {
  55098. if (this._coordinatesMode === value) {
  55099. return;
  55100. }
  55101. this._coordinatesMode = value;
  55102. if (this._scene) {
  55103. this._scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  55104. }
  55105. },
  55106. enumerable: true,
  55107. configurable: true
  55108. });
  55109. Object.defineProperty(BaseTexture.prototype, "isCube", {
  55110. /**
  55111. * Define if the texture is a cube texture or if false a 2d texture.
  55112. */
  55113. get: function () {
  55114. if (!this._texture) {
  55115. return false;
  55116. }
  55117. return this._texture.isCube;
  55118. },
  55119. set: function (value) {
  55120. if (!this._texture) {
  55121. return;
  55122. }
  55123. this._texture.isCube = value;
  55124. },
  55125. enumerable: true,
  55126. configurable: true
  55127. });
  55128. Object.defineProperty(BaseTexture.prototype, "is3D", {
  55129. /**
  55130. * Define if the texture is a 3d texture (webgl 2) or if false a 2d texture.
  55131. */
  55132. get: function () {
  55133. if (!this._texture) {
  55134. return false;
  55135. }
  55136. return this._texture.is3D;
  55137. },
  55138. set: function (value) {
  55139. if (!this._texture) {
  55140. return;
  55141. }
  55142. this._texture.is3D = value;
  55143. },
  55144. enumerable: true,
  55145. configurable: true
  55146. });
  55147. Object.defineProperty(BaseTexture.prototype, "isRGBD", {
  55148. /**
  55149. * Gets whether or not the texture contains RGBD data.
  55150. */
  55151. get: function () {
  55152. return this._texture != null && this._texture._isRGBD;
  55153. },
  55154. enumerable: true,
  55155. configurable: true
  55156. });
  55157. Object.defineProperty(BaseTexture.prototype, "noMipmap", {
  55158. /**
  55159. * Are mip maps generated for this texture or not.
  55160. */
  55161. get: function () {
  55162. return false;
  55163. },
  55164. enumerable: true,
  55165. configurable: true
  55166. });
  55167. Object.defineProperty(BaseTexture.prototype, "lodGenerationOffset", {
  55168. /**
  55169. * With prefiltered texture, defined the offset used during the prefiltering steps.
  55170. */
  55171. get: function () {
  55172. if (this._texture) {
  55173. return this._texture._lodGenerationOffset;
  55174. }
  55175. return 0.0;
  55176. },
  55177. set: function (value) {
  55178. if (this._texture) {
  55179. this._texture._lodGenerationOffset = value;
  55180. }
  55181. },
  55182. enumerable: true,
  55183. configurable: true
  55184. });
  55185. Object.defineProperty(BaseTexture.prototype, "lodGenerationScale", {
  55186. /**
  55187. * With prefiltered texture, defined the scale used during the prefiltering steps.
  55188. */
  55189. get: function () {
  55190. if (this._texture) {
  55191. return this._texture._lodGenerationScale;
  55192. }
  55193. return 0.0;
  55194. },
  55195. set: function (value) {
  55196. if (this._texture) {
  55197. this._texture._lodGenerationScale = value;
  55198. }
  55199. },
  55200. enumerable: true,
  55201. configurable: true
  55202. });
  55203. Object.defineProperty(BaseTexture.prototype, "uid", {
  55204. /**
  55205. * Define the unique id of the texture in the scene.
  55206. */
  55207. get: function () {
  55208. if (!this._uid) {
  55209. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].RandomId();
  55210. }
  55211. return this._uid;
  55212. },
  55213. enumerable: true,
  55214. configurable: true
  55215. });
  55216. /**
  55217. * Return a string representation of the texture.
  55218. * @returns the texture as a string
  55219. */
  55220. BaseTexture.prototype.toString = function () {
  55221. return this.name;
  55222. };
  55223. /**
  55224. * Get the class name of the texture.
  55225. * @returns "BaseTexture"
  55226. */
  55227. BaseTexture.prototype.getClassName = function () {
  55228. return "BaseTexture";
  55229. };
  55230. Object.defineProperty(BaseTexture.prototype, "onDispose", {
  55231. /**
  55232. * Callback triggered when the texture has been disposed.
  55233. * Kept for back compatibility, you can use the onDisposeObservable instead.
  55234. */
  55235. set: function (callback) {
  55236. if (this._onDisposeObserver) {
  55237. this.onDisposeObservable.remove(this._onDisposeObserver);
  55238. }
  55239. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  55240. },
  55241. enumerable: true,
  55242. configurable: true
  55243. });
  55244. Object.defineProperty(BaseTexture.prototype, "isBlocking", {
  55245. /**
  55246. * Define if the texture is preventinga material to render or not.
  55247. * If not and the texture is not ready, the engine will use a default black texture instead.
  55248. */
  55249. get: function () {
  55250. return true;
  55251. },
  55252. enumerable: true,
  55253. configurable: true
  55254. });
  55255. /**
  55256. * Get the scene the texture belongs to.
  55257. * @returns the scene or null if undefined
  55258. */
  55259. BaseTexture.prototype.getScene = function () {
  55260. return this._scene;
  55261. };
  55262. /**
  55263. * Get the texture transform matrix used to offset tile the texture for istance.
  55264. * @returns the transformation matrix
  55265. */
  55266. BaseTexture.prototype.getTextureMatrix = function () {
  55267. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  55268. };
  55269. /**
  55270. * Get the texture reflection matrix used to rotate/transform the reflection.
  55271. * @returns the reflection matrix
  55272. */
  55273. BaseTexture.prototype.getReflectionTextureMatrix = function () {
  55274. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].IdentityReadOnly;
  55275. };
  55276. /**
  55277. * Get the underlying lower level texture from Babylon.
  55278. * @returns the insternal texture
  55279. */
  55280. BaseTexture.prototype.getInternalTexture = function () {
  55281. return this._texture;
  55282. };
  55283. /**
  55284. * Get if the texture is ready to be consumed (either it is ready or it is not blocking)
  55285. * @returns true if ready or not blocking
  55286. */
  55287. BaseTexture.prototype.isReadyOrNotBlocking = function () {
  55288. return !this.isBlocking || this.isReady();
  55289. };
  55290. /**
  55291. * Get if the texture is ready to be used (downloaded, converted, mip mapped...).
  55292. * @returns true if fully ready
  55293. */
  55294. BaseTexture.prototype.isReady = function () {
  55295. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55296. this.delayLoad();
  55297. return false;
  55298. }
  55299. if (this._texture) {
  55300. return this._texture.isReady;
  55301. }
  55302. return false;
  55303. };
  55304. /**
  55305. * Get the size of the texture.
  55306. * @returns the texture size.
  55307. */
  55308. BaseTexture.prototype.getSize = function () {
  55309. if (this._texture) {
  55310. if (this._texture.width) {
  55311. this._cachedSize.width = this._texture.width;
  55312. this._cachedSize.height = this._texture.height;
  55313. return this._cachedSize;
  55314. }
  55315. if (this._texture._size) {
  55316. this._cachedSize.width = this._texture._size;
  55317. this._cachedSize.height = this._texture._size;
  55318. return this._cachedSize;
  55319. }
  55320. }
  55321. return this._cachedSize;
  55322. };
  55323. /**
  55324. * Get the base size of the texture.
  55325. * It can be different from the size if the texture has been resized for POT for instance
  55326. * @returns the base size
  55327. */
  55328. BaseTexture.prototype.getBaseSize = function () {
  55329. if (!this.isReady() || !this._texture) {
  55330. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"].Zero();
  55331. }
  55332. if (this._texture._size) {
  55333. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture._size, this._texture._size);
  55334. }
  55335. return new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Size"](this._texture.baseWidth, this._texture.baseHeight);
  55336. };
  55337. /**
  55338. * Update the sampling mode of the texture.
  55339. * Default is Trilinear mode.
  55340. *
  55341. * | Value | Type | Description |
  55342. * | ----- | ------------------ | ----------- |
  55343. * | 1 | NEAREST_SAMPLINGMODE or NEAREST_NEAREST_MIPLINEAR | Nearest is: mag = nearest, min = nearest, mip = linear |
  55344. * | 2 | BILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPNEAREST | Bilinear is: mag = linear, min = linear, mip = nearest |
  55345. * | 3 | TRILINEAR_SAMPLINGMODE or LINEAR_LINEAR_MIPLINEAR | Trilinear is: mag = linear, min = linear, mip = linear |
  55346. * | 4 | NEAREST_NEAREST_MIPNEAREST | |
  55347. * | 5 | NEAREST_LINEAR_MIPNEAREST | |
  55348. * | 6 | NEAREST_LINEAR_MIPLINEAR | |
  55349. * | 7 | NEAREST_LINEAR | |
  55350. * | 8 | NEAREST_NEAREST | |
  55351. * | 9 | LINEAR_NEAREST_MIPNEAREST | |
  55352. * | 10 | LINEAR_NEAREST_MIPLINEAR | |
  55353. * | 11 | LINEAR_LINEAR | |
  55354. * | 12 | LINEAR_NEAREST | |
  55355. *
  55356. * > _mag_: magnification filter (close to the viewer)
  55357. * > _min_: minification filter (far from the viewer)
  55358. * > _mip_: filter used between mip map levels
  55359. *@param samplingMode Define the new sampling mode of the texture
  55360. */
  55361. BaseTexture.prototype.updateSamplingMode = function (samplingMode) {
  55362. if (!this._texture) {
  55363. return;
  55364. }
  55365. var scene = this.getScene();
  55366. if (!scene) {
  55367. return;
  55368. }
  55369. scene.getEngine().updateTextureSamplingMode(samplingMode, this._texture);
  55370. };
  55371. /**
  55372. * Scales the texture if is `canRescale()`
  55373. * @param ratio the resize factor we want to use to rescale
  55374. */
  55375. BaseTexture.prototype.scale = function (ratio) {
  55376. };
  55377. Object.defineProperty(BaseTexture.prototype, "canRescale", {
  55378. /**
  55379. * Get if the texture can rescale.
  55380. */
  55381. get: function () {
  55382. return false;
  55383. },
  55384. enumerable: true,
  55385. configurable: true
  55386. });
  55387. /** @hidden */
  55388. BaseTexture.prototype._getFromCache = function (url, noMipmap, sampling) {
  55389. if (!this._scene) {
  55390. return null;
  55391. }
  55392. var texturesCache = this._scene.getEngine().getLoadedTexturesCache();
  55393. for (var index = 0; index < texturesCache.length; index++) {
  55394. var texturesCacheEntry = texturesCache[index];
  55395. if (texturesCacheEntry.url === url && texturesCacheEntry.generateMipMaps === !noMipmap) {
  55396. if (!sampling || sampling === texturesCacheEntry.samplingMode) {
  55397. texturesCacheEntry.incrementReferences();
  55398. return texturesCacheEntry;
  55399. }
  55400. }
  55401. }
  55402. return null;
  55403. };
  55404. /** @hidden */
  55405. BaseTexture.prototype._rebuild = function () {
  55406. };
  55407. /**
  55408. * Triggers the load sequence in delayed load mode.
  55409. */
  55410. BaseTexture.prototype.delayLoad = function () {
  55411. };
  55412. /**
  55413. * Clones the texture.
  55414. * @returns the cloned texture
  55415. */
  55416. BaseTexture.prototype.clone = function () {
  55417. return null;
  55418. };
  55419. Object.defineProperty(BaseTexture.prototype, "textureType", {
  55420. /**
  55421. * Get the texture underlying type (INT, FLOAT...)
  55422. */
  55423. get: function () {
  55424. if (!this._texture) {
  55425. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55426. }
  55427. return (this._texture.type !== undefined) ? this._texture.type : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  55428. },
  55429. enumerable: true,
  55430. configurable: true
  55431. });
  55432. Object.defineProperty(BaseTexture.prototype, "textureFormat", {
  55433. /**
  55434. * Get the texture underlying format (RGB, RGBA...)
  55435. */
  55436. get: function () {
  55437. if (!this._texture) {
  55438. return _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55439. }
  55440. return (this._texture.format !== undefined) ? this._texture.format : _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA;
  55441. },
  55442. enumerable: true,
  55443. configurable: true
  55444. });
  55445. /**
  55446. * Reads the pixels stored in the webgl texture and returns them as an ArrayBuffer.
  55447. * This will returns an RGBA array buffer containing either in values (0-255) or
  55448. * float values (0-1) depending of the underlying buffer type.
  55449. * @param faceIndex defines the face of the texture to read (in case of cube texture)
  55450. * @param level defines the LOD level of the texture to read (in case of Mip Maps)
  55451. * @param buffer defines a user defined buffer to fill with data (can be null)
  55452. * @returns The Array buffer containing the pixels data.
  55453. */
  55454. BaseTexture.prototype.readPixels = function (faceIndex, level, buffer) {
  55455. if (faceIndex === void 0) { faceIndex = 0; }
  55456. if (level === void 0) { level = 0; }
  55457. if (buffer === void 0) { buffer = null; }
  55458. if (!this._texture) {
  55459. return null;
  55460. }
  55461. var size = this.getSize();
  55462. var width = size.width;
  55463. var height = size.height;
  55464. var scene = this.getScene();
  55465. if (!scene) {
  55466. return null;
  55467. }
  55468. var engine = scene.getEngine();
  55469. if (level != 0) {
  55470. width = width / Math.pow(2, level);
  55471. height = height / Math.pow(2, level);
  55472. width = Math.round(width);
  55473. height = Math.round(height);
  55474. }
  55475. if (this._texture.isCube) {
  55476. return engine._readTexturePixels(this._texture, width, height, faceIndex, level, buffer);
  55477. }
  55478. return engine._readTexturePixels(this._texture, width, height, -1, level, buffer);
  55479. };
  55480. /**
  55481. * Release and destroy the underlying lower level texture aka internalTexture.
  55482. */
  55483. BaseTexture.prototype.releaseInternalTexture = function () {
  55484. if (this._texture) {
  55485. this._texture.dispose();
  55486. this._texture = null;
  55487. }
  55488. };
  55489. Object.defineProperty(BaseTexture.prototype, "sphericalPolynomial", {
  55490. /**
  55491. * Get the polynomial representation of the texture data.
  55492. * This is mainly use as a fast way to recover IBL Diffuse irradiance data.
  55493. * @see https://learnopengl.com/PBR/IBL/Diffuse-irradiance
  55494. */
  55495. get: function () {
  55496. if (!this._texture || !_Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"] || !this.isReady()) {
  55497. return null;
  55498. }
  55499. if (!this._texture._sphericalPolynomial) {
  55500. this._texture._sphericalPolynomial =
  55501. _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_4__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapTextureToSphericalPolynomial(this);
  55502. }
  55503. return this._texture._sphericalPolynomial;
  55504. },
  55505. set: function (value) {
  55506. if (this._texture) {
  55507. this._texture._sphericalPolynomial = value;
  55508. }
  55509. },
  55510. enumerable: true,
  55511. configurable: true
  55512. });
  55513. Object.defineProperty(BaseTexture.prototype, "_lodTextureHigh", {
  55514. /** @hidden */
  55515. get: function () {
  55516. if (this._texture) {
  55517. return this._texture._lodTextureHigh;
  55518. }
  55519. return null;
  55520. },
  55521. enumerable: true,
  55522. configurable: true
  55523. });
  55524. Object.defineProperty(BaseTexture.prototype, "_lodTextureMid", {
  55525. /** @hidden */
  55526. get: function () {
  55527. if (this._texture) {
  55528. return this._texture._lodTextureMid;
  55529. }
  55530. return null;
  55531. },
  55532. enumerable: true,
  55533. configurable: true
  55534. });
  55535. Object.defineProperty(BaseTexture.prototype, "_lodTextureLow", {
  55536. /** @hidden */
  55537. get: function () {
  55538. if (this._texture) {
  55539. return this._texture._lodTextureLow;
  55540. }
  55541. return null;
  55542. },
  55543. enumerable: true,
  55544. configurable: true
  55545. });
  55546. /**
  55547. * Dispose the texture and release its associated resources.
  55548. */
  55549. BaseTexture.prototype.dispose = function () {
  55550. if (!this._scene) {
  55551. return;
  55552. }
  55553. // Animations
  55554. this._scene.stopAnimation(this);
  55555. // Remove from scene
  55556. this._scene._removePendingData(this);
  55557. var index = this._scene.textures.indexOf(this);
  55558. if (index >= 0) {
  55559. this._scene.textures.splice(index, 1);
  55560. }
  55561. this._scene.onTextureRemovedObservable.notifyObservers(this);
  55562. if (this._texture === undefined) {
  55563. return;
  55564. }
  55565. // Release
  55566. this.releaseInternalTexture();
  55567. // Callback
  55568. this.onDisposeObservable.notifyObservers(this);
  55569. this.onDisposeObservable.clear();
  55570. };
  55571. /**
  55572. * Serialize the texture into a JSON representation that can be parsed later on.
  55573. * @returns the JSON representation of the texture
  55574. */
  55575. BaseTexture.prototype.serialize = function () {
  55576. if (!this.name) {
  55577. return null;
  55578. }
  55579. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  55580. // Animations
  55581. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  55582. return serializationObject;
  55583. };
  55584. /**
  55585. * Helper function to be called back once a list of texture contains only ready textures.
  55586. * @param textures Define the list of textures to wait for
  55587. * @param callback Define the callback triggered once the entire list will be ready
  55588. */
  55589. BaseTexture.WhenAllReady = function (textures, callback) {
  55590. var numRemaining = textures.length;
  55591. if (numRemaining === 0) {
  55592. callback();
  55593. return;
  55594. }
  55595. var _loop_1 = function () {
  55596. texture = textures[i];
  55597. if (texture.isReady()) {
  55598. if (--numRemaining === 0) {
  55599. callback();
  55600. }
  55601. }
  55602. else {
  55603. onLoadObservable = texture.onLoadObservable;
  55604. var onLoadCallback_1 = function () {
  55605. onLoadObservable.removeCallback(onLoadCallback_1);
  55606. if (--numRemaining === 0) {
  55607. callback();
  55608. }
  55609. };
  55610. onLoadObservable.add(onLoadCallback_1);
  55611. }
  55612. };
  55613. var texture, onLoadObservable;
  55614. for (var i = 0; i < textures.length; i++) {
  55615. _loop_1();
  55616. }
  55617. };
  55618. /**
  55619. * Default anisotropic filtering level for the application.
  55620. * It is set to 4 as a good tradeoff between perf and quality.
  55621. */
  55622. BaseTexture.DEFAULT_ANISOTROPIC_FILTERING_LEVEL = 4;
  55623. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55624. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55625. ], BaseTexture.prototype, "uniqueId", void 0);
  55626. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55627. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55628. ], BaseTexture.prototype, "name", void 0);
  55629. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55630. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55631. ], BaseTexture.prototype, "metadata", void 0);
  55632. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55633. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("hasAlpha")
  55634. ], BaseTexture.prototype, "_hasAlpha", void 0);
  55635. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55636. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55637. ], BaseTexture.prototype, "getAlphaFromRGB", void 0);
  55638. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55639. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55640. ], BaseTexture.prototype, "level", void 0);
  55641. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55642. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55643. ], BaseTexture.prototype, "coordinatesIndex", void 0);
  55644. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55645. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("coordinatesMode")
  55646. ], BaseTexture.prototype, "_coordinatesMode", void 0);
  55647. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55648. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55649. ], BaseTexture.prototype, "wrapU", void 0);
  55650. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55651. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55652. ], BaseTexture.prototype, "wrapV", void 0);
  55653. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55654. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55655. ], BaseTexture.prototype, "wrapR", void 0);
  55656. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55657. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55658. ], BaseTexture.prototype, "anisotropicFilteringLevel", void 0);
  55659. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55660. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55661. ], BaseTexture.prototype, "isCube", null);
  55662. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55663. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55664. ], BaseTexture.prototype, "is3D", null);
  55665. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55666. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55667. ], BaseTexture.prototype, "gammaSpace", void 0);
  55668. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55669. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55670. ], BaseTexture.prototype, "invertZ", void 0);
  55671. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55672. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55673. ], BaseTexture.prototype, "lodLevelInAlpha", void 0);
  55674. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55675. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55676. ], BaseTexture.prototype, "lodGenerationOffset", null);
  55677. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55678. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55679. ], BaseTexture.prototype, "lodGenerationScale", null);
  55680. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  55681. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  55682. ], BaseTexture.prototype, "isRenderTarget", void 0);
  55683. return BaseTexture;
  55684. }());
  55685. /***/ }),
  55686. /***/ "./Materials/Textures/colorGradingTexture.ts":
  55687. /*!***************************************************!*\
  55688. !*** ./Materials/Textures/colorGradingTexture.ts ***!
  55689. \***************************************************/
  55690. /*! exports provided: ColorGradingTexture */
  55691. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55692. "use strict";
  55693. __webpack_require__.r(__webpack_exports__);
  55694. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return ColorGradingTexture; });
  55695. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55696. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55697. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55698. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55699. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55700. /**
  55701. * This represents a color grading texture. This acts as a lookup table LUT, useful during post process
  55702. * It can help converting any input color in a desired output one. This can then be used to create effects
  55703. * from sepia, black and white to sixties or futuristic rendering...
  55704. *
  55705. * The only supported format is currently 3dl.
  55706. * More information on LUT: https://en.wikipedia.org/wiki/3D_lookup_table
  55707. */
  55708. var ColorGradingTexture = /** @class */ (function (_super) {
  55709. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorGradingTexture, _super);
  55710. /**
  55711. * Instantiates a ColorGradingTexture from the following parameters.
  55712. *
  55713. * @param url The location of the color gradind data (currently only supporting 3dl)
  55714. * @param scene The scene the texture will be used in
  55715. */
  55716. function ColorGradingTexture(url, scene) {
  55717. var _this = _super.call(this, scene) || this;
  55718. if (!url) {
  55719. return _this;
  55720. }
  55721. _this._engine = scene.getEngine();
  55722. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  55723. _this.name = url;
  55724. _this.url = url;
  55725. _this.hasAlpha = false;
  55726. _this.isCube = false;
  55727. _this.is3D = _this._engine.webGLVersion > 1;
  55728. _this.wrapU = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55729. _this.wrapV = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55730. _this.wrapR = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  55731. _this.anisotropicFilteringLevel = 1;
  55732. _this._texture = _this._getFromCache(url, true);
  55733. if (!_this._texture) {
  55734. if (!scene.useDelayedTextureLoading) {
  55735. _this.loadTexture();
  55736. }
  55737. else {
  55738. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED;
  55739. }
  55740. }
  55741. return _this;
  55742. }
  55743. /**
  55744. * Returns the texture matrix used in most of the material.
  55745. * This is not used in color grading but keep for troubleshooting purpose (easily swap diffuse by colorgrading to look in).
  55746. */
  55747. ColorGradingTexture.prototype.getTextureMatrix = function () {
  55748. return this._textureMatrix;
  55749. };
  55750. /**
  55751. * Occurs when the file being loaded is a .3dl LUT file.
  55752. */
  55753. ColorGradingTexture.prototype.load3dlTexture = function () {
  55754. var engine = this._engine;
  55755. var texture;
  55756. if (engine.webGLVersion === 1) {
  55757. 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);
  55758. }
  55759. else {
  55760. 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);
  55761. }
  55762. this._texture = texture;
  55763. var callback = function (text) {
  55764. if (typeof text !== "string") {
  55765. return;
  55766. }
  55767. var data = null;
  55768. var tempData = null;
  55769. var line;
  55770. var lines = text.split('\n');
  55771. var size = 0, pixelIndexW = 0, pixelIndexH = 0, pixelIndexSlice = 0;
  55772. var maxColor = 0;
  55773. for (var i = 0; i < lines.length; i++) {
  55774. line = lines[i];
  55775. if (!ColorGradingTexture._noneEmptyLineRegex.test(line)) {
  55776. continue;
  55777. }
  55778. if (line.indexOf('#') === 0) {
  55779. continue;
  55780. }
  55781. var words = line.split(" ");
  55782. if (size === 0) {
  55783. // Number of space + one
  55784. size = words.length;
  55785. data = new Uint8Array(size * size * size * 4); // volume texture of side size and rgb 8
  55786. tempData = new Float32Array(size * size * size * 4);
  55787. continue;
  55788. }
  55789. if (size != 0) {
  55790. var r = Math.max(parseInt(words[0]), 0);
  55791. var g = Math.max(parseInt(words[1]), 0);
  55792. var b = Math.max(parseInt(words[2]), 0);
  55793. maxColor = Math.max(r, maxColor);
  55794. maxColor = Math.max(g, maxColor);
  55795. maxColor = Math.max(b, maxColor);
  55796. var pixelStorageIndex = (pixelIndexW + pixelIndexSlice * size + pixelIndexH * size * size) * 4;
  55797. if (tempData) {
  55798. tempData[pixelStorageIndex + 0] = r;
  55799. tempData[pixelStorageIndex + 1] = g;
  55800. tempData[pixelStorageIndex + 2] = b;
  55801. }
  55802. // Keep for reference in case of back compat problems.
  55803. // pixelIndexSlice++;
  55804. // if (pixelIndexSlice % size == 0) {
  55805. // pixelIndexH++;
  55806. // pixelIndexSlice = 0;
  55807. // if (pixelIndexH % size == 0) {
  55808. // pixelIndexW++;
  55809. // pixelIndexH = 0;
  55810. // }
  55811. // }
  55812. pixelIndexH++;
  55813. if (pixelIndexH % size == 0) {
  55814. pixelIndexSlice++;
  55815. pixelIndexH = 0;
  55816. if (pixelIndexSlice % size == 0) {
  55817. pixelIndexW++;
  55818. pixelIndexSlice = 0;
  55819. }
  55820. }
  55821. }
  55822. }
  55823. if (tempData && data) {
  55824. for (var i = 0; i < tempData.length; i++) {
  55825. if (i > 0 && (i + 1) % 4 === 0) {
  55826. data[i] = 255;
  55827. }
  55828. else {
  55829. var value = tempData[i];
  55830. data[i] = (value / maxColor * 255);
  55831. }
  55832. }
  55833. }
  55834. if (texture.is3D) {
  55835. texture.updateSize(size, size, size);
  55836. engine.updateRawTexture3D(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55837. }
  55838. else {
  55839. texture.updateSize(size * size, size);
  55840. engine.updateRawTexture(texture, data, _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA, false);
  55841. }
  55842. };
  55843. var scene = this.getScene();
  55844. if (scene) {
  55845. scene._loadFile(this.url, callback);
  55846. }
  55847. else {
  55848. this._engine._loadFile(this.url, callback);
  55849. }
  55850. return this._texture;
  55851. };
  55852. /**
  55853. * Starts the loading process of the texture.
  55854. */
  55855. ColorGradingTexture.prototype.loadTexture = function () {
  55856. if (this.url && this.url.toLocaleLowerCase().indexOf(".3dl") == (this.url.length - 4)) {
  55857. this.load3dlTexture();
  55858. }
  55859. };
  55860. /**
  55861. * Clones the color gradind texture.
  55862. */
  55863. ColorGradingTexture.prototype.clone = function () {
  55864. var newTexture = new ColorGradingTexture(this.url, this.getScene());
  55865. // Base texture
  55866. newTexture.level = this.level;
  55867. return newTexture;
  55868. };
  55869. /**
  55870. * Called during delayed load for textures.
  55871. */
  55872. ColorGradingTexture.prototype.delayLoad = function () {
  55873. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  55874. return;
  55875. }
  55876. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].DELAYLOADSTATE_LOADED;
  55877. this._texture = this._getFromCache(this.url, true);
  55878. if (!this._texture) {
  55879. this.loadTexture();
  55880. }
  55881. };
  55882. /**
  55883. * Parses a color grading texture serialized by Babylon.
  55884. * @param parsedTexture The texture information being parsedTexture
  55885. * @param scene The scene to load the texture in
  55886. * @param rootUrl The root url of the data assets to load
  55887. * @return A color gradind texture
  55888. */
  55889. ColorGradingTexture.Parse = function (parsedTexture, scene) {
  55890. var texture = null;
  55891. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  55892. texture = new ColorGradingTexture(parsedTexture.name, scene);
  55893. texture.name = parsedTexture.name;
  55894. texture.level = parsedTexture.level;
  55895. }
  55896. return texture;
  55897. };
  55898. /**
  55899. * Serializes the LUT texture to json format.
  55900. */
  55901. ColorGradingTexture.prototype.serialize = function () {
  55902. if (!this.name) {
  55903. return null;
  55904. }
  55905. var serializationObject = {};
  55906. serializationObject.name = this.name;
  55907. serializationObject.level = this.level;
  55908. serializationObject.customType = "BABYLON.ColorGradingTexture";
  55909. return serializationObject;
  55910. };
  55911. /**
  55912. * Empty line regex stored for GC.
  55913. */
  55914. ColorGradingTexture._noneEmptyLineRegex = /\S+/;
  55915. return ColorGradingTexture;
  55916. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_2__["BaseTexture"]));
  55917. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_4__["_TypeStore"].RegisteredTypes["BABYLON.ColorGradingTexture"] = ColorGradingTexture;
  55918. /***/ }),
  55919. /***/ "./Materials/Textures/cubeTexture.ts":
  55920. /*!*******************************************!*\
  55921. !*** ./Materials/Textures/cubeTexture.ts ***!
  55922. \*******************************************/
  55923. /*! exports provided: CubeTexture */
  55924. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  55925. "use strict";
  55926. __webpack_require__.r(__webpack_exports__);
  55927. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return CubeTexture; });
  55928. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  55929. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  55930. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  55931. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  55932. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  55933. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  55934. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  55935. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  55936. /**
  55937. * Class for creating a cube texture
  55938. */
  55939. var CubeTexture = /** @class */ (function (_super) {
  55940. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTexture, _super);
  55941. /**
  55942. * Creates a cube texture to use with reflection for instance. It can be based upon dds or six images as well
  55943. * as prefiltered data.
  55944. * @param rootUrl defines the url of the texture or the root name of the six images
  55945. * @param scene defines the scene the texture is attached to
  55946. * @param extensions defines the suffixes add to the picture name in case six images are in use like _px.jpg...
  55947. * @param noMipmap defines if mipmaps should be created or not
  55948. * @param files defines the six files to load for the different faces
  55949. * @param onLoad defines a callback triggered at the end of the file load if no errors occured
  55950. * @param onError defines a callback triggered in case of error during load
  55951. * @param format defines the internal format to use for the texture once loaded
  55952. * @param prefiltered defines whether or not the texture is created from prefiltered data
  55953. * @param forcedExtension defines the extensions to use (force a special type of file to load) in case it is different from the file name
  55954. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  55955. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  55956. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  55957. * @return the cube texture
  55958. */
  55959. function CubeTexture(rootUrl, scene, extensions, noMipmap, files, onLoad, onError, format, prefiltered, forcedExtension, createPolynomials, lodScale, lodOffset) {
  55960. if (extensions === void 0) { extensions = null; }
  55961. if (noMipmap === void 0) { noMipmap = false; }
  55962. if (files === void 0) { files = null; }
  55963. if (onLoad === void 0) { onLoad = null; }
  55964. if (onError === void 0) { onError = null; }
  55965. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  55966. if (prefiltered === void 0) { prefiltered = false; }
  55967. if (forcedExtension === void 0) { forcedExtension = null; }
  55968. if (createPolynomials === void 0) { createPolynomials = false; }
  55969. if (lodScale === void 0) { lodScale = 0.8; }
  55970. if (lodOffset === void 0) { lodOffset = 0; }
  55971. var _this = _super.call(this, scene) || this;
  55972. /**
  55973. * Gets or sets the center of the bounding box associated with the cube texture.
  55974. * It must define where the camera used to render the texture was set
  55975. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  55976. */
  55977. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  55978. _this._rotationY = 0;
  55979. /** @hidden */
  55980. _this._prefiltered = false;
  55981. _this.name = rootUrl;
  55982. _this.url = rootUrl;
  55983. _this._noMipmap = noMipmap;
  55984. _this.hasAlpha = false;
  55985. _this._format = format;
  55986. _this.isCube = true;
  55987. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  55988. _this._createPolynomials = createPolynomials;
  55989. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].CUBIC_MODE;
  55990. if (!rootUrl && !files) {
  55991. return _this;
  55992. }
  55993. var lastDot = rootUrl.lastIndexOf(".");
  55994. var extension = forcedExtension ? forcedExtension : (lastDot > -1 ? rootUrl.substring(lastDot).toLowerCase() : "");
  55995. var isDDS = (extension === ".dds");
  55996. var isEnv = (extension === ".env");
  55997. if (isEnv) {
  55998. _this.gammaSpace = false;
  55999. _this._prefiltered = false;
  56000. }
  56001. else {
  56002. _this._prefiltered = prefiltered;
  56003. if (prefiltered) {
  56004. _this.gammaSpace = false;
  56005. }
  56006. }
  56007. _this._texture = _this._getFromCache(rootUrl, noMipmap);
  56008. if (!files) {
  56009. if (!isEnv && !isDDS && !extensions) {
  56010. extensions = ["_px.jpg", "_py.jpg", "_pz.jpg", "_nx.jpg", "_ny.jpg", "_nz.jpg"];
  56011. }
  56012. files = [];
  56013. if (extensions) {
  56014. for (var index = 0; index < extensions.length; index++) {
  56015. files.push(rootUrl + extensions[index]);
  56016. }
  56017. }
  56018. }
  56019. _this._files = files;
  56020. if (!_this._texture) {
  56021. if (!scene.useDelayedTextureLoading) {
  56022. if (prefiltered) {
  56023. _this._texture = scene.getEngine().createPrefilteredCubeTexture(rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, _this._createPolynomials);
  56024. }
  56025. else {
  56026. _this._texture = scene.getEngine().createCubeTexture(rootUrl, scene, files, noMipmap, onLoad, onError, _this._format, forcedExtension, false, lodScale, lodOffset);
  56027. }
  56028. }
  56029. else {
  56030. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  56031. }
  56032. }
  56033. else if (onLoad) {
  56034. if (_this._texture.isReady) {
  56035. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetImmediate(function () { return onLoad(); });
  56036. }
  56037. else {
  56038. _this._texture.onLoadedObservable.add(onLoad);
  56039. }
  56040. }
  56041. return _this;
  56042. }
  56043. Object.defineProperty(CubeTexture.prototype, "boundingBoxSize", {
  56044. /**
  56045. * Returns the bounding box size
  56046. * @see http://doc.babylonjs.com/how_to/reflect#using-local-cubemap-mode
  56047. */
  56048. get: function () {
  56049. return this._boundingBoxSize;
  56050. },
  56051. /**
  56052. * Gets or sets the size of the bounding box associated with the cube texture
  56053. * When defined, the cubemap will switch to local mode
  56054. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56055. * @example https://www.babylonjs-playground.com/#RNASML
  56056. */
  56057. set: function (value) {
  56058. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56059. return;
  56060. }
  56061. this._boundingBoxSize = value;
  56062. var scene = this.getScene();
  56063. if (scene) {
  56064. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  56065. }
  56066. },
  56067. enumerable: true,
  56068. configurable: true
  56069. });
  56070. Object.defineProperty(CubeTexture.prototype, "rotationY", {
  56071. /**
  56072. * Gets texture matrix rotation angle around Y axis radians.
  56073. */
  56074. get: function () {
  56075. return this._rotationY;
  56076. },
  56077. /**
  56078. * Sets texture matrix rotation angle around Y axis in radians.
  56079. */
  56080. set: function (value) {
  56081. this._rotationY = value;
  56082. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationY(this._rotationY));
  56083. },
  56084. enumerable: true,
  56085. configurable: true
  56086. });
  56087. Object.defineProperty(CubeTexture.prototype, "noMipmap", {
  56088. /**
  56089. * Are mip maps generated for this texture or not.
  56090. */
  56091. get: function () {
  56092. return this._noMipmap;
  56093. },
  56094. enumerable: true,
  56095. configurable: true
  56096. });
  56097. /**
  56098. * Creates a cube texture from an array of image urls
  56099. * @param files defines an array of image urls
  56100. * @param scene defines the hosting scene
  56101. * @param noMipmap specifies if mip maps are not used
  56102. * @returns a cube texture
  56103. */
  56104. CubeTexture.CreateFromImages = function (files, scene, noMipmap) {
  56105. var rootUrlKey = "";
  56106. files.forEach(function (url) { return rootUrlKey += url; });
  56107. return new CubeTexture(rootUrlKey, scene, null, noMipmap, files);
  56108. };
  56109. /**
  56110. * Creates and return a texture created from prefilterd data by tools like IBL Baker or Lys.
  56111. * @param url defines the url of the prefiltered texture
  56112. * @param scene defines the scene the texture is attached to
  56113. * @param forcedExtension defines the extension of the file if different from the url
  56114. * @param createPolynomials defines whether or not to create polynomial harmonics from the texture data if necessary
  56115. * @return the prefiltered texture
  56116. */
  56117. CubeTexture.CreateFromPrefilteredData = function (url, scene, forcedExtension, createPolynomials) {
  56118. if (forcedExtension === void 0) { forcedExtension = null; }
  56119. if (createPolynomials === void 0) { createPolynomials = true; }
  56120. return new CubeTexture(url, scene, null, false, null, null, null, undefined, true, forcedExtension, createPolynomials);
  56121. };
  56122. /**
  56123. * Get the current class name of the texture useful for serialization or dynamic coding.
  56124. * @returns "CubeTexture"
  56125. */
  56126. CubeTexture.prototype.getClassName = function () {
  56127. return "CubeTexture";
  56128. };
  56129. /**
  56130. * Update the url (and optional buffer) of this texture if url was null during construction.
  56131. * @param url the url of the texture
  56132. * @param forcedExtension defines the extension to use
  56133. * @param onLoad callback called when the texture is loaded (defaults to null)
  56134. */
  56135. CubeTexture.prototype.updateURL = function (url, forcedExtension, onLoad) {
  56136. if (this.url) {
  56137. this.releaseInternalTexture();
  56138. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  56139. }
  56140. this.url = url;
  56141. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  56142. this._prefiltered = false;
  56143. if (onLoad) {
  56144. this._delayedOnLoad = onLoad;
  56145. }
  56146. this.delayLoad(forcedExtension);
  56147. };
  56148. /**
  56149. * Delays loading of the cube texture
  56150. * @param forcedExtension defines the extension to use
  56151. */
  56152. CubeTexture.prototype.delayLoad = function (forcedExtension) {
  56153. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  56154. return;
  56155. }
  56156. var scene = this.getScene();
  56157. if (!scene) {
  56158. return;
  56159. }
  56160. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  56161. this._texture = this._getFromCache(this.url, this._noMipmap);
  56162. if (!this._texture) {
  56163. if (this._prefiltered) {
  56164. this._texture = scene.getEngine().createPrefilteredCubeTexture(this.url, scene, this.lodGenerationScale, this.lodGenerationOffset, this._delayedOnLoad, undefined, this._format, undefined, this._createPolynomials);
  56165. }
  56166. else {
  56167. this._texture = scene.getEngine().createCubeTexture(this.url, scene, this._files, this._noMipmap, this._delayedOnLoad, undefined, this._format, forcedExtension);
  56168. }
  56169. }
  56170. };
  56171. /**
  56172. * Returns the reflection texture matrix
  56173. * @returns the reflection texture matrix
  56174. */
  56175. CubeTexture.prototype.getReflectionTextureMatrix = function () {
  56176. return this._textureMatrix;
  56177. };
  56178. /**
  56179. * Sets the reflection texture matrix
  56180. * @param value Reflection texture matrix
  56181. */
  56182. CubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56183. var _this = this;
  56184. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56185. return;
  56186. }
  56187. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56188. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56189. }
  56190. this._textureMatrix = value;
  56191. };
  56192. /**
  56193. * Parses text to create a cube texture
  56194. * @param parsedTexture define the serialized text to read from
  56195. * @param scene defines the hosting scene
  56196. * @param rootUrl defines the root url of the cube texture
  56197. * @returns a cube texture
  56198. */
  56199. CubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56200. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  56201. var prefiltered = false;
  56202. if (parsedTexture.prefiltered) {
  56203. prefiltered = parsedTexture.prefiltered;
  56204. }
  56205. return new CubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.extensions, false, null, null, null, undefined, prefiltered);
  56206. }, parsedTexture, scene);
  56207. // Local Cubemaps
  56208. if (parsedTexture.boundingBoxPosition) {
  56209. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56210. }
  56211. if (parsedTexture.boundingBoxSize) {
  56212. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56213. }
  56214. // Animations
  56215. if (parsedTexture.animations) {
  56216. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  56217. var parsedAnimation = parsedTexture.animations[animationIndex];
  56218. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  56219. if (internalClass) {
  56220. texture.animations.push(internalClass.Parse(parsedAnimation));
  56221. }
  56222. }
  56223. }
  56224. return texture;
  56225. };
  56226. /**
  56227. * Makes a clone, or deep copy, of the cube texture
  56228. * @returns a new cube texture
  56229. */
  56230. CubeTexture.prototype.clone = function () {
  56231. var _this = this;
  56232. var scene = this.getScene();
  56233. var uniqueId = 0;
  56234. var newCubeTexture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  56235. if (!scene) {
  56236. return _this;
  56237. }
  56238. var cubeTexture = new CubeTexture(_this.url, scene, _this._extensions, _this._noMipmap, _this._files);
  56239. uniqueId = cubeTexture.uniqueId;
  56240. return cubeTexture;
  56241. }, this);
  56242. newCubeTexture.uniqueId = uniqueId;
  56243. return newCubeTexture;
  56244. };
  56245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("rotationY")
  56247. ], CubeTexture.prototype, "rotationY", null);
  56248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  56249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("textureMatrix")
  56250. ], CubeTexture.prototype, "_textureMatrix", void 0);
  56251. return CubeTexture;
  56252. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_4__["BaseTexture"]));
  56253. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"]._CubeTextureParser = CubeTexture.Parse;
  56254. // Some exporters relies on Tools.Instantiate
  56255. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].RegisteredTypes["BABYLON.CubeTexture"] = CubeTexture;
  56256. /***/ }),
  56257. /***/ "./Materials/Textures/dynamicTexture.ts":
  56258. /*!**********************************************!*\
  56259. !*** ./Materials/Textures/dynamicTexture.ts ***!
  56260. \**********************************************/
  56261. /*! exports provided: DynamicTexture */
  56262. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56263. "use strict";
  56264. __webpack_require__.r(__webpack_exports__);
  56265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return DynamicTexture; });
  56266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56267. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  56268. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56269. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56270. /**
  56271. * A class extending Texture allowing drawing on a texture
  56272. * @see http://doc.babylonjs.com/how_to/dynamictexture
  56273. */
  56274. var DynamicTexture = /** @class */ (function (_super) {
  56275. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DynamicTexture, _super);
  56276. /**
  56277. * Creates a DynamicTexture
  56278. * @param name defines the name of the texture
  56279. * @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
  56280. * @param scene defines the scene where you want the texture
  56281. * @param generateMipMaps defines the use of MinMaps or not (default is false)
  56282. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  56283. * @param format defines the texture format to use (default is Engine.TEXTUREFORMAT_RGBA)
  56284. */
  56285. function DynamicTexture(name, options, scene, generateMipMaps, samplingMode, format) {
  56286. if (scene === void 0) { scene = null; }
  56287. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  56288. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA; }
  56289. var _this = _super.call(this, null, scene, !generateMipMaps, undefined, samplingMode, undefined, undefined, undefined, undefined, format) || this;
  56290. _this.name = name;
  56291. _this._engine = _this.getScene().getEngine();
  56292. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  56293. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  56294. _this._generateMipMaps = generateMipMaps;
  56295. if (options.getContext) {
  56296. _this._canvas = options;
  56297. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  56298. }
  56299. else {
  56300. _this._canvas = document.createElement("canvas");
  56301. if (options.width || options.width === 0) {
  56302. _this._texture = _this._engine.createDynamicTexture(options.width, options.height, generateMipMaps, samplingMode);
  56303. }
  56304. else {
  56305. _this._texture = _this._engine.createDynamicTexture(options, options, generateMipMaps, samplingMode);
  56306. }
  56307. }
  56308. var textureSize = _this.getSize();
  56309. _this._canvas.width = textureSize.width;
  56310. _this._canvas.height = textureSize.height;
  56311. _this._context = _this._canvas.getContext("2d");
  56312. return _this;
  56313. }
  56314. /**
  56315. * Get the current class name of the texture useful for serialization or dynamic coding.
  56316. * @returns "DynamicTexture"
  56317. */
  56318. DynamicTexture.prototype.getClassName = function () {
  56319. return "DynamicTexture";
  56320. };
  56321. Object.defineProperty(DynamicTexture.prototype, "canRescale", {
  56322. /**
  56323. * Gets the current state of canRescale
  56324. */
  56325. get: function () {
  56326. return true;
  56327. },
  56328. enumerable: true,
  56329. configurable: true
  56330. });
  56331. DynamicTexture.prototype._recreate = function (textureSize) {
  56332. this._canvas.width = textureSize.width;
  56333. this._canvas.height = textureSize.height;
  56334. this.releaseInternalTexture();
  56335. this._texture = this._engine.createDynamicTexture(textureSize.width, textureSize.height, this._generateMipMaps, this.samplingMode);
  56336. };
  56337. /**
  56338. * Scales the texture
  56339. * @param ratio the scale factor to apply to both width and height
  56340. */
  56341. DynamicTexture.prototype.scale = function (ratio) {
  56342. var textureSize = this.getSize();
  56343. textureSize.width *= ratio;
  56344. textureSize.height *= ratio;
  56345. this._recreate(textureSize);
  56346. };
  56347. /**
  56348. * Resizes the texture
  56349. * @param width the new width
  56350. * @param height the new height
  56351. */
  56352. DynamicTexture.prototype.scaleTo = function (width, height) {
  56353. var textureSize = this.getSize();
  56354. textureSize.width = width;
  56355. textureSize.height = height;
  56356. this._recreate(textureSize);
  56357. };
  56358. /**
  56359. * Gets the context of the canvas used by the texture
  56360. * @returns the canvas context of the dynamic texture
  56361. */
  56362. DynamicTexture.prototype.getContext = function () {
  56363. return this._context;
  56364. };
  56365. /**
  56366. * Clears the texture
  56367. */
  56368. DynamicTexture.prototype.clear = function () {
  56369. var size = this.getSize();
  56370. this._context.fillRect(0, 0, size.width, size.height);
  56371. };
  56372. /**
  56373. * Updates the texture
  56374. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  56375. * @param premulAlpha defines if alpha is stored as premultiplied (default is false)
  56376. */
  56377. DynamicTexture.prototype.update = function (invertY, premulAlpha) {
  56378. if (premulAlpha === void 0) { premulAlpha = false; }
  56379. this._engine.updateDynamicTexture(this._texture, this._canvas, invertY === undefined ? true : invertY, premulAlpha, this._format || undefined);
  56380. };
  56381. /**
  56382. * Draws text onto the texture
  56383. * @param text defines the text to be drawn
  56384. * @param x defines the placement of the text from the left
  56385. * @param y defines the placement of the text from the top when invertY is true and from the bottom when false
  56386. * @param font defines the font to be used with font-style, font-size, font-name
  56387. * @param color defines the color used for the text
  56388. * @param clearColor defines the color for the canvas, use null to not overwrite canvas
  56389. * @param invertY defines the direction for the Y axis (default is true - y increases downwards)
  56390. * @param update defines whether texture is immediately update (default is true)
  56391. */
  56392. DynamicTexture.prototype.drawText = function (text, x, y, font, color, clearColor, invertY, update) {
  56393. if (update === void 0) { update = true; }
  56394. var size = this.getSize();
  56395. if (clearColor) {
  56396. this._context.fillStyle = clearColor;
  56397. this._context.fillRect(0, 0, size.width, size.height);
  56398. }
  56399. this._context.font = font;
  56400. if (x === null || x === undefined) {
  56401. var textSize = this._context.measureText(text);
  56402. x = (size.width - textSize.width) / 2;
  56403. }
  56404. if (y === null || y === undefined) {
  56405. var fontSize = parseInt((font.replace(/\D/g, '')));
  56406. y = (size.height / 2) + (fontSize / 3.65);
  56407. }
  56408. this._context.fillStyle = color;
  56409. this._context.fillText(text, x, y);
  56410. if (update) {
  56411. this.update(invertY);
  56412. }
  56413. };
  56414. /**
  56415. * Clones the texture
  56416. * @returns the clone of the texture.
  56417. */
  56418. DynamicTexture.prototype.clone = function () {
  56419. var scene = this.getScene();
  56420. if (!scene) {
  56421. return this;
  56422. }
  56423. var textureSize = this.getSize();
  56424. var newTexture = new DynamicTexture(this.name, textureSize, scene, this._generateMipMaps);
  56425. // Base texture
  56426. newTexture.hasAlpha = this.hasAlpha;
  56427. newTexture.level = this.level;
  56428. // Dynamic Texture
  56429. newTexture.wrapU = this.wrapU;
  56430. newTexture.wrapV = this.wrapV;
  56431. return newTexture;
  56432. };
  56433. /**
  56434. * Serializes the dynamic texture. The scene should be ready before the dynamic texture is serialized
  56435. * @returns a serialized dynamic texture object
  56436. */
  56437. DynamicTexture.prototype.serialize = function () {
  56438. var scene = this.getScene();
  56439. if (scene && !scene.isReady()) {
  56440. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The scene must be ready before serializing the dynamic texture");
  56441. }
  56442. var serializationObject = _super.prototype.serialize.call(this);
  56443. serializationObject.base64String = this._canvas.toDataURL();
  56444. serializationObject.invertY = this._invertY;
  56445. serializationObject.samplingMode = this.samplingMode;
  56446. return serializationObject;
  56447. };
  56448. /** @hidden */
  56449. DynamicTexture.prototype._rebuild = function () {
  56450. this.update();
  56451. };
  56452. return DynamicTexture;
  56453. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]));
  56454. /***/ }),
  56455. /***/ "./Materials/Textures/hdrCubeTexture.ts":
  56456. /*!**********************************************!*\
  56457. !*** ./Materials/Textures/hdrCubeTexture.ts ***!
  56458. \**********************************************/
  56459. /*! exports provided: HDRCubeTexture */
  56460. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56461. "use strict";
  56462. __webpack_require__.r(__webpack_exports__);
  56463. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return HDRCubeTexture; });
  56464. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  56465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  56466. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/engine */ "./Engines/engine.ts");
  56467. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  56468. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  56469. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56470. /* harmony import */ var _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/hdr */ "./Misc/HighDynamicRange/hdr.ts");
  56471. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  56472. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  56473. /**
  56474. * This represents a texture coming from an HDR input.
  56475. *
  56476. * The only supported format is currently panorama picture stored in RGBE format.
  56477. * Example of such files can be found on HDRLib: http://hdrlib.com/
  56478. */
  56479. var HDRCubeTexture = /** @class */ (function (_super) {
  56480. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTexture, _super);
  56481. /**
  56482. * Instantiates an HDRTexture from the following parameters.
  56483. *
  56484. * @param url The location of the HDR raw data (Panorama stored in RGBE format)
  56485. * @param scene The scene the texture will be used in
  56486. * @param size The cubemap desired size (the more it increases the longer the generation will be)
  56487. * @param noMipmap Forces to not generate the mipmap if true
  56488. * @param generateHarmonics Specifies whether you want to extract the polynomial harmonics during the generation process
  56489. * @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)
  56490. * @param reserved Reserved flag for internal use.
  56491. */
  56492. function HDRCubeTexture(url, scene, size, noMipmap, generateHarmonics, gammaSpace, reserved, onLoad, onError) {
  56493. if (noMipmap === void 0) { noMipmap = false; }
  56494. if (generateHarmonics === void 0) { generateHarmonics = true; }
  56495. if (gammaSpace === void 0) { gammaSpace = false; }
  56496. if (reserved === void 0) { reserved = false; }
  56497. if (onLoad === void 0) { onLoad = null; }
  56498. if (onError === void 0) { onError = null; }
  56499. var _this = _super.call(this, scene) || this;
  56500. _this._generateHarmonics = true;
  56501. _this._onLoad = null;
  56502. _this._onError = null;
  56503. /**
  56504. * The texture coordinates mode. As this texture is stored in a cube format, please modify carefully.
  56505. */
  56506. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CUBIC_MODE;
  56507. _this._isBlocking = true;
  56508. _this._rotationY = 0;
  56509. /**
  56510. * Gets or sets the center of the bounding box associated with the cube texture
  56511. * It must define where the camera used to render the texture was set
  56512. */
  56513. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  56514. if (!url) {
  56515. return _this;
  56516. }
  56517. _this.name = url;
  56518. _this.url = url;
  56519. _this.hasAlpha = false;
  56520. _this.isCube = true;
  56521. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  56522. _this._onLoad = onLoad;
  56523. _this._onError = onError;
  56524. _this.gammaSpace = gammaSpace;
  56525. _this._noMipmap = noMipmap;
  56526. _this._size = size;
  56527. _this._texture = _this._getFromCache(url, _this._noMipmap);
  56528. if (!_this._texture) {
  56529. if (!scene.useDelayedTextureLoading) {
  56530. _this.loadTexture();
  56531. }
  56532. else {
  56533. _this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED;
  56534. }
  56535. }
  56536. return _this;
  56537. }
  56538. Object.defineProperty(HDRCubeTexture.prototype, "isBlocking", {
  56539. /**
  56540. * Gets wether or not the texture is blocking during loading.
  56541. */
  56542. get: function () {
  56543. return this._isBlocking;
  56544. },
  56545. /**
  56546. * Sets wether or not the texture is blocking during loading.
  56547. */
  56548. set: function (value) {
  56549. this._isBlocking = value;
  56550. },
  56551. enumerable: true,
  56552. configurable: true
  56553. });
  56554. Object.defineProperty(HDRCubeTexture.prototype, "rotationY", {
  56555. /**
  56556. * Gets texture matrix rotation angle around Y axis radians.
  56557. */
  56558. get: function () {
  56559. return this._rotationY;
  56560. },
  56561. /**
  56562. * Sets texture matrix rotation angle around Y axis in radians.
  56563. */
  56564. set: function (value) {
  56565. this._rotationY = value;
  56566. this.setReflectionTextureMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].RotationY(this._rotationY));
  56567. },
  56568. enumerable: true,
  56569. configurable: true
  56570. });
  56571. Object.defineProperty(HDRCubeTexture.prototype, "boundingBoxSize", {
  56572. get: function () {
  56573. return this._boundingBoxSize;
  56574. },
  56575. /**
  56576. * Gets or sets the size of the bounding box associated with the cube texture
  56577. * When defined, the cubemap will switch to local mode
  56578. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  56579. * @example https://www.babylonjs-playground.com/#RNASML
  56580. */
  56581. set: function (value) {
  56582. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  56583. return;
  56584. }
  56585. this._boundingBoxSize = value;
  56586. var scene = this.getScene();
  56587. if (scene) {
  56588. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag);
  56589. }
  56590. },
  56591. enumerable: true,
  56592. configurable: true
  56593. });
  56594. /**
  56595. * Get the current class name of the texture useful for serialization or dynamic coding.
  56596. * @returns "HDRCubeTexture"
  56597. */
  56598. HDRCubeTexture.prototype.getClassName = function () {
  56599. return "HDRCubeTexture";
  56600. };
  56601. /**
  56602. * Occurs when the file is raw .hdr file.
  56603. */
  56604. HDRCubeTexture.prototype.loadTexture = function () {
  56605. var _this = this;
  56606. var callback = function (buffer) {
  56607. _this.lodGenerationOffset = 0.0;
  56608. _this.lodGenerationScale = 0.8;
  56609. var scene = _this.getScene();
  56610. if (!scene) {
  56611. return null;
  56612. }
  56613. // Extract the raw linear data.
  56614. var data = _Misc_HighDynamicRange_hdr__WEBPACK_IMPORTED_MODULE_6__["HDRTools"].GetCubeMapTextureData(buffer, _this._size);
  56615. // Generate harmonics if needed.
  56616. if (_this._generateHarmonics) {
  56617. var sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial(data);
  56618. _this.sphericalPolynomial = sphericalPolynomial;
  56619. }
  56620. var results = [];
  56621. var byteArray = null;
  56622. // Push each faces.
  56623. for (var j = 0; j < 6; j++) {
  56624. // Create uintarray fallback.
  56625. if (!scene.getEngine().getCaps().textureFloat) {
  56626. // 3 channels of 1 bytes per pixel in bytes.
  56627. var byteBuffer = new ArrayBuffer(_this._size * _this._size * 3);
  56628. byteArray = new Uint8Array(byteBuffer);
  56629. }
  56630. var dataFace = (data[HDRCubeTexture._facesMapping[j]]);
  56631. // If special cases.
  56632. if (_this.gammaSpace || byteArray) {
  56633. for (var i = 0; i < _this._size * _this._size; i++) {
  56634. // Put in gamma space if requested.
  56635. if (_this.gammaSpace) {
  56636. dataFace[(i * 3) + 0] = Math.pow(dataFace[(i * 3) + 0], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56637. dataFace[(i * 3) + 1] = Math.pow(dataFace[(i * 3) + 1], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56638. dataFace[(i * 3) + 2] = Math.pow(dataFace[(i * 3) + 2], _Maths_math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]);
  56639. }
  56640. // Convert to int texture for fallback.
  56641. if (byteArray) {
  56642. var r = Math.max(dataFace[(i * 3) + 0] * 255, 0);
  56643. var g = Math.max(dataFace[(i * 3) + 1] * 255, 0);
  56644. var b = Math.max(dataFace[(i * 3) + 2] * 255, 0);
  56645. // May use luminance instead if the result is not accurate.
  56646. var max = Math.max(Math.max(r, g), b);
  56647. if (max > 255) {
  56648. var scale = 255 / max;
  56649. r *= scale;
  56650. g *= scale;
  56651. b *= scale;
  56652. }
  56653. byteArray[(i * 3) + 0] = r;
  56654. byteArray[(i * 3) + 1] = g;
  56655. byteArray[(i * 3) + 2] = b;
  56656. }
  56657. }
  56658. }
  56659. if (byteArray) {
  56660. results.push(byteArray);
  56661. }
  56662. else {
  56663. results.push(dataFace);
  56664. }
  56665. }
  56666. return results;
  56667. };
  56668. var scene = this.getScene();
  56669. if (scene) {
  56670. 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);
  56671. }
  56672. };
  56673. HDRCubeTexture.prototype.clone = function () {
  56674. var scene = this.getScene();
  56675. if (!scene) {
  56676. return this;
  56677. }
  56678. var newTexture = new HDRCubeTexture(this.url, scene, this._size, this._noMipmap, this._generateHarmonics, this.gammaSpace);
  56679. // Base texture
  56680. newTexture.level = this.level;
  56681. newTexture.wrapU = this.wrapU;
  56682. newTexture.wrapV = this.wrapV;
  56683. newTexture.coordinatesIndex = this.coordinatesIndex;
  56684. newTexture.coordinatesMode = this.coordinatesMode;
  56685. return newTexture;
  56686. };
  56687. // Methods
  56688. HDRCubeTexture.prototype.delayLoad = function () {
  56689. if (this.delayLoadState !== _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_NOTLOADED) {
  56690. return;
  56691. }
  56692. this.delayLoadState = _Engines_engine__WEBPACK_IMPORTED_MODULE_2__["Engine"].DELAYLOADSTATE_LOADED;
  56693. this._texture = this._getFromCache(this.url, this._noMipmap);
  56694. if (!this._texture) {
  56695. this.loadTexture();
  56696. }
  56697. };
  56698. /**
  56699. * Get the texture reflection matrix used to rotate/transform the reflection.
  56700. * @returns the reflection matrix
  56701. */
  56702. HDRCubeTexture.prototype.getReflectionTextureMatrix = function () {
  56703. return this._textureMatrix;
  56704. };
  56705. /**
  56706. * Set the texture reflection matrix used to rotate/transform the reflection.
  56707. * @param value Define the reflection matrix to set
  56708. */
  56709. HDRCubeTexture.prototype.setReflectionTextureMatrix = function (value) {
  56710. var _this = this;
  56711. this._textureMatrix = value;
  56712. if (value.updateFlag === this._textureMatrix.updateFlag) {
  56713. return;
  56714. }
  56715. if (value.isIdentity() !== this._textureMatrix.isIdentity()) {
  56716. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) { return mat.getActiveTextures().indexOf(_this) !== -1; });
  56717. }
  56718. };
  56719. /**
  56720. * Parses a JSON representation of an HDR Texture in order to create the texture
  56721. * @param parsedTexture Define the JSON representation
  56722. * @param scene Define the scene the texture should be created in
  56723. * @param rootUrl Define the root url in case we need to load relative dependencies
  56724. * @returns the newly created texture after parsing
  56725. */
  56726. HDRCubeTexture.Parse = function (parsedTexture, scene, rootUrl) {
  56727. var texture = null;
  56728. if (parsedTexture.name && !parsedTexture.isRenderTarget) {
  56729. texture = new HDRCubeTexture(rootUrl + parsedTexture.name, scene, parsedTexture.size, parsedTexture.noMipmap, parsedTexture.generateHarmonics, parsedTexture.useInGammaSpace);
  56730. texture.name = parsedTexture.name;
  56731. texture.hasAlpha = parsedTexture.hasAlpha;
  56732. texture.level = parsedTexture.level;
  56733. texture.coordinatesMode = parsedTexture.coordinatesMode;
  56734. texture.isBlocking = parsedTexture.isBlocking;
  56735. }
  56736. if (texture) {
  56737. if (parsedTexture.boundingBoxPosition) {
  56738. texture.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxPosition);
  56739. }
  56740. if (parsedTexture.boundingBoxSize) {
  56741. texture.boundingBoxSize = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(parsedTexture.boundingBoxSize);
  56742. }
  56743. if (parsedTexture.rotationY) {
  56744. texture.rotationY = parsedTexture.rotationY;
  56745. }
  56746. }
  56747. return texture;
  56748. };
  56749. HDRCubeTexture.prototype.serialize = function () {
  56750. if (!this.name) {
  56751. return null;
  56752. }
  56753. var serializationObject = {};
  56754. serializationObject.name = this.name;
  56755. serializationObject.hasAlpha = this.hasAlpha;
  56756. serializationObject.isCube = true;
  56757. serializationObject.level = this.level;
  56758. serializationObject.size = this._size;
  56759. serializationObject.coordinatesMode = this.coordinatesMode;
  56760. serializationObject.useInGammaSpace = this.gammaSpace;
  56761. serializationObject.generateHarmonics = this._generateHarmonics;
  56762. serializationObject.customType = "BABYLON.HDRCubeTexture";
  56763. serializationObject.noMipmap = this._noMipmap;
  56764. serializationObject.isBlocking = this._isBlocking;
  56765. serializationObject.rotationY = this._rotationY;
  56766. return serializationObject;
  56767. };
  56768. HDRCubeTexture._facesMapping = [
  56769. "right",
  56770. "left",
  56771. "up",
  56772. "down",
  56773. "front",
  56774. "back"
  56775. ];
  56776. return HDRCubeTexture;
  56777. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_3__["BaseTexture"]));
  56778. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.HDRCubeTexture"] = HDRCubeTexture;
  56779. /***/ }),
  56780. /***/ "./Materials/Textures/index.ts":
  56781. /*!*************************************!*\
  56782. !*** ./Materials/Textures/index.ts ***!
  56783. \*************************************/
  56784. /*! exports provided: BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  56785. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56786. "use strict";
  56787. __webpack_require__.r(__webpack_exports__);
  56788. /* harmony import */ var _baseTexture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseTexture */ "./Materials/Textures/baseTexture.ts");
  56789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _baseTexture__WEBPACK_IMPORTED_MODULE_0__["BaseTexture"]; });
  56790. /* harmony import */ var _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorGradingTexture */ "./Materials/Textures/colorGradingTexture.ts");
  56791. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _colorGradingTexture__WEBPACK_IMPORTED_MODULE_1__["ColorGradingTexture"]; });
  56792. /* harmony import */ var _cubeTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  56793. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _cubeTexture__WEBPACK_IMPORTED_MODULE_2__["CubeTexture"]; });
  56794. /* harmony import */ var _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  56795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _dynamicTexture__WEBPACK_IMPORTED_MODULE_3__["DynamicTexture"]; });
  56796. /* harmony import */ var _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  56797. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _hdrCubeTexture__WEBPACK_IMPORTED_MODULE_4__["HDRCubeTexture"]; });
  56798. /* harmony import */ var _internalTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./internalTexture */ "./Materials/Textures/internalTexture.ts");
  56799. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _internalTexture__WEBPACK_IMPORTED_MODULE_5__["InternalTexture"]; });
  56800. /* harmony import */ var _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./internalTextureTracker */ "./Materials/Textures/internalTextureTracker.ts");
  56801. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _internalTextureTracker__WEBPACK_IMPORTED_MODULE_6__["DummyInternalTextureTracker"]; });
  56802. /* harmony import */ var _Loaders_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Loaders/index */ "./Materials/Textures/Loaders/index.ts");
  56803. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_DDSTextureLoader"]; });
  56804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_ENVTextureLoader"]; });
  56805. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_KTXTextureLoader"]; });
  56806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Loaders_index__WEBPACK_IMPORTED_MODULE_7__["_TGATextureLoader"]; });
  56807. /* harmony import */ var _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mirrorTexture */ "./Materials/Textures/mirrorTexture.ts");
  56808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _mirrorTexture__WEBPACK_IMPORTED_MODULE_8__["MirrorTexture"]; });
  56809. /* harmony import */ var _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  56810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _multiRenderTarget__WEBPACK_IMPORTED_MODULE_9__["MultiRenderTarget"]; });
  56811. /* harmony import */ var _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Procedurals/index */ "./Materials/Textures/Procedurals/index.ts");
  56812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTexture"]; });
  56813. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["CustomProceduralTexture"]; });
  56814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["NoiseProceduralTexture"]; });
  56815. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Procedurals_index__WEBPACK_IMPORTED_MODULE_10__["ProceduralTextureSceneComponent"]; });
  56816. /* harmony import */ var _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./rawCubeTexture */ "./Materials/Textures/rawCubeTexture.ts");
  56817. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _rawCubeTexture__WEBPACK_IMPORTED_MODULE_11__["RawCubeTexture"]; });
  56818. /* harmony import */ var _rawTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./rawTexture */ "./Materials/Textures/rawTexture.ts");
  56819. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _rawTexture__WEBPACK_IMPORTED_MODULE_12__["RawTexture"]; });
  56820. /* harmony import */ var _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./rawTexture3D */ "./Materials/Textures/rawTexture3D.ts");
  56821. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _rawTexture3D__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  56822. /* harmony import */ var _refractionTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./refractionTexture */ "./Materials/Textures/refractionTexture.ts");
  56823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _refractionTexture__WEBPACK_IMPORTED_MODULE_14__["RefractionTexture"]; });
  56824. /* harmony import */ var _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  56825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _renderTargetTexture__WEBPACK_IMPORTED_MODULE_15__["RenderTargetTexture"]; });
  56826. /* harmony import */ var _texture__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./texture */ "./Materials/Textures/texture.ts");
  56827. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _texture__WEBPACK_IMPORTED_MODULE_16__["Texture"]; });
  56828. /* harmony import */ var _videoTexture__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./videoTexture */ "./Materials/Textures/videoTexture.ts");
  56829. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _videoTexture__WEBPACK_IMPORTED_MODULE_17__["VideoTexture"]; });
  56830. /***/ }),
  56831. /***/ "./Materials/Textures/internalTexture.ts":
  56832. /*!***********************************************!*\
  56833. !*** ./Materials/Textures/internalTexture.ts ***!
  56834. \***********************************************/
  56835. /*! exports provided: InternalTexture */
  56836. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  56837. "use strict";
  56838. __webpack_require__.r(__webpack_exports__);
  56839. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return InternalTexture; });
  56840. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  56841. /* harmony import */ var _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetCreationOptions */ "./Materials/Textures/renderTargetCreationOptions.ts");
  56842. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  56843. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  56844. /**
  56845. * Class used to store data associated with WebGL texture data for the engine
  56846. * This class should not be used directly
  56847. */
  56848. var InternalTexture = /** @class */ (function () {
  56849. /**
  56850. * Creates a new InternalTexture
  56851. * @param engine defines the engine to use
  56852. * @param dataSource defines the type of data that will be used
  56853. * @param delayAllocation if the texture allocation should be delayed (default: false)
  56854. */
  56855. function InternalTexture(engine, dataSource, delayAllocation) {
  56856. if (delayAllocation === void 0) { delayAllocation = false; }
  56857. /**
  56858. * Observable called when the texture is loaded
  56859. */
  56860. this.onLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  56861. /**
  56862. * Gets or set the previous tracker in the list
  56863. */
  56864. this.previous = null;
  56865. /**
  56866. * Gets or set the next tracker in the list
  56867. */
  56868. this.next = null;
  56869. // Private
  56870. /** @hidden */
  56871. this._invertVScale = false;
  56872. /** @hidden */
  56873. this._initialSlot = -1;
  56874. /** @hidden */
  56875. this._designatedSlot = -1;
  56876. /** @hidden */
  56877. this._dataSource = InternalTexture.DATASOURCE_UNKNOWN;
  56878. /** @hidden */
  56879. this._comparisonFunction = 0;
  56880. /** @hidden */
  56881. this._sphericalPolynomial = null;
  56882. /** @hidden */
  56883. this._lodGenerationScale = 0;
  56884. /** @hidden */
  56885. this._lodGenerationOffset = 0;
  56886. /** @hidden */
  56887. this._isRGBD = false;
  56888. /** @hidden */
  56889. this._references = 1;
  56890. this._engine = engine;
  56891. this._dataSource = dataSource;
  56892. if (!delayAllocation) {
  56893. this._webGLTexture = engine._createTexture();
  56894. }
  56895. }
  56896. /**
  56897. * Gets the Engine the texture belongs to.
  56898. * @returns The babylon engine
  56899. */
  56900. InternalTexture.prototype.getEngine = function () {
  56901. return this._engine;
  56902. };
  56903. Object.defineProperty(InternalTexture.prototype, "dataSource", {
  56904. /**
  56905. * Gets the data source type of the texture (can be one of the InternalTexture.DATASOURCE_XXXX)
  56906. */
  56907. get: function () {
  56908. return this._dataSource;
  56909. },
  56910. enumerable: true,
  56911. configurable: true
  56912. });
  56913. /**
  56914. * Increments the number of references (ie. the number of Texture that point to it)
  56915. */
  56916. InternalTexture.prototype.incrementReferences = function () {
  56917. this._references++;
  56918. };
  56919. /**
  56920. * Change the size of the texture (not the size of the content)
  56921. * @param width defines the new width
  56922. * @param height defines the new height
  56923. * @param depth defines the new depth (1 by default)
  56924. */
  56925. InternalTexture.prototype.updateSize = function (width, height, depth) {
  56926. if (depth === void 0) { depth = 1; }
  56927. this.width = width;
  56928. this.height = height;
  56929. this.depth = depth;
  56930. this.baseWidth = width;
  56931. this.baseHeight = height;
  56932. this.baseDepth = depth;
  56933. this._size = width * height * depth;
  56934. };
  56935. /** @hidden */
  56936. InternalTexture.prototype._rebuild = function () {
  56937. var _this = this;
  56938. var proxy;
  56939. this.isReady = false;
  56940. this._cachedCoordinatesMode = null;
  56941. this._cachedWrapU = null;
  56942. this._cachedWrapV = null;
  56943. this._cachedAnisotropicFilteringLevel = null;
  56944. switch (this._dataSource) {
  56945. case InternalTexture.DATASOURCE_TEMP:
  56946. return;
  56947. case InternalTexture.DATASOURCE_URL:
  56948. proxy = this._engine.createTexture(this.url, !this.generateMipMaps, this.invertY, null, this.samplingMode, function () {
  56949. proxy._swapAndDie(_this);
  56950. _this.isReady = true;
  56951. }, null, this._buffer, undefined, this.format);
  56952. return;
  56953. case InternalTexture.DATASOURCE_RAW:
  56954. proxy = this._engine.createRawTexture(this._bufferView, this.baseWidth, this.baseHeight, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56955. proxy._swapAndDie(this);
  56956. this.isReady = true;
  56957. return;
  56958. case InternalTexture.DATASOURCE_RAW3D:
  56959. proxy = this._engine.createRawTexture3D(this._bufferView, this.baseWidth, this.baseHeight, this.baseDepth, this.format, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  56960. proxy._swapAndDie(this);
  56961. this.isReady = true;
  56962. return;
  56963. case InternalTexture.DATASOURCE_DYNAMIC:
  56964. proxy = this._engine.createDynamicTexture(this.baseWidth, this.baseHeight, this.generateMipMaps, this.samplingMode);
  56965. proxy._swapAndDie(this);
  56966. this._engine.updateDynamicTexture(this, this._engine.getRenderingCanvas(), this.invertY, undefined, undefined, true);
  56967. // The engine will make sure to update content so no need to flag it as isReady = true
  56968. return;
  56969. case InternalTexture.DATASOURCE_RENDERTARGET:
  56970. var options = new _Materials_Textures_renderTargetCreationOptions__WEBPACK_IMPORTED_MODULE_1__["RenderTargetCreationOptions"]();
  56971. options.generateDepthBuffer = this._generateDepthBuffer;
  56972. options.generateMipMaps = this.generateMipMaps;
  56973. options.generateStencilBuffer = this._generateStencilBuffer;
  56974. options.samplingMode = this.samplingMode;
  56975. options.type = this.type;
  56976. if (this.isCube) {
  56977. proxy = this._engine.createRenderTargetCubeTexture(this.width, options);
  56978. }
  56979. else {
  56980. var size = {
  56981. width: this.width,
  56982. height: this.height
  56983. };
  56984. proxy = this._engine.createRenderTargetTexture(size, options);
  56985. }
  56986. proxy._swapAndDie(this);
  56987. this.isReady = true;
  56988. return;
  56989. case InternalTexture.DATASOURCE_DEPTHTEXTURE:
  56990. var depthTextureOptions = {
  56991. bilinearFiltering: this.samplingMode !== _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE,
  56992. comparisonFunction: this._comparisonFunction,
  56993. generateStencil: this._generateStencilBuffer,
  56994. isCube: this.isCube
  56995. };
  56996. proxy = this._engine.createDepthStencilTexture({ width: this.width, height: this.height }, depthTextureOptions);
  56997. proxy._swapAndDie(this);
  56998. this.isReady = true;
  56999. return;
  57000. case InternalTexture.DATASOURCE_CUBE:
  57001. proxy = this._engine.createCubeTexture(this.url, null, this._files, !this.generateMipMaps, function () {
  57002. proxy._swapAndDie(_this);
  57003. _this.isReady = true;
  57004. }, null, this.format, this._extension);
  57005. return;
  57006. case InternalTexture.DATASOURCE_CUBERAW:
  57007. proxy = this._engine.createRawCubeTexture(this._bufferViewArray, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57008. proxy._swapAndDie(this);
  57009. this.isReady = true;
  57010. return;
  57011. case InternalTexture.DATASOURCE_CUBERAW_RGBD:
  57012. proxy = this._engine.createRawCubeTexture(null, this.width, this.format, this.type, this.generateMipMaps, this.invertY, this.samplingMode, this._compression);
  57013. InternalTexture._UpdateRGBDAsync(proxy, this._bufferViewArrayArray, this._sphericalPolynomial, this._lodGenerationScale, this._lodGenerationOffset).then(function () {
  57014. proxy._swapAndDie(_this);
  57015. _this.isReady = true;
  57016. });
  57017. return;
  57018. case InternalTexture.DATASOURCE_CUBEPREFILTERED:
  57019. proxy = this._engine.createPrefilteredCubeTexture(this.url, null, this._lodGenerationScale, this._lodGenerationOffset, function (proxy) {
  57020. if (proxy) {
  57021. proxy._swapAndDie(_this);
  57022. }
  57023. _this.isReady = true;
  57024. }, null, this.format, this._extension);
  57025. proxy._sphericalPolynomial = this._sphericalPolynomial;
  57026. return;
  57027. }
  57028. };
  57029. /** @hidden */
  57030. InternalTexture.prototype._swapAndDie = function (target) {
  57031. target._webGLTexture = this._webGLTexture;
  57032. if (this._framebuffer) {
  57033. target._framebuffer = this._framebuffer;
  57034. }
  57035. if (this._depthStencilBuffer) {
  57036. target._depthStencilBuffer = this._depthStencilBuffer;
  57037. }
  57038. if (this._lodTextureHigh) {
  57039. if (target._lodTextureHigh) {
  57040. target._lodTextureHigh.dispose();
  57041. }
  57042. target._lodTextureHigh = this._lodTextureHigh;
  57043. }
  57044. if (this._lodTextureMid) {
  57045. if (target._lodTextureMid) {
  57046. target._lodTextureMid.dispose();
  57047. }
  57048. target._lodTextureMid = this._lodTextureMid;
  57049. }
  57050. if (this._lodTextureLow) {
  57051. if (target._lodTextureLow) {
  57052. target._lodTextureLow.dispose();
  57053. }
  57054. target._lodTextureLow = this._lodTextureLow;
  57055. }
  57056. var cache = this._engine.getLoadedTexturesCache();
  57057. var index = cache.indexOf(this);
  57058. if (index !== -1) {
  57059. cache.splice(index, 1);
  57060. }
  57061. };
  57062. /**
  57063. * Dispose the current allocated resources
  57064. */
  57065. InternalTexture.prototype.dispose = function () {
  57066. if (!this._webGLTexture) {
  57067. return;
  57068. }
  57069. this._references--;
  57070. if (this._references === 0) {
  57071. this._engine._releaseTexture(this);
  57072. this._webGLTexture = null;
  57073. this.previous = null;
  57074. this.next = null;
  57075. }
  57076. };
  57077. /** hidden */
  57078. InternalTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57079. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("environmentTextureTools");
  57080. };
  57081. /**
  57082. * The source of the texture data is unknown
  57083. */
  57084. InternalTexture.DATASOURCE_UNKNOWN = 0;
  57085. /**
  57086. * Texture data comes from an URL
  57087. */
  57088. InternalTexture.DATASOURCE_URL = 1;
  57089. /**
  57090. * Texture data is only used for temporary storage
  57091. */
  57092. InternalTexture.DATASOURCE_TEMP = 2;
  57093. /**
  57094. * Texture data comes from raw data (ArrayBuffer)
  57095. */
  57096. InternalTexture.DATASOURCE_RAW = 3;
  57097. /**
  57098. * Texture content is dynamic (video or dynamic texture)
  57099. */
  57100. InternalTexture.DATASOURCE_DYNAMIC = 4;
  57101. /**
  57102. * Texture content is generated by rendering to it
  57103. */
  57104. InternalTexture.DATASOURCE_RENDERTARGET = 5;
  57105. /**
  57106. * Texture content is part of a multi render target process
  57107. */
  57108. InternalTexture.DATASOURCE_MULTIRENDERTARGET = 6;
  57109. /**
  57110. * Texture data comes from a cube data file
  57111. */
  57112. InternalTexture.DATASOURCE_CUBE = 7;
  57113. /**
  57114. * Texture data comes from a raw cube data
  57115. */
  57116. InternalTexture.DATASOURCE_CUBERAW = 8;
  57117. /**
  57118. * Texture data come from a prefiltered cube data file
  57119. */
  57120. InternalTexture.DATASOURCE_CUBEPREFILTERED = 9;
  57121. /**
  57122. * Texture content is raw 3D data
  57123. */
  57124. InternalTexture.DATASOURCE_RAW3D = 10;
  57125. /**
  57126. * Texture content is a depth texture
  57127. */
  57128. InternalTexture.DATASOURCE_DEPTHTEXTURE = 11;
  57129. /**
  57130. * Texture data comes from a raw cube data encoded with RGBD
  57131. */
  57132. InternalTexture.DATASOURCE_CUBERAW_RGBD = 12;
  57133. return InternalTexture;
  57134. }());
  57135. /***/ }),
  57136. /***/ "./Materials/Textures/internalTextureTracker.ts":
  57137. /*!******************************************************!*\
  57138. !*** ./Materials/Textures/internalTextureTracker.ts ***!
  57139. \******************************************************/
  57140. /*! exports provided: DummyInternalTextureTracker */
  57141. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57142. "use strict";
  57143. __webpack_require__.r(__webpack_exports__);
  57144. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return DummyInternalTextureTracker; });
  57145. /**
  57146. * Internal class used by the engine to get list of InternalTexture already bound to the GL context
  57147. */
  57148. var DummyInternalTextureTracker = /** @class */ (function () {
  57149. function DummyInternalTextureTracker() {
  57150. /**
  57151. * Gets or set the previous tracker in the list
  57152. */
  57153. this.previous = null;
  57154. /**
  57155. * Gets or set the next tracker in the list
  57156. */
  57157. this.next = null;
  57158. }
  57159. return DummyInternalTextureTracker;
  57160. }());
  57161. /***/ }),
  57162. /***/ "./Materials/Textures/mirrorTexture.ts":
  57163. /*!*********************************************!*\
  57164. !*** ./Materials/Textures/mirrorTexture.ts ***!
  57165. \*********************************************/
  57166. /*! exports provided: MirrorTexture */
  57167. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57168. "use strict";
  57169. __webpack_require__.r(__webpack_exports__);
  57170. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return MirrorTexture; });
  57171. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57172. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57173. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57174. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57175. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  57176. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57177. /**
  57178. * Mirror texture can be used to simulate the view from a mirror in a scene.
  57179. * It will dynamically be rendered every frame to adapt to the camera point of view.
  57180. * You can then easily use it as a reflectionTexture on a flat surface.
  57181. * In case the surface is not a plane, please consider relying on reflection probes.
  57182. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  57183. */
  57184. var MirrorTexture = /** @class */ (function (_super) {
  57185. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MirrorTexture, _super);
  57186. /**
  57187. * Instantiates a Mirror Texture.
  57188. * Mirror texture can be used to simulate the view from a mirror in a scene.
  57189. * It will dynamically be rendered every frame to adapt to the camera point of view.
  57190. * You can then easily use it as a reflectionTexture on a flat surface.
  57191. * In case the surface is not a plane, please consider relying on reflection probes.
  57192. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  57193. * @param name
  57194. * @param size
  57195. * @param scene
  57196. * @param generateMipMaps
  57197. * @param type
  57198. * @param samplingMode
  57199. * @param generateDepthBuffer
  57200. */
  57201. function MirrorTexture(name, size, scene, generateMipMaps, type, samplingMode, generateDepthBuffer) {
  57202. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57203. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  57204. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  57205. var _this = _super.call(this, name, size, scene, generateMipMaps, true, type, false, samplingMode, generateDepthBuffer) || this;
  57206. _this.scene = scene;
  57207. /**
  57208. * Define the reflection plane we want to use. The mirrorPlane is usually set to the constructed reflector.
  57209. * 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.
  57210. * @see https://doc.babylonjs.com/how_to/reflect#mirrors
  57211. */
  57212. _this.mirrorPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57213. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  57214. _this._mirrorMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Zero();
  57215. _this._adaptiveBlurKernel = 0;
  57216. _this._blurKernelX = 0;
  57217. _this._blurKernelY = 0;
  57218. _this._blurRatio = 1.0;
  57219. _this.ignoreCameraViewport = true;
  57220. _this._updateGammaSpace();
  57221. _this._imageProcessingConfigChangeObserver = scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  57222. _this._updateGammaSpace;
  57223. });
  57224. _this.onBeforeRenderObservable.add(function () {
  57225. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].ReflectionToRef(_this.mirrorPlane, _this._mirrorMatrix);
  57226. _this._savedViewMatrix = scene.getViewMatrix();
  57227. _this._mirrorMatrix.multiplyToRef(_this._savedViewMatrix, _this._transformMatrix);
  57228. scene.setTransformMatrix(_this._transformMatrix, scene.getProjectionMatrix());
  57229. scene.clipPlane = _this.mirrorPlane;
  57230. scene.getEngine().cullBackFaces = false;
  57231. scene._mirroredCameraPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(scene.activeCamera.globalPosition, _this._mirrorMatrix);
  57232. });
  57233. _this.onAfterRenderObservable.add(function () {
  57234. scene.setTransformMatrix(_this._savedViewMatrix, scene.getProjectionMatrix());
  57235. scene.getEngine().cullBackFaces = true;
  57236. scene._mirroredCameraPosition = null;
  57237. delete scene.clipPlane;
  57238. });
  57239. return _this;
  57240. }
  57241. Object.defineProperty(MirrorTexture.prototype, "blurRatio", {
  57242. get: function () {
  57243. return this._blurRatio;
  57244. },
  57245. /**
  57246. * Define the blur ratio used to blur the reflection if needed.
  57247. */
  57248. set: function (value) {
  57249. if (this._blurRatio === value) {
  57250. return;
  57251. }
  57252. this._blurRatio = value;
  57253. this._preparePostProcesses();
  57254. },
  57255. enumerable: true,
  57256. configurable: true
  57257. });
  57258. Object.defineProperty(MirrorTexture.prototype, "adaptiveBlurKernel", {
  57259. /**
  57260. * Define the adaptive blur kernel used to blur the reflection if needed.
  57261. * This will autocompute the closest best match for the `blurKernel`
  57262. */
  57263. set: function (value) {
  57264. this._adaptiveBlurKernel = value;
  57265. this._autoComputeBlurKernel();
  57266. },
  57267. enumerable: true,
  57268. configurable: true
  57269. });
  57270. Object.defineProperty(MirrorTexture.prototype, "blurKernel", {
  57271. /**
  57272. * Define the blur kernel used to blur the reflection if needed.
  57273. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  57274. */
  57275. set: function (value) {
  57276. this.blurKernelX = value;
  57277. this.blurKernelY = value;
  57278. },
  57279. enumerable: true,
  57280. configurable: true
  57281. });
  57282. Object.defineProperty(MirrorTexture.prototype, "blurKernelX", {
  57283. get: function () {
  57284. return this._blurKernelX;
  57285. },
  57286. /**
  57287. * Define the blur kernel on the X Axis used to blur the reflection if needed.
  57288. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  57289. */
  57290. set: function (value) {
  57291. if (this._blurKernelX === value) {
  57292. return;
  57293. }
  57294. this._blurKernelX = value;
  57295. this._preparePostProcesses();
  57296. },
  57297. enumerable: true,
  57298. configurable: true
  57299. });
  57300. Object.defineProperty(MirrorTexture.prototype, "blurKernelY", {
  57301. get: function () {
  57302. return this._blurKernelY;
  57303. },
  57304. /**
  57305. * Define the blur kernel on the Y Axis used to blur the reflection if needed.
  57306. * Please consider using `adaptiveBlurKernel` as it could find the closest best value for you.
  57307. */
  57308. set: function (value) {
  57309. if (this._blurKernelY === value) {
  57310. return;
  57311. }
  57312. this._blurKernelY = value;
  57313. this._preparePostProcesses();
  57314. },
  57315. enumerable: true,
  57316. configurable: true
  57317. });
  57318. MirrorTexture.prototype._autoComputeBlurKernel = function () {
  57319. var engine = this.getScene().getEngine();
  57320. var dw = this.getRenderWidth() / engine.getRenderWidth();
  57321. var dh = this.getRenderHeight() / engine.getRenderHeight();
  57322. this.blurKernelX = this._adaptiveBlurKernel * dw;
  57323. this.blurKernelY = this._adaptiveBlurKernel * dh;
  57324. };
  57325. MirrorTexture.prototype._onRatioRescale = function () {
  57326. if (this._sizeRatio) {
  57327. this.resize(this._initialSizeParameter);
  57328. if (!this._adaptiveBlurKernel) {
  57329. this._preparePostProcesses();
  57330. }
  57331. }
  57332. if (this._adaptiveBlurKernel) {
  57333. this._autoComputeBlurKernel();
  57334. }
  57335. };
  57336. MirrorTexture.prototype._updateGammaSpace = function () {
  57337. this.gammaSpace = !this.scene.imageProcessingConfiguration.isEnabled || !this.scene.imageProcessingConfiguration.applyByPostProcess;
  57338. };
  57339. MirrorTexture.prototype._preparePostProcesses = function () {
  57340. this.clearPostProcesses(true);
  57341. if (this._blurKernelX && this._blurKernelY) {
  57342. var engine = this.getScene().getEngine();
  57343. var textureType = engine.getCaps().textureFloatRender ? _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT : _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_HALF_FLOAT;
  57344. 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);
  57345. this._blurX.autoClear = false;
  57346. if (this._blurRatio === 1 && this.samples < 2 && this._texture) {
  57347. this._blurX.inputTexture = this._texture;
  57348. }
  57349. else {
  57350. this._blurX.alwaysForcePOT = true;
  57351. }
  57352. 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);
  57353. this._blurY.autoClear = false;
  57354. this._blurY.alwaysForcePOT = this._blurRatio !== 1;
  57355. this.addPostProcess(this._blurX);
  57356. this.addPostProcess(this._blurY);
  57357. }
  57358. else {
  57359. if (this._blurY) {
  57360. this.removePostProcess(this._blurY);
  57361. this._blurY.dispose();
  57362. this._blurY = null;
  57363. }
  57364. if (this._blurX) {
  57365. this.removePostProcess(this._blurX);
  57366. this._blurX.dispose();
  57367. this._blurX = null;
  57368. }
  57369. }
  57370. };
  57371. /**
  57372. * Clone the mirror texture.
  57373. * @returns the cloned texture
  57374. */
  57375. MirrorTexture.prototype.clone = function () {
  57376. var scene = this.getScene();
  57377. if (!scene) {
  57378. return this;
  57379. }
  57380. var textureSize = this.getSize();
  57381. var newTexture = new MirrorTexture(this.name, textureSize.width, scene, this._renderTargetOptions.generateMipMaps, this._renderTargetOptions.type, this._renderTargetOptions.samplingMode, this._renderTargetOptions.generateDepthBuffer);
  57382. // Base texture
  57383. newTexture.hasAlpha = this.hasAlpha;
  57384. newTexture.level = this.level;
  57385. // Mirror Texture
  57386. newTexture.mirrorPlane = this.mirrorPlane.clone();
  57387. if (this.renderList) {
  57388. newTexture.renderList = this.renderList.slice(0);
  57389. }
  57390. return newTexture;
  57391. };
  57392. /**
  57393. * Serialize the texture to a JSON representation you could use in Parse later on
  57394. * @returns the serialized JSON representation
  57395. */
  57396. MirrorTexture.prototype.serialize = function () {
  57397. if (!this.name) {
  57398. return null;
  57399. }
  57400. var serializationObject = _super.prototype.serialize.call(this);
  57401. serializationObject.mirrorPlane = this.mirrorPlane.asArray();
  57402. return serializationObject;
  57403. };
  57404. /**
  57405. * Dispose the texture and release its associated resources.
  57406. */
  57407. MirrorTexture.prototype.dispose = function () {
  57408. _super.prototype.dispose.call(this);
  57409. this.scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigChangeObserver);
  57410. };
  57411. return MirrorTexture;
  57412. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]));
  57413. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  57414. return new MirrorTexture(name, renderTargetSize, scene, generateMipMaps);
  57415. };
  57416. /***/ }),
  57417. /***/ "./Materials/Textures/multiRenderTarget.ts":
  57418. /*!*************************************************!*\
  57419. !*** ./Materials/Textures/multiRenderTarget.ts ***!
  57420. \*************************************************/
  57421. /*! exports provided: MultiRenderTarget */
  57422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57423. "use strict";
  57424. __webpack_require__.r(__webpack_exports__);
  57425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return MultiRenderTarget; });
  57426. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57427. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57428. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57429. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57430. /**
  57431. * A multi render target, like a render target provides the ability to render to a texture.
  57432. * Unlike the render target, it can render to several draw buffers in one draw.
  57433. * This is specially interesting in deferred rendering or for any effects requiring more than
  57434. * just one color from a single pass.
  57435. */
  57436. var MultiRenderTarget = /** @class */ (function (_super) {
  57437. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiRenderTarget, _super);
  57438. /**
  57439. * Instantiate a new multi render target texture.
  57440. * A multi render target, like a render target provides the ability to render to a texture.
  57441. * Unlike the render target, it can render to several draw buffers in one draw.
  57442. * This is specially interesting in deferred rendering or for any effects requiring more than
  57443. * just one color from a single pass.
  57444. * @param name Define the name of the texture
  57445. * @param size Define the size of the buffers to render to
  57446. * @param count Define the number of target we are rendering into
  57447. * @param scene Define the scene the texture belongs to
  57448. * @param options Define the options used to create the multi render target
  57449. */
  57450. function MultiRenderTarget(name, size, count, scene, options) {
  57451. var _this = this;
  57452. var generateMipMaps = options && options.generateMipMaps ? options.generateMipMaps : false;
  57453. var generateDepthTexture = options && options.generateDepthTexture ? options.generateDepthTexture : false;
  57454. var doNotChangeAspectRatio = !options || options.doNotChangeAspectRatio === undefined ? true : options.doNotChangeAspectRatio;
  57455. _this = _super.call(this, name, size, scene, generateMipMaps, doNotChangeAspectRatio) || this;
  57456. _this._engine = scene.getEngine();
  57457. if (!_this.isSupported) {
  57458. _this.dispose();
  57459. return;
  57460. }
  57461. var types = [];
  57462. var samplingModes = [];
  57463. for (var i = 0; i < count; i++) {
  57464. if (options && options.types && options.types[i] !== undefined) {
  57465. types.push(options.types[i]);
  57466. }
  57467. else {
  57468. types.push(options && options.defaultType ? options.defaultType : _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  57469. }
  57470. if (options && options.samplingModes && options.samplingModes[i] !== undefined) {
  57471. samplingModes.push(options.samplingModes[i]);
  57472. }
  57473. else {
  57474. samplingModes.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE);
  57475. }
  57476. }
  57477. var generateDepthBuffer = !options || options.generateDepthBuffer === undefined ? true : options.generateDepthBuffer;
  57478. var generateStencilBuffer = !options || options.generateStencilBuffer === undefined ? false : options.generateStencilBuffer;
  57479. _this._size = size;
  57480. _this._multiRenderTargetOptions = {
  57481. samplingModes: samplingModes,
  57482. generateMipMaps: generateMipMaps,
  57483. generateDepthBuffer: generateDepthBuffer,
  57484. generateStencilBuffer: generateStencilBuffer,
  57485. generateDepthTexture: generateDepthTexture,
  57486. types: types,
  57487. textureCount: count
  57488. };
  57489. _this._createInternalTextures();
  57490. _this._createTextures();
  57491. return _this;
  57492. }
  57493. Object.defineProperty(MultiRenderTarget.prototype, "isSupported", {
  57494. /**
  57495. * Get if draw buffers are currently supported by the used hardware and browser.
  57496. */
  57497. get: function () {
  57498. return this._engine.webGLVersion > 1 || this._engine.getCaps().drawBuffersExtension;
  57499. },
  57500. enumerable: true,
  57501. configurable: true
  57502. });
  57503. Object.defineProperty(MultiRenderTarget.prototype, "textures", {
  57504. /**
  57505. * Get the list of textures generated by the multi render target.
  57506. */
  57507. get: function () {
  57508. return this._textures;
  57509. },
  57510. enumerable: true,
  57511. configurable: true
  57512. });
  57513. Object.defineProperty(MultiRenderTarget.prototype, "depthTexture", {
  57514. /**
  57515. * Get the depth texture generated by the multi render target if options.generateDepthTexture has been set
  57516. */
  57517. get: function () {
  57518. return this._textures[this._textures.length - 1];
  57519. },
  57520. enumerable: true,
  57521. configurable: true
  57522. });
  57523. Object.defineProperty(MultiRenderTarget.prototype, "wrapU", {
  57524. /**
  57525. * Set the wrapping mode on U of all the textures we are rendering to.
  57526. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57527. */
  57528. set: function (wrap) {
  57529. if (this._textures) {
  57530. for (var i = 0; i < this._textures.length; i++) {
  57531. this._textures[i].wrapU = wrap;
  57532. }
  57533. }
  57534. },
  57535. enumerable: true,
  57536. configurable: true
  57537. });
  57538. Object.defineProperty(MultiRenderTarget.prototype, "wrapV", {
  57539. /**
  57540. * Set the wrapping mode on V of all the textures we are rendering to.
  57541. * Can be any of the Texture. (CLAMP_ADDRESSMODE, MIRROR_ADDRESSMODE or WRAP_ADDRESSMODE)
  57542. */
  57543. set: function (wrap) {
  57544. if (this._textures) {
  57545. for (var i = 0; i < this._textures.length; i++) {
  57546. this._textures[i].wrapV = wrap;
  57547. }
  57548. }
  57549. },
  57550. enumerable: true,
  57551. configurable: true
  57552. });
  57553. /** @hidden */
  57554. MultiRenderTarget.prototype._rebuild = function () {
  57555. this.releaseInternalTextures();
  57556. this._createInternalTextures();
  57557. for (var i = 0; i < this._internalTextures.length; i++) {
  57558. var texture = this._textures[i];
  57559. texture._texture = this._internalTextures[i];
  57560. }
  57561. // Keeps references to frame buffer and stencil/depth buffer
  57562. this._texture = this._internalTextures[0];
  57563. };
  57564. MultiRenderTarget.prototype._createInternalTextures = function () {
  57565. this._internalTextures = this._engine.createMultipleRenderTarget(this._size, this._multiRenderTargetOptions);
  57566. };
  57567. MultiRenderTarget.prototype._createTextures = function () {
  57568. this._textures = [];
  57569. for (var i = 0; i < this._internalTextures.length; i++) {
  57570. var texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](null, this.getScene());
  57571. texture._texture = this._internalTextures[i];
  57572. this._textures.push(texture);
  57573. }
  57574. // Keeps references to frame buffer and stencil/depth buffer
  57575. this._texture = this._internalTextures[0];
  57576. };
  57577. Object.defineProperty(MultiRenderTarget.prototype, "samples", {
  57578. /**
  57579. * Define the number of samples used if MSAA is enabled.
  57580. */
  57581. get: function () {
  57582. return this._samples;
  57583. },
  57584. set: function (value) {
  57585. if (this._samples === value) {
  57586. return;
  57587. }
  57588. this._samples = this._engine.updateMultipleRenderTargetTextureSampleCount(this._internalTextures, value);
  57589. },
  57590. enumerable: true,
  57591. configurable: true
  57592. });
  57593. /**
  57594. * Resize all the textures in the multi render target.
  57595. * Be carrefull as it will recreate all the data in the new texture.
  57596. * @param size Define the new size
  57597. */
  57598. MultiRenderTarget.prototype.resize = function (size) {
  57599. this.releaseInternalTextures();
  57600. this._internalTextures = this._engine.createMultipleRenderTarget(size, this._multiRenderTargetOptions);
  57601. this._createInternalTextures();
  57602. };
  57603. MultiRenderTarget.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  57604. var _this = this;
  57605. engine.unBindMultiColorAttachmentFramebuffer(this._internalTextures, this.isCube, function () {
  57606. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  57607. });
  57608. };
  57609. /**
  57610. * Dispose the render targets and their associated resources
  57611. */
  57612. MultiRenderTarget.prototype.dispose = function () {
  57613. this.releaseInternalTextures();
  57614. _super.prototype.dispose.call(this);
  57615. };
  57616. /**
  57617. * Release all the underlying texture used as draw buffers.
  57618. */
  57619. MultiRenderTarget.prototype.releaseInternalTextures = function () {
  57620. if (!this._internalTextures) {
  57621. return;
  57622. }
  57623. for (var i = this._internalTextures.length - 1; i >= 0; i--) {
  57624. if (this._internalTextures[i] !== undefined) {
  57625. this._internalTextures[i].dispose();
  57626. this._internalTextures.splice(i, 1);
  57627. }
  57628. }
  57629. };
  57630. return MultiRenderTarget;
  57631. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  57632. /***/ }),
  57633. /***/ "./Materials/Textures/rawCubeTexture.ts":
  57634. /*!**********************************************!*\
  57635. !*** ./Materials/Textures/rawCubeTexture.ts ***!
  57636. \**********************************************/
  57637. /*! exports provided: RawCubeTexture */
  57638. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57639. "use strict";
  57640. __webpack_require__.r(__webpack_exports__);
  57641. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return RawCubeTexture; });
  57642. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57643. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  57644. /* harmony import */ var _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  57645. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  57646. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  57647. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57648. /**
  57649. * Raw cube texture where the raw buffers are passed in
  57650. */
  57651. var RawCubeTexture = /** @class */ (function (_super) {
  57652. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawCubeTexture, _super);
  57653. /**
  57654. * Creates a cube texture where the raw buffers are passed in.
  57655. * @param scene defines the scene the texture is attached to
  57656. * @param data defines the array of data to use to create each face
  57657. * @param size defines the size of the textures
  57658. * @param format defines the format of the data
  57659. * @param type defines the type of the data (like Engine.TEXTURETYPE_UNSIGNED_INT)
  57660. * @param generateMipMaps defines if the engine should generate the mip levels
  57661. * @param invertY defines if data must be stored with Y axis inverted
  57662. * @param samplingMode defines the required sampling mode (like Texture.NEAREST_SAMPLINGMODE)
  57663. * @param compression defines the compression used (null by default)
  57664. */
  57665. function RawCubeTexture(scene, data, size, format, type, generateMipMaps, invertY, samplingMode, compression) {
  57666. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTUREFORMAT_RGBA; }
  57667. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57668. if (generateMipMaps === void 0) { generateMipMaps = false; }
  57669. if (invertY === void 0) { invertY = false; }
  57670. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57671. if (compression === void 0) { compression = null; }
  57672. var _this = _super.call(this, "", scene) || this;
  57673. _this._texture = scene.getEngine().createRawCubeTexture(data, size, format, type, generateMipMaps, invertY, samplingMode, compression);
  57674. return _this;
  57675. }
  57676. /**
  57677. * Updates the raw cube texture.
  57678. * @param data defines the data to store
  57679. * @param format defines the data format
  57680. * @param type defines the type fo the data (Engine.TEXTURETYPE_UNSIGNED_INT by default)
  57681. * @param invertY defines if data must be stored with Y axis inverted
  57682. * @param compression defines the compression used (null by default)
  57683. * @param level defines which level of the texture to update
  57684. */
  57685. RawCubeTexture.prototype.update = function (data, format, type, invertY, compression) {
  57686. if (compression === void 0) { compression = null; }
  57687. this._texture.getEngine().updateRawCubeTexture(this._texture, data, format, type, invertY, compression);
  57688. };
  57689. /**
  57690. * Updates a raw cube texture with RGBD encoded data.
  57691. * @param data defines the array of data [mipmap][face] to use to create each face
  57692. * @param sphericalPolynomial defines the spherical polynomial for irradiance
  57693. * @param lodScale defines the scale applied to environment texture. This manages the range of LOD level used for IBL according to the roughness
  57694. * @param lodOffset defines the offset applied to environment texture. This manages first LOD level used for IBL according to the roughness
  57695. * @returns a promsie that resolves when the operation is complete
  57696. */
  57697. RawCubeTexture.prototype.updateRGBDAsync = function (data, sphericalPolynomial, lodScale, lodOffset) {
  57698. if (sphericalPolynomial === void 0) { sphericalPolynomial = null; }
  57699. if (lodScale === void 0) { lodScale = 0.8; }
  57700. if (lodOffset === void 0) { lodOffset = 0; }
  57701. return RawCubeTexture._UpdateRGBDAsync(this._texture, data, sphericalPolynomial, lodScale, lodOffset);
  57702. };
  57703. /**
  57704. * Clones the raw cube texture.
  57705. * @return a new cube texture
  57706. */
  57707. RawCubeTexture.prototype.clone = function () {
  57708. var _this = this;
  57709. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  57710. var scene = _this.getScene();
  57711. var internalTexture = _this._texture;
  57712. var texture = new RawCubeTexture(scene, internalTexture._bufferViewArray, internalTexture.width, internalTexture.format, internalTexture.type, internalTexture.generateMipMaps, internalTexture.invertY, internalTexture.samplingMode, internalTexture._compression);
  57713. if (internalTexture.dataSource === _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD) {
  57714. texture.updateRGBDAsync(internalTexture._bufferViewArrayArray, internalTexture._sphericalPolynomial, internalTexture._lodGenerationScale, internalTexture._lodGenerationOffset);
  57715. }
  57716. return texture;
  57717. }, this);
  57718. };
  57719. /** @hidden */
  57720. RawCubeTexture._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  57721. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_3__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  57722. internalTexture._bufferViewArrayArray = data;
  57723. internalTexture._lodGenerationScale = lodScale;
  57724. internalTexture._lodGenerationOffset = lodOffset;
  57725. internalTexture._sphericalPolynomial = sphericalPolynomial;
  57726. return _Misc_environmentTextureTools__WEBPACK_IMPORTED_MODULE_2__["EnvironmentTextureTools"].UploadLevelsAsync(internalTexture, data).then(function () {
  57727. internalTexture.isReady = true;
  57728. });
  57729. };
  57730. return RawCubeTexture;
  57731. }(_Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_4__["CubeTexture"]));
  57732. /***/ }),
  57733. /***/ "./Materials/Textures/rawTexture.ts":
  57734. /*!******************************************!*\
  57735. !*** ./Materials/Textures/rawTexture.ts ***!
  57736. \******************************************/
  57737. /*! exports provided: RawTexture */
  57738. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57739. "use strict";
  57740. __webpack_require__.r(__webpack_exports__);
  57741. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return RawTexture; });
  57742. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57743. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57744. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57745. /**
  57746. * Raw texture can help creating a texture directly from an array of data.
  57747. * This can be super useful if you either get the data from an uncompressed source or
  57748. * if you wish to create your texture pixel by pixel.
  57749. */
  57750. var RawTexture = /** @class */ (function (_super) {
  57751. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture, _super);
  57752. /**
  57753. * Instantiates a new RawTexture.
  57754. * Raw texture can help creating a texture directly from an array of data.
  57755. * This can be super useful if you either get the data from an uncompressed source or
  57756. * if you wish to create your texture pixel by pixel.
  57757. * @param data define the array of data to use to create the texture
  57758. * @param width define the width of the texture
  57759. * @param height define the height of the texture
  57760. * @param format define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57761. * @param scene define the scene the texture belongs to
  57762. * @param generateMipMaps define whether mip maps should be generated or not
  57763. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57764. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57765. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57766. */
  57767. function RawTexture(data, width, height,
  57768. /**
  57769. * Define the format of the data (RGB, RGBA... Engine.TEXTUREFORMAT_xxx)
  57770. */
  57771. format, scene, generateMipMaps, invertY, samplingMode, type) {
  57772. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57773. if (invertY === void 0) { invertY = false; }
  57774. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57775. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57776. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57777. _this.format = format;
  57778. _this._engine = scene.getEngine();
  57779. _this._texture = scene.getEngine().createRawTexture(data, width, height, format, generateMipMaps, invertY, samplingMode, null, type);
  57780. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57781. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].CLAMP_ADDRESSMODE;
  57782. return _this;
  57783. }
  57784. /**
  57785. * Updates the texture underlying data.
  57786. * @param data Define the new data of the texture
  57787. */
  57788. RawTexture.prototype.update = function (data) {
  57789. this._engine.updateRawTexture(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57790. };
  57791. /**
  57792. * Creates a luminance texture from some data.
  57793. * @param data Define the texture data
  57794. * @param width Define the width of the texture
  57795. * @param height Define the height of the texture
  57796. * @param scene Define the scene the texture belongs to
  57797. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57798. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57799. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57800. * @returns the luminance texture
  57801. */
  57802. RawTexture.CreateLuminanceTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57803. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57804. if (invertY === void 0) { invertY = false; }
  57805. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57806. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE, scene, generateMipMaps, invertY, samplingMode);
  57807. };
  57808. /**
  57809. * Creates a luminance alpha texture from some data.
  57810. * @param data Define the texture data
  57811. * @param width Define the width of the texture
  57812. * @param height Define the height of the texture
  57813. * @param scene Define the scene the texture belongs to
  57814. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57815. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57816. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57817. * @returns the luminance alpha texture
  57818. */
  57819. RawTexture.CreateLuminanceAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57820. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57821. if (invertY === void 0) { invertY = false; }
  57822. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57823. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57824. };
  57825. /**
  57826. * Creates an alpha texture from some data.
  57827. * @param data Define the texture data
  57828. * @param width Define the width of the texture
  57829. * @param height Define the height of the texture
  57830. * @param scene Define the scene the texture belongs to
  57831. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57832. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57833. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57834. * @returns the alpha texture
  57835. */
  57836. RawTexture.CreateAlphaTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode) {
  57837. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57838. if (invertY === void 0) { invertY = false; }
  57839. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57840. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_ALPHA, scene, generateMipMaps, invertY, samplingMode);
  57841. };
  57842. /**
  57843. * Creates a RGB texture from some data.
  57844. * @param data Define the texture data
  57845. * @param width Define the width of the texture
  57846. * @param height Define the height of the texture
  57847. * @param scene Define the scene the texture belongs to
  57848. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57849. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57850. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57851. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57852. * @returns the RGB alpha texture
  57853. */
  57854. RawTexture.CreateRGBTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57855. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57856. if (invertY === void 0) { invertY = false; }
  57857. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57858. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57859. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB, scene, generateMipMaps, invertY, samplingMode, type);
  57860. };
  57861. /**
  57862. * Creates a RGBA texture from some data.
  57863. * @param data Define the texture data
  57864. * @param width Define the width of the texture
  57865. * @param height Define the height of the texture
  57866. * @param scene Define the scene the texture belongs to
  57867. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57868. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57869. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57870. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57871. * @returns the RGBA texture
  57872. */
  57873. RawTexture.CreateRGBATexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57874. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57875. if (invertY === void 0) { invertY = false; }
  57876. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE; }
  57877. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57878. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA, scene, generateMipMaps, invertY, samplingMode, type);
  57879. };
  57880. /**
  57881. * Creates a R texture from some data.
  57882. * @param data Define the texture data
  57883. * @param width Define the width of the texture
  57884. * @param height Define the height of the texture
  57885. * @param scene Define the scene the texture belongs to
  57886. * @param generateMipMaps Define whether or not to create mip maps for the texture
  57887. * @param invertY define if the data should be flipped on Y when uploaded to the GPU
  57888. * @param samplingMode define the texture sampling mode (Texture.xxx_SAMPLINGMODE)
  57889. * @param type define the format of the data (int, float... Engine.TEXTURETYPE_xxx)
  57890. * @returns the R texture
  57891. */
  57892. RawTexture.CreateRTexture = function (data, width, height, scene, generateMipMaps, invertY, samplingMode, type) {
  57893. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57894. if (invertY === void 0) { invertY = false; }
  57895. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57896. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT; }
  57897. return new RawTexture(data, width, height, _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_R, scene, generateMipMaps, invertY, samplingMode, type);
  57898. };
  57899. return RawTexture;
  57900. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57901. /***/ }),
  57902. /***/ "./Materials/Textures/rawTexture3D.ts":
  57903. /*!********************************************!*\
  57904. !*** ./Materials/Textures/rawTexture3D.ts ***!
  57905. \********************************************/
  57906. /*! exports provided: RawTexture3D */
  57907. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57908. "use strict";
  57909. __webpack_require__.r(__webpack_exports__);
  57910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return RawTexture3D; });
  57911. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57912. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  57913. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  57914. /**
  57915. * Class used to store 3D textures containing user data
  57916. */
  57917. var RawTexture3D = /** @class */ (function (_super) {
  57918. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RawTexture3D, _super);
  57919. /**
  57920. * Create a new RawTexture3D
  57921. * @param data defines the data of the texture
  57922. * @param width defines the width of the texture
  57923. * @param height defines the height of the texture
  57924. * @param depth defines the depth of the texture
  57925. * @param format defines the texture format to use
  57926. * @param scene defines the hosting scene
  57927. * @param generateMipMaps defines a boolean indicating if mip levels should be generated (true by default)
  57928. * @param invertY defines if texture must be stored with Y axis inverted
  57929. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  57930. * @param textureType defines the texture Type (Engine.TEXTURETYPE_UNSIGNED_INT, Engine.TEXTURETYPE_FLOAT...)
  57931. */
  57932. function RawTexture3D(data, width, height, depth,
  57933. /** Gets or sets the texture format to use */
  57934. format, scene, generateMipMaps, invertY, samplingMode, textureType) {
  57935. if (generateMipMaps === void 0) { generateMipMaps = true; }
  57936. if (invertY === void 0) { invertY = false; }
  57937. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE; }
  57938. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  57939. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  57940. _this.format = format;
  57941. _this._engine = scene.getEngine();
  57942. _this._texture = scene.getEngine().createRawTexture3D(data, width, height, depth, format, generateMipMaps, invertY, samplingMode, undefined, textureType);
  57943. _this.is3D = true;
  57944. return _this;
  57945. }
  57946. /**
  57947. * Update the texture with new data
  57948. * @param data defines the data to store in the texture
  57949. */
  57950. RawTexture3D.prototype.update = function (data) {
  57951. if (!this._texture) {
  57952. return;
  57953. }
  57954. this._engine.updateRawTexture3D(this._texture, data, this._texture.format, this._texture.invertY, undefined, this._texture.type);
  57955. };
  57956. return RawTexture3D;
  57957. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"]));
  57958. /***/ }),
  57959. /***/ "./Materials/Textures/refractionTexture.ts":
  57960. /*!*************************************************!*\
  57961. !*** ./Materials/Textures/refractionTexture.ts ***!
  57962. \*************************************************/
  57963. /*! exports provided: RefractionTexture */
  57964. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  57965. "use strict";
  57966. __webpack_require__.r(__webpack_exports__);
  57967. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return RefractionTexture; });
  57968. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  57969. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  57970. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  57971. /**
  57972. * Creates a refraction texture used by refraction channel of the standard material.
  57973. * It is like a mirror but to see through a material.
  57974. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57975. */
  57976. var RefractionTexture = /** @class */ (function (_super) {
  57977. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionTexture, _super);
  57978. /**
  57979. * Creates a refraction texture used by refraction channel of the standard material.
  57980. * It is like a mirror but to see through a material.
  57981. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57982. * @param name Define the texture name
  57983. * @param size Define the size of the underlying texture
  57984. * @param scene Define the scene the refraction belongs to
  57985. * @param generateMipMaps Define if we need to generate mips level for the refraction
  57986. */
  57987. function RefractionTexture(name, size, scene, generateMipMaps) {
  57988. var _this = _super.call(this, name, size, scene, generateMipMaps, true) || this;
  57989. /**
  57990. * Define the reflection plane we want to use. The refractionPlane is usually set to the constructed refractor.
  57991. * 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.
  57992. * @see https://doc.babylonjs.com/how_to/reflect#refraction
  57993. */
  57994. _this.refractionPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Plane"](0, 1, 0, 1);
  57995. /**
  57996. * Define how deep under the surface we should see.
  57997. */
  57998. _this.depth = 2.0;
  57999. _this.onBeforeRenderObservable.add(function () {
  58000. scene.clipPlane = _this.refractionPlane;
  58001. });
  58002. _this.onAfterRenderObservable.add(function () {
  58003. delete scene.clipPlane;
  58004. });
  58005. return _this;
  58006. }
  58007. /**
  58008. * Clone the refraction texture.
  58009. * @returns the cloned texture
  58010. */
  58011. RefractionTexture.prototype.clone = function () {
  58012. var scene = this.getScene();
  58013. if (!scene) {
  58014. return this;
  58015. }
  58016. var textureSize = this.getSize();
  58017. var newTexture = new RefractionTexture(this.name, textureSize.width, scene, this._generateMipMaps);
  58018. // Base texture
  58019. newTexture.hasAlpha = this.hasAlpha;
  58020. newTexture.level = this.level;
  58021. // Refraction Texture
  58022. newTexture.refractionPlane = this.refractionPlane.clone();
  58023. if (this.renderList) {
  58024. newTexture.renderList = this.renderList.slice(0);
  58025. }
  58026. newTexture.depth = this.depth;
  58027. return newTexture;
  58028. };
  58029. /**
  58030. * Serialize the texture to a JSON representation you could use in Parse later on
  58031. * @returns the serialized JSON representation
  58032. */
  58033. RefractionTexture.prototype.serialize = function () {
  58034. if (!this.name) {
  58035. return null;
  58036. }
  58037. var serializationObject = _super.prototype.serialize.call(this);
  58038. serializationObject.mirrorPlane = this.refractionPlane.asArray();
  58039. serializationObject.depth = this.depth;
  58040. return serializationObject;
  58041. };
  58042. return RefractionTexture;
  58043. }(_Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__["RenderTargetTexture"]));
  58044. /***/ }),
  58045. /***/ "./Materials/Textures/renderTargetCreationOptions.ts":
  58046. /*!***********************************************************!*\
  58047. !*** ./Materials/Textures/renderTargetCreationOptions.ts ***!
  58048. \***********************************************************/
  58049. /*! exports provided: RenderTargetCreationOptions */
  58050. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58051. "use strict";
  58052. __webpack_require__.r(__webpack_exports__);
  58053. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetCreationOptions", function() { return RenderTargetCreationOptions; });
  58054. /**
  58055. * Define options used to create a render target texture
  58056. */
  58057. var RenderTargetCreationOptions = /** @class */ (function () {
  58058. function RenderTargetCreationOptions() {
  58059. }
  58060. return RenderTargetCreationOptions;
  58061. }());
  58062. /***/ }),
  58063. /***/ "./Materials/Textures/renderTargetTexture.ts":
  58064. /*!***************************************************!*\
  58065. !*** ./Materials/Textures/renderTargetTexture.ts ***!
  58066. \***************************************************/
  58067. /*! exports provided: RenderTargetTexture */
  58068. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58069. "use strict";
  58070. __webpack_require__.r(__webpack_exports__);
  58071. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return RenderTargetTexture; });
  58072. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58073. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58074. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58075. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58076. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  58077. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  58078. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  58079. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58080. /**
  58081. * This Helps creating a texture that will be created from a camera in your scene.
  58082. * It is basically a dynamic texture that could be used to create special effects for instance.
  58083. * Actually, It is the base of lot of effects in the framework like post process, shadows, effect layers and rendering pipelines...
  58084. */
  58085. var RenderTargetTexture = /** @class */ (function (_super) {
  58086. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetTexture, _super);
  58087. /**
  58088. * Instantiate a render target texture. This is mainly used to render of screen the scene to for instance apply post processse
  58089. * or used a shadow, depth texture...
  58090. * @param name The friendly name of the texture
  58091. * @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)
  58092. * @param scene The scene the RTT belongs to. The latest created scene will be used if not precised.
  58093. * @param generateMipMaps True if mip maps need to be generated after render.
  58094. * @param doNotChangeAspectRatio True to not change the aspect ratio of the scene in the RTT
  58095. * @param type The type of the buffer in the RTT (int, half float, float...)
  58096. * @param isCube True if a cube texture needs to be created
  58097. * @param samplingMode The sampling mode to be usedwith the render target (Linear, Nearest...)
  58098. * @param generateDepthBuffer True to generate a depth buffer
  58099. * @param generateStencilBuffer True to generate a stencil buffer
  58100. * @param isMulti True if multiple textures need to be created (Draw Buffers)
  58101. * @param format The internal format of the buffer in the RTT (RED, RG, RGB, RGBA, ALPHA...)
  58102. * @param delayAllocation if the texture allocation should be delayed (default: false)
  58103. */
  58104. function RenderTargetTexture(name, size, scene, generateMipMaps, doNotChangeAspectRatio, type, isCube, samplingMode, generateDepthBuffer, generateStencilBuffer, isMulti, format, delayAllocation) {
  58105. if (doNotChangeAspectRatio === void 0) { doNotChangeAspectRatio = true; }
  58106. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  58107. if (isCube === void 0) { isCube = false; }
  58108. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  58109. if (generateDepthBuffer === void 0) { generateDepthBuffer = true; }
  58110. if (generateStencilBuffer === void 0) { generateStencilBuffer = false; }
  58111. if (isMulti === void 0) { isMulti = false; }
  58112. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].TEXTUREFORMAT_RGBA; }
  58113. if (delayAllocation === void 0) { delayAllocation = false; }
  58114. var _this = _super.call(this, null, scene, !generateMipMaps) || this;
  58115. _this.isCube = isCube;
  58116. /**
  58117. * Define if particles should be rendered in your texture.
  58118. */
  58119. _this.renderParticles = true;
  58120. /**
  58121. * Define if sprites should be rendered in your texture.
  58122. */
  58123. _this.renderSprites = false;
  58124. /**
  58125. * Override the default coordinates mode to projection for RTT as it is the most common case for rendered textures.
  58126. */
  58127. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].PROJECTION_MODE;
  58128. /**
  58129. * Define if the camera viewport should be respected while rendering the texture or if the render should be done to the entire texture.
  58130. */
  58131. _this.ignoreCameraViewport = false;
  58132. /**
  58133. * An event triggered when the texture is unbind.
  58134. */
  58135. _this.onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58136. /**
  58137. * An event triggered when the texture is unbind.
  58138. */
  58139. _this.onAfterUnbindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58140. /**
  58141. * An event triggered before rendering the texture
  58142. */
  58143. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58144. /**
  58145. * An event triggered after rendering the texture
  58146. */
  58147. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58148. /**
  58149. * An event triggered after the texture clear
  58150. */
  58151. _this.onClearObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  58152. _this._currentRefreshId = -1;
  58153. _this._refreshRate = 1;
  58154. _this._samples = 1;
  58155. /**
  58156. * Gets or sets the center of the bounding box associated with the texture (when in cube mode)
  58157. * It must define where the camera used to render the texture is set
  58158. */
  58159. _this.boundingBoxPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  58160. scene = _this.getScene();
  58161. if (!scene) {
  58162. return _this;
  58163. }
  58164. _this.renderList = new Array();
  58165. _this._engine = scene.getEngine();
  58166. _this.name = name;
  58167. _this.isRenderTarget = true;
  58168. _this._initialSizeParameter = size;
  58169. _this._processSizeParameter(size);
  58170. _this._resizeObserver = _this.getScene().getEngine().onResizeObservable.add(function () {
  58171. });
  58172. _this._generateMipMaps = generateMipMaps ? true : false;
  58173. _this._doNotChangeAspectRatio = doNotChangeAspectRatio;
  58174. // Rendering groups
  58175. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_6__["RenderingManager"](scene);
  58176. _this._renderingManager._useSceneAutoClearSetup = true;
  58177. if (isMulti) {
  58178. return _this;
  58179. }
  58180. _this._renderTargetOptions = {
  58181. generateMipMaps: generateMipMaps,
  58182. type: type,
  58183. format: format,
  58184. samplingMode: samplingMode,
  58185. generateDepthBuffer: generateDepthBuffer,
  58186. generateStencilBuffer: generateStencilBuffer
  58187. };
  58188. if (samplingMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].NEAREST_SAMPLINGMODE) {
  58189. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58190. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  58191. }
  58192. if (!delayAllocation) {
  58193. if (isCube) {
  58194. _this._texture = scene.getEngine().createRenderTargetCubeTexture(_this.getRenderSize(), _this._renderTargetOptions);
  58195. _this.coordinatesMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].INVCUBIC_MODE;
  58196. _this._textureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  58197. }
  58198. else {
  58199. _this._texture = scene.getEngine().createRenderTargetTexture(_this._size, _this._renderTargetOptions);
  58200. }
  58201. }
  58202. return _this;
  58203. }
  58204. Object.defineProperty(RenderTargetTexture.prototype, "renderList", {
  58205. /**
  58206. * Use this list to define the list of mesh you want to render.
  58207. */
  58208. get: function () {
  58209. return this._renderList;
  58210. },
  58211. set: function (value) {
  58212. this._renderList = value;
  58213. if (this._renderList) {
  58214. this._hookArray(this._renderList);
  58215. }
  58216. },
  58217. enumerable: true,
  58218. configurable: true
  58219. });
  58220. RenderTargetTexture.prototype._hookArray = function (array) {
  58221. var _this = this;
  58222. var oldPush = array.push;
  58223. array.push = function () {
  58224. var items = [];
  58225. for (var _i = 0; _i < arguments.length; _i++) {
  58226. items[_i] = arguments[_i];
  58227. }
  58228. var wasEmpty = array.length === 0;
  58229. var result = oldPush.apply(array, items);
  58230. if (wasEmpty) {
  58231. _this.getScene().meshes.forEach(function (mesh) {
  58232. mesh._markSubMeshesAsLightDirty();
  58233. });
  58234. }
  58235. return result;
  58236. };
  58237. var oldSplice = array.splice;
  58238. array.splice = function (index, deleteCount) {
  58239. var deleted = oldSplice.apply(array, [index, deleteCount]);
  58240. if (array.length === 0) {
  58241. _this.getScene().meshes.forEach(function (mesh) {
  58242. mesh._markSubMeshesAsLightDirty();
  58243. });
  58244. }
  58245. return deleted;
  58246. };
  58247. };
  58248. Object.defineProperty(RenderTargetTexture.prototype, "onAfterUnbind", {
  58249. /**
  58250. * Set a after unbind callback in the texture.
  58251. * This has been kept for backward compatibility and use of onAfterUnbindObservable is recommended.
  58252. */
  58253. set: function (callback) {
  58254. if (this._onAfterUnbindObserver) {
  58255. this.onAfterUnbindObservable.remove(this._onAfterUnbindObserver);
  58256. }
  58257. this._onAfterUnbindObserver = this.onAfterUnbindObservable.add(callback);
  58258. },
  58259. enumerable: true,
  58260. configurable: true
  58261. });
  58262. Object.defineProperty(RenderTargetTexture.prototype, "onBeforeRender", {
  58263. /**
  58264. * Set a before render callback in the texture.
  58265. * This has been kept for backward compatibility and use of onBeforeRenderObservable is recommended.
  58266. */
  58267. set: function (callback) {
  58268. if (this._onBeforeRenderObserver) {
  58269. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  58270. }
  58271. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  58272. },
  58273. enumerable: true,
  58274. configurable: true
  58275. });
  58276. Object.defineProperty(RenderTargetTexture.prototype, "onAfterRender", {
  58277. /**
  58278. * Set a after render callback in the texture.
  58279. * This has been kept for backward compatibility and use of onAfterRenderObservable is recommended.
  58280. */
  58281. set: function (callback) {
  58282. if (this._onAfterRenderObserver) {
  58283. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  58284. }
  58285. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  58286. },
  58287. enumerable: true,
  58288. configurable: true
  58289. });
  58290. Object.defineProperty(RenderTargetTexture.prototype, "onClear", {
  58291. /**
  58292. * Set a clear callback in the texture.
  58293. * This has been kept for backward compatibility and use of onClearObservable is recommended.
  58294. */
  58295. set: function (callback) {
  58296. if (this._onClearObserver) {
  58297. this.onClearObservable.remove(this._onClearObserver);
  58298. }
  58299. this._onClearObserver = this.onClearObservable.add(callback);
  58300. },
  58301. enumerable: true,
  58302. configurable: true
  58303. });
  58304. Object.defineProperty(RenderTargetTexture.prototype, "renderTargetOptions", {
  58305. /**
  58306. * Gets render target creation options that were used.
  58307. */
  58308. get: function () {
  58309. return this._renderTargetOptions;
  58310. },
  58311. enumerable: true,
  58312. configurable: true
  58313. });
  58314. RenderTargetTexture.prototype._onRatioRescale = function () {
  58315. if (this._sizeRatio) {
  58316. this.resize(this._initialSizeParameter);
  58317. }
  58318. };
  58319. Object.defineProperty(RenderTargetTexture.prototype, "boundingBoxSize", {
  58320. get: function () {
  58321. return this._boundingBoxSize;
  58322. },
  58323. /**
  58324. * Gets or sets the size of the bounding box associated with the texture (when in cube mode)
  58325. * When defined, the cubemap will switch to local mode
  58326. * @see https://community.arm.com/graphics/b/blog/posts/reflections-based-on-local-cubemaps-in-unity
  58327. * @example https://www.babylonjs-playground.com/#RNASML
  58328. */
  58329. set: function (value) {
  58330. if (this._boundingBoxSize && this._boundingBoxSize.equals(value)) {
  58331. return;
  58332. }
  58333. this._boundingBoxSize = value;
  58334. var scene = this.getScene();
  58335. if (scene) {
  58336. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].MATERIAL_TextureDirtyFlag);
  58337. }
  58338. },
  58339. enumerable: true,
  58340. configurable: true
  58341. });
  58342. /**
  58343. * Creates a depth stencil texture.
  58344. * This is only available in WebGL 2 or with the depth texture extension available.
  58345. * @param comparisonFunction Specifies the comparison function to set on the texture. If 0 or undefined, the texture is not in comparison mode
  58346. * @param bilinearFiltering Specifies whether or not bilinear filtering is enable on the texture
  58347. * @param generateStencil Specifies whether or not a stencil should be allocated in the texture
  58348. */
  58349. RenderTargetTexture.prototype.createDepthStencilTexture = function (comparisonFunction, bilinearFiltering, generateStencil) {
  58350. if (comparisonFunction === void 0) { comparisonFunction = 0; }
  58351. if (bilinearFiltering === void 0) { bilinearFiltering = true; }
  58352. if (generateStencil === void 0) { generateStencil = false; }
  58353. if (!this.getScene()) {
  58354. return;
  58355. }
  58356. var engine = this.getScene().getEngine();
  58357. this.depthStencilTexture = engine.createDepthStencilTexture(this._size, {
  58358. bilinearFiltering: bilinearFiltering,
  58359. comparisonFunction: comparisonFunction,
  58360. generateStencil: generateStencil,
  58361. isCube: this.isCube
  58362. });
  58363. engine.setFrameBufferDepthStencilTexture(this);
  58364. };
  58365. RenderTargetTexture.prototype._processSizeParameter = function (size) {
  58366. if (size.ratio) {
  58367. this._sizeRatio = size.ratio;
  58368. this._size = {
  58369. width: this._bestReflectionRenderTargetDimension(this._engine.getRenderWidth(), this._sizeRatio),
  58370. height: this._bestReflectionRenderTargetDimension(this._engine.getRenderHeight(), this._sizeRatio)
  58371. };
  58372. }
  58373. else {
  58374. this._size = size;
  58375. }
  58376. };
  58377. Object.defineProperty(RenderTargetTexture.prototype, "samples", {
  58378. /**
  58379. * Define the number of samples to use in case of MSAA.
  58380. * It defaults to one meaning no MSAA has been enabled.
  58381. */
  58382. get: function () {
  58383. return this._samples;
  58384. },
  58385. set: function (value) {
  58386. if (this._samples === value) {
  58387. return;
  58388. }
  58389. var scene = this.getScene();
  58390. if (!scene) {
  58391. return;
  58392. }
  58393. this._samples = scene.getEngine().updateRenderTargetTextureSampleCount(this._texture, value);
  58394. },
  58395. enumerable: true,
  58396. configurable: true
  58397. });
  58398. /**
  58399. * Resets the refresh counter of the texture and start bak from scratch.
  58400. * Could be useful to regenerate the texture if it is setup to render only once.
  58401. */
  58402. RenderTargetTexture.prototype.resetRefreshCounter = function () {
  58403. this._currentRefreshId = -1;
  58404. };
  58405. Object.defineProperty(RenderTargetTexture.prototype, "refreshRate", {
  58406. /**
  58407. * Define the refresh rate of the texture or the rendering frequency.
  58408. * Use 0 to render just once, 1 to render on every frame, 2 to render every two frames and so on...
  58409. */
  58410. get: function () {
  58411. return this._refreshRate;
  58412. },
  58413. set: function (value) {
  58414. this._refreshRate = value;
  58415. this.resetRefreshCounter();
  58416. },
  58417. enumerable: true,
  58418. configurable: true
  58419. });
  58420. /**
  58421. * Adds a post process to the render target rendering passes.
  58422. * @param postProcess define the post process to add
  58423. */
  58424. RenderTargetTexture.prototype.addPostProcess = function (postProcess) {
  58425. if (!this._postProcessManager) {
  58426. var scene = this.getScene();
  58427. if (!scene) {
  58428. return;
  58429. }
  58430. this._postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_5__["PostProcessManager"](scene);
  58431. this._postProcesses = new Array();
  58432. }
  58433. this._postProcesses.push(postProcess);
  58434. this._postProcesses[0].autoClear = false;
  58435. };
  58436. /**
  58437. * Clear all the post processes attached to the render target
  58438. * @param dispose define if the cleared post processesshould also be disposed (false by default)
  58439. */
  58440. RenderTargetTexture.prototype.clearPostProcesses = function (dispose) {
  58441. if (dispose === void 0) { dispose = false; }
  58442. if (!this._postProcesses) {
  58443. return;
  58444. }
  58445. if (dispose) {
  58446. for (var _i = 0, _a = this._postProcesses; _i < _a.length; _i++) {
  58447. var postProcess = _a[_i];
  58448. postProcess.dispose();
  58449. }
  58450. }
  58451. this._postProcesses = [];
  58452. };
  58453. /**
  58454. * Remove one of the post process from the list of attached post processes to the texture
  58455. * @param postProcess define the post process to remove from the list
  58456. */
  58457. RenderTargetTexture.prototype.removePostProcess = function (postProcess) {
  58458. if (!this._postProcesses) {
  58459. return;
  58460. }
  58461. var index = this._postProcesses.indexOf(postProcess);
  58462. if (index === -1) {
  58463. return;
  58464. }
  58465. this._postProcesses.splice(index, 1);
  58466. if (this._postProcesses.length > 0) {
  58467. this._postProcesses[0].autoClear = false;
  58468. }
  58469. };
  58470. /** @hidden */
  58471. RenderTargetTexture.prototype._shouldRender = function () {
  58472. if (this._currentRefreshId === -1) { // At least render once
  58473. this._currentRefreshId = 1;
  58474. return true;
  58475. }
  58476. if (this.refreshRate === this._currentRefreshId) {
  58477. this._currentRefreshId = 1;
  58478. return true;
  58479. }
  58480. this._currentRefreshId++;
  58481. return false;
  58482. };
  58483. /**
  58484. * Gets the actual render size of the texture.
  58485. * @returns the width of the render size
  58486. */
  58487. RenderTargetTexture.prototype.getRenderSize = function () {
  58488. return this.getRenderWidth();
  58489. };
  58490. /**
  58491. * Gets the actual render width of the texture.
  58492. * @returns the width of the render size
  58493. */
  58494. RenderTargetTexture.prototype.getRenderWidth = function () {
  58495. if (this._size.width) {
  58496. return this._size.width;
  58497. }
  58498. return this._size;
  58499. };
  58500. /**
  58501. * Gets the actual render height of the texture.
  58502. * @returns the height of the render size
  58503. */
  58504. RenderTargetTexture.prototype.getRenderHeight = function () {
  58505. if (this._size.width) {
  58506. return this._size.height;
  58507. }
  58508. return this._size;
  58509. };
  58510. Object.defineProperty(RenderTargetTexture.prototype, "canRescale", {
  58511. /**
  58512. * Get if the texture can be rescaled or not.
  58513. */
  58514. get: function () {
  58515. return true;
  58516. },
  58517. enumerable: true,
  58518. configurable: true
  58519. });
  58520. /**
  58521. * Resize the texture using a ratio.
  58522. * @param ratio the ratio to apply to the texture size in order to compute the new target size
  58523. */
  58524. RenderTargetTexture.prototype.scale = function (ratio) {
  58525. var newSize = this.getRenderSize() * ratio;
  58526. this.resize(newSize);
  58527. };
  58528. /**
  58529. * Get the texture reflection matrix used to rotate/transform the reflection.
  58530. * @returns the reflection matrix
  58531. */
  58532. RenderTargetTexture.prototype.getReflectionTextureMatrix = function () {
  58533. if (this.isCube) {
  58534. return this._textureMatrix;
  58535. }
  58536. return _super.prototype.getReflectionTextureMatrix.call(this);
  58537. };
  58538. /**
  58539. * Resize the texture to a new desired size.
  58540. * Be carrefull as it will recreate all the data in the new texture.
  58541. * @param size Define the new size. It can be:
  58542. * - a number for squared texture,
  58543. * - an object containing { width: number, height: number }
  58544. * - or an object containing a ratio { ratio: number }
  58545. */
  58546. RenderTargetTexture.prototype.resize = function (size) {
  58547. this.releaseInternalTexture();
  58548. var scene = this.getScene();
  58549. if (!scene) {
  58550. return;
  58551. }
  58552. this._processSizeParameter(size);
  58553. if (this.isCube) {
  58554. this._texture = scene.getEngine().createRenderTargetCubeTexture(this.getRenderSize(), this._renderTargetOptions);
  58555. }
  58556. else {
  58557. this._texture = scene.getEngine().createRenderTargetTexture(this._size, this._renderTargetOptions);
  58558. }
  58559. };
  58560. /**
  58561. * Renders all the objects from the render list into the texture.
  58562. * @param useCameraPostProcess Define if camera post processes should be used during the rendering
  58563. * @param dumpForDebug Define if the rendering result should be dumped (copied) for debugging purpose
  58564. */
  58565. RenderTargetTexture.prototype.render = function (useCameraPostProcess, dumpForDebug) {
  58566. if (useCameraPostProcess === void 0) { useCameraPostProcess = false; }
  58567. if (dumpForDebug === void 0) { dumpForDebug = false; }
  58568. var scene = this.getScene();
  58569. if (!scene) {
  58570. return;
  58571. }
  58572. var engine = scene.getEngine();
  58573. if (this.useCameraPostProcesses !== undefined) {
  58574. useCameraPostProcess = this.useCameraPostProcesses;
  58575. }
  58576. if (this._waitingRenderList) {
  58577. this.renderList = [];
  58578. for (var index = 0; index < this._waitingRenderList.length; index++) {
  58579. var id = this._waitingRenderList[index];
  58580. var mesh_1 = scene.getMeshByID(id);
  58581. if (mesh_1) {
  58582. this.renderList.push(mesh_1);
  58583. }
  58584. }
  58585. delete this._waitingRenderList;
  58586. }
  58587. // Is predicate defined?
  58588. if (this.renderListPredicate) {
  58589. if (this.renderList) {
  58590. this.renderList.length = 0; // Clear previous renderList
  58591. }
  58592. else {
  58593. this.renderList = [];
  58594. }
  58595. var scene = this.getScene();
  58596. if (!scene) {
  58597. return;
  58598. }
  58599. var sceneMeshes = scene.meshes;
  58600. for (var index = 0; index < sceneMeshes.length; index++) {
  58601. var mesh = sceneMeshes[index];
  58602. if (this.renderListPredicate(mesh)) {
  58603. this.renderList.push(mesh);
  58604. }
  58605. }
  58606. }
  58607. this.onBeforeBindObservable.notifyObservers(this);
  58608. // Set custom projection.
  58609. // Needs to be before binding to prevent changing the aspect ratio.
  58610. var camera;
  58611. if (this.activeCamera) {
  58612. camera = this.activeCamera;
  58613. engine.setViewport(this.activeCamera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58614. if (this.activeCamera !== scene.activeCamera) {
  58615. scene.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(true));
  58616. }
  58617. }
  58618. else {
  58619. camera = scene.activeCamera;
  58620. if (camera) {
  58621. engine.setViewport(camera.viewport, this.getRenderWidth(), this.getRenderHeight());
  58622. }
  58623. }
  58624. // Prepare renderingManager
  58625. this._renderingManager.reset();
  58626. var currentRenderList = this.renderList ? this.renderList : scene.getActiveMeshes().data;
  58627. var currentRenderListLength = this.renderList ? this.renderList.length : scene.getActiveMeshes().length;
  58628. var sceneRenderId = scene.getRenderId();
  58629. for (var meshIndex = 0; meshIndex < currentRenderListLength; meshIndex++) {
  58630. var mesh = currentRenderList[meshIndex];
  58631. if (mesh) {
  58632. if (!mesh.isReady(this.refreshRate === 0)) {
  58633. this.resetRefreshCounter();
  58634. continue;
  58635. }
  58636. mesh._preActivateForIntermediateRendering(sceneRenderId);
  58637. var isMasked = void 0;
  58638. if (!this.renderList && camera) {
  58639. isMasked = ((mesh.layerMask & camera.layerMask) === 0);
  58640. }
  58641. else {
  58642. isMasked = false;
  58643. }
  58644. if (mesh.isEnabled() && mesh.isVisible && mesh.subMeshes && !isMasked) {
  58645. mesh._activate(sceneRenderId);
  58646. for (var subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  58647. var subMesh = mesh.subMeshes[subIndex];
  58648. scene._activeIndices.addCount(subMesh.indexCount, false);
  58649. this._renderingManager.dispatch(subMesh, mesh);
  58650. }
  58651. }
  58652. }
  58653. }
  58654. for (var particleIndex = 0; particleIndex < scene.particleSystems.length; particleIndex++) {
  58655. var particleSystem = scene.particleSystems[particleIndex];
  58656. var emitter = particleSystem.emitter;
  58657. if (!particleSystem.isStarted() || !emitter || !emitter.position || !emitter.isEnabled()) {
  58658. continue;
  58659. }
  58660. if (currentRenderList.indexOf(emitter) >= 0) {
  58661. this._renderingManager.dispatchParticles(particleSystem);
  58662. }
  58663. }
  58664. if (this.isCube) {
  58665. for (var face = 0; face < 6; face++) {
  58666. this.renderToTarget(face, currentRenderList, useCameraPostProcess, dumpForDebug);
  58667. scene.incrementRenderId();
  58668. scene.resetCachedMaterial();
  58669. }
  58670. }
  58671. else {
  58672. this.renderToTarget(0, currentRenderList, useCameraPostProcess, dumpForDebug);
  58673. }
  58674. this.onAfterUnbindObservable.notifyObservers(this);
  58675. if (scene.activeCamera) {
  58676. if (this.activeCamera && this.activeCamera !== scene.activeCamera) {
  58677. scene.setTransformMatrix(scene.activeCamera.getViewMatrix(), scene.activeCamera.getProjectionMatrix(true));
  58678. }
  58679. engine.setViewport(scene.activeCamera.viewport);
  58680. }
  58681. scene.resetCachedMaterial();
  58682. };
  58683. RenderTargetTexture.prototype._bestReflectionRenderTargetDimension = function (renderDimension, scale) {
  58684. var minimum = 128;
  58685. var x = renderDimension * scale;
  58686. var curved = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].NearestPOT(x + (minimum * minimum / (minimum + x)));
  58687. // Ensure we don't exceed the render dimension (while staying POT)
  58688. return Math.min(_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].FloorPOT(renderDimension), curved);
  58689. };
  58690. RenderTargetTexture.prototype.unbindFrameBuffer = function (engine, faceIndex) {
  58691. var _this = this;
  58692. if (!this._texture) {
  58693. return;
  58694. }
  58695. engine.unBindFramebuffer(this._texture, this.isCube, function () {
  58696. _this.onAfterRenderObservable.notifyObservers(faceIndex);
  58697. });
  58698. };
  58699. RenderTargetTexture.prototype.renderToTarget = function (faceIndex, currentRenderList, useCameraPostProcess, dumpForDebug) {
  58700. var scene = this.getScene();
  58701. if (!scene) {
  58702. return;
  58703. }
  58704. var engine = scene.getEngine();
  58705. if (!this._texture) {
  58706. return;
  58707. }
  58708. // Bind
  58709. if (this._postProcessManager) {
  58710. this._postProcessManager._prepareFrame(this._texture, this._postProcesses);
  58711. }
  58712. else if (!useCameraPostProcess || !scene.postProcessManager._prepareFrame(this._texture)) {
  58713. if (this._texture) {
  58714. engine.bindFramebuffer(this._texture, this.isCube ? faceIndex : undefined, undefined, undefined, this.ignoreCameraViewport, this.depthStencilTexture ? this.depthStencilTexture : undefined);
  58715. }
  58716. }
  58717. this.onBeforeRenderObservable.notifyObservers(faceIndex);
  58718. // Clear
  58719. if (this.onClearObservable.hasObservers()) {
  58720. this.onClearObservable.notifyObservers(engine);
  58721. }
  58722. else {
  58723. engine.clear(this.clearColor || scene.clearColor, true, true, true);
  58724. }
  58725. if (!this._doNotChangeAspectRatio) {
  58726. scene.updateTransformMatrix(true);
  58727. }
  58728. // Before Camera Draw
  58729. for (var _i = 0, _a = scene._beforeRenderTargetDrawStage; _i < _a.length; _i++) {
  58730. var step = _a[_i];
  58731. step.action(this);
  58732. }
  58733. // Render
  58734. this._renderingManager.render(this.customRenderFunction, currentRenderList, this.renderParticles, this.renderSprites);
  58735. // After Camera Draw
  58736. for (var _b = 0, _c = scene._afterRenderTargetDrawStage; _b < _c.length; _b++) {
  58737. var step = _c[_b];
  58738. step.action(this);
  58739. }
  58740. if (this._postProcessManager) {
  58741. this._postProcessManager._finalizeFrame(false, this._texture, faceIndex, this._postProcesses, this.ignoreCameraViewport);
  58742. }
  58743. else if (useCameraPostProcess) {
  58744. scene.postProcessManager._finalizeFrame(false, this._texture, faceIndex);
  58745. }
  58746. if (!this._doNotChangeAspectRatio) {
  58747. scene.updateTransformMatrix(true);
  58748. }
  58749. // Dump ?
  58750. if (dumpForDebug) {
  58751. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].DumpFramebuffer(this.getRenderWidth(), this.getRenderHeight(), engine);
  58752. }
  58753. // Unbind
  58754. if (!this.isCube || faceIndex === 5) {
  58755. if (this.isCube) {
  58756. if (faceIndex === 5) {
  58757. engine.generateMipMapsForCubemap(this._texture);
  58758. }
  58759. }
  58760. this.unbindFrameBuffer(engine, faceIndex);
  58761. }
  58762. else {
  58763. this.onAfterRenderObservable.notifyObservers(faceIndex);
  58764. }
  58765. };
  58766. /**
  58767. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  58768. * This allowed control for front to back rendering or reversly depending of the special needs.
  58769. *
  58770. * @param renderingGroupId The rendering group id corresponding to its index
  58771. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  58772. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  58773. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  58774. */
  58775. RenderTargetTexture.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  58776. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  58777. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  58778. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  58779. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  58780. };
  58781. /**
  58782. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  58783. *
  58784. * @param renderingGroupId The rendering group id corresponding to its index
  58785. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  58786. */
  58787. RenderTargetTexture.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  58788. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  58789. this._renderingManager._useSceneAutoClearSetup = false;
  58790. };
  58791. /**
  58792. * Clones the texture.
  58793. * @returns the cloned texture
  58794. */
  58795. RenderTargetTexture.prototype.clone = function () {
  58796. var textureSize = this.getSize();
  58797. 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);
  58798. // Base texture
  58799. newTexture.hasAlpha = this.hasAlpha;
  58800. newTexture.level = this.level;
  58801. // RenderTarget Texture
  58802. newTexture.coordinatesMode = this.coordinatesMode;
  58803. if (this.renderList) {
  58804. newTexture.renderList = this.renderList.slice(0);
  58805. }
  58806. return newTexture;
  58807. };
  58808. /**
  58809. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  58810. * @returns The JSON representation of the texture
  58811. */
  58812. RenderTargetTexture.prototype.serialize = function () {
  58813. if (!this.name) {
  58814. return null;
  58815. }
  58816. var serializationObject = _super.prototype.serialize.call(this);
  58817. serializationObject.renderTargetSize = this.getRenderSize();
  58818. serializationObject.renderList = [];
  58819. if (this.renderList) {
  58820. for (var index = 0; index < this.renderList.length; index++) {
  58821. serializationObject.renderList.push(this.renderList[index].id);
  58822. }
  58823. }
  58824. return serializationObject;
  58825. };
  58826. /**
  58827. * This will remove the attached framebuffer objects. The texture will not be able to be used as render target anymore
  58828. */
  58829. RenderTargetTexture.prototype.disposeFramebufferObjects = function () {
  58830. var objBuffer = this.getInternalTexture();
  58831. var scene = this.getScene();
  58832. if (objBuffer && scene) {
  58833. scene.getEngine()._releaseFramebufferObjects(objBuffer);
  58834. }
  58835. };
  58836. /**
  58837. * Dispose the texture and release its associated resources.
  58838. */
  58839. RenderTargetTexture.prototype.dispose = function () {
  58840. if (this._postProcessManager) {
  58841. this._postProcessManager.dispose();
  58842. this._postProcessManager = null;
  58843. }
  58844. this.clearPostProcesses(true);
  58845. if (this._resizeObserver) {
  58846. this.getScene().getEngine().onResizeObservable.remove(this._resizeObserver);
  58847. this._resizeObserver = null;
  58848. }
  58849. this.renderList = null;
  58850. // Remove from custom render targets
  58851. var scene = this.getScene();
  58852. if (!scene) {
  58853. return;
  58854. }
  58855. var index = scene.customRenderTargets.indexOf(this);
  58856. if (index >= 0) {
  58857. scene.customRenderTargets.splice(index, 1);
  58858. }
  58859. for (var _i = 0, _a = scene.cameras; _i < _a.length; _i++) {
  58860. var camera = _a[_i];
  58861. index = camera.customRenderTargets.indexOf(this);
  58862. if (index >= 0) {
  58863. camera.customRenderTargets.splice(index, 1);
  58864. }
  58865. }
  58866. _super.prototype.dispose.call(this);
  58867. };
  58868. /** @hidden */
  58869. RenderTargetTexture.prototype._rebuild = function () {
  58870. if (this.refreshRate === RenderTargetTexture.REFRESHRATE_RENDER_ONCE) {
  58871. this.refreshRate = RenderTargetTexture.REFRESHRATE_RENDER_ONCE;
  58872. }
  58873. if (this._postProcessManager) {
  58874. this._postProcessManager._rebuild();
  58875. }
  58876. };
  58877. /**
  58878. * Clear the info related to rendering groups preventing retention point in material dispose.
  58879. */
  58880. RenderTargetTexture.prototype.freeRenderingGroups = function () {
  58881. if (this._renderingManager) {
  58882. this._renderingManager.freeRenderingGroups();
  58883. }
  58884. };
  58885. /**
  58886. * The texture will only be rendered once which can be useful to improve performance if everything in your render is static for instance.
  58887. */
  58888. RenderTargetTexture.REFRESHRATE_RENDER_ONCE = 0;
  58889. /**
  58890. * The texture will only be rendered rendered every frame and is recomended for dynamic contents.
  58891. */
  58892. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYFRAME = 1;
  58893. /**
  58894. * The texture will be rendered every 2 frames which could be enough if your dynamic objects are not
  58895. * the central point of your effect and can save a lot of performances.
  58896. */
  58897. RenderTargetTexture.REFRESHRATE_RENDER_ONEVERYTWOFRAMES = 2;
  58898. return RenderTargetTexture;
  58899. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  58900. _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  58901. return new RenderTargetTexture(name, renderTargetSize, scene, generateMipMaps);
  58902. };
  58903. /***/ }),
  58904. /***/ "./Materials/Textures/texture.ts":
  58905. /*!***************************************!*\
  58906. !*** ./Materials/Textures/texture.ts ***!
  58907. \***************************************/
  58908. /*! exports provided: Texture */
  58909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  58910. "use strict";
  58911. __webpack_require__.r(__webpack_exports__);
  58912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return Texture; });
  58913. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  58914. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  58915. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  58916. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  58917. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  58918. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  58919. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  58920. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../Misc/typeStore */ "./Misc/typeStore.ts");
  58921. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../Misc/devTools */ "./Misc/devTools.ts");
  58922. /**
  58923. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58924. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58925. */
  58926. var Texture = /** @class */ (function (_super) {
  58927. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Texture, _super);
  58928. /**
  58929. * Instantiates a new texture.
  58930. * This represents a texture in babylon. It can be easily loaded from a network, base64 or html input.
  58931. * @see http://doc.babylonjs.com/babylon101/materials#texture
  58932. * @param url define the url of the picture to load as a texture
  58933. * @param scene define the scene the texture will belong to
  58934. * @param noMipmap define if the texture will require mip maps or not
  58935. * @param invertY define if the texture needs to be inverted on the y axis during loading
  58936. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  58937. * @param onLoad define a callback triggered when the texture has been loaded
  58938. * @param onError define a callback triggered when an error occurred during the loading session
  58939. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  58940. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  58941. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  58942. */
  58943. function Texture(url, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format) {
  58944. if (noMipmap === void 0) { noMipmap = false; }
  58945. if (invertY === void 0) { invertY = true; }
  58946. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  58947. if (onLoad === void 0) { onLoad = null; }
  58948. if (onError === void 0) { onError = null; }
  58949. if (buffer === void 0) { buffer = null; }
  58950. if (deleteBuffer === void 0) { deleteBuffer = false; }
  58951. var _this = _super.call(this, scene) || this;
  58952. /**
  58953. * Define an offset on the texture to offset the u coordinates of the UVs
  58954. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58955. */
  58956. _this.uOffset = 0;
  58957. /**
  58958. * Define an offset on the texture to offset the v coordinates of the UVs
  58959. * @see http://doc.babylonjs.com/how_to/more_materials#offsetting
  58960. */
  58961. _this.vOffset = 0;
  58962. /**
  58963. * Define an offset on the texture to scale the u coordinates of the UVs
  58964. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58965. */
  58966. _this.uScale = 1.0;
  58967. /**
  58968. * Define an offset on the texture to scale the v coordinates of the UVs
  58969. * @see http://doc.babylonjs.com/how_to/more_materials#tiling
  58970. */
  58971. _this.vScale = 1.0;
  58972. /**
  58973. * Define an offset on the texture to rotate around the u coordinates of the UVs
  58974. * @see http://doc.babylonjs.com/how_to/more_materials
  58975. */
  58976. _this.uAng = 0;
  58977. /**
  58978. * Define an offset on the texture to rotate around the v coordinates of the UVs
  58979. * @see http://doc.babylonjs.com/how_to/more_materials
  58980. */
  58981. _this.vAng = 0;
  58982. /**
  58983. * Define an offset on the texture to rotate around the w coordinates of the UVs (in case of 3d texture)
  58984. * @see http://doc.babylonjs.com/how_to/more_materials
  58985. */
  58986. _this.wAng = 0;
  58987. /**
  58988. * Defines the center of rotation (U)
  58989. */
  58990. _this.uRotationCenter = 0.5;
  58991. /**
  58992. * Defines the center of rotation (V)
  58993. */
  58994. _this.vRotationCenter = 0.5;
  58995. /**
  58996. * Defines the center of rotation (W)
  58997. */
  58998. _this.wRotationCenter = 0.5;
  58999. /** @hidden */
  59000. _this._initialSamplingMode = Texture.BILINEAR_SAMPLINGMODE;
  59001. /**
  59002. * Observable triggered once the texture has been loaded.
  59003. */
  59004. _this.onLoadObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  59005. _this._isBlocking = true;
  59006. _this.name = url || "";
  59007. _this.url = url;
  59008. _this._noMipmap = noMipmap;
  59009. _this._invertY = invertY;
  59010. _this._initialSamplingMode = samplingMode;
  59011. _this._buffer = buffer;
  59012. _this._deleteBuffer = deleteBuffer;
  59013. if (format) {
  59014. _this._format = format;
  59015. }
  59016. scene = _this.getScene();
  59017. if (!scene) {
  59018. return _this;
  59019. }
  59020. scene.getEngine().onBeforeTextureInitObservable.notifyObservers(_this);
  59021. var load = function () {
  59022. if (_this._texture && _this._texture._invertVScale) {
  59023. _this.vScale = -1;
  59024. }
  59025. if (_this.onLoadObservable.hasObservers()) {
  59026. _this.onLoadObservable.notifyObservers(_this);
  59027. }
  59028. if (onLoad) {
  59029. onLoad();
  59030. }
  59031. if (!_this.isBlocking && scene) {
  59032. scene.resetCachedMaterial();
  59033. }
  59034. };
  59035. if (!_this.url) {
  59036. _this._delayedOnLoad = load;
  59037. _this._delayedOnError = onError;
  59038. return _this;
  59039. }
  59040. _this._texture = _this._getFromCache(_this.url, noMipmap, samplingMode);
  59041. if (!_this._texture) {
  59042. if (!scene.useDelayedTextureLoading) {
  59043. _this._texture = scene.getEngine().createTexture(_this.url, noMipmap, invertY, scene, samplingMode, load, onError, _this._buffer, undefined, _this._format);
  59044. if (deleteBuffer) {
  59045. delete _this._buffer;
  59046. }
  59047. }
  59048. else {
  59049. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59050. _this._delayedOnLoad = load;
  59051. _this._delayedOnError = onError;
  59052. }
  59053. }
  59054. else {
  59055. if (_this._texture.isReady) {
  59056. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(function () { return load(); });
  59057. }
  59058. else {
  59059. _this._texture.onLoadedObservable.add(load);
  59060. }
  59061. }
  59062. return _this;
  59063. }
  59064. Object.defineProperty(Texture.prototype, "noMipmap", {
  59065. /**
  59066. * Are mip maps generated for this texture or not.
  59067. */
  59068. get: function () {
  59069. return this._noMipmap;
  59070. },
  59071. enumerable: true,
  59072. configurable: true
  59073. });
  59074. Object.defineProperty(Texture.prototype, "isBlocking", {
  59075. get: function () {
  59076. return this._isBlocking;
  59077. },
  59078. /**
  59079. * Is the texture preventing material to render while loading.
  59080. * If false, a default texture will be used instead of the loading one during the preparation step.
  59081. */
  59082. set: function (value) {
  59083. this._isBlocking = value;
  59084. },
  59085. enumerable: true,
  59086. configurable: true
  59087. });
  59088. Object.defineProperty(Texture.prototype, "samplingMode", {
  59089. /**
  59090. * Get the current sampling mode associated with the texture.
  59091. */
  59092. get: function () {
  59093. if (!this._texture) {
  59094. return this._initialSamplingMode;
  59095. }
  59096. return this._texture.samplingMode;
  59097. },
  59098. enumerable: true,
  59099. configurable: true
  59100. });
  59101. Object.defineProperty(Texture.prototype, "invertY", {
  59102. /**
  59103. * Gets a boolean indicating if the texture needs to be inverted on the y axis during loading
  59104. */
  59105. get: function () {
  59106. return this._invertY;
  59107. },
  59108. enumerable: true,
  59109. configurable: true
  59110. });
  59111. /**
  59112. * Update the url (and optional buffer) of this texture if url was null during construction.
  59113. * @param url the url of the texture
  59114. * @param buffer the buffer of the texture (defaults to null)
  59115. * @param onLoad callback called when the texture is loaded (defaults to null)
  59116. */
  59117. Texture.prototype.updateURL = function (url, buffer, onLoad) {
  59118. if (buffer === void 0) { buffer = null; }
  59119. if (this.url) {
  59120. this.releaseInternalTexture();
  59121. this.getScene().markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag);
  59122. }
  59123. this.url = url;
  59124. this._buffer = buffer;
  59125. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  59126. if (onLoad) {
  59127. this._delayedOnLoad = onLoad;
  59128. }
  59129. this.delayLoad();
  59130. };
  59131. /**
  59132. * Finish the loading sequence of a texture flagged as delayed load.
  59133. * @hidden
  59134. */
  59135. Texture.prototype.delayLoad = function () {
  59136. if (this.delayLoadState !== _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  59137. return;
  59138. }
  59139. var scene = this.getScene();
  59140. if (!scene) {
  59141. return;
  59142. }
  59143. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  59144. this._texture = this._getFromCache(this.url, this._noMipmap, this.samplingMode);
  59145. if (!this._texture) {
  59146. this._texture = scene.getEngine().createTexture(this.url, this._noMipmap, this._invertY, scene, this.samplingMode, this._delayedOnLoad, this._delayedOnError, this._buffer, null, this._format);
  59147. if (this._deleteBuffer) {
  59148. delete this._buffer;
  59149. }
  59150. }
  59151. else {
  59152. if (this._delayedOnLoad) {
  59153. if (this._texture.isReady) {
  59154. _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].SetImmediate(this._delayedOnLoad);
  59155. }
  59156. else {
  59157. this._texture.onLoadedObservable.add(this._delayedOnLoad);
  59158. }
  59159. }
  59160. }
  59161. this._delayedOnLoad = null;
  59162. this._delayedOnError = null;
  59163. };
  59164. Texture.prototype._prepareRowForTextureGeneration = function (x, y, z, t) {
  59165. x *= this.uScale;
  59166. y *= this.vScale;
  59167. x -= this.uRotationCenter * this.uScale;
  59168. y -= this.vRotationCenter * this.vScale;
  59169. z -= this.wRotationCenter;
  59170. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, this._rowGenerationMatrix, t);
  59171. t.x += this.uRotationCenter * this.uScale + this.uOffset;
  59172. t.y += this.vRotationCenter * this.vScale + this.vOffset;
  59173. t.z += this.wRotationCenter;
  59174. };
  59175. /**
  59176. * Get the current texture matrix which includes the requested offsetting, tiling and rotation components.
  59177. * @returns the transform matrix of the texture.
  59178. */
  59179. Texture.prototype.getTextureMatrix = function () {
  59180. var _this = this;
  59181. if (this.uOffset === this._cachedUOffset &&
  59182. this.vOffset === this._cachedVOffset &&
  59183. this.uScale === this._cachedUScale &&
  59184. this.vScale === this._cachedVScale &&
  59185. this.uAng === this._cachedUAng &&
  59186. this.vAng === this._cachedVAng &&
  59187. this.wAng === this._cachedWAng) {
  59188. return this._cachedTextureMatrix;
  59189. }
  59190. this._cachedUOffset = this.uOffset;
  59191. this._cachedVOffset = this.vOffset;
  59192. this._cachedUScale = this.uScale;
  59193. this._cachedVScale = this.vScale;
  59194. this._cachedUAng = this.uAng;
  59195. this._cachedVAng = this.vAng;
  59196. this._cachedWAng = this.wAng;
  59197. if (!this._cachedTextureMatrix) {
  59198. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  59199. this._rowGenerationMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"]();
  59200. this._t0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  59201. this._t1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  59202. this._t2 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Zero();
  59203. }
  59204. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].RotationYawPitchRollToRef(this.vAng, this.uAng, this.wAng, this._rowGenerationMatrix);
  59205. this._prepareRowForTextureGeneration(0, 0, 0, this._t0);
  59206. this._prepareRowForTextureGeneration(1.0, 0, 0, this._t1);
  59207. this._prepareRowForTextureGeneration(0, 1.0, 0, this._t2);
  59208. this._t1.subtractInPlace(this._t0);
  59209. this._t2.subtractInPlace(this._t0);
  59210. _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);
  59211. var scene = this.getScene();
  59212. if (!scene) {
  59213. return this._cachedTextureMatrix;
  59214. }
  59215. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  59216. return mat.hasTexture(_this);
  59217. });
  59218. return this._cachedTextureMatrix;
  59219. };
  59220. /**
  59221. * Get the current matrix used to apply reflection. This is useful to rotate an environment texture for instance.
  59222. * @returns The reflection texture transform
  59223. */
  59224. Texture.prototype.getReflectionTextureMatrix = function () {
  59225. var _this = this;
  59226. var scene = this.getScene();
  59227. if (!scene) {
  59228. return this._cachedTextureMatrix;
  59229. }
  59230. if (this.uOffset === this._cachedUOffset &&
  59231. this.vOffset === this._cachedVOffset &&
  59232. this.uScale === this._cachedUScale &&
  59233. this.vScale === this._cachedVScale &&
  59234. this.coordinatesMode === this._cachedCoordinatesMode) {
  59235. if (this.coordinatesMode === Texture.PROJECTION_MODE) {
  59236. if (this._cachedProjectionMatrixId === scene.getProjectionMatrix().updateFlag) {
  59237. return this._cachedTextureMatrix;
  59238. }
  59239. }
  59240. else {
  59241. return this._cachedTextureMatrix;
  59242. }
  59243. }
  59244. if (!this._cachedTextureMatrix) {
  59245. this._cachedTextureMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  59246. }
  59247. if (!this._projectionModeMatrix) {
  59248. this._projectionModeMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  59249. }
  59250. this._cachedUOffset = this.uOffset;
  59251. this._cachedVOffset = this.vOffset;
  59252. this._cachedUScale = this.uScale;
  59253. this._cachedVScale = this.vScale;
  59254. this._cachedCoordinatesMode = this.coordinatesMode;
  59255. switch (this.coordinatesMode) {
  59256. case Texture.PLANAR_MODE:
  59257. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  59258. this._cachedTextureMatrix[0] = this.uScale;
  59259. this._cachedTextureMatrix[5] = this.vScale;
  59260. this._cachedTextureMatrix[12] = this.uOffset;
  59261. this._cachedTextureMatrix[13] = this.vOffset;
  59262. break;
  59263. case Texture.PROJECTION_MODE:
  59264. _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);
  59265. var projectionMatrix = scene.getProjectionMatrix();
  59266. this._cachedProjectionMatrixId = projectionMatrix.updateFlag;
  59267. projectionMatrix.multiplyToRef(this._projectionModeMatrix, this._cachedTextureMatrix);
  59268. break;
  59269. default:
  59270. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].IdentityToRef(this._cachedTextureMatrix);
  59271. break;
  59272. }
  59273. scene.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].MATERIAL_TextureDirtyFlag, function (mat) {
  59274. return (mat.getActiveTextures().indexOf(_this) !== -1);
  59275. });
  59276. return this._cachedTextureMatrix;
  59277. };
  59278. /**
  59279. * Clones the texture.
  59280. * @returns the cloned texture
  59281. */
  59282. Texture.prototype.clone = function () {
  59283. var _this = this;
  59284. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () {
  59285. return new Texture(_this._texture ? _this._texture.url : null, _this.getScene(), _this._noMipmap, _this._invertY, _this.samplingMode);
  59286. }, this);
  59287. };
  59288. /**
  59289. * Serialize the texture to a JSON representation we can easily use in the resepective Parse function.
  59290. * @returns The JSON representation of the texture
  59291. */
  59292. Texture.prototype.serialize = function () {
  59293. var serializationObject = _super.prototype.serialize.call(this);
  59294. if (typeof this._buffer === "string" && this._buffer.substr(0, 5) === "data:") {
  59295. serializationObject.base64String = this._buffer;
  59296. serializationObject.name = serializationObject.name.replace("data:", "");
  59297. }
  59298. serializationObject.invertY = this._invertY;
  59299. serializationObject.samplingMode = this.samplingMode;
  59300. return serializationObject;
  59301. };
  59302. /**
  59303. * Get the current class name of the texture useful for serialization or dynamic coding.
  59304. * @returns "Texture"
  59305. */
  59306. Texture.prototype.getClassName = function () {
  59307. return "Texture";
  59308. };
  59309. /**
  59310. * Dispose the texture and release its associated resources.
  59311. */
  59312. Texture.prototype.dispose = function () {
  59313. _super.prototype.dispose.call(this);
  59314. this.onLoadObservable.clear();
  59315. this._delayedOnLoad = null;
  59316. this._delayedOnError = null;
  59317. };
  59318. /**
  59319. * Parse the JSON representation of a texture in order to recreate the texture in the given scene.
  59320. * @param parsedTexture Define the JSON representation of the texture
  59321. * @param scene Define the scene the parsed texture should be instantiated in
  59322. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  59323. * @returns The parsed texture if successful
  59324. */
  59325. Texture.Parse = function (parsedTexture, scene, rootUrl) {
  59326. if (parsedTexture.customType) {
  59327. var customTexture = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Instantiate(parsedTexture.customType);
  59328. // Update Sampling Mode
  59329. var parsedCustomTexture = customTexture.Parse(parsedTexture, scene, rootUrl);
  59330. if (parsedTexture.samplingMode && parsedCustomTexture.updateSamplingMode && parsedCustomTexture._samplingMode) {
  59331. if (parsedCustomTexture._samplingMode !== parsedTexture.samplingMode) {
  59332. parsedCustomTexture.updateSamplingMode(parsedTexture.samplingMode);
  59333. }
  59334. }
  59335. return parsedCustomTexture;
  59336. }
  59337. if (parsedTexture.isCube && !parsedTexture.isRenderTarget) {
  59338. return Texture._CubeTextureParser(parsedTexture, scene, rootUrl);
  59339. }
  59340. if (!parsedTexture.name && !parsedTexture.isRenderTarget) {
  59341. return null;
  59342. }
  59343. var texture = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () {
  59344. var generateMipMaps = true;
  59345. if (parsedTexture.noMipmap) {
  59346. generateMipMaps = false;
  59347. }
  59348. if (parsedTexture.mirrorPlane) {
  59349. var mirrorTexture = Texture._CreateMirror(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  59350. mirrorTexture._waitingRenderList = parsedTexture.renderList;
  59351. mirrorTexture.mirrorPlane = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"].FromArray(parsedTexture.mirrorPlane);
  59352. return mirrorTexture;
  59353. }
  59354. else if (parsedTexture.isRenderTarget) {
  59355. var renderTargetTexture = null;
  59356. if (parsedTexture.isCube) {
  59357. // Search for an existing reflection probe (which contains a cube render target texture)
  59358. if (scene.reflectionProbes) {
  59359. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  59360. var probe = scene.reflectionProbes[index];
  59361. if (probe.name === parsedTexture.name) {
  59362. return probe.cubeTexture;
  59363. }
  59364. }
  59365. }
  59366. }
  59367. else {
  59368. renderTargetTexture = Texture._CreateRenderTargetTexture(parsedTexture.name, parsedTexture.renderTargetSize, scene, generateMipMaps);
  59369. renderTargetTexture._waitingRenderList = parsedTexture.renderList;
  59370. }
  59371. return renderTargetTexture;
  59372. }
  59373. else {
  59374. var texture;
  59375. if (parsedTexture.base64String) {
  59376. texture = Texture.CreateFromBase64String(parsedTexture.base64String, parsedTexture.name, scene, !generateMipMaps);
  59377. }
  59378. else {
  59379. var url = rootUrl + parsedTexture.name;
  59380. if (Texture.UseSerializedUrlIfAny && parsedTexture.url) {
  59381. url = parsedTexture.url;
  59382. }
  59383. texture = new Texture(url, scene, !generateMipMaps, parsedTexture.invertY);
  59384. }
  59385. return texture;
  59386. }
  59387. }, parsedTexture, scene);
  59388. // Update Sampling Mode
  59389. if (parsedTexture.samplingMode) {
  59390. var sampling = parsedTexture.samplingMode;
  59391. if (texture && texture.samplingMode !== sampling) {
  59392. texture.updateSamplingMode(sampling);
  59393. }
  59394. }
  59395. // Animations
  59396. if (texture && parsedTexture.animations) {
  59397. for (var animationIndex = 0; animationIndex < parsedTexture.animations.length; animationIndex++) {
  59398. var parsedAnimation = parsedTexture.animations[animationIndex];
  59399. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_7__["_TypeStore"].GetClass("BABYLON.Animation");
  59400. if (internalClass) {
  59401. texture.animations.push(internalClass.Parse(parsedAnimation));
  59402. }
  59403. }
  59404. }
  59405. return texture;
  59406. };
  59407. /**
  59408. * Creates a texture from its base 64 representation.
  59409. * @param data Define the base64 payload without the data: prefix
  59410. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  59411. * @param scene Define the scene the texture should belong to
  59412. * @param noMipmap Forces the texture to not create mip map information if true
  59413. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59414. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59415. * @param onLoad define a callback triggered when the texture has been loaded
  59416. * @param onError define a callback triggered when an error occurred during the loading session
  59417. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59418. * @returns the created texture
  59419. */
  59420. Texture.CreateFromBase64String = function (data, name, scene, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59421. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59422. if (onLoad === void 0) { onLoad = null; }
  59423. if (onError === void 0) { onError = null; }
  59424. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59425. return new Texture("data:" + name, scene, noMipmap, invertY, samplingMode, onLoad, onError, data, false, format);
  59426. };
  59427. /**
  59428. * Creates a texture from its data: representation. (data: will be added in case only the payload has been passed in)
  59429. * @param data Define the base64 payload without the data: prefix
  59430. * @param name Define the name of the texture in the scene useful fo caching purpose for instance
  59431. * @param buffer define the buffer to load the texture from in case the texture is loaded from a buffer representation
  59432. * @param scene Define the scene the texture should belong to
  59433. * @param deleteBuffer define if the buffer we are loading the texture from should be deleted after load
  59434. * @param noMipmap Forces the texture to not create mip map information if true
  59435. * @param invertY define if the texture needs to be inverted on the y axis during loading
  59436. * @param samplingMode define the sampling mode we want for the texture while fectching from it (Texture.NEAREST_SAMPLINGMODE...)
  59437. * @param onLoad define a callback triggered when the texture has been loaded
  59438. * @param onError define a callback triggered when an error occurred during the loading session
  59439. * @param format define the format of the texture we are trying to load (Engine.TEXTUREFORMAT_RGBA...)
  59440. * @returns the created texture
  59441. */
  59442. Texture.LoadFromDataString = function (name, buffer, scene, deleteBuffer, noMipmap, invertY, samplingMode, onLoad, onError, format) {
  59443. if (deleteBuffer === void 0) { deleteBuffer = false; }
  59444. if (noMipmap === void 0) { noMipmap = false; }
  59445. if (invertY === void 0) { invertY = true; }
  59446. if (samplingMode === void 0) { samplingMode = Texture.TRILINEAR_SAMPLINGMODE; }
  59447. if (onLoad === void 0) { onLoad = null; }
  59448. if (onError === void 0) { onError = null; }
  59449. if (format === void 0) { format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA; }
  59450. if (name.substr(0, 5) !== "data:") {
  59451. name = "data:" + name;
  59452. }
  59453. return new Texture(name, scene, noMipmap, invertY, samplingMode, onLoad, onError, buffer, deleteBuffer, format);
  59454. };
  59455. /** @hidden */
  59456. Texture._CubeTextureParser = function (jsonTexture, scene, rootUrl) {
  59457. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("CubeTexture");
  59458. };
  59459. /** @hidden */
  59460. Texture._CreateMirror = function (name, renderTargetSize, scene, generateMipMaps) {
  59461. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("MirrorTexture");
  59462. };
  59463. /** @hidden */
  59464. Texture._CreateRenderTargetTexture = function (name, renderTargetSize, scene, generateMipMaps) {
  59465. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("RenderTargetTexture");
  59466. };
  59467. /** nearest is mag = nearest and min = nearest and mip = linear */
  59468. Texture.NEAREST_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  59469. /** nearest is mag = nearest and min = nearest and mip = linear */
  59470. 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
  59471. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59472. Texture.BILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE;
  59473. /** Bilinear is mag = linear and min = linear and mip = nearest */
  59474. 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
  59475. /** Trilinear is mag = linear and min = linear and mip = linear */
  59476. Texture.TRILINEAR_SAMPLINGMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE;
  59477. /** Trilinear is mag = linear and min = linear and mip = linear */
  59478. 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
  59479. /** mag = nearest and min = nearest and mip = nearest */
  59480. Texture.NEAREST_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST_MIPNEAREST;
  59481. /** mag = nearest and min = linear and mip = nearest */
  59482. Texture.NEAREST_LINEAR_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPNEAREST;
  59483. /** mag = nearest and min = linear and mip = linear */
  59484. Texture.NEAREST_LINEAR_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR_MIPLINEAR;
  59485. /** mag = nearest and min = linear and mip = none */
  59486. Texture.NEAREST_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_LINEAR;
  59487. /** mag = nearest and min = nearest and mip = none */
  59488. Texture.NEAREST_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_NEAREST;
  59489. /** mag = linear and min = nearest and mip = nearest */
  59490. Texture.LINEAR_NEAREST_MIPNEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPNEAREST;
  59491. /** mag = linear and min = nearest and mip = linear */
  59492. Texture.LINEAR_NEAREST_MIPLINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST_MIPLINEAR;
  59493. /** mag = linear and min = linear and mip = none */
  59494. Texture.LINEAR_LINEAR = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR;
  59495. /** mag = linear and min = nearest and mip = none */
  59496. Texture.LINEAR_NEAREST = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_NEAREST;
  59497. /** Explicit coordinates mode */
  59498. Texture.EXPLICIT_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EXPLICIT_MODE;
  59499. /** Spherical coordinates mode */
  59500. Texture.SPHERICAL_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SPHERICAL_MODE;
  59501. /** Planar coordinates mode */
  59502. Texture.PLANAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PLANAR_MODE;
  59503. /** Cubic coordinates mode */
  59504. Texture.CUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CUBIC_MODE;
  59505. /** Projection coordinates mode */
  59506. Texture.PROJECTION_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_PROJECTION_MODE;
  59507. /** Inverse Cubic coordinates mode */
  59508. Texture.SKYBOX_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_SKYBOX_MODE;
  59509. /** Inverse Cubic coordinates mode */
  59510. Texture.INVCUBIC_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_INVCUBIC_MODE;
  59511. /** Equirectangular coordinates mode */
  59512. Texture.EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_EQUIRECTANGULAR_MODE;
  59513. /** Equirectangular Fixed coordinates mode */
  59514. Texture.FIXED_EQUIRECTANGULAR_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MODE;
  59515. /** Equirectangular Fixed Mirrored coordinates mode */
  59516. Texture.FIXED_EQUIRECTANGULAR_MIRRORED_MODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_FIXED_EQUIRECTANGULAR_MIRRORED_MODE;
  59517. /** Texture is not repeating outside of 0..1 UVs */
  59518. Texture.CLAMP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_CLAMP_ADDRESSMODE;
  59519. /** Texture is repeating outside of 0..1 UVs */
  59520. Texture.WRAP_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_WRAP_ADDRESSMODE;
  59521. /** Texture is repeating and mirrored */
  59522. Texture.MIRROR_ADDRESSMODE = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_MIRROR_ADDRESSMODE;
  59523. /**
  59524. * 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
  59525. */
  59526. Texture.UseSerializedUrlIfAny = false;
  59527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59529. ], Texture.prototype, "url", void 0);
  59530. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59531. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59532. ], Texture.prototype, "uOffset", void 0);
  59533. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59534. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59535. ], Texture.prototype, "vOffset", void 0);
  59536. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59537. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59538. ], Texture.prototype, "uScale", void 0);
  59539. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59540. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59541. ], Texture.prototype, "vScale", void 0);
  59542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59544. ], Texture.prototype, "uAng", void 0);
  59545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59547. ], Texture.prototype, "vAng", void 0);
  59548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59550. ], Texture.prototype, "wAng", void 0);
  59551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59553. ], Texture.prototype, "uRotationCenter", void 0);
  59554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59556. ], Texture.prototype, "vRotationCenter", void 0);
  59557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59559. ], Texture.prototype, "wRotationCenter", void 0);
  59560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  59561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  59562. ], Texture.prototype, "isBlocking", null);
  59563. return Texture;
  59564. }(_Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"]));
  59565. // References the dependencies.
  59566. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._TextureParser = Texture.Parse;
  59567. /***/ }),
  59568. /***/ "./Materials/Textures/videoTexture.ts":
  59569. /*!********************************************!*\
  59570. !*** ./Materials/Textures/videoTexture.ts ***!
  59571. \********************************************/
  59572. /*! exports provided: VideoTexture */
  59573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59574. "use strict";
  59575. __webpack_require__.r(__webpack_exports__);
  59576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return VideoTexture; });
  59577. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59578. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/observable */ "./Misc/observable.ts");
  59579. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  59580. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  59581. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  59582. /**
  59583. * If you want to display a video in your scene, this is the special texture for that.
  59584. * This special texture works similar to other textures, with the exception of a few parameters.
  59585. * @see https://doc.babylonjs.com/how_to/video_texture
  59586. */
  59587. var VideoTexture = /** @class */ (function (_super) {
  59588. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VideoTexture, _super);
  59589. /**
  59590. * Creates a video texture.
  59591. * If you want to display a video in your scene, this is the special texture for that.
  59592. * This special texture works similar to other textures, with the exception of a few parameters.
  59593. * @see https://doc.babylonjs.com/how_to/video_texture
  59594. * @param name optional name, will detect from video source, if not defined
  59595. * @param src can be used to provide an url, array of urls or an already setup HTML video element.
  59596. * @param scene is obviously the current scene.
  59597. * @param generateMipMaps can be used to turn on mipmaps (Can be expensive for videoTextures because they are often updated).
  59598. * @param invertY is false by default but can be used to invert video on Y axis
  59599. * @param samplingMode controls the sampling method and is set to TRILINEAR_SAMPLINGMODE by default
  59600. * @param settings allows finer control over video usage
  59601. */
  59602. function VideoTexture(name, src, scene, generateMipMaps, invertY, samplingMode, settings) {
  59603. if (generateMipMaps === void 0) { generateMipMaps = false; }
  59604. if (invertY === void 0) { invertY = false; }
  59605. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  59606. if (settings === void 0) { settings = {
  59607. autoPlay: true,
  59608. loop: true,
  59609. autoUpdateTexture: true,
  59610. }; }
  59611. var _this = _super.call(this, null, scene, !generateMipMaps, invertY) || this;
  59612. _this._onUserActionRequestedObservable = null;
  59613. _this._stillImageCaptured = false;
  59614. _this._displayingPosterTexture = false;
  59615. _this._createInternalTexture = function () {
  59616. if (_this._texture != null) {
  59617. if (_this._displayingPosterTexture) {
  59618. _this._texture.dispose();
  59619. _this._displayingPosterTexture = false;
  59620. }
  59621. else {
  59622. return;
  59623. }
  59624. }
  59625. if (!_this._engine.needPOTTextures ||
  59626. (_Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoWidth) && _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].IsExponentOfTwo(_this.video.videoHeight))) {
  59627. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59628. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  59629. }
  59630. else {
  59631. _this.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59632. _this.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].CLAMP_ADDRESSMODE;
  59633. _this._generateMipMaps = false;
  59634. }
  59635. _this._texture = _this._engine.createDynamicTexture(_this.video.videoWidth, _this.video.videoHeight, _this._generateMipMaps, _this.samplingMode);
  59636. if (!_this.video.autoplay && !_this._settings.poster) {
  59637. var oldHandler_1 = _this.video.onplaying;
  59638. var error_1 = false;
  59639. var oldMuted_1 = _this.video.muted;
  59640. _this.video.muted = true;
  59641. _this.video.onplaying = function () {
  59642. _this.video.muted = oldMuted_1;
  59643. _this.video.onplaying = oldHandler_1;
  59644. _this._texture.isReady = true;
  59645. _this._updateInternalTexture();
  59646. if (!error_1) {
  59647. _this.video.pause();
  59648. }
  59649. if (_this.onLoadObservable.hasObservers()) {
  59650. _this.onLoadObservable.notifyObservers(_this);
  59651. }
  59652. };
  59653. var playing = _this.video.play();
  59654. if (playing) {
  59655. playing.then(function () {
  59656. // Everything is good.
  59657. })
  59658. .catch(function () {
  59659. error_1 = true;
  59660. // On Chrome for instance, new policies might prevent playing without user interaction.
  59661. if (_this._onUserActionRequestedObservable && _this._onUserActionRequestedObservable.hasObservers()) {
  59662. _this._onUserActionRequestedObservable.notifyObservers(_this);
  59663. }
  59664. });
  59665. }
  59666. else {
  59667. _this.video.onplaying = oldHandler_1;
  59668. _this._texture.isReady = true;
  59669. _this._updateInternalTexture();
  59670. if (_this.onLoadObservable.hasObservers()) {
  59671. _this.onLoadObservable.notifyObservers(_this);
  59672. }
  59673. }
  59674. }
  59675. else {
  59676. _this._texture.isReady = true;
  59677. _this._updateInternalTexture();
  59678. if (_this.onLoadObservable.hasObservers()) {
  59679. _this.onLoadObservable.notifyObservers(_this);
  59680. }
  59681. }
  59682. };
  59683. _this.reset = function () {
  59684. if (_this._texture == null) {
  59685. return;
  59686. }
  59687. if (!_this._displayingPosterTexture) {
  59688. _this._texture.dispose();
  59689. _this._texture = null;
  59690. }
  59691. };
  59692. _this._updateInternalTexture = function () {
  59693. if (_this._texture == null || !_this._texture.isReady) {
  59694. return;
  59695. }
  59696. if (_this.video.readyState < _this.video.HAVE_CURRENT_DATA) {
  59697. return;
  59698. }
  59699. if (_this._displayingPosterTexture) {
  59700. return;
  59701. }
  59702. _this._engine.updateVideoTexture(_this._texture, _this.video, _this._invertY);
  59703. };
  59704. _this._engine = _this.getScene().getEngine();
  59705. _this._generateMipMaps = generateMipMaps;
  59706. _this._initialSamplingMode = samplingMode;
  59707. _this.autoUpdateTexture = settings.autoUpdateTexture;
  59708. _this.name = name || _this._getName(src);
  59709. _this.video = _this._getVideo(src);
  59710. _this._settings = settings;
  59711. if (settings.poster) {
  59712. _this.video.poster = settings.poster;
  59713. }
  59714. if (settings.autoPlay !== undefined) {
  59715. _this.video.autoplay = settings.autoPlay;
  59716. }
  59717. if (settings.loop !== undefined) {
  59718. _this.video.loop = settings.loop;
  59719. }
  59720. _this.video.setAttribute("playsinline", "");
  59721. _this.video.addEventListener("paused", _this._updateInternalTexture);
  59722. _this.video.addEventListener("seeked", _this._updateInternalTexture);
  59723. _this.video.addEventListener("emptied", _this.reset);
  59724. _this._createInternalTextureOnEvent = (settings.poster && !settings.autoPlay) ? "play" : "canplay";
  59725. _this.video.addEventListener(_this._createInternalTextureOnEvent, _this._createInternalTexture);
  59726. var videoHasEnoughData = (_this.video.readyState >= _this.video.HAVE_CURRENT_DATA);
  59727. if (settings.poster &&
  59728. (!settings.autoPlay || !videoHasEnoughData)) {
  59729. _this._texture = _this._engine.createTexture(settings.poster, false, true, scene);
  59730. _this._displayingPosterTexture = true;
  59731. }
  59732. else if (videoHasEnoughData) {
  59733. _this._createInternalTexture();
  59734. }
  59735. return _this;
  59736. }
  59737. Object.defineProperty(VideoTexture.prototype, "onUserActionRequestedObservable", {
  59738. /**
  59739. * Event triggerd when a dom action is required by the user to play the video.
  59740. * This happens due to recent changes in browser policies preventing video to auto start.
  59741. */
  59742. get: function () {
  59743. if (!this._onUserActionRequestedObservable) {
  59744. this._onUserActionRequestedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  59745. }
  59746. return this._onUserActionRequestedObservable;
  59747. },
  59748. enumerable: true,
  59749. configurable: true
  59750. });
  59751. VideoTexture.prototype._getName = function (src) {
  59752. if (src instanceof HTMLVideoElement) {
  59753. return src.currentSrc;
  59754. }
  59755. if (typeof src === "object") {
  59756. return src.toString();
  59757. }
  59758. return src;
  59759. };
  59760. VideoTexture.prototype._getVideo = function (src) {
  59761. if (src instanceof HTMLVideoElement) {
  59762. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src.currentSrc, src);
  59763. return src;
  59764. }
  59765. var video = document.createElement("video");
  59766. if (typeof src === "string") {
  59767. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src, video);
  59768. video.src = src;
  59769. }
  59770. else {
  59771. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(src[0], video);
  59772. src.forEach(function (url) {
  59773. var source = document.createElement("source");
  59774. source.src = url;
  59775. video.appendChild(source);
  59776. });
  59777. }
  59778. return video;
  59779. };
  59780. /**
  59781. * @hidden Internal method to initiate `update`.
  59782. */
  59783. VideoTexture.prototype._rebuild = function () {
  59784. this.update();
  59785. };
  59786. /**
  59787. * Update Texture in the `auto` mode. Does not do anything if `settings.autoUpdateTexture` is false.
  59788. */
  59789. VideoTexture.prototype.update = function () {
  59790. if (!this.autoUpdateTexture) {
  59791. // Expecting user to call `updateTexture` manually
  59792. return;
  59793. }
  59794. this.updateTexture(true);
  59795. };
  59796. /**
  59797. * Update Texture in `manual` mode. Does not do anything if not visible or paused.
  59798. * @param isVisible Visibility state, detected by user using `scene.getActiveMeshes()` or othervise.
  59799. */
  59800. VideoTexture.prototype.updateTexture = function (isVisible) {
  59801. if (!isVisible) {
  59802. return;
  59803. }
  59804. if (this.video.paused && this._stillImageCaptured) {
  59805. return;
  59806. }
  59807. this._stillImageCaptured = true;
  59808. this._updateInternalTexture();
  59809. };
  59810. /**
  59811. * Change video content. Changing video instance or setting multiple urls (as in constructor) is not supported.
  59812. * @param url New url.
  59813. */
  59814. VideoTexture.prototype.updateURL = function (url) {
  59815. this.video.src = url;
  59816. };
  59817. /**
  59818. * Dispose the texture and release its associated resources.
  59819. */
  59820. VideoTexture.prototype.dispose = function () {
  59821. _super.prototype.dispose.call(this);
  59822. if (this._onUserActionRequestedObservable) {
  59823. this._onUserActionRequestedObservable.clear();
  59824. this._onUserActionRequestedObservable = null;
  59825. }
  59826. this.video.removeEventListener(this._createInternalTextureOnEvent, this._createInternalTexture);
  59827. this.video.removeEventListener("paused", this._updateInternalTexture);
  59828. this.video.removeEventListener("seeked", this._updateInternalTexture);
  59829. this.video.removeEventListener("emptied", this.reset);
  59830. this.video.pause();
  59831. };
  59832. /**
  59833. * Creates a video texture straight from your WebCam video feed.
  59834. * @param scene Define the scene the texture should be created in
  59835. * @param onReady Define a callback to triggered once the texture will be ready
  59836. * @param constraints Define the constraints to use to create the web cam feed from WebRTC
  59837. */
  59838. VideoTexture.CreateFromWebCam = function (scene, onReady, constraints) {
  59839. var video = document.createElement("video");
  59840. video.setAttribute('autoplay', '');
  59841. video.setAttribute('muted', '');
  59842. video.setAttribute('playsinline', '');
  59843. var constraintsDeviceId;
  59844. if (constraints && constraints.deviceId) {
  59845. constraintsDeviceId = {
  59846. exact: constraints.deviceId,
  59847. };
  59848. }
  59849. window.URL = window.URL || window.webkitURL || window.mozURL || window.msURL;
  59850. if (navigator.mediaDevices) {
  59851. navigator.mediaDevices.getUserMedia({ video: constraints })
  59852. .then(function (stream) {
  59853. if (video.mozSrcObject !== undefined) {
  59854. // hack for Firefox < 19
  59855. video.mozSrcObject = stream;
  59856. }
  59857. else {
  59858. video.srcObject = stream;
  59859. }
  59860. var onPlaying = function () {
  59861. if (onReady) {
  59862. onReady(new VideoTexture("video", video, scene, true, true));
  59863. }
  59864. video.removeEventListener("playing", onPlaying);
  59865. };
  59866. video.addEventListener("playing", onPlaying);
  59867. video.play();
  59868. })
  59869. .catch(function (err) {
  59870. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(err.name);
  59871. });
  59872. }
  59873. else {
  59874. navigator.getUserMedia =
  59875. navigator.getUserMedia ||
  59876. navigator.webkitGetUserMedia ||
  59877. navigator.mozGetUserMedia ||
  59878. navigator.msGetUserMedia;
  59879. if (navigator.getUserMedia) {
  59880. navigator.getUserMedia({
  59881. video: {
  59882. deviceId: constraintsDeviceId,
  59883. width: {
  59884. min: (constraints && constraints.minWidth) || 256,
  59885. max: (constraints && constraints.maxWidth) || 640,
  59886. },
  59887. height: {
  59888. min: (constraints && constraints.minHeight) || 256,
  59889. max: (constraints && constraints.maxHeight) || 480,
  59890. },
  59891. },
  59892. }, function (stream) {
  59893. if (video.mozSrcObject !== undefined) {
  59894. // hack for Firefox < 19
  59895. video.mozSrcObject = stream;
  59896. }
  59897. else {
  59898. video.src = (window.URL && window.URL.createObjectURL(stream)) || stream;
  59899. }
  59900. video.play();
  59901. if (onReady) {
  59902. onReady(new VideoTexture("video", video, scene, true, true));
  59903. }
  59904. }, function (e) {
  59905. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error(e.name);
  59906. });
  59907. }
  59908. }
  59909. };
  59910. return VideoTexture;
  59911. }(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"]));
  59912. /***/ }),
  59913. /***/ "./Materials/colorCurves.ts":
  59914. /*!**********************************!*\
  59915. !*** ./Materials/colorCurves.ts ***!
  59916. \**********************************/
  59917. /*! exports provided: ColorCurves */
  59918. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  59919. "use strict";
  59920. __webpack_require__.r(__webpack_exports__);
  59921. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return ColorCurves; });
  59922. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  59923. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  59924. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  59925. /**
  59926. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  59927. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  59928. * 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;
  59929. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  59930. */
  59931. var ColorCurves = /** @class */ (function () {
  59932. function ColorCurves() {
  59933. this._dirty = true;
  59934. this._tempColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59935. this._globalCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59936. this._highlightsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59937. this._midtonesCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59938. this._shadowsCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59939. this._positiveCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59940. this._negativeCurve = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"](0, 0, 0, 0);
  59941. this._globalHue = 30;
  59942. this._globalDensity = 0;
  59943. this._globalSaturation = 0;
  59944. this._globalExposure = 0;
  59945. this._highlightsHue = 30;
  59946. this._highlightsDensity = 0;
  59947. this._highlightsSaturation = 0;
  59948. this._highlightsExposure = 0;
  59949. this._midtonesHue = 30;
  59950. this._midtonesDensity = 0;
  59951. this._midtonesSaturation = 0;
  59952. this._midtonesExposure = 0;
  59953. this._shadowsHue = 30;
  59954. this._shadowsDensity = 0;
  59955. this._shadowsSaturation = 0;
  59956. this._shadowsExposure = 0;
  59957. }
  59958. Object.defineProperty(ColorCurves.prototype, "globalHue", {
  59959. /**
  59960. * Gets the global Hue value.
  59961. * 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).
  59962. */
  59963. get: function () {
  59964. return this._globalHue;
  59965. },
  59966. /**
  59967. * Sets the global Hue value.
  59968. * 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).
  59969. */
  59970. set: function (value) {
  59971. this._globalHue = value;
  59972. this._dirty = true;
  59973. },
  59974. enumerable: true,
  59975. configurable: true
  59976. });
  59977. Object.defineProperty(ColorCurves.prototype, "globalDensity", {
  59978. /**
  59979. * Gets the global Density value.
  59980. * 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.
  59981. * Values less than zero provide a filter of opposite hue.
  59982. */
  59983. get: function () {
  59984. return this._globalDensity;
  59985. },
  59986. /**
  59987. * Sets the global Density value.
  59988. * 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.
  59989. * Values less than zero provide a filter of opposite hue.
  59990. */
  59991. set: function (value) {
  59992. this._globalDensity = value;
  59993. this._dirty = true;
  59994. },
  59995. enumerable: true,
  59996. configurable: true
  59997. });
  59998. Object.defineProperty(ColorCurves.prototype, "globalSaturation", {
  59999. /**
  60000. * Gets the global Saturation value.
  60001. * 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.
  60002. */
  60003. get: function () {
  60004. return this._globalSaturation;
  60005. },
  60006. /**
  60007. * Sets the global Saturation value.
  60008. * 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.
  60009. */
  60010. set: function (value) {
  60011. this._globalSaturation = value;
  60012. this._dirty = true;
  60013. },
  60014. enumerable: true,
  60015. configurable: true
  60016. });
  60017. Object.defineProperty(ColorCurves.prototype, "globalExposure", {
  60018. /**
  60019. * Gets the global Exposure value.
  60020. * 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.
  60021. */
  60022. get: function () {
  60023. return this._globalExposure;
  60024. },
  60025. /**
  60026. * Sets the global Exposure value.
  60027. * 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.
  60028. */
  60029. set: function (value) {
  60030. this._globalExposure = value;
  60031. this._dirty = true;
  60032. },
  60033. enumerable: true,
  60034. configurable: true
  60035. });
  60036. Object.defineProperty(ColorCurves.prototype, "highlightsHue", {
  60037. /**
  60038. * Gets the highlights Hue value.
  60039. * 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).
  60040. */
  60041. get: function () {
  60042. return this._highlightsHue;
  60043. },
  60044. /**
  60045. * Sets the highlights Hue value.
  60046. * 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).
  60047. */
  60048. set: function (value) {
  60049. this._highlightsHue = value;
  60050. this._dirty = true;
  60051. },
  60052. enumerable: true,
  60053. configurable: true
  60054. });
  60055. Object.defineProperty(ColorCurves.prototype, "highlightsDensity", {
  60056. /**
  60057. * Gets the highlights Density value.
  60058. * 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.
  60059. * Values less than zero provide a filter of opposite hue.
  60060. */
  60061. get: function () {
  60062. return this._highlightsDensity;
  60063. },
  60064. /**
  60065. * Sets the highlights Density value.
  60066. * 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.
  60067. * Values less than zero provide a filter of opposite hue.
  60068. */
  60069. set: function (value) {
  60070. this._highlightsDensity = value;
  60071. this._dirty = true;
  60072. },
  60073. enumerable: true,
  60074. configurable: true
  60075. });
  60076. Object.defineProperty(ColorCurves.prototype, "highlightsSaturation", {
  60077. /**
  60078. * Gets the highlights Saturation value.
  60079. * 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.
  60080. */
  60081. get: function () {
  60082. return this._highlightsSaturation;
  60083. },
  60084. /**
  60085. * Sets the highlights Saturation value.
  60086. * 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.
  60087. */
  60088. set: function (value) {
  60089. this._highlightsSaturation = value;
  60090. this._dirty = true;
  60091. },
  60092. enumerable: true,
  60093. configurable: true
  60094. });
  60095. Object.defineProperty(ColorCurves.prototype, "highlightsExposure", {
  60096. /**
  60097. * Gets the highlights Exposure value.
  60098. * 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.
  60099. */
  60100. get: function () {
  60101. return this._highlightsExposure;
  60102. },
  60103. /**
  60104. * Sets the highlights Exposure value.
  60105. * 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.
  60106. */
  60107. set: function (value) {
  60108. this._highlightsExposure = value;
  60109. this._dirty = true;
  60110. },
  60111. enumerable: true,
  60112. configurable: true
  60113. });
  60114. Object.defineProperty(ColorCurves.prototype, "midtonesHue", {
  60115. /**
  60116. * Gets the midtones Hue value.
  60117. * 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).
  60118. */
  60119. get: function () {
  60120. return this._midtonesHue;
  60121. },
  60122. /**
  60123. * Sets the midtones Hue value.
  60124. * 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).
  60125. */
  60126. set: function (value) {
  60127. this._midtonesHue = value;
  60128. this._dirty = true;
  60129. },
  60130. enumerable: true,
  60131. configurable: true
  60132. });
  60133. Object.defineProperty(ColorCurves.prototype, "midtonesDensity", {
  60134. /**
  60135. * Gets the midtones Density value.
  60136. * 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.
  60137. * Values less than zero provide a filter of opposite hue.
  60138. */
  60139. get: function () {
  60140. return this._midtonesDensity;
  60141. },
  60142. /**
  60143. * Sets the midtones Density value.
  60144. * 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.
  60145. * Values less than zero provide a filter of opposite hue.
  60146. */
  60147. set: function (value) {
  60148. this._midtonesDensity = value;
  60149. this._dirty = true;
  60150. },
  60151. enumerable: true,
  60152. configurable: true
  60153. });
  60154. Object.defineProperty(ColorCurves.prototype, "midtonesSaturation", {
  60155. /**
  60156. * Gets the midtones Saturation value.
  60157. * 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.
  60158. */
  60159. get: function () {
  60160. return this._midtonesSaturation;
  60161. },
  60162. /**
  60163. * Sets the midtones Saturation value.
  60164. * 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.
  60165. */
  60166. set: function (value) {
  60167. this._midtonesSaturation = value;
  60168. this._dirty = true;
  60169. },
  60170. enumerable: true,
  60171. configurable: true
  60172. });
  60173. Object.defineProperty(ColorCurves.prototype, "midtonesExposure", {
  60174. /**
  60175. * Gets the midtones Exposure value.
  60176. * 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.
  60177. */
  60178. get: function () {
  60179. return this._midtonesExposure;
  60180. },
  60181. /**
  60182. * Sets the midtones Exposure value.
  60183. * 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.
  60184. */
  60185. set: function (value) {
  60186. this._midtonesExposure = value;
  60187. this._dirty = true;
  60188. },
  60189. enumerable: true,
  60190. configurable: true
  60191. });
  60192. Object.defineProperty(ColorCurves.prototype, "shadowsHue", {
  60193. /**
  60194. * Gets the shadows Hue value.
  60195. * 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).
  60196. */
  60197. get: function () {
  60198. return this._shadowsHue;
  60199. },
  60200. /**
  60201. * Sets the shadows Hue value.
  60202. * 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).
  60203. */
  60204. set: function (value) {
  60205. this._shadowsHue = value;
  60206. this._dirty = true;
  60207. },
  60208. enumerable: true,
  60209. configurable: true
  60210. });
  60211. Object.defineProperty(ColorCurves.prototype, "shadowsDensity", {
  60212. /**
  60213. * Gets the shadows Density value.
  60214. * 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.
  60215. * Values less than zero provide a filter of opposite hue.
  60216. */
  60217. get: function () {
  60218. return this._shadowsDensity;
  60219. },
  60220. /**
  60221. * Sets the shadows Density value.
  60222. * 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.
  60223. * Values less than zero provide a filter of opposite hue.
  60224. */
  60225. set: function (value) {
  60226. this._shadowsDensity = value;
  60227. this._dirty = true;
  60228. },
  60229. enumerable: true,
  60230. configurable: true
  60231. });
  60232. Object.defineProperty(ColorCurves.prototype, "shadowsSaturation", {
  60233. /**
  60234. * Gets the shadows Saturation value.
  60235. * 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.
  60236. */
  60237. get: function () {
  60238. return this._shadowsSaturation;
  60239. },
  60240. /**
  60241. * Sets the shadows Saturation value.
  60242. * 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.
  60243. */
  60244. set: function (value) {
  60245. this._shadowsSaturation = value;
  60246. this._dirty = true;
  60247. },
  60248. enumerable: true,
  60249. configurable: true
  60250. });
  60251. Object.defineProperty(ColorCurves.prototype, "shadowsExposure", {
  60252. /**
  60253. * Gets the shadows Exposure value.
  60254. * 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.
  60255. */
  60256. get: function () {
  60257. return this._shadowsExposure;
  60258. },
  60259. /**
  60260. * Sets the shadows Exposure value.
  60261. * 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.
  60262. */
  60263. set: function (value) {
  60264. this._shadowsExposure = value;
  60265. this._dirty = true;
  60266. },
  60267. enumerable: true,
  60268. configurable: true
  60269. });
  60270. /**
  60271. * Returns the class name
  60272. * @returns The class name
  60273. */
  60274. ColorCurves.prototype.getClassName = function () {
  60275. return "ColorCurves";
  60276. };
  60277. /**
  60278. * Binds the color curves to the shader.
  60279. * @param colorCurves The color curve to bind
  60280. * @param effect The effect to bind to
  60281. * @param positiveUniform The positive uniform shader parameter
  60282. * @param neutralUniform The neutral uniform shader parameter
  60283. * @param negativeUniform The negative uniform shader parameter
  60284. */
  60285. ColorCurves.Bind = function (colorCurves, effect, positiveUniform, neutralUniform, negativeUniform) {
  60286. if (positiveUniform === void 0) { positiveUniform = "vCameraColorCurvePositive"; }
  60287. if (neutralUniform === void 0) { neutralUniform = "vCameraColorCurveNeutral"; }
  60288. if (negativeUniform === void 0) { negativeUniform = "vCameraColorCurveNegative"; }
  60289. if (colorCurves._dirty) {
  60290. colorCurves._dirty = false;
  60291. // Fill in global info.
  60292. colorCurves.getColorGradingDataToRef(colorCurves._globalHue, colorCurves._globalDensity, colorCurves._globalSaturation, colorCurves._globalExposure, colorCurves._globalCurve);
  60293. // Compute highlights info.
  60294. colorCurves.getColorGradingDataToRef(colorCurves._highlightsHue, colorCurves._highlightsDensity, colorCurves._highlightsSaturation, colorCurves._highlightsExposure, colorCurves._tempColor);
  60295. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._highlightsCurve);
  60296. // Compute midtones info.
  60297. colorCurves.getColorGradingDataToRef(colorCurves._midtonesHue, colorCurves._midtonesDensity, colorCurves._midtonesSaturation, colorCurves._midtonesExposure, colorCurves._tempColor);
  60298. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._midtonesCurve);
  60299. // Compute shadows info.
  60300. colorCurves.getColorGradingDataToRef(colorCurves._shadowsHue, colorCurves._shadowsDensity, colorCurves._shadowsSaturation, colorCurves._shadowsExposure, colorCurves._tempColor);
  60301. colorCurves._tempColor.multiplyToRef(colorCurves._globalCurve, colorCurves._shadowsCurve);
  60302. // Compute deltas (neutral is midtones).
  60303. colorCurves._highlightsCurve.subtractToRef(colorCurves._midtonesCurve, colorCurves._positiveCurve);
  60304. colorCurves._midtonesCurve.subtractToRef(colorCurves._shadowsCurve, colorCurves._negativeCurve);
  60305. }
  60306. if (effect) {
  60307. effect.setFloat4(positiveUniform, colorCurves._positiveCurve.r, colorCurves._positiveCurve.g, colorCurves._positiveCurve.b, colorCurves._positiveCurve.a);
  60308. effect.setFloat4(neutralUniform, colorCurves._midtonesCurve.r, colorCurves._midtonesCurve.g, colorCurves._midtonesCurve.b, colorCurves._midtonesCurve.a);
  60309. effect.setFloat4(negativeUniform, colorCurves._negativeCurve.r, colorCurves._negativeCurve.g, colorCurves._negativeCurve.b, colorCurves._negativeCurve.a);
  60310. }
  60311. };
  60312. /**
  60313. * Prepare the list of uniforms associated with the ColorCurves effects.
  60314. * @param uniformsList The list of uniforms used in the effect
  60315. */
  60316. ColorCurves.PrepareUniforms = function (uniformsList) {
  60317. uniformsList.push("vCameraColorCurveNeutral", "vCameraColorCurvePositive", "vCameraColorCurveNegative");
  60318. };
  60319. /**
  60320. * Returns color grading data based on a hue, density, saturation and exposure value.
  60321. * @param filterHue The hue of the color filter.
  60322. * @param filterDensity The density of the color filter.
  60323. * @param saturation The saturation.
  60324. * @param exposure The exposure.
  60325. * @param result The result data container.
  60326. */
  60327. ColorCurves.prototype.getColorGradingDataToRef = function (hue, density, saturation, exposure, result) {
  60328. if (hue == null) {
  60329. return;
  60330. }
  60331. hue = ColorCurves.clamp(hue, 0, 360);
  60332. density = ColorCurves.clamp(density, -100, 100);
  60333. saturation = ColorCurves.clamp(saturation, -100, 100);
  60334. exposure = ColorCurves.clamp(exposure, -100, 100);
  60335. // Remap the slider/config filter density with non-linear mapping and also scale by half
  60336. // so that the maximum filter density is only 50% control. This provides fine control
  60337. // for small values and reasonable range.
  60338. density = ColorCurves.applyColorGradingSliderNonlinear(density);
  60339. density *= 0.5;
  60340. exposure = ColorCurves.applyColorGradingSliderNonlinear(exposure);
  60341. if (density < 0) {
  60342. density *= -1;
  60343. hue = (hue + 180) % 360;
  60344. }
  60345. ColorCurves.fromHSBToRef(hue, density, 50 + 0.25 * exposure, result);
  60346. result.scaleToRef(2, result);
  60347. result.a = 1 + 0.01 * saturation;
  60348. };
  60349. /**
  60350. * Takes an input slider value and returns an adjusted value that provides extra control near the centre.
  60351. * @param value The input slider value in range [-100,100].
  60352. * @returns Adjusted value.
  60353. */
  60354. ColorCurves.applyColorGradingSliderNonlinear = function (value) {
  60355. value /= 100;
  60356. var x = Math.abs(value);
  60357. x = Math.pow(x, 2);
  60358. if (value < 0) {
  60359. x *= -1;
  60360. }
  60361. x *= 100;
  60362. return x;
  60363. };
  60364. /**
  60365. * Returns an RGBA Color4 based on Hue, Saturation and Brightness (also referred to as value, HSV).
  60366. * @param hue The hue (H) input.
  60367. * @param saturation The saturation (S) input.
  60368. * @param brightness The brightness (B) input.
  60369. * @result An RGBA color represented as Vector4.
  60370. */
  60371. ColorCurves.fromHSBToRef = function (hue, saturation, brightness, result) {
  60372. var h = ColorCurves.clamp(hue, 0, 360);
  60373. var s = ColorCurves.clamp(saturation / 100, 0, 1);
  60374. var v = ColorCurves.clamp(brightness / 100, 0, 1);
  60375. if (s === 0) {
  60376. result.r = v;
  60377. result.g = v;
  60378. result.b = v;
  60379. }
  60380. else {
  60381. // sector 0 to 5
  60382. h /= 60;
  60383. var i = Math.floor(h);
  60384. // fractional part of h
  60385. var f = h - i;
  60386. var p = v * (1 - s);
  60387. var q = v * (1 - s * f);
  60388. var t = v * (1 - s * (1 - f));
  60389. switch (i) {
  60390. case 0:
  60391. result.r = v;
  60392. result.g = t;
  60393. result.b = p;
  60394. break;
  60395. case 1:
  60396. result.r = q;
  60397. result.g = v;
  60398. result.b = p;
  60399. break;
  60400. case 2:
  60401. result.r = p;
  60402. result.g = v;
  60403. result.b = t;
  60404. break;
  60405. case 3:
  60406. result.r = p;
  60407. result.g = q;
  60408. result.b = v;
  60409. break;
  60410. case 4:
  60411. result.r = t;
  60412. result.g = p;
  60413. result.b = v;
  60414. break;
  60415. default: // case 5:
  60416. result.r = v;
  60417. result.g = p;
  60418. result.b = q;
  60419. break;
  60420. }
  60421. }
  60422. result.a = 1;
  60423. };
  60424. /**
  60425. * Returns a value clamped between min and max
  60426. * @param value The value to clamp
  60427. * @param min The minimum of value
  60428. * @param max The maximum of value
  60429. * @returns The clamped value.
  60430. */
  60431. ColorCurves.clamp = function (value, min, max) {
  60432. return Math.min(Math.max(value, min), max);
  60433. };
  60434. /**
  60435. * Clones the current color curve instance.
  60436. * @return The cloned curves
  60437. */
  60438. ColorCurves.prototype.clone = function () {
  60439. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ColorCurves(); }, this);
  60440. };
  60441. /**
  60442. * Serializes the current color curve instance to a json representation.
  60443. * @return a JSON representation
  60444. */
  60445. ColorCurves.prototype.serialize = function () {
  60446. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  60447. };
  60448. /**
  60449. * Parses the color curve from a json representation.
  60450. * @param source the JSON source to parse
  60451. * @return The parsed curves
  60452. */
  60453. ColorCurves.Parse = function (source) {
  60454. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ColorCurves(); }, source, null, null);
  60455. };
  60456. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60457. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60458. ], ColorCurves.prototype, "_globalHue", void 0);
  60459. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60460. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60461. ], ColorCurves.prototype, "_globalDensity", void 0);
  60462. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60463. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60464. ], ColorCurves.prototype, "_globalSaturation", void 0);
  60465. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60466. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60467. ], ColorCurves.prototype, "_globalExposure", void 0);
  60468. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60469. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60470. ], ColorCurves.prototype, "_highlightsHue", void 0);
  60471. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60472. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60473. ], ColorCurves.prototype, "_highlightsDensity", void 0);
  60474. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60475. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60476. ], ColorCurves.prototype, "_highlightsSaturation", void 0);
  60477. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60478. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60479. ], ColorCurves.prototype, "_highlightsExposure", void 0);
  60480. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60481. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60482. ], ColorCurves.prototype, "_midtonesHue", void 0);
  60483. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60484. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60485. ], ColorCurves.prototype, "_midtonesDensity", void 0);
  60486. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60487. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60488. ], ColorCurves.prototype, "_midtonesSaturation", void 0);
  60489. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  60490. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  60491. ], ColorCurves.prototype, "_midtonesExposure", void 0);
  60492. return ColorCurves;
  60493. }());
  60494. // References the dependencies.
  60495. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ColorCurvesParser = ColorCurves.Parse;
  60496. /***/ }),
  60497. /***/ "./Materials/effect.ts":
  60498. /*!*****************************!*\
  60499. !*** ./Materials/effect.ts ***!
  60500. \*****************************/
  60501. /*! exports provided: EffectFallbacks, EffectCreationOptions, Effect */
  60502. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  60503. "use strict";
  60504. __webpack_require__.r(__webpack_exports__);
  60505. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return EffectFallbacks; });
  60506. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return EffectCreationOptions; });
  60507. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return Effect; });
  60508. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  60509. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  60510. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/domManagement */ "./Misc/domManagement.ts");
  60511. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  60512. /**
  60513. * EffectFallbacks can be used to add fallbacks (properties to disable) to certain properties when desired to improve performance.
  60514. * (Eg. Start at high quality with reflection and fog, if fps is low, remove reflection, if still low remove fog)
  60515. */
  60516. var EffectFallbacks = /** @class */ (function () {
  60517. function EffectFallbacks() {
  60518. this._defines = {};
  60519. this._currentRank = 32;
  60520. this._maxRank = -1;
  60521. }
  60522. /**
  60523. * Removes the fallback from the bound mesh.
  60524. */
  60525. EffectFallbacks.prototype.unBindMesh = function () {
  60526. this._mesh = null;
  60527. };
  60528. /**
  60529. * Adds a fallback on the specified property.
  60530. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60531. * @param define The name of the define in the shader
  60532. */
  60533. EffectFallbacks.prototype.addFallback = function (rank, define) {
  60534. if (!this._defines[rank]) {
  60535. if (rank < this._currentRank) {
  60536. this._currentRank = rank;
  60537. }
  60538. if (rank > this._maxRank) {
  60539. this._maxRank = rank;
  60540. }
  60541. this._defines[rank] = new Array();
  60542. }
  60543. this._defines[rank].push(define);
  60544. };
  60545. /**
  60546. * Sets the mesh to use CPU skinning when needing to fallback.
  60547. * @param rank The rank of the fallback (Lower ranks will be fallbacked to first)
  60548. * @param mesh The mesh to use the fallbacks.
  60549. */
  60550. EffectFallbacks.prototype.addCPUSkinningFallback = function (rank, mesh) {
  60551. this._mesh = mesh;
  60552. if (rank < this._currentRank) {
  60553. this._currentRank = rank;
  60554. }
  60555. if (rank > this._maxRank) {
  60556. this._maxRank = rank;
  60557. }
  60558. };
  60559. Object.defineProperty(EffectFallbacks.prototype, "isMoreFallbacks", {
  60560. /**
  60561. * Checks to see if more fallbacks are still availible.
  60562. */
  60563. get: function () {
  60564. return this._currentRank <= this._maxRank;
  60565. },
  60566. enumerable: true,
  60567. configurable: true
  60568. });
  60569. /**
  60570. * Removes the defines that shoould be removed when falling back.
  60571. * @param currentDefines defines the current define statements for the shader.
  60572. * @param effect defines the current effect we try to compile
  60573. * @returns The resulting defines with defines of the current rank removed.
  60574. */
  60575. EffectFallbacks.prototype.reduce = function (currentDefines, effect) {
  60576. // First we try to switch to CPU skinning
  60577. if (this._mesh && this._mesh.computeBonesUsingShaders && this._mesh.numBoneInfluencers > 0 && this._mesh.material) {
  60578. this._mesh.computeBonesUsingShaders = false;
  60579. currentDefines = currentDefines.replace("#define NUM_BONE_INFLUENCERS " + this._mesh.numBoneInfluencers, "#define NUM_BONE_INFLUENCERS 0");
  60580. effect._bonesComputationForcedToCPU = true;
  60581. var scene = this._mesh.getScene();
  60582. for (var index = 0; index < scene.meshes.length; index++) {
  60583. var otherMesh = scene.meshes[index];
  60584. if (!otherMesh.material) {
  60585. continue;
  60586. }
  60587. if (!otherMesh.computeBonesUsingShaders || otherMesh.numBoneInfluencers === 0) {
  60588. continue;
  60589. }
  60590. if (otherMesh.material.getEffect() === effect) {
  60591. otherMesh.computeBonesUsingShaders = false;
  60592. }
  60593. else if (otherMesh.subMeshes) {
  60594. for (var _i = 0, _a = otherMesh.subMeshes; _i < _a.length; _i++) {
  60595. var subMesh = _a[_i];
  60596. var subMeshEffect = subMesh.effect;
  60597. if (subMeshEffect === effect) {
  60598. otherMesh.computeBonesUsingShaders = false;
  60599. break;
  60600. }
  60601. }
  60602. }
  60603. }
  60604. }
  60605. else {
  60606. var currentFallbacks = this._defines[this._currentRank];
  60607. if (currentFallbacks) {
  60608. for (var index = 0; index < currentFallbacks.length; index++) {
  60609. currentDefines = currentDefines.replace("#define " + currentFallbacks[index], "");
  60610. }
  60611. }
  60612. this._currentRank++;
  60613. }
  60614. return currentDefines;
  60615. };
  60616. return EffectFallbacks;
  60617. }());
  60618. /**
  60619. * Options to be used when creating an effect.
  60620. */
  60621. var EffectCreationOptions = /** @class */ (function () {
  60622. function EffectCreationOptions() {
  60623. }
  60624. return EffectCreationOptions;
  60625. }());
  60626. /**
  60627. * Effect containing vertex and fragment shader that can be executed on an object.
  60628. */
  60629. var Effect = /** @class */ (function () {
  60630. /**
  60631. * Instantiates an effect.
  60632. * An effect can be used to create/manage/execute vertex and fragment shaders.
  60633. * @param baseName Name of the effect.
  60634. * @param attributesNamesOrOptions List of attribute names that will be passed to the shader or set of all options to create the effect.
  60635. * @param uniformsNamesOrEngine List of uniform variable names that will be passed to the shader or the engine that will be used to render effect.
  60636. * @param samplers List of sampler variables that will be passed to the shader.
  60637. * @param engine Engine to be used to render the effect
  60638. * @param defines Define statements to be added to the shader.
  60639. * @param fallbacks Possible fallbacks for this effect to improve performance when needed.
  60640. * @param onCompiled Callback that will be called when the shader is compiled.
  60641. * @param onError Callback that will be called if an error occurs during shader compilation.
  60642. * @param indexParameters Parameters to be used with Babylons include syntax to iterate over an array (eg. {lights: 10})
  60643. */
  60644. function Effect(baseName, attributesNamesOrOptions, uniformsNamesOrEngine, samplers, engine, defines, fallbacks, onCompiled, onError, indexParameters) {
  60645. if (samplers === void 0) { samplers = null; }
  60646. if (defines === void 0) { defines = null; }
  60647. if (fallbacks === void 0) { fallbacks = null; }
  60648. if (onCompiled === void 0) { onCompiled = null; }
  60649. if (onError === void 0) { onError = null; }
  60650. var _this = this;
  60651. /**
  60652. * Unique ID of the effect.
  60653. */
  60654. this.uniqueId = 0;
  60655. /**
  60656. * Observable that will be called when the shader is compiled.
  60657. * It is recommended to use executeWhenCompile() or to make sure that scene.isReady() is called to get this observable raised.
  60658. */
  60659. this.onCompileObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60660. /**
  60661. * Observable that will be called if an error occurs during shader compilation.
  60662. */
  60663. this.onErrorObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60664. /** @hidden */
  60665. this._bonesComputationForcedToCPU = false;
  60666. this._uniformBuffersNames = {};
  60667. this._isReady = false;
  60668. this._compilationError = "";
  60669. this.name = baseName;
  60670. if (attributesNamesOrOptions.attributes) {
  60671. var options = attributesNamesOrOptions;
  60672. this._engine = uniformsNamesOrEngine;
  60673. this._attributesNames = options.attributes;
  60674. this._uniformsNames = options.uniformsNames.concat(options.samplers);
  60675. this._samplers = options.samplers.slice();
  60676. this.defines = options.defines;
  60677. this.onError = options.onError;
  60678. this.onCompiled = options.onCompiled;
  60679. this._fallbacks = options.fallbacks;
  60680. this._indexParameters = options.indexParameters;
  60681. this._transformFeedbackVaryings = options.transformFeedbackVaryings;
  60682. if (options.uniformBuffersNames) {
  60683. for (var i = 0; i < options.uniformBuffersNames.length; i++) {
  60684. this._uniformBuffersNames[options.uniformBuffersNames[i]] = i;
  60685. }
  60686. }
  60687. }
  60688. else {
  60689. this._engine = engine;
  60690. this.defines = defines;
  60691. this._uniformsNames = uniformsNamesOrEngine.concat(samplers);
  60692. this._samplers = samplers ? samplers.slice() : [];
  60693. this._attributesNames = attributesNamesOrOptions;
  60694. this.onError = onError;
  60695. this.onCompiled = onCompiled;
  60696. this._indexParameters = indexParameters;
  60697. this._fallbacks = fallbacks;
  60698. }
  60699. this.uniqueId = Effect._uniqueIdSeed++;
  60700. var vertexSource;
  60701. var fragmentSource;
  60702. if (baseName.vertexElement) {
  60703. vertexSource = document.getElementById(baseName.vertexElement);
  60704. if (!vertexSource) {
  60705. vertexSource = baseName.vertexElement;
  60706. }
  60707. }
  60708. else {
  60709. vertexSource = baseName.vertex || baseName;
  60710. }
  60711. if (baseName.fragmentElement) {
  60712. fragmentSource = document.getElementById(baseName.fragmentElement);
  60713. if (!fragmentSource) {
  60714. fragmentSource = baseName.fragmentElement;
  60715. }
  60716. }
  60717. else {
  60718. fragmentSource = baseName.fragment || baseName;
  60719. }
  60720. this._loadVertexShader(vertexSource, function (vertexCode) {
  60721. _this._processIncludes(vertexCode, function (vertexCodeWithIncludes) {
  60722. _this._processShaderConversion(vertexCodeWithIncludes, false, function (migratedVertexCode) {
  60723. _this._loadFragmentShader(fragmentSource, function (fragmentCode) {
  60724. _this._processIncludes(fragmentCode, function (fragmentCodeWithIncludes) {
  60725. _this._processShaderConversion(fragmentCodeWithIncludes, true, function (migratedFragmentCode) {
  60726. if (baseName) {
  60727. var vertex = baseName.vertexElement || baseName.vertex || baseName;
  60728. var fragment = baseName.fragmentElement || baseName.fragment || baseName;
  60729. _this._vertexSourceCode = "#define SHADER_NAME vertex:" + vertex + "\n" + migratedVertexCode;
  60730. _this._fragmentSourceCode = "#define SHADER_NAME fragment:" + fragment + "\n" + migratedFragmentCode;
  60731. }
  60732. else {
  60733. _this._vertexSourceCode = migratedVertexCode;
  60734. _this._fragmentSourceCode = migratedFragmentCode;
  60735. }
  60736. _this._prepareEffect();
  60737. });
  60738. });
  60739. });
  60740. });
  60741. });
  60742. });
  60743. }
  60744. Object.defineProperty(Effect.prototype, "onBindObservable", {
  60745. /**
  60746. * Observable that will be called when effect is bound.
  60747. */
  60748. get: function () {
  60749. if (!this._onBindObservable) {
  60750. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  60751. }
  60752. return this._onBindObservable;
  60753. },
  60754. enumerable: true,
  60755. configurable: true
  60756. });
  60757. Object.defineProperty(Effect.prototype, "key", {
  60758. /**
  60759. * Unique key for this effect
  60760. */
  60761. get: function () {
  60762. return this._key;
  60763. },
  60764. enumerable: true,
  60765. configurable: true
  60766. });
  60767. /**
  60768. * If the effect has been compiled and prepared.
  60769. * @returns if the effect is compiled and prepared.
  60770. */
  60771. Effect.prototype.isReady = function () {
  60772. if (!this._isReady && this._program && this._program.isParallelCompiled) {
  60773. return this._engine._isProgramCompiled(this._program);
  60774. }
  60775. return this._isReady;
  60776. };
  60777. /**
  60778. * The engine the effect was initialized with.
  60779. * @returns the engine.
  60780. */
  60781. Effect.prototype.getEngine = function () {
  60782. return this._engine;
  60783. };
  60784. /**
  60785. * The compiled webGL program for the effect
  60786. * @returns the webGL program.
  60787. */
  60788. Effect.prototype.getProgram = function () {
  60789. return this._program;
  60790. };
  60791. /**
  60792. * The set of names of attribute variables for the shader.
  60793. * @returns An array of attribute names.
  60794. */
  60795. Effect.prototype.getAttributesNames = function () {
  60796. return this._attributesNames;
  60797. };
  60798. /**
  60799. * Returns the attribute at the given index.
  60800. * @param index The index of the attribute.
  60801. * @returns The location of the attribute.
  60802. */
  60803. Effect.prototype.getAttributeLocation = function (index) {
  60804. return this._attributes[index];
  60805. };
  60806. /**
  60807. * Returns the attribute based on the name of the variable.
  60808. * @param name of the attribute to look up.
  60809. * @returns the attribute location.
  60810. */
  60811. Effect.prototype.getAttributeLocationByName = function (name) {
  60812. var index = this._attributesNames.indexOf(name);
  60813. return this._attributes[index];
  60814. };
  60815. /**
  60816. * The number of attributes.
  60817. * @returns the numnber of attributes.
  60818. */
  60819. Effect.prototype.getAttributesCount = function () {
  60820. return this._attributes.length;
  60821. };
  60822. /**
  60823. * Gets the index of a uniform variable.
  60824. * @param uniformName of the uniform to look up.
  60825. * @returns the index.
  60826. */
  60827. Effect.prototype.getUniformIndex = function (uniformName) {
  60828. return this._uniformsNames.indexOf(uniformName);
  60829. };
  60830. /**
  60831. * Returns the attribute based on the name of the variable.
  60832. * @param uniformName of the uniform to look up.
  60833. * @returns the location of the uniform.
  60834. */
  60835. Effect.prototype.getUniform = function (uniformName) {
  60836. return this._uniforms[this._uniformsNames.indexOf(uniformName)];
  60837. };
  60838. /**
  60839. * Returns an array of sampler variable names
  60840. * @returns The array of sampler variable neames.
  60841. */
  60842. Effect.prototype.getSamplers = function () {
  60843. return this._samplers;
  60844. };
  60845. /**
  60846. * The error from the last compilation.
  60847. * @returns the error string.
  60848. */
  60849. Effect.prototype.getCompilationError = function () {
  60850. return this._compilationError;
  60851. };
  60852. /**
  60853. * Adds a callback to the onCompiled observable and call the callback imediatly if already ready.
  60854. * @param func The callback to be used.
  60855. */
  60856. Effect.prototype.executeWhenCompiled = function (func) {
  60857. var _this = this;
  60858. if (this.isReady()) {
  60859. func(this);
  60860. return;
  60861. }
  60862. this.onCompileObservable.add(function (effect) {
  60863. func(effect);
  60864. });
  60865. if (!this._program || this._program.isParallelCompiled) {
  60866. setTimeout(function () {
  60867. _this._checkIsReady();
  60868. }, 16);
  60869. }
  60870. };
  60871. Effect.prototype._checkIsReady = function () {
  60872. var _this = this;
  60873. if (this.isReady()) {
  60874. return;
  60875. }
  60876. setTimeout(function () {
  60877. _this._checkIsReady();
  60878. }, 16);
  60879. };
  60880. /** @hidden */
  60881. Effect.prototype._loadVertexShader = function (vertex, callback) {
  60882. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60883. // DOM element ?
  60884. if (vertex instanceof HTMLElement) {
  60885. var vertexCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(vertex);
  60886. callback(vertexCode);
  60887. return;
  60888. }
  60889. }
  60890. // Base64 encoded ?
  60891. if (vertex.substr(0, 7) === "base64:") {
  60892. var vertexBinary = window.atob(vertex.substr(7));
  60893. callback(vertexBinary);
  60894. return;
  60895. }
  60896. // Is in local store ?
  60897. if (Effect.ShadersStore[vertex + "VertexShader"]) {
  60898. callback(Effect.ShadersStore[vertex + "VertexShader"]);
  60899. return;
  60900. }
  60901. var vertexShaderUrl;
  60902. if (vertex[0] === "." || vertex[0] === "/" || vertex.indexOf("http") > -1) {
  60903. vertexShaderUrl = vertex;
  60904. }
  60905. else {
  60906. vertexShaderUrl = Effect.ShadersRepository + vertex;
  60907. }
  60908. // Vertex shader
  60909. this._engine._loadFile(vertexShaderUrl + ".vertex.fx", callback);
  60910. };
  60911. /** @hidden */
  60912. Effect.prototype._loadFragmentShader = function (fragment, callback) {
  60913. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].IsWindowObjectExist()) {
  60914. // DOM element ?
  60915. if (fragment instanceof HTMLElement) {
  60916. var fragmentCode = _Misc_domManagement__WEBPACK_IMPORTED_MODULE_2__["DomManagement"].GetDOMTextContent(fragment);
  60917. callback(fragmentCode);
  60918. return;
  60919. }
  60920. }
  60921. // Base64 encoded ?
  60922. if (fragment.substr(0, 7) === "base64:") {
  60923. var fragmentBinary = window.atob(fragment.substr(7));
  60924. callback(fragmentBinary);
  60925. return;
  60926. }
  60927. // Is in local store ?
  60928. if (Effect.ShadersStore[fragment + "PixelShader"]) {
  60929. callback(Effect.ShadersStore[fragment + "PixelShader"]);
  60930. return;
  60931. }
  60932. if (Effect.ShadersStore[fragment + "FragmentShader"]) {
  60933. callback(Effect.ShadersStore[fragment + "FragmentShader"]);
  60934. return;
  60935. }
  60936. var fragmentShaderUrl;
  60937. if (fragment[0] === "." || fragment[0] === "/" || fragment.indexOf("http") > -1) {
  60938. fragmentShaderUrl = fragment;
  60939. }
  60940. else {
  60941. fragmentShaderUrl = Effect.ShadersRepository + fragment;
  60942. }
  60943. // Fragment shader
  60944. this._engine._loadFile(fragmentShaderUrl + ".fragment.fx", callback);
  60945. };
  60946. /** @hidden */
  60947. Effect.prototype._dumpShadersSource = function (vertexCode, fragmentCode, defines) {
  60948. // Rebuild shaders source code
  60949. var shaderVersion = (this._engine.webGLVersion > 1) ? "#version 300 es\n#define WEBGL2 \n" : "";
  60950. var prefix = shaderVersion + (defines ? defines + "\n" : "");
  60951. vertexCode = prefix + vertexCode;
  60952. fragmentCode = prefix + fragmentCode;
  60953. // Number lines of shaders source code
  60954. var i = 2;
  60955. var regex = /\n/gm;
  60956. var formattedVertexCode = "\n1\t" + vertexCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60957. i = 2;
  60958. var formattedFragmentCode = "\n1\t" + fragmentCode.replace(regex, function () { return "\n" + (i++) + "\t"; });
  60959. // Dump shaders name and formatted source code
  60960. if (this.name.vertexElement) {
  60961. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertexElement + formattedVertexCode);
  60962. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragmentElement + formattedFragmentCode);
  60963. }
  60964. else if (this.name.vertex) {
  60965. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name.vertex + formattedVertexCode);
  60966. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name.fragment + formattedFragmentCode);
  60967. }
  60968. else {
  60969. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Vertex shader: " + this.name + formattedVertexCode);
  60970. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Fragment shader: " + this.name + formattedFragmentCode);
  60971. }
  60972. };
  60973. Effect.prototype._processShaderConversion = function (sourceCode, isFragment, callback) {
  60974. var preparedSourceCode = this._processPrecision(sourceCode);
  60975. if (this._engine.webGLVersion == 1) {
  60976. callback(preparedSourceCode);
  60977. return;
  60978. }
  60979. // Already converted
  60980. if (preparedSourceCode.indexOf("#version 3") !== -1) {
  60981. callback(preparedSourceCode.replace("#version 300 es", ""));
  60982. return;
  60983. }
  60984. var hasDrawBuffersExtension = preparedSourceCode.search(/#extension.+GL_EXT_draw_buffers.+require/) !== -1;
  60985. // Remove extensions
  60986. // #extension GL_OES_standard_derivatives : enable
  60987. // #extension GL_EXT_shader_texture_lod : enable
  60988. // #extension GL_EXT_frag_depth : enable
  60989. // #extension GL_EXT_draw_buffers : require
  60990. var regex = /#extension.+(GL_OES_standard_derivatives|GL_EXT_shader_texture_lod|GL_EXT_frag_depth|GL_EXT_draw_buffers).+(enable|require)/g;
  60991. var result = preparedSourceCode.replace(regex, "");
  60992. // Migrate to GLSL v300
  60993. result = result.replace(/varying(?![\n\r])\s/g, isFragment ? "in " : "out ");
  60994. result = result.replace(/attribute[ \t]/g, "in ");
  60995. result = result.replace(/[ \t]attribute/g, " in");
  60996. result = result.replace(/texture2D\s*\(/g, "texture(");
  60997. if (isFragment) {
  60998. result = result.replace(/texture2DLodEXT\s*\(/g, "textureLod(");
  60999. result = result.replace(/textureCubeLodEXT\s*\(/g, "textureLod(");
  61000. result = result.replace(/textureCube\s*\(/g, "texture(");
  61001. result = result.replace(/gl_FragDepthEXT/g, "gl_FragDepth");
  61002. result = result.replace(/gl_FragColor/g, "glFragColor");
  61003. result = result.replace(/gl_FragData/g, "glFragData");
  61004. result = result.replace(/void\s+?main\s*\(/g, (hasDrawBuffersExtension ? "" : "out vec4 glFragColor;\n") + "void main(");
  61005. }
  61006. callback(result);
  61007. };
  61008. Effect.prototype._processIncludes = function (sourceCode, callback) {
  61009. var _this = this;
  61010. var regex = /#include<(.+)>(\((.*)\))*(\[(.*)\])*/g;
  61011. var match = regex.exec(sourceCode);
  61012. var returnValue = new String(sourceCode);
  61013. while (match != null) {
  61014. var includeFile = match[1];
  61015. // Uniform declaration
  61016. if (includeFile.indexOf("__decl__") !== -1) {
  61017. includeFile = includeFile.replace(/__decl__/, "");
  61018. if (this._engine.supportsUniformBuffers) {
  61019. includeFile = includeFile.replace(/Vertex/, "Ubo");
  61020. includeFile = includeFile.replace(/Fragment/, "Ubo");
  61021. }
  61022. includeFile = includeFile + "Declaration";
  61023. }
  61024. if (Effect.IncludesShadersStore[includeFile]) {
  61025. // Substitution
  61026. var includeContent = Effect.IncludesShadersStore[includeFile];
  61027. if (match[2]) {
  61028. var splits = match[3].split(",");
  61029. for (var index = 0; index < splits.length; index += 2) {
  61030. var source = new RegExp(splits[index], "g");
  61031. var dest = splits[index + 1];
  61032. includeContent = includeContent.replace(source, dest);
  61033. }
  61034. }
  61035. if (match[4]) {
  61036. var indexString = match[5];
  61037. if (indexString.indexOf("..") !== -1) {
  61038. var indexSplits = indexString.split("..");
  61039. var minIndex = parseInt(indexSplits[0]);
  61040. var maxIndex = parseInt(indexSplits[1]);
  61041. var sourceIncludeContent = includeContent.slice(0);
  61042. includeContent = "";
  61043. if (isNaN(maxIndex)) {
  61044. maxIndex = this._indexParameters[indexSplits[1]];
  61045. }
  61046. for (var i = minIndex; i < maxIndex; i++) {
  61047. if (!this._engine.supportsUniformBuffers) {
  61048. // Ubo replacement
  61049. sourceIncludeContent = sourceIncludeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  61050. return p1 + "{X}";
  61051. });
  61052. }
  61053. includeContent += sourceIncludeContent.replace(/\{X\}/g, i.toString()) + "\n";
  61054. }
  61055. }
  61056. else {
  61057. if (!this._engine.supportsUniformBuffers) {
  61058. // Ubo replacement
  61059. includeContent = includeContent.replace(/light\{X\}.(\w*)/g, function (str, p1) {
  61060. return p1 + "{X}";
  61061. });
  61062. }
  61063. includeContent = includeContent.replace(/\{X\}/g, indexString);
  61064. }
  61065. }
  61066. // Replace
  61067. returnValue = returnValue.replace(match[0], includeContent);
  61068. }
  61069. else {
  61070. var includeShaderUrl = Effect.ShadersRepository + "ShadersInclude/" + includeFile + ".fx";
  61071. this._engine._loadFile(includeShaderUrl, function (fileContent) {
  61072. Effect.IncludesShadersStore[includeFile] = fileContent;
  61073. _this._processIncludes(returnValue, callback);
  61074. });
  61075. return;
  61076. }
  61077. match = regex.exec(sourceCode);
  61078. }
  61079. callback(returnValue);
  61080. };
  61081. Effect.prototype._processPrecision = function (source) {
  61082. if (source.indexOf("precision highp float") === -1) {
  61083. if (!this._engine.getCaps().highPrecisionShaderSupported) {
  61084. source = "precision mediump float;\n" + source;
  61085. }
  61086. else {
  61087. source = "precision highp float;\n" + source;
  61088. }
  61089. }
  61090. else {
  61091. if (!this._engine.getCaps().highPrecisionShaderSupported) { // Moving highp to mediump
  61092. source = source.replace("precision highp float", "precision mediump float");
  61093. }
  61094. }
  61095. return source;
  61096. };
  61097. /**
  61098. * Recompiles the webGL program
  61099. * @param vertexSourceCode The source code for the vertex shader.
  61100. * @param fragmentSourceCode The source code for the fragment shader.
  61101. * @param onCompiled Callback called when completed.
  61102. * @param onError Callback called on error.
  61103. * @hidden
  61104. */
  61105. Effect.prototype._rebuildProgram = function (vertexSourceCode, fragmentSourceCode, onCompiled, onError) {
  61106. var _this = this;
  61107. this._isReady = false;
  61108. this._vertexSourceCodeOverride = vertexSourceCode;
  61109. this._fragmentSourceCodeOverride = fragmentSourceCode;
  61110. this.onError = function (effect, error) {
  61111. if (onError) {
  61112. onError(error);
  61113. }
  61114. };
  61115. this.onCompiled = function () {
  61116. var scenes = _this.getEngine().scenes;
  61117. for (var i = 0; i < scenes.length; i++) {
  61118. scenes[i].markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_AllDirtyFlag);
  61119. }
  61120. if (onCompiled) {
  61121. onCompiled(_this._program);
  61122. }
  61123. };
  61124. this._fallbacks = null;
  61125. this._prepareEffect();
  61126. };
  61127. /**
  61128. * Gets the uniform locations of the the specified variable names
  61129. * @param names THe names of the variables to lookup.
  61130. * @returns Array of locations in the same order as variable names.
  61131. */
  61132. Effect.prototype.getSpecificUniformLocations = function (names) {
  61133. var engine = this._engine;
  61134. return engine.getUniforms(this._program, names);
  61135. };
  61136. /**
  61137. * Prepares the effect
  61138. * @hidden
  61139. */
  61140. Effect.prototype._prepareEffect = function () {
  61141. var _this = this;
  61142. var attributesNames = this._attributesNames;
  61143. var defines = this.defines;
  61144. var fallbacks = this._fallbacks;
  61145. this._valueCache = {};
  61146. var previousProgram = this._program;
  61147. try {
  61148. var engine_1 = this._engine;
  61149. if (this._vertexSourceCodeOverride && this._fragmentSourceCodeOverride) {
  61150. this._program = engine_1.createRawShaderProgram(this._vertexSourceCodeOverride, this._fragmentSourceCodeOverride, undefined, this._transformFeedbackVaryings);
  61151. }
  61152. else {
  61153. this._program = engine_1.createShaderProgram(this._vertexSourceCode, this._fragmentSourceCode, defines, undefined, this._transformFeedbackVaryings);
  61154. }
  61155. this._program.__SPECTOR_rebuildProgram = this._rebuildProgram.bind(this);
  61156. engine_1._executeWhenProgramIsCompiled(this._program, function () {
  61157. if (engine_1.supportsUniformBuffers) {
  61158. for (var name in _this._uniformBuffersNames) {
  61159. _this.bindUniformBlock(name, _this._uniformBuffersNames[name]);
  61160. }
  61161. }
  61162. _this._uniforms = engine_1.getUniforms(_this._program, _this._uniformsNames);
  61163. _this._attributes = engine_1.getAttributes(_this._program, attributesNames);
  61164. var index;
  61165. for (index = 0; index < _this._samplers.length; index++) {
  61166. var sampler = _this.getUniform(_this._samplers[index]);
  61167. if (sampler == null) {
  61168. _this._samplers.splice(index, 1);
  61169. index--;
  61170. }
  61171. }
  61172. engine_1.bindSamplers(_this);
  61173. _this._compilationError = "";
  61174. _this._isReady = true;
  61175. if (_this.onCompiled) {
  61176. _this.onCompiled(_this);
  61177. }
  61178. _this.onCompileObservable.notifyObservers(_this);
  61179. _this.onCompileObservable.clear();
  61180. // Unbind mesh reference in fallbacks
  61181. if (_this._fallbacks) {
  61182. _this._fallbacks.unBindMesh();
  61183. }
  61184. if (previousProgram) {
  61185. _this.getEngine()._deleteProgram(previousProgram);
  61186. }
  61187. });
  61188. if (this._program.isParallelCompiled) {
  61189. this._checkIsReady();
  61190. }
  61191. }
  61192. catch (e) {
  61193. this._compilationError = e.message;
  61194. // Let's go through fallbacks then
  61195. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Unable to compile effect:");
  61196. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Uniforms: " + this._uniformsNames.map(function (uniform) {
  61197. return " " + uniform;
  61198. }));
  61199. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Attributes: " + attributesNames.map(function (attribute) {
  61200. return " " + attribute;
  61201. }));
  61202. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Error: " + this._compilationError);
  61203. if (previousProgram) {
  61204. this._program = previousProgram;
  61205. this._isReady = true;
  61206. if (this.onError) {
  61207. this.onError(this, this._compilationError);
  61208. }
  61209. this.onErrorObservable.notifyObservers(this);
  61210. }
  61211. if (fallbacks && fallbacks.isMoreFallbacks) {
  61212. _Misc_logger__WEBPACK_IMPORTED_MODULE_3__["Logger"].Error("Trying next fallback.");
  61213. this.defines = fallbacks.reduce(this.defines, this);
  61214. this._prepareEffect();
  61215. }
  61216. else { // Sorry we did everything we can
  61217. if (this.onError) {
  61218. this.onError(this, this._compilationError);
  61219. }
  61220. this.onErrorObservable.notifyObservers(this);
  61221. this.onErrorObservable.clear();
  61222. // Unbind mesh reference in fallbacks
  61223. if (this._fallbacks) {
  61224. this._fallbacks.unBindMesh();
  61225. }
  61226. }
  61227. }
  61228. };
  61229. Object.defineProperty(Effect.prototype, "isSupported", {
  61230. /**
  61231. * Checks if the effect is supported. (Must be called after compilation)
  61232. */
  61233. get: function () {
  61234. return this._compilationError === "";
  61235. },
  61236. enumerable: true,
  61237. configurable: true
  61238. });
  61239. /**
  61240. * Binds a texture to the engine to be used as output of the shader.
  61241. * @param channel Name of the output variable.
  61242. * @param texture Texture to bind.
  61243. * @hidden
  61244. */
  61245. Effect.prototype._bindTexture = function (channel, texture) {
  61246. this._engine._bindTexture(this._samplers.indexOf(channel), texture);
  61247. };
  61248. /**
  61249. * Sets a texture on the engine to be used in the shader.
  61250. * @param channel Name of the sampler variable.
  61251. * @param texture Texture to set.
  61252. */
  61253. Effect.prototype.setTexture = function (channel, texture) {
  61254. this._engine.setTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  61255. };
  61256. /**
  61257. * Sets a depth stencil texture from a render target on the engine to be used in the shader.
  61258. * @param channel Name of the sampler variable.
  61259. * @param texture Texture to set.
  61260. */
  61261. Effect.prototype.setDepthStencilTexture = function (channel, texture) {
  61262. this._engine.setDepthStencilTexture(this._samplers.indexOf(channel), this.getUniform(channel), texture);
  61263. };
  61264. /**
  61265. * Sets an array of textures on the engine to be used in the shader.
  61266. * @param channel Name of the variable.
  61267. * @param textures Textures to set.
  61268. */
  61269. Effect.prototype.setTextureArray = function (channel, textures) {
  61270. if (this._samplers.indexOf(channel + "Ex") === -1) {
  61271. var initialPos = this._samplers.indexOf(channel);
  61272. for (var index = 1; index < textures.length; index++) {
  61273. this._samplers.splice(initialPos + index, 0, channel + "Ex");
  61274. }
  61275. }
  61276. this._engine.setTextureArray(this._samplers.indexOf(channel), this.getUniform(channel), textures);
  61277. };
  61278. /**
  61279. * 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)
  61280. * @param channel Name of the sampler variable.
  61281. * @param postProcess Post process to get the input texture from.
  61282. */
  61283. Effect.prototype.setTextureFromPostProcess = function (channel, postProcess) {
  61284. this._engine.setTextureFromPostProcess(this._samplers.indexOf(channel), postProcess);
  61285. };
  61286. /**
  61287. * (Warning! setTextureFromPostProcessOutput may be desired instead)
  61288. * 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)
  61289. * @param channel Name of the sampler variable.
  61290. * @param postProcess Post process to get the output texture from.
  61291. */
  61292. Effect.prototype.setTextureFromPostProcessOutput = function (channel, postProcess) {
  61293. this._engine.setTextureFromPostProcessOutput(this._samplers.indexOf(channel), postProcess);
  61294. };
  61295. /** @hidden */
  61296. Effect.prototype._cacheMatrix = function (uniformName, matrix) {
  61297. var cache = this._valueCache[uniformName];
  61298. var flag = matrix.updateFlag;
  61299. if (cache !== undefined && cache === flag) {
  61300. return false;
  61301. }
  61302. this._valueCache[uniformName] = flag;
  61303. return true;
  61304. };
  61305. /** @hidden */
  61306. Effect.prototype._cacheFloat2 = function (uniformName, x, y) {
  61307. var cache = this._valueCache[uniformName];
  61308. if (!cache) {
  61309. cache = [x, y];
  61310. this._valueCache[uniformName] = cache;
  61311. return true;
  61312. }
  61313. var changed = false;
  61314. if (cache[0] !== x) {
  61315. cache[0] = x;
  61316. changed = true;
  61317. }
  61318. if (cache[1] !== y) {
  61319. cache[1] = y;
  61320. changed = true;
  61321. }
  61322. return changed;
  61323. };
  61324. /** @hidden */
  61325. Effect.prototype._cacheFloat3 = function (uniformName, x, y, z) {
  61326. var cache = this._valueCache[uniformName];
  61327. if (!cache) {
  61328. cache = [x, y, z];
  61329. this._valueCache[uniformName] = cache;
  61330. return true;
  61331. }
  61332. var changed = false;
  61333. if (cache[0] !== x) {
  61334. cache[0] = x;
  61335. changed = true;
  61336. }
  61337. if (cache[1] !== y) {
  61338. cache[1] = y;
  61339. changed = true;
  61340. }
  61341. if (cache[2] !== z) {
  61342. cache[2] = z;
  61343. changed = true;
  61344. }
  61345. return changed;
  61346. };
  61347. /** @hidden */
  61348. Effect.prototype._cacheFloat4 = function (uniformName, x, y, z, w) {
  61349. var cache = this._valueCache[uniformName];
  61350. if (!cache) {
  61351. cache = [x, y, z, w];
  61352. this._valueCache[uniformName] = cache;
  61353. return true;
  61354. }
  61355. var changed = false;
  61356. if (cache[0] !== x) {
  61357. cache[0] = x;
  61358. changed = true;
  61359. }
  61360. if (cache[1] !== y) {
  61361. cache[1] = y;
  61362. changed = true;
  61363. }
  61364. if (cache[2] !== z) {
  61365. cache[2] = z;
  61366. changed = true;
  61367. }
  61368. if (cache[3] !== w) {
  61369. cache[3] = w;
  61370. changed = true;
  61371. }
  61372. return changed;
  61373. };
  61374. /**
  61375. * Binds a buffer to a uniform.
  61376. * @param buffer Buffer to bind.
  61377. * @param name Name of the uniform variable to bind to.
  61378. */
  61379. Effect.prototype.bindUniformBuffer = function (buffer, name) {
  61380. var bufferName = this._uniformBuffersNames[name];
  61381. if (bufferName === undefined || Effect._baseCache[bufferName] === buffer) {
  61382. return;
  61383. }
  61384. Effect._baseCache[bufferName] = buffer;
  61385. this._engine.bindUniformBufferBase(buffer, bufferName);
  61386. };
  61387. /**
  61388. * Binds block to a uniform.
  61389. * @param blockName Name of the block to bind.
  61390. * @param index Index to bind.
  61391. */
  61392. Effect.prototype.bindUniformBlock = function (blockName, index) {
  61393. this._engine.bindUniformBlock(this._program, blockName, index);
  61394. };
  61395. /**
  61396. * Sets an interger value on a uniform variable.
  61397. * @param uniformName Name of the variable.
  61398. * @param value Value to be set.
  61399. * @returns this effect.
  61400. */
  61401. Effect.prototype.setInt = function (uniformName, value) {
  61402. var cache = this._valueCache[uniformName];
  61403. if (cache !== undefined && cache === value) {
  61404. return this;
  61405. }
  61406. this._valueCache[uniformName] = value;
  61407. this._engine.setInt(this.getUniform(uniformName), value);
  61408. return this;
  61409. };
  61410. /**
  61411. * Sets an int array on a uniform variable.
  61412. * @param uniformName Name of the variable.
  61413. * @param array array to be set.
  61414. * @returns this effect.
  61415. */
  61416. Effect.prototype.setIntArray = function (uniformName, array) {
  61417. this._valueCache[uniformName] = null;
  61418. this._engine.setIntArray(this.getUniform(uniformName), array);
  61419. return this;
  61420. };
  61421. /**
  61422. * 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)
  61423. * @param uniformName Name of the variable.
  61424. * @param array array to be set.
  61425. * @returns this effect.
  61426. */
  61427. Effect.prototype.setIntArray2 = function (uniformName, array) {
  61428. this._valueCache[uniformName] = null;
  61429. this._engine.setIntArray2(this.getUniform(uniformName), array);
  61430. return this;
  61431. };
  61432. /**
  61433. * 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)
  61434. * @param uniformName Name of the variable.
  61435. * @param array array to be set.
  61436. * @returns this effect.
  61437. */
  61438. Effect.prototype.setIntArray3 = function (uniformName, array) {
  61439. this._valueCache[uniformName] = null;
  61440. this._engine.setIntArray3(this.getUniform(uniformName), array);
  61441. return this;
  61442. };
  61443. /**
  61444. * 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)
  61445. * @param uniformName Name of the variable.
  61446. * @param array array to be set.
  61447. * @returns this effect.
  61448. */
  61449. Effect.prototype.setIntArray4 = function (uniformName, array) {
  61450. this._valueCache[uniformName] = null;
  61451. this._engine.setIntArray4(this.getUniform(uniformName), array);
  61452. return this;
  61453. };
  61454. /**
  61455. * Sets an float array on a uniform variable.
  61456. * @param uniformName Name of the variable.
  61457. * @param array array to be set.
  61458. * @returns this effect.
  61459. */
  61460. Effect.prototype.setFloatArray = function (uniformName, array) {
  61461. this._valueCache[uniformName] = null;
  61462. this._engine.setFloatArray(this.getUniform(uniformName), array);
  61463. return this;
  61464. };
  61465. /**
  61466. * 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)
  61467. * @param uniformName Name of the variable.
  61468. * @param array array to be set.
  61469. * @returns this effect.
  61470. */
  61471. Effect.prototype.setFloatArray2 = function (uniformName, array) {
  61472. this._valueCache[uniformName] = null;
  61473. this._engine.setFloatArray2(this.getUniform(uniformName), array);
  61474. return this;
  61475. };
  61476. /**
  61477. * 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)
  61478. * @param uniformName Name of the variable.
  61479. * @param array array to be set.
  61480. * @returns this effect.
  61481. */
  61482. Effect.prototype.setFloatArray3 = function (uniformName, array) {
  61483. this._valueCache[uniformName] = null;
  61484. this._engine.setFloatArray3(this.getUniform(uniformName), array);
  61485. return this;
  61486. };
  61487. /**
  61488. * 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)
  61489. * @param uniformName Name of the variable.
  61490. * @param array array to be set.
  61491. * @returns this effect.
  61492. */
  61493. Effect.prototype.setFloatArray4 = function (uniformName, array) {
  61494. this._valueCache[uniformName] = null;
  61495. this._engine.setFloatArray4(this.getUniform(uniformName), array);
  61496. return this;
  61497. };
  61498. /**
  61499. * Sets an array on a uniform variable.
  61500. * @param uniformName Name of the variable.
  61501. * @param array array to be set.
  61502. * @returns this effect.
  61503. */
  61504. Effect.prototype.setArray = function (uniformName, array) {
  61505. this._valueCache[uniformName] = null;
  61506. this._engine.setArray(this.getUniform(uniformName), array);
  61507. return this;
  61508. };
  61509. /**
  61510. * 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)
  61511. * @param uniformName Name of the variable.
  61512. * @param array array to be set.
  61513. * @returns this effect.
  61514. */
  61515. Effect.prototype.setArray2 = function (uniformName, array) {
  61516. this._valueCache[uniformName] = null;
  61517. this._engine.setArray2(this.getUniform(uniformName), array);
  61518. return this;
  61519. };
  61520. /**
  61521. * 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)
  61522. * @param uniformName Name of the variable.
  61523. * @param array array to be set.
  61524. * @returns this effect.
  61525. */
  61526. Effect.prototype.setArray3 = function (uniformName, array) {
  61527. this._valueCache[uniformName] = null;
  61528. this._engine.setArray3(this.getUniform(uniformName), array);
  61529. return this;
  61530. };
  61531. /**
  61532. * 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)
  61533. * @param uniformName Name of the variable.
  61534. * @param array array to be set.
  61535. * @returns this effect.
  61536. */
  61537. Effect.prototype.setArray4 = function (uniformName, array) {
  61538. this._valueCache[uniformName] = null;
  61539. this._engine.setArray4(this.getUniform(uniformName), array);
  61540. return this;
  61541. };
  61542. /**
  61543. * Sets matrices on a uniform variable.
  61544. * @param uniformName Name of the variable.
  61545. * @param matrices matrices to be set.
  61546. * @returns this effect.
  61547. */
  61548. Effect.prototype.setMatrices = function (uniformName, matrices) {
  61549. if (!matrices) {
  61550. return this;
  61551. }
  61552. this._valueCache[uniformName] = null;
  61553. this._engine.setMatrices(this.getUniform(uniformName), matrices);
  61554. return this;
  61555. };
  61556. /**
  61557. * Sets matrix on a uniform variable.
  61558. * @param uniformName Name of the variable.
  61559. * @param matrix matrix to be set.
  61560. * @returns this effect.
  61561. */
  61562. Effect.prototype.setMatrix = function (uniformName, matrix) {
  61563. if (this._cacheMatrix(uniformName, matrix)) {
  61564. this._engine.setMatrix(this.getUniform(uniformName), matrix);
  61565. }
  61566. return this;
  61567. };
  61568. /**
  61569. * 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)
  61570. * @param uniformName Name of the variable.
  61571. * @param matrix matrix to be set.
  61572. * @returns this effect.
  61573. */
  61574. Effect.prototype.setMatrix3x3 = function (uniformName, matrix) {
  61575. this._valueCache[uniformName] = null;
  61576. this._engine.setMatrix3x3(this.getUniform(uniformName), matrix);
  61577. return this;
  61578. };
  61579. /**
  61580. * Sets a 2x2 matrix on a uniform variable. (Speicified as [1,2,3,4] will result in [1,2][3,4] matrix)
  61581. * @param uniformName Name of the variable.
  61582. * @param matrix matrix to be set.
  61583. * @returns this effect.
  61584. */
  61585. Effect.prototype.setMatrix2x2 = function (uniformName, matrix) {
  61586. this._valueCache[uniformName] = null;
  61587. this._engine.setMatrix2x2(this.getUniform(uniformName), matrix);
  61588. return this;
  61589. };
  61590. /**
  61591. * Sets a float on a uniform variable.
  61592. * @param uniformName Name of the variable.
  61593. * @param value value to be set.
  61594. * @returns this effect.
  61595. */
  61596. Effect.prototype.setFloat = function (uniformName, value) {
  61597. var cache = this._valueCache[uniformName];
  61598. if (cache !== undefined && cache === value) {
  61599. return this;
  61600. }
  61601. this._valueCache[uniformName] = value;
  61602. this._engine.setFloat(this.getUniform(uniformName), value);
  61603. return this;
  61604. };
  61605. /**
  61606. * Sets a boolean on a uniform variable.
  61607. * @param uniformName Name of the variable.
  61608. * @param bool value to be set.
  61609. * @returns this effect.
  61610. */
  61611. Effect.prototype.setBool = function (uniformName, bool) {
  61612. var cache = this._valueCache[uniformName];
  61613. if (cache !== undefined && cache === bool) {
  61614. return this;
  61615. }
  61616. this._valueCache[uniformName] = bool;
  61617. this._engine.setBool(this.getUniform(uniformName), bool ? 1 : 0);
  61618. return this;
  61619. };
  61620. /**
  61621. * Sets a Vector2 on a uniform variable.
  61622. * @param uniformName Name of the variable.
  61623. * @param vector2 vector2 to be set.
  61624. * @returns this effect.
  61625. */
  61626. Effect.prototype.setVector2 = function (uniformName, vector2) {
  61627. if (this._cacheFloat2(uniformName, vector2.x, vector2.y)) {
  61628. this._engine.setFloat2(this.getUniform(uniformName), vector2.x, vector2.y);
  61629. }
  61630. return this;
  61631. };
  61632. /**
  61633. * Sets a float2 on a uniform variable.
  61634. * @param uniformName Name of the variable.
  61635. * @param x First float in float2.
  61636. * @param y Second float in float2.
  61637. * @returns this effect.
  61638. */
  61639. Effect.prototype.setFloat2 = function (uniformName, x, y) {
  61640. if (this._cacheFloat2(uniformName, x, y)) {
  61641. this._engine.setFloat2(this.getUniform(uniformName), x, y);
  61642. }
  61643. return this;
  61644. };
  61645. /**
  61646. * Sets a Vector3 on a uniform variable.
  61647. * @param uniformName Name of the variable.
  61648. * @param vector3 Value to be set.
  61649. * @returns this effect.
  61650. */
  61651. Effect.prototype.setVector3 = function (uniformName, vector3) {
  61652. if (this._cacheFloat3(uniformName, vector3.x, vector3.y, vector3.z)) {
  61653. this._engine.setFloat3(this.getUniform(uniformName), vector3.x, vector3.y, vector3.z);
  61654. }
  61655. return this;
  61656. };
  61657. /**
  61658. * Sets a float3 on a uniform variable.
  61659. * @param uniformName Name of the variable.
  61660. * @param x First float in float3.
  61661. * @param y Second float in float3.
  61662. * @param z Third float in float3.
  61663. * @returns this effect.
  61664. */
  61665. Effect.prototype.setFloat3 = function (uniformName, x, y, z) {
  61666. if (this._cacheFloat3(uniformName, x, y, z)) {
  61667. this._engine.setFloat3(this.getUniform(uniformName), x, y, z);
  61668. }
  61669. return this;
  61670. };
  61671. /**
  61672. * Sets a Vector4 on a uniform variable.
  61673. * @param uniformName Name of the variable.
  61674. * @param vector4 Value to be set.
  61675. * @returns this effect.
  61676. */
  61677. Effect.prototype.setVector4 = function (uniformName, vector4) {
  61678. if (this._cacheFloat4(uniformName, vector4.x, vector4.y, vector4.z, vector4.w)) {
  61679. this._engine.setFloat4(this.getUniform(uniformName), vector4.x, vector4.y, vector4.z, vector4.w);
  61680. }
  61681. return this;
  61682. };
  61683. /**
  61684. * Sets a float4 on a uniform variable.
  61685. * @param uniformName Name of the variable.
  61686. * @param x First float in float4.
  61687. * @param y Second float in float4.
  61688. * @param z Third float in float4.
  61689. * @param w Fourth float in float4.
  61690. * @returns this effect.
  61691. */
  61692. Effect.prototype.setFloat4 = function (uniformName, x, y, z, w) {
  61693. if (this._cacheFloat4(uniformName, x, y, z, w)) {
  61694. this._engine.setFloat4(this.getUniform(uniformName), x, y, z, w);
  61695. }
  61696. return this;
  61697. };
  61698. /**
  61699. * Sets a Color3 on a uniform variable.
  61700. * @param uniformName Name of the variable.
  61701. * @param color3 Value to be set.
  61702. * @returns this effect.
  61703. */
  61704. Effect.prototype.setColor3 = function (uniformName, color3) {
  61705. if (this._cacheFloat3(uniformName, color3.r, color3.g, color3.b)) {
  61706. this._engine.setColor3(this.getUniform(uniformName), color3);
  61707. }
  61708. return this;
  61709. };
  61710. /**
  61711. * Sets a Color4 on a uniform variable.
  61712. * @param uniformName Name of the variable.
  61713. * @param color3 Value to be set.
  61714. * @param alpha Alpha value to be set.
  61715. * @returns this effect.
  61716. */
  61717. Effect.prototype.setColor4 = function (uniformName, color3, alpha) {
  61718. if (this._cacheFloat4(uniformName, color3.r, color3.g, color3.b, alpha)) {
  61719. this._engine.setColor4(this.getUniform(uniformName), color3, alpha);
  61720. }
  61721. return this;
  61722. };
  61723. /**
  61724. * Sets a Color4 on a uniform variable
  61725. * @param uniformName defines the name of the variable
  61726. * @param color4 defines the value to be set
  61727. * @returns this effect.
  61728. */
  61729. Effect.prototype.setDirectColor4 = function (uniformName, color4) {
  61730. if (this._cacheFloat4(uniformName, color4.r, color4.g, color4.b, color4.a)) {
  61731. this._engine.setDirectColor4(this.getUniform(uniformName), color4);
  61732. }
  61733. return this;
  61734. };
  61735. /**
  61736. * This function will add a new shader to the shader store
  61737. * @param name the name of the shader
  61738. * @param pixelShader optional pixel shader content
  61739. * @param vertexShader optional vertex shader content
  61740. */
  61741. Effect.RegisterShader = function (name, pixelShader, vertexShader) {
  61742. if (pixelShader) {
  61743. Effect.ShadersStore[name + "PixelShader"] = pixelShader;
  61744. }
  61745. if (vertexShader) {
  61746. Effect.ShadersStore[name + "VertexShader"] = vertexShader;
  61747. }
  61748. };
  61749. /**
  61750. * Resets the cache of effects.
  61751. */
  61752. Effect.ResetCache = function () {
  61753. Effect._baseCache = {};
  61754. };
  61755. /**
  61756. * Gets or sets the relative url used to load shaders if using the engine in non-minified mode
  61757. */
  61758. Effect.ShadersRepository = "src/Shaders/";
  61759. Effect._uniqueIdSeed = 0;
  61760. Effect._baseCache = {};
  61761. /**
  61762. * Store of each shader (The can be looked up using effect.key)
  61763. */
  61764. Effect.ShadersStore = {};
  61765. /**
  61766. * Store of each included file for a shader (The can be looked up using effect.key)
  61767. */
  61768. Effect.IncludesShadersStore = {};
  61769. return Effect;
  61770. }());
  61771. /***/ }),
  61772. /***/ "./Materials/fresnelParameters.ts":
  61773. /*!****************************************!*\
  61774. !*** ./Materials/fresnelParameters.ts ***!
  61775. \****************************************/
  61776. /*! exports provided: FresnelParameters */
  61777. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61778. "use strict";
  61779. __webpack_require__.r(__webpack_exports__);
  61780. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return FresnelParameters; });
  61781. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  61782. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61783. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  61784. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61785. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  61786. /**
  61787. * This represents all the required information to add a fresnel effect on a material:
  61788. * @see http://doc.babylonjs.com/how_to/how_to_use_fresnelparameters
  61789. */
  61790. var FresnelParameters = /** @class */ (function () {
  61791. function FresnelParameters() {
  61792. this._isEnabled = true;
  61793. /**
  61794. * Define the color used on edges (grazing angle)
  61795. */
  61796. this.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].White();
  61797. /**
  61798. * Define the color used on center
  61799. */
  61800. this.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].Black();
  61801. /**
  61802. * Define bias applied to computed fresnel term
  61803. */
  61804. this.bias = 0;
  61805. /**
  61806. * Defined the power exponent applied to fresnel term
  61807. */
  61808. this.power = 1;
  61809. }
  61810. Object.defineProperty(FresnelParameters.prototype, "isEnabled", {
  61811. /**
  61812. * Define if the fresnel effect is enable or not.
  61813. */
  61814. get: function () {
  61815. return this._isEnabled;
  61816. },
  61817. set: function (value) {
  61818. if (this._isEnabled === value) {
  61819. return;
  61820. }
  61821. this._isEnabled = value;
  61822. _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);
  61823. },
  61824. enumerable: true,
  61825. configurable: true
  61826. });
  61827. /**
  61828. * Clones the current fresnel and its valuues
  61829. * @returns a clone fresnel configuration
  61830. */
  61831. FresnelParameters.prototype.clone = function () {
  61832. var newFresnelParameters = new FresnelParameters();
  61833. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newFresnelParameters);
  61834. return newFresnelParameters;
  61835. };
  61836. /**
  61837. * Serializes the current fresnel parameters to a JSON representation.
  61838. * @return the JSON serialization
  61839. */
  61840. FresnelParameters.prototype.serialize = function () {
  61841. var serializationObject = {};
  61842. serializationObject.isEnabled = this.isEnabled;
  61843. serializationObject.leftColor = this.leftColor.asArray();
  61844. serializationObject.rightColor = this.rightColor.asArray();
  61845. serializationObject.bias = this.bias;
  61846. serializationObject.power = this.power;
  61847. return serializationObject;
  61848. };
  61849. /**
  61850. * Parse a JSON object and deserialize it to a new Fresnel parameter object.
  61851. * @param parsedFresnelParameters Define the JSON representation
  61852. * @returns the parsed parameters
  61853. */
  61854. FresnelParameters.Parse = function (parsedFresnelParameters) {
  61855. var fresnelParameters = new FresnelParameters();
  61856. fresnelParameters.isEnabled = parsedFresnelParameters.isEnabled;
  61857. fresnelParameters.leftColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.leftColor);
  61858. fresnelParameters.rightColor = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(parsedFresnelParameters.rightColor);
  61859. fresnelParameters.bias = parsedFresnelParameters.bias;
  61860. fresnelParameters.power = parsedFresnelParameters.power || 1.0;
  61861. return fresnelParameters;
  61862. };
  61863. return FresnelParameters;
  61864. }());
  61865. // References the dependencies.
  61866. _Misc_decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]._FresnelParametersParser = FresnelParameters.Parse;
  61867. /***/ }),
  61868. /***/ "./Materials/imageProcessingConfiguration.ts":
  61869. /*!***************************************************!*\
  61870. !*** ./Materials/imageProcessingConfiguration.ts ***!
  61871. \***************************************************/
  61872. /*! exports provided: ImageProcessingConfigurationDefines, ImageProcessingConfiguration */
  61873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  61874. "use strict";
  61875. __webpack_require__.r(__webpack_exports__);
  61876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return ImageProcessingConfigurationDefines; });
  61877. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return ImageProcessingConfiguration; });
  61878. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  61879. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  61880. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  61881. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  61882. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  61883. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  61884. /* harmony import */ var _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/colorCurves */ "./Materials/colorCurves.ts");
  61885. /**
  61886. * @hidden
  61887. */
  61888. var ImageProcessingConfigurationDefines = /** @class */ (function (_super) {
  61889. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingConfigurationDefines, _super);
  61890. function ImageProcessingConfigurationDefines() {
  61891. var _this = _super.call(this) || this;
  61892. _this.IMAGEPROCESSING = false;
  61893. _this.VIGNETTE = false;
  61894. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  61895. _this.VIGNETTEBLENDMODEOPAQUE = false;
  61896. _this.TONEMAPPING = false;
  61897. _this.TONEMAPPING_ACES = false;
  61898. _this.CONTRAST = false;
  61899. _this.COLORCURVES = false;
  61900. _this.COLORGRADING = false;
  61901. _this.COLORGRADING3D = false;
  61902. _this.SAMPLER3DGREENDEPTH = false;
  61903. _this.SAMPLER3DBGRMAP = false;
  61904. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  61905. _this.EXPOSURE = false;
  61906. _this.rebuild();
  61907. return _this;
  61908. }
  61909. return ImageProcessingConfigurationDefines;
  61910. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_5__["MaterialDefines"]));
  61911. /**
  61912. * This groups together the common properties used for image processing either in direct forward pass
  61913. * or through post processing effect depending on the use of the image processing pipeline in your scene
  61914. * or not.
  61915. */
  61916. var ImageProcessingConfiguration = /** @class */ (function () {
  61917. function ImageProcessingConfiguration() {
  61918. /**
  61919. * Color curves setup used in the effect if colorCurvesEnabled is set to true
  61920. */
  61921. this.colorCurves = new _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"]();
  61922. this._colorCurvesEnabled = false;
  61923. this._colorGradingEnabled = false;
  61924. this._colorGradingWithGreenDepth = true;
  61925. this._colorGradingBGR = true;
  61926. /** @hidden */
  61927. this._exposure = 1.0;
  61928. this._toneMappingEnabled = false;
  61929. this._toneMappingType = ImageProcessingConfiguration.TONEMAPPING_STANDARD;
  61930. this._contrast = 1.0;
  61931. /**
  61932. * Vignette stretch size.
  61933. */
  61934. this.vignetteStretch = 0;
  61935. /**
  61936. * Vignette centre X Offset.
  61937. */
  61938. this.vignetteCentreX = 0;
  61939. /**
  61940. * Vignette centre Y Offset.
  61941. */
  61942. this.vignetteCentreY = 0;
  61943. /**
  61944. * Vignette weight or intensity of the vignette effect.
  61945. */
  61946. this.vignetteWeight = 1.5;
  61947. /**
  61948. * Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  61949. * if vignetteEnabled is set to true.
  61950. */
  61951. this.vignetteColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color4"](0, 0, 0, 0);
  61952. /**
  61953. * Camera field of view used by the Vignette effect.
  61954. */
  61955. this.vignetteCameraFov = 0.5;
  61956. this._vignetteBlendMode = ImageProcessingConfiguration.VIGNETTEMODE_MULTIPLY;
  61957. this._vignetteEnabled = false;
  61958. this._applyByPostProcess = false;
  61959. this._isEnabled = true;
  61960. /**
  61961. * An event triggered when the configuration changes and requires Shader to Update some parameters.
  61962. */
  61963. this.onUpdateParameters = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  61964. }
  61965. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorCurvesEnabled", {
  61966. /**
  61967. * Gets wether the color curves effect is enabled.
  61968. */
  61969. get: function () {
  61970. return this._colorCurvesEnabled;
  61971. },
  61972. /**
  61973. * Sets wether the color curves effect is enabled.
  61974. */
  61975. set: function (value) {
  61976. if (this._colorCurvesEnabled === value) {
  61977. return;
  61978. }
  61979. this._colorCurvesEnabled = value;
  61980. this._updateParameters();
  61981. },
  61982. enumerable: true,
  61983. configurable: true
  61984. });
  61985. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingTexture", {
  61986. /**
  61987. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61988. */
  61989. get: function () {
  61990. return this._colorGradingTexture;
  61991. },
  61992. /**
  61993. * Color grading LUT texture used in the effect if colorGradingEnabled is set to true
  61994. */
  61995. set: function (value) {
  61996. if (this._colorGradingTexture === value) {
  61997. return;
  61998. }
  61999. this._colorGradingTexture = value;
  62000. this._updateParameters();
  62001. },
  62002. enumerable: true,
  62003. configurable: true
  62004. });
  62005. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingEnabled", {
  62006. /**
  62007. * Gets wether the color grading effect is enabled.
  62008. */
  62009. get: function () {
  62010. return this._colorGradingEnabled;
  62011. },
  62012. /**
  62013. * Sets wether the color grading effect is enabled.
  62014. */
  62015. set: function (value) {
  62016. if (this._colorGradingEnabled === value) {
  62017. return;
  62018. }
  62019. this._colorGradingEnabled = value;
  62020. this._updateParameters();
  62021. },
  62022. enumerable: true,
  62023. configurable: true
  62024. });
  62025. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingWithGreenDepth", {
  62026. /**
  62027. * Gets wether the color grading effect is using a green depth for the 3d Texture.
  62028. */
  62029. get: function () {
  62030. return this._colorGradingWithGreenDepth;
  62031. },
  62032. /**
  62033. * Sets wether the color grading effect is using a green depth for the 3d Texture.
  62034. */
  62035. set: function (value) {
  62036. if (this._colorGradingWithGreenDepth === value) {
  62037. return;
  62038. }
  62039. this._colorGradingWithGreenDepth = value;
  62040. this._updateParameters();
  62041. },
  62042. enumerable: true,
  62043. configurable: true
  62044. });
  62045. Object.defineProperty(ImageProcessingConfiguration.prototype, "colorGradingBGR", {
  62046. /**
  62047. * Gets wether the color grading texture contains BGR values.
  62048. */
  62049. get: function () {
  62050. return this._colorGradingBGR;
  62051. },
  62052. /**
  62053. * Sets wether the color grading texture contains BGR values.
  62054. */
  62055. set: function (value) {
  62056. if (this._colorGradingBGR === value) {
  62057. return;
  62058. }
  62059. this._colorGradingBGR = value;
  62060. this._updateParameters();
  62061. },
  62062. enumerable: true,
  62063. configurable: true
  62064. });
  62065. Object.defineProperty(ImageProcessingConfiguration.prototype, "exposure", {
  62066. /**
  62067. * Gets the Exposure used in the effect.
  62068. */
  62069. get: function () {
  62070. return this._exposure;
  62071. },
  62072. /**
  62073. * Sets the Exposure used in the effect.
  62074. */
  62075. set: function (value) {
  62076. if (this._exposure === value) {
  62077. return;
  62078. }
  62079. this._exposure = value;
  62080. this._updateParameters();
  62081. },
  62082. enumerable: true,
  62083. configurable: true
  62084. });
  62085. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingEnabled", {
  62086. /**
  62087. * Gets wether the tone mapping effect is enabled.
  62088. */
  62089. get: function () {
  62090. return this._toneMappingEnabled;
  62091. },
  62092. /**
  62093. * Sets wether the tone mapping effect is enabled.
  62094. */
  62095. set: function (value) {
  62096. if (this._toneMappingEnabled === value) {
  62097. return;
  62098. }
  62099. this._toneMappingEnabled = value;
  62100. this._updateParameters();
  62101. },
  62102. enumerable: true,
  62103. configurable: true
  62104. });
  62105. Object.defineProperty(ImageProcessingConfiguration.prototype, "toneMappingType", {
  62106. /**
  62107. * Gets the type of tone mapping effect.
  62108. */
  62109. get: function () {
  62110. return this._toneMappingType;
  62111. },
  62112. /**
  62113. * Sets the type of tone mapping effect used in BabylonJS.
  62114. */
  62115. set: function (value) {
  62116. if (this._toneMappingType === value) {
  62117. return;
  62118. }
  62119. this._toneMappingType = value;
  62120. this._updateParameters();
  62121. },
  62122. enumerable: true,
  62123. configurable: true
  62124. });
  62125. Object.defineProperty(ImageProcessingConfiguration.prototype, "contrast", {
  62126. /**
  62127. * Gets the contrast used in the effect.
  62128. */
  62129. get: function () {
  62130. return this._contrast;
  62131. },
  62132. /**
  62133. * Sets the contrast used in the effect.
  62134. */
  62135. set: function (value) {
  62136. if (this._contrast === value) {
  62137. return;
  62138. }
  62139. this._contrast = value;
  62140. this._updateParameters();
  62141. },
  62142. enumerable: true,
  62143. configurable: true
  62144. });
  62145. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteBlendMode", {
  62146. /**
  62147. * Gets the vignette blend mode allowing different kind of effect.
  62148. */
  62149. get: function () {
  62150. return this._vignetteBlendMode;
  62151. },
  62152. /**
  62153. * Sets the vignette blend mode allowing different kind of effect.
  62154. */
  62155. set: function (value) {
  62156. if (this._vignetteBlendMode === value) {
  62157. return;
  62158. }
  62159. this._vignetteBlendMode = value;
  62160. this._updateParameters();
  62161. },
  62162. enumerable: true,
  62163. configurable: true
  62164. });
  62165. Object.defineProperty(ImageProcessingConfiguration.prototype, "vignetteEnabled", {
  62166. /**
  62167. * Gets wether the vignette effect is enabled.
  62168. */
  62169. get: function () {
  62170. return this._vignetteEnabled;
  62171. },
  62172. /**
  62173. * Sets wether the vignette effect is enabled.
  62174. */
  62175. set: function (value) {
  62176. if (this._vignetteEnabled === value) {
  62177. return;
  62178. }
  62179. this._vignetteEnabled = value;
  62180. this._updateParameters();
  62181. },
  62182. enumerable: true,
  62183. configurable: true
  62184. });
  62185. Object.defineProperty(ImageProcessingConfiguration.prototype, "applyByPostProcess", {
  62186. /**
  62187. * Gets wether the image processing is applied through a post process or not.
  62188. */
  62189. get: function () {
  62190. return this._applyByPostProcess;
  62191. },
  62192. /**
  62193. * Sets wether the image processing is applied through a post process or not.
  62194. */
  62195. set: function (value) {
  62196. if (this._applyByPostProcess === value) {
  62197. return;
  62198. }
  62199. this._applyByPostProcess = value;
  62200. this._updateParameters();
  62201. },
  62202. enumerable: true,
  62203. configurable: true
  62204. });
  62205. Object.defineProperty(ImageProcessingConfiguration.prototype, "isEnabled", {
  62206. /**
  62207. * Gets wether the image processing is enabled or not.
  62208. */
  62209. get: function () {
  62210. return this._isEnabled;
  62211. },
  62212. /**
  62213. * Sets wether the image processing is enabled or not.
  62214. */
  62215. set: function (value) {
  62216. if (this._isEnabled === value) {
  62217. return;
  62218. }
  62219. this._isEnabled = value;
  62220. this._updateParameters();
  62221. },
  62222. enumerable: true,
  62223. configurable: true
  62224. });
  62225. /**
  62226. * Method called each time the image processing information changes requires to recompile the effect.
  62227. */
  62228. ImageProcessingConfiguration.prototype._updateParameters = function () {
  62229. this.onUpdateParameters.notifyObservers(this);
  62230. };
  62231. /**
  62232. * Gets the current class name.
  62233. * @return "ImageProcessingConfiguration"
  62234. */
  62235. ImageProcessingConfiguration.prototype.getClassName = function () {
  62236. return "ImageProcessingConfiguration";
  62237. };
  62238. /**
  62239. * Prepare the list of uniforms associated with the Image Processing effects.
  62240. * @param uniforms The list of uniforms used in the effect
  62241. * @param defines the list of defines currently in use
  62242. */
  62243. ImageProcessingConfiguration.PrepareUniforms = function (uniforms, defines) {
  62244. if (defines.EXPOSURE) {
  62245. uniforms.push("exposureLinear");
  62246. }
  62247. if (defines.CONTRAST) {
  62248. uniforms.push("contrast");
  62249. }
  62250. if (defines.COLORGRADING) {
  62251. uniforms.push("colorTransformSettings");
  62252. }
  62253. if (defines.VIGNETTE) {
  62254. uniforms.push("vInverseScreenSize");
  62255. uniforms.push("vignetteSettings1");
  62256. uniforms.push("vignetteSettings2");
  62257. }
  62258. if (defines.COLORCURVES) {
  62259. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].PrepareUniforms(uniforms);
  62260. }
  62261. };
  62262. /**
  62263. * Prepare the list of samplers associated with the Image Processing effects.
  62264. * @param samplersList The list of uniforms used in the effect
  62265. * @param defines the list of defines currently in use
  62266. */
  62267. ImageProcessingConfiguration.PrepareSamplers = function (samplersList, defines) {
  62268. if (defines.COLORGRADING) {
  62269. samplersList.push("txColorTransform");
  62270. }
  62271. };
  62272. /**
  62273. * Prepare the list of defines associated to the shader.
  62274. * @param defines the list of defines to complete
  62275. * @param forPostProcess Define if we are currently in post process mode or not
  62276. */
  62277. ImageProcessingConfiguration.prototype.prepareDefines = function (defines, forPostProcess) {
  62278. if (forPostProcess === void 0) { forPostProcess = false; }
  62279. if (forPostProcess !== this.applyByPostProcess || !this._isEnabled) {
  62280. defines.VIGNETTE = false;
  62281. defines.TONEMAPPING = false;
  62282. defines.TONEMAPPING_ACES = false;
  62283. defines.CONTRAST = false;
  62284. defines.EXPOSURE = false;
  62285. defines.COLORCURVES = false;
  62286. defines.COLORGRADING = false;
  62287. defines.COLORGRADING3D = false;
  62288. defines.IMAGEPROCESSING = false;
  62289. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess && this._isEnabled;
  62290. return;
  62291. }
  62292. defines.VIGNETTE = this.vignetteEnabled;
  62293. defines.VIGNETTEBLENDMODEMULTIPLY = (this.vignetteBlendMode === ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY);
  62294. defines.VIGNETTEBLENDMODEOPAQUE = !defines.VIGNETTEBLENDMODEMULTIPLY;
  62295. defines.TONEMAPPING = this.toneMappingEnabled;
  62296. switch (this._toneMappingType) {
  62297. case ImageProcessingConfiguration.TONEMAPPING_ACES:
  62298. defines.TONEMAPPING_ACES = true;
  62299. break;
  62300. default:
  62301. defines.TONEMAPPING_ACES = false;
  62302. break;
  62303. }
  62304. defines.CONTRAST = (this.contrast !== 1.0);
  62305. defines.EXPOSURE = (this.exposure !== 1.0);
  62306. defines.COLORCURVES = (this.colorCurvesEnabled && !!this.colorCurves);
  62307. defines.COLORGRADING = (this.colorGradingEnabled && !!this.colorGradingTexture);
  62308. if (defines.COLORGRADING) {
  62309. defines.COLORGRADING3D = this.colorGradingTexture.is3D;
  62310. }
  62311. else {
  62312. defines.COLORGRADING3D = false;
  62313. }
  62314. defines.SAMPLER3DGREENDEPTH = this.colorGradingWithGreenDepth;
  62315. defines.SAMPLER3DBGRMAP = this.colorGradingBGR;
  62316. defines.IMAGEPROCESSINGPOSTPROCESS = this.applyByPostProcess;
  62317. defines.IMAGEPROCESSING = defines.VIGNETTE || defines.TONEMAPPING || defines.CONTRAST || defines.EXPOSURE || defines.COLORCURVES || defines.COLORGRADING;
  62318. };
  62319. /**
  62320. * Returns true if all the image processing information are ready.
  62321. * @returns True if ready, otherwise, false
  62322. */
  62323. ImageProcessingConfiguration.prototype.isReady = function () {
  62324. // Color Grading texure can not be none blocking.
  62325. return !this.colorGradingEnabled || !this.colorGradingTexture || this.colorGradingTexture.isReady();
  62326. };
  62327. /**
  62328. * Binds the image processing to the shader.
  62329. * @param effect The effect to bind to
  62330. * @param aspectRatio Define the current aspect ratio of the effect
  62331. */
  62332. ImageProcessingConfiguration.prototype.bind = function (effect, aspectRatio) {
  62333. if (aspectRatio === void 0) { aspectRatio = 1; }
  62334. // Color Curves
  62335. if (this._colorCurvesEnabled && this.colorCurves) {
  62336. _Materials_colorCurves__WEBPACK_IMPORTED_MODULE_6__["ColorCurves"].Bind(this.colorCurves, effect);
  62337. }
  62338. // Vignette
  62339. if (this._vignetteEnabled) {
  62340. var inverseWidth = 1 / effect.getEngine().getRenderWidth();
  62341. var inverseHeight = 1 / effect.getEngine().getRenderHeight();
  62342. effect.setFloat2("vInverseScreenSize", inverseWidth, inverseHeight);
  62343. var vignetteScaleY = Math.tan(this.vignetteCameraFov * 0.5);
  62344. var vignetteScaleX = vignetteScaleY * aspectRatio;
  62345. var vignetteScaleGeometricMean = Math.sqrt(vignetteScaleX * vignetteScaleY);
  62346. vignetteScaleX = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleX, vignetteScaleGeometricMean, this.vignetteStretch);
  62347. vignetteScaleY = _Misc_tools__WEBPACK_IMPORTED_MODULE_3__["Tools"].Mix(vignetteScaleY, vignetteScaleGeometricMean, this.vignetteStretch);
  62348. effect.setFloat4("vignetteSettings1", vignetteScaleX, vignetteScaleY, -vignetteScaleX * this.vignetteCentreX, -vignetteScaleY * this.vignetteCentreY);
  62349. var vignettePower = -2.0 * this.vignetteWeight;
  62350. effect.setFloat4("vignetteSettings2", this.vignetteColor.r, this.vignetteColor.g, this.vignetteColor.b, vignettePower);
  62351. }
  62352. // Exposure
  62353. effect.setFloat("exposureLinear", this.exposure);
  62354. // Contrast
  62355. effect.setFloat("contrast", this.contrast);
  62356. // Color transform settings
  62357. if (this.colorGradingTexture) {
  62358. effect.setTexture("txColorTransform", this.colorGradingTexture);
  62359. var textureSize = this.colorGradingTexture.getSize().height;
  62360. effect.setFloat4("colorTransformSettings", (textureSize - 1) / textureSize, // textureScale
  62361. 0.5 / textureSize, // textureOffset
  62362. textureSize, // textureSize
  62363. this.colorGradingTexture.level // weight
  62364. );
  62365. }
  62366. };
  62367. /**
  62368. * Clones the current image processing instance.
  62369. * @return The cloned image processing
  62370. */
  62371. ImageProcessingConfiguration.prototype.clone = function () {
  62372. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new ImageProcessingConfiguration(); }, this);
  62373. };
  62374. /**
  62375. * Serializes the current image processing instance to a json representation.
  62376. * @return a JSON representation
  62377. */
  62378. ImageProcessingConfiguration.prototype.serialize = function () {
  62379. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  62380. };
  62381. /**
  62382. * Parses the image processing from a json representation.
  62383. * @param source the JSON source to parse
  62384. * @return The parsed image processing
  62385. */
  62386. ImageProcessingConfiguration.Parse = function (source) {
  62387. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ImageProcessingConfiguration(); }, source, null, null);
  62388. };
  62389. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_MULTIPLY", {
  62390. /**
  62391. * Used to apply the vignette as a mix with the pixel color.
  62392. */
  62393. get: function () {
  62394. return this._VIGNETTEMODE_MULTIPLY;
  62395. },
  62396. enumerable: true,
  62397. configurable: true
  62398. });
  62399. Object.defineProperty(ImageProcessingConfiguration, "VIGNETTEMODE_OPAQUE", {
  62400. /**
  62401. * Used to apply the vignette as a replacement of the pixel color.
  62402. */
  62403. get: function () {
  62404. return this._VIGNETTEMODE_OPAQUE;
  62405. },
  62406. enumerable: true,
  62407. configurable: true
  62408. });
  62409. /**
  62410. * Default tone mapping applied in BabylonJS.
  62411. */
  62412. ImageProcessingConfiguration.TONEMAPPING_STANDARD = 0;
  62413. /**
  62414. * ACES Tone mapping (used by default in unreal and unity). This can help getting closer
  62415. * to other engines rendering to increase portability.
  62416. */
  62417. ImageProcessingConfiguration.TONEMAPPING_ACES = 1;
  62418. // Static constants associated to the image processing.
  62419. ImageProcessingConfiguration._VIGNETTEMODE_MULTIPLY = 0;
  62420. ImageProcessingConfiguration._VIGNETTEMODE_OPAQUE = 1;
  62421. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62422. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColorCurves"])()
  62423. ], ImageProcessingConfiguration.prototype, "colorCurves", void 0);
  62424. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62425. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62426. ], ImageProcessingConfiguration.prototype, "_colorCurvesEnabled", void 0);
  62427. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62428. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("colorGradingTexture")
  62429. ], ImageProcessingConfiguration.prototype, "_colorGradingTexture", void 0);
  62430. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62431. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62432. ], ImageProcessingConfiguration.prototype, "_colorGradingEnabled", void 0);
  62433. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62434. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62435. ], ImageProcessingConfiguration.prototype, "_colorGradingWithGreenDepth", void 0);
  62436. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62437. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62438. ], ImageProcessingConfiguration.prototype, "_colorGradingBGR", void 0);
  62439. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62440. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62441. ], ImageProcessingConfiguration.prototype, "_exposure", void 0);
  62442. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62443. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62444. ], ImageProcessingConfiguration.prototype, "_toneMappingEnabled", void 0);
  62445. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62446. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62447. ], ImageProcessingConfiguration.prototype, "_toneMappingType", void 0);
  62448. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62449. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62450. ], ImageProcessingConfiguration.prototype, "_contrast", void 0);
  62451. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62452. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62453. ], ImageProcessingConfiguration.prototype, "vignetteStretch", void 0);
  62454. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62455. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62456. ], ImageProcessingConfiguration.prototype, "vignetteCentreX", void 0);
  62457. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62458. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62459. ], ImageProcessingConfiguration.prototype, "vignetteCentreY", void 0);
  62460. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62461. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62462. ], ImageProcessingConfiguration.prototype, "vignetteWeight", void 0);
  62463. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62464. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor4"])()
  62465. ], ImageProcessingConfiguration.prototype, "vignetteColor", void 0);
  62466. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62467. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62468. ], ImageProcessingConfiguration.prototype, "vignetteCameraFov", void 0);
  62469. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62470. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62471. ], ImageProcessingConfiguration.prototype, "_vignetteBlendMode", void 0);
  62472. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62473. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62474. ], ImageProcessingConfiguration.prototype, "_vignetteEnabled", void 0);
  62475. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62476. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62477. ], ImageProcessingConfiguration.prototype, "_applyByPostProcess", void 0);
  62478. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  62479. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  62480. ], ImageProcessingConfiguration.prototype, "_isEnabled", void 0);
  62481. return ImageProcessingConfiguration;
  62482. }());
  62483. // References the dependencies.
  62484. _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"]._ImageProcessingConfigurationParser = ImageProcessingConfiguration.Parse;
  62485. /***/ }),
  62486. /***/ "./Materials/index.ts":
  62487. /*!****************************!*\
  62488. !*** ./Materials/index.ts ***!
  62489. \****************************/
  62490. /*! exports provided: ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent */
  62491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62492. "use strict";
  62493. __webpack_require__.r(__webpack_exports__);
  62494. /* harmony import */ var _Background_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Background/index */ "./Materials/Background/index.ts");
  62495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Background_index__WEBPACK_IMPORTED_MODULE_0__["BackgroundMaterial"]; });
  62496. /* harmony import */ var _colorCurves__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./colorCurves */ "./Materials/colorCurves.ts");
  62497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _colorCurves__WEBPACK_IMPORTED_MODULE_1__["ColorCurves"]; });
  62498. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  62499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectFallbacks"]; });
  62500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["EffectCreationOptions"]; });
  62501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _effect__WEBPACK_IMPORTED_MODULE_2__["Effect"]; });
  62502. /* harmony import */ var _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./fresnelParameters */ "./Materials/fresnelParameters.ts");
  62503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _fresnelParameters__WEBPACK_IMPORTED_MODULE_3__["FresnelParameters"]; });
  62504. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  62505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfigurationDefines"]; });
  62506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_4__["ImageProcessingConfiguration"]; });
  62507. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  62508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _material__WEBPACK_IMPORTED_MODULE_5__["Material"]; });
  62509. /* harmony import */ var _materialDefines__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./materialDefines */ "./Materials/materialDefines.ts");
  62510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _materialDefines__WEBPACK_IMPORTED_MODULE_6__["MaterialDefines"]; });
  62511. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  62512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _materialHelper__WEBPACK_IMPORTED_MODULE_7__["MaterialHelper"]; });
  62513. /* harmony import */ var _multiMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./multiMaterial */ "./Materials/multiMaterial.ts");
  62514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _multiMaterial__WEBPACK_IMPORTED_MODULE_8__["MultiMaterial"]; });
  62515. /* harmony import */ var _PBR_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./PBR/index */ "./Materials/PBR/index.ts");
  62516. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseMaterial"]; });
  62517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRBaseSimpleMaterial"]; });
  62518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMaterial"]; });
  62519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRMetallicRoughnessMaterial"]; });
  62520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _PBR_index__WEBPACK_IMPORTED_MODULE_9__["PBRSpecularGlossinessMaterial"]; });
  62521. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  62522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _pushMaterial__WEBPACK_IMPORTED_MODULE_10__["PushMaterial"]; });
  62523. /* harmony import */ var _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./shaderMaterial */ "./Materials/shaderMaterial.ts");
  62524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _shaderMaterial__WEBPACK_IMPORTED_MODULE_11__["ShaderMaterial"]; });
  62525. /* harmony import */ var _standardMaterial__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./standardMaterial */ "./Materials/standardMaterial.ts");
  62526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterialDefines"]; });
  62527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _standardMaterial__WEBPACK_IMPORTED_MODULE_12__["StandardMaterial"]; });
  62528. /* harmony import */ var _Textures_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Textures/index */ "./Materials/Textures/index.ts");
  62529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["BaseTexture"]; });
  62530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CubeTexture"]; });
  62531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["HDRCubeTexture"]; });
  62532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["InternalTexture"]; });
  62533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DummyInternalTextureTracker"]; });
  62534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MirrorTexture"]; });
  62535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["MultiRenderTarget"]; });
  62536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture"]; });
  62537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RenderTargetTexture"]; });
  62538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["Texture"]; });
  62539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ColorGradingTexture"]; });
  62540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["DynamicTexture"]; });
  62541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTexture"]; });
  62542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawCubeTexture"]; });
  62543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RawTexture3D"]; });
  62544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["RefractionTexture"]; });
  62545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["VideoTexture"]; });
  62546. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_DDSTextureLoader"]; });
  62547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_ENVTextureLoader"]; });
  62548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_KTXTextureLoader"]; });
  62549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["_TGATextureLoader"]; });
  62550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["CustomProceduralTexture"]; });
  62551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["NoiseProceduralTexture"]; });
  62552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Textures_index__WEBPACK_IMPORTED_MODULE_13__["ProceduralTextureSceneComponent"]; });
  62553. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _uniformBuffer__WEBPACK_IMPORTED_MODULE_14__["UniformBuffer"]; });
  62555. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  62556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _materialFlags__WEBPACK_IMPORTED_MODULE_15__["MaterialFlags"]; });
  62557. /***/ }),
  62558. /***/ "./Materials/material.ts":
  62559. /*!*******************************!*\
  62560. !*** ./Materials/material.ts ***!
  62561. \*******************************/
  62562. /*! exports provided: Material */
  62563. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  62564. "use strict";
  62565. __webpack_require__.r(__webpack_exports__);
  62566. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return Material; });
  62567. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  62568. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  62569. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  62570. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  62571. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  62572. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  62573. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  62574. /* harmony import */ var _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./uniformBuffer */ "./Materials/uniformBuffer.ts");
  62575. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  62576. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  62577. /**
  62578. * Base class for the main features of a material in Babylon.js
  62579. */
  62580. var Material = /** @class */ (function () {
  62581. /**
  62582. * Creates a material instance
  62583. * @param name defines the name of the material
  62584. * @param scene defines the scene to reference
  62585. * @param doNotAdd specifies if the material should be added to the scene
  62586. */
  62587. function Material(name, scene, doNotAdd) {
  62588. /**
  62589. * Gets or sets user defined metadata
  62590. */
  62591. this.metadata = null;
  62592. /**
  62593. * For internal use only. Please do not use.
  62594. */
  62595. this.reservedDataStore = null;
  62596. /**
  62597. * Specifies if the ready state should be checked on each call
  62598. */
  62599. this.checkReadyOnEveryCall = false;
  62600. /**
  62601. * Specifies if the ready state should be checked once
  62602. */
  62603. this.checkReadyOnlyOnce = false;
  62604. /**
  62605. * The state of the material
  62606. */
  62607. this.state = "";
  62608. /**
  62609. * The alpha value of the material
  62610. */
  62611. this._alpha = 1.0;
  62612. /**
  62613. * Specifies if back face culling is enabled
  62614. */
  62615. this._backFaceCulling = true;
  62616. /**
  62617. * Specifies if the material should be serialized
  62618. */
  62619. this.doNotSerialize = false;
  62620. /**
  62621. * @hidden
  62622. */
  62623. this._storeEffectOnSubMeshes = false;
  62624. /**
  62625. * An event triggered when the material is disposed
  62626. */
  62627. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62628. /**
  62629. * Stores the value of the alpha mode
  62630. */
  62631. this._alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE;
  62632. /**
  62633. * Stores the state of the need depth pre-pass value
  62634. */
  62635. this._needDepthPrePass = false;
  62636. /**
  62637. * Specifies if depth writing should be disabled
  62638. */
  62639. this.disableDepthWrite = false;
  62640. /**
  62641. * Specifies if depth writing should be forced
  62642. */
  62643. this.forceDepthWrite = false;
  62644. /**
  62645. * Specifies if there should be a separate pass for culling
  62646. */
  62647. this.separateCullingPass = false;
  62648. /**
  62649. * Stores the state specifing if fog should be enabled
  62650. */
  62651. this._fogEnabled = true;
  62652. /**
  62653. * Stores the size of points
  62654. */
  62655. this.pointSize = 1.0;
  62656. /**
  62657. * Stores the z offset value
  62658. */
  62659. this.zOffset = 0;
  62660. /**
  62661. * @hidden
  62662. * Specifies if the material was previously ready
  62663. */
  62664. this._wasPreviouslyReady = false;
  62665. /**
  62666. * Stores the fill mode state
  62667. */
  62668. this._fillMode = Material.TriangleFillMode;
  62669. /** @hidden */
  62670. this._indexInSceneMaterialArray = -1;
  62671. this.name = name;
  62672. this.id = name || _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].RandomId();
  62673. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  62674. this.uniqueId = this._scene.getUniqueId();
  62675. if (this._scene.useRightHandedSystem) {
  62676. this.sideOrientation = Material.ClockWiseSideOrientation;
  62677. }
  62678. else {
  62679. this.sideOrientation = Material.CounterClockWiseSideOrientation;
  62680. }
  62681. this._uniformBuffer = new _uniformBuffer__WEBPACK_IMPORTED_MODULE_7__["UniformBuffer"](this._scene.getEngine());
  62682. this._useUBO = this.getScene().getEngine().supportsUniformBuffers;
  62683. if (!doNotAdd) {
  62684. this._scene.addMaterial(this);
  62685. }
  62686. if (this._scene.useMaterialMeshMap) {
  62687. this.meshMap = {};
  62688. }
  62689. }
  62690. Object.defineProperty(Material.prototype, "alpha", {
  62691. /**
  62692. * Gets the alpha value of the material
  62693. */
  62694. get: function () {
  62695. return this._alpha;
  62696. },
  62697. /**
  62698. * Sets the alpha value of the material
  62699. */
  62700. set: function (value) {
  62701. if (this._alpha === value) {
  62702. return;
  62703. }
  62704. this._alpha = value;
  62705. this.markAsDirty(Material.MiscDirtyFlag);
  62706. },
  62707. enumerable: true,
  62708. configurable: true
  62709. });
  62710. Object.defineProperty(Material.prototype, "backFaceCulling", {
  62711. /**
  62712. * Gets the back-face culling state
  62713. */
  62714. get: function () {
  62715. return this._backFaceCulling;
  62716. },
  62717. /**
  62718. * Sets the back-face culling state
  62719. */
  62720. set: function (value) {
  62721. if (this._backFaceCulling === value) {
  62722. return;
  62723. }
  62724. this._backFaceCulling = value;
  62725. this.markAsDirty(Material.TextureDirtyFlag);
  62726. },
  62727. enumerable: true,
  62728. configurable: true
  62729. });
  62730. Object.defineProperty(Material.prototype, "hasRenderTargetTextures", {
  62731. /**
  62732. * Gets a boolean indicating that current material needs to register RTT
  62733. */
  62734. get: function () {
  62735. return false;
  62736. },
  62737. enumerable: true,
  62738. configurable: true
  62739. });
  62740. Object.defineProperty(Material.prototype, "onDispose", {
  62741. /**
  62742. * Called during a dispose event
  62743. */
  62744. set: function (callback) {
  62745. if (this._onDisposeObserver) {
  62746. this.onDisposeObservable.remove(this._onDisposeObserver);
  62747. }
  62748. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  62749. },
  62750. enumerable: true,
  62751. configurable: true
  62752. });
  62753. Object.defineProperty(Material.prototype, "onBindObservable", {
  62754. /**
  62755. * An event triggered when the material is bound
  62756. */
  62757. get: function () {
  62758. if (!this._onBindObservable) {
  62759. this._onBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62760. }
  62761. return this._onBindObservable;
  62762. },
  62763. enumerable: true,
  62764. configurable: true
  62765. });
  62766. Object.defineProperty(Material.prototype, "onBind", {
  62767. /**
  62768. * Called during a bind event
  62769. */
  62770. set: function (callback) {
  62771. if (this._onBindObserver) {
  62772. this.onBindObservable.remove(this._onBindObserver);
  62773. }
  62774. this._onBindObserver = this.onBindObservable.add(callback);
  62775. },
  62776. enumerable: true,
  62777. configurable: true
  62778. });
  62779. Object.defineProperty(Material.prototype, "onUnBindObservable", {
  62780. /**
  62781. * An event triggered when the material is unbound
  62782. */
  62783. get: function () {
  62784. if (!this._onUnBindObservable) {
  62785. this._onUnBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  62786. }
  62787. return this._onUnBindObservable;
  62788. },
  62789. enumerable: true,
  62790. configurable: true
  62791. });
  62792. Object.defineProperty(Material.prototype, "alphaMode", {
  62793. /**
  62794. * Gets the value of the alpha mode
  62795. */
  62796. get: function () {
  62797. return this._alphaMode;
  62798. },
  62799. /**
  62800. * Sets the value of the alpha mode.
  62801. *
  62802. * | Value | Type | Description |
  62803. * | --- | --- | --- |
  62804. * | 0 | ALPHA_DISABLE | |
  62805. * | 1 | ALPHA_ADD | |
  62806. * | 2 | ALPHA_COMBINE | |
  62807. * | 3 | ALPHA_SUBTRACT | |
  62808. * | 4 | ALPHA_MULTIPLY | |
  62809. * | 5 | ALPHA_MAXIMIZED | |
  62810. * | 6 | ALPHA_ONEONE | |
  62811. * | 7 | ALPHA_PREMULTIPLIED | |
  62812. * | 8 | ALPHA_PREMULTIPLIED_PORTERDUFF | |
  62813. * | 9 | ALPHA_INTERPOLATE | |
  62814. * | 10 | ALPHA_SCREENMODE | |
  62815. *
  62816. */
  62817. set: function (value) {
  62818. if (this._alphaMode === value) {
  62819. return;
  62820. }
  62821. this._alphaMode = value;
  62822. this.markAsDirty(Material.TextureDirtyFlag);
  62823. },
  62824. enumerable: true,
  62825. configurable: true
  62826. });
  62827. Object.defineProperty(Material.prototype, "needDepthPrePass", {
  62828. /**
  62829. * Gets the depth pre-pass value
  62830. */
  62831. get: function () {
  62832. return this._needDepthPrePass;
  62833. },
  62834. /**
  62835. * Sets the need depth pre-pass value
  62836. */
  62837. set: function (value) {
  62838. if (this._needDepthPrePass === value) {
  62839. return;
  62840. }
  62841. this._needDepthPrePass = value;
  62842. if (this._needDepthPrePass) {
  62843. this.checkReadyOnEveryCall = true;
  62844. }
  62845. },
  62846. enumerable: true,
  62847. configurable: true
  62848. });
  62849. Object.defineProperty(Material.prototype, "fogEnabled", {
  62850. /**
  62851. * Gets the value of the fog enabled state
  62852. */
  62853. get: function () {
  62854. return this._fogEnabled;
  62855. },
  62856. /**
  62857. * Sets the state for enabling fog
  62858. */
  62859. set: function (value) {
  62860. if (this._fogEnabled === value) {
  62861. return;
  62862. }
  62863. this._fogEnabled = value;
  62864. this.markAsDirty(Material.MiscDirtyFlag);
  62865. },
  62866. enumerable: true,
  62867. configurable: true
  62868. });
  62869. Object.defineProperty(Material.prototype, "wireframe", {
  62870. /**
  62871. * Gets a value specifying if wireframe mode is enabled
  62872. */
  62873. get: function () {
  62874. switch (this._fillMode) {
  62875. case Material.WireFrameFillMode:
  62876. case Material.LineListDrawMode:
  62877. case Material.LineLoopDrawMode:
  62878. case Material.LineStripDrawMode:
  62879. return true;
  62880. }
  62881. return this._scene.forceWireframe;
  62882. },
  62883. /**
  62884. * Sets the state of wireframe mode
  62885. */
  62886. set: function (value) {
  62887. this.fillMode = (value ? Material.WireFrameFillMode : Material.TriangleFillMode);
  62888. },
  62889. enumerable: true,
  62890. configurable: true
  62891. });
  62892. Object.defineProperty(Material.prototype, "pointsCloud", {
  62893. /**
  62894. * Gets the value specifying if point clouds are enabled
  62895. */
  62896. get: function () {
  62897. switch (this._fillMode) {
  62898. case Material.PointFillMode:
  62899. case Material.PointListDrawMode:
  62900. return true;
  62901. }
  62902. return this._scene.forcePointsCloud;
  62903. },
  62904. /**
  62905. * Sets the state of point cloud mode
  62906. */
  62907. set: function (value) {
  62908. this.fillMode = (value ? Material.PointFillMode : Material.TriangleFillMode);
  62909. },
  62910. enumerable: true,
  62911. configurable: true
  62912. });
  62913. Object.defineProperty(Material.prototype, "fillMode", {
  62914. /**
  62915. * Gets the material fill mode
  62916. */
  62917. get: function () {
  62918. return this._fillMode;
  62919. },
  62920. /**
  62921. * Sets the material fill mode
  62922. */
  62923. set: function (value) {
  62924. if (this._fillMode === value) {
  62925. return;
  62926. }
  62927. this._fillMode = value;
  62928. this.markAsDirty(Material.MiscDirtyFlag);
  62929. },
  62930. enumerable: true,
  62931. configurable: true
  62932. });
  62933. /**
  62934. * Returns a string representation of the current material
  62935. * @param fullDetails defines a boolean indicating which levels of logging is desired
  62936. * @returns a string with material information
  62937. */
  62938. Material.prototype.toString = function (fullDetails) {
  62939. var ret = "Name: " + this.name;
  62940. if (fullDetails) {
  62941. }
  62942. return ret;
  62943. };
  62944. /**
  62945. * Gets the class name of the material
  62946. * @returns a string with the class name of the material
  62947. */
  62948. Material.prototype.getClassName = function () {
  62949. return "Material";
  62950. };
  62951. Object.defineProperty(Material.prototype, "isFrozen", {
  62952. /**
  62953. * Specifies if updates for the material been locked
  62954. */
  62955. get: function () {
  62956. return this.checkReadyOnlyOnce;
  62957. },
  62958. enumerable: true,
  62959. configurable: true
  62960. });
  62961. /**
  62962. * Locks updates for the material
  62963. */
  62964. Material.prototype.freeze = function () {
  62965. this.checkReadyOnlyOnce = true;
  62966. };
  62967. /**
  62968. * Unlocks updates for the material
  62969. */
  62970. Material.prototype.unfreeze = function () {
  62971. this.checkReadyOnlyOnce = false;
  62972. };
  62973. /**
  62974. * Specifies if the material is ready to be used
  62975. * @param mesh defines the mesh to check
  62976. * @param useInstances specifies if instances should be used
  62977. * @returns a boolean indicating if the material is ready to be used
  62978. */
  62979. Material.prototype.isReady = function (mesh, useInstances) {
  62980. return true;
  62981. };
  62982. /**
  62983. * Specifies that the submesh is ready to be used
  62984. * @param mesh defines the mesh to check
  62985. * @param subMesh defines which submesh to check
  62986. * @param useInstances specifies that instances should be used
  62987. * @returns a boolean indicating that the submesh is ready or not
  62988. */
  62989. Material.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  62990. return false;
  62991. };
  62992. /**
  62993. * Returns the material effect
  62994. * @returns the effect associated with the material
  62995. */
  62996. Material.prototype.getEffect = function () {
  62997. return this._effect;
  62998. };
  62999. /**
  63000. * Returns the current scene
  63001. * @returns a Scene
  63002. */
  63003. Material.prototype.getScene = function () {
  63004. return this._scene;
  63005. };
  63006. /**
  63007. * Specifies if the material will require alpha blending
  63008. * @returns a boolean specifying if alpha blending is needed
  63009. */
  63010. Material.prototype.needAlphaBlending = function () {
  63011. return (this.alpha < 1.0);
  63012. };
  63013. /**
  63014. * Specifies if the mesh will require alpha blending
  63015. * @param mesh defines the mesh to check
  63016. * @returns a boolean specifying if alpha blending is needed for the mesh
  63017. */
  63018. Material.prototype.needAlphaBlendingForMesh = function (mesh) {
  63019. return this.needAlphaBlending() || (mesh.visibility < 1.0) || mesh.hasVertexAlpha;
  63020. };
  63021. /**
  63022. * Specifies if this material should be rendered in alpha test mode
  63023. * @returns a boolean specifying if an alpha test is needed.
  63024. */
  63025. Material.prototype.needAlphaTesting = function () {
  63026. return false;
  63027. };
  63028. /**
  63029. * Gets the texture used for the alpha test
  63030. * @returns the texture to use for alpha testing
  63031. */
  63032. Material.prototype.getAlphaTestTexture = function () {
  63033. return null;
  63034. };
  63035. /**
  63036. * Marks the material to indicate that it needs to be re-calculated
  63037. */
  63038. Material.prototype.markDirty = function () {
  63039. this._wasPreviouslyReady = false;
  63040. };
  63041. /** @hidden */
  63042. Material.prototype._preBind = function (effect, overrideOrientation) {
  63043. if (overrideOrientation === void 0) { overrideOrientation = null; }
  63044. var engine = this._scene.getEngine();
  63045. var orientation = (overrideOrientation == null) ? this.sideOrientation : overrideOrientation;
  63046. var reverse = orientation === Material.ClockWiseSideOrientation;
  63047. engine.enableEffect(effect ? effect : this._effect);
  63048. engine.setState(this.backFaceCulling, this.zOffset, false, reverse);
  63049. return reverse;
  63050. };
  63051. /**
  63052. * Binds the material to the mesh
  63053. * @param world defines the world transformation matrix
  63054. * @param mesh defines the mesh to bind the material to
  63055. */
  63056. Material.prototype.bind = function (world, mesh) {
  63057. };
  63058. /**
  63059. * Binds the submesh to the material
  63060. * @param world defines the world transformation matrix
  63061. * @param mesh defines the mesh containing the submesh
  63062. * @param subMesh defines the submesh to bind the material to
  63063. */
  63064. Material.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  63065. };
  63066. /**
  63067. * Binds the world matrix to the material
  63068. * @param world defines the world transformation matrix
  63069. */
  63070. Material.prototype.bindOnlyWorldMatrix = function (world) {
  63071. };
  63072. /**
  63073. * Binds the scene's uniform buffer to the effect.
  63074. * @param effect defines the effect to bind to the scene uniform buffer
  63075. * @param sceneUbo defines the uniform buffer storing scene data
  63076. */
  63077. Material.prototype.bindSceneUniformBuffer = function (effect, sceneUbo) {
  63078. sceneUbo.bindToEffect(effect, "Scene");
  63079. };
  63080. /**
  63081. * Binds the view matrix to the effect
  63082. * @param effect defines the effect to bind the view matrix to
  63083. */
  63084. Material.prototype.bindView = function (effect) {
  63085. if (!this._useUBO) {
  63086. effect.setMatrix("view", this.getScene().getViewMatrix());
  63087. }
  63088. else {
  63089. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  63090. }
  63091. };
  63092. /**
  63093. * Binds the view projection matrix to the effect
  63094. * @param effect defines the effect to bind the view projection matrix to
  63095. */
  63096. Material.prototype.bindViewProjection = function (effect) {
  63097. if (!this._useUBO) {
  63098. effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  63099. }
  63100. else {
  63101. this.bindSceneUniformBuffer(effect, this.getScene().getSceneUniformBuffer());
  63102. }
  63103. };
  63104. /**
  63105. * Specifies if material alpha testing should be turned on for the mesh
  63106. * @param mesh defines the mesh to check
  63107. */
  63108. Material.prototype._shouldTurnAlphaTestOn = function (mesh) {
  63109. return (!this.needAlphaBlendingForMesh(mesh) && this.needAlphaTesting());
  63110. };
  63111. /**
  63112. * Processes to execute after binding the material to a mesh
  63113. * @param mesh defines the rendered mesh
  63114. */
  63115. Material.prototype._afterBind = function (mesh) {
  63116. this._scene._cachedMaterial = this;
  63117. if (mesh) {
  63118. this._scene._cachedVisibility = mesh.visibility;
  63119. }
  63120. else {
  63121. this._scene._cachedVisibility = 1;
  63122. }
  63123. if (this._onBindObservable && mesh) {
  63124. this._onBindObservable.notifyObservers(mesh);
  63125. }
  63126. if (this.disableDepthWrite) {
  63127. var engine = this._scene.getEngine();
  63128. this._cachedDepthWriteState = engine.getDepthWrite();
  63129. engine.setDepthWrite(false);
  63130. }
  63131. };
  63132. /**
  63133. * Unbinds the material from the mesh
  63134. */
  63135. Material.prototype.unbind = function () {
  63136. if (this._onUnBindObservable) {
  63137. this._onUnBindObservable.notifyObservers(this);
  63138. }
  63139. if (this.disableDepthWrite) {
  63140. var engine = this._scene.getEngine();
  63141. engine.setDepthWrite(this._cachedDepthWriteState);
  63142. }
  63143. };
  63144. /**
  63145. * Gets the active textures from the material
  63146. * @returns an array of textures
  63147. */
  63148. Material.prototype.getActiveTextures = function () {
  63149. return [];
  63150. };
  63151. /**
  63152. * Specifies if the material uses a texture
  63153. * @param texture defines the texture to check against the material
  63154. * @returns a boolean specifying if the material uses the texture
  63155. */
  63156. Material.prototype.hasTexture = function (texture) {
  63157. return false;
  63158. };
  63159. /**
  63160. * Makes a duplicate of the material, and gives it a new name
  63161. * @param name defines the new name for the duplicated material
  63162. * @returns the cloned material
  63163. */
  63164. Material.prototype.clone = function (name) {
  63165. return null;
  63166. };
  63167. /**
  63168. * Gets the meshes bound to the material
  63169. * @returns an array of meshes bound to the material
  63170. */
  63171. Material.prototype.getBindedMeshes = function () {
  63172. var _this = this;
  63173. if (this.meshMap) {
  63174. var result = new Array();
  63175. for (var meshId in this.meshMap) {
  63176. var mesh = this.meshMap[meshId];
  63177. if (mesh) {
  63178. result.push(mesh);
  63179. }
  63180. }
  63181. return result;
  63182. }
  63183. else {
  63184. var meshes = this._scene.meshes;
  63185. return meshes.filter(function (mesh) { return mesh.material === _this; });
  63186. }
  63187. };
  63188. /**
  63189. * Force shader compilation
  63190. * @param mesh defines the mesh associated with this material
  63191. * @param onCompiled defines a function to execute once the material is compiled
  63192. * @param options defines the options to configure the compilation
  63193. */
  63194. Material.prototype.forceCompilation = function (mesh, onCompiled, options) {
  63195. var _this = this;
  63196. var localOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ clipPlane: false }, options);
  63197. var subMesh = new _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_6__["BaseSubMesh"]();
  63198. var scene = this.getScene();
  63199. var checkReady = function () {
  63200. if (!_this._scene || !_this._scene.getEngine()) {
  63201. return;
  63202. }
  63203. if (subMesh._materialDefines) {
  63204. subMesh._materialDefines._renderId = -1;
  63205. }
  63206. var clipPlaneState = scene.clipPlane;
  63207. if (localOptions.clipPlane) {
  63208. scene.clipPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Plane"](0, 0, 0, 1);
  63209. }
  63210. if (_this._storeEffectOnSubMeshes) {
  63211. if (_this.isReadyForSubMesh(mesh, subMesh)) {
  63212. if (onCompiled) {
  63213. onCompiled(_this);
  63214. }
  63215. }
  63216. else {
  63217. setTimeout(checkReady, 16);
  63218. }
  63219. }
  63220. else {
  63221. if (_this.isReady()) {
  63222. if (onCompiled) {
  63223. onCompiled(_this);
  63224. }
  63225. }
  63226. else {
  63227. setTimeout(checkReady, 16);
  63228. }
  63229. }
  63230. if (localOptions.clipPlane) {
  63231. scene.clipPlane = clipPlaneState;
  63232. }
  63233. };
  63234. checkReady();
  63235. };
  63236. /**
  63237. * Force shader compilation
  63238. * @param mesh defines the mesh that will use this material
  63239. * @param options defines additional options for compiling the shaders
  63240. * @returns a promise that resolves when the compilation completes
  63241. */
  63242. Material.prototype.forceCompilationAsync = function (mesh, options) {
  63243. var _this = this;
  63244. return new Promise(function (resolve) {
  63245. _this.forceCompilation(mesh, function () {
  63246. resolve();
  63247. }, options);
  63248. });
  63249. };
  63250. /**
  63251. * Marks a define in the material to indicate that it needs to be re-computed
  63252. * @param flag defines a flag used to determine which parts of the material have to be marked as dirty
  63253. */
  63254. Material.prototype.markAsDirty = function (flag) {
  63255. if (this.getScene().blockMaterialDirtyMechanism) {
  63256. return;
  63257. }
  63258. Material._DirtyCallbackArray.length = 0;
  63259. if (flag & Material.TextureDirtyFlag) {
  63260. Material._DirtyCallbackArray.push(Material._TextureDirtyCallBack);
  63261. }
  63262. if (flag & Material.LightDirtyFlag) {
  63263. Material._DirtyCallbackArray.push(Material._LightsDirtyCallBack);
  63264. }
  63265. if (flag & Material.FresnelDirtyFlag) {
  63266. Material._DirtyCallbackArray.push(Material._FresnelDirtyCallBack);
  63267. }
  63268. if (flag & Material.AttributesDirtyFlag) {
  63269. Material._DirtyCallbackArray.push(Material._AttributeDirtyCallBack);
  63270. }
  63271. if (flag & Material.MiscDirtyFlag) {
  63272. Material._DirtyCallbackArray.push(Material._MiscDirtyCallBack);
  63273. }
  63274. if (Material._DirtyCallbackArray.length) {
  63275. this._markAllSubMeshesAsDirty(Material._RunDirtyCallBacks);
  63276. }
  63277. this.getScene().resetCachedMaterial();
  63278. };
  63279. /**
  63280. * Marks all submeshes of a material to indicate that their material defines need to be re-calculated
  63281. * @param func defines a function which checks material defines against the submeshes
  63282. */
  63283. Material.prototype._markAllSubMeshesAsDirty = function (func) {
  63284. if (this.getScene().blockMaterialDirtyMechanism) {
  63285. return;
  63286. }
  63287. var meshes = this.getScene().meshes;
  63288. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  63289. var mesh = meshes_1[_i];
  63290. if (!mesh.subMeshes) {
  63291. continue;
  63292. }
  63293. for (var _a = 0, _b = mesh.subMeshes; _a < _b.length; _a++) {
  63294. var subMesh = _b[_a];
  63295. if (subMesh.getMaterial() !== this) {
  63296. continue;
  63297. }
  63298. if (!subMesh._materialDefines) {
  63299. continue;
  63300. }
  63301. func(subMesh._materialDefines);
  63302. }
  63303. }
  63304. };
  63305. /**
  63306. * Indicates that image processing needs to be re-calculated for all submeshes
  63307. */
  63308. Material.prototype._markAllSubMeshesAsImageProcessingDirty = function () {
  63309. this._markAllSubMeshesAsDirty(Material._ImageProcessingDirtyCallBack);
  63310. };
  63311. /**
  63312. * Indicates that textures need to be re-calculated for all submeshes
  63313. */
  63314. Material.prototype._markAllSubMeshesAsTexturesDirty = function () {
  63315. this._markAllSubMeshesAsDirty(Material._TextureDirtyCallBack);
  63316. };
  63317. /**
  63318. * Indicates that fresnel needs to be re-calculated for all submeshes
  63319. */
  63320. Material.prototype._markAllSubMeshesAsFresnelDirty = function () {
  63321. this._markAllSubMeshesAsDirty(Material._FresnelDirtyCallBack);
  63322. };
  63323. /**
  63324. * Indicates that fresnel and misc need to be re-calculated for all submeshes
  63325. */
  63326. Material.prototype._markAllSubMeshesAsFresnelAndMiscDirty = function () {
  63327. this._markAllSubMeshesAsDirty(Material._FresnelAndMiscDirtyCallBack);
  63328. };
  63329. /**
  63330. * Indicates that lights need to be re-calculated for all submeshes
  63331. */
  63332. Material.prototype._markAllSubMeshesAsLightsDirty = function () {
  63333. this._markAllSubMeshesAsDirty(Material._LightsDirtyCallBack);
  63334. };
  63335. /**
  63336. * Indicates that attributes need to be re-calculated for all submeshes
  63337. */
  63338. Material.prototype._markAllSubMeshesAsAttributesDirty = function () {
  63339. this._markAllSubMeshesAsDirty(Material._AttributeDirtyCallBack);
  63340. };
  63341. /**
  63342. * Indicates that misc needs to be re-calculated for all submeshes
  63343. */
  63344. Material.prototype._markAllSubMeshesAsMiscDirty = function () {
  63345. this._markAllSubMeshesAsDirty(Material._MiscDirtyCallBack);
  63346. };
  63347. /**
  63348. * Indicates that textures and misc need to be re-calculated for all submeshes
  63349. */
  63350. Material.prototype._markAllSubMeshesAsTexturesAndMiscDirty = function () {
  63351. this._markAllSubMeshesAsDirty(Material._TextureAndMiscDirtyCallBack);
  63352. };
  63353. /**
  63354. * Disposes the material
  63355. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  63356. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  63357. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  63358. */
  63359. Material.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  63360. var scene = this.getScene();
  63361. // Animations
  63362. scene.stopAnimation(this);
  63363. scene.freeProcessedMaterials();
  63364. // Remove from scene
  63365. scene.removeMaterial(this);
  63366. if (notBoundToMesh !== true) {
  63367. // Remove from meshes
  63368. if (this.meshMap) {
  63369. for (var meshId in this.meshMap) {
  63370. var mesh = this.meshMap[meshId];
  63371. if (mesh) {
  63372. mesh.material = null; // will set the entry in the map to undefined
  63373. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  63374. }
  63375. }
  63376. }
  63377. else {
  63378. var meshes = scene.meshes;
  63379. for (var _i = 0, meshes_2 = meshes; _i < meshes_2.length; _i++) {
  63380. var mesh = meshes_2[_i];
  63381. if (mesh.material === this) {
  63382. mesh.material = null;
  63383. this.releaseVertexArrayObject(mesh, forceDisposeEffect);
  63384. }
  63385. }
  63386. }
  63387. }
  63388. this._uniformBuffer.dispose();
  63389. // Shader are kept in cache for further use but we can get rid of this by using forceDisposeEffect
  63390. if (forceDisposeEffect && this._effect) {
  63391. if (!this._storeEffectOnSubMeshes) {
  63392. scene.getEngine()._releaseEffect(this._effect);
  63393. }
  63394. this._effect = null;
  63395. }
  63396. // Callback
  63397. this.onDisposeObservable.notifyObservers(this);
  63398. this.onDisposeObservable.clear();
  63399. if (this._onBindObservable) {
  63400. this._onBindObservable.clear();
  63401. }
  63402. if (this._onUnBindObservable) {
  63403. this._onUnBindObservable.clear();
  63404. }
  63405. };
  63406. /** @hidden */
  63407. Material.prototype.releaseVertexArrayObject = function (mesh, forceDisposeEffect) {
  63408. if (mesh.geometry) {
  63409. var geometry = (mesh.geometry);
  63410. var scene = this.getScene();
  63411. if (this._storeEffectOnSubMeshes) {
  63412. for (var _i = 0, _a = mesh.subMeshes; _i < _a.length; _i++) {
  63413. var subMesh = _a[_i];
  63414. geometry._releaseVertexArrayObject(subMesh._materialEffect);
  63415. if (forceDisposeEffect && subMesh._materialEffect) {
  63416. scene.getEngine()._releaseEffect(subMesh._materialEffect);
  63417. }
  63418. }
  63419. }
  63420. else {
  63421. geometry._releaseVertexArrayObject(this._effect);
  63422. }
  63423. }
  63424. };
  63425. /**
  63426. * Serializes this material
  63427. * @returns the serialized material object
  63428. */
  63429. Material.prototype.serialize = function () {
  63430. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  63431. };
  63432. /**
  63433. * Creates a material from parsed material data
  63434. * @param parsedMaterial defines parsed material data
  63435. * @param scene defines the hosting scene
  63436. * @param rootUrl defines the root URL to use to load textures
  63437. * @returns a new material
  63438. */
  63439. Material.Parse = function (parsedMaterial, scene, rootUrl) {
  63440. if (!parsedMaterial.customType) {
  63441. parsedMaterial.customType = "BABYLON.StandardMaterial";
  63442. }
  63443. else if (parsedMaterial.customType === "BABYLON.PBRMaterial" && parsedMaterial.overloadedAlbedo) {
  63444. parsedMaterial.customType = "BABYLON.LegacyPBRMaterial";
  63445. if (!BABYLON.LegacyPBRMaterial) {
  63446. _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.");
  63447. return;
  63448. }
  63449. }
  63450. var materialType = _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].Instantiate(parsedMaterial.customType);
  63451. return materialType.Parse(parsedMaterial, scene, rootUrl);
  63452. };
  63453. /**
  63454. * Returns the triangle fill mode
  63455. */
  63456. Material.TriangleFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFillMode;
  63457. /**
  63458. * Returns the wireframe mode
  63459. */
  63460. Material.WireFrameFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_WireFrameFillMode;
  63461. /**
  63462. * Returns the point fill mode
  63463. */
  63464. Material.PointFillMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointFillMode;
  63465. /**
  63466. * Returns the point list draw mode
  63467. */
  63468. Material.PointListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_PointListDrawMode;
  63469. /**
  63470. * Returns the line list draw mode
  63471. */
  63472. Material.LineListDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineListDrawMode;
  63473. /**
  63474. * Returns the line loop draw mode
  63475. */
  63476. Material.LineLoopDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineLoopDrawMode;
  63477. /**
  63478. * Returns the line strip draw mode
  63479. */
  63480. Material.LineStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LineStripDrawMode;
  63481. /**
  63482. * Returns the triangle strip draw mode
  63483. */
  63484. Material.TriangleStripDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleStripDrawMode;
  63485. /**
  63486. * Returns the triangle fan draw mode
  63487. */
  63488. Material.TriangleFanDrawMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TriangleFanDrawMode;
  63489. /**
  63490. * Stores the clock-wise side orientation
  63491. */
  63492. Material.ClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_ClockWiseSideOrientation;
  63493. /**
  63494. * Stores the counter clock-wise side orientation
  63495. */
  63496. Material.CounterClockWiseSideOrientation = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_CounterClockWiseSideOrientation;
  63497. /**
  63498. * The dirty texture flag value
  63499. */
  63500. Material.TextureDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_TextureDirtyFlag;
  63501. /**
  63502. * The dirty light flag value
  63503. */
  63504. Material.LightDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_LightDirtyFlag;
  63505. /**
  63506. * The dirty fresnel flag value
  63507. */
  63508. Material.FresnelDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_FresnelDirtyFlag;
  63509. /**
  63510. * The dirty attribute flag value
  63511. */
  63512. Material.AttributesDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AttributesDirtyFlag;
  63513. /**
  63514. * The dirty misc flag value
  63515. */
  63516. Material.MiscDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_MiscDirtyFlag;
  63517. /**
  63518. * The all dirty flag value
  63519. */
  63520. Material.AllDirtyFlag = _Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].MATERIAL_AllDirtyFlag;
  63521. Material._ImageProcessingDirtyCallBack = function (defines) { return defines.markAsImageProcessingDirty(); };
  63522. Material._TextureDirtyCallBack = function (defines) { return defines.markAsTexturesDirty(); };
  63523. Material._FresnelDirtyCallBack = function (defines) { return defines.markAsFresnelDirty(); };
  63524. Material._MiscDirtyCallBack = function (defines) { return defines.markAsMiscDirty(); };
  63525. Material._LightsDirtyCallBack = function (defines) { return defines.markAsLightDirty(); };
  63526. Material._AttributeDirtyCallBack = function (defines) { return defines.markAsAttributesDirty(); };
  63527. Material._FresnelAndMiscDirtyCallBack = function (defines) {
  63528. Material._FresnelDirtyCallBack(defines);
  63529. Material._MiscDirtyCallBack(defines);
  63530. };
  63531. Material._TextureAndMiscDirtyCallBack = function (defines) {
  63532. Material._TextureDirtyCallBack(defines);
  63533. Material._MiscDirtyCallBack(defines);
  63534. };
  63535. Material._DirtyCallbackArray = [];
  63536. Material._RunDirtyCallBacks = function (defines) {
  63537. for (var _i = 0, _a = Material._DirtyCallbackArray; _i < _a.length; _i++) {
  63538. var cb = _a[_i];
  63539. cb(defines);
  63540. }
  63541. };
  63542. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63543. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63544. ], Material.prototype, "id", void 0);
  63545. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63546. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63547. ], Material.prototype, "uniqueId", void 0);
  63548. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63549. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63550. ], Material.prototype, "name", void 0);
  63551. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63552. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63553. ], Material.prototype, "checkReadyOnEveryCall", void 0);
  63554. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63555. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63556. ], Material.prototype, "checkReadyOnlyOnce", void 0);
  63557. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63558. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63559. ], Material.prototype, "state", void 0);
  63560. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63561. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alpha")
  63562. ], Material.prototype, "_alpha", void 0);
  63563. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63564. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("backFaceCulling")
  63565. ], Material.prototype, "_backFaceCulling", void 0);
  63566. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63567. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63568. ], Material.prototype, "sideOrientation", void 0);
  63569. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63570. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("alphaMode")
  63571. ], Material.prototype, "_alphaMode", void 0);
  63572. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63573. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63574. ], Material.prototype, "_needDepthPrePass", void 0);
  63575. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63576. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63577. ], Material.prototype, "disableDepthWrite", void 0);
  63578. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63579. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63580. ], Material.prototype, "forceDepthWrite", void 0);
  63581. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63582. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63583. ], Material.prototype, "separateCullingPass", void 0);
  63584. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63585. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("fogEnabled")
  63586. ], Material.prototype, "_fogEnabled", void 0);
  63587. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63588. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63589. ], Material.prototype, "pointSize", void 0);
  63590. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63591. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63592. ], Material.prototype, "zOffset", void 0);
  63593. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63594. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63595. ], Material.prototype, "wireframe", null);
  63596. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63597. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63598. ], Material.prototype, "pointsCloud", null);
  63599. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  63600. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  63601. ], Material.prototype, "fillMode", null);
  63602. return Material;
  63603. }());
  63604. /***/ }),
  63605. /***/ "./Materials/materialDefines.ts":
  63606. /*!**************************************!*\
  63607. !*** ./Materials/materialDefines.ts ***!
  63608. \**************************************/
  63609. /*! exports provided: MaterialDefines */
  63610. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63611. "use strict";
  63612. __webpack_require__.r(__webpack_exports__);
  63613. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return MaterialDefines; });
  63614. /**
  63615. * Manages the defines for the Material
  63616. */
  63617. var MaterialDefines = /** @class */ (function () {
  63618. function MaterialDefines() {
  63619. this._isDirty = true;
  63620. /** @hidden */
  63621. this._areLightsDirty = true;
  63622. /** @hidden */
  63623. this._areAttributesDirty = true;
  63624. /** @hidden */
  63625. this._areTexturesDirty = true;
  63626. /** @hidden */
  63627. this._areFresnelDirty = true;
  63628. /** @hidden */
  63629. this._areMiscDirty = true;
  63630. /** @hidden */
  63631. this._areImageProcessingDirty = true;
  63632. /** @hidden */
  63633. this._normals = false;
  63634. /** @hidden */
  63635. this._uvs = false;
  63636. /** @hidden */
  63637. this._needNormals = false;
  63638. /** @hidden */
  63639. this._needUVs = false;
  63640. }
  63641. Object.defineProperty(MaterialDefines.prototype, "isDirty", {
  63642. /**
  63643. * Specifies if the material needs to be re-calculated
  63644. */
  63645. get: function () {
  63646. return this._isDirty;
  63647. },
  63648. enumerable: true,
  63649. configurable: true
  63650. });
  63651. /**
  63652. * Marks the material to indicate that it has been re-calculated
  63653. */
  63654. MaterialDefines.prototype.markAsProcessed = function () {
  63655. this._isDirty = false;
  63656. this._areAttributesDirty = false;
  63657. this._areTexturesDirty = false;
  63658. this._areFresnelDirty = false;
  63659. this._areLightsDirty = false;
  63660. this._areMiscDirty = false;
  63661. this._areImageProcessingDirty = false;
  63662. };
  63663. /**
  63664. * Marks the material to indicate that it needs to be re-calculated
  63665. */
  63666. MaterialDefines.prototype.markAsUnprocessed = function () {
  63667. this._isDirty = true;
  63668. };
  63669. /**
  63670. * Marks the material to indicate all of its defines need to be re-calculated
  63671. */
  63672. MaterialDefines.prototype.markAllAsDirty = function () {
  63673. this._areTexturesDirty = true;
  63674. this._areAttributesDirty = true;
  63675. this._areLightsDirty = true;
  63676. this._areFresnelDirty = true;
  63677. this._areMiscDirty = true;
  63678. this._areImageProcessingDirty = true;
  63679. this._isDirty = true;
  63680. };
  63681. /**
  63682. * Marks the material to indicate that image processing needs to be re-calculated
  63683. */
  63684. MaterialDefines.prototype.markAsImageProcessingDirty = function () {
  63685. this._areImageProcessingDirty = true;
  63686. this._isDirty = true;
  63687. };
  63688. /**
  63689. * Marks the material to indicate the lights need to be re-calculated
  63690. */
  63691. MaterialDefines.prototype.markAsLightDirty = function () {
  63692. this._areLightsDirty = true;
  63693. this._isDirty = true;
  63694. };
  63695. /**
  63696. * Marks the attribute state as changed
  63697. */
  63698. MaterialDefines.prototype.markAsAttributesDirty = function () {
  63699. this._areAttributesDirty = true;
  63700. this._isDirty = true;
  63701. };
  63702. /**
  63703. * Marks the texture state as changed
  63704. */
  63705. MaterialDefines.prototype.markAsTexturesDirty = function () {
  63706. this._areTexturesDirty = true;
  63707. this._isDirty = true;
  63708. };
  63709. /**
  63710. * Marks the fresnel state as changed
  63711. */
  63712. MaterialDefines.prototype.markAsFresnelDirty = function () {
  63713. this._areFresnelDirty = true;
  63714. this._isDirty = true;
  63715. };
  63716. /**
  63717. * Marks the misc state as changed
  63718. */
  63719. MaterialDefines.prototype.markAsMiscDirty = function () {
  63720. this._areMiscDirty = true;
  63721. this._isDirty = true;
  63722. };
  63723. /**
  63724. * Rebuilds the material defines
  63725. */
  63726. MaterialDefines.prototype.rebuild = function () {
  63727. if (this._keys) {
  63728. delete this._keys;
  63729. }
  63730. this._keys = [];
  63731. for (var _i = 0, _a = Object.keys(this); _i < _a.length; _i++) {
  63732. var key = _a[_i];
  63733. if (key[0] === "_") {
  63734. continue;
  63735. }
  63736. this._keys.push(key);
  63737. }
  63738. };
  63739. /**
  63740. * Specifies if two material defines are equal
  63741. * @param other - A material define instance to compare to
  63742. * @returns - Boolean indicating if the material defines are equal (true) or not (false)
  63743. */
  63744. MaterialDefines.prototype.isEqual = function (other) {
  63745. if (this._keys.length !== other._keys.length) {
  63746. return false;
  63747. }
  63748. for (var index = 0; index < this._keys.length; index++) {
  63749. var prop = this._keys[index];
  63750. if (this[prop] !== other[prop]) {
  63751. return false;
  63752. }
  63753. }
  63754. return true;
  63755. };
  63756. /**
  63757. * Clones this instance's defines to another instance
  63758. * @param other - material defines to clone values to
  63759. */
  63760. MaterialDefines.prototype.cloneTo = function (other) {
  63761. if (this._keys.length !== other._keys.length) {
  63762. other._keys = this._keys.slice(0);
  63763. }
  63764. for (var index = 0; index < this._keys.length; index++) {
  63765. var prop = this._keys[index];
  63766. other[prop] = this[prop];
  63767. }
  63768. };
  63769. /**
  63770. * Resets the material define values
  63771. */
  63772. MaterialDefines.prototype.reset = function () {
  63773. for (var index = 0; index < this._keys.length; index++) {
  63774. var prop = this._keys[index];
  63775. var type = typeof this[prop];
  63776. switch (type) {
  63777. case "number":
  63778. this[prop] = 0;
  63779. break;
  63780. case "string":
  63781. this[prop] = "";
  63782. break;
  63783. default:
  63784. this[prop] = false;
  63785. break;
  63786. }
  63787. }
  63788. };
  63789. /**
  63790. * Converts the material define values to a string
  63791. * @returns - String of material define information
  63792. */
  63793. MaterialDefines.prototype.toString = function () {
  63794. var result = "";
  63795. for (var index = 0; index < this._keys.length; index++) {
  63796. var prop = this._keys[index];
  63797. var value = this[prop];
  63798. var type = typeof value;
  63799. switch (type) {
  63800. case "number":
  63801. case "string":
  63802. result += "#define " + prop + " " + value + "\n";
  63803. break;
  63804. default:
  63805. if (value) {
  63806. result += "#define " + prop + "\n";
  63807. }
  63808. break;
  63809. }
  63810. }
  63811. return result;
  63812. };
  63813. return MaterialDefines;
  63814. }());
  63815. /***/ }),
  63816. /***/ "./Materials/materialFlags.ts":
  63817. /*!************************************!*\
  63818. !*** ./Materials/materialFlags.ts ***!
  63819. \************************************/
  63820. /*! exports provided: MaterialFlags */
  63821. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  63822. "use strict";
  63823. __webpack_require__.r(__webpack_exports__);
  63824. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return MaterialFlags; });
  63825. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  63826. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  63827. /**
  63828. * This groups all the flags used to control the materials channel.
  63829. */
  63830. var MaterialFlags = /** @class */ (function () {
  63831. function MaterialFlags() {
  63832. }
  63833. Object.defineProperty(MaterialFlags, "DiffuseTextureEnabled", {
  63834. /**
  63835. * Are diffuse textures enabled in the application.
  63836. */
  63837. get: function () {
  63838. return this._DiffuseTextureEnabled;
  63839. },
  63840. set: function (value) {
  63841. if (this._DiffuseTextureEnabled === value) {
  63842. return;
  63843. }
  63844. this._DiffuseTextureEnabled = value;
  63845. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63846. },
  63847. enumerable: true,
  63848. configurable: true
  63849. });
  63850. Object.defineProperty(MaterialFlags, "AmbientTextureEnabled", {
  63851. /**
  63852. * Are ambient textures enabled in the application.
  63853. */
  63854. get: function () {
  63855. return this._AmbientTextureEnabled;
  63856. },
  63857. set: function (value) {
  63858. if (this._AmbientTextureEnabled === value) {
  63859. return;
  63860. }
  63861. this._AmbientTextureEnabled = value;
  63862. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63863. },
  63864. enumerable: true,
  63865. configurable: true
  63866. });
  63867. Object.defineProperty(MaterialFlags, "OpacityTextureEnabled", {
  63868. /**
  63869. * Are opacity textures enabled in the application.
  63870. */
  63871. get: function () {
  63872. return this._OpacityTextureEnabled;
  63873. },
  63874. set: function (value) {
  63875. if (this._OpacityTextureEnabled === value) {
  63876. return;
  63877. }
  63878. this._OpacityTextureEnabled = value;
  63879. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63880. },
  63881. enumerable: true,
  63882. configurable: true
  63883. });
  63884. Object.defineProperty(MaterialFlags, "ReflectionTextureEnabled", {
  63885. /**
  63886. * Are reflection textures enabled in the application.
  63887. */
  63888. get: function () {
  63889. return this._ReflectionTextureEnabled;
  63890. },
  63891. set: function (value) {
  63892. if (this._ReflectionTextureEnabled === value) {
  63893. return;
  63894. }
  63895. this._ReflectionTextureEnabled = value;
  63896. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63897. },
  63898. enumerable: true,
  63899. configurable: true
  63900. });
  63901. Object.defineProperty(MaterialFlags, "EmissiveTextureEnabled", {
  63902. /**
  63903. * Are emissive textures enabled in the application.
  63904. */
  63905. get: function () {
  63906. return this._EmissiveTextureEnabled;
  63907. },
  63908. set: function (value) {
  63909. if (this._EmissiveTextureEnabled === value) {
  63910. return;
  63911. }
  63912. this._EmissiveTextureEnabled = value;
  63913. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63914. },
  63915. enumerable: true,
  63916. configurable: true
  63917. });
  63918. Object.defineProperty(MaterialFlags, "SpecularTextureEnabled", {
  63919. /**
  63920. * Are specular textures enabled in the application.
  63921. */
  63922. get: function () {
  63923. return this._SpecularTextureEnabled;
  63924. },
  63925. set: function (value) {
  63926. if (this._SpecularTextureEnabled === value) {
  63927. return;
  63928. }
  63929. this._SpecularTextureEnabled = value;
  63930. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63931. },
  63932. enumerable: true,
  63933. configurable: true
  63934. });
  63935. Object.defineProperty(MaterialFlags, "BumpTextureEnabled", {
  63936. /**
  63937. * Are bump textures enabled in the application.
  63938. */
  63939. get: function () {
  63940. return this._BumpTextureEnabled;
  63941. },
  63942. set: function (value) {
  63943. if (this._BumpTextureEnabled === value) {
  63944. return;
  63945. }
  63946. this._BumpTextureEnabled = value;
  63947. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63948. },
  63949. enumerable: true,
  63950. configurable: true
  63951. });
  63952. Object.defineProperty(MaterialFlags, "LightmapTextureEnabled", {
  63953. /**
  63954. * Are lightmap textures enabled in the application.
  63955. */
  63956. get: function () {
  63957. return this._LightmapTextureEnabled;
  63958. },
  63959. set: function (value) {
  63960. if (this._LightmapTextureEnabled === value) {
  63961. return;
  63962. }
  63963. this._LightmapTextureEnabled = value;
  63964. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63965. },
  63966. enumerable: true,
  63967. configurable: true
  63968. });
  63969. Object.defineProperty(MaterialFlags, "RefractionTextureEnabled", {
  63970. /**
  63971. * Are refraction textures enabled in the application.
  63972. */
  63973. get: function () {
  63974. return this._RefractionTextureEnabled;
  63975. },
  63976. set: function (value) {
  63977. if (this._RefractionTextureEnabled === value) {
  63978. return;
  63979. }
  63980. this._RefractionTextureEnabled = value;
  63981. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63982. },
  63983. enumerable: true,
  63984. configurable: true
  63985. });
  63986. Object.defineProperty(MaterialFlags, "ColorGradingTextureEnabled", {
  63987. /**
  63988. * Are color grading textures enabled in the application.
  63989. */
  63990. get: function () {
  63991. return this._ColorGradingTextureEnabled;
  63992. },
  63993. set: function (value) {
  63994. if (this._ColorGradingTextureEnabled === value) {
  63995. return;
  63996. }
  63997. this._ColorGradingTextureEnabled = value;
  63998. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  63999. },
  64000. enumerable: true,
  64001. configurable: true
  64002. });
  64003. Object.defineProperty(MaterialFlags, "FresnelEnabled", {
  64004. /**
  64005. * Are fresnels enabled in the application.
  64006. */
  64007. get: function () {
  64008. return this._FresnelEnabled;
  64009. },
  64010. set: function (value) {
  64011. if (this._FresnelEnabled === value) {
  64012. return;
  64013. }
  64014. this._FresnelEnabled = value;
  64015. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_FresnelDirtyFlag);
  64016. },
  64017. enumerable: true,
  64018. configurable: true
  64019. });
  64020. Object.defineProperty(MaterialFlags, "ClearCoatTextureEnabled", {
  64021. /**
  64022. * Are clear coat textures enabled in the application.
  64023. */
  64024. get: function () {
  64025. return this._ClearCoatTextureEnabled;
  64026. },
  64027. set: function (value) {
  64028. if (this._ClearCoatTextureEnabled === value) {
  64029. return;
  64030. }
  64031. this._ClearCoatTextureEnabled = value;
  64032. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64033. },
  64034. enumerable: true,
  64035. configurable: true
  64036. });
  64037. Object.defineProperty(MaterialFlags, "ClearCoatBumpTextureEnabled", {
  64038. /**
  64039. * Are clear coat bump textures enabled in the application.
  64040. */
  64041. get: function () {
  64042. return this._ClearCoatBumpTextureEnabled;
  64043. },
  64044. set: function (value) {
  64045. if (this._ClearCoatBumpTextureEnabled === value) {
  64046. return;
  64047. }
  64048. this._ClearCoatBumpTextureEnabled = value;
  64049. _Engines_engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].MarkAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].MATERIAL_TextureDirtyFlag);
  64050. },
  64051. enumerable: true,
  64052. configurable: true
  64053. });
  64054. // Flags used to enable or disable a type of texture for all Standard Materials
  64055. MaterialFlags._DiffuseTextureEnabled = true;
  64056. MaterialFlags._AmbientTextureEnabled = true;
  64057. MaterialFlags._OpacityTextureEnabled = true;
  64058. MaterialFlags._ReflectionTextureEnabled = true;
  64059. MaterialFlags._EmissiveTextureEnabled = true;
  64060. MaterialFlags._SpecularTextureEnabled = true;
  64061. MaterialFlags._BumpTextureEnabled = true;
  64062. MaterialFlags._LightmapTextureEnabled = true;
  64063. MaterialFlags._RefractionTextureEnabled = true;
  64064. MaterialFlags._ColorGradingTextureEnabled = true;
  64065. MaterialFlags._FresnelEnabled = true;
  64066. MaterialFlags._ClearCoatTextureEnabled = true;
  64067. MaterialFlags._ClearCoatBumpTextureEnabled = true;
  64068. return MaterialFlags;
  64069. }());
  64070. /***/ }),
  64071. /***/ "./Materials/materialHelper.ts":
  64072. /*!*************************************!*\
  64073. !*** ./Materials/materialHelper.ts ***!
  64074. \*************************************/
  64075. /*! exports provided: MaterialHelper */
  64076. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64077. "use strict";
  64078. __webpack_require__.r(__webpack_exports__);
  64079. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return MaterialHelper; });
  64080. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  64081. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  64082. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64083. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  64084. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  64085. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Lights/light */ "./Lights/light.ts");
  64086. /**
  64087. * "Static Class" containing the most commonly used helper while dealing with material for
  64088. * rendering purpose.
  64089. *
  64090. * It contains the basic tools to help defining defines, binding uniform for the common part of the materials.
  64091. *
  64092. * This works by convention in BabylonJS but is meant to be use only with shader following the in place naming rules and conventions.
  64093. */
  64094. var MaterialHelper = /** @class */ (function () {
  64095. function MaterialHelper() {
  64096. }
  64097. /**
  64098. * Bind the current view position to an effect.
  64099. * @param effect The effect to be bound
  64100. * @param scene The scene the eyes position is used from
  64101. */
  64102. MaterialHelper.BindEyePosition = function (effect, scene) {
  64103. if (scene._forcedViewPosition) {
  64104. effect.setVector3("vEyePosition", scene._forcedViewPosition);
  64105. return;
  64106. }
  64107. effect.setVector3("vEyePosition", scene._mirroredCameraPosition ? scene._mirroredCameraPosition : scene.activeCamera.globalPosition);
  64108. };
  64109. /**
  64110. * Helps preparing the defines values about the UVs in used in the effect.
  64111. * UVs are shared as much as we can accross channels in the shaders.
  64112. * @param texture The texture we are preparing the UVs for
  64113. * @param defines The defines to update
  64114. * @param key The channel key "diffuse", "specular"... used in the shader
  64115. */
  64116. MaterialHelper.PrepareDefinesForMergedUV = function (texture, defines, key) {
  64117. defines._needUVs = true;
  64118. defines[key] = true;
  64119. if (texture.getTextureMatrix().isIdentityAs3x2()) {
  64120. defines[key + "DIRECTUV"] = texture.coordinatesIndex + 1;
  64121. if (texture.coordinatesIndex === 0) {
  64122. defines["MAINUV1"] = true;
  64123. }
  64124. else {
  64125. defines["MAINUV2"] = true;
  64126. }
  64127. }
  64128. else {
  64129. defines[key + "DIRECTUV"] = 0;
  64130. }
  64131. };
  64132. /**
  64133. * Binds a texture matrix value to its corrsponding uniform
  64134. * @param texture The texture to bind the matrix for
  64135. * @param uniformBuffer The uniform buffer receivin the data
  64136. * @param key The channel key "diffuse", "specular"... used in the shader
  64137. */
  64138. MaterialHelper.BindTextureMatrix = function (texture, uniformBuffer, key) {
  64139. var matrix = texture.getTextureMatrix();
  64140. if (!matrix.isIdentityAs3x2()) {
  64141. uniformBuffer.updateMatrix(key + "Matrix", matrix);
  64142. }
  64143. };
  64144. /**
  64145. * Helper used to prepare the list of defines associated with misc. values for shader compilation
  64146. * @param mesh defines the current mesh
  64147. * @param scene defines the current scene
  64148. * @param useLogarithmicDepth defines if logarithmic depth has to be turned on
  64149. * @param pointsCloud defines if point cloud rendering has to be turned on
  64150. * @param fogEnabled defines if fog has to be turned on
  64151. * @param alphaTest defines if alpha testing has to be turned on
  64152. * @param defines defines the current list of defines
  64153. */
  64154. MaterialHelper.PrepareDefinesForMisc = function (mesh, scene, useLogarithmicDepth, pointsCloud, fogEnabled, alphaTest, defines) {
  64155. if (defines._areMiscDirty) {
  64156. defines["LOGARITHMICDEPTH"] = useLogarithmicDepth;
  64157. defines["POINTSIZE"] = pointsCloud;
  64158. defines["FOG"] = (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE && fogEnabled);
  64159. defines["NONUNIFORMSCALING"] = mesh.nonUniformScaling;
  64160. defines["ALPHATEST"] = alphaTest;
  64161. }
  64162. };
  64163. /**
  64164. * Helper used to prepare the list of defines associated with frame values for shader compilation
  64165. * @param scene defines the current scene
  64166. * @param engine defines the current engine
  64167. * @param defines specifies the list of active defines
  64168. * @param useInstances defines if instances have to be turned on
  64169. * @param useClipPlane defines if clip plane have to be turned on
  64170. */
  64171. MaterialHelper.PrepareDefinesForFrameBoundValues = function (scene, engine, defines, useInstances, useClipPlane) {
  64172. if (useClipPlane === void 0) { useClipPlane = null; }
  64173. var changed = false;
  64174. var useClipPlane1 = false;
  64175. var useClipPlane2 = false;
  64176. var useClipPlane3 = false;
  64177. var useClipPlane4 = false;
  64178. useClipPlane1 = useClipPlane == null ? (scene.clipPlane !== undefined && scene.clipPlane !== null) : useClipPlane;
  64179. useClipPlane2 = useClipPlane == null ? (scene.clipPlane2 !== undefined && scene.clipPlane2 !== null) : useClipPlane;
  64180. useClipPlane3 = useClipPlane == null ? (scene.clipPlane3 !== undefined && scene.clipPlane3 !== null) : useClipPlane;
  64181. useClipPlane4 = useClipPlane == null ? (scene.clipPlane4 !== undefined && scene.clipPlane4 !== null) : useClipPlane;
  64182. if (defines["CLIPPLANE"] !== useClipPlane1) {
  64183. defines["CLIPPLANE"] = useClipPlane1;
  64184. changed = true;
  64185. }
  64186. if (defines["CLIPPLANE2"] !== useClipPlane2) {
  64187. defines["CLIPPLANE2"] = useClipPlane2;
  64188. changed = true;
  64189. }
  64190. if (defines["CLIPPLANE3"] !== useClipPlane3) {
  64191. defines["CLIPPLANE3"] = useClipPlane3;
  64192. changed = true;
  64193. }
  64194. if (defines["CLIPPLANE4"] !== useClipPlane4) {
  64195. defines["CLIPPLANE4"] = useClipPlane4;
  64196. changed = true;
  64197. }
  64198. if (defines["DEPTHPREPASS"] !== !engine.getColorWrite()) {
  64199. defines["DEPTHPREPASS"] = !defines["DEPTHPREPASS"];
  64200. changed = true;
  64201. }
  64202. if (defines["INSTANCES"] !== useInstances) {
  64203. defines["INSTANCES"] = useInstances;
  64204. changed = true;
  64205. }
  64206. if (changed) {
  64207. defines.markAsUnprocessed();
  64208. }
  64209. };
  64210. /**
  64211. * Prepares the defines used in the shader depending on the attributes data available in the mesh
  64212. * @param mesh The mesh containing the geometry data we will draw
  64213. * @param defines The defines to update
  64214. * @param useVertexColor Precise whether vertex colors should be used or not (override mesh info)
  64215. * @param useBones Precise whether bones should be used or not (override mesh info)
  64216. * @param useMorphTargets Precise whether morph targets should be used or not (override mesh info)
  64217. * @param useVertexAlpha Precise whether vertex alpha should be used or not (override mesh info)
  64218. * @returns false if defines are considered not dirty and have not been checked
  64219. */
  64220. MaterialHelper.PrepareDefinesForAttributes = function (mesh, defines, useVertexColor, useBones, useMorphTargets, useVertexAlpha) {
  64221. if (useMorphTargets === void 0) { useMorphTargets = false; }
  64222. if (useVertexAlpha === void 0) { useVertexAlpha = true; }
  64223. if (!defines._areAttributesDirty && defines._needNormals === defines._normals && defines._needUVs === defines._uvs) {
  64224. return false;
  64225. }
  64226. defines._normals = defines._needNormals;
  64227. defines._uvs = defines._needUVs;
  64228. defines["NORMAL"] = (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind));
  64229. if (defines._needNormals && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind)) {
  64230. defines["TANGENT"] = true;
  64231. }
  64232. if (defines._needUVs) {
  64233. defines["UV1"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  64234. defines["UV2"] = mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  64235. }
  64236. else {
  64237. defines["UV1"] = false;
  64238. defines["UV2"] = false;
  64239. }
  64240. if (useVertexColor) {
  64241. var hasVertexColors = mesh.useVertexColors && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  64242. defines["VERTEXCOLOR"] = hasVertexColors;
  64243. defines["VERTEXALPHA"] = mesh.hasVertexAlpha && hasVertexColors && useVertexAlpha;
  64244. }
  64245. if (useBones) {
  64246. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64247. defines["NUM_BONE_INFLUENCERS"] = mesh.numBoneInfluencers;
  64248. var materialSupportsBoneTexture = defines["BONETEXTURE"] !== undefined;
  64249. if (mesh.skeleton.isUsingTextureForMatrices && materialSupportsBoneTexture) {
  64250. defines["BONETEXTURE"] = true;
  64251. }
  64252. else {
  64253. defines["BonesPerMesh"] = (mesh.skeleton.bones.length + 1);
  64254. defines["BONETEXTURE"] = materialSupportsBoneTexture ? false : undefined;
  64255. }
  64256. }
  64257. else {
  64258. defines["NUM_BONE_INFLUENCERS"] = 0;
  64259. defines["BonesPerMesh"] = 0;
  64260. }
  64261. }
  64262. if (useMorphTargets) {
  64263. var manager = mesh.morphTargetManager;
  64264. if (manager) {
  64265. defines["MORPHTARGETS_TANGENT"] = manager.supportsTangents && defines["TANGENT"];
  64266. defines["MORPHTARGETS_NORMAL"] = manager.supportsNormals && defines["NORMAL"];
  64267. defines["MORPHTARGETS"] = (manager.numInfluencers > 0);
  64268. defines["NUM_MORPH_INFLUENCERS"] = manager.numInfluencers;
  64269. }
  64270. else {
  64271. defines["MORPHTARGETS_TANGENT"] = false;
  64272. defines["MORPHTARGETS_NORMAL"] = false;
  64273. defines["MORPHTARGETS"] = false;
  64274. defines["NUM_MORPH_INFLUENCERS"] = 0;
  64275. }
  64276. }
  64277. return true;
  64278. };
  64279. /**
  64280. * Prepares the defines related to the light information passed in parameter
  64281. * @param scene The scene we are intending to draw
  64282. * @param mesh The mesh the effect is compiling for
  64283. * @param defines The defines to update
  64284. * @param specularSupported Specifies whether specular is supported or not (override lights data)
  64285. * @param maxSimultaneousLights Specfies how manuy lights can be added to the effect at max
  64286. * @param disableLighting Specifies whether the lighting is disabled (override scene and light)
  64287. * @returns true if normals will be required for the rest of the effect
  64288. */
  64289. MaterialHelper.PrepareDefinesForLights = function (scene, mesh, defines, specularSupported, maxSimultaneousLights, disableLighting) {
  64290. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64291. if (disableLighting === void 0) { disableLighting = false; }
  64292. if (!defines._areLightsDirty) {
  64293. return defines._needNormals;
  64294. }
  64295. var lightIndex = 0;
  64296. var needNormals = false;
  64297. var needRebuild = false;
  64298. var lightmapMode = false;
  64299. var shadowEnabled = false;
  64300. var specularEnabled = false;
  64301. if (scene.lightsEnabled && !disableLighting) {
  64302. for (var _i = 0, _a = mesh._lightSources; _i < _a.length; _i++) {
  64303. var light = _a[_i];
  64304. needNormals = true;
  64305. if (defines["LIGHT" + lightIndex] === undefined) {
  64306. needRebuild = true;
  64307. }
  64308. defines["LIGHT" + lightIndex] = true;
  64309. defines["SPOTLIGHT" + lightIndex] = false;
  64310. defines["HEMILIGHT" + lightIndex] = false;
  64311. defines["POINTLIGHT" + lightIndex] = false;
  64312. defines["DIRLIGHT" + lightIndex] = false;
  64313. light.prepareLightSpecificDefines(defines, lightIndex);
  64314. // FallOff.
  64315. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = false;
  64316. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = false;
  64317. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = false;
  64318. switch (light.falloffType) {
  64319. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_GLTF:
  64320. defines["LIGHT_FALLOFF_GLTF" + lightIndex] = true;
  64321. break;
  64322. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_PHYSICAL:
  64323. defines["LIGHT_FALLOFF_PHYSICAL" + lightIndex] = true;
  64324. break;
  64325. case _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].FALLOFF_STANDARD:
  64326. defines["LIGHT_FALLOFF_STANDARD" + lightIndex] = true;
  64327. break;
  64328. }
  64329. // Specular
  64330. if (specularSupported && !light.specular.equalsFloats(0, 0, 0)) {
  64331. specularEnabled = true;
  64332. }
  64333. // Shadows
  64334. defines["SHADOW" + lightIndex] = false;
  64335. defines["SHADOWPCF" + lightIndex] = false;
  64336. defines["SHADOWPCSS" + lightIndex] = false;
  64337. defines["SHADOWPOISSON" + lightIndex] = false;
  64338. defines["SHADOWESM" + lightIndex] = false;
  64339. defines["SHADOWCUBE" + lightIndex] = false;
  64340. defines["SHADOWLOWQUALITY" + lightIndex] = false;
  64341. defines["SHADOWMEDIUMQUALITY" + lightIndex] = false;
  64342. if (mesh && mesh.receiveShadows && scene.shadowsEnabled && light.shadowEnabled) {
  64343. var shadowGenerator = light.getShadowGenerator();
  64344. if (shadowGenerator) {
  64345. var shadowMap = shadowGenerator.getShadowMap();
  64346. if (shadowMap) {
  64347. if (shadowMap.renderList && shadowMap.renderList.length > 0) {
  64348. shadowEnabled = true;
  64349. shadowGenerator.prepareDefines(defines, lightIndex);
  64350. }
  64351. }
  64352. }
  64353. }
  64354. if (light.lightmapMode != _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_DEFAULT) {
  64355. lightmapMode = true;
  64356. defines["LIGHTMAPEXCLUDED" + lightIndex] = true;
  64357. defines["LIGHTMAPNOSPECULAR" + lightIndex] = (light.lightmapMode == _Lights_light__WEBPACK_IMPORTED_MODULE_5__["Light"].LIGHTMAP_SHADOWSONLY);
  64358. }
  64359. else {
  64360. defines["LIGHTMAPEXCLUDED" + lightIndex] = false;
  64361. defines["LIGHTMAPNOSPECULAR" + lightIndex] = false;
  64362. }
  64363. lightIndex++;
  64364. if (lightIndex === maxSimultaneousLights) {
  64365. break;
  64366. }
  64367. }
  64368. }
  64369. defines["SPECULARTERM"] = specularEnabled;
  64370. defines["SHADOWS"] = shadowEnabled;
  64371. // Resetting all other lights if any
  64372. for (var index = lightIndex; index < maxSimultaneousLights; index++) {
  64373. if (defines["LIGHT" + index] !== undefined) {
  64374. defines["LIGHT" + index] = false;
  64375. defines["HEMILIGHT" + index] = false;
  64376. defines["POINTLIGHT" + index] = false;
  64377. defines["DIRLIGHT" + index] = false;
  64378. defines["SPOTLIGHT" + index] = false;
  64379. defines["SHADOW" + index] = false;
  64380. defines["SHADOWPCF" + index] = false;
  64381. defines["SHADOWPCSS" + index] = false;
  64382. defines["SHADOWPOISSON" + index] = false;
  64383. defines["SHADOWESM" + index] = false;
  64384. defines["SHADOWCUBE" + index] = false;
  64385. defines["SHADOWLOWQUALITY" + index] = false;
  64386. defines["SHADOWMEDIUMQUALITY" + index] = false;
  64387. }
  64388. }
  64389. var caps = scene.getEngine().getCaps();
  64390. if (defines["SHADOWFLOAT"] === undefined) {
  64391. needRebuild = true;
  64392. }
  64393. defines["SHADOWFLOAT"] = shadowEnabled &&
  64394. ((caps.textureFloatRender && caps.textureFloatLinearFiltering) ||
  64395. (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering));
  64396. defines["LIGHTMAPEXCLUDED"] = lightmapMode;
  64397. if (needRebuild) {
  64398. defines.rebuild();
  64399. }
  64400. return needNormals;
  64401. };
  64402. /**
  64403. * Prepares the uniforms and samplers list to be used in the effect. This can automatically remove from the list uniforms
  64404. * that won t be acctive due to defines being turned off.
  64405. * @param uniformsListOrOptions The uniform names to prepare or an EffectCreationOptions containing the liist and extra information
  64406. * @param samplersList The samplers list
  64407. * @param defines The defines helping in the list generation
  64408. * @param maxSimultaneousLights The maximum number of simultanous light allowed in the effect
  64409. */
  64410. MaterialHelper.PrepareUniformsAndSamplersList = function (uniformsListOrOptions, samplersList, defines, maxSimultaneousLights) {
  64411. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64412. var uniformsList;
  64413. var uniformBuffersList = null;
  64414. if (uniformsListOrOptions.uniformsNames) {
  64415. var options = uniformsListOrOptions;
  64416. uniformsList = options.uniformsNames;
  64417. uniformBuffersList = options.uniformBuffersNames;
  64418. samplersList = options.samplers;
  64419. defines = options.defines;
  64420. maxSimultaneousLights = options.maxSimultaneousLights;
  64421. }
  64422. else {
  64423. uniformsList = uniformsListOrOptions;
  64424. if (!samplersList) {
  64425. samplersList = [];
  64426. }
  64427. }
  64428. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  64429. if (!defines["LIGHT" + lightIndex]) {
  64430. break;
  64431. }
  64432. uniformsList.push("vLightData" + lightIndex, "vLightDiffuse" + lightIndex, "vLightSpecular" + lightIndex, "vLightDirection" + lightIndex, "vLightFalloff" + lightIndex, "vLightGround" + lightIndex, "lightMatrix" + lightIndex, "shadowsInfo" + lightIndex, "depthValues" + lightIndex);
  64433. if (uniformBuffersList) {
  64434. uniformBuffersList.push("Light" + lightIndex);
  64435. }
  64436. samplersList.push("shadowSampler" + lightIndex);
  64437. samplersList.push("depthSampler" + lightIndex);
  64438. if (defines["PROJECTEDLIGHTTEXTURE" + lightIndex]) {
  64439. samplersList.push("projectionLightSampler" + lightIndex);
  64440. uniformsList.push("textureProjectionMatrix" + lightIndex);
  64441. }
  64442. }
  64443. if (defines["NUM_MORPH_INFLUENCERS"]) {
  64444. uniformsList.push("morphTargetInfluences");
  64445. }
  64446. };
  64447. /**
  64448. * This helps decreasing rank by rank the shadow quality (0 being the highest rank and quality)
  64449. * @param defines The defines to update while falling back
  64450. * @param fallbacks The authorized effect fallbacks
  64451. * @param maxSimultaneousLights The maximum number of lights allowed
  64452. * @param rank the current rank of the Effect
  64453. * @returns The newly affected rank
  64454. */
  64455. MaterialHelper.HandleFallbacksForShadows = function (defines, fallbacks, maxSimultaneousLights, rank) {
  64456. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64457. if (rank === void 0) { rank = 0; }
  64458. var lightFallbackRank = 0;
  64459. for (var lightIndex = 0; lightIndex < maxSimultaneousLights; lightIndex++) {
  64460. if (!defines["LIGHT" + lightIndex]) {
  64461. break;
  64462. }
  64463. if (lightIndex > 0) {
  64464. lightFallbackRank = rank + lightIndex;
  64465. fallbacks.addFallback(lightFallbackRank, "LIGHT" + lightIndex);
  64466. }
  64467. if (!defines["SHADOWS"]) {
  64468. if (defines["SHADOW" + lightIndex]) {
  64469. fallbacks.addFallback(rank, "SHADOW" + lightIndex);
  64470. }
  64471. if (defines["SHADOWPCF" + lightIndex]) {
  64472. fallbacks.addFallback(rank, "SHADOWPCF" + lightIndex);
  64473. }
  64474. if (defines["SHADOWPCSS" + lightIndex]) {
  64475. fallbacks.addFallback(rank, "SHADOWPCSS" + lightIndex);
  64476. }
  64477. if (defines["SHADOWPOISSON" + lightIndex]) {
  64478. fallbacks.addFallback(rank, "SHADOWPOISSON" + lightIndex);
  64479. }
  64480. if (defines["SHADOWESM" + lightIndex]) {
  64481. fallbacks.addFallback(rank, "SHADOWESM" + lightIndex);
  64482. }
  64483. }
  64484. }
  64485. return lightFallbackRank++;
  64486. };
  64487. /**
  64488. * Prepares the list of attributes required for morph targets according to the effect defines.
  64489. * @param attribs The current list of supported attribs
  64490. * @param mesh The mesh to prepare the morph targets attributes for
  64491. * @param defines The current Defines of the effect
  64492. */
  64493. MaterialHelper.PrepareAttributesForMorphTargets = function (attribs, mesh, defines) {
  64494. var influencers = defines["NUM_MORPH_INFLUENCERS"];
  64495. if (influencers > 0 && _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine) {
  64496. var maxAttributesCount = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedEngine.getCaps().maxVertexAttribs;
  64497. var manager = mesh.morphTargetManager;
  64498. var normal = manager && manager.supportsNormals && defines["NORMAL"];
  64499. var tangent = manager && manager.supportsTangents && defines["TANGENT"];
  64500. for (var index = 0; index < influencers; index++) {
  64501. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind + index);
  64502. if (normal) {
  64503. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind + index);
  64504. }
  64505. if (tangent) {
  64506. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].TangentKind + index);
  64507. }
  64508. if (attribs.length > maxAttributesCount) {
  64509. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add more vertex attributes for mesh " + mesh.name);
  64510. }
  64511. }
  64512. }
  64513. };
  64514. /**
  64515. * Prepares the list of attributes required for bones according to the effect defines.
  64516. * @param attribs The current list of supported attribs
  64517. * @param mesh The mesh to prepare the bones attributes for
  64518. * @param defines The current Defines of the effect
  64519. * @param fallbacks The current efffect fallback strategy
  64520. */
  64521. MaterialHelper.PrepareAttributesForBones = function (attribs, mesh, defines, fallbacks) {
  64522. if (defines["NUM_BONE_INFLUENCERS"] > 0) {
  64523. fallbacks.addCPUSkinningFallback(0, mesh);
  64524. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  64525. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  64526. if (defines["NUM_BONE_INFLUENCERS"] > 4) {
  64527. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesExtraKind);
  64528. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsExtraKind);
  64529. }
  64530. }
  64531. };
  64532. /**
  64533. * Prepares the list of attributes required for instances according to the effect defines.
  64534. * @param attribs The current list of supported attribs
  64535. * @param defines The current Defines of the effect
  64536. */
  64537. MaterialHelper.PrepareAttributesForInstances = function (attribs, defines) {
  64538. if (defines["INSTANCES"]) {
  64539. attribs.push("world0");
  64540. attribs.push("world1");
  64541. attribs.push("world2");
  64542. attribs.push("world3");
  64543. }
  64544. };
  64545. /**
  64546. * Binds the light shadow information to the effect for the given mesh.
  64547. * @param light The light containing the generator
  64548. * @param scene The scene the lights belongs to
  64549. * @param mesh The mesh we are binding the information to render
  64550. * @param lightIndex The light index in the effect used to render the mesh
  64551. * @param effect The effect we are binding the data to
  64552. */
  64553. MaterialHelper.BindLightShadow = function (light, mesh, lightIndex, effect) {
  64554. if (light.shadowEnabled && mesh.receiveShadows) {
  64555. var shadowGenerator = light.getShadowGenerator();
  64556. if (shadowGenerator) {
  64557. shadowGenerator.bindShadowLight(lightIndex, effect);
  64558. }
  64559. }
  64560. };
  64561. /**
  64562. * Binds the light information to the effect.
  64563. * @param light The light containing the generator
  64564. * @param effect The effect we are binding the data to
  64565. * @param lightIndex The light index in the effect used to render
  64566. */
  64567. MaterialHelper.BindLightProperties = function (light, effect, lightIndex) {
  64568. light.transferToEffect(effect, lightIndex + "");
  64569. };
  64570. /**
  64571. * Binds the lights information from the scene to the effect for the given mesh.
  64572. * @param scene The scene the lights belongs to
  64573. * @param mesh The mesh we are binding the information to render
  64574. * @param effect The effect we are binding the data to
  64575. * @param defines The generated defines for the effect
  64576. * @param maxSimultaneousLights The maximum number of light that can be bound to the effect
  64577. * @param usePhysicalLightFalloff Specifies whether the light falloff is defined physically or not
  64578. */
  64579. MaterialHelper.BindLights = function (scene, mesh, effect, defines, maxSimultaneousLights, usePhysicalLightFalloff) {
  64580. if (maxSimultaneousLights === void 0) { maxSimultaneousLights = 4; }
  64581. if (usePhysicalLightFalloff === void 0) { usePhysicalLightFalloff = false; }
  64582. var len = Math.min(mesh._lightSources.length, maxSimultaneousLights);
  64583. for (var i = 0; i < len; i++) {
  64584. var light = mesh._lightSources[i];
  64585. var iAsString = i.toString();
  64586. var scaledIntensity = light.getScaledIntensity();
  64587. light._uniformBuffer.bindToEffect(effect, "Light" + i);
  64588. MaterialHelper.BindLightProperties(light, effect, i);
  64589. light.diffuse.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0]);
  64590. light._uniformBuffer.updateColor4("vLightDiffuse", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[0], usePhysicalLightFalloff ? light.radius : light.range, iAsString);
  64591. if (defines["SPECULARTERM"]) {
  64592. light.specular.scaleToRef(scaledIntensity, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1]);
  64593. light._uniformBuffer.updateColor3("vLightSpecular", _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Tmp"].Color3[1], iAsString);
  64594. }
  64595. // Shadows
  64596. if (scene.shadowsEnabled) {
  64597. this.BindLightShadow(light, mesh, iAsString, effect);
  64598. }
  64599. light._uniformBuffer.update();
  64600. }
  64601. };
  64602. /**
  64603. * Binds the fog information from the scene to the effect for the given mesh.
  64604. * @param scene The scene the lights belongs to
  64605. * @param mesh The mesh we are binding the information to render
  64606. * @param effect The effect we are binding the data to
  64607. * @param linearSpace Defines if the fog effect is applied in linear space
  64608. */
  64609. MaterialHelper.BindFogParameters = function (scene, mesh, effect, linearSpace) {
  64610. if (linearSpace === void 0) { linearSpace = false; }
  64611. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].FOGMODE_NONE) {
  64612. effect.setFloat4("vFogInfos", scene.fogMode, scene.fogStart, scene.fogEnd, scene.fogDensity);
  64613. // Convert fog color to linear space if used in a linear space computed shader.
  64614. if (linearSpace) {
  64615. scene.fogColor.toLinearSpaceToRef(this._tempFogColor);
  64616. effect.setColor3("vFogColor", this._tempFogColor);
  64617. }
  64618. else {
  64619. effect.setColor3("vFogColor", scene.fogColor);
  64620. }
  64621. }
  64622. };
  64623. /**
  64624. * Binds the bones information from the mesh to the effect.
  64625. * @param mesh The mesh we are binding the information to render
  64626. * @param effect The effect we are binding the data to
  64627. */
  64628. MaterialHelper.BindBonesParameters = function (mesh, effect) {
  64629. if (!effect || !mesh) {
  64630. return;
  64631. }
  64632. if (mesh.computeBonesUsingShaders && effect._bonesComputationForcedToCPU) {
  64633. mesh.computeBonesUsingShaders = false;
  64634. }
  64635. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  64636. var skeleton = mesh.skeleton;
  64637. if (skeleton.isUsingTextureForMatrices && effect.getUniformIndex("boneTextureWidth") > -1) {
  64638. var boneTexture = skeleton.getTransformMatrixTexture();
  64639. effect.setTexture("boneSampler", boneTexture);
  64640. effect.setFloat("boneTextureWidth", 4.0 * (skeleton.bones.length + 1));
  64641. }
  64642. else {
  64643. var matrices = skeleton.getTransformMatrices(mesh);
  64644. if (matrices) {
  64645. effect.setMatrices("mBones", matrices);
  64646. }
  64647. }
  64648. }
  64649. };
  64650. /**
  64651. * Binds the morph targets information from the mesh to the effect.
  64652. * @param abstractMesh The mesh we are binding the information to render
  64653. * @param effect The effect we are binding the data to
  64654. */
  64655. MaterialHelper.BindMorphTargetParameters = function (abstractMesh, effect) {
  64656. var manager = abstractMesh.morphTargetManager;
  64657. if (!abstractMesh || !manager) {
  64658. return;
  64659. }
  64660. effect.setFloatArray("morphTargetInfluences", manager.influences);
  64661. };
  64662. /**
  64663. * Binds the logarithmic depth information from the scene to the effect for the given defines.
  64664. * @param defines The generated defines used in the effect
  64665. * @param effect The effect we are binding the data to
  64666. * @param scene The scene we are willing to render with logarithmic scale for
  64667. */
  64668. MaterialHelper.BindLogDepth = function (defines, effect, scene) {
  64669. if (defines["LOGARITHMICDEPTH"]) {
  64670. effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  64671. }
  64672. };
  64673. /**
  64674. * Binds the clip plane information from the scene to the effect.
  64675. * @param scene The scene the clip plane information are extracted from
  64676. * @param effect The effect we are binding the data to
  64677. */
  64678. MaterialHelper.BindClipPlane = function (effect, scene) {
  64679. if (scene.clipPlane) {
  64680. var clipPlane = scene.clipPlane;
  64681. effect.setFloat4("vClipPlane", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64682. }
  64683. if (scene.clipPlane2) {
  64684. var clipPlane = scene.clipPlane2;
  64685. effect.setFloat4("vClipPlane2", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64686. }
  64687. if (scene.clipPlane3) {
  64688. var clipPlane = scene.clipPlane3;
  64689. effect.setFloat4("vClipPlane3", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64690. }
  64691. if (scene.clipPlane4) {
  64692. var clipPlane = scene.clipPlane4;
  64693. effect.setFloat4("vClipPlane4", clipPlane.normal.x, clipPlane.normal.y, clipPlane.normal.z, clipPlane.d);
  64694. }
  64695. };
  64696. MaterialHelper._tempFogColor = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].Black();
  64697. return MaterialHelper;
  64698. }());
  64699. /***/ }),
  64700. /***/ "./Materials/multiMaterial.ts":
  64701. /*!************************************!*\
  64702. !*** ./Materials/multiMaterial.ts ***!
  64703. \************************************/
  64704. /*! exports provided: MultiMaterial */
  64705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64706. "use strict";
  64707. __webpack_require__.r(__webpack_exports__);
  64708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return MultiMaterial; });
  64709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64710. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64711. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  64712. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  64713. /**
  64714. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64715. * separate meshes. This can be use to improve performances.
  64716. * @see http://doc.babylonjs.com/how_to/multi_materials
  64717. */
  64718. var MultiMaterial = /** @class */ (function (_super) {
  64719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MultiMaterial, _super);
  64720. /**
  64721. * Instantiates a new Multi Material
  64722. * A multi-material is used to apply different materials to different parts of the same object without the need of
  64723. * separate meshes. This can be use to improve performances.
  64724. * @see http://doc.babylonjs.com/how_to/multi_materials
  64725. * @param name Define the name in the scene
  64726. * @param scene Define the scene the material belongs to
  64727. */
  64728. function MultiMaterial(name, scene) {
  64729. var _this = _super.call(this, name, scene, true) || this;
  64730. scene.multiMaterials.push(_this);
  64731. _this.subMaterials = new Array();
  64732. _this._storeEffectOnSubMeshes = true; // multimaterial is considered like a push material
  64733. return _this;
  64734. }
  64735. Object.defineProperty(MultiMaterial.prototype, "subMaterials", {
  64736. /**
  64737. * Gets or Sets the list of Materials used within the multi material.
  64738. * They need to be ordered according to the submeshes order in the associated mesh
  64739. */
  64740. get: function () {
  64741. return this._subMaterials;
  64742. },
  64743. set: function (value) {
  64744. this._subMaterials = value;
  64745. this._hookArray(value);
  64746. },
  64747. enumerable: true,
  64748. configurable: true
  64749. });
  64750. /**
  64751. * Function used to align with Node.getChildren()
  64752. * @returns the list of Materials used within the multi material
  64753. */
  64754. MultiMaterial.prototype.getChildren = function () {
  64755. return this.subMaterials;
  64756. };
  64757. MultiMaterial.prototype._hookArray = function (array) {
  64758. var _this = this;
  64759. var oldPush = array.push;
  64760. array.push = function () {
  64761. var items = [];
  64762. for (var _i = 0; _i < arguments.length; _i++) {
  64763. items[_i] = arguments[_i];
  64764. }
  64765. var result = oldPush.apply(array, items);
  64766. _this._markAllSubMeshesAsTexturesDirty();
  64767. return result;
  64768. };
  64769. var oldSplice = array.splice;
  64770. array.splice = function (index, deleteCount) {
  64771. var deleted = oldSplice.apply(array, [index, deleteCount]);
  64772. _this._markAllSubMeshesAsTexturesDirty();
  64773. return deleted;
  64774. };
  64775. };
  64776. /**
  64777. * Get one of the submaterial by its index in the submaterials array
  64778. * @param index The index to look the sub material at
  64779. * @returns The Material if the index has been defined
  64780. */
  64781. MultiMaterial.prototype.getSubMaterial = function (index) {
  64782. if (index < 0 || index >= this.subMaterials.length) {
  64783. return this.getScene().defaultMaterial;
  64784. }
  64785. return this.subMaterials[index];
  64786. };
  64787. /**
  64788. * Get the list of active textures for the whole sub materials list.
  64789. * @returns All the textures that will be used during the rendering
  64790. */
  64791. MultiMaterial.prototype.getActiveTextures = function () {
  64792. var _a;
  64793. return (_a = _super.prototype.getActiveTextures.call(this)).concat.apply(_a, this.subMaterials.map(function (subMaterial) {
  64794. if (subMaterial) {
  64795. return subMaterial.getActiveTextures();
  64796. }
  64797. else {
  64798. return [];
  64799. }
  64800. }));
  64801. };
  64802. /**
  64803. * Gets the current class name of the material e.g. "MultiMaterial"
  64804. * Mainly use in serialization.
  64805. * @returns the class name
  64806. */
  64807. MultiMaterial.prototype.getClassName = function () {
  64808. return "MultiMaterial";
  64809. };
  64810. /**
  64811. * Checks if the material is ready to render the requested sub mesh
  64812. * @param mesh Define the mesh the submesh belongs to
  64813. * @param subMesh Define the sub mesh to look readyness for
  64814. * @param useInstances Define whether or not the material is used with instances
  64815. * @returns true if ready, otherwise false
  64816. */
  64817. MultiMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  64818. for (var index = 0; index < this.subMaterials.length; index++) {
  64819. var subMaterial = this.subMaterials[index];
  64820. if (subMaterial) {
  64821. if (subMaterial._storeEffectOnSubMeshes) {
  64822. if (!subMaterial.isReadyForSubMesh(mesh, subMesh, useInstances)) {
  64823. return false;
  64824. }
  64825. continue;
  64826. }
  64827. if (!subMaterial.isReady(mesh)) {
  64828. return false;
  64829. }
  64830. }
  64831. }
  64832. return true;
  64833. };
  64834. /**
  64835. * Clones the current material and its related sub materials
  64836. * @param name Define the name of the newly cloned material
  64837. * @param cloneChildren Define if submaterial will be cloned or shared with the parent instance
  64838. * @returns the cloned material
  64839. */
  64840. MultiMaterial.prototype.clone = function (name, cloneChildren) {
  64841. var newMultiMaterial = new MultiMaterial(name, this.getScene());
  64842. for (var index = 0; index < this.subMaterials.length; index++) {
  64843. var subMaterial = null;
  64844. var current = this.subMaterials[index];
  64845. if (cloneChildren && current) {
  64846. subMaterial = current.clone(name + "-" + current.name);
  64847. }
  64848. else {
  64849. subMaterial = this.subMaterials[index];
  64850. }
  64851. newMultiMaterial.subMaterials.push(subMaterial);
  64852. }
  64853. return newMultiMaterial;
  64854. };
  64855. /**
  64856. * Serializes the materials into a JSON representation.
  64857. * @returns the JSON representation
  64858. */
  64859. MultiMaterial.prototype.serialize = function () {
  64860. var serializationObject = {};
  64861. serializationObject.name = this.name;
  64862. serializationObject.id = this.id;
  64863. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64864. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].GetTags(this);
  64865. }
  64866. serializationObject.materials = [];
  64867. for (var matIndex = 0; matIndex < this.subMaterials.length; matIndex++) {
  64868. var subMat = this.subMaterials[matIndex];
  64869. if (subMat) {
  64870. serializationObject.materials.push(subMat.id);
  64871. }
  64872. else {
  64873. serializationObject.materials.push(null);
  64874. }
  64875. }
  64876. return serializationObject;
  64877. };
  64878. /**
  64879. * Dispose the material and release its associated resources
  64880. * @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)
  64881. * @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)
  64882. * @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)
  64883. */
  64884. MultiMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, forceDisposeChildren) {
  64885. var scene = this.getScene();
  64886. if (!scene) {
  64887. return;
  64888. }
  64889. if (forceDisposeChildren) {
  64890. for (var index = 0; index < this.subMaterials.length; index++) {
  64891. var subMaterial = this.subMaterials[index];
  64892. if (subMaterial) {
  64893. subMaterial.dispose(forceDisposeEffect, forceDisposeTextures);
  64894. }
  64895. }
  64896. }
  64897. var index = scene.multiMaterials.indexOf(this);
  64898. if (index >= 0) {
  64899. scene.multiMaterials.splice(index, 1);
  64900. }
  64901. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  64902. };
  64903. /**
  64904. * Creates a MultiMaterial from parsed MultiMaterial data.
  64905. * @param parsedMultiMaterial defines parsed MultiMaterial data.
  64906. * @param scene defines the hosting scene
  64907. * @returns a new MultiMaterial
  64908. */
  64909. MultiMaterial.ParseMultiMaterial = function (parsedMultiMaterial, scene) {
  64910. var multiMaterial = new MultiMaterial(parsedMultiMaterial.name, scene);
  64911. multiMaterial.id = parsedMultiMaterial.id;
  64912. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"]) {
  64913. _Misc_tags__WEBPACK_IMPORTED_MODULE_2__["Tags"].AddTagsTo(multiMaterial, parsedMultiMaterial.tags);
  64914. }
  64915. for (var matIndex = 0; matIndex < parsedMultiMaterial.materials.length; matIndex++) {
  64916. var subMatId = parsedMultiMaterial.materials[matIndex];
  64917. if (subMatId) {
  64918. multiMaterial.subMaterials.push(scene.getMaterialByID(subMatId));
  64919. }
  64920. else {
  64921. multiMaterial.subMaterials.push(null);
  64922. }
  64923. }
  64924. return multiMaterial;
  64925. };
  64926. return MultiMaterial;
  64927. }(_Materials_material__WEBPACK_IMPORTED_MODULE_1__["Material"]));
  64928. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_3__["_TypeStore"].RegisteredTypes["BABYLON.MultiMaterial"] = MultiMaterial;
  64929. /***/ }),
  64930. /***/ "./Materials/pushMaterial.ts":
  64931. /*!***********************************!*\
  64932. !*** ./Materials/pushMaterial.ts ***!
  64933. \***********************************/
  64934. /*! exports provided: PushMaterial */
  64935. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  64936. "use strict";
  64937. __webpack_require__.r(__webpack_exports__);
  64938. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return PushMaterial; });
  64939. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  64940. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  64941. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  64942. /**
  64943. * Base class of materials working in push mode in babylon JS
  64944. * @hidden
  64945. */
  64946. var PushMaterial = /** @class */ (function (_super) {
  64947. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PushMaterial, _super);
  64948. function PushMaterial(name, scene) {
  64949. var _this = _super.call(this, name, scene) || this;
  64950. _this._normalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]();
  64951. /**
  64952. * Gets or sets a boolean indicating that the material is allowed to do shader hot swapping.
  64953. * This means that the material can keep using a previous shader while a new one is being compiled.
  64954. * This is mostly used when shader parallel compilation is supported (true by default)
  64955. */
  64956. _this.allowShaderHotSwapping = true;
  64957. _this._storeEffectOnSubMeshes = true;
  64958. return _this;
  64959. }
  64960. PushMaterial.prototype.getEffect = function () {
  64961. return this._activeEffect;
  64962. };
  64963. PushMaterial.prototype.isReady = function (mesh, useInstances) {
  64964. if (!mesh) {
  64965. return false;
  64966. }
  64967. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  64968. return true;
  64969. }
  64970. return this.isReadyForSubMesh(mesh, mesh.subMeshes[0], useInstances);
  64971. };
  64972. /**
  64973. * Binds the given world matrix to the active effect
  64974. *
  64975. * @param world the matrix to bind
  64976. */
  64977. PushMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  64978. this._activeEffect.setMatrix("world", world);
  64979. };
  64980. /**
  64981. * Binds the given normal matrix to the active effect
  64982. *
  64983. * @param normalMatrix the matrix to bind
  64984. */
  64985. PushMaterial.prototype.bindOnlyNormalMatrix = function (normalMatrix) {
  64986. this._activeEffect.setMatrix("normalMatrix", normalMatrix);
  64987. };
  64988. PushMaterial.prototype.bind = function (world, mesh) {
  64989. if (!mesh) {
  64990. return;
  64991. }
  64992. this.bindForSubMesh(world, mesh, mesh.subMeshes[0]);
  64993. };
  64994. PushMaterial.prototype._afterBind = function (mesh, effect) {
  64995. if (effect === void 0) { effect = null; }
  64996. _super.prototype._afterBind.call(this, mesh);
  64997. this.getScene()._cachedEffect = effect;
  64998. };
  64999. PushMaterial.prototype._mustRebind = function (scene, effect, visibility) {
  65000. if (visibility === void 0) { visibility = 1; }
  65001. return scene.isCachedMaterialInvalid(this, effect, visibility);
  65002. };
  65003. return PushMaterial;
  65004. }(_Materials_material__WEBPACK_IMPORTED_MODULE_2__["Material"]));
  65005. /***/ }),
  65006. /***/ "./Materials/shaderMaterial.ts":
  65007. /*!*************************************!*\
  65008. !*** ./Materials/shaderMaterial.ts ***!
  65009. \*************************************/
  65010. /*! exports provided: ShaderMaterial */
  65011. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65012. "use strict";
  65013. __webpack_require__.r(__webpack_exports__);
  65014. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return ShaderMaterial; });
  65015. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65016. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65017. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65018. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65019. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65020. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65021. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65022. /* harmony import */ var _material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./material */ "./Materials/material.ts");
  65023. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65024. /**
  65025. * 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.
  65026. *
  65027. * This returned material effects how the mesh will look based on the code in the shaders.
  65028. *
  65029. * @see http://doc.babylonjs.com/how_to/shader_material
  65030. */
  65031. var ShaderMaterial = /** @class */ (function (_super) {
  65032. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShaderMaterial, _super);
  65033. /**
  65034. * Instantiate a new shader material.
  65035. * 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.
  65036. * This returned material effects how the mesh will look based on the code in the shaders.
  65037. * @see http://doc.babylonjs.com/how_to/shader_material
  65038. * @param name Define the name of the material in the scene
  65039. * @param scene Define the scene the material belongs to
  65040. * @param shaderPath Defines the route to the shader code in one of three ways:
  65041. * - object - { vertex: "custom", fragment: "custom" }, used with Effect.ShadersStore["customVertexShader"] and Effect.ShadersStore["customFragmentShader"]
  65042. * - object - { vertexElement: "vertexShaderCode", fragmentElement: "fragmentShaderCode" }, used with shader code in <script> tags
  65043. * - string - "./COMMON_NAME", used with external files COMMON_NAME.vertex.fx and COMMON_NAME.fragment.fx in index.html folder.
  65044. * @param options Define the options used to create the shader
  65045. */
  65046. function ShaderMaterial(name, scene, shaderPath, options) {
  65047. if (options === void 0) { options = {}; }
  65048. var _this = _super.call(this, name, scene) || this;
  65049. _this._textures = {};
  65050. _this._textureArrays = {};
  65051. _this._floats = {};
  65052. _this._ints = {};
  65053. _this._floatsArrays = {};
  65054. _this._colors3 = {};
  65055. _this._colors3Arrays = {};
  65056. _this._colors4 = {};
  65057. _this._vectors2 = {};
  65058. _this._vectors3 = {};
  65059. _this._vectors4 = {};
  65060. _this._matrices = {};
  65061. _this._matrices3x3 = {};
  65062. _this._matrices2x2 = {};
  65063. _this._vectors2Arrays = {};
  65064. _this._vectors3Arrays = {};
  65065. _this._cachedWorldViewMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"]();
  65066. _this._shaderPath = shaderPath;
  65067. _this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ needAlphaBlending: false, needAlphaTesting: false, attributes: ["position", "normal", "uv"], uniforms: ["worldViewProjection"], uniformBuffers: [], samplers: [], defines: [] }, options);
  65068. return _this;
  65069. }
  65070. /**
  65071. * Gets the current class name of the material e.g. "ShaderMaterial"
  65072. * Mainly use in serialization.
  65073. * @returns the class name
  65074. */
  65075. ShaderMaterial.prototype.getClassName = function () {
  65076. return "ShaderMaterial";
  65077. };
  65078. /**
  65079. * Specifies if the material will require alpha blending
  65080. * @returns a boolean specifying if alpha blending is needed
  65081. */
  65082. ShaderMaterial.prototype.needAlphaBlending = function () {
  65083. return (this.alpha < 1.0) || this._options.needAlphaBlending;
  65084. };
  65085. /**
  65086. * Specifies if this material should be rendered in alpha test mode
  65087. * @returns a boolean specifying if an alpha test is needed.
  65088. */
  65089. ShaderMaterial.prototype.needAlphaTesting = function () {
  65090. return this._options.needAlphaTesting;
  65091. };
  65092. ShaderMaterial.prototype._checkUniform = function (uniformName) {
  65093. if (this._options.uniforms.indexOf(uniformName) === -1) {
  65094. this._options.uniforms.push(uniformName);
  65095. }
  65096. };
  65097. /**
  65098. * Set a texture in the shader.
  65099. * @param name Define the name of the uniform samplers as defined in the shader
  65100. * @param texture Define the texture to bind to this sampler
  65101. * @return the material itself allowing "fluent" like uniform updates
  65102. */
  65103. ShaderMaterial.prototype.setTexture = function (name, texture) {
  65104. if (this._options.samplers.indexOf(name) === -1) {
  65105. this._options.samplers.push(name);
  65106. }
  65107. this._textures[name] = texture;
  65108. return this;
  65109. };
  65110. /**
  65111. * Set a texture array in the shader.
  65112. * @param name Define the name of the uniform sampler array as defined in the shader
  65113. * @param textures Define the list of textures to bind to this sampler
  65114. * @return the material itself allowing "fluent" like uniform updates
  65115. */
  65116. ShaderMaterial.prototype.setTextureArray = function (name, textures) {
  65117. if (this._options.samplers.indexOf(name) === -1) {
  65118. this._options.samplers.push(name);
  65119. }
  65120. this._checkUniform(name);
  65121. this._textureArrays[name] = textures;
  65122. return this;
  65123. };
  65124. /**
  65125. * Set a float in the shader.
  65126. * @param name Define the name of the uniform as defined in the shader
  65127. * @param value Define the value to give to the uniform
  65128. * @return the material itself allowing "fluent" like uniform updates
  65129. */
  65130. ShaderMaterial.prototype.setFloat = function (name, value) {
  65131. this._checkUniform(name);
  65132. this._floats[name] = value;
  65133. return this;
  65134. };
  65135. /**
  65136. * Set a int in the shader.
  65137. * @param name Define the name of the uniform as defined in the shader
  65138. * @param value Define the value to give to the uniform
  65139. * @return the material itself allowing "fluent" like uniform updates
  65140. */
  65141. ShaderMaterial.prototype.setInt = function (name, value) {
  65142. this._checkUniform(name);
  65143. this._ints[name] = value;
  65144. return this;
  65145. };
  65146. /**
  65147. * Set an array of floats in the shader.
  65148. * @param name Define the name of the uniform as defined in the shader
  65149. * @param value Define the value to give to the uniform
  65150. * @return the material itself allowing "fluent" like uniform updates
  65151. */
  65152. ShaderMaterial.prototype.setFloats = function (name, value) {
  65153. this._checkUniform(name);
  65154. this._floatsArrays[name] = value;
  65155. return this;
  65156. };
  65157. /**
  65158. * Set a vec3 in the shader from a Color3.
  65159. * @param name Define the name of the uniform as defined in the shader
  65160. * @param value Define the value to give to the uniform
  65161. * @return the material itself allowing "fluent" like uniform updates
  65162. */
  65163. ShaderMaterial.prototype.setColor3 = function (name, value) {
  65164. this._checkUniform(name);
  65165. this._colors3[name] = value;
  65166. return this;
  65167. };
  65168. /**
  65169. * Set a vec3 array in the shader from a Color3 array.
  65170. * @param name Define the name of the uniform as defined in the shader
  65171. * @param value Define the value to give to the uniform
  65172. * @return the material itself allowing "fluent" like uniform updates
  65173. */
  65174. ShaderMaterial.prototype.setColor3Array = function (name, value) {
  65175. this._checkUniform(name);
  65176. this._colors3Arrays[name] = value.reduce(function (arr, color) {
  65177. color.toArray(arr, arr.length);
  65178. return arr;
  65179. }, []);
  65180. return this;
  65181. };
  65182. /**
  65183. * Set a vec4 in the shader from a Color4.
  65184. * @param name Define the name of the uniform as defined in the shader
  65185. * @param value Define the value to give to the uniform
  65186. * @return the material itself allowing "fluent" like uniform updates
  65187. */
  65188. ShaderMaterial.prototype.setColor4 = function (name, value) {
  65189. this._checkUniform(name);
  65190. this._colors4[name] = value;
  65191. return this;
  65192. };
  65193. /**
  65194. * Set a vec2 in the shader from a Vector2.
  65195. * @param name Define the name of the uniform as defined in the shader
  65196. * @param value Define the value to give to the uniform
  65197. * @return the material itself allowing "fluent" like uniform updates
  65198. */
  65199. ShaderMaterial.prototype.setVector2 = function (name, value) {
  65200. this._checkUniform(name);
  65201. this._vectors2[name] = value;
  65202. return this;
  65203. };
  65204. /**
  65205. * Set a vec3 in the shader from a Vector3.
  65206. * @param name Define the name of the uniform as defined in the shader
  65207. * @param value Define the value to give to the uniform
  65208. * @return the material itself allowing "fluent" like uniform updates
  65209. */
  65210. ShaderMaterial.prototype.setVector3 = function (name, value) {
  65211. this._checkUniform(name);
  65212. this._vectors3[name] = value;
  65213. return this;
  65214. };
  65215. /**
  65216. * Set a vec4 in the shader from a Vector4.
  65217. * @param name Define the name of the uniform as defined in the shader
  65218. * @param value Define the value to give to the uniform
  65219. * @return the material itself allowing "fluent" like uniform updates
  65220. */
  65221. ShaderMaterial.prototype.setVector4 = function (name, value) {
  65222. this._checkUniform(name);
  65223. this._vectors4[name] = value;
  65224. return this;
  65225. };
  65226. /**
  65227. * Set a mat4 in the shader from a Matrix.
  65228. * @param name Define the name of the uniform as defined in the shader
  65229. * @param value Define the value to give to the uniform
  65230. * @return the material itself allowing "fluent" like uniform updates
  65231. */
  65232. ShaderMaterial.prototype.setMatrix = function (name, value) {
  65233. this._checkUniform(name);
  65234. this._matrices[name] = value;
  65235. return this;
  65236. };
  65237. /**
  65238. * Set a mat3 in the shader from a Float32Array.
  65239. * @param name Define the name of the uniform as defined in the shader
  65240. * @param value Define the value to give to the uniform
  65241. * @return the material itself allowing "fluent" like uniform updates
  65242. */
  65243. ShaderMaterial.prototype.setMatrix3x3 = function (name, value) {
  65244. this._checkUniform(name);
  65245. this._matrices3x3[name] = value;
  65246. return this;
  65247. };
  65248. /**
  65249. * Set a mat2 in the shader from a Float32Array.
  65250. * @param name Define the name of the uniform as defined in the shader
  65251. * @param value Define the value to give to the uniform
  65252. * @return the material itself allowing "fluent" like uniform updates
  65253. */
  65254. ShaderMaterial.prototype.setMatrix2x2 = function (name, value) {
  65255. this._checkUniform(name);
  65256. this._matrices2x2[name] = value;
  65257. return this;
  65258. };
  65259. /**
  65260. * Set a vec2 array in the shader from a number array.
  65261. * @param name Define the name of the uniform as defined in the shader
  65262. * @param value Define the value to give to the uniform
  65263. * @return the material itself allowing "fluent" like uniform updates
  65264. */
  65265. ShaderMaterial.prototype.setArray2 = function (name, value) {
  65266. this._checkUniform(name);
  65267. this._vectors2Arrays[name] = value;
  65268. return this;
  65269. };
  65270. /**
  65271. * Set a vec3 array in the shader from a number array.
  65272. * @param name Define the name of the uniform as defined in the shader
  65273. * @param value Define the value to give to the uniform
  65274. * @return the material itself allowing "fluent" like uniform updates
  65275. */
  65276. ShaderMaterial.prototype.setArray3 = function (name, value) {
  65277. this._checkUniform(name);
  65278. this._vectors3Arrays[name] = value;
  65279. return this;
  65280. };
  65281. ShaderMaterial.prototype._checkCache = function (mesh, useInstances) {
  65282. if (!mesh) {
  65283. return true;
  65284. }
  65285. if (this._effect && (this._effect.defines.indexOf("#define INSTANCES") !== -1) !== useInstances) {
  65286. return false;
  65287. }
  65288. return false;
  65289. };
  65290. /**
  65291. * Checks if the material is ready to render the requested mesh
  65292. * @param mesh Define the mesh to render
  65293. * @param useInstances Define whether or not the material is used with instances
  65294. * @returns true if ready, otherwise false
  65295. */
  65296. ShaderMaterial.prototype.isReady = function (mesh, useInstances) {
  65297. var scene = this.getScene();
  65298. var engine = scene.getEngine();
  65299. if (!this.checkReadyOnEveryCall) {
  65300. if (this._renderId === scene.getRenderId()) {
  65301. if (this._checkCache(mesh, useInstances)) {
  65302. return true;
  65303. }
  65304. }
  65305. }
  65306. // Instances
  65307. var defines = [];
  65308. var attribs = [];
  65309. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_6__["EffectFallbacks"]();
  65310. for (var index = 0; index < this._options.defines.length; index++) {
  65311. defines.push(this._options.defines[index]);
  65312. }
  65313. for (var index = 0; index < this._options.attributes.length; index++) {
  65314. attribs.push(this._options.attributes[index]);
  65315. }
  65316. if (mesh && mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind)) {
  65317. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].ColorKind);
  65318. defines.push("#define VERTEXCOLOR");
  65319. }
  65320. if (useInstances) {
  65321. defines.push("#define INSTANCES");
  65322. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  65323. }
  65324. // Bones
  65325. if (mesh && mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  65326. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesKind);
  65327. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsKind);
  65328. if (mesh.numBoneInfluencers > 4) {
  65329. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesIndicesExtraKind);
  65330. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].MatricesWeightsExtraKind);
  65331. }
  65332. var skeleton = mesh.skeleton;
  65333. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  65334. fallbacks.addCPUSkinningFallback(0, mesh);
  65335. if (skeleton.isUsingTextureForMatrices) {
  65336. defines.push("#define BONETEXTURE");
  65337. if (this._options.uniforms.indexOf("boneTextureWidth") === -1) {
  65338. this._options.uniforms.push("boneTextureWidth");
  65339. }
  65340. if (this._options.samplers.indexOf("boneSampler") === -1) {
  65341. this._options.samplers.push("boneSampler");
  65342. }
  65343. }
  65344. else {
  65345. defines.push("#define BonesPerMesh " + (skeleton.bones.length + 1));
  65346. if (this._options.uniforms.indexOf("mBones") === -1) {
  65347. this._options.uniforms.push("mBones");
  65348. }
  65349. }
  65350. }
  65351. else {
  65352. defines.push("#define NUM_BONE_INFLUENCERS 0");
  65353. }
  65354. // Textures
  65355. for (var name in this._textures) {
  65356. if (!this._textures[name].isReady()) {
  65357. return false;
  65358. }
  65359. }
  65360. // Alpha test
  65361. if (mesh && this._shouldTurnAlphaTestOn(mesh)) {
  65362. defines.push("#define ALPHATEST");
  65363. }
  65364. var previousEffect = this._effect;
  65365. var join = defines.join("\n");
  65366. this._effect = engine.createEffect(this._shaderPath, {
  65367. attributes: attribs,
  65368. uniformsNames: this._options.uniforms,
  65369. uniformBuffersNames: this._options.uniformBuffers,
  65370. samplers: this._options.samplers,
  65371. defines: join,
  65372. fallbacks: fallbacks,
  65373. onCompiled: this.onCompiled,
  65374. onError: this.onError
  65375. }, engine);
  65376. if (!this._effect.isReady()) {
  65377. return false;
  65378. }
  65379. if (previousEffect !== this._effect) {
  65380. scene.resetCachedMaterial();
  65381. }
  65382. this._renderId = scene.getRenderId();
  65383. return true;
  65384. };
  65385. /**
  65386. * Binds the world matrix to the material
  65387. * @param world defines the world transformation matrix
  65388. */
  65389. ShaderMaterial.prototype.bindOnlyWorldMatrix = function (world) {
  65390. var scene = this.getScene();
  65391. if (!this._effect) {
  65392. return;
  65393. }
  65394. if (this._options.uniforms.indexOf("world") !== -1) {
  65395. this._effect.setMatrix("world", world);
  65396. }
  65397. if (this._options.uniforms.indexOf("worldView") !== -1) {
  65398. world.multiplyToRef(scene.getViewMatrix(), this._cachedWorldViewMatrix);
  65399. this._effect.setMatrix("worldView", this._cachedWorldViewMatrix);
  65400. }
  65401. if (this._options.uniforms.indexOf("worldViewProjection") !== -1) {
  65402. this._effect.setMatrix("worldViewProjection", world.multiply(scene.getTransformMatrix()));
  65403. }
  65404. };
  65405. /**
  65406. * Binds the material to the mesh
  65407. * @param world defines the world transformation matrix
  65408. * @param mesh defines the mesh to bind the material to
  65409. */
  65410. ShaderMaterial.prototype.bind = function (world, mesh) {
  65411. // Std values
  65412. this.bindOnlyWorldMatrix(world);
  65413. if (this._effect && this.getScene().getCachedMaterial() !== this) {
  65414. if (this._options.uniforms.indexOf("view") !== -1) {
  65415. this._effect.setMatrix("view", this.getScene().getViewMatrix());
  65416. }
  65417. if (this._options.uniforms.indexOf("projection") !== -1) {
  65418. this._effect.setMatrix("projection", this.getScene().getProjectionMatrix());
  65419. }
  65420. if (this._options.uniforms.indexOf("viewProjection") !== -1) {
  65421. this._effect.setMatrix("viewProjection", this.getScene().getTransformMatrix());
  65422. }
  65423. // Bones
  65424. _materialHelper__WEBPACK_IMPORTED_MODULE_5__["MaterialHelper"].BindBonesParameters(mesh, this._effect);
  65425. var name;
  65426. // Texture
  65427. for (name in this._textures) {
  65428. this._effect.setTexture(name, this._textures[name]);
  65429. }
  65430. // Texture arrays
  65431. for (name in this._textureArrays) {
  65432. this._effect.setTextureArray(name, this._textureArrays[name]);
  65433. }
  65434. // Int
  65435. for (name in this._ints) {
  65436. this._effect.setInt(name, this._ints[name]);
  65437. }
  65438. // Float
  65439. for (name in this._floats) {
  65440. this._effect.setFloat(name, this._floats[name]);
  65441. }
  65442. // Floats
  65443. for (name in this._floatsArrays) {
  65444. this._effect.setArray(name, this._floatsArrays[name]);
  65445. }
  65446. // Color3
  65447. for (name in this._colors3) {
  65448. this._effect.setColor3(name, this._colors3[name]);
  65449. }
  65450. for (name in this._colors3Arrays) {
  65451. this._effect.setArray3(name, this._colors3Arrays[name]);
  65452. }
  65453. // Color4
  65454. for (name in this._colors4) {
  65455. var color = this._colors4[name];
  65456. this._effect.setFloat4(name, color.r, color.g, color.b, color.a);
  65457. }
  65458. // Vector2
  65459. for (name in this._vectors2) {
  65460. this._effect.setVector2(name, this._vectors2[name]);
  65461. }
  65462. // Vector3
  65463. for (name in this._vectors3) {
  65464. this._effect.setVector3(name, this._vectors3[name]);
  65465. }
  65466. // Vector4
  65467. for (name in this._vectors4) {
  65468. this._effect.setVector4(name, this._vectors4[name]);
  65469. }
  65470. // Matrix
  65471. for (name in this._matrices) {
  65472. this._effect.setMatrix(name, this._matrices[name]);
  65473. }
  65474. // Matrix 3x3
  65475. for (name in this._matrices3x3) {
  65476. this._effect.setMatrix3x3(name, this._matrices3x3[name]);
  65477. }
  65478. // Matrix 2x2
  65479. for (name in this._matrices2x2) {
  65480. this._effect.setMatrix2x2(name, this._matrices2x2[name]);
  65481. }
  65482. // Vector2Array
  65483. for (name in this._vectors2Arrays) {
  65484. this._effect.setArray2(name, this._vectors2Arrays[name]);
  65485. }
  65486. // Vector3Array
  65487. for (name in this._vectors3Arrays) {
  65488. this._effect.setArray3(name, this._vectors3Arrays[name]);
  65489. }
  65490. }
  65491. this._afterBind(mesh);
  65492. };
  65493. /**
  65494. * Gets the active textures from the material
  65495. * @returns an array of textures
  65496. */
  65497. ShaderMaterial.prototype.getActiveTextures = function () {
  65498. var activeTextures = _super.prototype.getActiveTextures.call(this);
  65499. for (var name in this._textures) {
  65500. activeTextures.push(this._textures[name]);
  65501. }
  65502. for (var name in this._textureArrays) {
  65503. var array = this._textureArrays[name];
  65504. for (var index = 0; index < array.length; index++) {
  65505. activeTextures.push(array[index]);
  65506. }
  65507. }
  65508. return activeTextures;
  65509. };
  65510. /**
  65511. * Specifies if the material uses a texture
  65512. * @param texture defines the texture to check against the material
  65513. * @returns a boolean specifying if the material uses the texture
  65514. */
  65515. ShaderMaterial.prototype.hasTexture = function (texture) {
  65516. if (_super.prototype.hasTexture.call(this, texture)) {
  65517. return true;
  65518. }
  65519. for (var name in this._textures) {
  65520. if (this._textures[name] === texture) {
  65521. return true;
  65522. }
  65523. }
  65524. for (var name in this._textureArrays) {
  65525. var array = this._textureArrays[name];
  65526. for (var index = 0; index < array.length; index++) {
  65527. if (array[index] === texture) {
  65528. return true;
  65529. }
  65530. }
  65531. }
  65532. return false;
  65533. };
  65534. /**
  65535. * Makes a duplicate of the material, and gives it a new name
  65536. * @param name defines the new name for the duplicated material
  65537. * @returns the cloned material
  65538. */
  65539. ShaderMaterial.prototype.clone = function (name) {
  65540. var newShaderMaterial = new ShaderMaterial(name, this.getScene(), this._shaderPath, this._options);
  65541. return newShaderMaterial;
  65542. };
  65543. /**
  65544. * Disposes the material
  65545. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  65546. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  65547. * @param notBoundToMesh specifies if the material that is being disposed is known to be not bound to any mesh
  65548. */
  65549. ShaderMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures, notBoundToMesh) {
  65550. if (forceDisposeTextures) {
  65551. var name;
  65552. for (name in this._textures) {
  65553. this._textures[name].dispose();
  65554. }
  65555. for (name in this._textureArrays) {
  65556. var array = this._textureArrays[name];
  65557. for (var index = 0; index < array.length; index++) {
  65558. array[index].dispose();
  65559. }
  65560. }
  65561. }
  65562. this._textures = {};
  65563. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures, notBoundToMesh);
  65564. };
  65565. /**
  65566. * Serializes this material in a JSON representation
  65567. * @returns the serialized material object
  65568. */
  65569. ShaderMaterial.prototype.serialize = function () {
  65570. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  65571. serializationObject.customType = "ShaderMaterial";
  65572. serializationObject.options = this._options;
  65573. serializationObject.shaderPath = this._shaderPath;
  65574. var name;
  65575. // Texture
  65576. serializationObject.textures = {};
  65577. for (name in this._textures) {
  65578. serializationObject.textures[name] = this._textures[name].serialize();
  65579. }
  65580. // Texture arrays
  65581. serializationObject.textureArrays = {};
  65582. for (name in this._textureArrays) {
  65583. serializationObject.textureArrays[name] = [];
  65584. var array = this._textureArrays[name];
  65585. for (var index = 0; index < array.length; index++) {
  65586. serializationObject.textureArrays[name].push(array[index].serialize());
  65587. }
  65588. }
  65589. // Float
  65590. serializationObject.floats = {};
  65591. for (name in this._floats) {
  65592. serializationObject.floats[name] = this._floats[name];
  65593. }
  65594. // Float s
  65595. serializationObject.FloatArrays = {};
  65596. for (name in this._floatsArrays) {
  65597. serializationObject.FloatArrays[name] = this._floatsArrays[name];
  65598. }
  65599. // Color3
  65600. serializationObject.colors3 = {};
  65601. for (name in this._colors3) {
  65602. serializationObject.colors3[name] = this._colors3[name].asArray();
  65603. }
  65604. // Color3 array
  65605. serializationObject.colors3Arrays = {};
  65606. for (name in this._colors3Arrays) {
  65607. serializationObject.colors3Arrays[name] = this._colors3Arrays[name];
  65608. }
  65609. // Color4
  65610. serializationObject.colors4 = {};
  65611. for (name in this._colors4) {
  65612. serializationObject.colors4[name] = this._colors4[name].asArray();
  65613. }
  65614. // Vector2
  65615. serializationObject.vectors2 = {};
  65616. for (name in this._vectors2) {
  65617. serializationObject.vectors2[name] = this._vectors2[name].asArray();
  65618. }
  65619. // Vector3
  65620. serializationObject.vectors3 = {};
  65621. for (name in this._vectors3) {
  65622. serializationObject.vectors3[name] = this._vectors3[name].asArray();
  65623. }
  65624. // Vector4
  65625. serializationObject.vectors4 = {};
  65626. for (name in this._vectors4) {
  65627. serializationObject.vectors4[name] = this._vectors4[name].asArray();
  65628. }
  65629. // Matrix
  65630. serializationObject.matrices = {};
  65631. for (name in this._matrices) {
  65632. serializationObject.matrices[name] = this._matrices[name].asArray();
  65633. }
  65634. // Matrix 3x3
  65635. serializationObject.matrices3x3 = {};
  65636. for (name in this._matrices3x3) {
  65637. serializationObject.matrices3x3[name] = this._matrices3x3[name];
  65638. }
  65639. // Matrix 2x2
  65640. serializationObject.matrices2x2 = {};
  65641. for (name in this._matrices2x2) {
  65642. serializationObject.matrices2x2[name] = this._matrices2x2[name];
  65643. }
  65644. // Vector2Array
  65645. serializationObject.vectors2Arrays = {};
  65646. for (name in this._vectors2Arrays) {
  65647. serializationObject.vectors2Arrays[name] = this._vectors2Arrays[name];
  65648. }
  65649. // Vector3Array
  65650. serializationObject.vectors3Arrays = {};
  65651. for (name in this._vectors3Arrays) {
  65652. serializationObject.vectors3Arrays[name] = this._vectors3Arrays[name];
  65653. }
  65654. return serializationObject;
  65655. };
  65656. /**
  65657. * Creates a shader material from parsed shader material data
  65658. * @param source defines the JSON represnetation of the material
  65659. * @param scene defines the hosting scene
  65660. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  65661. * @returns a new material
  65662. */
  65663. ShaderMaterial.Parse = function (source, scene, rootUrl) {
  65664. var material = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new ShaderMaterial(source.name, scene, source.shaderPath, source.options); }, source, scene, rootUrl);
  65665. var name;
  65666. // Texture
  65667. for (name in source.textures) {
  65668. material.setTexture(name, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(source.textures[name], scene, rootUrl));
  65669. }
  65670. // Texture arrays
  65671. for (name in source.textureArrays) {
  65672. var array = source.textureArrays[name];
  65673. var textureArray = new Array();
  65674. for (var index = 0; index < array.length; index++) {
  65675. textureArray.push(_Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].Parse(array[index], scene, rootUrl));
  65676. }
  65677. material.setTextureArray(name, textureArray);
  65678. }
  65679. // Float
  65680. for (name in source.floats) {
  65681. material.setFloat(name, source.floats[name]);
  65682. }
  65683. // Float s
  65684. for (name in source.floatsArrays) {
  65685. material.setFloats(name, source.floatsArrays[name]);
  65686. }
  65687. // Color3
  65688. for (name in source.colors3) {
  65689. material.setColor3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(source.colors3[name]));
  65690. }
  65691. // Color3 arrays
  65692. for (name in source.colors3Arrays) {
  65693. var colors = source.colors3Arrays[name].reduce(function (arr, num, i) {
  65694. if (i % 3 === 0) {
  65695. arr.push([num]);
  65696. }
  65697. else {
  65698. arr[arr.length - 1].push(num);
  65699. }
  65700. return arr;
  65701. }, []).map(function (color) { return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color3"].FromArray(color); });
  65702. material.setColor3Array(name, colors);
  65703. }
  65704. // Color4
  65705. for (name in source.colors4) {
  65706. material.setColor4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Color4"].FromArray(source.colors4[name]));
  65707. }
  65708. // Vector2
  65709. for (name in source.vectors2) {
  65710. material.setVector2(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"].FromArray(source.vectors2[name]));
  65711. }
  65712. // Vector3
  65713. for (name in source.vectors3) {
  65714. material.setVector3(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].FromArray(source.vectors3[name]));
  65715. }
  65716. // Vector4
  65717. for (name in source.vectors4) {
  65718. material.setVector4(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector4"].FromArray(source.vectors4[name]));
  65719. }
  65720. // Matrix
  65721. for (name in source.matrices) {
  65722. material.setMatrix(name, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Matrix"].FromArray(source.matrices[name]));
  65723. }
  65724. // Matrix 3x3
  65725. for (name in source.matrices3x3) {
  65726. material.setMatrix3x3(name, source.matrices3x3[name]);
  65727. }
  65728. // Matrix 2x2
  65729. for (name in source.matrices2x2) {
  65730. material.setMatrix2x2(name, source.matrices2x2[name]);
  65731. }
  65732. // Vector2Array
  65733. for (name in source.vectors2Arrays) {
  65734. material.setArray2(name, source.vectors2Arrays[name]);
  65735. }
  65736. // Vector3Array
  65737. for (name in source.vectors3Arrays) {
  65738. material.setArray3(name, source.vectors3Arrays[name]);
  65739. }
  65740. return material;
  65741. };
  65742. return ShaderMaterial;
  65743. }(_material__WEBPACK_IMPORTED_MODULE_7__["Material"]));
  65744. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].RegisteredTypes["BABYLON.ShaderMaterial"] = ShaderMaterial;
  65745. /***/ }),
  65746. /***/ "./Materials/standardMaterial.ts":
  65747. /*!***************************************!*\
  65748. !*** ./Materials/standardMaterial.ts ***!
  65749. \***************************************/
  65750. /*! exports provided: StandardMaterialDefines, StandardMaterial */
  65751. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  65752. "use strict";
  65753. __webpack_require__.r(__webpack_exports__);
  65754. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return StandardMaterialDefines; });
  65755. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return StandardMaterial; });
  65756. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  65757. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  65758. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  65759. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  65760. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  65761. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  65762. /* harmony import */ var _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  65763. /* harmony import */ var _effect__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./effect */ "./Materials/effect.ts");
  65764. /* harmony import */ var _Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialDefines */ "./Materials/materialDefines.ts");
  65765. /* harmony import */ var _pushMaterial__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./pushMaterial */ "./Materials/pushMaterial.ts");
  65766. /* harmony import */ var _materialHelper__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./materialHelper */ "./Materials/materialHelper.ts");
  65767. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  65768. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  65769. /* harmony import */ var _materialFlags__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./materialFlags */ "./Materials/materialFlags.ts");
  65770. /* harmony import */ var _Shaders_default_fragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/default.fragment */ "./Shaders/default.fragment.ts");
  65771. /* harmony import */ var _Shaders_default_vertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/default.vertex */ "./Shaders/default.vertex.ts");
  65772. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  65773. /** @hidden */
  65774. var StandardMaterialDefines = /** @class */ (function (_super) {
  65775. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterialDefines, _super);
  65776. function StandardMaterialDefines() {
  65777. var _this = _super.call(this) || this;
  65778. _this.MAINUV1 = false;
  65779. _this.MAINUV2 = false;
  65780. _this.DIFFUSE = false;
  65781. _this.DIFFUSEDIRECTUV = 0;
  65782. _this.AMBIENT = false;
  65783. _this.AMBIENTDIRECTUV = 0;
  65784. _this.OPACITY = false;
  65785. _this.OPACITYDIRECTUV = 0;
  65786. _this.OPACITYRGB = false;
  65787. _this.REFLECTION = false;
  65788. _this.EMISSIVE = false;
  65789. _this.EMISSIVEDIRECTUV = 0;
  65790. _this.SPECULAR = false;
  65791. _this.SPECULARDIRECTUV = 0;
  65792. _this.BUMP = false;
  65793. _this.BUMPDIRECTUV = 0;
  65794. _this.PARALLAX = false;
  65795. _this.PARALLAXOCCLUSION = false;
  65796. _this.SPECULAROVERALPHA = false;
  65797. _this.CLIPPLANE = false;
  65798. _this.CLIPPLANE2 = false;
  65799. _this.CLIPPLANE3 = false;
  65800. _this.CLIPPLANE4 = false;
  65801. _this.ALPHATEST = false;
  65802. _this.DEPTHPREPASS = false;
  65803. _this.ALPHAFROMDIFFUSE = false;
  65804. _this.POINTSIZE = false;
  65805. _this.FOG = false;
  65806. _this.SPECULARTERM = false;
  65807. _this.DIFFUSEFRESNEL = false;
  65808. _this.OPACITYFRESNEL = false;
  65809. _this.REFLECTIONFRESNEL = false;
  65810. _this.REFRACTIONFRESNEL = false;
  65811. _this.EMISSIVEFRESNEL = false;
  65812. _this.FRESNEL = false;
  65813. _this.NORMAL = false;
  65814. _this.UV1 = false;
  65815. _this.UV2 = false;
  65816. _this.VERTEXCOLOR = false;
  65817. _this.VERTEXALPHA = false;
  65818. _this.NUM_BONE_INFLUENCERS = 0;
  65819. _this.BonesPerMesh = 0;
  65820. _this.BONETEXTURE = false;
  65821. _this.INSTANCES = false;
  65822. _this.GLOSSINESS = false;
  65823. _this.ROUGHNESS = false;
  65824. _this.EMISSIVEASILLUMINATION = false;
  65825. _this.LINKEMISSIVEWITHDIFFUSE = false;
  65826. _this.REFLECTIONFRESNELFROMSPECULAR = false;
  65827. _this.LIGHTMAP = false;
  65828. _this.LIGHTMAPDIRECTUV = 0;
  65829. _this.OBJECTSPACE_NORMALMAP = false;
  65830. _this.USELIGHTMAPASSHADOWMAP = false;
  65831. _this.REFLECTIONMAP_3D = false;
  65832. _this.REFLECTIONMAP_SPHERICAL = false;
  65833. _this.REFLECTIONMAP_PLANAR = false;
  65834. _this.REFLECTIONMAP_CUBIC = false;
  65835. _this.USE_LOCAL_REFLECTIONMAP_CUBIC = false;
  65836. _this.REFLECTIONMAP_PROJECTION = false;
  65837. _this.REFLECTIONMAP_SKYBOX = false;
  65838. _this.REFLECTIONMAP_SKYBOX_TRANSFORMED = false;
  65839. _this.REFLECTIONMAP_EXPLICIT = false;
  65840. _this.REFLECTIONMAP_EQUIRECTANGULAR = false;
  65841. _this.REFLECTIONMAP_EQUIRECTANGULAR_FIXED = false;
  65842. _this.REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED = false;
  65843. _this.INVERTCUBICMAP = false;
  65844. _this.LOGARITHMICDEPTH = false;
  65845. _this.REFRACTION = false;
  65846. _this.REFRACTIONMAP_3D = false;
  65847. _this.REFLECTIONOVERALPHA = false;
  65848. _this.TWOSIDEDLIGHTING = false;
  65849. _this.SHADOWFLOAT = false;
  65850. _this.MORPHTARGETS = false;
  65851. _this.MORPHTARGETS_NORMAL = false;
  65852. _this.MORPHTARGETS_TANGENT = false;
  65853. _this.NUM_MORPH_INFLUENCERS = 0;
  65854. _this.NONUNIFORMSCALING = false; // https://playground.babylonjs.com#V6DWIH
  65855. _this.PREMULTIPLYALPHA = false; // https://playground.babylonjs.com#LNVJJ7
  65856. _this.IMAGEPROCESSING = false;
  65857. _this.VIGNETTE = false;
  65858. _this.VIGNETTEBLENDMODEMULTIPLY = false;
  65859. _this.VIGNETTEBLENDMODEOPAQUE = false;
  65860. _this.TONEMAPPING = false;
  65861. _this.TONEMAPPING_ACES = false;
  65862. _this.CONTRAST = false;
  65863. _this.COLORCURVES = false;
  65864. _this.COLORGRADING = false;
  65865. _this.COLORGRADING3D = false;
  65866. _this.SAMPLER3DGREENDEPTH = false;
  65867. _this.SAMPLER3DBGRMAP = false;
  65868. _this.IMAGEPROCESSINGPOSTPROCESS = false;
  65869. /**
  65870. * If the reflection texture on this material is in linear color space
  65871. * @hidden
  65872. */
  65873. _this.IS_REFLECTION_LINEAR = false;
  65874. /**
  65875. * If the refraction texture on this material is in linear color space
  65876. * @hidden
  65877. */
  65878. _this.IS_REFRACTION_LINEAR = false;
  65879. _this.EXPOSURE = false;
  65880. _this.rebuild();
  65881. return _this;
  65882. }
  65883. StandardMaterialDefines.prototype.setReflectionMode = function (modeToEnable) {
  65884. var modes = [
  65885. "REFLECTIONMAP_CUBIC", "REFLECTIONMAP_EXPLICIT", "REFLECTIONMAP_PLANAR",
  65886. "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_PROJECTION", "REFLECTIONMAP_SKYBOX",
  65887. "REFLECTIONMAP_SPHERICAL", "REFLECTIONMAP_EQUIRECTANGULAR", "REFLECTIONMAP_EQUIRECTANGULAR_FIXED",
  65888. "REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED"
  65889. ];
  65890. for (var _i = 0, modes_1 = modes; _i < modes_1.length; _i++) {
  65891. var mode = modes_1[_i];
  65892. this[mode] = (mode === modeToEnable);
  65893. }
  65894. };
  65895. return StandardMaterialDefines;
  65896. }(_Materials_materialDefines__WEBPACK_IMPORTED_MODULE_8__["MaterialDefines"]));
  65897. /**
  65898. * This is the default material used in Babylon. It is the best trade off between quality
  65899. * and performances.
  65900. * @see http://doc.babylonjs.com/babylon101/materials
  65901. */
  65902. var StandardMaterial = /** @class */ (function (_super) {
  65903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardMaterial, _super);
  65904. /**
  65905. * Instantiates a new standard material.
  65906. * This is the default material used in Babylon. It is the best trade off between quality
  65907. * and performances.
  65908. * @see http://doc.babylonjs.com/babylon101/materials
  65909. * @param name Define the name of the material in the scene
  65910. * @param scene Define the scene the material belong to
  65911. */
  65912. function StandardMaterial(name, scene) {
  65913. var _this = _super.call(this, name, scene) || this;
  65914. /**
  65915. * The color of the material lit by the environmental background lighting.
  65916. * @see http://doc.babylonjs.com/babylon101/materials#ambient-color-example
  65917. */
  65918. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65919. /**
  65920. * The basic color of the material as viewed under a light.
  65921. */
  65922. _this.diffuseColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65923. /**
  65924. * Define how the color and intensity of the highlight given by the light in the material.
  65925. */
  65926. _this.specularColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  65927. /**
  65928. * Define the color of the material as if self lit.
  65929. * This will be mixed in the final result even in the absence of light.
  65930. */
  65931. _this.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65932. /**
  65933. * Defines how sharp are the highlights in the material.
  65934. * The bigger the value the sharper giving a more glossy feeling to the result.
  65935. * Reversely, the smaller the value the blurrier giving a more rough feeling to the result.
  65936. */
  65937. _this.specularPower = 64;
  65938. _this._useAlphaFromDiffuseTexture = false;
  65939. _this._useEmissiveAsIllumination = false;
  65940. _this._linkEmissiveWithDiffuse = false;
  65941. _this._useSpecularOverAlpha = false;
  65942. _this._useReflectionOverAlpha = false;
  65943. _this._disableLighting = false;
  65944. _this._useObjectSpaceNormalMap = false;
  65945. _this._useParallax = false;
  65946. _this._useParallaxOcclusion = false;
  65947. /**
  65948. * 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.
  65949. */
  65950. _this.parallaxScaleBias = 0.05;
  65951. _this._roughness = 0;
  65952. /**
  65953. * In case of refraction, define the value of the indice of refraction.
  65954. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65955. */
  65956. _this.indexOfRefraction = 0.98;
  65957. /**
  65958. * Invert the refraction texture alongside the y axis.
  65959. * It can be useful with procedural textures or probe for instance.
  65960. * @see http://doc.babylonjs.com/how_to/reflect#how-to-obtain-reflections-and-refractions
  65961. */
  65962. _this.invertRefractionY = true;
  65963. /**
  65964. * Defines the alpha limits in alpha test mode.
  65965. */
  65966. _this.alphaCutOff = 0.4;
  65967. _this._useLightmapAsShadowmap = false;
  65968. _this._useReflectionFresnelFromSpecular = false;
  65969. _this._useGlossinessFromSpecularMapAlpha = false;
  65970. _this._maxSimultaneousLights = 4;
  65971. _this._invertNormalMapX = false;
  65972. _this._invertNormalMapY = false;
  65973. _this._twoSidedLighting = false;
  65974. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_2__["SmartArray"](16);
  65975. _this._worldViewProjectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Zero();
  65976. _this._globalAmbientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0, 0, 0);
  65977. // Setup the default processing configuration to the scene.
  65978. _this._attachImageProcessingConfiguration(null);
  65979. _this.getRenderTargetTextures = function () {
  65980. _this._renderTargets.reset();
  65981. if (StandardMaterial.ReflectionTextureEnabled && _this._reflectionTexture && _this._reflectionTexture.isRenderTarget) {
  65982. _this._renderTargets.push(_this._reflectionTexture);
  65983. }
  65984. if (StandardMaterial.RefractionTextureEnabled && _this._refractionTexture && _this._refractionTexture.isRenderTarget) {
  65985. _this._renderTargets.push(_this._refractionTexture);
  65986. }
  65987. return _this._renderTargets;
  65988. };
  65989. return _this;
  65990. }
  65991. Object.defineProperty(StandardMaterial.prototype, "imageProcessingConfiguration", {
  65992. /**
  65993. * Gets the image processing configuration used either in this material.
  65994. */
  65995. get: function () {
  65996. return this._imageProcessingConfiguration;
  65997. },
  65998. /**
  65999. * Sets the Default image processing configuration used either in the this material.
  66000. *
  66001. * If sets to null, the scene one is in use.
  66002. */
  66003. set: function (value) {
  66004. this._attachImageProcessingConfiguration(value);
  66005. // Ensure the effect will be rebuilt.
  66006. this._markAllSubMeshesAsTexturesDirty();
  66007. },
  66008. enumerable: true,
  66009. configurable: true
  66010. });
  66011. /**
  66012. * Attaches a new image processing configuration to the Standard Material.
  66013. * @param configuration
  66014. */
  66015. StandardMaterial.prototype._attachImageProcessingConfiguration = function (configuration) {
  66016. var _this = this;
  66017. if (configuration === this._imageProcessingConfiguration) {
  66018. return;
  66019. }
  66020. // Detaches observer.
  66021. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66022. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66023. }
  66024. // Pick the scene configuration if needed.
  66025. if (!configuration) {
  66026. this._imageProcessingConfiguration = this.getScene().imageProcessingConfiguration;
  66027. }
  66028. else {
  66029. this._imageProcessingConfiguration = configuration;
  66030. }
  66031. // Attaches observer.
  66032. if (this._imageProcessingConfiguration) {
  66033. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  66034. _this._markAllSubMeshesAsImageProcessingDirty();
  66035. });
  66036. }
  66037. };
  66038. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurvesEnabled", {
  66039. /**
  66040. * Gets wether the color curves effect is enabled.
  66041. */
  66042. get: function () {
  66043. return this.imageProcessingConfiguration.colorCurvesEnabled;
  66044. },
  66045. /**
  66046. * Sets wether the color curves effect is enabled.
  66047. */
  66048. set: function (value) {
  66049. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  66050. },
  66051. enumerable: true,
  66052. configurable: true
  66053. });
  66054. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingEnabled", {
  66055. /**
  66056. * Gets wether the color grading effect is enabled.
  66057. */
  66058. get: function () {
  66059. return this.imageProcessingConfiguration.colorGradingEnabled;
  66060. },
  66061. /**
  66062. * Gets wether the color grading effect is enabled.
  66063. */
  66064. set: function (value) {
  66065. this.imageProcessingConfiguration.colorGradingEnabled = value;
  66066. },
  66067. enumerable: true,
  66068. configurable: true
  66069. });
  66070. Object.defineProperty(StandardMaterial.prototype, "cameraToneMappingEnabled", {
  66071. /**
  66072. * Gets wether tonemapping is enabled or not.
  66073. */
  66074. get: function () {
  66075. return this._imageProcessingConfiguration.toneMappingEnabled;
  66076. },
  66077. /**
  66078. * Sets wether tonemapping is enabled or not
  66079. */
  66080. set: function (value) {
  66081. this._imageProcessingConfiguration.toneMappingEnabled = value;
  66082. },
  66083. enumerable: true,
  66084. configurable: true
  66085. });
  66086. Object.defineProperty(StandardMaterial.prototype, "cameraExposure", {
  66087. /**
  66088. * The camera exposure used on this material.
  66089. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  66090. * This corresponds to a photographic exposure.
  66091. */
  66092. get: function () {
  66093. return this._imageProcessingConfiguration.exposure;
  66094. },
  66095. /**
  66096. * The camera exposure used on this material.
  66097. * This property is here and not in the camera to allow controlling exposure without full screen post process.
  66098. * This corresponds to a photographic exposure.
  66099. */
  66100. set: function (value) {
  66101. this._imageProcessingConfiguration.exposure = value;
  66102. },
  66103. enumerable: true,
  66104. configurable: true
  66105. });
  66106. Object.defineProperty(StandardMaterial.prototype, "cameraContrast", {
  66107. /**
  66108. * Gets The camera contrast used on this material.
  66109. */
  66110. get: function () {
  66111. return this._imageProcessingConfiguration.contrast;
  66112. },
  66113. /**
  66114. * Sets The camera contrast used on this material.
  66115. */
  66116. set: function (value) {
  66117. this._imageProcessingConfiguration.contrast = value;
  66118. },
  66119. enumerable: true,
  66120. configurable: true
  66121. });
  66122. Object.defineProperty(StandardMaterial.prototype, "cameraColorGradingTexture", {
  66123. /**
  66124. * Gets the Color Grading 2D Lookup Texture.
  66125. */
  66126. get: function () {
  66127. return this._imageProcessingConfiguration.colorGradingTexture;
  66128. },
  66129. /**
  66130. * Sets the Color Grading 2D Lookup Texture.
  66131. */
  66132. set: function (value) {
  66133. this._imageProcessingConfiguration.colorGradingTexture = value;
  66134. },
  66135. enumerable: true,
  66136. configurable: true
  66137. });
  66138. Object.defineProperty(StandardMaterial.prototype, "cameraColorCurves", {
  66139. /**
  66140. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  66141. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  66142. * 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;
  66143. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  66144. */
  66145. get: function () {
  66146. return this._imageProcessingConfiguration.colorCurves;
  66147. },
  66148. /**
  66149. * The color grading curves provide additional color adjustmnent that is applied after any color grading transform (3D LUT).
  66150. * They allow basic adjustment of saturation and small exposure adjustments, along with color filter tinting to provide white balance adjustment or more stylistic effects.
  66151. * 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;
  66152. * corresponding to low luminance, medium luminance, and high luminance areas respectively.
  66153. */
  66154. set: function (value) {
  66155. this._imageProcessingConfiguration.colorCurves = value;
  66156. },
  66157. enumerable: true,
  66158. configurable: true
  66159. });
  66160. Object.defineProperty(StandardMaterial.prototype, "hasRenderTargetTextures", {
  66161. /**
  66162. * Gets a boolean indicating that current material needs to register RTT
  66163. */
  66164. get: function () {
  66165. if (StandardMaterial.ReflectionTextureEnabled && this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66166. return true;
  66167. }
  66168. if (StandardMaterial.RefractionTextureEnabled && this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66169. return true;
  66170. }
  66171. return false;
  66172. },
  66173. enumerable: true,
  66174. configurable: true
  66175. });
  66176. /**
  66177. * Gets the current class name of the material e.g. "StandardMaterial"
  66178. * Mainly use in serialization.
  66179. * @returns the class name
  66180. */
  66181. StandardMaterial.prototype.getClassName = function () {
  66182. return "StandardMaterial";
  66183. };
  66184. Object.defineProperty(StandardMaterial.prototype, "useLogarithmicDepth", {
  66185. /**
  66186. * In case the depth buffer does not allow enough depth precision for your scene (might be the case in large scenes)
  66187. * You can try switching to logarithmic depth.
  66188. * @see http://doc.babylonjs.com/how_to/using_logarithmic_depth_buffer
  66189. */
  66190. get: function () {
  66191. return this._useLogarithmicDepth;
  66192. },
  66193. set: function (value) {
  66194. this._useLogarithmicDepth = value && this.getScene().getEngine().getCaps().fragmentDepthSupported;
  66195. this._markAllSubMeshesAsMiscDirty();
  66196. },
  66197. enumerable: true,
  66198. configurable: true
  66199. });
  66200. /**
  66201. * Specifies if the material will require alpha blending
  66202. * @returns a boolean specifying if alpha blending is needed
  66203. */
  66204. StandardMaterial.prototype.needAlphaBlending = function () {
  66205. return (this.alpha < 1.0) || (this._opacityTexture != null) || this._shouldUseAlphaFromDiffuseTexture() || this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled;
  66206. };
  66207. /**
  66208. * Specifies if this material should be rendered in alpha test mode
  66209. * @returns a boolean specifying if an alpha test is needed.
  66210. */
  66211. StandardMaterial.prototype.needAlphaTesting = function () {
  66212. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha;
  66213. };
  66214. StandardMaterial.prototype._shouldUseAlphaFromDiffuseTexture = function () {
  66215. return this._diffuseTexture != null && this._diffuseTexture.hasAlpha && this._useAlphaFromDiffuseTexture;
  66216. };
  66217. /**
  66218. * Get the texture used for alpha test purpose.
  66219. * @returns the diffuse texture in case of the standard material.
  66220. */
  66221. StandardMaterial.prototype.getAlphaTestTexture = function () {
  66222. return this._diffuseTexture;
  66223. };
  66224. /**
  66225. * Get if the submesh is ready to be used and all its information available.
  66226. * Child classes can use it to update shaders
  66227. * @param mesh defines the mesh to check
  66228. * @param subMesh defines which submesh to check
  66229. * @param useInstances specifies that instances should be used
  66230. * @returns a boolean indicating that the submesh is ready or not
  66231. */
  66232. StandardMaterial.prototype.isReadyForSubMesh = function (mesh, subMesh, useInstances) {
  66233. if (useInstances === void 0) { useInstances = false; }
  66234. if (subMesh.effect && this.isFrozen) {
  66235. if (this._wasPreviouslyReady) {
  66236. return true;
  66237. }
  66238. }
  66239. if (!subMesh._materialDefines) {
  66240. subMesh._materialDefines = new StandardMaterialDefines();
  66241. }
  66242. var scene = this.getScene();
  66243. var defines = subMesh._materialDefines;
  66244. if (!this.checkReadyOnEveryCall && subMesh.effect) {
  66245. if (defines._renderId === scene.getRenderId()) {
  66246. return true;
  66247. }
  66248. }
  66249. var engine = scene.getEngine();
  66250. // Lights
  66251. defines._needNormals = _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForLights(scene, mesh, defines, true, this._maxSimultaneousLights, this._disableLighting);
  66252. // Textures
  66253. if (defines._areTexturesDirty) {
  66254. defines._needUVs = false;
  66255. defines.MAINUV1 = false;
  66256. defines.MAINUV2 = false;
  66257. if (scene.texturesEnabled) {
  66258. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66259. if (!this._diffuseTexture.isReadyOrNotBlocking()) {
  66260. return false;
  66261. }
  66262. else {
  66263. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._diffuseTexture, defines, "DIFFUSE");
  66264. }
  66265. }
  66266. else {
  66267. defines.DIFFUSE = false;
  66268. }
  66269. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66270. if (!this._ambientTexture.isReadyOrNotBlocking()) {
  66271. return false;
  66272. }
  66273. else {
  66274. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._ambientTexture, defines, "AMBIENT");
  66275. }
  66276. }
  66277. else {
  66278. defines.AMBIENT = false;
  66279. }
  66280. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66281. if (!this._opacityTexture.isReadyOrNotBlocking()) {
  66282. return false;
  66283. }
  66284. else {
  66285. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._opacityTexture, defines, "OPACITY");
  66286. defines.OPACITYRGB = this._opacityTexture.getAlphaFromRGB;
  66287. }
  66288. }
  66289. else {
  66290. defines.OPACITY = false;
  66291. }
  66292. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66293. if (!this._reflectionTexture.isReadyOrNotBlocking()) {
  66294. return false;
  66295. }
  66296. else {
  66297. defines._needNormals = true;
  66298. defines.REFLECTION = true;
  66299. defines.ROUGHNESS = (this._roughness > 0);
  66300. defines.REFLECTIONOVERALPHA = this._useReflectionOverAlpha;
  66301. defines.INVERTCUBICMAP = (this._reflectionTexture.coordinatesMode === _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE);
  66302. defines.REFLECTIONMAP_3D = this._reflectionTexture.isCube;
  66303. switch (this._reflectionTexture.coordinatesMode) {
  66304. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EXPLICIT_MODE:
  66305. defines.setReflectionMode("REFLECTIONMAP_EXPLICIT");
  66306. break;
  66307. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PLANAR_MODE:
  66308. defines.setReflectionMode("REFLECTIONMAP_PLANAR");
  66309. break;
  66310. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].PROJECTION_MODE:
  66311. defines.setReflectionMode("REFLECTIONMAP_PROJECTION");
  66312. break;
  66313. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SKYBOX_MODE:
  66314. defines.setReflectionMode("REFLECTIONMAP_SKYBOX");
  66315. defines.REFLECTIONMAP_SKYBOX_TRANSFORMED = !this._reflectionTexture.getReflectionTextureMatrix().isIdentity();
  66316. break;
  66317. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].SPHERICAL_MODE:
  66318. defines.setReflectionMode("REFLECTIONMAP_SPHERICAL");
  66319. break;
  66320. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].EQUIRECTANGULAR_MODE:
  66321. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR");
  66322. break;
  66323. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MODE:
  66324. defines.setReflectionMode("REFLECTIONMAP_EQUIRECTANGULAR_FIXED");
  66325. break;
  66326. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].FIXED_EQUIRECTANGULAR_MIRRORED_MODE:
  66327. defines.setReflectionMode("REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED");
  66328. break;
  66329. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].CUBIC_MODE:
  66330. case _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_11__["Texture"].INVCUBIC_MODE:
  66331. default:
  66332. defines.setReflectionMode("REFLECTIONMAP_CUBIC");
  66333. break;
  66334. }
  66335. defines.USE_LOCAL_REFLECTIONMAP_CUBIC = this._reflectionTexture.boundingBoxSize ? true : false;
  66336. }
  66337. }
  66338. else {
  66339. defines.REFLECTION = false;
  66340. }
  66341. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66342. if (!this._emissiveTexture.isReadyOrNotBlocking()) {
  66343. return false;
  66344. }
  66345. else {
  66346. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._emissiveTexture, defines, "EMISSIVE");
  66347. }
  66348. }
  66349. else {
  66350. defines.EMISSIVE = false;
  66351. }
  66352. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66353. if (!this._lightmapTexture.isReadyOrNotBlocking()) {
  66354. return false;
  66355. }
  66356. else {
  66357. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._lightmapTexture, defines, "LIGHTMAP");
  66358. defines.USELIGHTMAPASSHADOWMAP = this._useLightmapAsShadowmap;
  66359. }
  66360. }
  66361. else {
  66362. defines.LIGHTMAP = false;
  66363. }
  66364. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66365. if (!this._specularTexture.isReadyOrNotBlocking()) {
  66366. return false;
  66367. }
  66368. else {
  66369. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._specularTexture, defines, "SPECULAR");
  66370. defines.GLOSSINESS = this._useGlossinessFromSpecularMapAlpha;
  66371. }
  66372. }
  66373. else {
  66374. defines.SPECULAR = false;
  66375. }
  66376. if (scene.getEngine().getCaps().standardDerivatives && this._bumpTexture && StandardMaterial.BumpTextureEnabled) {
  66377. // Bump texure can not be not blocking.
  66378. if (!this._bumpTexture.isReady()) {
  66379. return false;
  66380. }
  66381. else {
  66382. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMergedUV(this._bumpTexture, defines, "BUMP");
  66383. defines.PARALLAX = this._useParallax;
  66384. defines.PARALLAXOCCLUSION = this._useParallaxOcclusion;
  66385. }
  66386. defines.OBJECTSPACE_NORMALMAP = this._useObjectSpaceNormalMap;
  66387. }
  66388. else {
  66389. defines.BUMP = false;
  66390. }
  66391. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66392. if (!this._refractionTexture.isReadyOrNotBlocking()) {
  66393. return false;
  66394. }
  66395. else {
  66396. defines._needUVs = true;
  66397. defines.REFRACTION = true;
  66398. defines.REFRACTIONMAP_3D = this._refractionTexture.isCube;
  66399. }
  66400. }
  66401. else {
  66402. defines.REFRACTION = false;
  66403. }
  66404. defines.TWOSIDEDLIGHTING = !this._backFaceCulling && this._twoSidedLighting;
  66405. }
  66406. else {
  66407. defines.DIFFUSE = false;
  66408. defines.AMBIENT = false;
  66409. defines.OPACITY = false;
  66410. defines.REFLECTION = false;
  66411. defines.EMISSIVE = false;
  66412. defines.LIGHTMAP = false;
  66413. defines.BUMP = false;
  66414. defines.REFRACTION = false;
  66415. }
  66416. defines.ALPHAFROMDIFFUSE = this._shouldUseAlphaFromDiffuseTexture();
  66417. defines.EMISSIVEASILLUMINATION = this._useEmissiveAsIllumination;
  66418. defines.LINKEMISSIVEWITHDIFFUSE = this._linkEmissiveWithDiffuse;
  66419. defines.SPECULAROVERALPHA = this._useSpecularOverAlpha;
  66420. 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);
  66421. }
  66422. if (defines._areImageProcessingDirty && this._imageProcessingConfiguration) {
  66423. if (!this._imageProcessingConfiguration.isReady()) {
  66424. return false;
  66425. }
  66426. this._imageProcessingConfiguration.prepareDefines(defines);
  66427. defines.IS_REFLECTION_LINEAR = (this.reflectionTexture != null && !this.reflectionTexture.gammaSpace);
  66428. defines.IS_REFRACTION_LINEAR = (this.refractionTexture != null && !this.refractionTexture.gammaSpace);
  66429. }
  66430. if (defines._areFresnelDirty) {
  66431. if (StandardMaterial.FresnelEnabled) {
  66432. // Fresnel
  66433. if (this._diffuseFresnelParameters || this._opacityFresnelParameters ||
  66434. this._emissiveFresnelParameters || this._refractionFresnelParameters ||
  66435. this._reflectionFresnelParameters) {
  66436. defines.DIFFUSEFRESNEL = (this._diffuseFresnelParameters && this._diffuseFresnelParameters.isEnabled);
  66437. defines.OPACITYFRESNEL = (this._opacityFresnelParameters && this._opacityFresnelParameters.isEnabled);
  66438. defines.REFLECTIONFRESNEL = (this._reflectionFresnelParameters && this._reflectionFresnelParameters.isEnabled);
  66439. defines.REFLECTIONFRESNELFROMSPECULAR = this._useReflectionFresnelFromSpecular;
  66440. defines.REFRACTIONFRESNEL = (this._refractionFresnelParameters && this._refractionFresnelParameters.isEnabled);
  66441. defines.EMISSIVEFRESNEL = (this._emissiveFresnelParameters && this._emissiveFresnelParameters.isEnabled);
  66442. defines._needNormals = true;
  66443. defines.FRESNEL = true;
  66444. }
  66445. }
  66446. else {
  66447. defines.FRESNEL = false;
  66448. }
  66449. }
  66450. // Misc.
  66451. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForMisc(mesh, scene, this._useLogarithmicDepth, this.pointsCloud, this.fogEnabled, this._shouldTurnAlphaTestOn(mesh), defines);
  66452. // Attribs
  66453. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForAttributes(mesh, defines, true, true, true);
  66454. // Values that need to be evaluated on every frame
  66455. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareDefinesForFrameBoundValues(scene, engine, defines, useInstances);
  66456. // Get correct effect
  66457. if (defines.isDirty) {
  66458. defines.markAsProcessed();
  66459. // Fallbacks
  66460. var fallbacks = new _effect__WEBPACK_IMPORTED_MODULE_7__["EffectFallbacks"]();
  66461. if (defines.REFLECTION) {
  66462. fallbacks.addFallback(0, "REFLECTION");
  66463. }
  66464. if (defines.SPECULAR) {
  66465. fallbacks.addFallback(0, "SPECULAR");
  66466. }
  66467. if (defines.BUMP) {
  66468. fallbacks.addFallback(0, "BUMP");
  66469. }
  66470. if (defines.PARALLAX) {
  66471. fallbacks.addFallback(1, "PARALLAX");
  66472. }
  66473. if (defines.PARALLAXOCCLUSION) {
  66474. fallbacks.addFallback(0, "PARALLAXOCCLUSION");
  66475. }
  66476. if (defines.SPECULAROVERALPHA) {
  66477. fallbacks.addFallback(0, "SPECULAROVERALPHA");
  66478. }
  66479. if (defines.FOG) {
  66480. fallbacks.addFallback(1, "FOG");
  66481. }
  66482. if (defines.POINTSIZE) {
  66483. fallbacks.addFallback(0, "POINTSIZE");
  66484. }
  66485. if (defines.LOGARITHMICDEPTH) {
  66486. fallbacks.addFallback(0, "LOGARITHMICDEPTH");
  66487. }
  66488. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].HandleFallbacksForShadows(defines, fallbacks, this._maxSimultaneousLights);
  66489. if (defines.SPECULARTERM) {
  66490. fallbacks.addFallback(0, "SPECULARTERM");
  66491. }
  66492. if (defines.DIFFUSEFRESNEL) {
  66493. fallbacks.addFallback(1, "DIFFUSEFRESNEL");
  66494. }
  66495. if (defines.OPACITYFRESNEL) {
  66496. fallbacks.addFallback(2, "OPACITYFRESNEL");
  66497. }
  66498. if (defines.REFLECTIONFRESNEL) {
  66499. fallbacks.addFallback(3, "REFLECTIONFRESNEL");
  66500. }
  66501. if (defines.EMISSIVEFRESNEL) {
  66502. fallbacks.addFallback(4, "EMISSIVEFRESNEL");
  66503. }
  66504. if (defines.FRESNEL) {
  66505. fallbacks.addFallback(4, "FRESNEL");
  66506. }
  66507. //Attributes
  66508. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind];
  66509. if (defines.NORMAL) {
  66510. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  66511. }
  66512. if (defines.UV1) {
  66513. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UVKind);
  66514. }
  66515. if (defines.UV2) {
  66516. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].UV2Kind);
  66517. }
  66518. if (defines.VERTEXCOLOR) {
  66519. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind);
  66520. }
  66521. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForBones(attribs, mesh, defines, fallbacks);
  66522. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForInstances(attribs, defines);
  66523. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareAttributesForMorphTargets(attribs, mesh, defines);
  66524. var shaderName = "default";
  66525. var uniforms = ["world", "view", "viewProjection", "vEyePosition", "vLightsType", "vAmbientColor", "vDiffuseColor", "vSpecularColor", "vEmissiveColor",
  66526. "vFogInfos", "vFogColor", "pointSize",
  66527. "vDiffuseInfos", "vAmbientInfos", "vOpacityInfos", "vReflectionInfos", "vEmissiveInfos", "vSpecularInfos", "vBumpInfos", "vLightmapInfos", "vRefractionInfos",
  66528. "mBones",
  66529. "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "diffuseMatrix", "ambientMatrix", "opacityMatrix", "reflectionMatrix", "emissiveMatrix", "specularMatrix", "bumpMatrix", "normalMatrix", "lightmapMatrix", "refractionMatrix",
  66530. "diffuseLeftColor", "diffuseRightColor", "opacityParts", "reflectionLeftColor", "reflectionRightColor", "emissiveLeftColor", "emissiveRightColor", "refractionLeftColor", "refractionRightColor",
  66531. "vReflectionPosition", "vReflectionSize",
  66532. "logarithmicDepthConstant", "vTangentSpaceParams", "alphaCutOff", "boneTextureWidth"
  66533. ];
  66534. var samplers = ["diffuseSampler", "ambientSampler", "opacitySampler", "reflectionCubeSampler",
  66535. "reflection2DSampler", "emissiveSampler", "specularSampler", "bumpSampler", "lightmapSampler",
  66536. "refractionCubeSampler", "refraction2DSampler", "boneSampler"];
  66537. var uniformBuffers = ["Material", "Scene"];
  66538. if (_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"]) {
  66539. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, defines);
  66540. _imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_6__["ImageProcessingConfiguration"].PrepareSamplers(samplers, defines);
  66541. }
  66542. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].PrepareUniformsAndSamplersList({
  66543. uniformsNames: uniforms,
  66544. uniformBuffersNames: uniformBuffers,
  66545. samplers: samplers,
  66546. defines: defines,
  66547. maxSimultaneousLights: this._maxSimultaneousLights
  66548. });
  66549. if (this.customShaderNameResolve) {
  66550. shaderName = this.customShaderNameResolve(shaderName, uniforms, uniformBuffers, samplers, defines);
  66551. }
  66552. var join = defines.toString();
  66553. var previousEffect = subMesh.effect;
  66554. var effect = scene.getEngine().createEffect(shaderName, {
  66555. attributes: attribs,
  66556. uniformsNames: uniforms,
  66557. uniformBuffersNames: uniformBuffers,
  66558. samplers: samplers,
  66559. defines: join,
  66560. fallbacks: fallbacks,
  66561. onCompiled: this.onCompiled,
  66562. onError: this.onError,
  66563. indexParameters: { maxSimultaneousLights: this._maxSimultaneousLights, maxSimultaneousMorphTargets: defines.NUM_MORPH_INFLUENCERS }
  66564. }, engine);
  66565. if (effect) {
  66566. // Use previous effect while new one is compiling
  66567. if (this.allowShaderHotSwapping && previousEffect && !effect.isReady()) {
  66568. effect = previousEffect;
  66569. defines.markAsUnprocessed();
  66570. }
  66571. else {
  66572. scene.resetCachedMaterial();
  66573. subMesh.setEffect(effect, defines);
  66574. this.buildUniformLayout();
  66575. }
  66576. }
  66577. }
  66578. if (!subMesh.effect || !subMesh.effect.isReady()) {
  66579. return false;
  66580. }
  66581. defines._renderId = scene.getRenderId();
  66582. this._wasPreviouslyReady = true;
  66583. return true;
  66584. };
  66585. /**
  66586. * Builds the material UBO layouts.
  66587. * Used internally during the effect preparation.
  66588. */
  66589. StandardMaterial.prototype.buildUniformLayout = function () {
  66590. // Order is important !
  66591. this._uniformBuffer.addUniform("diffuseLeftColor", 4);
  66592. this._uniformBuffer.addUniform("diffuseRightColor", 4);
  66593. this._uniformBuffer.addUniform("opacityParts", 4);
  66594. this._uniformBuffer.addUniform("reflectionLeftColor", 4);
  66595. this._uniformBuffer.addUniform("reflectionRightColor", 4);
  66596. this._uniformBuffer.addUniform("refractionLeftColor", 4);
  66597. this._uniformBuffer.addUniform("refractionRightColor", 4);
  66598. this._uniformBuffer.addUniform("emissiveLeftColor", 4);
  66599. this._uniformBuffer.addUniform("emissiveRightColor", 4);
  66600. this._uniformBuffer.addUniform("vDiffuseInfos", 2);
  66601. this._uniformBuffer.addUniform("vAmbientInfos", 2);
  66602. this._uniformBuffer.addUniform("vOpacityInfos", 2);
  66603. this._uniformBuffer.addUniform("vReflectionInfos", 2);
  66604. this._uniformBuffer.addUniform("vReflectionPosition", 3);
  66605. this._uniformBuffer.addUniform("vReflectionSize", 3);
  66606. this._uniformBuffer.addUniform("vEmissiveInfos", 2);
  66607. this._uniformBuffer.addUniform("vLightmapInfos", 2);
  66608. this._uniformBuffer.addUniform("vSpecularInfos", 2);
  66609. this._uniformBuffer.addUniform("vBumpInfos", 3);
  66610. this._uniformBuffer.addUniform("diffuseMatrix", 16);
  66611. this._uniformBuffer.addUniform("ambientMatrix", 16);
  66612. this._uniformBuffer.addUniform("opacityMatrix", 16);
  66613. this._uniformBuffer.addUniform("reflectionMatrix", 16);
  66614. this._uniformBuffer.addUniform("emissiveMatrix", 16);
  66615. this._uniformBuffer.addUniform("lightmapMatrix", 16);
  66616. this._uniformBuffer.addUniform("specularMatrix", 16);
  66617. this._uniformBuffer.addUniform("bumpMatrix", 16);
  66618. this._uniformBuffer.addUniform("vTangentSpaceParams", 2);
  66619. this._uniformBuffer.addUniform("refractionMatrix", 16);
  66620. this._uniformBuffer.addUniform("vRefractionInfos", 4);
  66621. this._uniformBuffer.addUniform("vSpecularColor", 4);
  66622. this._uniformBuffer.addUniform("vEmissiveColor", 3);
  66623. this._uniformBuffer.addUniform("vDiffuseColor", 4);
  66624. this._uniformBuffer.addUniform("pointSize", 1);
  66625. this._uniformBuffer.create();
  66626. };
  66627. /**
  66628. * Unbinds the material from the mesh
  66629. */
  66630. StandardMaterial.prototype.unbind = function () {
  66631. if (this._activeEffect) {
  66632. var needFlag = false;
  66633. if (this._reflectionTexture && this._reflectionTexture.isRenderTarget) {
  66634. this._activeEffect.setTexture("reflection2DSampler", null);
  66635. needFlag = true;
  66636. }
  66637. if (this._refractionTexture && this._refractionTexture.isRenderTarget) {
  66638. this._activeEffect.setTexture("refraction2DSampler", null);
  66639. needFlag = true;
  66640. }
  66641. if (needFlag) {
  66642. this._markAllSubMeshesAsTexturesDirty();
  66643. }
  66644. }
  66645. _super.prototype.unbind.call(this);
  66646. };
  66647. /**
  66648. * Binds the submesh to this material by preparing the effect and shader to draw
  66649. * @param world defines the world transformation matrix
  66650. * @param mesh defines the mesh containing the submesh
  66651. * @param subMesh defines the submesh to bind the material to
  66652. */
  66653. StandardMaterial.prototype.bindForSubMesh = function (world, mesh, subMesh) {
  66654. var scene = this.getScene();
  66655. var defines = subMesh._materialDefines;
  66656. if (!defines) {
  66657. return;
  66658. }
  66659. var effect = subMesh.effect;
  66660. if (!effect) {
  66661. return;
  66662. }
  66663. this._activeEffect = effect;
  66664. // Matrices
  66665. this.bindOnlyWorldMatrix(world);
  66666. // Normal Matrix
  66667. if (defines.OBJECTSPACE_NORMALMAP) {
  66668. world.toNormalMatrix(this._normalMatrix);
  66669. this.bindOnlyNormalMatrix(this._normalMatrix);
  66670. }
  66671. var mustRebind = this._mustRebind(scene, effect, mesh.visibility);
  66672. // Bones
  66673. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindBonesParameters(mesh, effect);
  66674. if (mustRebind) {
  66675. this._uniformBuffer.bindToEffect(effect, "Material");
  66676. this.bindViewProjection(effect);
  66677. if (!this._uniformBuffer.useUbo || !this.isFrozen || !this._uniformBuffer.isSync) {
  66678. if (StandardMaterial.FresnelEnabled && defines.FRESNEL) {
  66679. // Fresnel
  66680. if (this.diffuseFresnelParameters && this.diffuseFresnelParameters.isEnabled) {
  66681. this._uniformBuffer.updateColor4("diffuseLeftColor", this.diffuseFresnelParameters.leftColor, this.diffuseFresnelParameters.power);
  66682. this._uniformBuffer.updateColor4("diffuseRightColor", this.diffuseFresnelParameters.rightColor, this.diffuseFresnelParameters.bias);
  66683. }
  66684. if (this.opacityFresnelParameters && this.opacityFresnelParameters.isEnabled) {
  66685. 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);
  66686. }
  66687. if (this.reflectionFresnelParameters && this.reflectionFresnelParameters.isEnabled) {
  66688. this._uniformBuffer.updateColor4("reflectionLeftColor", this.reflectionFresnelParameters.leftColor, this.reflectionFresnelParameters.power);
  66689. this._uniformBuffer.updateColor4("reflectionRightColor", this.reflectionFresnelParameters.rightColor, this.reflectionFresnelParameters.bias);
  66690. }
  66691. if (this.refractionFresnelParameters && this.refractionFresnelParameters.isEnabled) {
  66692. this._uniformBuffer.updateColor4("refractionLeftColor", this.refractionFresnelParameters.leftColor, this.refractionFresnelParameters.power);
  66693. this._uniformBuffer.updateColor4("refractionRightColor", this.refractionFresnelParameters.rightColor, this.refractionFresnelParameters.bias);
  66694. }
  66695. if (this.emissiveFresnelParameters && this.emissiveFresnelParameters.isEnabled) {
  66696. this._uniformBuffer.updateColor4("emissiveLeftColor", this.emissiveFresnelParameters.leftColor, this.emissiveFresnelParameters.power);
  66697. this._uniformBuffer.updateColor4("emissiveRightColor", this.emissiveFresnelParameters.rightColor, this.emissiveFresnelParameters.bias);
  66698. }
  66699. }
  66700. // Textures
  66701. if (scene.texturesEnabled) {
  66702. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66703. this._uniformBuffer.updateFloat2("vDiffuseInfos", this._diffuseTexture.coordinatesIndex, this._diffuseTexture.level);
  66704. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._diffuseTexture, this._uniformBuffer, "diffuse");
  66705. if (this._diffuseTexture.hasAlpha) {
  66706. effect.setFloat("alphaCutOff", this.alphaCutOff);
  66707. }
  66708. }
  66709. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66710. this._uniformBuffer.updateFloat2("vAmbientInfos", this._ambientTexture.coordinatesIndex, this._ambientTexture.level);
  66711. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._ambientTexture, this._uniformBuffer, "ambient");
  66712. }
  66713. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66714. this._uniformBuffer.updateFloat2("vOpacityInfos", this._opacityTexture.coordinatesIndex, this._opacityTexture.level);
  66715. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._opacityTexture, this._uniformBuffer, "opacity");
  66716. }
  66717. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66718. this._uniformBuffer.updateFloat2("vReflectionInfos", this._reflectionTexture.level, this.roughness);
  66719. this._uniformBuffer.updateMatrix("reflectionMatrix", this._reflectionTexture.getReflectionTextureMatrix());
  66720. if (this._reflectionTexture.boundingBoxSize) {
  66721. var cubeTexture = this._reflectionTexture;
  66722. this._uniformBuffer.updateVector3("vReflectionPosition", cubeTexture.boundingBoxPosition);
  66723. this._uniformBuffer.updateVector3("vReflectionSize", cubeTexture.boundingBoxSize);
  66724. }
  66725. }
  66726. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66727. this._uniformBuffer.updateFloat2("vEmissiveInfos", this._emissiveTexture.coordinatesIndex, this._emissiveTexture.level);
  66728. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._emissiveTexture, this._uniformBuffer, "emissive");
  66729. }
  66730. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66731. this._uniformBuffer.updateFloat2("vLightmapInfos", this._lightmapTexture.coordinatesIndex, this._lightmapTexture.level);
  66732. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._lightmapTexture, this._uniformBuffer, "lightmap");
  66733. }
  66734. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66735. this._uniformBuffer.updateFloat2("vSpecularInfos", this._specularTexture.coordinatesIndex, this._specularTexture.level);
  66736. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._specularTexture, this._uniformBuffer, "specular");
  66737. }
  66738. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66739. this._uniformBuffer.updateFloat3("vBumpInfos", this._bumpTexture.coordinatesIndex, 1.0 / this._bumpTexture.level, this.parallaxScaleBias);
  66740. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindTextureMatrix(this._bumpTexture, this._uniformBuffer, "bump");
  66741. if (scene._mirroredCameraPosition) {
  66742. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? 1.0 : -1.0, this._invertNormalMapY ? 1.0 : -1.0);
  66743. }
  66744. else {
  66745. this._uniformBuffer.updateFloat2("vTangentSpaceParams", this._invertNormalMapX ? -1.0 : 1.0, this._invertNormalMapY ? -1.0 : 1.0);
  66746. }
  66747. }
  66748. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66749. var depth = 1.0;
  66750. if (!this._refractionTexture.isCube) {
  66751. this._uniformBuffer.updateMatrix("refractionMatrix", this._refractionTexture.getReflectionTextureMatrix());
  66752. if (this._refractionTexture.depth) {
  66753. depth = this._refractionTexture.depth;
  66754. }
  66755. }
  66756. this._uniformBuffer.updateFloat4("vRefractionInfos", this._refractionTexture.level, this.indexOfRefraction, depth, this.invertRefractionY ? -1 : 1);
  66757. }
  66758. }
  66759. // Point size
  66760. if (this.pointsCloud) {
  66761. this._uniformBuffer.updateFloat("pointSize", this.pointSize);
  66762. }
  66763. if (defines.SPECULARTERM) {
  66764. this._uniformBuffer.updateColor4("vSpecularColor", this.specularColor, this.specularPower);
  66765. }
  66766. this._uniformBuffer.updateColor3("vEmissiveColor", StandardMaterial.EmissiveTextureEnabled ? this.emissiveColor : _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"].BlackReadOnly);
  66767. // Diffuse
  66768. this._uniformBuffer.updateColor4("vDiffuseColor", this.diffuseColor, this.alpha * mesh.visibility);
  66769. }
  66770. // Textures
  66771. if (scene.texturesEnabled) {
  66772. if (this._diffuseTexture && StandardMaterial.DiffuseTextureEnabled) {
  66773. effect.setTexture("diffuseSampler", this._diffuseTexture);
  66774. }
  66775. if (this._ambientTexture && StandardMaterial.AmbientTextureEnabled) {
  66776. effect.setTexture("ambientSampler", this._ambientTexture);
  66777. }
  66778. if (this._opacityTexture && StandardMaterial.OpacityTextureEnabled) {
  66779. effect.setTexture("opacitySampler", this._opacityTexture);
  66780. }
  66781. if (this._reflectionTexture && StandardMaterial.ReflectionTextureEnabled) {
  66782. if (this._reflectionTexture.isCube) {
  66783. effect.setTexture("reflectionCubeSampler", this._reflectionTexture);
  66784. }
  66785. else {
  66786. effect.setTexture("reflection2DSampler", this._reflectionTexture);
  66787. }
  66788. }
  66789. if (this._emissiveTexture && StandardMaterial.EmissiveTextureEnabled) {
  66790. effect.setTexture("emissiveSampler", this._emissiveTexture);
  66791. }
  66792. if (this._lightmapTexture && StandardMaterial.LightmapTextureEnabled) {
  66793. effect.setTexture("lightmapSampler", this._lightmapTexture);
  66794. }
  66795. if (this._specularTexture && StandardMaterial.SpecularTextureEnabled) {
  66796. effect.setTexture("specularSampler", this._specularTexture);
  66797. }
  66798. if (this._bumpTexture && scene.getEngine().getCaps().standardDerivatives && StandardMaterial.BumpTextureEnabled) {
  66799. effect.setTexture("bumpSampler", this._bumpTexture);
  66800. }
  66801. if (this._refractionTexture && StandardMaterial.RefractionTextureEnabled) {
  66802. var depth = 1.0;
  66803. if (this._refractionTexture.isCube) {
  66804. effect.setTexture("refractionCubeSampler", this._refractionTexture);
  66805. }
  66806. else {
  66807. effect.setTexture("refraction2DSampler", this._refractionTexture);
  66808. }
  66809. }
  66810. }
  66811. // Clip plane
  66812. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindClipPlane(effect, scene);
  66813. // Colors
  66814. scene.ambientColor.multiplyToRef(this.ambientColor, this._globalAmbientColor);
  66815. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindEyePosition(effect, scene);
  66816. effect.setColor3("vAmbientColor", this._globalAmbientColor);
  66817. }
  66818. if (mustRebind || !this.isFrozen) {
  66819. // Lights
  66820. if (scene.lightsEnabled && !this._disableLighting) {
  66821. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLights(scene, mesh, effect, defines, this._maxSimultaneousLights);
  66822. }
  66823. // View
  66824. if (scene.fogEnabled && mesh.applyFog && scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].FOGMODE_NONE || this._reflectionTexture || this._refractionTexture) {
  66825. this.bindView(effect);
  66826. }
  66827. // Fog
  66828. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindFogParameters(scene, mesh, effect);
  66829. // Morph targets
  66830. if (defines.NUM_MORPH_INFLUENCERS) {
  66831. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindMorphTargetParameters(mesh, effect);
  66832. }
  66833. // Log. depth
  66834. _materialHelper__WEBPACK_IMPORTED_MODULE_10__["MaterialHelper"].BindLogDepth(defines, effect, scene);
  66835. // image processing
  66836. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  66837. this._imageProcessingConfiguration.bind(this._activeEffect);
  66838. }
  66839. }
  66840. this._uniformBuffer.update();
  66841. this._afterBind(mesh, this._activeEffect);
  66842. };
  66843. /**
  66844. * Get the list of animatables in the material.
  66845. * @returns the list of animatables object used in the material
  66846. */
  66847. StandardMaterial.prototype.getAnimatables = function () {
  66848. var results = [];
  66849. if (this._diffuseTexture && this._diffuseTexture.animations && this._diffuseTexture.animations.length > 0) {
  66850. results.push(this._diffuseTexture);
  66851. }
  66852. if (this._ambientTexture && this._ambientTexture.animations && this._ambientTexture.animations.length > 0) {
  66853. results.push(this._ambientTexture);
  66854. }
  66855. if (this._opacityTexture && this._opacityTexture.animations && this._opacityTexture.animations.length > 0) {
  66856. results.push(this._opacityTexture);
  66857. }
  66858. if (this._reflectionTexture && this._reflectionTexture.animations && this._reflectionTexture.animations.length > 0) {
  66859. results.push(this._reflectionTexture);
  66860. }
  66861. if (this._emissiveTexture && this._emissiveTexture.animations && this._emissiveTexture.animations.length > 0) {
  66862. results.push(this._emissiveTexture);
  66863. }
  66864. if (this._specularTexture && this._specularTexture.animations && this._specularTexture.animations.length > 0) {
  66865. results.push(this._specularTexture);
  66866. }
  66867. if (this._bumpTexture && this._bumpTexture.animations && this._bumpTexture.animations.length > 0) {
  66868. results.push(this._bumpTexture);
  66869. }
  66870. if (this._lightmapTexture && this._lightmapTexture.animations && this._lightmapTexture.animations.length > 0) {
  66871. results.push(this._lightmapTexture);
  66872. }
  66873. if (this._refractionTexture && this._refractionTexture.animations && this._refractionTexture.animations.length > 0) {
  66874. results.push(this._refractionTexture);
  66875. }
  66876. return results;
  66877. };
  66878. /**
  66879. * Gets the active textures from the material
  66880. * @returns an array of textures
  66881. */
  66882. StandardMaterial.prototype.getActiveTextures = function () {
  66883. var activeTextures = _super.prototype.getActiveTextures.call(this);
  66884. if (this._diffuseTexture) {
  66885. activeTextures.push(this._diffuseTexture);
  66886. }
  66887. if (this._ambientTexture) {
  66888. activeTextures.push(this._ambientTexture);
  66889. }
  66890. if (this._opacityTexture) {
  66891. activeTextures.push(this._opacityTexture);
  66892. }
  66893. if (this._reflectionTexture) {
  66894. activeTextures.push(this._reflectionTexture);
  66895. }
  66896. if (this._emissiveTexture) {
  66897. activeTextures.push(this._emissiveTexture);
  66898. }
  66899. if (this._specularTexture) {
  66900. activeTextures.push(this._specularTexture);
  66901. }
  66902. if (this._bumpTexture) {
  66903. activeTextures.push(this._bumpTexture);
  66904. }
  66905. if (this._lightmapTexture) {
  66906. activeTextures.push(this._lightmapTexture);
  66907. }
  66908. if (this._refractionTexture) {
  66909. activeTextures.push(this._refractionTexture);
  66910. }
  66911. return activeTextures;
  66912. };
  66913. /**
  66914. * Specifies if the material uses a texture
  66915. * @param texture defines the texture to check against the material
  66916. * @returns a boolean specifying if the material uses the texture
  66917. */
  66918. StandardMaterial.prototype.hasTexture = function (texture) {
  66919. if (_super.prototype.hasTexture.call(this, texture)) {
  66920. return true;
  66921. }
  66922. if (this._diffuseTexture === texture) {
  66923. return true;
  66924. }
  66925. if (this._ambientTexture === texture) {
  66926. return true;
  66927. }
  66928. if (this._opacityTexture === texture) {
  66929. return true;
  66930. }
  66931. if (this._reflectionTexture === texture) {
  66932. return true;
  66933. }
  66934. if (this._emissiveTexture === texture) {
  66935. return true;
  66936. }
  66937. if (this._specularTexture === texture) {
  66938. return true;
  66939. }
  66940. if (this._bumpTexture === texture) {
  66941. return true;
  66942. }
  66943. if (this._lightmapTexture === texture) {
  66944. return true;
  66945. }
  66946. if (this._refractionTexture === texture) {
  66947. return true;
  66948. }
  66949. return false;
  66950. };
  66951. /**
  66952. * Disposes the material
  66953. * @param forceDisposeEffect specifies if effects should be forcefully disposed
  66954. * @param forceDisposeTextures specifies if textures should be forcefully disposed
  66955. */
  66956. StandardMaterial.prototype.dispose = function (forceDisposeEffect, forceDisposeTextures) {
  66957. if (forceDisposeTextures) {
  66958. if (this._diffuseTexture) {
  66959. this._diffuseTexture.dispose();
  66960. }
  66961. if (this._ambientTexture) {
  66962. this._ambientTexture.dispose();
  66963. }
  66964. if (this._opacityTexture) {
  66965. this._opacityTexture.dispose();
  66966. }
  66967. if (this._reflectionTexture) {
  66968. this._reflectionTexture.dispose();
  66969. }
  66970. if (this._emissiveTexture) {
  66971. this._emissiveTexture.dispose();
  66972. }
  66973. if (this._specularTexture) {
  66974. this._specularTexture.dispose();
  66975. }
  66976. if (this._bumpTexture) {
  66977. this._bumpTexture.dispose();
  66978. }
  66979. if (this._lightmapTexture) {
  66980. this._lightmapTexture.dispose();
  66981. }
  66982. if (this._refractionTexture) {
  66983. this._refractionTexture.dispose();
  66984. }
  66985. }
  66986. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  66987. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  66988. }
  66989. _super.prototype.dispose.call(this, forceDisposeEffect, forceDisposeTextures);
  66990. };
  66991. /**
  66992. * Makes a duplicate of the material, and gives it a new name
  66993. * @param name defines the new name for the duplicated material
  66994. * @returns the cloned material
  66995. */
  66996. StandardMaterial.prototype.clone = function (name) {
  66997. var _this = this;
  66998. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new StandardMaterial(name, _this.getScene()); }, this);
  66999. result.name = name;
  67000. result.id = name;
  67001. return result;
  67002. };
  67003. /**
  67004. * Serializes this material in a JSON representation
  67005. * @returns the serialized material object
  67006. */
  67007. StandardMaterial.prototype.serialize = function () {
  67008. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  67009. };
  67010. /**
  67011. * Creates a standard material from parsed material data
  67012. * @param source defines the JSON representation of the material
  67013. * @param scene defines the hosting scene
  67014. * @param rootUrl defines the root URL to use to load textures and relative dependencies
  67015. * @returns a new standard material
  67016. */
  67017. StandardMaterial.Parse = function (source, scene, rootUrl) {
  67018. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardMaterial(source.name, scene); }, source, scene, rootUrl);
  67019. };
  67020. Object.defineProperty(StandardMaterial, "DiffuseTextureEnabled", {
  67021. // Flags used to enable or disable a type of texture for all Standard Materials
  67022. /**
  67023. * Are diffuse textures enabled in the application.
  67024. */
  67025. get: function () {
  67026. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled;
  67027. },
  67028. set: function (value) {
  67029. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].DiffuseTextureEnabled = value;
  67030. },
  67031. enumerable: true,
  67032. configurable: true
  67033. });
  67034. Object.defineProperty(StandardMaterial, "AmbientTextureEnabled", {
  67035. /**
  67036. * Are ambient textures enabled in the application.
  67037. */
  67038. get: function () {
  67039. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled;
  67040. },
  67041. set: function (value) {
  67042. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].AmbientTextureEnabled = value;
  67043. },
  67044. enumerable: true,
  67045. configurable: true
  67046. });
  67047. Object.defineProperty(StandardMaterial, "OpacityTextureEnabled", {
  67048. /**
  67049. * Are opacity textures enabled in the application.
  67050. */
  67051. get: function () {
  67052. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled;
  67053. },
  67054. set: function (value) {
  67055. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].OpacityTextureEnabled = value;
  67056. },
  67057. enumerable: true,
  67058. configurable: true
  67059. });
  67060. Object.defineProperty(StandardMaterial, "ReflectionTextureEnabled", {
  67061. /**
  67062. * Are reflection textures enabled in the application.
  67063. */
  67064. get: function () {
  67065. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled;
  67066. },
  67067. set: function (value) {
  67068. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ReflectionTextureEnabled = value;
  67069. },
  67070. enumerable: true,
  67071. configurable: true
  67072. });
  67073. Object.defineProperty(StandardMaterial, "EmissiveTextureEnabled", {
  67074. /**
  67075. * Are emissive textures enabled in the application.
  67076. */
  67077. get: function () {
  67078. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled;
  67079. },
  67080. set: function (value) {
  67081. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].EmissiveTextureEnabled = value;
  67082. },
  67083. enumerable: true,
  67084. configurable: true
  67085. });
  67086. Object.defineProperty(StandardMaterial, "SpecularTextureEnabled", {
  67087. /**
  67088. * Are specular textures enabled in the application.
  67089. */
  67090. get: function () {
  67091. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled;
  67092. },
  67093. set: function (value) {
  67094. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].SpecularTextureEnabled = value;
  67095. },
  67096. enumerable: true,
  67097. configurable: true
  67098. });
  67099. Object.defineProperty(StandardMaterial, "BumpTextureEnabled", {
  67100. /**
  67101. * Are bump textures enabled in the application.
  67102. */
  67103. get: function () {
  67104. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled;
  67105. },
  67106. set: function (value) {
  67107. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].BumpTextureEnabled = value;
  67108. },
  67109. enumerable: true,
  67110. configurable: true
  67111. });
  67112. Object.defineProperty(StandardMaterial, "LightmapTextureEnabled", {
  67113. /**
  67114. * Are lightmap textures enabled in the application.
  67115. */
  67116. get: function () {
  67117. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled;
  67118. },
  67119. set: function (value) {
  67120. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].LightmapTextureEnabled = value;
  67121. },
  67122. enumerable: true,
  67123. configurable: true
  67124. });
  67125. Object.defineProperty(StandardMaterial, "RefractionTextureEnabled", {
  67126. /**
  67127. * Are refraction textures enabled in the application.
  67128. */
  67129. get: function () {
  67130. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled;
  67131. },
  67132. set: function (value) {
  67133. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].RefractionTextureEnabled = value;
  67134. },
  67135. enumerable: true,
  67136. configurable: true
  67137. });
  67138. Object.defineProperty(StandardMaterial, "ColorGradingTextureEnabled", {
  67139. /**
  67140. * Are color grading textures enabled in the application.
  67141. */
  67142. get: function () {
  67143. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled;
  67144. },
  67145. set: function (value) {
  67146. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].ColorGradingTextureEnabled = value;
  67147. },
  67148. enumerable: true,
  67149. configurable: true
  67150. });
  67151. Object.defineProperty(StandardMaterial, "FresnelEnabled", {
  67152. /**
  67153. * Are fresnels enabled in the application.
  67154. */
  67155. get: function () {
  67156. return _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled;
  67157. },
  67158. set: function (value) {
  67159. _materialFlags__WEBPACK_IMPORTED_MODULE_13__["MaterialFlags"].FresnelEnabled = value;
  67160. },
  67161. enumerable: true,
  67162. configurable: true
  67163. });
  67164. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67165. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("diffuseTexture")
  67166. ], StandardMaterial.prototype, "_diffuseTexture", void 0);
  67167. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67168. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  67169. ], StandardMaterial.prototype, "diffuseTexture", void 0);
  67170. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67171. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("ambientTexture")
  67172. ], StandardMaterial.prototype, "_ambientTexture", void 0);
  67173. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67174. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67175. ], StandardMaterial.prototype, "ambientTexture", void 0);
  67176. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67177. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("opacityTexture")
  67178. ], StandardMaterial.prototype, "_opacityTexture", void 0);
  67179. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67180. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesAndMiscDirty")
  67181. ], StandardMaterial.prototype, "opacityTexture", void 0);
  67182. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67183. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("reflectionTexture")
  67184. ], StandardMaterial.prototype, "_reflectionTexture", void 0);
  67185. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67186. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67187. ], StandardMaterial.prototype, "reflectionTexture", void 0);
  67188. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67189. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("emissiveTexture")
  67190. ], StandardMaterial.prototype, "_emissiveTexture", void 0);
  67191. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67192. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67193. ], StandardMaterial.prototype, "emissiveTexture", void 0);
  67194. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67195. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("specularTexture")
  67196. ], StandardMaterial.prototype, "_specularTexture", void 0);
  67197. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67198. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67199. ], StandardMaterial.prototype, "specularTexture", void 0);
  67200. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67201. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("bumpTexture")
  67202. ], StandardMaterial.prototype, "_bumpTexture", void 0);
  67203. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67204. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67205. ], StandardMaterial.prototype, "bumpTexture", void 0);
  67206. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67207. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lightmapTexture")
  67208. ], StandardMaterial.prototype, "_lightmapTexture", void 0);
  67209. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67210. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67211. ], StandardMaterial.prototype, "lightmapTexture", void 0);
  67212. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67213. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("refractionTexture")
  67214. ], StandardMaterial.prototype, "_refractionTexture", void 0);
  67215. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67216. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67217. ], StandardMaterial.prototype, "refractionTexture", void 0);
  67218. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67219. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("ambient")
  67220. ], StandardMaterial.prototype, "ambientColor", void 0);
  67221. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67222. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("diffuse")
  67223. ], StandardMaterial.prototype, "diffuseColor", void 0);
  67224. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67225. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("specular")
  67226. ], StandardMaterial.prototype, "specularColor", void 0);
  67227. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67228. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsColor3"])("emissive")
  67229. ], StandardMaterial.prototype, "emissiveColor", void 0);
  67230. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67231. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67232. ], StandardMaterial.prototype, "specularPower", void 0);
  67233. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67234. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useAlphaFromDiffuseTexture")
  67235. ], StandardMaterial.prototype, "_useAlphaFromDiffuseTexture", void 0);
  67236. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67237. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67238. ], StandardMaterial.prototype, "useAlphaFromDiffuseTexture", void 0);
  67239. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67240. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useEmissiveAsIllumination")
  67241. ], StandardMaterial.prototype, "_useEmissiveAsIllumination", void 0);
  67242. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67243. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67244. ], StandardMaterial.prototype, "useEmissiveAsIllumination", void 0);
  67245. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67246. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("linkEmissiveWithDiffuse")
  67247. ], StandardMaterial.prototype, "_linkEmissiveWithDiffuse", void 0);
  67248. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67249. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67250. ], StandardMaterial.prototype, "linkEmissiveWithDiffuse", void 0);
  67251. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67252. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useSpecularOverAlpha")
  67253. ], StandardMaterial.prototype, "_useSpecularOverAlpha", void 0);
  67254. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67255. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67256. ], StandardMaterial.prototype, "useSpecularOverAlpha", void 0);
  67257. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67258. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionOverAlpha")
  67259. ], StandardMaterial.prototype, "_useReflectionOverAlpha", void 0);
  67260. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67261. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67262. ], StandardMaterial.prototype, "useReflectionOverAlpha", void 0);
  67263. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67264. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("disableLighting")
  67265. ], StandardMaterial.prototype, "_disableLighting", void 0);
  67266. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67267. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  67268. ], StandardMaterial.prototype, "disableLighting", void 0);
  67269. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67270. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useObjectSpaceNormalMap")
  67271. ], StandardMaterial.prototype, "_useObjectSpaceNormalMap", void 0);
  67272. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67273. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67274. ], StandardMaterial.prototype, "useObjectSpaceNormalMap", void 0);
  67275. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67276. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallax")
  67277. ], StandardMaterial.prototype, "_useParallax", void 0);
  67278. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67279. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67280. ], StandardMaterial.prototype, "useParallax", void 0);
  67281. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67282. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useParallaxOcclusion")
  67283. ], StandardMaterial.prototype, "_useParallaxOcclusion", void 0);
  67284. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67285. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67286. ], StandardMaterial.prototype, "useParallaxOcclusion", void 0);
  67287. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67288. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67289. ], StandardMaterial.prototype, "parallaxScaleBias", void 0);
  67290. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67291. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("roughness")
  67292. ], StandardMaterial.prototype, "_roughness", void 0);
  67293. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67294. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67295. ], StandardMaterial.prototype, "roughness", void 0);
  67296. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67297. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67298. ], StandardMaterial.prototype, "indexOfRefraction", void 0);
  67299. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67300. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67301. ], StandardMaterial.prototype, "invertRefractionY", void 0);
  67302. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67303. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67304. ], StandardMaterial.prototype, "alphaCutOff", void 0);
  67305. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67306. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useLightmapAsShadowmap")
  67307. ], StandardMaterial.prototype, "_useLightmapAsShadowmap", void 0);
  67308. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67309. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67310. ], StandardMaterial.prototype, "useLightmapAsShadowmap", void 0);
  67311. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67312. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("diffuseFresnelParameters")
  67313. ], StandardMaterial.prototype, "_diffuseFresnelParameters", void 0);
  67314. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67315. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  67316. ], StandardMaterial.prototype, "diffuseFresnelParameters", void 0);
  67317. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67318. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("opacityFresnelParameters")
  67319. ], StandardMaterial.prototype, "_opacityFresnelParameters", void 0);
  67320. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67321. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelAndMiscDirty")
  67322. ], StandardMaterial.prototype, "opacityFresnelParameters", void 0);
  67323. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67324. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("reflectionFresnelParameters")
  67325. ], StandardMaterial.prototype, "_reflectionFresnelParameters", void 0);
  67326. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67327. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  67328. ], StandardMaterial.prototype, "reflectionFresnelParameters", void 0);
  67329. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67330. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("refractionFresnelParameters")
  67331. ], StandardMaterial.prototype, "_refractionFresnelParameters", void 0);
  67332. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67333. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  67334. ], StandardMaterial.prototype, "refractionFresnelParameters", void 0);
  67335. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67336. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsFresnelParameters"])("emissiveFresnelParameters")
  67337. ], StandardMaterial.prototype, "_emissiveFresnelParameters", void 0);
  67338. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67339. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  67340. ], StandardMaterial.prototype, "emissiveFresnelParameters", void 0);
  67341. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67342. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useReflectionFresnelFromSpecular")
  67343. ], StandardMaterial.prototype, "_useReflectionFresnelFromSpecular", void 0);
  67344. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67345. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsFresnelDirty")
  67346. ], StandardMaterial.prototype, "useReflectionFresnelFromSpecular", void 0);
  67347. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67348. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("useGlossinessFromSpecularMapAlpha")
  67349. ], StandardMaterial.prototype, "_useGlossinessFromSpecularMapAlpha", void 0);
  67350. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67351. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67352. ], StandardMaterial.prototype, "useGlossinessFromSpecularMapAlpha", void 0);
  67353. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67354. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("maxSimultaneousLights")
  67355. ], StandardMaterial.prototype, "_maxSimultaneousLights", void 0);
  67356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsLightsDirty")
  67358. ], StandardMaterial.prototype, "maxSimultaneousLights", void 0);
  67359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapX")
  67361. ], StandardMaterial.prototype, "_invertNormalMapX", void 0);
  67362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67364. ], StandardMaterial.prototype, "invertNormalMapX", void 0);
  67365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("invertNormalMapY")
  67367. ], StandardMaterial.prototype, "_invertNormalMapY", void 0);
  67368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67370. ], StandardMaterial.prototype, "invertNormalMapY", void 0);
  67371. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67372. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])("twoSidedLighting")
  67373. ], StandardMaterial.prototype, "_twoSidedLighting", void 0);
  67374. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67375. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["expandToProperty"])("_markAllSubMeshesAsTexturesDirty")
  67376. ], StandardMaterial.prototype, "twoSidedLighting", void 0);
  67377. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  67378. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  67379. ], StandardMaterial.prototype, "useLogarithmicDepth", null);
  67380. return StandardMaterial;
  67381. }(_pushMaterial__WEBPACK_IMPORTED_MODULE_9__["PushMaterial"]));
  67382. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardMaterial"] = StandardMaterial;
  67383. _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"].DefaultMaterialFactory = function (scene) {
  67384. return new StandardMaterial("default material", scene);
  67385. };
  67386. /***/ }),
  67387. /***/ "./Materials/uniformBuffer.ts":
  67388. /*!************************************!*\
  67389. !*** ./Materials/uniformBuffer.ts ***!
  67390. \************************************/
  67391. /*! exports provided: UniformBuffer */
  67392. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67393. "use strict";
  67394. __webpack_require__.r(__webpack_exports__);
  67395. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return UniformBuffer; });
  67396. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  67397. /**
  67398. * Uniform buffer objects.
  67399. *
  67400. * Handles blocks of uniform on the GPU.
  67401. *
  67402. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  67403. *
  67404. * For more information, please refer to :
  67405. * https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  67406. */
  67407. var UniformBuffer = /** @class */ (function () {
  67408. /**
  67409. * Instantiates a new Uniform buffer objects.
  67410. *
  67411. * Handles blocks of uniform on the GPU.
  67412. *
  67413. * If WebGL 2 is not available, this class falls back on traditionnal setUniformXXX calls.
  67414. *
  67415. * For more information, please refer to :
  67416. * @see https://www.khronos.org/opengl/wiki/Uniform_Buffer_Object
  67417. * @param engine Define the engine the buffer is associated with
  67418. * @param data Define the data contained in the buffer
  67419. * @param dynamic Define if the buffer is updatable
  67420. */
  67421. function UniformBuffer(engine, data, dynamic) {
  67422. this._engine = engine;
  67423. this._noUBO = !engine.supportsUniformBuffers;
  67424. this._dynamic = dynamic;
  67425. this._data = data || [];
  67426. this._uniformLocations = {};
  67427. this._uniformSizes = {};
  67428. this._uniformLocationPointer = 0;
  67429. this._needSync = false;
  67430. if (this._noUBO) {
  67431. this.updateMatrix3x3 = this._updateMatrix3x3ForEffect;
  67432. this.updateMatrix2x2 = this._updateMatrix2x2ForEffect;
  67433. this.updateFloat = this._updateFloatForEffect;
  67434. this.updateFloat2 = this._updateFloat2ForEffect;
  67435. this.updateFloat3 = this._updateFloat3ForEffect;
  67436. this.updateFloat4 = this._updateFloat4ForEffect;
  67437. this.updateMatrix = this._updateMatrixForEffect;
  67438. this.updateVector3 = this._updateVector3ForEffect;
  67439. this.updateVector4 = this._updateVector4ForEffect;
  67440. this.updateColor3 = this._updateColor3ForEffect;
  67441. this.updateColor4 = this._updateColor4ForEffect;
  67442. }
  67443. else {
  67444. this._engine._uniformBuffers.push(this);
  67445. this.updateMatrix3x3 = this._updateMatrix3x3ForUniform;
  67446. this.updateMatrix2x2 = this._updateMatrix2x2ForUniform;
  67447. this.updateFloat = this._updateFloatForUniform;
  67448. this.updateFloat2 = this._updateFloat2ForUniform;
  67449. this.updateFloat3 = this._updateFloat3ForUniform;
  67450. this.updateFloat4 = this._updateFloat4ForUniform;
  67451. this.updateMatrix = this._updateMatrixForUniform;
  67452. this.updateVector3 = this._updateVector3ForUniform;
  67453. this.updateVector4 = this._updateVector4ForUniform;
  67454. this.updateColor3 = this._updateColor3ForUniform;
  67455. this.updateColor4 = this._updateColor4ForUniform;
  67456. }
  67457. }
  67458. Object.defineProperty(UniformBuffer.prototype, "useUbo", {
  67459. /**
  67460. * Indicates if the buffer is using the WebGL2 UBO implementation,
  67461. * or just falling back on setUniformXXX calls.
  67462. */
  67463. get: function () {
  67464. return !this._noUBO;
  67465. },
  67466. enumerable: true,
  67467. configurable: true
  67468. });
  67469. Object.defineProperty(UniformBuffer.prototype, "isSync", {
  67470. /**
  67471. * Indicates if the WebGL underlying uniform buffer is in sync
  67472. * with the javascript cache data.
  67473. */
  67474. get: function () {
  67475. return !this._needSync;
  67476. },
  67477. enumerable: true,
  67478. configurable: true
  67479. });
  67480. /**
  67481. * Indicates if the WebGL underlying uniform buffer is dynamic.
  67482. * Also, a dynamic UniformBuffer will disable cache verification and always
  67483. * update the underlying WebGL uniform buffer to the GPU.
  67484. * @returns if Dynamic, otherwise false
  67485. */
  67486. UniformBuffer.prototype.isDynamic = function () {
  67487. return this._dynamic !== undefined;
  67488. };
  67489. /**
  67490. * The data cache on JS side.
  67491. * @returns the underlying data as a float array
  67492. */
  67493. UniformBuffer.prototype.getData = function () {
  67494. return this._bufferData;
  67495. };
  67496. /**
  67497. * The underlying WebGL Uniform buffer.
  67498. * @returns the webgl buffer
  67499. */
  67500. UniformBuffer.prototype.getBuffer = function () {
  67501. return this._buffer;
  67502. };
  67503. /**
  67504. * std140 layout specifies how to align data within an UBO structure.
  67505. * See https://khronos.org/registry/OpenGL/specs/gl/glspec45.core.pdf#page=159
  67506. * for specs.
  67507. */
  67508. UniformBuffer.prototype._fillAlignment = function (size) {
  67509. // This code has been simplified because we only use floats, vectors of 1, 2, 3, 4 components
  67510. // and 4x4 matrices
  67511. // TODO : change if other types are used
  67512. var alignment;
  67513. if (size <= 2) {
  67514. alignment = size;
  67515. }
  67516. else {
  67517. alignment = 4;
  67518. }
  67519. if ((this._uniformLocationPointer % alignment) !== 0) {
  67520. var oldPointer = this._uniformLocationPointer;
  67521. this._uniformLocationPointer += alignment - (this._uniformLocationPointer % alignment);
  67522. var diff = this._uniformLocationPointer - oldPointer;
  67523. for (var i = 0; i < diff; i++) {
  67524. this._data.push(0);
  67525. }
  67526. }
  67527. };
  67528. /**
  67529. * Adds an uniform in the buffer.
  67530. * Warning : the subsequents calls of this function must be in the same order as declared in the shader
  67531. * for the layout to be correct !
  67532. * @param name Name of the uniform, as used in the uniform block in the shader.
  67533. * @param size Data size, or data directly.
  67534. */
  67535. UniformBuffer.prototype.addUniform = function (name, size) {
  67536. if (this._noUBO) {
  67537. return;
  67538. }
  67539. if (this._uniformLocations[name] !== undefined) {
  67540. // Already existing uniform
  67541. return;
  67542. }
  67543. // This function must be called in the order of the shader layout !
  67544. // size can be the size of the uniform, or data directly
  67545. var data;
  67546. if (size instanceof Array) {
  67547. data = size;
  67548. size = data.length;
  67549. }
  67550. else {
  67551. size = size;
  67552. data = [];
  67553. // Fill with zeros
  67554. for (var i = 0; i < size; i++) {
  67555. data.push(0);
  67556. }
  67557. }
  67558. this._fillAlignment(size);
  67559. this._uniformSizes[name] = size;
  67560. this._uniformLocations[name] = this._uniformLocationPointer;
  67561. this._uniformLocationPointer += size;
  67562. for (var i = 0; i < size; i++) {
  67563. this._data.push(data[i]);
  67564. }
  67565. this._needSync = true;
  67566. };
  67567. /**
  67568. * Adds a Matrix 4x4 to the uniform buffer.
  67569. * @param name Name of the uniform, as used in the uniform block in the shader.
  67570. * @param mat A 4x4 matrix.
  67571. */
  67572. UniformBuffer.prototype.addMatrix = function (name, mat) {
  67573. this.addUniform(name, Array.prototype.slice.call(mat.toArray()));
  67574. };
  67575. /**
  67576. * Adds a vec2 to the uniform buffer.
  67577. * @param name Name of the uniform, as used in the uniform block in the shader.
  67578. * @param x Define the x component value of the vec2
  67579. * @param y Define the y component value of the vec2
  67580. */
  67581. UniformBuffer.prototype.addFloat2 = function (name, x, y) {
  67582. var temp = [x, y];
  67583. this.addUniform(name, temp);
  67584. };
  67585. /**
  67586. * Adds a vec3 to the uniform buffer.
  67587. * @param name Name of the uniform, as used in the uniform block in the shader.
  67588. * @param x Define the x component value of the vec3
  67589. * @param y Define the y component value of the vec3
  67590. * @param z Define the z component value of the vec3
  67591. */
  67592. UniformBuffer.prototype.addFloat3 = function (name, x, y, z) {
  67593. var temp = [x, y, z];
  67594. this.addUniform(name, temp);
  67595. };
  67596. /**
  67597. * Adds a vec3 to the uniform buffer.
  67598. * @param name Name of the uniform, as used in the uniform block in the shader.
  67599. * @param color Define the vec3 from a Color
  67600. */
  67601. UniformBuffer.prototype.addColor3 = function (name, color) {
  67602. var temp = new Array();
  67603. color.toArray(temp);
  67604. this.addUniform(name, temp);
  67605. };
  67606. /**
  67607. * Adds a vec4 to the uniform buffer.
  67608. * @param name Name of the uniform, as used in the uniform block in the shader.
  67609. * @param color Define the rgb components from a Color
  67610. * @param alpha Define the a component of the vec4
  67611. */
  67612. UniformBuffer.prototype.addColor4 = function (name, color, alpha) {
  67613. var temp = new Array();
  67614. color.toArray(temp);
  67615. temp.push(alpha);
  67616. this.addUniform(name, temp);
  67617. };
  67618. /**
  67619. * Adds a vec3 to the uniform buffer.
  67620. * @param name Name of the uniform, as used in the uniform block in the shader.
  67621. * @param vector Define the vec3 components from a Vector
  67622. */
  67623. UniformBuffer.prototype.addVector3 = function (name, vector) {
  67624. var temp = new Array();
  67625. vector.toArray(temp);
  67626. this.addUniform(name, temp);
  67627. };
  67628. /**
  67629. * Adds a Matrix 3x3 to the uniform buffer.
  67630. * @param name Name of the uniform, as used in the uniform block in the shader.
  67631. */
  67632. UniformBuffer.prototype.addMatrix3x3 = function (name) {
  67633. this.addUniform(name, 12);
  67634. };
  67635. /**
  67636. * Adds a Matrix 2x2 to the uniform buffer.
  67637. * @param name Name of the uniform, as used in the uniform block in the shader.
  67638. */
  67639. UniformBuffer.prototype.addMatrix2x2 = function (name) {
  67640. this.addUniform(name, 8);
  67641. };
  67642. /**
  67643. * Effectively creates the WebGL Uniform Buffer, once layout is completed with `addUniform`.
  67644. */
  67645. UniformBuffer.prototype.create = function () {
  67646. if (this._noUBO) {
  67647. return;
  67648. }
  67649. if (this._buffer) {
  67650. return; // nothing to do
  67651. }
  67652. // See spec, alignment must be filled as a vec4
  67653. this._fillAlignment(4);
  67654. this._bufferData = new Float32Array(this._data);
  67655. this._rebuild();
  67656. this._needSync = true;
  67657. };
  67658. /** @hidden */
  67659. UniformBuffer.prototype._rebuild = function () {
  67660. if (this._noUBO) {
  67661. return;
  67662. }
  67663. if (this._dynamic) {
  67664. this._buffer = this._engine.createDynamicUniformBuffer(this._bufferData);
  67665. }
  67666. else {
  67667. this._buffer = this._engine.createUniformBuffer(this._bufferData);
  67668. }
  67669. };
  67670. /**
  67671. * Updates the WebGL Uniform Buffer on the GPU.
  67672. * If the `dynamic` flag is set to true, no cache comparison is done.
  67673. * Otherwise, the buffer will be updated only if the cache differs.
  67674. */
  67675. UniformBuffer.prototype.update = function () {
  67676. if (!this._buffer) {
  67677. this.create();
  67678. return;
  67679. }
  67680. if (!this._dynamic && !this._needSync) {
  67681. return;
  67682. }
  67683. this._engine.updateUniformBuffer(this._buffer, this._bufferData);
  67684. this._needSync = false;
  67685. };
  67686. /**
  67687. * Updates the value of an uniform. The `update` method must be called afterwards to make it effective in the GPU.
  67688. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67689. * @param data Define the flattened data
  67690. * @param size Define the size of the data.
  67691. */
  67692. UniformBuffer.prototype.updateUniform = function (uniformName, data, size) {
  67693. var location = this._uniformLocations[uniformName];
  67694. if (location === undefined) {
  67695. if (this._buffer) {
  67696. // Cannot add an uniform if the buffer is already created
  67697. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Cannot add an uniform after UBO has been created.");
  67698. return;
  67699. }
  67700. this.addUniform(uniformName, size);
  67701. location = this._uniformLocations[uniformName];
  67702. }
  67703. if (!this._buffer) {
  67704. this.create();
  67705. }
  67706. if (!this._dynamic) {
  67707. // Cache for static uniform buffers
  67708. var changed = false;
  67709. for (var i = 0; i < size; i++) {
  67710. if (this._bufferData[location + i] !== data[i]) {
  67711. changed = true;
  67712. this._bufferData[location + i] = data[i];
  67713. }
  67714. }
  67715. this._needSync = this._needSync || changed;
  67716. }
  67717. else {
  67718. // No cache for dynamic
  67719. for (var i = 0; i < size; i++) {
  67720. this._bufferData[location + i] = data[i];
  67721. }
  67722. }
  67723. };
  67724. // Update methods
  67725. UniformBuffer.prototype._updateMatrix3x3ForUniform = function (name, matrix) {
  67726. // To match std140, matrix must be realigned
  67727. for (var i = 0; i < 3; i++) {
  67728. UniformBuffer._tempBuffer[i * 4] = matrix[i * 3];
  67729. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 3 + 1];
  67730. UniformBuffer._tempBuffer[i * 4 + 2] = matrix[i * 3 + 2];
  67731. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67732. }
  67733. this.updateUniform(name, UniformBuffer._tempBuffer, 12);
  67734. };
  67735. UniformBuffer.prototype._updateMatrix3x3ForEffect = function (name, matrix) {
  67736. this._currentEffect.setMatrix3x3(name, matrix);
  67737. };
  67738. UniformBuffer.prototype._updateMatrix2x2ForEffect = function (name, matrix) {
  67739. this._currentEffect.setMatrix2x2(name, matrix);
  67740. };
  67741. UniformBuffer.prototype._updateMatrix2x2ForUniform = function (name, matrix) {
  67742. // To match std140, matrix must be realigned
  67743. for (var i = 0; i < 2; i++) {
  67744. UniformBuffer._tempBuffer[i * 4] = matrix[i * 2];
  67745. UniformBuffer._tempBuffer[i * 4 + 1] = matrix[i * 2 + 1];
  67746. UniformBuffer._tempBuffer[i * 4 + 2] = 0.0;
  67747. UniformBuffer._tempBuffer[i * 4 + 3] = 0.0;
  67748. }
  67749. this.updateUniform(name, UniformBuffer._tempBuffer, 8);
  67750. };
  67751. UniformBuffer.prototype._updateFloatForEffect = function (name, x) {
  67752. this._currentEffect.setFloat(name, x);
  67753. };
  67754. UniformBuffer.prototype._updateFloatForUniform = function (name, x) {
  67755. UniformBuffer._tempBuffer[0] = x;
  67756. this.updateUniform(name, UniformBuffer._tempBuffer, 1);
  67757. };
  67758. UniformBuffer.prototype._updateFloat2ForEffect = function (name, x, y, suffix) {
  67759. if (suffix === void 0) { suffix = ""; }
  67760. this._currentEffect.setFloat2(name + suffix, x, y);
  67761. };
  67762. UniformBuffer.prototype._updateFloat2ForUniform = function (name, x, y) {
  67763. UniformBuffer._tempBuffer[0] = x;
  67764. UniformBuffer._tempBuffer[1] = y;
  67765. this.updateUniform(name, UniformBuffer._tempBuffer, 2);
  67766. };
  67767. UniformBuffer.prototype._updateFloat3ForEffect = function (name, x, y, z, suffix) {
  67768. if (suffix === void 0) { suffix = ""; }
  67769. this._currentEffect.setFloat3(name + suffix, x, y, z);
  67770. };
  67771. UniformBuffer.prototype._updateFloat3ForUniform = function (name, x, y, z) {
  67772. UniformBuffer._tempBuffer[0] = x;
  67773. UniformBuffer._tempBuffer[1] = y;
  67774. UniformBuffer._tempBuffer[2] = z;
  67775. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67776. };
  67777. UniformBuffer.prototype._updateFloat4ForEffect = function (name, x, y, z, w, suffix) {
  67778. if (suffix === void 0) { suffix = ""; }
  67779. this._currentEffect.setFloat4(name + suffix, x, y, z, w);
  67780. };
  67781. UniformBuffer.prototype._updateFloat4ForUniform = function (name, x, y, z, w) {
  67782. UniformBuffer._tempBuffer[0] = x;
  67783. UniformBuffer._tempBuffer[1] = y;
  67784. UniformBuffer._tempBuffer[2] = z;
  67785. UniformBuffer._tempBuffer[3] = w;
  67786. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67787. };
  67788. UniformBuffer.prototype._updateMatrixForEffect = function (name, mat) {
  67789. this._currentEffect.setMatrix(name, mat);
  67790. };
  67791. UniformBuffer.prototype._updateMatrixForUniform = function (name, mat) {
  67792. this.updateUniform(name, mat.toArray(), 16);
  67793. };
  67794. UniformBuffer.prototype._updateVector3ForEffect = function (name, vector) {
  67795. this._currentEffect.setVector3(name, vector);
  67796. };
  67797. UniformBuffer.prototype._updateVector3ForUniform = function (name, vector) {
  67798. vector.toArray(UniformBuffer._tempBuffer);
  67799. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67800. };
  67801. UniformBuffer.prototype._updateVector4ForEffect = function (name, vector) {
  67802. this._currentEffect.setVector4(name, vector);
  67803. };
  67804. UniformBuffer.prototype._updateVector4ForUniform = function (name, vector) {
  67805. vector.toArray(UniformBuffer._tempBuffer);
  67806. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67807. };
  67808. UniformBuffer.prototype._updateColor3ForEffect = function (name, color, suffix) {
  67809. if (suffix === void 0) { suffix = ""; }
  67810. this._currentEffect.setColor3(name + suffix, color);
  67811. };
  67812. UniformBuffer.prototype._updateColor3ForUniform = function (name, color) {
  67813. color.toArray(UniformBuffer._tempBuffer);
  67814. this.updateUniform(name, UniformBuffer._tempBuffer, 3);
  67815. };
  67816. UniformBuffer.prototype._updateColor4ForEffect = function (name, color, alpha, suffix) {
  67817. if (suffix === void 0) { suffix = ""; }
  67818. this._currentEffect.setColor4(name + suffix, color, alpha);
  67819. };
  67820. UniformBuffer.prototype._updateColor4ForUniform = function (name, color, alpha) {
  67821. color.toArray(UniformBuffer._tempBuffer);
  67822. UniformBuffer._tempBuffer[3] = alpha;
  67823. this.updateUniform(name, UniformBuffer._tempBuffer, 4);
  67824. };
  67825. /**
  67826. * Sets a sampler uniform on the effect.
  67827. * @param name Define the name of the sampler.
  67828. * @param texture Define the texture to set in the sampler
  67829. */
  67830. UniformBuffer.prototype.setTexture = function (name, texture) {
  67831. this._currentEffect.setTexture(name, texture);
  67832. };
  67833. /**
  67834. * Directly updates the value of the uniform in the cache AND on the GPU.
  67835. * @param uniformName Define the name of the uniform, as used in the uniform block in the shader.
  67836. * @param data Define the flattened data
  67837. */
  67838. UniformBuffer.prototype.updateUniformDirectly = function (uniformName, data) {
  67839. this.updateUniform(uniformName, data, data.length);
  67840. this.update();
  67841. };
  67842. /**
  67843. * Binds this uniform buffer to an effect.
  67844. * @param effect Define the effect to bind the buffer to
  67845. * @param name Name of the uniform block in the shader.
  67846. */
  67847. UniformBuffer.prototype.bindToEffect = function (effect, name) {
  67848. this._currentEffect = effect;
  67849. if (this._noUBO || !this._buffer) {
  67850. return;
  67851. }
  67852. effect.bindUniformBuffer(this._buffer, name);
  67853. };
  67854. /**
  67855. * Disposes the uniform buffer.
  67856. */
  67857. UniformBuffer.prototype.dispose = function () {
  67858. if (this._noUBO) {
  67859. return;
  67860. }
  67861. var uniformBuffers = this._engine._uniformBuffers;
  67862. var index = uniformBuffers.indexOf(this);
  67863. if (index !== -1) {
  67864. uniformBuffers[index] = uniformBuffers[uniformBuffers.length - 1];
  67865. uniformBuffers.pop();
  67866. }
  67867. if (!this._buffer) {
  67868. return;
  67869. }
  67870. if (this._engine._releaseBuffer(this._buffer)) {
  67871. this._buffer = null;
  67872. }
  67873. };
  67874. // Pool for avoiding memory leaks
  67875. UniformBuffer._MAX_UNIFORM_SIZE = 256;
  67876. UniformBuffer._tempBuffer = new Float32Array(UniformBuffer._MAX_UNIFORM_SIZE);
  67877. return UniformBuffer;
  67878. }());
  67879. /***/ }),
  67880. /***/ "./Maths/index.ts":
  67881. /*!************************!*\
  67882. !*** ./Maths/index.ts ***!
  67883. \************************/
  67884. /*! 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 */
  67885. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67886. "use strict";
  67887. __webpack_require__.r(__webpack_exports__);
  67888. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  67889. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"]; });
  67890. /* harmony import */ var _math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math */ "./Maths/math.ts");
  67891. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToGammaSpace"]; });
  67892. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["ToLinearSpace"]; });
  67893. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Epsilon"]; });
  67894. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color3"]; });
  67895. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Color4"]; });
  67896. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector2"]; });
  67897. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector3"]; });
  67898. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Vector4"]; });
  67899. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Size"]; });
  67900. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]; });
  67901. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Matrix"]; });
  67902. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Plane"]; });
  67903. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Viewport"]; });
  67904. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Frustum"]; });
  67905. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Space"]; });
  67906. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Axis"]; });
  67907. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["BezierCurve"]; });
  67908. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Orientation"]; });
  67909. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Angle"]; });
  67910. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Arc2"]; });
  67911. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path2"]; });
  67912. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Path3D"]; });
  67913. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Curve3"]; });
  67914. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalVertex"]; });
  67915. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["PositionNormalTextureVertex"]; });
  67916. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _math__WEBPACK_IMPORTED_MODULE_1__["Tmp"]; });
  67917. /* harmony import */ var _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  67918. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"]; });
  67919. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]; });
  67920. /***/ }),
  67921. /***/ "./Maths/math.scalar.ts":
  67922. /*!******************************!*\
  67923. !*** ./Maths/math.scalar.ts ***!
  67924. \******************************/
  67925. /*! exports provided: Scalar */
  67926. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  67927. "use strict";
  67928. __webpack_require__.r(__webpack_exports__);
  67929. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return Scalar; });
  67930. /**
  67931. * Scalar computation library
  67932. */
  67933. var Scalar = /** @class */ (function () {
  67934. function Scalar() {
  67935. }
  67936. /**
  67937. * Boolean : true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67938. * @param a number
  67939. * @param b number
  67940. * @param epsilon (default = 1.401298E-45)
  67941. * @returns true if the absolute difference between a and b is lower than epsilon (default = 1.401298E-45)
  67942. */
  67943. Scalar.WithinEpsilon = function (a, b, epsilon) {
  67944. if (epsilon === void 0) { epsilon = 1.401298E-45; }
  67945. var num = a - b;
  67946. return -epsilon <= num && num <= epsilon;
  67947. };
  67948. /**
  67949. * Returns a string : the upper case translation of the number i to hexadecimal.
  67950. * @param i number
  67951. * @returns the upper case translation of the number i to hexadecimal.
  67952. */
  67953. Scalar.ToHex = function (i) {
  67954. var str = i.toString(16);
  67955. if (i <= 15) {
  67956. return ("0" + str).toUpperCase();
  67957. }
  67958. return str.toUpperCase();
  67959. };
  67960. /**
  67961. * Returns -1 if value is negative and +1 is value is positive.
  67962. * @param value the value
  67963. * @returns the value itself if it's equal to zero.
  67964. */
  67965. Scalar.Sign = function (value) {
  67966. value = +value; // convert to a number
  67967. if (value === 0 || isNaN(value)) {
  67968. return value;
  67969. }
  67970. return value > 0 ? 1 : -1;
  67971. };
  67972. /**
  67973. * Returns the value itself if it's between min and max.
  67974. * Returns min if the value is lower than min.
  67975. * Returns max if the value is greater than max.
  67976. * @param value the value to clmap
  67977. * @param min the min value to clamp to (default: 0)
  67978. * @param max the max value to clamp to (default: 1)
  67979. * @returns the clamped value
  67980. */
  67981. Scalar.Clamp = function (value, min, max) {
  67982. if (min === void 0) { min = 0; }
  67983. if (max === void 0) { max = 1; }
  67984. return Math.min(max, Math.max(min, value));
  67985. };
  67986. /**
  67987. * the log2 of value.
  67988. * @param value the value to compute log2 of
  67989. * @returns the log2 of value.
  67990. */
  67991. Scalar.Log2 = function (value) {
  67992. return Math.log(value) * Math.LOG2E;
  67993. };
  67994. /**
  67995. * Loops the value, so that it is never larger than length and never smaller than 0.
  67996. *
  67997. * This is similar to the modulo operator but it works with floating point numbers.
  67998. * For example, using 3.0 for t and 2.5 for length, the result would be 0.5.
  67999. * With t = 5 and length = 2.5, the result would be 0.0.
  68000. * Note, however, that the behaviour is not defined for negative numbers as it is for the modulo operator
  68001. * @param value the value
  68002. * @param length the length
  68003. * @returns the looped value
  68004. */
  68005. Scalar.Repeat = function (value, length) {
  68006. return value - Math.floor(value / length) * length;
  68007. };
  68008. /**
  68009. * Normalize the value between 0.0 and 1.0 using min and max values
  68010. * @param value value to normalize
  68011. * @param min max to normalize between
  68012. * @param max min to normalize between
  68013. * @returns the normalized value
  68014. */
  68015. Scalar.Normalize = function (value, min, max) {
  68016. return (value - min) / (max - min);
  68017. };
  68018. /**
  68019. * Denormalize the value from 0.0 and 1.0 using min and max values
  68020. * @param normalized value to denormalize
  68021. * @param min max to denormalize between
  68022. * @param max min to denormalize between
  68023. * @returns the denormalized value
  68024. */
  68025. Scalar.Denormalize = function (normalized, min, max) {
  68026. return (normalized * (max - min) + min);
  68027. };
  68028. /**
  68029. * Calculates the shortest difference between two given angles given in degrees.
  68030. * @param current current angle in degrees
  68031. * @param target target angle in degrees
  68032. * @returns the delta
  68033. */
  68034. Scalar.DeltaAngle = function (current, target) {
  68035. var num = Scalar.Repeat(target - current, 360.0);
  68036. if (num > 180.0) {
  68037. num -= 360.0;
  68038. }
  68039. return num;
  68040. };
  68041. /**
  68042. * PingPongs the value t, so that it is never larger than length and never smaller than 0.
  68043. * @param tx value
  68044. * @param length length
  68045. * @returns The returned value will move back and forth between 0 and length
  68046. */
  68047. Scalar.PingPong = function (tx, length) {
  68048. var t = Scalar.Repeat(tx, length * 2.0);
  68049. return length - Math.abs(t - length);
  68050. };
  68051. /**
  68052. * Interpolates between min and max with smoothing at the limits.
  68053. *
  68054. * This function interpolates between min and max in a similar way to Lerp. However, the interpolation will gradually speed up
  68055. * from the start and slow down toward the end. This is useful for creating natural-looking animation, fading and other transitions.
  68056. * @param from from
  68057. * @param to to
  68058. * @param tx value
  68059. * @returns the smooth stepped value
  68060. */
  68061. Scalar.SmoothStep = function (from, to, tx) {
  68062. var t = Scalar.Clamp(tx);
  68063. t = -2.0 * t * t * t + 3.0 * t * t;
  68064. return to * t + from * (1.0 - t);
  68065. };
  68066. /**
  68067. * Moves a value current towards target.
  68068. *
  68069. * This is essentially the same as Mathf.Lerp but instead the function will ensure that the speed never exceeds maxDelta.
  68070. * Negative values of maxDelta pushes the value away from target.
  68071. * @param current current value
  68072. * @param target target value
  68073. * @param maxDelta max distance to move
  68074. * @returns resulting value
  68075. */
  68076. Scalar.MoveTowards = function (current, target, maxDelta) {
  68077. var result = 0;
  68078. if (Math.abs(target - current) <= maxDelta) {
  68079. result = target;
  68080. }
  68081. else {
  68082. result = current + Scalar.Sign(target - current) * maxDelta;
  68083. }
  68084. return result;
  68085. };
  68086. /**
  68087. * Same as MoveTowards but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68088. *
  68089. * Variables current and target are assumed to be in degrees. For optimization reasons, negative values of maxDelta
  68090. * are not supported and may cause oscillation. To push current away from a target angle, add 180 to that angle instead.
  68091. * @param current current value
  68092. * @param target target value
  68093. * @param maxDelta max distance to move
  68094. * @returns resulting angle
  68095. */
  68096. Scalar.MoveTowardsAngle = function (current, target, maxDelta) {
  68097. var num = Scalar.DeltaAngle(current, target);
  68098. var result = 0;
  68099. if (-maxDelta < num && num < maxDelta) {
  68100. result = target;
  68101. }
  68102. else {
  68103. target = current + num;
  68104. result = Scalar.MoveTowards(current, target, maxDelta);
  68105. }
  68106. return result;
  68107. };
  68108. /**
  68109. * Creates a new scalar with values linearly interpolated of "amount" between the start scalar and the end scalar.
  68110. * @param start start value
  68111. * @param end target value
  68112. * @param amount amount to lerp between
  68113. * @returns the lerped value
  68114. */
  68115. Scalar.Lerp = function (start, end, amount) {
  68116. return start + ((end - start) * amount);
  68117. };
  68118. /**
  68119. * Same as Lerp but makes sure the values interpolate correctly when they wrap around 360 degrees.
  68120. * The parameter t is clamped to the range [0, 1]. Variables a and b are assumed to be in degrees.
  68121. * @param start start value
  68122. * @param end target value
  68123. * @param amount amount to lerp between
  68124. * @returns the lerped value
  68125. */
  68126. Scalar.LerpAngle = function (start, end, amount) {
  68127. var num = Scalar.Repeat(end - start, 360.0);
  68128. if (num > 180.0) {
  68129. num -= 360.0;
  68130. }
  68131. return start + num * Scalar.Clamp(amount);
  68132. };
  68133. /**
  68134. * Calculates the linear parameter t that produces the interpolant value within the range [a, b].
  68135. * @param a start value
  68136. * @param b target value
  68137. * @param value value between a and b
  68138. * @returns the inverseLerp value
  68139. */
  68140. Scalar.InverseLerp = function (a, b, value) {
  68141. var result = 0;
  68142. if (a != b) {
  68143. result = Scalar.Clamp((value - a) / (b - a));
  68144. }
  68145. else {
  68146. result = 0.0;
  68147. }
  68148. return result;
  68149. };
  68150. /**
  68151. * Returns a new scalar located for "amount" (float) on the Hermite spline defined by the scalars "value1", "value3", "tangent1", "tangent2".
  68152. * @see http://mathworld.wolfram.com/HermitePolynomial.html
  68153. * @param value1 spline value
  68154. * @param tangent1 spline value
  68155. * @param value2 spline value
  68156. * @param tangent2 spline value
  68157. * @param amount input value
  68158. * @returns hermite result
  68159. */
  68160. Scalar.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  68161. var squared = amount * amount;
  68162. var cubed = amount * squared;
  68163. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  68164. var part2 = (-2.0 * cubed) + (3.0 * squared);
  68165. var part3 = (cubed - (2.0 * squared)) + amount;
  68166. var part4 = cubed - squared;
  68167. return (((value1 * part1) + (value2 * part2)) + (tangent1 * part3)) + (tangent2 * part4);
  68168. };
  68169. /**
  68170. * Returns a random float number between and min and max values
  68171. * @param min min value of random
  68172. * @param max max value of random
  68173. * @returns random value
  68174. */
  68175. Scalar.RandomRange = function (min, max) {
  68176. if (min === max) {
  68177. return min;
  68178. }
  68179. return ((Math.random() * (max - min)) + min);
  68180. };
  68181. /**
  68182. * This function returns percentage of a number in a given range.
  68183. *
  68184. * RangeToPercent(40,20,60) will return 0.5 (50%)
  68185. * RangeToPercent(34,0,100) will return 0.34 (34%)
  68186. * @param number to convert to percentage
  68187. * @param min min range
  68188. * @param max max range
  68189. * @returns the percentage
  68190. */
  68191. Scalar.RangeToPercent = function (number, min, max) {
  68192. return ((number - min) / (max - min));
  68193. };
  68194. /**
  68195. * This function returns number that corresponds to the percentage in a given range.
  68196. *
  68197. * PercentToRange(0.34,0,100) will return 34.
  68198. * @param percent to convert to number
  68199. * @param min min range
  68200. * @param max max range
  68201. * @returns the number
  68202. */
  68203. Scalar.PercentToRange = function (percent, min, max) {
  68204. return ((max - min) * percent + min);
  68205. };
  68206. /**
  68207. * Returns the angle converted to equivalent value between -Math.PI and Math.PI radians.
  68208. * @param angle The angle to normalize in radian.
  68209. * @return The converted angle.
  68210. */
  68211. Scalar.NormalizeRadians = function (angle) {
  68212. // More precise but slower version kept for reference.
  68213. // angle = angle % Tools.TwoPi;
  68214. // angle = (angle + Tools.TwoPi) % Tools.TwoPi;
  68215. //if (angle > Math.PI) {
  68216. // angle -= Tools.TwoPi;
  68217. //}
  68218. angle -= (Scalar.TwoPi * Math.floor((angle + Math.PI) / Scalar.TwoPi));
  68219. return angle;
  68220. };
  68221. /**
  68222. * Two pi constants convenient for computation.
  68223. */
  68224. Scalar.TwoPi = Math.PI * 2;
  68225. return Scalar;
  68226. }());
  68227. /***/ }),
  68228. /***/ "./Maths/math.ts":
  68229. /*!***********************!*\
  68230. !*** ./Maths/math.ts ***!
  68231. \***********************/
  68232. /*! 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 */
  68233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  68234. "use strict";
  68235. __webpack_require__.r(__webpack_exports__);
  68236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return ToGammaSpace; });
  68237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return ToLinearSpace; });
  68238. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return Epsilon; });
  68239. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return Color3; });
  68240. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return Color4; });
  68241. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return Vector2; });
  68242. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return Vector3; });
  68243. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return Vector4; });
  68244. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return Size; });
  68245. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return Quaternion; });
  68246. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return Matrix; });
  68247. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return Plane; });
  68248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return Viewport; });
  68249. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return Frustum; });
  68250. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return Space; });
  68251. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return Axis; });
  68252. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return BezierCurve; });
  68253. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return Orientation; });
  68254. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return Angle; });
  68255. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return Arc2; });
  68256. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return Path2; });
  68257. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return Path3D; });
  68258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return Curve3; });
  68259. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return PositionNormalVertex; });
  68260. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return PositionNormalTextureVertex; });
  68261. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return Tmp; });
  68262. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  68263. /* harmony import */ var _math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./math.scalar */ "./Maths/math.scalar.ts");
  68264. /**
  68265. * Constant used to convert a value to gamma space
  68266. * @ignorenaming
  68267. */
  68268. var ToGammaSpace = 1 / 2.2;
  68269. /**
  68270. * Constant used to convert a value to linear space
  68271. * @ignorenaming
  68272. */
  68273. var ToLinearSpace = 2.2;
  68274. /**
  68275. * Constant used to define the minimal number value in Babylon.js
  68276. * @ignorenaming
  68277. */
  68278. var Epsilon = 0.001;
  68279. /**
  68280. * Class used to hold a RBG color
  68281. */
  68282. var Color3 = /** @class */ (function () {
  68283. /**
  68284. * Creates a new Color3 object from red, green, blue values, all between 0 and 1
  68285. * @param r defines the red component (between 0 and 1, default is 0)
  68286. * @param g defines the green component (between 0 and 1, default is 0)
  68287. * @param b defines the blue component (between 0 and 1, default is 0)
  68288. */
  68289. function Color3(
  68290. /**
  68291. * Defines the red component (between 0 and 1, default is 0)
  68292. */
  68293. r,
  68294. /**
  68295. * Defines the green component (between 0 and 1, default is 0)
  68296. */
  68297. g,
  68298. /**
  68299. * Defines the blue component (between 0 and 1, default is 0)
  68300. */
  68301. b) {
  68302. if (r === void 0) { r = 0; }
  68303. if (g === void 0) { g = 0; }
  68304. if (b === void 0) { b = 0; }
  68305. this.r = r;
  68306. this.g = g;
  68307. this.b = b;
  68308. }
  68309. /**
  68310. * Creates a string with the Color3 current values
  68311. * @returns the string representation of the Color3 object
  68312. */
  68313. Color3.prototype.toString = function () {
  68314. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + "}";
  68315. };
  68316. /**
  68317. * Returns the string "Color3"
  68318. * @returns "Color3"
  68319. */
  68320. Color3.prototype.getClassName = function () {
  68321. return "Color3";
  68322. };
  68323. /**
  68324. * Compute the Color3 hash code
  68325. * @returns an unique number that can be used to hash Color3 objects
  68326. */
  68327. Color3.prototype.getHashCode = function () {
  68328. var hash = this.r || 0;
  68329. hash = (hash * 397) ^ (this.g || 0);
  68330. hash = (hash * 397) ^ (this.b || 0);
  68331. return hash;
  68332. };
  68333. // Operators
  68334. /**
  68335. * Stores in the given array from the given starting index the red, green, blue values as successive elements
  68336. * @param array defines the array where to store the r,g,b components
  68337. * @param index defines an optional index in the target array to define where to start storing values
  68338. * @returns the current Color3 object
  68339. */
  68340. Color3.prototype.toArray = function (array, index) {
  68341. if (index === void 0) { index = 0; }
  68342. array[index] = this.r;
  68343. array[index + 1] = this.g;
  68344. array[index + 2] = this.b;
  68345. return this;
  68346. };
  68347. /**
  68348. * Returns a new Color4 object from the current Color3 and the given alpha
  68349. * @param alpha defines the alpha component on the new Color4 object (default is 1)
  68350. * @returns a new Color4 object
  68351. */
  68352. Color3.prototype.toColor4 = function (alpha) {
  68353. if (alpha === void 0) { alpha = 1; }
  68354. return new Color4(this.r, this.g, this.b, alpha);
  68355. };
  68356. /**
  68357. * Returns a new array populated with 3 numeric elements : red, green and blue values
  68358. * @returns the new array
  68359. */
  68360. Color3.prototype.asArray = function () {
  68361. var result = new Array();
  68362. this.toArray(result, 0);
  68363. return result;
  68364. };
  68365. /**
  68366. * Returns the luminance value
  68367. * @returns a float value
  68368. */
  68369. Color3.prototype.toLuminance = function () {
  68370. return this.r * 0.3 + this.g * 0.59 + this.b * 0.11;
  68371. };
  68372. /**
  68373. * Multiply each Color3 rgb values by the given Color3 rgb values in a new Color3 object
  68374. * @param otherColor defines the second operand
  68375. * @returns the new Color3 object
  68376. */
  68377. Color3.prototype.multiply = function (otherColor) {
  68378. return new Color3(this.r * otherColor.r, this.g * otherColor.g, this.b * otherColor.b);
  68379. };
  68380. /**
  68381. * Multiply the rgb values of the Color3 and the given Color3 and stores the result in the object "result"
  68382. * @param otherColor defines the second operand
  68383. * @param result defines the Color3 object where to store the result
  68384. * @returns the current Color3
  68385. */
  68386. Color3.prototype.multiplyToRef = function (otherColor, result) {
  68387. result.r = this.r * otherColor.r;
  68388. result.g = this.g * otherColor.g;
  68389. result.b = this.b * otherColor.b;
  68390. return this;
  68391. };
  68392. /**
  68393. * Determines equality between Color3 objects
  68394. * @param otherColor defines the second operand
  68395. * @returns true if the rgb values are equal to the given ones
  68396. */
  68397. Color3.prototype.equals = function (otherColor) {
  68398. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b;
  68399. };
  68400. /**
  68401. * Determines equality between the current Color3 object and a set of r,b,g values
  68402. * @param r defines the red component to check
  68403. * @param g defines the green component to check
  68404. * @param b defines the blue component to check
  68405. * @returns true if the rgb values are equal to the given ones
  68406. */
  68407. Color3.prototype.equalsFloats = function (r, g, b) {
  68408. return this.r === r && this.g === g && this.b === b;
  68409. };
  68410. /**
  68411. * Multiplies in place each rgb value by scale
  68412. * @param scale defines the scaling factor
  68413. * @returns the updated Color3
  68414. */
  68415. Color3.prototype.scale = function (scale) {
  68416. return new Color3(this.r * scale, this.g * scale, this.b * scale);
  68417. };
  68418. /**
  68419. * Multiplies the rgb values by scale and stores the result into "result"
  68420. * @param scale defines the scaling factor
  68421. * @param result defines the Color3 object where to store the result
  68422. * @returns the unmodified current Color3
  68423. */
  68424. Color3.prototype.scaleToRef = function (scale, result) {
  68425. result.r = this.r * scale;
  68426. result.g = this.g * scale;
  68427. result.b = this.b * scale;
  68428. return this;
  68429. };
  68430. /**
  68431. * Scale the current Color3 values by a factor and add the result to a given Color3
  68432. * @param scale defines the scale factor
  68433. * @param result defines color to store the result into
  68434. * @returns the unmodified current Color3
  68435. */
  68436. Color3.prototype.scaleAndAddToRef = function (scale, result) {
  68437. result.r += this.r * scale;
  68438. result.g += this.g * scale;
  68439. result.b += this.b * scale;
  68440. return this;
  68441. };
  68442. /**
  68443. * Clamps the rgb values by the min and max values and stores the result into "result"
  68444. * @param min defines minimum clamping value (default is 0)
  68445. * @param max defines maximum clamping value (default is 1)
  68446. * @param result defines color to store the result into
  68447. * @returns the original Color3
  68448. */
  68449. Color3.prototype.clampToRef = function (min, max, result) {
  68450. if (min === void 0) { min = 0; }
  68451. if (max === void 0) { max = 1; }
  68452. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68453. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68454. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68455. return this;
  68456. };
  68457. /**
  68458. * Creates a new Color3 set with the added values of the current Color3 and of the given one
  68459. * @param otherColor defines the second operand
  68460. * @returns the new Color3
  68461. */
  68462. Color3.prototype.add = function (otherColor) {
  68463. return new Color3(this.r + otherColor.r, this.g + otherColor.g, this.b + otherColor.b);
  68464. };
  68465. /**
  68466. * Stores the result of the addition of the current Color3 and given one rgb values into "result"
  68467. * @param otherColor defines the second operand
  68468. * @param result defines Color3 object to store the result into
  68469. * @returns the unmodified current Color3
  68470. */
  68471. Color3.prototype.addToRef = function (otherColor, result) {
  68472. result.r = this.r + otherColor.r;
  68473. result.g = this.g + otherColor.g;
  68474. result.b = this.b + otherColor.b;
  68475. return this;
  68476. };
  68477. /**
  68478. * Returns a new Color3 set with the subtracted values of the given one from the current Color3
  68479. * @param otherColor defines the second operand
  68480. * @returns the new Color3
  68481. */
  68482. Color3.prototype.subtract = function (otherColor) {
  68483. return new Color3(this.r - otherColor.r, this.g - otherColor.g, this.b - otherColor.b);
  68484. };
  68485. /**
  68486. * Stores the result of the subtraction of given one from the current Color3 rgb values into "result"
  68487. * @param otherColor defines the second operand
  68488. * @param result defines Color3 object to store the result into
  68489. * @returns the unmodified current Color3
  68490. */
  68491. Color3.prototype.subtractToRef = function (otherColor, result) {
  68492. result.r = this.r - otherColor.r;
  68493. result.g = this.g - otherColor.g;
  68494. result.b = this.b - otherColor.b;
  68495. return this;
  68496. };
  68497. /**
  68498. * Copy the current object
  68499. * @returns a new Color3 copied the current one
  68500. */
  68501. Color3.prototype.clone = function () {
  68502. return new Color3(this.r, this.g, this.b);
  68503. };
  68504. /**
  68505. * Copies the rgb values from the source in the current Color3
  68506. * @param source defines the source Color3 object
  68507. * @returns the updated Color3 object
  68508. */
  68509. Color3.prototype.copyFrom = function (source) {
  68510. this.r = source.r;
  68511. this.g = source.g;
  68512. this.b = source.b;
  68513. return this;
  68514. };
  68515. /**
  68516. * Updates the Color3 rgb values from the given floats
  68517. * @param r defines the red component to read from
  68518. * @param g defines the green component to read from
  68519. * @param b defines the blue component to read from
  68520. * @returns the current Color3 object
  68521. */
  68522. Color3.prototype.copyFromFloats = function (r, g, b) {
  68523. this.r = r;
  68524. this.g = g;
  68525. this.b = b;
  68526. return this;
  68527. };
  68528. /**
  68529. * Updates the Color3 rgb values from the given floats
  68530. * @param r defines the red component to read from
  68531. * @param g defines the green component to read from
  68532. * @param b defines the blue component to read from
  68533. * @returns the current Color3 object
  68534. */
  68535. Color3.prototype.set = function (r, g, b) {
  68536. return this.copyFromFloats(r, g, b);
  68537. };
  68538. /**
  68539. * Compute the Color3 hexadecimal code as a string
  68540. * @returns a string containing the hexadecimal representation of the Color3 object
  68541. */
  68542. Color3.prototype.toHexString = function () {
  68543. var intR = (this.r * 255) | 0;
  68544. var intG = (this.g * 255) | 0;
  68545. var intB = (this.b * 255) | 0;
  68546. 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);
  68547. };
  68548. /**
  68549. * Computes a new Color3 converted from the current one to linear space
  68550. * @returns a new Color3 object
  68551. */
  68552. Color3.prototype.toLinearSpace = function () {
  68553. var convertedColor = new Color3();
  68554. this.toLinearSpaceToRef(convertedColor);
  68555. return convertedColor;
  68556. };
  68557. /**
  68558. * Converts the Color3 values to linear space and stores the result in "convertedColor"
  68559. * @param convertedColor defines the Color3 object where to store the linear space version
  68560. * @returns the unmodified Color3
  68561. */
  68562. Color3.prototype.toLinearSpaceToRef = function (convertedColor) {
  68563. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68564. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68565. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68566. return this;
  68567. };
  68568. /**
  68569. * Computes a new Color3 converted from the current one to gamma space
  68570. * @returns a new Color3 object
  68571. */
  68572. Color3.prototype.toGammaSpace = function () {
  68573. var convertedColor = new Color3();
  68574. this.toGammaSpaceToRef(convertedColor);
  68575. return convertedColor;
  68576. };
  68577. /**
  68578. * Converts the Color3 values to gamma space and stores the result in "convertedColor"
  68579. * @param convertedColor defines the Color3 object where to store the gamma space version
  68580. * @returns the unmodified Color3
  68581. */
  68582. Color3.prototype.toGammaSpaceToRef = function (convertedColor) {
  68583. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  68584. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  68585. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  68586. return this;
  68587. };
  68588. /**
  68589. * Creates a new Color3 from the string containing valid hexadecimal values
  68590. * @param hex defines a string containing valid hexadecimal values
  68591. * @returns a new Color3 object
  68592. */
  68593. Color3.FromHexString = function (hex) {
  68594. if (hex.substring(0, 1) !== "#" || hex.length !== 7) {
  68595. return new Color3(0, 0, 0);
  68596. }
  68597. var r = parseInt(hex.substring(1, 3), 16);
  68598. var g = parseInt(hex.substring(3, 5), 16);
  68599. var b = parseInt(hex.substring(5, 7), 16);
  68600. return Color3.FromInts(r, g, b);
  68601. };
  68602. /**
  68603. * Creates a new Vector3 from the starting index of the given array
  68604. * @param array defines the source array
  68605. * @param offset defines an offset in the source array
  68606. * @returns a new Color3 object
  68607. */
  68608. Color3.FromArray = function (array, offset) {
  68609. if (offset === void 0) { offset = 0; }
  68610. return new Color3(array[offset], array[offset + 1], array[offset + 2]);
  68611. };
  68612. /**
  68613. * Creates a new Color3 from integer values (< 256)
  68614. * @param r defines the red component to read from (value between 0 and 255)
  68615. * @param g defines the green component to read from (value between 0 and 255)
  68616. * @param b defines the blue component to read from (value between 0 and 255)
  68617. * @returns a new Color3 object
  68618. */
  68619. Color3.FromInts = function (r, g, b) {
  68620. return new Color3(r / 255.0, g / 255.0, b / 255.0);
  68621. };
  68622. /**
  68623. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68624. * @param start defines the start Color3 value
  68625. * @param end defines the end Color3 value
  68626. * @param amount defines the gradient value between start and end
  68627. * @returns a new Color3 object
  68628. */
  68629. Color3.Lerp = function (start, end, amount) {
  68630. var result = new Color3(0.0, 0.0, 0.0);
  68631. Color3.LerpToRef(start, end, amount, result);
  68632. return result;
  68633. };
  68634. /**
  68635. * Creates a new Color3 with values linearly interpolated of "amount" between the start Color3 and the end Color3
  68636. * @param left defines the start value
  68637. * @param right defines the end value
  68638. * @param amount defines the gradient factor
  68639. * @param result defines the Color3 object where to store the result
  68640. */
  68641. Color3.LerpToRef = function (left, right, amount, result) {
  68642. result.r = left.r + ((right.r - left.r) * amount);
  68643. result.g = left.g + ((right.g - left.g) * amount);
  68644. result.b = left.b + ((right.b - left.b) * amount);
  68645. };
  68646. /**
  68647. * Returns a Color3 value containing a red color
  68648. * @returns a new Color3 object
  68649. */
  68650. Color3.Red = function () { return new Color3(1, 0, 0); };
  68651. /**
  68652. * Returns a Color3 value containing a green color
  68653. * @returns a new Color3 object
  68654. */
  68655. Color3.Green = function () { return new Color3(0, 1, 0); };
  68656. /**
  68657. * Returns a Color3 value containing a blue color
  68658. * @returns a new Color3 object
  68659. */
  68660. Color3.Blue = function () { return new Color3(0, 0, 1); };
  68661. /**
  68662. * Returns a Color3 value containing a black color
  68663. * @returns a new Color3 object
  68664. */
  68665. Color3.Black = function () { return new Color3(0, 0, 0); };
  68666. Object.defineProperty(Color3, "BlackReadOnly", {
  68667. /**
  68668. * Gets a Color3 value containing a black color that must not be updated
  68669. */
  68670. get: function () {
  68671. return Color3._BlackReadOnly;
  68672. },
  68673. enumerable: true,
  68674. configurable: true
  68675. });
  68676. /**
  68677. * Returns a Color3 value containing a white color
  68678. * @returns a new Color3 object
  68679. */
  68680. Color3.White = function () { return new Color3(1, 1, 1); };
  68681. /**
  68682. * Returns a Color3 value containing a purple color
  68683. * @returns a new Color3 object
  68684. */
  68685. Color3.Purple = function () { return new Color3(0.5, 0, 0.5); };
  68686. /**
  68687. * Returns a Color3 value containing a magenta color
  68688. * @returns a new Color3 object
  68689. */
  68690. Color3.Magenta = function () { return new Color3(1, 0, 1); };
  68691. /**
  68692. * Returns a Color3 value containing a yellow color
  68693. * @returns a new Color3 object
  68694. */
  68695. Color3.Yellow = function () { return new Color3(1, 1, 0); };
  68696. /**
  68697. * Returns a Color3 value containing a gray color
  68698. * @returns a new Color3 object
  68699. */
  68700. Color3.Gray = function () { return new Color3(0.5, 0.5, 0.5); };
  68701. /**
  68702. * Returns a Color3 value containing a teal color
  68703. * @returns a new Color3 object
  68704. */
  68705. Color3.Teal = function () { return new Color3(0, 1.0, 1.0); };
  68706. /**
  68707. * Returns a Color3 value containing a random color
  68708. * @returns a new Color3 object
  68709. */
  68710. Color3.Random = function () { return new Color3(Math.random(), Math.random(), Math.random()); };
  68711. // Statics
  68712. Color3._BlackReadOnly = Color3.Black();
  68713. return Color3;
  68714. }());
  68715. /**
  68716. * Class used to hold a RBGA color
  68717. */
  68718. var Color4 = /** @class */ (function () {
  68719. /**
  68720. * Creates a new Color4 object from red, green, blue values, all between 0 and 1
  68721. * @param r defines the red component (between 0 and 1, default is 0)
  68722. * @param g defines the green component (between 0 and 1, default is 0)
  68723. * @param b defines the blue component (between 0 and 1, default is 0)
  68724. * @param a defines the alpha component (between 0 and 1, default is 1)
  68725. */
  68726. function Color4(
  68727. /**
  68728. * Defines the red component (between 0 and 1, default is 0)
  68729. */
  68730. r,
  68731. /**
  68732. * Defines the green component (between 0 and 1, default is 0)
  68733. */
  68734. g,
  68735. /**
  68736. * Defines the blue component (between 0 and 1, default is 0)
  68737. */
  68738. b,
  68739. /**
  68740. * Defines the alpha component (between 0 and 1, default is 1)
  68741. */
  68742. a) {
  68743. if (r === void 0) { r = 0; }
  68744. if (g === void 0) { g = 0; }
  68745. if (b === void 0) { b = 0; }
  68746. if (a === void 0) { a = 1; }
  68747. this.r = r;
  68748. this.g = g;
  68749. this.b = b;
  68750. this.a = a;
  68751. }
  68752. // Operators
  68753. /**
  68754. * Adds in place the given Color4 values to the current Color4 object
  68755. * @param right defines the second operand
  68756. * @returns the current updated Color4 object
  68757. */
  68758. Color4.prototype.addInPlace = function (right) {
  68759. this.r += right.r;
  68760. this.g += right.g;
  68761. this.b += right.b;
  68762. this.a += right.a;
  68763. return this;
  68764. };
  68765. /**
  68766. * Creates a new array populated with 4 numeric elements : red, green, blue, alpha values
  68767. * @returns the new array
  68768. */
  68769. Color4.prototype.asArray = function () {
  68770. var result = new Array();
  68771. this.toArray(result, 0);
  68772. return result;
  68773. };
  68774. /**
  68775. * Stores from the starting index in the given array the Color4 successive values
  68776. * @param array defines the array where to store the r,g,b components
  68777. * @param index defines an optional index in the target array to define where to start storing values
  68778. * @returns the current Color4 object
  68779. */
  68780. Color4.prototype.toArray = function (array, index) {
  68781. if (index === void 0) { index = 0; }
  68782. array[index] = this.r;
  68783. array[index + 1] = this.g;
  68784. array[index + 2] = this.b;
  68785. array[index + 3] = this.a;
  68786. return this;
  68787. };
  68788. /**
  68789. * Determines equality between Color4 objects
  68790. * @param otherColor defines the second operand
  68791. * @returns true if the rgba values are equal to the given ones
  68792. */
  68793. Color4.prototype.equals = function (otherColor) {
  68794. return otherColor && this.r === otherColor.r && this.g === otherColor.g && this.b === otherColor.b && this.a === otherColor.a;
  68795. };
  68796. /**
  68797. * Creates a new Color4 set with the added values of the current Color4 and of the given one
  68798. * @param right defines the second operand
  68799. * @returns a new Color4 object
  68800. */
  68801. Color4.prototype.add = function (right) {
  68802. return new Color4(this.r + right.r, this.g + right.g, this.b + right.b, this.a + right.a);
  68803. };
  68804. /**
  68805. * Creates a new Color4 set with the subtracted values of the given one from the current Color4
  68806. * @param right defines the second operand
  68807. * @returns a new Color4 object
  68808. */
  68809. Color4.prototype.subtract = function (right) {
  68810. return new Color4(this.r - right.r, this.g - right.g, this.b - right.b, this.a - right.a);
  68811. };
  68812. /**
  68813. * Subtracts the given ones from the current Color4 values and stores the results in "result"
  68814. * @param right defines the second operand
  68815. * @param result defines the Color4 object where to store the result
  68816. * @returns the current Color4 object
  68817. */
  68818. Color4.prototype.subtractToRef = function (right, result) {
  68819. result.r = this.r - right.r;
  68820. result.g = this.g - right.g;
  68821. result.b = this.b - right.b;
  68822. result.a = this.a - right.a;
  68823. return this;
  68824. };
  68825. /**
  68826. * Creates a new Color4 with the current Color4 values multiplied by scale
  68827. * @param scale defines the scaling factor to apply
  68828. * @returns a new Color4 object
  68829. */
  68830. Color4.prototype.scale = function (scale) {
  68831. return new Color4(this.r * scale, this.g * scale, this.b * scale, this.a * scale);
  68832. };
  68833. /**
  68834. * Multiplies the current Color4 values by scale and stores the result in "result"
  68835. * @param scale defines the scaling factor to apply
  68836. * @param result defines the Color4 object where to store the result
  68837. * @returns the current unmodified Color4
  68838. */
  68839. Color4.prototype.scaleToRef = function (scale, result) {
  68840. result.r = this.r * scale;
  68841. result.g = this.g * scale;
  68842. result.b = this.b * scale;
  68843. result.a = this.a * scale;
  68844. return this;
  68845. };
  68846. /**
  68847. * Scale the current Color4 values by a factor and add the result to a given Color4
  68848. * @param scale defines the scale factor
  68849. * @param result defines the Color4 object where to store the result
  68850. * @returns the unmodified current Color4
  68851. */
  68852. Color4.prototype.scaleAndAddToRef = function (scale, result) {
  68853. result.r += this.r * scale;
  68854. result.g += this.g * scale;
  68855. result.b += this.b * scale;
  68856. result.a += this.a * scale;
  68857. return this;
  68858. };
  68859. /**
  68860. * Clamps the rgb values by the min and max values and stores the result into "result"
  68861. * @param min defines minimum clamping value (default is 0)
  68862. * @param max defines maximum clamping value (default is 1)
  68863. * @param result defines color to store the result into.
  68864. * @returns the cuurent Color4
  68865. */
  68866. Color4.prototype.clampToRef = function (min, max, result) {
  68867. if (min === void 0) { min = 0; }
  68868. if (max === void 0) { max = 1; }
  68869. result.r = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.r, min, max);
  68870. result.g = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.g, min, max);
  68871. result.b = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.b, min, max);
  68872. result.a = _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(this.a, min, max);
  68873. return this;
  68874. };
  68875. /**
  68876. * Multipy an Color4 value by another and return a new Color4 object
  68877. * @param color defines the Color4 value to multiply by
  68878. * @returns a new Color4 object
  68879. */
  68880. Color4.prototype.multiply = function (color) {
  68881. return new Color4(this.r * color.r, this.g * color.g, this.b * color.b, this.a * color.a);
  68882. };
  68883. /**
  68884. * Multipy a Color4 value by another and push the result in a reference value
  68885. * @param color defines the Color4 value to multiply by
  68886. * @param result defines the Color4 to fill the result in
  68887. * @returns the result Color4
  68888. */
  68889. Color4.prototype.multiplyToRef = function (color, result) {
  68890. result.r = this.r * color.r;
  68891. result.g = this.g * color.g;
  68892. result.b = this.b * color.b;
  68893. result.a = this.a * color.a;
  68894. return result;
  68895. };
  68896. /**
  68897. * Creates a string with the Color4 current values
  68898. * @returns the string representation of the Color4 object
  68899. */
  68900. Color4.prototype.toString = function () {
  68901. return "{R: " + this.r + " G:" + this.g + " B:" + this.b + " A:" + this.a + "}";
  68902. };
  68903. /**
  68904. * Returns the string "Color4"
  68905. * @returns "Color4"
  68906. */
  68907. Color4.prototype.getClassName = function () {
  68908. return "Color4";
  68909. };
  68910. /**
  68911. * Compute the Color4 hash code
  68912. * @returns an unique number that can be used to hash Color4 objects
  68913. */
  68914. Color4.prototype.getHashCode = function () {
  68915. var hash = this.r || 0;
  68916. hash = (hash * 397) ^ (this.g || 0);
  68917. hash = (hash * 397) ^ (this.b || 0);
  68918. hash = (hash * 397) ^ (this.a || 0);
  68919. return hash;
  68920. };
  68921. /**
  68922. * Creates a new Color4 copied from the current one
  68923. * @returns a new Color4 object
  68924. */
  68925. Color4.prototype.clone = function () {
  68926. return new Color4(this.r, this.g, this.b, this.a);
  68927. };
  68928. /**
  68929. * Copies the given Color4 values into the current one
  68930. * @param source defines the source Color4 object
  68931. * @returns the current updated Color4 object
  68932. */
  68933. Color4.prototype.copyFrom = function (source) {
  68934. this.r = source.r;
  68935. this.g = source.g;
  68936. this.b = source.b;
  68937. this.a = source.a;
  68938. return this;
  68939. };
  68940. /**
  68941. * Copies the given float values into the current one
  68942. * @param r defines the red component to read from
  68943. * @param g defines the green component to read from
  68944. * @param b defines the blue component to read from
  68945. * @param a defines the alpha component to read from
  68946. * @returns the current updated Color4 object
  68947. */
  68948. Color4.prototype.copyFromFloats = function (r, g, b, a) {
  68949. this.r = r;
  68950. this.g = g;
  68951. this.b = b;
  68952. this.a = a;
  68953. return this;
  68954. };
  68955. /**
  68956. * Copies the given float values into the current one
  68957. * @param r defines the red component to read from
  68958. * @param g defines the green component to read from
  68959. * @param b defines the blue component to read from
  68960. * @param a defines the alpha component to read from
  68961. * @returns the current updated Color4 object
  68962. */
  68963. Color4.prototype.set = function (r, g, b, a) {
  68964. return this.copyFromFloats(r, g, b, a);
  68965. };
  68966. /**
  68967. * Compute the Color4 hexadecimal code as a string
  68968. * @returns a string containing the hexadecimal representation of the Color4 object
  68969. */
  68970. Color4.prototype.toHexString = function () {
  68971. var intR = (this.r * 255) | 0;
  68972. var intG = (this.g * 255) | 0;
  68973. var intB = (this.b * 255) | 0;
  68974. var intA = (this.a * 255) | 0;
  68975. 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);
  68976. };
  68977. /**
  68978. * Computes a new Color4 converted from the current one to linear space
  68979. * @returns a new Color4 object
  68980. */
  68981. Color4.prototype.toLinearSpace = function () {
  68982. var convertedColor = new Color4();
  68983. this.toLinearSpaceToRef(convertedColor);
  68984. return convertedColor;
  68985. };
  68986. /**
  68987. * Converts the Color4 values to linear space and stores the result in "convertedColor"
  68988. * @param convertedColor defines the Color4 object where to store the linear space version
  68989. * @returns the unmodified Color4
  68990. */
  68991. Color4.prototype.toLinearSpaceToRef = function (convertedColor) {
  68992. convertedColor.r = Math.pow(this.r, ToLinearSpace);
  68993. convertedColor.g = Math.pow(this.g, ToLinearSpace);
  68994. convertedColor.b = Math.pow(this.b, ToLinearSpace);
  68995. convertedColor.a = this.a;
  68996. return this;
  68997. };
  68998. /**
  68999. * Computes a new Color4 converted from the current one to gamma space
  69000. * @returns a new Color4 object
  69001. */
  69002. Color4.prototype.toGammaSpace = function () {
  69003. var convertedColor = new Color4();
  69004. this.toGammaSpaceToRef(convertedColor);
  69005. return convertedColor;
  69006. };
  69007. /**
  69008. * Converts the Color4 values to gamma space and stores the result in "convertedColor"
  69009. * @param convertedColor defines the Color4 object where to store the gamma space version
  69010. * @returns the unmodified Color4
  69011. */
  69012. Color4.prototype.toGammaSpaceToRef = function (convertedColor) {
  69013. convertedColor.r = Math.pow(this.r, ToGammaSpace);
  69014. convertedColor.g = Math.pow(this.g, ToGammaSpace);
  69015. convertedColor.b = Math.pow(this.b, ToGammaSpace);
  69016. convertedColor.a = this.a;
  69017. return this;
  69018. };
  69019. // Statics
  69020. /**
  69021. * Creates a new Color4 from the string containing valid hexadecimal values
  69022. * @param hex defines a string containing valid hexadecimal values
  69023. * @returns a new Color4 object
  69024. */
  69025. Color4.FromHexString = function (hex) {
  69026. if (hex.substring(0, 1) !== "#" || hex.length !== 9) {
  69027. return new Color4(0.0, 0.0, 0.0, 0.0);
  69028. }
  69029. var r = parseInt(hex.substring(1, 3), 16);
  69030. var g = parseInt(hex.substring(3, 5), 16);
  69031. var b = parseInt(hex.substring(5, 7), 16);
  69032. var a = parseInt(hex.substring(7, 9), 16);
  69033. return Color4.FromInts(r, g, b, a);
  69034. };
  69035. /**
  69036. * Creates a new Color4 object set with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69037. * @param left defines the start value
  69038. * @param right defines the end value
  69039. * @param amount defines the gradient factor
  69040. * @returns a new Color4 object
  69041. */
  69042. Color4.Lerp = function (left, right, amount) {
  69043. var result = new Color4(0.0, 0.0, 0.0, 0.0);
  69044. Color4.LerpToRef(left, right, amount, result);
  69045. return result;
  69046. };
  69047. /**
  69048. * Set the given "result" with the linearly interpolated values of "amount" between the left Color4 object and the right Color4 object
  69049. * @param left defines the start value
  69050. * @param right defines the end value
  69051. * @param amount defines the gradient factor
  69052. * @param result defines the Color4 object where to store data
  69053. */
  69054. Color4.LerpToRef = function (left, right, amount, result) {
  69055. result.r = left.r + (right.r - left.r) * amount;
  69056. result.g = left.g + (right.g - left.g) * amount;
  69057. result.b = left.b + (right.b - left.b) * amount;
  69058. result.a = left.a + (right.a - left.a) * amount;
  69059. };
  69060. /**
  69061. * Creates a new Color4 from a Color3 and an alpha value
  69062. * @param color3 defines the source Color3 to read from
  69063. * @param alpha defines the alpha component (1.0 by default)
  69064. * @returns a new Color4 object
  69065. */
  69066. Color4.FromColor3 = function (color3, alpha) {
  69067. if (alpha === void 0) { alpha = 1.0; }
  69068. return new Color4(color3.r, color3.g, color3.b, alpha);
  69069. };
  69070. /**
  69071. * Creates a new Color4 from the starting index element of the given array
  69072. * @param array defines the source array to read from
  69073. * @param offset defines the offset in the source array
  69074. * @returns a new Color4 object
  69075. */
  69076. Color4.FromArray = function (array, offset) {
  69077. if (offset === void 0) { offset = 0; }
  69078. return new Color4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  69079. };
  69080. /**
  69081. * Creates a new Color3 from integer values (< 256)
  69082. * @param r defines the red component to read from (value between 0 and 255)
  69083. * @param g defines the green component to read from (value between 0 and 255)
  69084. * @param b defines the blue component to read from (value between 0 and 255)
  69085. * @param a defines the alpha component to read from (value between 0 and 255)
  69086. * @returns a new Color3 object
  69087. */
  69088. Color4.FromInts = function (r, g, b, a) {
  69089. return new Color4(r / 255.0, g / 255.0, b / 255.0, a / 255.0);
  69090. };
  69091. /**
  69092. * Check the content of a given array and convert it to an array containing RGBA data
  69093. * If the original array was already containing count * 4 values then it is returned directly
  69094. * @param colors defines the array to check
  69095. * @param count defines the number of RGBA data to expect
  69096. * @returns an array containing count * 4 values (RGBA)
  69097. */
  69098. Color4.CheckColors4 = function (colors, count) {
  69099. // Check if color3 was used
  69100. if (colors.length === count * 3) {
  69101. var colors4 = [];
  69102. for (var index = 0; index < colors.length; index += 3) {
  69103. var newIndex = (index / 3) * 4;
  69104. colors4[newIndex] = colors[index];
  69105. colors4[newIndex + 1] = colors[index + 1];
  69106. colors4[newIndex + 2] = colors[index + 2];
  69107. colors4[newIndex + 3] = 1.0;
  69108. }
  69109. return colors4;
  69110. }
  69111. return colors;
  69112. };
  69113. return Color4;
  69114. }());
  69115. /**
  69116. * Class representing a vector containing 2 coordinates
  69117. */
  69118. var Vector2 = /** @class */ (function () {
  69119. /**
  69120. * Creates a new Vector2 from the given x and y coordinates
  69121. * @param x defines the first coordinate
  69122. * @param y defines the second coordinate
  69123. */
  69124. function Vector2(
  69125. /** defines the first coordinate */
  69126. x,
  69127. /** defines the second coordinate */
  69128. y) {
  69129. if (x === void 0) { x = 0; }
  69130. if (y === void 0) { y = 0; }
  69131. this.x = x;
  69132. this.y = y;
  69133. }
  69134. /**
  69135. * Gets a string with the Vector2 coordinates
  69136. * @returns a string with the Vector2 coordinates
  69137. */
  69138. Vector2.prototype.toString = function () {
  69139. return "{X: " + this.x + " Y:" + this.y + "}";
  69140. };
  69141. /**
  69142. * Gets class name
  69143. * @returns the string "Vector2"
  69144. */
  69145. Vector2.prototype.getClassName = function () {
  69146. return "Vector2";
  69147. };
  69148. /**
  69149. * Gets current vector hash code
  69150. * @returns the Vector2 hash code as a number
  69151. */
  69152. Vector2.prototype.getHashCode = function () {
  69153. var hash = this.x || 0;
  69154. hash = (hash * 397) ^ (this.y || 0);
  69155. return hash;
  69156. };
  69157. // Operators
  69158. /**
  69159. * Sets the Vector2 coordinates in the given array or Float32Array from the given index.
  69160. * @param array defines the source array
  69161. * @param index defines the offset in source array
  69162. * @returns the current Vector2
  69163. */
  69164. Vector2.prototype.toArray = function (array, index) {
  69165. if (index === void 0) { index = 0; }
  69166. array[index] = this.x;
  69167. array[index + 1] = this.y;
  69168. return this;
  69169. };
  69170. /**
  69171. * Copy the current vector to an array
  69172. * @returns a new array with 2 elements: the Vector2 coordinates.
  69173. */
  69174. Vector2.prototype.asArray = function () {
  69175. var result = new Array();
  69176. this.toArray(result, 0);
  69177. return result;
  69178. };
  69179. /**
  69180. * Sets the Vector2 coordinates with the given Vector2 coordinates
  69181. * @param source defines the source Vector2
  69182. * @returns the current updated Vector2
  69183. */
  69184. Vector2.prototype.copyFrom = function (source) {
  69185. this.x = source.x;
  69186. this.y = source.y;
  69187. return this;
  69188. };
  69189. /**
  69190. * Sets the Vector2 coordinates with the given floats
  69191. * @param x defines the first coordinate
  69192. * @param y defines the second coordinate
  69193. * @returns the current updated Vector2
  69194. */
  69195. Vector2.prototype.copyFromFloats = function (x, y) {
  69196. this.x = x;
  69197. this.y = y;
  69198. return this;
  69199. };
  69200. /**
  69201. * Sets the Vector2 coordinates with the given floats
  69202. * @param x defines the first coordinate
  69203. * @param y defines the second coordinate
  69204. * @returns the current updated Vector2
  69205. */
  69206. Vector2.prototype.set = function (x, y) {
  69207. return this.copyFromFloats(x, y);
  69208. };
  69209. /**
  69210. * Add another vector with the current one
  69211. * @param otherVector defines the other vector
  69212. * @returns a new Vector2 set with the addition of the current Vector2 and the given one coordinates
  69213. */
  69214. Vector2.prototype.add = function (otherVector) {
  69215. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  69216. };
  69217. /**
  69218. * Sets the "result" coordinates with the addition of the current Vector2 and the given one coordinates
  69219. * @param otherVector defines the other vector
  69220. * @param result defines the target vector
  69221. * @returns the unmodified current Vector2
  69222. */
  69223. Vector2.prototype.addToRef = function (otherVector, result) {
  69224. result.x = this.x + otherVector.x;
  69225. result.y = this.y + otherVector.y;
  69226. return this;
  69227. };
  69228. /**
  69229. * Set the Vector2 coordinates by adding the given Vector2 coordinates
  69230. * @param otherVector defines the other vector
  69231. * @returns the current updated Vector2
  69232. */
  69233. Vector2.prototype.addInPlace = function (otherVector) {
  69234. this.x += otherVector.x;
  69235. this.y += otherVector.y;
  69236. return this;
  69237. };
  69238. /**
  69239. * Gets a new Vector2 by adding the current Vector2 coordinates to the given Vector3 x, y coordinates
  69240. * @param otherVector defines the other vector
  69241. * @returns a new Vector2
  69242. */
  69243. Vector2.prototype.addVector3 = function (otherVector) {
  69244. return new Vector2(this.x + otherVector.x, this.y + otherVector.y);
  69245. };
  69246. /**
  69247. * Gets a new Vector2 set with the subtracted coordinates of the given one from the current Vector2
  69248. * @param otherVector defines the other vector
  69249. * @returns a new Vector2
  69250. */
  69251. Vector2.prototype.subtract = function (otherVector) {
  69252. return new Vector2(this.x - otherVector.x, this.y - otherVector.y);
  69253. };
  69254. /**
  69255. * Sets the "result" coordinates with the subtraction of the given one from the current Vector2 coordinates.
  69256. * @param otherVector defines the other vector
  69257. * @param result defines the target vector
  69258. * @returns the unmodified current Vector2
  69259. */
  69260. Vector2.prototype.subtractToRef = function (otherVector, result) {
  69261. result.x = this.x - otherVector.x;
  69262. result.y = this.y - otherVector.y;
  69263. return this;
  69264. };
  69265. /**
  69266. * Sets the current Vector2 coordinates by subtracting from it the given one coordinates
  69267. * @param otherVector defines the other vector
  69268. * @returns the current updated Vector2
  69269. */
  69270. Vector2.prototype.subtractInPlace = function (otherVector) {
  69271. this.x -= otherVector.x;
  69272. this.y -= otherVector.y;
  69273. return this;
  69274. };
  69275. /**
  69276. * Multiplies in place the current Vector2 coordinates by the given ones
  69277. * @param otherVector defines the other vector
  69278. * @returns the current updated Vector2
  69279. */
  69280. Vector2.prototype.multiplyInPlace = function (otherVector) {
  69281. this.x *= otherVector.x;
  69282. this.y *= otherVector.y;
  69283. return this;
  69284. };
  69285. /**
  69286. * Returns a new Vector2 set with the multiplication of the current Vector2 and the given one coordinates
  69287. * @param otherVector defines the other vector
  69288. * @returns a new Vector2
  69289. */
  69290. Vector2.prototype.multiply = function (otherVector) {
  69291. return new Vector2(this.x * otherVector.x, this.y * otherVector.y);
  69292. };
  69293. /**
  69294. * Sets "result" coordinates with the multiplication of the current Vector2 and the given one coordinates
  69295. * @param otherVector defines the other vector
  69296. * @param result defines the target vector
  69297. * @returns the unmodified current Vector2
  69298. */
  69299. Vector2.prototype.multiplyToRef = function (otherVector, result) {
  69300. result.x = this.x * otherVector.x;
  69301. result.y = this.y * otherVector.y;
  69302. return this;
  69303. };
  69304. /**
  69305. * Gets a new Vector2 set with the Vector2 coordinates multiplied by the given floats
  69306. * @param x defines the first coordinate
  69307. * @param y defines the second coordinate
  69308. * @returns a new Vector2
  69309. */
  69310. Vector2.prototype.multiplyByFloats = function (x, y) {
  69311. return new Vector2(this.x * x, this.y * y);
  69312. };
  69313. /**
  69314. * Returns a new Vector2 set with the Vector2 coordinates divided by the given one coordinates
  69315. * @param otherVector defines the other vector
  69316. * @returns a new Vector2
  69317. */
  69318. Vector2.prototype.divide = function (otherVector) {
  69319. return new Vector2(this.x / otherVector.x, this.y / otherVector.y);
  69320. };
  69321. /**
  69322. * Sets the "result" coordinates with the Vector2 divided by the given one coordinates
  69323. * @param otherVector defines the other vector
  69324. * @param result defines the target vector
  69325. * @returns the unmodified current Vector2
  69326. */
  69327. Vector2.prototype.divideToRef = function (otherVector, result) {
  69328. result.x = this.x / otherVector.x;
  69329. result.y = this.y / otherVector.y;
  69330. return this;
  69331. };
  69332. /**
  69333. * Divides the current Vector2 coordinates by the given ones
  69334. * @param otherVector defines the other vector
  69335. * @returns the current updated Vector2
  69336. */
  69337. Vector2.prototype.divideInPlace = function (otherVector) {
  69338. return this.divideToRef(otherVector, this);
  69339. };
  69340. /**
  69341. * Gets a new Vector2 with current Vector2 negated coordinates
  69342. * @returns a new Vector2
  69343. */
  69344. Vector2.prototype.negate = function () {
  69345. return new Vector2(-this.x, -this.y);
  69346. };
  69347. /**
  69348. * Multiply the Vector2 coordinates by scale
  69349. * @param scale defines the scaling factor
  69350. * @returns the current updated Vector2
  69351. */
  69352. Vector2.prototype.scaleInPlace = function (scale) {
  69353. this.x *= scale;
  69354. this.y *= scale;
  69355. return this;
  69356. };
  69357. /**
  69358. * Returns a new Vector2 scaled by "scale" from the current Vector2
  69359. * @param scale defines the scaling factor
  69360. * @returns a new Vector2
  69361. */
  69362. Vector2.prototype.scale = function (scale) {
  69363. var result = new Vector2(0, 0);
  69364. this.scaleToRef(scale, result);
  69365. return result;
  69366. };
  69367. /**
  69368. * Scale the current Vector2 values by a factor to a given Vector2
  69369. * @param scale defines the scale factor
  69370. * @param result defines the Vector2 object where to store the result
  69371. * @returns the unmodified current Vector2
  69372. */
  69373. Vector2.prototype.scaleToRef = function (scale, result) {
  69374. result.x = this.x * scale;
  69375. result.y = this.y * scale;
  69376. return this;
  69377. };
  69378. /**
  69379. * Scale the current Vector2 values by a factor and add the result to a given Vector2
  69380. * @param scale defines the scale factor
  69381. * @param result defines the Vector2 object where to store the result
  69382. * @returns the unmodified current Vector2
  69383. */
  69384. Vector2.prototype.scaleAndAddToRef = function (scale, result) {
  69385. result.x += this.x * scale;
  69386. result.y += this.y * scale;
  69387. return this;
  69388. };
  69389. /**
  69390. * Gets a boolean if two vectors are equals
  69391. * @param otherVector defines the other vector
  69392. * @returns true if the given vector coordinates strictly equal the current Vector2 ones
  69393. */
  69394. Vector2.prototype.equals = function (otherVector) {
  69395. return otherVector && this.x === otherVector.x && this.y === otherVector.y;
  69396. };
  69397. /**
  69398. * Gets a boolean if two vectors are equals (using an epsilon value)
  69399. * @param otherVector defines the other vector
  69400. * @param epsilon defines the minimal distance to consider equality
  69401. * @returns true if the given vector coordinates are close to the current ones by a distance of epsilon.
  69402. */
  69403. Vector2.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69404. if (epsilon === void 0) { epsilon = Epsilon; }
  69405. 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);
  69406. };
  69407. /**
  69408. * Gets a new Vector2 from current Vector2 floored values
  69409. * @returns a new Vector2
  69410. */
  69411. Vector2.prototype.floor = function () {
  69412. return new Vector2(Math.floor(this.x), Math.floor(this.y));
  69413. };
  69414. /**
  69415. * Gets a new Vector2 from current Vector2 floored values
  69416. * @returns a new Vector2
  69417. */
  69418. Vector2.prototype.fract = function () {
  69419. return new Vector2(this.x - Math.floor(this.x), this.y - Math.floor(this.y));
  69420. };
  69421. // Properties
  69422. /**
  69423. * Gets the length of the vector
  69424. * @returns the vector length (float)
  69425. */
  69426. Vector2.prototype.length = function () {
  69427. return Math.sqrt(this.x * this.x + this.y * this.y);
  69428. };
  69429. /**
  69430. * Gets the vector squared length
  69431. * @returns the vector squared length (float)
  69432. */
  69433. Vector2.prototype.lengthSquared = function () {
  69434. return (this.x * this.x + this.y * this.y);
  69435. };
  69436. // Methods
  69437. /**
  69438. * Normalize the vector
  69439. * @returns the current updated Vector2
  69440. */
  69441. Vector2.prototype.normalize = function () {
  69442. var len = this.length();
  69443. if (len === 0) {
  69444. return this;
  69445. }
  69446. var num = 1.0 / len;
  69447. this.x *= num;
  69448. this.y *= num;
  69449. return this;
  69450. };
  69451. /**
  69452. * Gets a new Vector2 copied from the Vector2
  69453. * @returns a new Vector2
  69454. */
  69455. Vector2.prototype.clone = function () {
  69456. return new Vector2(this.x, this.y);
  69457. };
  69458. // Statics
  69459. /**
  69460. * Gets a new Vector2(0, 0)
  69461. * @returns a new Vector2
  69462. */
  69463. Vector2.Zero = function () {
  69464. return new Vector2(0, 0);
  69465. };
  69466. /**
  69467. * Gets a new Vector2(1, 1)
  69468. * @returns a new Vector2
  69469. */
  69470. Vector2.One = function () {
  69471. return new Vector2(1, 1);
  69472. };
  69473. /**
  69474. * Gets a new Vector2 set from the given index element of the given array
  69475. * @param array defines the data source
  69476. * @param offset defines the offset in the data source
  69477. * @returns a new Vector2
  69478. */
  69479. Vector2.FromArray = function (array, offset) {
  69480. if (offset === void 0) { offset = 0; }
  69481. return new Vector2(array[offset], array[offset + 1]);
  69482. };
  69483. /**
  69484. * Sets "result" from the given index element of the given array
  69485. * @param array defines the data source
  69486. * @param offset defines the offset in the data source
  69487. * @param result defines the target vector
  69488. */
  69489. Vector2.FromArrayToRef = function (array, offset, result) {
  69490. result.x = array[offset];
  69491. result.y = array[offset + 1];
  69492. };
  69493. /**
  69494. * Gets a new Vector2 located for "amount" (float) on the CatmullRom spline defined by the given four Vector2
  69495. * @param value1 defines 1st point of control
  69496. * @param value2 defines 2nd point of control
  69497. * @param value3 defines 3rd point of control
  69498. * @param value4 defines 4th point of control
  69499. * @param amount defines the interpolation factor
  69500. * @returns a new Vector2
  69501. */
  69502. Vector2.CatmullRom = function (value1, value2, value3, value4, amount) {
  69503. var squared = amount * amount;
  69504. var cubed = amount * squared;
  69505. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  69506. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  69507. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  69508. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  69509. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  69510. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  69511. return new Vector2(x, y);
  69512. };
  69513. /**
  69514. * 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".
  69515. * If a coordinate of "value" is lower than "min" coordinates, the returned Vector2 is given this "min" coordinate.
  69516. * If a coordinate of "value" is greater than "max" coordinates, the returned Vector2 is given this "max" coordinate
  69517. * @param value defines the value to clamp
  69518. * @param min defines the lower limit
  69519. * @param max defines the upper limit
  69520. * @returns a new Vector2
  69521. */
  69522. Vector2.Clamp = function (value, min, max) {
  69523. var x = value.x;
  69524. x = (x > max.x) ? max.x : x;
  69525. x = (x < min.x) ? min.x : x;
  69526. var y = value.y;
  69527. y = (y > max.y) ? max.y : y;
  69528. y = (y < min.y) ? min.y : y;
  69529. return new Vector2(x, y);
  69530. };
  69531. /**
  69532. * Returns a new Vector2 located for "amount" (float) on the Hermite spline defined by the vectors "value1", "value3", "tangent1", "tangent2"
  69533. * @param value1 defines the 1st control point
  69534. * @param tangent1 defines the outgoing tangent
  69535. * @param value2 defines the 2nd control point
  69536. * @param tangent2 defines the incoming tangent
  69537. * @param amount defines the interpolation factor
  69538. * @returns a new Vector2
  69539. */
  69540. Vector2.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  69541. var squared = amount * amount;
  69542. var cubed = amount * squared;
  69543. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  69544. var part2 = (-2.0 * cubed) + (3.0 * squared);
  69545. var part3 = (cubed - (2.0 * squared)) + amount;
  69546. var part4 = cubed - squared;
  69547. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  69548. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  69549. return new Vector2(x, y);
  69550. };
  69551. /**
  69552. * Returns a new Vector2 located for "amount" (float) on the linear interpolation between the vector "start" adn the vector "end".
  69553. * @param start defines the start vector
  69554. * @param end defines the end vector
  69555. * @param amount defines the interpolation factor
  69556. * @returns a new Vector2
  69557. */
  69558. Vector2.Lerp = function (start, end, amount) {
  69559. var x = start.x + ((end.x - start.x) * amount);
  69560. var y = start.y + ((end.y - start.y) * amount);
  69561. return new Vector2(x, y);
  69562. };
  69563. /**
  69564. * Gets the dot product of the vector "left" and the vector "right"
  69565. * @param left defines first vector
  69566. * @param right defines second vector
  69567. * @returns the dot product (float)
  69568. */
  69569. Vector2.Dot = function (left, right) {
  69570. return left.x * right.x + left.y * right.y;
  69571. };
  69572. /**
  69573. * Returns a new Vector2 equal to the normalized given vector
  69574. * @param vector defines the vector to normalize
  69575. * @returns a new Vector2
  69576. */
  69577. Vector2.Normalize = function (vector) {
  69578. var newVector = vector.clone();
  69579. newVector.normalize();
  69580. return newVector;
  69581. };
  69582. /**
  69583. * Gets a new Vector2 set with the minimal coordinate values from the "left" and "right" vectors
  69584. * @param left defines 1st vector
  69585. * @param right defines 2nd vector
  69586. * @returns a new Vector2
  69587. */
  69588. Vector2.Minimize = function (left, right) {
  69589. var x = (left.x < right.x) ? left.x : right.x;
  69590. var y = (left.y < right.y) ? left.y : right.y;
  69591. return new Vector2(x, y);
  69592. };
  69593. /**
  69594. * Gets a new Vecto2 set with the maximal coordinate values from the "left" and "right" vectors
  69595. * @param left defines 1st vector
  69596. * @param right defines 2nd vector
  69597. * @returns a new Vector2
  69598. */
  69599. Vector2.Maximize = function (left, right) {
  69600. var x = (left.x > right.x) ? left.x : right.x;
  69601. var y = (left.y > right.y) ? left.y : right.y;
  69602. return new Vector2(x, y);
  69603. };
  69604. /**
  69605. * Gets a new Vector2 set with the transformed coordinates of the given vector by the given transformation matrix
  69606. * @param vector defines the vector to transform
  69607. * @param transformation defines the matrix to apply
  69608. * @returns a new Vector2
  69609. */
  69610. Vector2.Transform = function (vector, transformation) {
  69611. var r = Vector2.Zero();
  69612. Vector2.TransformToRef(vector, transformation, r);
  69613. return r;
  69614. };
  69615. /**
  69616. * Transforms the given vector coordinates by the given transformation matrix and stores the result in the vector "result" coordinates
  69617. * @param vector defines the vector to transform
  69618. * @param transformation defines the matrix to apply
  69619. * @param result defines the target vector
  69620. */
  69621. Vector2.TransformToRef = function (vector, transformation, result) {
  69622. var m = transformation.m;
  69623. var x = (vector.x * m[0]) + (vector.y * m[4]) + m[12];
  69624. var y = (vector.x * m[1]) + (vector.y * m[5]) + m[13];
  69625. result.x = x;
  69626. result.y = y;
  69627. };
  69628. /**
  69629. * Determines if a given vector is included in a triangle
  69630. * @param p defines the vector to test
  69631. * @param p0 defines 1st triangle point
  69632. * @param p1 defines 2nd triangle point
  69633. * @param p2 defines 3rd triangle point
  69634. * @returns true if the point "p" is in the triangle defined by the vertors "p0", "p1", "p2"
  69635. */
  69636. Vector2.PointInTriangle = function (p, p0, p1, p2) {
  69637. var a = 1 / 2 * (-p1.y * p2.x + p0.y * (-p1.x + p2.x) + p0.x * (p1.y - p2.y) + p1.x * p2.y);
  69638. var sign = a < 0 ? -1 : 1;
  69639. var s = (p0.y * p2.x - p0.x * p2.y + (p2.y - p0.y) * p.x + (p0.x - p2.x) * p.y) * sign;
  69640. var t = (p0.x * p1.y - p0.y * p1.x + (p0.y - p1.y) * p.x + (p1.x - p0.x) * p.y) * sign;
  69641. return s > 0 && t > 0 && (s + t) < 2 * a * sign;
  69642. };
  69643. /**
  69644. * Gets the distance between the vectors "value1" and "value2"
  69645. * @param value1 defines first vector
  69646. * @param value2 defines second vector
  69647. * @returns the distance between vectors
  69648. */
  69649. Vector2.Distance = function (value1, value2) {
  69650. return Math.sqrt(Vector2.DistanceSquared(value1, value2));
  69651. };
  69652. /**
  69653. * Returns the squared distance between the vectors "value1" and "value2"
  69654. * @param value1 defines first vector
  69655. * @param value2 defines second vector
  69656. * @returns the squared distance between vectors
  69657. */
  69658. Vector2.DistanceSquared = function (value1, value2) {
  69659. var x = value1.x - value2.x;
  69660. var y = value1.y - value2.y;
  69661. return (x * x) + (y * y);
  69662. };
  69663. /**
  69664. * Gets a new Vector2 located at the center of the vectors "value1" and "value2"
  69665. * @param value1 defines first vector
  69666. * @param value2 defines second vector
  69667. * @returns a new Vector2
  69668. */
  69669. Vector2.Center = function (value1, value2) {
  69670. var center = value1.add(value2);
  69671. center.scaleInPlace(0.5);
  69672. return center;
  69673. };
  69674. /**
  69675. * Gets the shortest distance (float) between the point "p" and the segment defined by the two points "segA" and "segB".
  69676. * @param p defines the middle point
  69677. * @param segA defines one point of the segment
  69678. * @param segB defines the other point of the segment
  69679. * @returns the shortest distance
  69680. */
  69681. Vector2.DistanceOfPointFromSegment = function (p, segA, segB) {
  69682. var l2 = Vector2.DistanceSquared(segA, segB);
  69683. if (l2 === 0.0) {
  69684. return Vector2.Distance(p, segA);
  69685. }
  69686. var v = segB.subtract(segA);
  69687. var t = Math.max(0, Math.min(1, Vector2.Dot(p.subtract(segA), v) / l2));
  69688. var proj = segA.add(v.multiplyByFloats(t, t));
  69689. return Vector2.Distance(p, proj);
  69690. };
  69691. return Vector2;
  69692. }());
  69693. /**
  69694. * Classed used to store (x,y,z) vector representation
  69695. * A Vector3 is the main object used in 3D geometry
  69696. * It can represent etiher the coordinates of a point the space, either a direction
  69697. * Reminder: js uses a left handed forward facing system
  69698. */
  69699. var Vector3 = /** @class */ (function () {
  69700. /**
  69701. * Creates a new Vector3 object from the given x, y, z (floats) coordinates.
  69702. * @param x defines the first coordinates (on X axis)
  69703. * @param y defines the second coordinates (on Y axis)
  69704. * @param z defines the third coordinates (on Z axis)
  69705. */
  69706. function Vector3(
  69707. /**
  69708. * Defines the first coordinates (on X axis)
  69709. */
  69710. x,
  69711. /**
  69712. * Defines the second coordinates (on Y axis)
  69713. */
  69714. y,
  69715. /**
  69716. * Defines the third coordinates (on Z axis)
  69717. */
  69718. z) {
  69719. if (x === void 0) { x = 0; }
  69720. if (y === void 0) { y = 0; }
  69721. if (z === void 0) { z = 0; }
  69722. this.x = x;
  69723. this.y = y;
  69724. this.z = z;
  69725. }
  69726. /**
  69727. * Creates a string representation of the Vector3
  69728. * @returns a string with the Vector3 coordinates.
  69729. */
  69730. Vector3.prototype.toString = function () {
  69731. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + "}";
  69732. };
  69733. /**
  69734. * Gets the class name
  69735. * @returns the string "Vector3"
  69736. */
  69737. Vector3.prototype.getClassName = function () {
  69738. return "Vector3";
  69739. };
  69740. /**
  69741. * Creates the Vector3 hash code
  69742. * @returns a number which tends to be unique between Vector3 instances
  69743. */
  69744. Vector3.prototype.getHashCode = function () {
  69745. var hash = this.x || 0;
  69746. hash = (hash * 397) ^ (this.y || 0);
  69747. hash = (hash * 397) ^ (this.z || 0);
  69748. return hash;
  69749. };
  69750. // Operators
  69751. /**
  69752. * Creates an array containing three elements : the coordinates of the Vector3
  69753. * @returns a new array of numbers
  69754. */
  69755. Vector3.prototype.asArray = function () {
  69756. var result = [];
  69757. this.toArray(result, 0);
  69758. return result;
  69759. };
  69760. /**
  69761. * Populates the given array or Float32Array from the given index with the successive coordinates of the Vector3
  69762. * @param array defines the destination array
  69763. * @param index defines the offset in the destination array
  69764. * @returns the current Vector3
  69765. */
  69766. Vector3.prototype.toArray = function (array, index) {
  69767. if (index === void 0) { index = 0; }
  69768. array[index] = this.x;
  69769. array[index + 1] = this.y;
  69770. array[index + 2] = this.z;
  69771. return this;
  69772. };
  69773. /**
  69774. * Converts the current Vector3 into a quaternion (considering that the Vector3 contains Euler angles representation of a rotation)
  69775. * @returns a new Quaternion object, computed from the Vector3 coordinates
  69776. */
  69777. Vector3.prototype.toQuaternion = function () {
  69778. return Quaternion.RotationYawPitchRoll(this.y, this.x, this.z);
  69779. };
  69780. /**
  69781. * Adds the given vector to the current Vector3
  69782. * @param otherVector defines the second operand
  69783. * @returns the current updated Vector3
  69784. */
  69785. Vector3.prototype.addInPlace = function (otherVector) {
  69786. return this.addInPlaceFromFloats(otherVector.x, otherVector.y, otherVector.z);
  69787. };
  69788. /**
  69789. * Adds the given coordinates to the current Vector3
  69790. * @param x defines the x coordinate of the operand
  69791. * @param y defines the y coordinate of the operand
  69792. * @param z defines the z coordinate of the operand
  69793. * @returns the current updated Vector3
  69794. */
  69795. Vector3.prototype.addInPlaceFromFloats = function (x, y, z) {
  69796. this.x += x;
  69797. this.y += y;
  69798. this.z += z;
  69799. return this;
  69800. };
  69801. /**
  69802. * Gets a new Vector3, result of the addition the current Vector3 and the given vector
  69803. * @param otherVector defines the second operand
  69804. * @returns the resulting Vector3
  69805. */
  69806. Vector3.prototype.add = function (otherVector) {
  69807. return new Vector3(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69808. };
  69809. /**
  69810. * Adds the current Vector3 to the given one and stores the result in the vector "result"
  69811. * @param otherVector defines the second operand
  69812. * @param result defines the Vector3 object where to store the result
  69813. * @returns the current Vector3
  69814. */
  69815. Vector3.prototype.addToRef = function (otherVector, result) {
  69816. return result.copyFromFloats(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z);
  69817. };
  69818. /**
  69819. * Subtract the given vector from the current Vector3
  69820. * @param otherVector defines the second operand
  69821. * @returns the current updated Vector3
  69822. */
  69823. Vector3.prototype.subtractInPlace = function (otherVector) {
  69824. this.x -= otherVector.x;
  69825. this.y -= otherVector.y;
  69826. this.z -= otherVector.z;
  69827. return this;
  69828. };
  69829. /**
  69830. * Returns a new Vector3, result of the subtraction of the given vector from the current Vector3
  69831. * @param otherVector defines the second operand
  69832. * @returns the resulting Vector3
  69833. */
  69834. Vector3.prototype.subtract = function (otherVector) {
  69835. return new Vector3(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z);
  69836. };
  69837. /**
  69838. * Subtracts the given vector from the current Vector3 and stores the result in the vector "result".
  69839. * @param otherVector defines the second operand
  69840. * @param result defines the Vector3 object where to store the result
  69841. * @returns the current Vector3
  69842. */
  69843. Vector3.prototype.subtractToRef = function (otherVector, result) {
  69844. return this.subtractFromFloatsToRef(otherVector.x, otherVector.y, otherVector.z, result);
  69845. };
  69846. /**
  69847. * Returns a new Vector3 set with the subtraction of the given floats from the current Vector3 coordinates
  69848. * @param x defines the x coordinate of the operand
  69849. * @param y defines the y coordinate of the operand
  69850. * @param z defines the z coordinate of the operand
  69851. * @returns the resulting Vector3
  69852. */
  69853. Vector3.prototype.subtractFromFloats = function (x, y, z) {
  69854. return new Vector3(this.x - x, this.y - y, this.z - z);
  69855. };
  69856. /**
  69857. * Subtracts the given floats from the current Vector3 coordinates and set the given vector "result" with this result
  69858. * @param x defines the x coordinate of the operand
  69859. * @param y defines the y coordinate of the operand
  69860. * @param z defines the z coordinate of the operand
  69861. * @param result defines the Vector3 object where to store the result
  69862. * @returns the current Vector3
  69863. */
  69864. Vector3.prototype.subtractFromFloatsToRef = function (x, y, z, result) {
  69865. return result.copyFromFloats(this.x - x, this.y - y, this.z - z);
  69866. };
  69867. /**
  69868. * Gets a new Vector3 set with the current Vector3 negated coordinates
  69869. * @returns a new Vector3
  69870. */
  69871. Vector3.prototype.negate = function () {
  69872. return new Vector3(-this.x, -this.y, -this.z);
  69873. };
  69874. /**
  69875. * Multiplies the Vector3 coordinates by the float "scale"
  69876. * @param scale defines the multiplier factor
  69877. * @returns the current updated Vector3
  69878. */
  69879. Vector3.prototype.scaleInPlace = function (scale) {
  69880. this.x *= scale;
  69881. this.y *= scale;
  69882. this.z *= scale;
  69883. return this;
  69884. };
  69885. /**
  69886. * Returns a new Vector3 set with the current Vector3 coordinates multiplied by the float "scale"
  69887. * @param scale defines the multiplier factor
  69888. * @returns a new Vector3
  69889. */
  69890. Vector3.prototype.scale = function (scale) {
  69891. return new Vector3(this.x * scale, this.y * scale, this.z * scale);
  69892. };
  69893. /**
  69894. * Multiplies the current Vector3 coordinates by the float "scale" and stores the result in the given vector "result" coordinates
  69895. * @param scale defines the multiplier factor
  69896. * @param result defines the Vector3 object where to store the result
  69897. * @returns the current Vector3
  69898. */
  69899. Vector3.prototype.scaleToRef = function (scale, result) {
  69900. return result.copyFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69901. };
  69902. /**
  69903. * Scale the current Vector3 values by a factor and add the result to a given Vector3
  69904. * @param scale defines the scale factor
  69905. * @param result defines the Vector3 object where to store the result
  69906. * @returns the unmodified current Vector3
  69907. */
  69908. Vector3.prototype.scaleAndAddToRef = function (scale, result) {
  69909. return result.addInPlaceFromFloats(this.x * scale, this.y * scale, this.z * scale);
  69910. };
  69911. /**
  69912. * Returns true if the current Vector3 and the given vector coordinates are strictly equal
  69913. * @param otherVector defines the second operand
  69914. * @returns true if both vectors are equals
  69915. */
  69916. Vector3.prototype.equals = function (otherVector) {
  69917. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z;
  69918. };
  69919. /**
  69920. * Returns true if the current Vector3 and the given vector coordinates are distant less than epsilon
  69921. * @param otherVector defines the second operand
  69922. * @param epsilon defines the minimal distance to define values as equals
  69923. * @returns true if both vectors are distant less than epsilon
  69924. */
  69925. Vector3.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  69926. if (epsilon === void 0) { epsilon = Epsilon; }
  69927. 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);
  69928. };
  69929. /**
  69930. * Returns true if the current Vector3 coordinates equals the given floats
  69931. * @param x defines the x coordinate of the operand
  69932. * @param y defines the y coordinate of the operand
  69933. * @param z defines the z coordinate of the operand
  69934. * @returns true if both vectors are equals
  69935. */
  69936. Vector3.prototype.equalsToFloats = function (x, y, z) {
  69937. return this.x === x && this.y === y && this.z === z;
  69938. };
  69939. /**
  69940. * Multiplies the current Vector3 coordinates by the given ones
  69941. * @param otherVector defines the second operand
  69942. * @returns the current updated Vector3
  69943. */
  69944. Vector3.prototype.multiplyInPlace = function (otherVector) {
  69945. this.x *= otherVector.x;
  69946. this.y *= otherVector.y;
  69947. this.z *= otherVector.z;
  69948. return this;
  69949. };
  69950. /**
  69951. * Returns a new Vector3, result of the multiplication of the current Vector3 by the given vector
  69952. * @param otherVector defines the second operand
  69953. * @returns the new Vector3
  69954. */
  69955. Vector3.prototype.multiply = function (otherVector) {
  69956. return this.multiplyByFloats(otherVector.x, otherVector.y, otherVector.z);
  69957. };
  69958. /**
  69959. * Multiplies the current Vector3 by the given one and stores the result in the given vector "result"
  69960. * @param otherVector defines the second operand
  69961. * @param result defines the Vector3 object where to store the result
  69962. * @returns the current Vector3
  69963. */
  69964. Vector3.prototype.multiplyToRef = function (otherVector, result) {
  69965. return result.copyFromFloats(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z);
  69966. };
  69967. /**
  69968. * Returns a new Vector3 set with the result of the mulliplication of the current Vector3 coordinates by the given floats
  69969. * @param x defines the x coordinate of the operand
  69970. * @param y defines the y coordinate of the operand
  69971. * @param z defines the z coordinate of the operand
  69972. * @returns the new Vector3
  69973. */
  69974. Vector3.prototype.multiplyByFloats = function (x, y, z) {
  69975. return new Vector3(this.x * x, this.y * y, this.z * z);
  69976. };
  69977. /**
  69978. * Returns a new Vector3 set with the result of the division of the current Vector3 coordinates by the given ones
  69979. * @param otherVector defines the second operand
  69980. * @returns the new Vector3
  69981. */
  69982. Vector3.prototype.divide = function (otherVector) {
  69983. return new Vector3(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69984. };
  69985. /**
  69986. * Divides the current Vector3 coordinates by the given ones and stores the result in the given vector "result"
  69987. * @param otherVector defines the second operand
  69988. * @param result defines the Vector3 object where to store the result
  69989. * @returns the current Vector3
  69990. */
  69991. Vector3.prototype.divideToRef = function (otherVector, result) {
  69992. return result.copyFromFloats(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z);
  69993. };
  69994. /**
  69995. * Divides the current Vector3 coordinates by the given ones.
  69996. * @param otherVector defines the second operand
  69997. * @returns the current updated Vector3
  69998. */
  69999. Vector3.prototype.divideInPlace = function (otherVector) {
  70000. return this.divideToRef(otherVector, this);
  70001. };
  70002. /**
  70003. * Updates the current Vector3 with the minimal coordinate values between its and the given vector ones
  70004. * @param other defines the second operand
  70005. * @returns the current updated Vector3
  70006. */
  70007. Vector3.prototype.minimizeInPlace = function (other) {
  70008. return this.minimizeInPlaceFromFloats(other.x, other.y, other.z);
  70009. };
  70010. /**
  70011. * Updates the current Vector3 with the maximal coordinate values between its and the given vector ones.
  70012. * @param other defines the second operand
  70013. * @returns the current updated Vector3
  70014. */
  70015. Vector3.prototype.maximizeInPlace = function (other) {
  70016. return this.maximizeInPlaceFromFloats(other.x, other.y, other.z);
  70017. };
  70018. /**
  70019. * Updates the current Vector3 with the minimal coordinate values between its and the given coordinates
  70020. * @param x defines the x coordinate of the operand
  70021. * @param y defines the y coordinate of the operand
  70022. * @param z defines the z coordinate of the operand
  70023. * @returns the current updated Vector3
  70024. */
  70025. Vector3.prototype.minimizeInPlaceFromFloats = function (x, y, z) {
  70026. if (x < this.x) {
  70027. this.x = x;
  70028. }
  70029. if (y < this.y) {
  70030. this.y = y;
  70031. }
  70032. if (z < this.z) {
  70033. this.z = z;
  70034. }
  70035. return this;
  70036. };
  70037. /**
  70038. * Updates the current Vector3 with the maximal coordinate values between its and the given coordinates.
  70039. * @param x defines the x coordinate of the operand
  70040. * @param y defines the y coordinate of the operand
  70041. * @param z defines the z coordinate of the operand
  70042. * @returns the current updated Vector3
  70043. */
  70044. Vector3.prototype.maximizeInPlaceFromFloats = function (x, y, z) {
  70045. if (x > this.x) {
  70046. this.x = x;
  70047. }
  70048. if (y > this.y) {
  70049. this.y = y;
  70050. }
  70051. if (z > this.z) {
  70052. this.z = z;
  70053. }
  70054. return this;
  70055. };
  70056. /**
  70057. * Due to float precision, scale of a mesh could be uniform but float values are off by a small fraction
  70058. * Check if is non uniform within a certain amount of decimal places to account for this
  70059. * @param epsilon the amount the values can differ
  70060. * @returns if the the vector is non uniform to a certain number of decimal places
  70061. */
  70062. Vector3.prototype.isNonUniformWithinEpsilon = function (epsilon) {
  70063. var absX = Math.abs(this.x);
  70064. var absY = Math.abs(this.y);
  70065. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absY, epsilon)) {
  70066. return true;
  70067. }
  70068. var absZ = Math.abs(this.z);
  70069. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absX, absZ, epsilon)) {
  70070. return true;
  70071. }
  70072. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(absY, absZ, epsilon)) {
  70073. return true;
  70074. }
  70075. return false;
  70076. };
  70077. Object.defineProperty(Vector3.prototype, "isNonUniform", {
  70078. /**
  70079. * Gets a boolean indicating that the vector is non uniform meaning x, y or z are not all the same
  70080. */
  70081. get: function () {
  70082. var absX = Math.abs(this.x);
  70083. var absY = Math.abs(this.y);
  70084. if (absX !== absY) {
  70085. return true;
  70086. }
  70087. var absZ = Math.abs(this.z);
  70088. if (absX !== absZ) {
  70089. return true;
  70090. }
  70091. if (absY !== absZ) {
  70092. return true;
  70093. }
  70094. return false;
  70095. },
  70096. enumerable: true,
  70097. configurable: true
  70098. });
  70099. /**
  70100. * Gets a new Vector3 from current Vector3 floored values
  70101. * @returns a new Vector3
  70102. */
  70103. Vector3.prototype.floor = function () {
  70104. return new Vector3(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z));
  70105. };
  70106. /**
  70107. * Gets a new Vector3 from current Vector3 floored values
  70108. * @returns a new Vector3
  70109. */
  70110. Vector3.prototype.fract = function () {
  70111. return new Vector3(this.x - Math.floor(this.x), this.y - Math.floor(this.y), this.z - Math.floor(this.z));
  70112. };
  70113. // Properties
  70114. /**
  70115. * Gets the length of the Vector3
  70116. * @returns the length of the Vecto3
  70117. */
  70118. Vector3.prototype.length = function () {
  70119. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z);
  70120. };
  70121. /**
  70122. * Gets the squared length of the Vector3
  70123. * @returns squared length of the Vector3
  70124. */
  70125. Vector3.prototype.lengthSquared = function () {
  70126. return (this.x * this.x + this.y * this.y + this.z * this.z);
  70127. };
  70128. /**
  70129. * Normalize the current Vector3.
  70130. * Please note that this is an in place operation.
  70131. * @returns the current updated Vector3
  70132. */
  70133. Vector3.prototype.normalize = function () {
  70134. return this.normalizeFromLength(this.length());
  70135. };
  70136. /**
  70137. * Reorders the x y z properties of the vector in place
  70138. * @param order new ordering of the properties (eg. for vector 1,2,3 with "ZYX" will produce 3,2,1)
  70139. * @returns the current updated vector
  70140. */
  70141. Vector3.prototype.reorderInPlace = function (order) {
  70142. var _this = this;
  70143. order = order.toLowerCase();
  70144. if (order === "xyz") {
  70145. return this;
  70146. }
  70147. MathTmp.Vector3[0].copyFrom(this);
  70148. ["x", "y", "z"].forEach(function (val, i) {
  70149. _this[val] = MathTmp.Vector3[0][order[i]];
  70150. });
  70151. return this;
  70152. };
  70153. /**
  70154. * Rotates the vector around 0,0,0 by a quaternion
  70155. * @param quaternion the rotation quaternion
  70156. * @param result vector to store the result
  70157. * @returns the resulting vector
  70158. */
  70159. Vector3.prototype.rotateByQuaternionToRef = function (quaternion, result) {
  70160. quaternion.toRotationMatrix(MathTmp.Matrix[0]);
  70161. Vector3.TransformCoordinatesToRef(this, MathTmp.Matrix[0], result);
  70162. return result;
  70163. };
  70164. /**
  70165. * Rotates a vector around a given point
  70166. * @param quaternion the rotation quaternion
  70167. * @param point the point to rotate around
  70168. * @param result vector to store the result
  70169. * @returns the resulting vector
  70170. */
  70171. Vector3.prototype.rotateByQuaternionAroundPointToRef = function (quaternion, point, result) {
  70172. this.subtractToRef(point, MathTmp.Vector3[0]);
  70173. MathTmp.Vector3[0].rotateByQuaternionToRef(quaternion, MathTmp.Vector3[0]);
  70174. point.addToRef(MathTmp.Vector3[0], result);
  70175. return result;
  70176. };
  70177. /**
  70178. * Normalize the current Vector3 with the given input length.
  70179. * Please note that this is an in place operation.
  70180. * @param len the length of the vector
  70181. * @returns the current updated Vector3
  70182. */
  70183. Vector3.prototype.normalizeFromLength = function (len) {
  70184. if (len === 0 || len === 1.0) {
  70185. return this;
  70186. }
  70187. return this.scaleInPlace(1.0 / len);
  70188. };
  70189. /**
  70190. * Normalize the current Vector3 to a new vector
  70191. * @returns the new Vector3
  70192. */
  70193. Vector3.prototype.normalizeToNew = function () {
  70194. var normalized = new Vector3(0, 0, 0);
  70195. this.normalizeToRef(normalized);
  70196. return normalized;
  70197. };
  70198. /**
  70199. * Normalize the current Vector3 to the reference
  70200. * @param reference define the Vector3 to update
  70201. * @returns the updated Vector3
  70202. */
  70203. Vector3.prototype.normalizeToRef = function (reference) {
  70204. var len = this.length();
  70205. if (len === 0 || len === 1.0) {
  70206. return reference.copyFromFloats(this.x, this.y, this.z);
  70207. }
  70208. return this.scaleToRef(1.0 / len, reference);
  70209. };
  70210. /**
  70211. * Creates a new Vector3 copied from the current Vector3
  70212. * @returns the new Vector3
  70213. */
  70214. Vector3.prototype.clone = function () {
  70215. return new Vector3(this.x, this.y, this.z);
  70216. };
  70217. /**
  70218. * Copies the given vector coordinates to the current Vector3 ones
  70219. * @param source defines the source Vector3
  70220. * @returns the current updated Vector3
  70221. */
  70222. Vector3.prototype.copyFrom = function (source) {
  70223. return this.copyFromFloats(source.x, source.y, source.z);
  70224. };
  70225. /**
  70226. * Copies the given floats to the current Vector3 coordinates
  70227. * @param x defines the x coordinate of the operand
  70228. * @param y defines the y coordinate of the operand
  70229. * @param z defines the z coordinate of the operand
  70230. * @returns the current updated Vector3
  70231. */
  70232. Vector3.prototype.copyFromFloats = function (x, y, z) {
  70233. this.x = x;
  70234. this.y = y;
  70235. this.z = z;
  70236. return this;
  70237. };
  70238. /**
  70239. * Copies the given floats to the current Vector3 coordinates
  70240. * @param x defines the x coordinate of the operand
  70241. * @param y defines the y coordinate of the operand
  70242. * @param z defines the z coordinate of the operand
  70243. * @returns the current updated Vector3
  70244. */
  70245. Vector3.prototype.set = function (x, y, z) {
  70246. return this.copyFromFloats(x, y, z);
  70247. };
  70248. /**
  70249. * Copies the given float to the current Vector3 coordinates
  70250. * @param v defines the x, y and z coordinates of the operand
  70251. * @returns the current updated Vector3
  70252. */
  70253. Vector3.prototype.setAll = function (v) {
  70254. this.x = this.y = this.z = v;
  70255. return this;
  70256. };
  70257. // Statics
  70258. /**
  70259. * Get the clip factor between two vectors
  70260. * @param vector0 defines the first operand
  70261. * @param vector1 defines the second operand
  70262. * @param axis defines the axis to use
  70263. * @param size defines the size along the axis
  70264. * @returns the clip factor
  70265. */
  70266. Vector3.GetClipFactor = function (vector0, vector1, axis, size) {
  70267. var d0 = Vector3.Dot(vector0, axis) - size;
  70268. var d1 = Vector3.Dot(vector1, axis) - size;
  70269. var s = d0 / (d0 - d1);
  70270. return s;
  70271. };
  70272. /**
  70273. * Get angle between two vectors
  70274. * @param vector0 angle between vector0 and vector1
  70275. * @param vector1 angle between vector0 and vector1
  70276. * @param normal direction of the normal
  70277. * @return the angle between vector0 and vector1
  70278. */
  70279. Vector3.GetAngleBetweenVectors = function (vector0, vector1, normal) {
  70280. var v0 = vector0.normalizeToRef(MathTmp.Vector3[1]);
  70281. var v1 = vector1.normalizeToRef(MathTmp.Vector3[2]);
  70282. var dot = Vector3.Dot(v0, v1);
  70283. var n = MathTmp.Vector3[3];
  70284. Vector3.CrossToRef(v0, v1, n);
  70285. if (Vector3.Dot(n, normal) > 0) {
  70286. return Math.acos(dot);
  70287. }
  70288. return -Math.acos(dot);
  70289. };
  70290. /**
  70291. * Returns a new Vector3 set from the index "offset" of the given array
  70292. * @param array defines the source array
  70293. * @param offset defines the offset in the source array
  70294. * @returns the new Vector3
  70295. */
  70296. Vector3.FromArray = function (array, offset) {
  70297. if (offset === void 0) { offset = 0; }
  70298. return new Vector3(array[offset], array[offset + 1], array[offset + 2]);
  70299. };
  70300. /**
  70301. * Returns a new Vector3 set from the index "offset" of the given Float32Array
  70302. * This function is deprecated. Use FromArray instead
  70303. * @param array defines the source array
  70304. * @param offset defines the offset in the source array
  70305. * @returns the new Vector3
  70306. */
  70307. Vector3.FromFloatArray = function (array, offset) {
  70308. return Vector3.FromArray(array, offset);
  70309. };
  70310. /**
  70311. * Sets the given vector "result" with the element values from the index "offset" of the given array
  70312. * @param array defines the source array
  70313. * @param offset defines the offset in the source array
  70314. * @param result defines the Vector3 where to store the result
  70315. */
  70316. Vector3.FromArrayToRef = function (array, offset, result) {
  70317. result.x = array[offset];
  70318. result.y = array[offset + 1];
  70319. result.z = array[offset + 2];
  70320. };
  70321. /**
  70322. * Sets the given vector "result" with the element values from the index "offset" of the given Float32Array
  70323. * This function is deprecated. Use FromArrayToRef instead.
  70324. * @param array defines the source array
  70325. * @param offset defines the offset in the source array
  70326. * @param result defines the Vector3 where to store the result
  70327. */
  70328. Vector3.FromFloatArrayToRef = function (array, offset, result) {
  70329. return Vector3.FromArrayToRef(array, offset, result);
  70330. };
  70331. /**
  70332. * Sets the given vector "result" with the given floats.
  70333. * @param x defines the x coordinate of the source
  70334. * @param y defines the y coordinate of the source
  70335. * @param z defines the z coordinate of the source
  70336. * @param result defines the Vector3 where to store the result
  70337. */
  70338. Vector3.FromFloatsToRef = function (x, y, z, result) {
  70339. result.copyFromFloats(x, y, z);
  70340. };
  70341. /**
  70342. * Returns a new Vector3 set to (0.0, 0.0, 0.0)
  70343. * @returns a new empty Vector3
  70344. */
  70345. Vector3.Zero = function () {
  70346. return new Vector3(0.0, 0.0, 0.0);
  70347. };
  70348. /**
  70349. * Returns a new Vector3 set to (1.0, 1.0, 1.0)
  70350. * @returns a new unit Vector3
  70351. */
  70352. Vector3.One = function () {
  70353. return new Vector3(1.0, 1.0, 1.0);
  70354. };
  70355. /**
  70356. * Returns a new Vector3 set to (0.0, 1.0, 0.0)
  70357. * @returns a new up Vector3
  70358. */
  70359. Vector3.Up = function () {
  70360. return new Vector3(0.0, 1.0, 0.0);
  70361. };
  70362. Object.defineProperty(Vector3, "UpReadOnly", {
  70363. /**
  70364. * Gets a up Vector3 that must not be updated
  70365. */
  70366. get: function () {
  70367. return Vector3._UpReadOnly;
  70368. },
  70369. enumerable: true,
  70370. configurable: true
  70371. });
  70372. /**
  70373. * Returns a new Vector3 set to (0.0, -1.0, 0.0)
  70374. * @returns a new down Vector3
  70375. */
  70376. Vector3.Down = function () {
  70377. return new Vector3(0.0, -1.0, 0.0);
  70378. };
  70379. /**
  70380. * Returns a new Vector3 set to (0.0, 0.0, 1.0)
  70381. * @returns a new forward Vector3
  70382. */
  70383. Vector3.Forward = function () {
  70384. return new Vector3(0.0, 0.0, 1.0);
  70385. };
  70386. /**
  70387. * Returns a new Vector3 set to (0.0, 0.0, -1.0)
  70388. * @returns a new forward Vector3
  70389. */
  70390. Vector3.Backward = function () {
  70391. return new Vector3(0.0, 0.0, -1.0);
  70392. };
  70393. /**
  70394. * Returns a new Vector3 set to (1.0, 0.0, 0.0)
  70395. * @returns a new right Vector3
  70396. */
  70397. Vector3.Right = function () {
  70398. return new Vector3(1.0, 0.0, 0.0);
  70399. };
  70400. /**
  70401. * Returns a new Vector3 set to (-1.0, 0.0, 0.0)
  70402. * @returns a new left Vector3
  70403. */
  70404. Vector3.Left = function () {
  70405. return new Vector3(-1.0, 0.0, 0.0);
  70406. };
  70407. /**
  70408. * Returns a new Vector3 set with the result of the transformation by the given matrix of the given vector.
  70409. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70410. * @param vector defines the Vector3 to transform
  70411. * @param transformation defines the transformation matrix
  70412. * @returns the transformed Vector3
  70413. */
  70414. Vector3.TransformCoordinates = function (vector, transformation) {
  70415. var result = Vector3.Zero();
  70416. Vector3.TransformCoordinatesToRef(vector, transformation, result);
  70417. return result;
  70418. };
  70419. /**
  70420. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given vector
  70421. * This method computes tranformed coordinates only, not transformed direction vectors (ie. it takes translation in account)
  70422. * @param vector defines the Vector3 to transform
  70423. * @param transformation defines the transformation matrix
  70424. * @param result defines the Vector3 where to store the result
  70425. */
  70426. Vector3.TransformCoordinatesToRef = function (vector, transformation, result) {
  70427. Vector3.TransformCoordinatesFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  70428. };
  70429. /**
  70430. * Sets the given vector "result" coordinates with the result of the transformation by the given matrix of the given floats (x, y, z)
  70431. * This method computes tranformed coordinates only, not transformed direction vectors
  70432. * @param x define the x coordinate of the source vector
  70433. * @param y define the y coordinate of the source vector
  70434. * @param z define the z coordinate of the source vector
  70435. * @param transformation defines the transformation matrix
  70436. * @param result defines the Vector3 where to store the result
  70437. */
  70438. Vector3.TransformCoordinatesFromFloatsToRef = function (x, y, z, transformation, result) {
  70439. var m = transformation.m;
  70440. var rx = x * m[0] + y * m[4] + z * m[8] + m[12];
  70441. var ry = x * m[1] + y * m[5] + z * m[9] + m[13];
  70442. var rz = x * m[2] + y * m[6] + z * m[10] + m[14];
  70443. var rw = 1 / (x * m[3] + y * m[7] + z * m[11] + m[15]);
  70444. result.x = rx * rw;
  70445. result.y = ry * rw;
  70446. result.z = rz * rw;
  70447. };
  70448. /**
  70449. * Returns a new Vector3 set with the result of the normal transformation by the given matrix of the given vector
  70450. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70451. * @param vector defines the Vector3 to transform
  70452. * @param transformation defines the transformation matrix
  70453. * @returns the new Vector3
  70454. */
  70455. Vector3.TransformNormal = function (vector, transformation) {
  70456. var result = Vector3.Zero();
  70457. Vector3.TransformNormalToRef(vector, transformation, result);
  70458. return result;
  70459. };
  70460. /**
  70461. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector
  70462. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70463. * @param vector defines the Vector3 to transform
  70464. * @param transformation defines the transformation matrix
  70465. * @param result defines the Vector3 where to store the result
  70466. */
  70467. Vector3.TransformNormalToRef = function (vector, transformation, result) {
  70468. this.TransformNormalFromFloatsToRef(vector.x, vector.y, vector.z, transformation, result);
  70469. };
  70470. /**
  70471. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z)
  70472. * This methods computes transformed normalized direction vectors only (ie. it does not apply translation)
  70473. * @param x define the x coordinate of the source vector
  70474. * @param y define the y coordinate of the source vector
  70475. * @param z define the z coordinate of the source vector
  70476. * @param transformation defines the transformation matrix
  70477. * @param result defines the Vector3 where to store the result
  70478. */
  70479. Vector3.TransformNormalFromFloatsToRef = function (x, y, z, transformation, result) {
  70480. var m = transformation.m;
  70481. result.x = x * m[0] + y * m[4] + z * m[8];
  70482. result.y = x * m[1] + y * m[5] + z * m[9];
  70483. result.z = x * m[2] + y * m[6] + z * m[10];
  70484. };
  70485. /**
  70486. * Returns a new Vector3 located for "amount" on the CatmullRom interpolation spline defined by the vectors "value1", "value2", "value3", "value4"
  70487. * @param value1 defines the first control point
  70488. * @param value2 defines the second control point
  70489. * @param value3 defines the third control point
  70490. * @param value4 defines the fourth control point
  70491. * @param amount defines the amount on the spline to use
  70492. * @returns the new Vector3
  70493. */
  70494. Vector3.CatmullRom = function (value1, value2, value3, value4, amount) {
  70495. var squared = amount * amount;
  70496. var cubed = amount * squared;
  70497. var x = 0.5 * ((((2.0 * value2.x) + ((-value1.x + value3.x) * amount)) +
  70498. (((((2.0 * value1.x) - (5.0 * value2.x)) + (4.0 * value3.x)) - value4.x) * squared)) +
  70499. ((((-value1.x + (3.0 * value2.x)) - (3.0 * value3.x)) + value4.x) * cubed));
  70500. var y = 0.5 * ((((2.0 * value2.y) + ((-value1.y + value3.y) * amount)) +
  70501. (((((2.0 * value1.y) - (5.0 * value2.y)) + (4.0 * value3.y)) - value4.y) * squared)) +
  70502. ((((-value1.y + (3.0 * value2.y)) - (3.0 * value3.y)) + value4.y) * cubed));
  70503. var z = 0.5 * ((((2.0 * value2.z) + ((-value1.z + value3.z) * amount)) +
  70504. (((((2.0 * value1.z) - (5.0 * value2.z)) + (4.0 * value3.z)) - value4.z) * squared)) +
  70505. ((((-value1.z + (3.0 * value2.z)) - (3.0 * value3.z)) + value4.z) * cubed));
  70506. return new Vector3(x, y, z);
  70507. };
  70508. /**
  70509. * 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"
  70510. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70511. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70512. * @param value defines the current value
  70513. * @param min defines the lower range value
  70514. * @param max defines the upper range value
  70515. * @returns the new Vector3
  70516. */
  70517. Vector3.Clamp = function (value, min, max) {
  70518. var v = new Vector3();
  70519. Vector3.ClampToRef(value, min, max, v);
  70520. return v;
  70521. };
  70522. /**
  70523. * 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"
  70524. * If a coordinate value of "value" is lower than one of the "min" coordinate, then this "value" coordinate is set with the "min" one
  70525. * If a coordinate value of "value" is greater than one of the "max" coordinate, then this "value" coordinate is set with the "max" one
  70526. * @param value defines the current value
  70527. * @param min defines the lower range value
  70528. * @param max defines the upper range value
  70529. * @param result defines the Vector3 where to store the result
  70530. */
  70531. Vector3.ClampToRef = function (value, min, max, result) {
  70532. var x = value.x;
  70533. x = (x > max.x) ? max.x : x;
  70534. x = (x < min.x) ? min.x : x;
  70535. var y = value.y;
  70536. y = (y > max.y) ? max.y : y;
  70537. y = (y < min.y) ? min.y : y;
  70538. var z = value.z;
  70539. z = (z > max.z) ? max.z : z;
  70540. z = (z < min.z) ? min.z : z;
  70541. result.copyFromFloats(x, y, z);
  70542. };
  70543. /**
  70544. * Returns a new Vector3 located for "amount" (float) on the Hermite interpolation spline defined by the vectors "value1", "tangent1", "value2", "tangent2"
  70545. * @param value1 defines the first control point
  70546. * @param tangent1 defines the first tangent vector
  70547. * @param value2 defines the second control point
  70548. * @param tangent2 defines the second tangent vector
  70549. * @param amount defines the amount on the interpolation spline (between 0 and 1)
  70550. * @returns the new Vector3
  70551. */
  70552. Vector3.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  70553. var squared = amount * amount;
  70554. var cubed = amount * squared;
  70555. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  70556. var part2 = (-2.0 * cubed) + (3.0 * squared);
  70557. var part3 = (cubed - (2.0 * squared)) + amount;
  70558. var part4 = cubed - squared;
  70559. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  70560. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  70561. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  70562. return new Vector3(x, y, z);
  70563. };
  70564. /**
  70565. * Returns a new Vector3 located for "amount" (float) on the linear interpolation between the vectors "start" and "end"
  70566. * @param start defines the start value
  70567. * @param end defines the end value
  70568. * @param amount max defines amount between both (between 0 and 1)
  70569. * @returns the new Vector3
  70570. */
  70571. Vector3.Lerp = function (start, end, amount) {
  70572. var result = new Vector3(0, 0, 0);
  70573. Vector3.LerpToRef(start, end, amount, result);
  70574. return result;
  70575. };
  70576. /**
  70577. * Sets the given vector "result" with the result of the linear interpolation from the vector "start" for "amount" to the vector "end"
  70578. * @param start defines the start value
  70579. * @param end defines the end value
  70580. * @param amount max defines amount between both (between 0 and 1)
  70581. * @param result defines the Vector3 where to store the result
  70582. */
  70583. Vector3.LerpToRef = function (start, end, amount, result) {
  70584. result.x = start.x + ((end.x - start.x) * amount);
  70585. result.y = start.y + ((end.y - start.y) * amount);
  70586. result.z = start.z + ((end.z - start.z) * amount);
  70587. };
  70588. /**
  70589. * Returns the dot product (float) between the vectors "left" and "right"
  70590. * @param left defines the left operand
  70591. * @param right defines the right operand
  70592. * @returns the dot product
  70593. */
  70594. Vector3.Dot = function (left, right) {
  70595. return (left.x * right.x + left.y * right.y + left.z * right.z);
  70596. };
  70597. /**
  70598. * Returns a new Vector3 as the cross product of the vectors "left" and "right"
  70599. * The cross product is then orthogonal to both "left" and "right"
  70600. * @param left defines the left operand
  70601. * @param right defines the right operand
  70602. * @returns the cross product
  70603. */
  70604. Vector3.Cross = function (left, right) {
  70605. var result = Vector3.Zero();
  70606. Vector3.CrossToRef(left, right, result);
  70607. return result;
  70608. };
  70609. /**
  70610. * Sets the given vector "result" with the cross product of "left" and "right"
  70611. * The cross product is then orthogonal to both "left" and "right"
  70612. * @param left defines the left operand
  70613. * @param right defines the right operand
  70614. * @param result defines the Vector3 where to store the result
  70615. */
  70616. Vector3.CrossToRef = function (left, right, result) {
  70617. var x = left.y * right.z - left.z * right.y;
  70618. var y = left.z * right.x - left.x * right.z;
  70619. var z = left.x * right.y - left.y * right.x;
  70620. result.copyFromFloats(x, y, z);
  70621. };
  70622. /**
  70623. * Returns a new Vector3 as the normalization of the given vector
  70624. * @param vector defines the Vector3 to normalize
  70625. * @returns the new Vector3
  70626. */
  70627. Vector3.Normalize = function (vector) {
  70628. var result = Vector3.Zero();
  70629. Vector3.NormalizeToRef(vector, result);
  70630. return result;
  70631. };
  70632. /**
  70633. * Sets the given vector "result" with the normalization of the given first vector
  70634. * @param vector defines the Vector3 to normalize
  70635. * @param result defines the Vector3 where to store the result
  70636. */
  70637. Vector3.NormalizeToRef = function (vector, result) {
  70638. vector.normalizeToRef(result);
  70639. };
  70640. /**
  70641. * Project a Vector3 onto screen space
  70642. * @param vector defines the Vector3 to project
  70643. * @param world defines the world matrix to use
  70644. * @param transform defines the transform (view x projection) matrix to use
  70645. * @param viewport defines the screen viewport to use
  70646. * @returns the new Vector3
  70647. */
  70648. Vector3.Project = function (vector, world, transform, viewport) {
  70649. var cw = viewport.width;
  70650. var ch = viewport.height;
  70651. var cx = viewport.x;
  70652. var cy = viewport.y;
  70653. var viewportMatrix = MathTmp.Matrix[1];
  70654. 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);
  70655. var matrix = MathTmp.Matrix[0];
  70656. world.multiplyToRef(transform, matrix);
  70657. matrix.multiplyToRef(viewportMatrix, matrix);
  70658. return Vector3.TransformCoordinates(vector, matrix);
  70659. };
  70660. /** @hidden */
  70661. Vector3._UnprojectFromInvertedMatrixToRef = function (source, matrix, result) {
  70662. Vector3.TransformCoordinatesToRef(source, matrix, result);
  70663. var m = matrix.m;
  70664. var num = source.x * m[3] + source.y * m[7] + source.z * m[11] + m[15];
  70665. if (_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(num, 1.0)) {
  70666. result.scaleInPlace(1.0 / num);
  70667. }
  70668. };
  70669. /**
  70670. * Unproject from screen space to object space
  70671. * @param source defines the screen space Vector3 to use
  70672. * @param viewportWidth defines the current width of the viewport
  70673. * @param viewportHeight defines the current height of the viewport
  70674. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70675. * @param transform defines the transform (view x projection) matrix to use
  70676. * @returns the new Vector3
  70677. */
  70678. Vector3.UnprojectFromTransform = function (source, viewportWidth, viewportHeight, world, transform) {
  70679. var matrix = MathTmp.Matrix[0];
  70680. world.multiplyToRef(transform, matrix);
  70681. matrix.invert();
  70682. source.x = source.x / viewportWidth * 2 - 1;
  70683. source.y = -(source.y / viewportHeight * 2 - 1);
  70684. var vector = new Vector3();
  70685. Vector3._UnprojectFromInvertedMatrixToRef(source, matrix, vector);
  70686. return vector;
  70687. };
  70688. /**
  70689. * Unproject from screen space to object space
  70690. * @param source defines the screen space Vector3 to use
  70691. * @param viewportWidth defines the current width of the viewport
  70692. * @param viewportHeight defines the current height of the viewport
  70693. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70694. * @param view defines the view matrix to use
  70695. * @param projection defines the projection matrix to use
  70696. * @returns the new Vector3
  70697. */
  70698. Vector3.Unproject = function (source, viewportWidth, viewportHeight, world, view, projection) {
  70699. var result = Vector3.Zero();
  70700. Vector3.UnprojectToRef(source, viewportWidth, viewportHeight, world, view, projection, result);
  70701. return result;
  70702. };
  70703. /**
  70704. * Unproject from screen space to object space
  70705. * @param source defines the screen space Vector3 to use
  70706. * @param viewportWidth defines the current width of the viewport
  70707. * @param viewportHeight defines the current height of the viewport
  70708. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70709. * @param view defines the view matrix to use
  70710. * @param projection defines the projection matrix to use
  70711. * @param result defines the Vector3 where to store the result
  70712. */
  70713. Vector3.UnprojectToRef = function (source, viewportWidth, viewportHeight, world, view, projection, result) {
  70714. Vector3.UnprojectFloatsToRef(source.x, source.y, source.z, viewportWidth, viewportHeight, world, view, projection, result);
  70715. };
  70716. /**
  70717. * Unproject from screen space to object space
  70718. * @param sourceX defines the screen space x coordinate to use
  70719. * @param sourceY defines the screen space y coordinate to use
  70720. * @param sourceZ defines the screen space z coordinate to use
  70721. * @param viewportWidth defines the current width of the viewport
  70722. * @param viewportHeight defines the current height of the viewport
  70723. * @param world defines the world matrix to use (can be set to Identity to go to world space)
  70724. * @param view defines the view matrix to use
  70725. * @param projection defines the projection matrix to use
  70726. * @param result defines the Vector3 where to store the result
  70727. */
  70728. Vector3.UnprojectFloatsToRef = function (sourceX, sourceY, sourceZ, viewportWidth, viewportHeight, world, view, projection, result) {
  70729. var matrix = MathTmp.Matrix[0];
  70730. world.multiplyToRef(view, matrix);
  70731. matrix.multiplyToRef(projection, matrix);
  70732. matrix.invert();
  70733. var screenSource = MathTmp.Vector3[0];
  70734. screenSource.x = sourceX / viewportWidth * 2 - 1;
  70735. screenSource.y = -(sourceY / viewportHeight * 2 - 1);
  70736. screenSource.z = 2 * sourceZ - 1.0;
  70737. Vector3._UnprojectFromInvertedMatrixToRef(screenSource, matrix, result);
  70738. };
  70739. /**
  70740. * Gets the minimal coordinate values between two Vector3
  70741. * @param left defines the first operand
  70742. * @param right defines the second operand
  70743. * @returns the new Vector3
  70744. */
  70745. Vector3.Minimize = function (left, right) {
  70746. var min = left.clone();
  70747. min.minimizeInPlace(right);
  70748. return min;
  70749. };
  70750. /**
  70751. * Gets the maximal coordinate values between two Vector3
  70752. * @param left defines the first operand
  70753. * @param right defines the second operand
  70754. * @returns the new Vector3
  70755. */
  70756. Vector3.Maximize = function (left, right) {
  70757. var max = left.clone();
  70758. max.maximizeInPlace(right);
  70759. return max;
  70760. };
  70761. /**
  70762. * Returns the distance between the vectors "value1" and "value2"
  70763. * @param value1 defines the first operand
  70764. * @param value2 defines the second operand
  70765. * @returns the distance
  70766. */
  70767. Vector3.Distance = function (value1, value2) {
  70768. return Math.sqrt(Vector3.DistanceSquared(value1, value2));
  70769. };
  70770. /**
  70771. * Returns the squared distance between the vectors "value1" and "value2"
  70772. * @param value1 defines the first operand
  70773. * @param value2 defines the second operand
  70774. * @returns the squared distance
  70775. */
  70776. Vector3.DistanceSquared = function (value1, value2) {
  70777. var x = value1.x - value2.x;
  70778. var y = value1.y - value2.y;
  70779. var z = value1.z - value2.z;
  70780. return (x * x) + (y * y) + (z * z);
  70781. };
  70782. /**
  70783. * Returns a new Vector3 located at the center between "value1" and "value2"
  70784. * @param value1 defines the first operand
  70785. * @param value2 defines the second operand
  70786. * @returns the new Vector3
  70787. */
  70788. Vector3.Center = function (value1, value2) {
  70789. var center = value1.add(value2);
  70790. center.scaleInPlace(0.5);
  70791. return center;
  70792. };
  70793. /**
  70794. * Given three orthogonal normalized left-handed oriented Vector3 axis in space (target system),
  70795. * RotationFromAxis() returns the rotation Euler angles (ex : rotation.x, rotation.y, rotation.z) to apply
  70796. * to something in order to rotate it from its local system to the given target system
  70797. * Note: axis1, axis2 and axis3 are normalized during this operation
  70798. * @param axis1 defines the first axis
  70799. * @param axis2 defines the second axis
  70800. * @param axis3 defines the third axis
  70801. * @returns a new Vector3
  70802. */
  70803. Vector3.RotationFromAxis = function (axis1, axis2, axis3) {
  70804. var rotation = Vector3.Zero();
  70805. Vector3.RotationFromAxisToRef(axis1, axis2, axis3, rotation);
  70806. return rotation;
  70807. };
  70808. /**
  70809. * The same than RotationFromAxis but updates the given ref Vector3 parameter instead of returning a new Vector3
  70810. * @param axis1 defines the first axis
  70811. * @param axis2 defines the second axis
  70812. * @param axis3 defines the third axis
  70813. * @param ref defines the Vector3 where to store the result
  70814. */
  70815. Vector3.RotationFromAxisToRef = function (axis1, axis2, axis3, ref) {
  70816. var quat = MathTmp.Quaternion[0];
  70817. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  70818. quat.toEulerAnglesToRef(ref);
  70819. };
  70820. Vector3._UpReadOnly = Vector3.Up();
  70821. return Vector3;
  70822. }());
  70823. /**
  70824. * Vector4 class created for EulerAngle class conversion to Quaternion
  70825. */
  70826. var Vector4 = /** @class */ (function () {
  70827. /**
  70828. * Creates a Vector4 object from the given floats.
  70829. * @param x x value of the vector
  70830. * @param y y value of the vector
  70831. * @param z z value of the vector
  70832. * @param w w value of the vector
  70833. */
  70834. function Vector4(
  70835. /** x value of the vector */
  70836. x,
  70837. /** y value of the vector */
  70838. y,
  70839. /** z value of the vector */
  70840. z,
  70841. /** w value of the vector */
  70842. w) {
  70843. this.x = x;
  70844. this.y = y;
  70845. this.z = z;
  70846. this.w = w;
  70847. }
  70848. /**
  70849. * Returns the string with the Vector4 coordinates.
  70850. * @returns a string containing all the vector values
  70851. */
  70852. Vector4.prototype.toString = function () {
  70853. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  70854. };
  70855. /**
  70856. * Returns the string "Vector4".
  70857. * @returns "Vector4"
  70858. */
  70859. Vector4.prototype.getClassName = function () {
  70860. return "Vector4";
  70861. };
  70862. /**
  70863. * Returns the Vector4 hash code.
  70864. * @returns a unique hash code
  70865. */
  70866. Vector4.prototype.getHashCode = function () {
  70867. var hash = this.x || 0;
  70868. hash = (hash * 397) ^ (this.y || 0);
  70869. hash = (hash * 397) ^ (this.z || 0);
  70870. hash = (hash * 397) ^ (this.w || 0);
  70871. return hash;
  70872. };
  70873. // Operators
  70874. /**
  70875. * Returns a new array populated with 4 elements : the Vector4 coordinates.
  70876. * @returns the resulting array
  70877. */
  70878. Vector4.prototype.asArray = function () {
  70879. var result = new Array();
  70880. this.toArray(result, 0);
  70881. return result;
  70882. };
  70883. /**
  70884. * Populates the given array from the given index with the Vector4 coordinates.
  70885. * @param array array to populate
  70886. * @param index index of the array to start at (default: 0)
  70887. * @returns the Vector4.
  70888. */
  70889. Vector4.prototype.toArray = function (array, index) {
  70890. if (index === undefined) {
  70891. index = 0;
  70892. }
  70893. array[index] = this.x;
  70894. array[index + 1] = this.y;
  70895. array[index + 2] = this.z;
  70896. array[index + 3] = this.w;
  70897. return this;
  70898. };
  70899. /**
  70900. * Adds the given vector to the current Vector4.
  70901. * @param otherVector the vector to add
  70902. * @returns the updated Vector4.
  70903. */
  70904. Vector4.prototype.addInPlace = function (otherVector) {
  70905. this.x += otherVector.x;
  70906. this.y += otherVector.y;
  70907. this.z += otherVector.z;
  70908. this.w += otherVector.w;
  70909. return this;
  70910. };
  70911. /**
  70912. * Returns a new Vector4 as the result of the addition of the current Vector4 and the given one.
  70913. * @param otherVector the vector to add
  70914. * @returns the resulting vector
  70915. */
  70916. Vector4.prototype.add = function (otherVector) {
  70917. return new Vector4(this.x + otherVector.x, this.y + otherVector.y, this.z + otherVector.z, this.w + otherVector.w);
  70918. };
  70919. /**
  70920. * Updates the given vector "result" with the result of the addition of the current Vector4 and the given one.
  70921. * @param otherVector the vector to add
  70922. * @param result the vector to store the result
  70923. * @returns the current Vector4.
  70924. */
  70925. Vector4.prototype.addToRef = function (otherVector, result) {
  70926. result.x = this.x + otherVector.x;
  70927. result.y = this.y + otherVector.y;
  70928. result.z = this.z + otherVector.z;
  70929. result.w = this.w + otherVector.w;
  70930. return this;
  70931. };
  70932. /**
  70933. * Subtract in place the given vector from the current Vector4.
  70934. * @param otherVector the vector to subtract
  70935. * @returns the updated Vector4.
  70936. */
  70937. Vector4.prototype.subtractInPlace = function (otherVector) {
  70938. this.x -= otherVector.x;
  70939. this.y -= otherVector.y;
  70940. this.z -= otherVector.z;
  70941. this.w -= otherVector.w;
  70942. return this;
  70943. };
  70944. /**
  70945. * Returns a new Vector4 with the result of the subtraction of the given vector from the current Vector4.
  70946. * @param otherVector the vector to add
  70947. * @returns the new vector with the result
  70948. */
  70949. Vector4.prototype.subtract = function (otherVector) {
  70950. return new Vector4(this.x - otherVector.x, this.y - otherVector.y, this.z - otherVector.z, this.w - otherVector.w);
  70951. };
  70952. /**
  70953. * Sets the given vector "result" with the result of the subtraction of the given vector from the current Vector4.
  70954. * @param otherVector the vector to subtract
  70955. * @param result the vector to store the result
  70956. * @returns the current Vector4.
  70957. */
  70958. Vector4.prototype.subtractToRef = function (otherVector, result) {
  70959. result.x = this.x - otherVector.x;
  70960. result.y = this.y - otherVector.y;
  70961. result.z = this.z - otherVector.z;
  70962. result.w = this.w - otherVector.w;
  70963. return this;
  70964. };
  70965. /**
  70966. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70967. */
  70968. /**
  70969. * Returns a new Vector4 set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70970. * @param x value to subtract
  70971. * @param y value to subtract
  70972. * @param z value to subtract
  70973. * @param w value to subtract
  70974. * @returns new vector containing the result
  70975. */
  70976. Vector4.prototype.subtractFromFloats = function (x, y, z, w) {
  70977. return new Vector4(this.x - x, this.y - y, this.z - z, this.w - w);
  70978. };
  70979. /**
  70980. * Sets the given vector "result" set with the result of the subtraction of the given floats from the current Vector4 coordinates.
  70981. * @param x value to subtract
  70982. * @param y value to subtract
  70983. * @param z value to subtract
  70984. * @param w value to subtract
  70985. * @param result the vector to store the result in
  70986. * @returns the current Vector4.
  70987. */
  70988. Vector4.prototype.subtractFromFloatsToRef = function (x, y, z, w, result) {
  70989. result.x = this.x - x;
  70990. result.y = this.y - y;
  70991. result.z = this.z - z;
  70992. result.w = this.w - w;
  70993. return this;
  70994. };
  70995. /**
  70996. * Returns a new Vector4 set with the current Vector4 negated coordinates.
  70997. * @returns a new vector with the negated values
  70998. */
  70999. Vector4.prototype.negate = function () {
  71000. return new Vector4(-this.x, -this.y, -this.z, -this.w);
  71001. };
  71002. /**
  71003. * Multiplies the current Vector4 coordinates by scale (float).
  71004. * @param scale the number to scale with
  71005. * @returns the updated Vector4.
  71006. */
  71007. Vector4.prototype.scaleInPlace = function (scale) {
  71008. this.x *= scale;
  71009. this.y *= scale;
  71010. this.z *= scale;
  71011. this.w *= scale;
  71012. return this;
  71013. };
  71014. /**
  71015. * Returns a new Vector4 set with the current Vector4 coordinates multiplied by scale (float).
  71016. * @param scale the number to scale with
  71017. * @returns a new vector with the result
  71018. */
  71019. Vector4.prototype.scale = function (scale) {
  71020. return new Vector4(this.x * scale, this.y * scale, this.z * scale, this.w * scale);
  71021. };
  71022. /**
  71023. * Sets the given vector "result" with the current Vector4 coordinates multiplied by scale (float).
  71024. * @param scale the number to scale with
  71025. * @param result a vector to store the result in
  71026. * @returns the current Vector4.
  71027. */
  71028. Vector4.prototype.scaleToRef = function (scale, result) {
  71029. result.x = this.x * scale;
  71030. result.y = this.y * scale;
  71031. result.z = this.z * scale;
  71032. result.w = this.w * scale;
  71033. return this;
  71034. };
  71035. /**
  71036. * Scale the current Vector4 values by a factor and add the result to a given Vector4
  71037. * @param scale defines the scale factor
  71038. * @param result defines the Vector4 object where to store the result
  71039. * @returns the unmodified current Vector4
  71040. */
  71041. Vector4.prototype.scaleAndAddToRef = function (scale, result) {
  71042. result.x += this.x * scale;
  71043. result.y += this.y * scale;
  71044. result.z += this.z * scale;
  71045. result.w += this.w * scale;
  71046. return this;
  71047. };
  71048. /**
  71049. * Boolean : True if the current Vector4 coordinates are stricly equal to the given ones.
  71050. * @param otherVector the vector to compare against
  71051. * @returns true if they are equal
  71052. */
  71053. Vector4.prototype.equals = function (otherVector) {
  71054. return otherVector && this.x === otherVector.x && this.y === otherVector.y && this.z === otherVector.z && this.w === otherVector.w;
  71055. };
  71056. /**
  71057. * Boolean : True if the current Vector4 coordinates are each beneath the distance "epsilon" from the given vector ones.
  71058. * @param otherVector vector to compare against
  71059. * @param epsilon (Default: very small number)
  71060. * @returns true if they are equal
  71061. */
  71062. Vector4.prototype.equalsWithEpsilon = function (otherVector, epsilon) {
  71063. if (epsilon === void 0) { epsilon = Epsilon; }
  71064. return otherVector
  71065. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.x, otherVector.x, epsilon)
  71066. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.y, otherVector.y, epsilon)
  71067. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.z, otherVector.z, epsilon)
  71068. && _math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(this.w, otherVector.w, epsilon);
  71069. };
  71070. /**
  71071. * Boolean : True if the given floats are strictly equal to the current Vector4 coordinates.
  71072. * @param x x value to compare against
  71073. * @param y y value to compare against
  71074. * @param z z value to compare against
  71075. * @param w w value to compare against
  71076. * @returns true if equal
  71077. */
  71078. Vector4.prototype.equalsToFloats = function (x, y, z, w) {
  71079. return this.x === x && this.y === y && this.z === z && this.w === w;
  71080. };
  71081. /**
  71082. * Multiplies in place the current Vector4 by the given one.
  71083. * @param otherVector vector to multiple with
  71084. * @returns the updated Vector4.
  71085. */
  71086. Vector4.prototype.multiplyInPlace = function (otherVector) {
  71087. this.x *= otherVector.x;
  71088. this.y *= otherVector.y;
  71089. this.z *= otherVector.z;
  71090. this.w *= otherVector.w;
  71091. return this;
  71092. };
  71093. /**
  71094. * Returns a new Vector4 set with the multiplication result of the current Vector4 and the given one.
  71095. * @param otherVector vector to multiple with
  71096. * @returns resulting new vector
  71097. */
  71098. Vector4.prototype.multiply = function (otherVector) {
  71099. return new Vector4(this.x * otherVector.x, this.y * otherVector.y, this.z * otherVector.z, this.w * otherVector.w);
  71100. };
  71101. /**
  71102. * Updates the given vector "result" with the multiplication result of the current Vector4 and the given one.
  71103. * @param otherVector vector to multiple with
  71104. * @param result vector to store the result
  71105. * @returns the current Vector4.
  71106. */
  71107. Vector4.prototype.multiplyToRef = function (otherVector, result) {
  71108. result.x = this.x * otherVector.x;
  71109. result.y = this.y * otherVector.y;
  71110. result.z = this.z * otherVector.z;
  71111. result.w = this.w * otherVector.w;
  71112. return this;
  71113. };
  71114. /**
  71115. * Returns a new Vector4 set with the multiplication result of the given floats and the current Vector4 coordinates.
  71116. * @param x x value multiply with
  71117. * @param y y value multiply with
  71118. * @param z z value multiply with
  71119. * @param w w value multiply with
  71120. * @returns resulting new vector
  71121. */
  71122. Vector4.prototype.multiplyByFloats = function (x, y, z, w) {
  71123. return new Vector4(this.x * x, this.y * y, this.z * z, this.w * w);
  71124. };
  71125. /**
  71126. * Returns a new Vector4 set with the division result of the current Vector4 by the given one.
  71127. * @param otherVector vector to devide with
  71128. * @returns resulting new vector
  71129. */
  71130. Vector4.prototype.divide = function (otherVector) {
  71131. return new Vector4(this.x / otherVector.x, this.y / otherVector.y, this.z / otherVector.z, this.w / otherVector.w);
  71132. };
  71133. /**
  71134. * Updates the given vector "result" with the division result of the current Vector4 by the given one.
  71135. * @param otherVector vector to devide with
  71136. * @param result vector to store the result
  71137. * @returns the current Vector4.
  71138. */
  71139. Vector4.prototype.divideToRef = function (otherVector, result) {
  71140. result.x = this.x / otherVector.x;
  71141. result.y = this.y / otherVector.y;
  71142. result.z = this.z / otherVector.z;
  71143. result.w = this.w / otherVector.w;
  71144. return this;
  71145. };
  71146. /**
  71147. * Divides the current Vector3 coordinates by the given ones.
  71148. * @param otherVector vector to devide with
  71149. * @returns the updated Vector3.
  71150. */
  71151. Vector4.prototype.divideInPlace = function (otherVector) {
  71152. return this.divideToRef(otherVector, this);
  71153. };
  71154. /**
  71155. * Updates the Vector4 coordinates with the minimum values between its own and the given vector ones
  71156. * @param other defines the second operand
  71157. * @returns the current updated Vector4
  71158. */
  71159. Vector4.prototype.minimizeInPlace = function (other) {
  71160. if (other.x < this.x) {
  71161. this.x = other.x;
  71162. }
  71163. if (other.y < this.y) {
  71164. this.y = other.y;
  71165. }
  71166. if (other.z < this.z) {
  71167. this.z = other.z;
  71168. }
  71169. if (other.w < this.w) {
  71170. this.w = other.w;
  71171. }
  71172. return this;
  71173. };
  71174. /**
  71175. * Updates the Vector4 coordinates with the maximum values between its own and the given vector ones
  71176. * @param other defines the second operand
  71177. * @returns the current updated Vector4
  71178. */
  71179. Vector4.prototype.maximizeInPlace = function (other) {
  71180. if (other.x > this.x) {
  71181. this.x = other.x;
  71182. }
  71183. if (other.y > this.y) {
  71184. this.y = other.y;
  71185. }
  71186. if (other.z > this.z) {
  71187. this.z = other.z;
  71188. }
  71189. if (other.w > this.w) {
  71190. this.w = other.w;
  71191. }
  71192. return this;
  71193. };
  71194. /**
  71195. * Gets a new Vector4 from current Vector4 floored values
  71196. * @returns a new Vector4
  71197. */
  71198. Vector4.prototype.floor = function () {
  71199. return new Vector4(Math.floor(this.x), Math.floor(this.y), Math.floor(this.z), Math.floor(this.w));
  71200. };
  71201. /**
  71202. * Gets a new Vector4 from current Vector3 floored values
  71203. * @returns a new Vector4
  71204. */
  71205. Vector4.prototype.fract = function () {
  71206. 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));
  71207. };
  71208. // Properties
  71209. /**
  71210. * Returns the Vector4 length (float).
  71211. * @returns the length
  71212. */
  71213. Vector4.prototype.length = function () {
  71214. return Math.sqrt(this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  71215. };
  71216. /**
  71217. * Returns the Vector4 squared length (float).
  71218. * @returns the length squared
  71219. */
  71220. Vector4.prototype.lengthSquared = function () {
  71221. return (this.x * this.x + this.y * this.y + this.z * this.z + this.w * this.w);
  71222. };
  71223. // Methods
  71224. /**
  71225. * Normalizes in place the Vector4.
  71226. * @returns the updated Vector4.
  71227. */
  71228. Vector4.prototype.normalize = function () {
  71229. var len = this.length();
  71230. if (len === 0) {
  71231. return this;
  71232. }
  71233. return this.scaleInPlace(1.0 / len);
  71234. };
  71235. /**
  71236. * Returns a new Vector3 from the Vector4 (x, y, z) coordinates.
  71237. * @returns this converted to a new vector3
  71238. */
  71239. Vector4.prototype.toVector3 = function () {
  71240. return new Vector3(this.x, this.y, this.z);
  71241. };
  71242. /**
  71243. * Returns a new Vector4 copied from the current one.
  71244. * @returns the new cloned vector
  71245. */
  71246. Vector4.prototype.clone = function () {
  71247. return new Vector4(this.x, this.y, this.z, this.w);
  71248. };
  71249. /**
  71250. * Updates the current Vector4 with the given one coordinates.
  71251. * @param source the source vector to copy from
  71252. * @returns the updated Vector4.
  71253. */
  71254. Vector4.prototype.copyFrom = function (source) {
  71255. this.x = source.x;
  71256. this.y = source.y;
  71257. this.z = source.z;
  71258. this.w = source.w;
  71259. return this;
  71260. };
  71261. /**
  71262. * Updates the current Vector4 coordinates with the given floats.
  71263. * @param x float to copy from
  71264. * @param y float to copy from
  71265. * @param z float to copy from
  71266. * @param w float to copy from
  71267. * @returns the updated Vector4.
  71268. */
  71269. Vector4.prototype.copyFromFloats = function (x, y, z, w) {
  71270. this.x = x;
  71271. this.y = y;
  71272. this.z = z;
  71273. this.w = w;
  71274. return this;
  71275. };
  71276. /**
  71277. * Updates the current Vector4 coordinates with the given floats.
  71278. * @param x float to set from
  71279. * @param y float to set from
  71280. * @param z float to set from
  71281. * @param w float to set from
  71282. * @returns the updated Vector4.
  71283. */
  71284. Vector4.prototype.set = function (x, y, z, w) {
  71285. return this.copyFromFloats(x, y, z, w);
  71286. };
  71287. /**
  71288. * Copies the given float to the current Vector3 coordinates
  71289. * @param v defines the x, y, z and w coordinates of the operand
  71290. * @returns the current updated Vector3
  71291. */
  71292. Vector4.prototype.setAll = function (v) {
  71293. this.x = this.y = this.z = this.w = v;
  71294. return this;
  71295. };
  71296. // Statics
  71297. /**
  71298. * Returns a new Vector4 set from the starting index of the given array.
  71299. * @param array the array to pull values from
  71300. * @param offset the offset into the array to start at
  71301. * @returns the new vector
  71302. */
  71303. Vector4.FromArray = function (array, offset) {
  71304. if (!offset) {
  71305. offset = 0;
  71306. }
  71307. return new Vector4(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  71308. };
  71309. /**
  71310. * Updates the given vector "result" from the starting index of the given array.
  71311. * @param array the array to pull values from
  71312. * @param offset the offset into the array to start at
  71313. * @param result the vector to store the result in
  71314. */
  71315. Vector4.FromArrayToRef = function (array, offset, result) {
  71316. result.x = array[offset];
  71317. result.y = array[offset + 1];
  71318. result.z = array[offset + 2];
  71319. result.w = array[offset + 3];
  71320. };
  71321. /**
  71322. * Updates the given vector "result" from the starting index of the given Float32Array.
  71323. * @param array the array to pull values from
  71324. * @param offset the offset into the array to start at
  71325. * @param result the vector to store the result in
  71326. */
  71327. Vector4.FromFloatArrayToRef = function (array, offset, result) {
  71328. Vector4.FromArrayToRef(array, offset, result);
  71329. };
  71330. /**
  71331. * Updates the given vector "result" coordinates from the given floats.
  71332. * @param x float to set from
  71333. * @param y float to set from
  71334. * @param z float to set from
  71335. * @param w float to set from
  71336. * @param result the vector to the floats in
  71337. */
  71338. Vector4.FromFloatsToRef = function (x, y, z, w, result) {
  71339. result.x = x;
  71340. result.y = y;
  71341. result.z = z;
  71342. result.w = w;
  71343. };
  71344. /**
  71345. * Returns a new Vector4 set to (0.0, 0.0, 0.0, 0.0)
  71346. * @returns the new vector
  71347. */
  71348. Vector4.Zero = function () {
  71349. return new Vector4(0.0, 0.0, 0.0, 0.0);
  71350. };
  71351. /**
  71352. * Returns a new Vector4 set to (1.0, 1.0, 1.0, 1.0)
  71353. * @returns the new vector
  71354. */
  71355. Vector4.One = function () {
  71356. return new Vector4(1.0, 1.0, 1.0, 1.0);
  71357. };
  71358. /**
  71359. * Returns a new normalized Vector4 from the given one.
  71360. * @param vector the vector to normalize
  71361. * @returns the vector
  71362. */
  71363. Vector4.Normalize = function (vector) {
  71364. var result = Vector4.Zero();
  71365. Vector4.NormalizeToRef(vector, result);
  71366. return result;
  71367. };
  71368. /**
  71369. * Updates the given vector "result" from the normalization of the given one.
  71370. * @param vector the vector to normalize
  71371. * @param result the vector to store the result in
  71372. */
  71373. Vector4.NormalizeToRef = function (vector, result) {
  71374. result.copyFrom(vector);
  71375. result.normalize();
  71376. };
  71377. /**
  71378. * Returns a vector with the minimum values from the left and right vectors
  71379. * @param left left vector to minimize
  71380. * @param right right vector to minimize
  71381. * @returns a new vector with the minimum of the left and right vector values
  71382. */
  71383. Vector4.Minimize = function (left, right) {
  71384. var min = left.clone();
  71385. min.minimizeInPlace(right);
  71386. return min;
  71387. };
  71388. /**
  71389. * Returns a vector with the maximum values from the left and right vectors
  71390. * @param left left vector to maximize
  71391. * @param right right vector to maximize
  71392. * @returns a new vector with the maximum of the left and right vector values
  71393. */
  71394. Vector4.Maximize = function (left, right) {
  71395. var max = left.clone();
  71396. max.maximizeInPlace(right);
  71397. return max;
  71398. };
  71399. /**
  71400. * Returns the distance (float) between the vectors "value1" and "value2".
  71401. * @param value1 value to calulate the distance between
  71402. * @param value2 value to calulate the distance between
  71403. * @return the distance between the two vectors
  71404. */
  71405. Vector4.Distance = function (value1, value2) {
  71406. return Math.sqrt(Vector4.DistanceSquared(value1, value2));
  71407. };
  71408. /**
  71409. * Returns the squared distance (float) between the vectors "value1" and "value2".
  71410. * @param value1 value to calulate the distance between
  71411. * @param value2 value to calulate the distance between
  71412. * @return the distance between the two vectors squared
  71413. */
  71414. Vector4.DistanceSquared = function (value1, value2) {
  71415. var x = value1.x - value2.x;
  71416. var y = value1.y - value2.y;
  71417. var z = value1.z - value2.z;
  71418. var w = value1.w - value2.w;
  71419. return (x * x) + (y * y) + (z * z) + (w * w);
  71420. };
  71421. /**
  71422. * Returns a new Vector4 located at the center between the vectors "value1" and "value2".
  71423. * @param value1 value to calulate the center between
  71424. * @param value2 value to calulate the center between
  71425. * @return the center between the two vectors
  71426. */
  71427. Vector4.Center = function (value1, value2) {
  71428. var center = value1.add(value2);
  71429. center.scaleInPlace(0.5);
  71430. return center;
  71431. };
  71432. /**
  71433. * Returns a new Vector4 set with the result of the normal transformation by the given matrix of the given vector.
  71434. * This methods computes transformed normalized direction vectors only.
  71435. * @param vector the vector to transform
  71436. * @param transformation the transformation matrix to apply
  71437. * @returns the new vector
  71438. */
  71439. Vector4.TransformNormal = function (vector, transformation) {
  71440. var result = Vector4.Zero();
  71441. Vector4.TransformNormalToRef(vector, transformation, result);
  71442. return result;
  71443. };
  71444. /**
  71445. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given vector.
  71446. * This methods computes transformed normalized direction vectors only.
  71447. * @param vector the vector to transform
  71448. * @param transformation the transformation matrix to apply
  71449. * @param result the vector to store the result in
  71450. */
  71451. Vector4.TransformNormalToRef = function (vector, transformation, result) {
  71452. var m = transformation.m;
  71453. var x = (vector.x * m[0]) + (vector.y * m[4]) + (vector.z * m[8]);
  71454. var y = (vector.x * m[1]) + (vector.y * m[5]) + (vector.z * m[9]);
  71455. var z = (vector.x * m[2]) + (vector.y * m[6]) + (vector.z * m[10]);
  71456. result.x = x;
  71457. result.y = y;
  71458. result.z = z;
  71459. result.w = vector.w;
  71460. };
  71461. /**
  71462. * Sets the given vector "result" with the result of the normal transformation by the given matrix of the given floats (x, y, z, w).
  71463. * This methods computes transformed normalized direction vectors only.
  71464. * @param x value to transform
  71465. * @param y value to transform
  71466. * @param z value to transform
  71467. * @param w value to transform
  71468. * @param transformation the transformation matrix to apply
  71469. * @param result the vector to store the results in
  71470. */
  71471. Vector4.TransformNormalFromFloatsToRef = function (x, y, z, w, transformation, result) {
  71472. var m = transformation.m;
  71473. result.x = (x * m[0]) + (y * m[4]) + (z * m[8]);
  71474. result.y = (x * m[1]) + (y * m[5]) + (z * m[9]);
  71475. result.z = (x * m[2]) + (y * m[6]) + (z * m[10]);
  71476. result.w = w;
  71477. };
  71478. /**
  71479. * Creates a new Vector4 from a Vector3
  71480. * @param source defines the source data
  71481. * @param w defines the 4th component (default is 0)
  71482. * @returns a new Vector4
  71483. */
  71484. Vector4.FromVector3 = function (source, w) {
  71485. if (w === void 0) { w = 0; }
  71486. return new Vector4(source.x, source.y, source.z, w);
  71487. };
  71488. return Vector4;
  71489. }());
  71490. /**
  71491. * Size containing widht and height
  71492. */
  71493. var Size = /** @class */ (function () {
  71494. /**
  71495. * Creates a Size object from the given width and height (floats).
  71496. * @param width width of the new size
  71497. * @param height height of the new size
  71498. */
  71499. function Size(width, height) {
  71500. this.width = width;
  71501. this.height = height;
  71502. }
  71503. /**
  71504. * Returns a string with the Size width and height
  71505. * @returns a string with the Size width and height
  71506. */
  71507. Size.prototype.toString = function () {
  71508. return "{W: " + this.width + ", H: " + this.height + "}";
  71509. };
  71510. /**
  71511. * "Size"
  71512. * @returns the string "Size"
  71513. */
  71514. Size.prototype.getClassName = function () {
  71515. return "Size";
  71516. };
  71517. /**
  71518. * Returns the Size hash code.
  71519. * @returns a hash code for a unique width and height
  71520. */
  71521. Size.prototype.getHashCode = function () {
  71522. var hash = this.width || 0;
  71523. hash = (hash * 397) ^ (this.height || 0);
  71524. return hash;
  71525. };
  71526. /**
  71527. * Updates the current size from the given one.
  71528. * @param src the given size
  71529. */
  71530. Size.prototype.copyFrom = function (src) {
  71531. this.width = src.width;
  71532. this.height = src.height;
  71533. };
  71534. /**
  71535. * Updates in place the current Size from the given floats.
  71536. * @param width width of the new size
  71537. * @param height height of the new size
  71538. * @returns the updated Size.
  71539. */
  71540. Size.prototype.copyFromFloats = function (width, height) {
  71541. this.width = width;
  71542. this.height = height;
  71543. return this;
  71544. };
  71545. /**
  71546. * Updates in place the current Size from the given floats.
  71547. * @param width width to set
  71548. * @param height height to set
  71549. * @returns the updated Size.
  71550. */
  71551. Size.prototype.set = function (width, height) {
  71552. return this.copyFromFloats(width, height);
  71553. };
  71554. /**
  71555. * Multiplies the width and height by numbers
  71556. * @param w factor to multiple the width by
  71557. * @param h factor to multiple the height by
  71558. * @returns a new Size set with the multiplication result of the current Size and the given floats.
  71559. */
  71560. Size.prototype.multiplyByFloats = function (w, h) {
  71561. return new Size(this.width * w, this.height * h);
  71562. };
  71563. /**
  71564. * Clones the size
  71565. * @returns a new Size copied from the given one.
  71566. */
  71567. Size.prototype.clone = function () {
  71568. return new Size(this.width, this.height);
  71569. };
  71570. /**
  71571. * True if the current Size and the given one width and height are strictly equal.
  71572. * @param other the other size to compare against
  71573. * @returns True if the current Size and the given one width and height are strictly equal.
  71574. */
  71575. Size.prototype.equals = function (other) {
  71576. if (!other) {
  71577. return false;
  71578. }
  71579. return (this.width === other.width) && (this.height === other.height);
  71580. };
  71581. Object.defineProperty(Size.prototype, "surface", {
  71582. /**
  71583. * The surface of the Size : width * height (float).
  71584. */
  71585. get: function () {
  71586. return this.width * this.height;
  71587. },
  71588. enumerable: true,
  71589. configurable: true
  71590. });
  71591. /**
  71592. * Create a new size of zero
  71593. * @returns a new Size set to (0.0, 0.0)
  71594. */
  71595. Size.Zero = function () {
  71596. return new Size(0.0, 0.0);
  71597. };
  71598. /**
  71599. * Sums the width and height of two sizes
  71600. * @param otherSize size to add to this size
  71601. * @returns a new Size set as the addition result of the current Size and the given one.
  71602. */
  71603. Size.prototype.add = function (otherSize) {
  71604. var r = new Size(this.width + otherSize.width, this.height + otherSize.height);
  71605. return r;
  71606. };
  71607. /**
  71608. * Subtracts the width and height of two
  71609. * @param otherSize size to subtract to this size
  71610. * @returns a new Size set as the subtraction result of the given one from the current Size.
  71611. */
  71612. Size.prototype.subtract = function (otherSize) {
  71613. var r = new Size(this.width - otherSize.width, this.height - otherSize.height);
  71614. return r;
  71615. };
  71616. /**
  71617. * Creates a new Size set at the linear interpolation "amount" between "start" and "end"
  71618. * @param start starting size to lerp between
  71619. * @param end end size to lerp between
  71620. * @param amount amount to lerp between the start and end values
  71621. * @returns a new Size set at the linear interpolation "amount" between "start" and "end"
  71622. */
  71623. Size.Lerp = function (start, end, amount) {
  71624. var w = start.width + ((end.width - start.width) * amount);
  71625. var h = start.height + ((end.height - start.height) * amount);
  71626. return new Size(w, h);
  71627. };
  71628. return Size;
  71629. }());
  71630. /**
  71631. * Class used to store quaternion data
  71632. * @see https://en.wikipedia.org/wiki/Quaternion
  71633. * @see http://doc.babylonjs.com/features/position,_rotation,_scaling
  71634. */
  71635. var Quaternion = /** @class */ (function () {
  71636. /**
  71637. * Creates a new Quaternion from the given floats
  71638. * @param x defines the first component (0 by default)
  71639. * @param y defines the second component (0 by default)
  71640. * @param z defines the third component (0 by default)
  71641. * @param w defines the fourth component (1.0 by default)
  71642. */
  71643. function Quaternion(
  71644. /** defines the first component (0 by default) */
  71645. x,
  71646. /** defines the second component (0 by default) */
  71647. y,
  71648. /** defines the third component (0 by default) */
  71649. z,
  71650. /** defines the fourth component (1.0 by default) */
  71651. w) {
  71652. if (x === void 0) { x = 0.0; }
  71653. if (y === void 0) { y = 0.0; }
  71654. if (z === void 0) { z = 0.0; }
  71655. if (w === void 0) { w = 1.0; }
  71656. this.x = x;
  71657. this.y = y;
  71658. this.z = z;
  71659. this.w = w;
  71660. }
  71661. /**
  71662. * Gets a string representation for the current quaternion
  71663. * @returns a string with the Quaternion coordinates
  71664. */
  71665. Quaternion.prototype.toString = function () {
  71666. return "{X: " + this.x + " Y:" + this.y + " Z:" + this.z + " W:" + this.w + "}";
  71667. };
  71668. /**
  71669. * Gets the class name of the quaternion
  71670. * @returns the string "Quaternion"
  71671. */
  71672. Quaternion.prototype.getClassName = function () {
  71673. return "Quaternion";
  71674. };
  71675. /**
  71676. * Gets a hash code for this quaternion
  71677. * @returns the quaternion hash code
  71678. */
  71679. Quaternion.prototype.getHashCode = function () {
  71680. var hash = this.x || 0;
  71681. hash = (hash * 397) ^ (this.y || 0);
  71682. hash = (hash * 397) ^ (this.z || 0);
  71683. hash = (hash * 397) ^ (this.w || 0);
  71684. return hash;
  71685. };
  71686. /**
  71687. * Copy the quaternion to an array
  71688. * @returns a new array populated with 4 elements from the quaternion coordinates
  71689. */
  71690. Quaternion.prototype.asArray = function () {
  71691. return [this.x, this.y, this.z, this.w];
  71692. };
  71693. /**
  71694. * Check if two quaternions are equals
  71695. * @param otherQuaternion defines the second operand
  71696. * @return true if the current quaternion and the given one coordinates are strictly equals
  71697. */
  71698. Quaternion.prototype.equals = function (otherQuaternion) {
  71699. return otherQuaternion && this.x === otherQuaternion.x && this.y === otherQuaternion.y && this.z === otherQuaternion.z && this.w === otherQuaternion.w;
  71700. };
  71701. /**
  71702. * Clone the current quaternion
  71703. * @returns a new quaternion copied from the current one
  71704. */
  71705. Quaternion.prototype.clone = function () {
  71706. return new Quaternion(this.x, this.y, this.z, this.w);
  71707. };
  71708. /**
  71709. * Copy a quaternion to the current one
  71710. * @param other defines the other quaternion
  71711. * @returns the updated current quaternion
  71712. */
  71713. Quaternion.prototype.copyFrom = function (other) {
  71714. this.x = other.x;
  71715. this.y = other.y;
  71716. this.z = other.z;
  71717. this.w = other.w;
  71718. return this;
  71719. };
  71720. /**
  71721. * Updates the current quaternion with the given float coordinates
  71722. * @param x defines the x coordinate
  71723. * @param y defines the y coordinate
  71724. * @param z defines the z coordinate
  71725. * @param w defines the w coordinate
  71726. * @returns the updated current quaternion
  71727. */
  71728. Quaternion.prototype.copyFromFloats = function (x, y, z, w) {
  71729. this.x = x;
  71730. this.y = y;
  71731. this.z = z;
  71732. this.w = w;
  71733. return this;
  71734. };
  71735. /**
  71736. * Updates the current quaternion from the given float coordinates
  71737. * @param x defines the x coordinate
  71738. * @param y defines the y coordinate
  71739. * @param z defines the z coordinate
  71740. * @param w defines the w coordinate
  71741. * @returns the updated current quaternion
  71742. */
  71743. Quaternion.prototype.set = function (x, y, z, w) {
  71744. return this.copyFromFloats(x, y, z, w);
  71745. };
  71746. /**
  71747. * Adds two quaternions
  71748. * @param other defines the second operand
  71749. * @returns a new quaternion as the addition result of the given one and the current quaternion
  71750. */
  71751. Quaternion.prototype.add = function (other) {
  71752. return new Quaternion(this.x + other.x, this.y + other.y, this.z + other.z, this.w + other.w);
  71753. };
  71754. /**
  71755. * Add a quaternion to the current one
  71756. * @param other defines the quaternion to add
  71757. * @returns the current quaternion
  71758. */
  71759. Quaternion.prototype.addInPlace = function (other) {
  71760. this.x += other.x;
  71761. this.y += other.y;
  71762. this.z += other.z;
  71763. this.w += other.w;
  71764. return this;
  71765. };
  71766. /**
  71767. * Subtract two quaternions
  71768. * @param other defines the second operand
  71769. * @returns a new quaternion as the subtraction result of the given one from the current one
  71770. */
  71771. Quaternion.prototype.subtract = function (other) {
  71772. return new Quaternion(this.x - other.x, this.y - other.y, this.z - other.z, this.w - other.w);
  71773. };
  71774. /**
  71775. * Multiplies the current quaternion by a scale factor
  71776. * @param value defines the scale factor
  71777. * @returns a new quaternion set by multiplying the current quaternion coordinates by the float "scale"
  71778. */
  71779. Quaternion.prototype.scale = function (value) {
  71780. return new Quaternion(this.x * value, this.y * value, this.z * value, this.w * value);
  71781. };
  71782. /**
  71783. * Scale the current quaternion values by a factor and stores the result to a given quaternion
  71784. * @param scale defines the scale factor
  71785. * @param result defines the Quaternion object where to store the result
  71786. * @returns the unmodified current quaternion
  71787. */
  71788. Quaternion.prototype.scaleToRef = function (scale, result) {
  71789. result.x = this.x * scale;
  71790. result.y = this.y * scale;
  71791. result.z = this.z * scale;
  71792. result.w = this.w * scale;
  71793. return this;
  71794. };
  71795. /**
  71796. * Multiplies in place the current quaternion by a scale factor
  71797. * @param value defines the scale factor
  71798. * @returns the current modified quaternion
  71799. */
  71800. Quaternion.prototype.scaleInPlace = function (value) {
  71801. this.x *= value;
  71802. this.y *= value;
  71803. this.z *= value;
  71804. this.w *= value;
  71805. return this;
  71806. };
  71807. /**
  71808. * Scale the current quaternion values by a factor and add the result to a given quaternion
  71809. * @param scale defines the scale factor
  71810. * @param result defines the Quaternion object where to store the result
  71811. * @returns the unmodified current quaternion
  71812. */
  71813. Quaternion.prototype.scaleAndAddToRef = function (scale, result) {
  71814. result.x += this.x * scale;
  71815. result.y += this.y * scale;
  71816. result.z += this.z * scale;
  71817. result.w += this.w * scale;
  71818. return this;
  71819. };
  71820. /**
  71821. * Multiplies two quaternions
  71822. * @param q1 defines the second operand
  71823. * @returns a new quaternion set as the multiplication result of the current one with the given one "q1"
  71824. */
  71825. Quaternion.prototype.multiply = function (q1) {
  71826. var result = new Quaternion(0, 0, 0, 1.0);
  71827. this.multiplyToRef(q1, result);
  71828. return result;
  71829. };
  71830. /**
  71831. * Sets the given "result" as the the multiplication result of the current one with the given one "q1"
  71832. * @param q1 defines the second operand
  71833. * @param result defines the target quaternion
  71834. * @returns the current quaternion
  71835. */
  71836. Quaternion.prototype.multiplyToRef = function (q1, result) {
  71837. var x = this.x * q1.w + this.y * q1.z - this.z * q1.y + this.w * q1.x;
  71838. var y = -this.x * q1.z + this.y * q1.w + this.z * q1.x + this.w * q1.y;
  71839. var z = this.x * q1.y - this.y * q1.x + this.z * q1.w + this.w * q1.z;
  71840. var w = -this.x * q1.x - this.y * q1.y - this.z * q1.z + this.w * q1.w;
  71841. result.copyFromFloats(x, y, z, w);
  71842. return this;
  71843. };
  71844. /**
  71845. * Updates the current quaternion with the multiplication of itself with the given one "q1"
  71846. * @param q1 defines the second operand
  71847. * @returns the currentupdated quaternion
  71848. */
  71849. Quaternion.prototype.multiplyInPlace = function (q1) {
  71850. this.multiplyToRef(q1, this);
  71851. return this;
  71852. };
  71853. /**
  71854. * Conjugates (1-q) the current quaternion and stores the result in the given quaternion
  71855. * @param ref defines the target quaternion
  71856. * @returns the current quaternion
  71857. */
  71858. Quaternion.prototype.conjugateToRef = function (ref) {
  71859. ref.copyFromFloats(-this.x, -this.y, -this.z, this.w);
  71860. return this;
  71861. };
  71862. /**
  71863. * Conjugates in place (1-q) the current quaternion
  71864. * @returns the current updated quaternion
  71865. */
  71866. Quaternion.prototype.conjugateInPlace = function () {
  71867. this.x *= -1;
  71868. this.y *= -1;
  71869. this.z *= -1;
  71870. return this;
  71871. };
  71872. /**
  71873. * Conjugates in place (1-q) the current quaternion
  71874. * @returns a new quaternion
  71875. */
  71876. Quaternion.prototype.conjugate = function () {
  71877. var result = new Quaternion(-this.x, -this.y, -this.z, this.w);
  71878. return result;
  71879. };
  71880. /**
  71881. * Gets length of current quaternion
  71882. * @returns the quaternion length (float)
  71883. */
  71884. Quaternion.prototype.length = function () {
  71885. return Math.sqrt((this.x * this.x) + (this.y * this.y) + (this.z * this.z) + (this.w * this.w));
  71886. };
  71887. /**
  71888. * Normalize in place the current quaternion
  71889. * @returns the current updated quaternion
  71890. */
  71891. Quaternion.prototype.normalize = function () {
  71892. var length = 1.0 / this.length();
  71893. this.x *= length;
  71894. this.y *= length;
  71895. this.z *= length;
  71896. this.w *= length;
  71897. return this;
  71898. };
  71899. /**
  71900. * Returns a new Vector3 set with the Euler angles translated from the current quaternion
  71901. * @param order is a reserved parameter and is ignore for now
  71902. * @returns a new Vector3 containing the Euler angles
  71903. */
  71904. Quaternion.prototype.toEulerAngles = function (order) {
  71905. if (order === void 0) { order = "YZX"; }
  71906. var result = Vector3.Zero();
  71907. this.toEulerAnglesToRef(result);
  71908. return result;
  71909. };
  71910. /**
  71911. * Sets the given vector3 "result" with the Euler angles translated from the current quaternion
  71912. * @param result defines the vector which will be filled with the Euler angles
  71913. * @param order is a reserved parameter and is ignore for now
  71914. * @returns the current unchanged quaternion
  71915. */
  71916. Quaternion.prototype.toEulerAnglesToRef = function (result) {
  71917. var qz = this.z;
  71918. var qx = this.x;
  71919. var qy = this.y;
  71920. var qw = this.w;
  71921. var sqw = qw * qw;
  71922. var sqz = qz * qz;
  71923. var sqx = qx * qx;
  71924. var sqy = qy * qy;
  71925. var zAxisY = qy * qz - qx * qw;
  71926. var limit = .4999999;
  71927. if (zAxisY < -limit) {
  71928. result.y = 2 * Math.atan2(qy, qw);
  71929. result.x = Math.PI / 2;
  71930. result.z = 0;
  71931. }
  71932. else if (zAxisY > limit) {
  71933. result.y = 2 * Math.atan2(qy, qw);
  71934. result.x = -Math.PI / 2;
  71935. result.z = 0;
  71936. }
  71937. else {
  71938. result.z = Math.atan2(2.0 * (qx * qy + qz * qw), (-sqz - sqx + sqy + sqw));
  71939. result.x = Math.asin(-2.0 * (qz * qy - qx * qw));
  71940. result.y = Math.atan2(2.0 * (qz * qx + qy * qw), (sqz - sqx - sqy + sqw));
  71941. }
  71942. return this;
  71943. };
  71944. /**
  71945. * Updates the given rotation matrix with the current quaternion values
  71946. * @param result defines the target matrix
  71947. * @returns the current unchanged quaternion
  71948. */
  71949. Quaternion.prototype.toRotationMatrix = function (result) {
  71950. Matrix.FromQuaternionToRef(this, result);
  71951. return this;
  71952. };
  71953. /**
  71954. * Updates the current quaternion from the given rotation matrix values
  71955. * @param matrix defines the source matrix
  71956. * @returns the current updated quaternion
  71957. */
  71958. Quaternion.prototype.fromRotationMatrix = function (matrix) {
  71959. Quaternion.FromRotationMatrixToRef(matrix, this);
  71960. return this;
  71961. };
  71962. // Statics
  71963. /**
  71964. * Creates a new quaternion from a rotation matrix
  71965. * @param matrix defines the source matrix
  71966. * @returns a new quaternion created from the given rotation matrix values
  71967. */
  71968. Quaternion.FromRotationMatrix = function (matrix) {
  71969. var result = new Quaternion();
  71970. Quaternion.FromRotationMatrixToRef(matrix, result);
  71971. return result;
  71972. };
  71973. /**
  71974. * Updates the given quaternion with the given rotation matrix values
  71975. * @param matrix defines the source matrix
  71976. * @param result defines the target quaternion
  71977. */
  71978. Quaternion.FromRotationMatrixToRef = function (matrix, result) {
  71979. var data = matrix.m;
  71980. var m11 = data[0], m12 = data[4], m13 = data[8];
  71981. var m21 = data[1], m22 = data[5], m23 = data[9];
  71982. var m31 = data[2], m32 = data[6], m33 = data[10];
  71983. var trace = m11 + m22 + m33;
  71984. var s;
  71985. if (trace > 0) {
  71986. s = 0.5 / Math.sqrt(trace + 1.0);
  71987. result.w = 0.25 / s;
  71988. result.x = (m32 - m23) * s;
  71989. result.y = (m13 - m31) * s;
  71990. result.z = (m21 - m12) * s;
  71991. }
  71992. else if (m11 > m22 && m11 > m33) {
  71993. s = 2.0 * Math.sqrt(1.0 + m11 - m22 - m33);
  71994. result.w = (m32 - m23) / s;
  71995. result.x = 0.25 * s;
  71996. result.y = (m12 + m21) / s;
  71997. result.z = (m13 + m31) / s;
  71998. }
  71999. else if (m22 > m33) {
  72000. s = 2.0 * Math.sqrt(1.0 + m22 - m11 - m33);
  72001. result.w = (m13 - m31) / s;
  72002. result.x = (m12 + m21) / s;
  72003. result.y = 0.25 * s;
  72004. result.z = (m23 + m32) / s;
  72005. }
  72006. else {
  72007. s = 2.0 * Math.sqrt(1.0 + m33 - m11 - m22);
  72008. result.w = (m21 - m12) / s;
  72009. result.x = (m13 + m31) / s;
  72010. result.y = (m23 + m32) / s;
  72011. result.z = 0.25 * s;
  72012. }
  72013. };
  72014. /**
  72015. * Returns the dot product (float) between the quaternions "left" and "right"
  72016. * @param left defines the left operand
  72017. * @param right defines the right operand
  72018. * @returns the dot product
  72019. */
  72020. Quaternion.Dot = function (left, right) {
  72021. return (left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w);
  72022. };
  72023. /**
  72024. * Checks if the two quaternions are close to each other
  72025. * @param quat0 defines the first quaternion to check
  72026. * @param quat1 defines the second quaternion to check
  72027. * @returns true if the two quaternions are close to each other
  72028. */
  72029. Quaternion.AreClose = function (quat0, quat1) {
  72030. var dot = Quaternion.Dot(quat0, quat1);
  72031. return dot >= 0;
  72032. };
  72033. /**
  72034. * Creates an empty quaternion
  72035. * @returns a new quaternion set to (0.0, 0.0, 0.0)
  72036. */
  72037. Quaternion.Zero = function () {
  72038. return new Quaternion(0.0, 0.0, 0.0, 0.0);
  72039. };
  72040. /**
  72041. * Inverse a given quaternion
  72042. * @param q defines the source quaternion
  72043. * @returns a new quaternion as the inverted current quaternion
  72044. */
  72045. Quaternion.Inverse = function (q) {
  72046. return new Quaternion(-q.x, -q.y, -q.z, q.w);
  72047. };
  72048. /**
  72049. * Inverse a given quaternion
  72050. * @param q defines the source quaternion
  72051. * @param result the quaternion the result will be stored in
  72052. * @returns the result quaternion
  72053. */
  72054. Quaternion.InverseToRef = function (q, result) {
  72055. result.set(-q.x, -q.y, -q.z, q.w);
  72056. return result;
  72057. };
  72058. /**
  72059. * Creates an identity quaternion
  72060. * @returns the identity quaternion
  72061. */
  72062. Quaternion.Identity = function () {
  72063. return new Quaternion(0.0, 0.0, 0.0, 1.0);
  72064. };
  72065. /**
  72066. * Gets a boolean indicating if the given quaternion is identity
  72067. * @param quaternion defines the quaternion to check
  72068. * @returns true if the quaternion is identity
  72069. */
  72070. Quaternion.IsIdentity = function (quaternion) {
  72071. return quaternion && quaternion.x === 0 && quaternion.y === 0 && quaternion.z === 0 && quaternion.w === 1;
  72072. };
  72073. /**
  72074. * Creates a quaternion from a rotation around an axis
  72075. * @param axis defines the axis to use
  72076. * @param angle defines the angle to use
  72077. * @returns a new quaternion created from the given axis (Vector3) and angle in radians (float)
  72078. */
  72079. Quaternion.RotationAxis = function (axis, angle) {
  72080. return Quaternion.RotationAxisToRef(axis, angle, new Quaternion());
  72081. };
  72082. /**
  72083. * Creates a rotation around an axis and stores it into the given quaternion
  72084. * @param axis defines the axis to use
  72085. * @param angle defines the angle to use
  72086. * @param result defines the target quaternion
  72087. * @returns the target quaternion
  72088. */
  72089. Quaternion.RotationAxisToRef = function (axis, angle, result) {
  72090. var sin = Math.sin(angle / 2);
  72091. axis.normalize();
  72092. result.w = Math.cos(angle / 2);
  72093. result.x = axis.x * sin;
  72094. result.y = axis.y * sin;
  72095. result.z = axis.z * sin;
  72096. return result;
  72097. };
  72098. /**
  72099. * Creates a new quaternion from data stored into an array
  72100. * @param array defines the data source
  72101. * @param offset defines the offset in the source array where the data starts
  72102. * @returns a new quaternion
  72103. */
  72104. Quaternion.FromArray = function (array, offset) {
  72105. if (!offset) {
  72106. offset = 0;
  72107. }
  72108. return new Quaternion(array[offset], array[offset + 1], array[offset + 2], array[offset + 3]);
  72109. };
  72110. /**
  72111. * Create a quaternion from Euler rotation angles
  72112. * @param x Pitch
  72113. * @param y Yaw
  72114. * @param z Roll
  72115. * @returns the new Quaternion
  72116. */
  72117. Quaternion.FromEulerAngles = function (x, y, z) {
  72118. var q = new Quaternion();
  72119. Quaternion.RotationYawPitchRollToRef(y, x, z, q);
  72120. return q;
  72121. };
  72122. /**
  72123. * Updates a quaternion from Euler rotation angles
  72124. * @param x Pitch
  72125. * @param y Yaw
  72126. * @param z Roll
  72127. * @param result the quaternion to store the result
  72128. * @returns the updated quaternion
  72129. */
  72130. Quaternion.FromEulerAnglesToRef = function (x, y, z, result) {
  72131. Quaternion.RotationYawPitchRollToRef(y, x, z, result);
  72132. return result;
  72133. };
  72134. /**
  72135. * Create a quaternion from Euler rotation vector
  72136. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72137. * @returns the new Quaternion
  72138. */
  72139. Quaternion.FromEulerVector = function (vec) {
  72140. var q = new Quaternion();
  72141. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, q);
  72142. return q;
  72143. };
  72144. /**
  72145. * Updates a quaternion from Euler rotation vector
  72146. * @param vec the Euler vector (x Pitch, y Yaw, z Roll)
  72147. * @param result the quaternion to store the result
  72148. * @returns the updated quaternion
  72149. */
  72150. Quaternion.FromEulerVectorToRef = function (vec, result) {
  72151. Quaternion.RotationYawPitchRollToRef(vec.y, vec.x, vec.z, result);
  72152. return result;
  72153. };
  72154. /**
  72155. * Creates a new quaternion from the given Euler float angles (y, x, z)
  72156. * @param yaw defines the rotation around Y axis
  72157. * @param pitch defines the rotation around X axis
  72158. * @param roll defines the rotation around Z axis
  72159. * @returns the new quaternion
  72160. */
  72161. Quaternion.RotationYawPitchRoll = function (yaw, pitch, roll) {
  72162. var q = new Quaternion();
  72163. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, q);
  72164. return q;
  72165. };
  72166. /**
  72167. * Creates a new rotation from the given Euler float angles (y, x, z) and stores it in the target quaternion
  72168. * @param yaw defines the rotation around Y axis
  72169. * @param pitch defines the rotation around X axis
  72170. * @param roll defines the rotation around Z axis
  72171. * @param result defines the target quaternion
  72172. */
  72173. Quaternion.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  72174. // Produces a quaternion from Euler angles in the z-y-x orientation (Tait-Bryan angles)
  72175. var halfRoll = roll * 0.5;
  72176. var halfPitch = pitch * 0.5;
  72177. var halfYaw = yaw * 0.5;
  72178. var sinRoll = Math.sin(halfRoll);
  72179. var cosRoll = Math.cos(halfRoll);
  72180. var sinPitch = Math.sin(halfPitch);
  72181. var cosPitch = Math.cos(halfPitch);
  72182. var sinYaw = Math.sin(halfYaw);
  72183. var cosYaw = Math.cos(halfYaw);
  72184. result.x = (cosYaw * sinPitch * cosRoll) + (sinYaw * cosPitch * sinRoll);
  72185. result.y = (sinYaw * cosPitch * cosRoll) - (cosYaw * sinPitch * sinRoll);
  72186. result.z = (cosYaw * cosPitch * sinRoll) - (sinYaw * sinPitch * cosRoll);
  72187. result.w = (cosYaw * cosPitch * cosRoll) + (sinYaw * sinPitch * sinRoll);
  72188. };
  72189. /**
  72190. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation
  72191. * @param alpha defines the rotation around first axis
  72192. * @param beta defines the rotation around second axis
  72193. * @param gamma defines the rotation around third axis
  72194. * @returns the new quaternion
  72195. */
  72196. Quaternion.RotationAlphaBetaGamma = function (alpha, beta, gamma) {
  72197. var result = new Quaternion();
  72198. Quaternion.RotationAlphaBetaGammaToRef(alpha, beta, gamma, result);
  72199. return result;
  72200. };
  72201. /**
  72202. * Creates a new quaternion from the given Euler float angles expressed in z-x-z orientation and stores it in the target quaternion
  72203. * @param alpha defines the rotation around first axis
  72204. * @param beta defines the rotation around second axis
  72205. * @param gamma defines the rotation around third axis
  72206. * @param result defines the target quaternion
  72207. */
  72208. Quaternion.RotationAlphaBetaGammaToRef = function (alpha, beta, gamma, result) {
  72209. // Produces a quaternion from Euler angles in the z-x-z orientation
  72210. var halfGammaPlusAlpha = (gamma + alpha) * 0.5;
  72211. var halfGammaMinusAlpha = (gamma - alpha) * 0.5;
  72212. var halfBeta = beta * 0.5;
  72213. result.x = Math.cos(halfGammaMinusAlpha) * Math.sin(halfBeta);
  72214. result.y = Math.sin(halfGammaMinusAlpha) * Math.sin(halfBeta);
  72215. result.z = Math.sin(halfGammaPlusAlpha) * Math.cos(halfBeta);
  72216. result.w = Math.cos(halfGammaPlusAlpha) * Math.cos(halfBeta);
  72217. };
  72218. /**
  72219. * 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)
  72220. * @param axis1 defines the first axis
  72221. * @param axis2 defines the second axis
  72222. * @param axis3 defines the third axis
  72223. * @returns the new quaternion
  72224. */
  72225. Quaternion.RotationQuaternionFromAxis = function (axis1, axis2, axis3) {
  72226. var quat = new Quaternion(0.0, 0.0, 0.0, 0.0);
  72227. Quaternion.RotationQuaternionFromAxisToRef(axis1, axis2, axis3, quat);
  72228. return quat;
  72229. };
  72230. /**
  72231. * 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
  72232. * @param axis1 defines the first axis
  72233. * @param axis2 defines the second axis
  72234. * @param axis3 defines the third axis
  72235. * @param ref defines the target quaternion
  72236. */
  72237. Quaternion.RotationQuaternionFromAxisToRef = function (axis1, axis2, axis3, ref) {
  72238. var rotMat = MathTmp.Matrix[0];
  72239. Matrix.FromXYZAxesToRef(axis1.normalize(), axis2.normalize(), axis3.normalize(), rotMat);
  72240. Quaternion.FromRotationMatrixToRef(rotMat, ref);
  72241. };
  72242. /**
  72243. * Interpolates between two quaternions
  72244. * @param left defines first quaternion
  72245. * @param right defines second quaternion
  72246. * @param amount defines the gradient to use
  72247. * @returns the new interpolated quaternion
  72248. */
  72249. Quaternion.Slerp = function (left, right, amount) {
  72250. var result = Quaternion.Identity();
  72251. Quaternion.SlerpToRef(left, right, amount, result);
  72252. return result;
  72253. };
  72254. /**
  72255. * Interpolates between two quaternions and stores it into a target quaternion
  72256. * @param left defines first quaternion
  72257. * @param right defines second quaternion
  72258. * @param amount defines the gradient to use
  72259. * @param result defines the target quaternion
  72260. */
  72261. Quaternion.SlerpToRef = function (left, right, amount, result) {
  72262. var num2;
  72263. var num3;
  72264. var num4 = (((left.x * right.x) + (left.y * right.y)) + (left.z * right.z)) + (left.w * right.w);
  72265. var flag = false;
  72266. if (num4 < 0) {
  72267. flag = true;
  72268. num4 = -num4;
  72269. }
  72270. if (num4 > 0.999999) {
  72271. num3 = 1 - amount;
  72272. num2 = flag ? -amount : amount;
  72273. }
  72274. else {
  72275. var num5 = Math.acos(num4);
  72276. var num6 = (1.0 / Math.sin(num5));
  72277. num3 = (Math.sin((1.0 - amount) * num5)) * num6;
  72278. num2 = flag ? ((-Math.sin(amount * num5)) * num6) : ((Math.sin(amount * num5)) * num6);
  72279. }
  72280. result.x = (num3 * left.x) + (num2 * right.x);
  72281. result.y = (num3 * left.y) + (num2 * right.y);
  72282. result.z = (num3 * left.z) + (num2 * right.z);
  72283. result.w = (num3 * left.w) + (num2 * right.w);
  72284. };
  72285. /**
  72286. * Interpolate between two quaternions using Hermite interpolation
  72287. * @param value1 defines first quaternion
  72288. * @param tangent1 defines the incoming tangent
  72289. * @param value2 defines second quaternion
  72290. * @param tangent2 defines the outgoing tangent
  72291. * @param amount defines the target quaternion
  72292. * @returns the new interpolated quaternion
  72293. */
  72294. Quaternion.Hermite = function (value1, tangent1, value2, tangent2, amount) {
  72295. var squared = amount * amount;
  72296. var cubed = amount * squared;
  72297. var part1 = ((2.0 * cubed) - (3.0 * squared)) + 1.0;
  72298. var part2 = (-2.0 * cubed) + (3.0 * squared);
  72299. var part3 = (cubed - (2.0 * squared)) + amount;
  72300. var part4 = cubed - squared;
  72301. var x = (((value1.x * part1) + (value2.x * part2)) + (tangent1.x * part3)) + (tangent2.x * part4);
  72302. var y = (((value1.y * part1) + (value2.y * part2)) + (tangent1.y * part3)) + (tangent2.y * part4);
  72303. var z = (((value1.z * part1) + (value2.z * part2)) + (tangent1.z * part3)) + (tangent2.z * part4);
  72304. var w = (((value1.w * part1) + (value2.w * part2)) + (tangent1.w * part3)) + (tangent2.w * part4);
  72305. return new Quaternion(x, y, z, w);
  72306. };
  72307. return Quaternion;
  72308. }());
  72309. /**
  72310. * Class used to store matrix data (4x4)
  72311. */
  72312. var Matrix = /** @class */ (function () {
  72313. /**
  72314. * Creates an empty matrix (filled with zeros)
  72315. */
  72316. function Matrix() {
  72317. this._isIdentity = false;
  72318. this._isIdentityDirty = true;
  72319. this._isIdentity3x2 = true;
  72320. this._isIdentity3x2Dirty = true;
  72321. this._m = new Float32Array(16);
  72322. this._updateIdentityStatus(false);
  72323. }
  72324. Object.defineProperty(Matrix.prototype, "m", {
  72325. /**
  72326. * Gets the internal data of the matrix
  72327. */
  72328. get: function () { return this._m; },
  72329. enumerable: true,
  72330. configurable: true
  72331. });
  72332. /** @hidden */
  72333. Matrix.prototype._markAsUpdated = function () {
  72334. this.updateFlag = Matrix._updateFlagSeed++;
  72335. this._isIdentity = false;
  72336. this._isIdentity3x2 = false;
  72337. this._isIdentityDirty = true;
  72338. this._isIdentity3x2Dirty = true;
  72339. };
  72340. /** @hidden */
  72341. Matrix.prototype._updateIdentityStatus = function (isIdentity, isIdentityDirty, isIdentity3x2, isIdentity3x2Dirty) {
  72342. if (isIdentityDirty === void 0) { isIdentityDirty = false; }
  72343. if (isIdentity3x2 === void 0) { isIdentity3x2 = false; }
  72344. if (isIdentity3x2Dirty === void 0) { isIdentity3x2Dirty = true; }
  72345. this.updateFlag = Matrix._updateFlagSeed++;
  72346. this._isIdentity = isIdentity;
  72347. this._isIdentity3x2 = isIdentity || isIdentity3x2;
  72348. this._isIdentityDirty = this._isIdentity ? false : isIdentityDirty;
  72349. this._isIdentity3x2Dirty = this._isIdentity3x2 ? false : isIdentity3x2Dirty;
  72350. };
  72351. // Properties
  72352. /**
  72353. * Check if the current matrix is identity
  72354. * @returns true is the matrix is the identity matrix
  72355. */
  72356. Matrix.prototype.isIdentity = function () {
  72357. if (this._isIdentityDirty) {
  72358. this._isIdentityDirty = false;
  72359. var m = this._m;
  72360. this._isIdentity = (m[0] === 1.0 && m[1] === 0.0 && m[2] === 0.0 && m[3] === 0.0 &&
  72361. m[4] === 0.0 && m[5] === 1.0 && m[6] === 0.0 && m[7] === 0.0 &&
  72362. m[8] === 0.0 && m[9] === 0.0 && m[10] === 1.0 && m[11] === 0.0 &&
  72363. m[12] === 0.0 && m[13] === 0.0 && m[14] === 0.0 && m[15] === 1.0);
  72364. }
  72365. return this._isIdentity;
  72366. };
  72367. /**
  72368. * Check if the current matrix is identity as a texture matrix (3x2 store in 4x4)
  72369. * @returns true is the matrix is the identity matrix
  72370. */
  72371. Matrix.prototype.isIdentityAs3x2 = function () {
  72372. if (this._isIdentity3x2Dirty) {
  72373. this._isIdentity3x2Dirty = false;
  72374. if (this._m[0] !== 1.0 || this._m[5] !== 1.0 || this._m[15] !== 1.0) {
  72375. this._isIdentity3x2 = false;
  72376. }
  72377. else if (this._m[1] !== 0.0 || this._m[2] !== 0.0 || this._m[3] !== 0.0 ||
  72378. this._m[4] !== 0.0 || this._m[6] !== 0.0 || this._m[7] !== 0.0 ||
  72379. this._m[8] !== 0.0 || this._m[9] !== 0.0 || this._m[10] !== 0.0 || this._m[11] !== 0.0 ||
  72380. this._m[12] !== 0.0 || this._m[13] !== 0.0 || this._m[14] !== 0.0) {
  72381. this._isIdentity3x2 = false;
  72382. }
  72383. else {
  72384. this._isIdentity3x2 = true;
  72385. }
  72386. }
  72387. return this._isIdentity3x2;
  72388. };
  72389. /**
  72390. * Gets the determinant of the matrix
  72391. * @returns the matrix determinant
  72392. */
  72393. Matrix.prototype.determinant = function () {
  72394. if (this._isIdentity === true) {
  72395. return 1;
  72396. }
  72397. var m = this._m;
  72398. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  72399. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  72400. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  72401. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  72402. // https://en.wikipedia.org/wiki/Laplace_expansion
  72403. // to compute the deterrminant of a 4x4 Matrix we compute the cofactors of any row or column,
  72404. // then we multiply each Cofactor by its corresponding matrix value and sum them all to get the determinant
  72405. // Cofactor(i, j) = sign(i,j) * det(Minor(i, j))
  72406. // where
  72407. // - sign(i,j) = (i+j) % 2 === 0 ? 1 : -1
  72408. // - Minor(i, j) is the 3x3 matrix we get by removing row i and column j from current Matrix
  72409. //
  72410. // Here we do that for the 1st row.
  72411. var det_22_33 = m22 * m33 - m32 * m23;
  72412. var det_21_33 = m21 * m33 - m31 * m23;
  72413. var det_21_32 = m21 * m32 - m31 * m22;
  72414. var det_20_33 = m20 * m33 - m30 * m23;
  72415. var det_20_32 = m20 * m32 - m22 * m30;
  72416. var det_20_31 = m20 * m31 - m30 * m21;
  72417. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  72418. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  72419. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  72420. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  72421. return m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  72422. };
  72423. // Methods
  72424. /**
  72425. * Returns the matrix as a Float32Array
  72426. * @returns the matrix underlying array
  72427. */
  72428. Matrix.prototype.toArray = function () {
  72429. return this._m;
  72430. };
  72431. /**
  72432. * Returns the matrix as a Float32Array
  72433. * @returns the matrix underlying array.
  72434. */
  72435. Matrix.prototype.asArray = function () {
  72436. return this._m;
  72437. };
  72438. /**
  72439. * Inverts the current matrix in place
  72440. * @returns the current inverted matrix
  72441. */
  72442. Matrix.prototype.invert = function () {
  72443. this.invertToRef(this);
  72444. return this;
  72445. };
  72446. /**
  72447. * Sets all the matrix elements to zero
  72448. * @returns the current matrix
  72449. */
  72450. Matrix.prototype.reset = function () {
  72451. 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);
  72452. this._updateIdentityStatus(false);
  72453. return this;
  72454. };
  72455. /**
  72456. * Adds the current matrix with a second one
  72457. * @param other defines the matrix to add
  72458. * @returns a new matrix as the addition of the current matrix and the given one
  72459. */
  72460. Matrix.prototype.add = function (other) {
  72461. var result = new Matrix();
  72462. this.addToRef(other, result);
  72463. return result;
  72464. };
  72465. /**
  72466. * Sets the given matrix "result" to the addition of the current matrix and the given one
  72467. * @param other defines the matrix to add
  72468. * @param result defines the target matrix
  72469. * @returns the current matrix
  72470. */
  72471. Matrix.prototype.addToRef = function (other, result) {
  72472. var m = this._m;
  72473. var resultM = result._m;
  72474. var otherM = other.m;
  72475. for (var index = 0; index < 16; index++) {
  72476. resultM[index] = m[index] + otherM[index];
  72477. }
  72478. result._markAsUpdated();
  72479. return this;
  72480. };
  72481. /**
  72482. * Adds in place the given matrix to the current matrix
  72483. * @param other defines the second operand
  72484. * @returns the current updated matrix
  72485. */
  72486. Matrix.prototype.addToSelf = function (other) {
  72487. var m = this._m;
  72488. var otherM = other.m;
  72489. for (var index = 0; index < 16; index++) {
  72490. m[index] += otherM[index];
  72491. }
  72492. this._markAsUpdated();
  72493. return this;
  72494. };
  72495. /**
  72496. * Sets the given matrix to the current inverted Matrix
  72497. * @param other defines the target matrix
  72498. * @returns the unmodified current matrix
  72499. */
  72500. Matrix.prototype.invertToRef = function (other) {
  72501. if (this._isIdentity === true) {
  72502. Matrix.IdentityToRef(other);
  72503. return this;
  72504. }
  72505. // the inverse of a Matrix is the transpose of cofactor matrix divided by the determinant
  72506. var m = this._m;
  72507. var m00 = m[0], m01 = m[1], m02 = m[2], m03 = m[3];
  72508. var m10 = m[4], m11 = m[5], m12 = m[6], m13 = m[7];
  72509. var m20 = m[8], m21 = m[9], m22 = m[10], m23 = m[11];
  72510. var m30 = m[12], m31 = m[13], m32 = m[14], m33 = m[15];
  72511. var det_22_33 = m22 * m33 - m32 * m23;
  72512. var det_21_33 = m21 * m33 - m31 * m23;
  72513. var det_21_32 = m21 * m32 - m31 * m22;
  72514. var det_20_33 = m20 * m33 - m30 * m23;
  72515. var det_20_32 = m20 * m32 - m22 * m30;
  72516. var det_20_31 = m20 * m31 - m30 * m21;
  72517. var cofact_00 = +(m11 * det_22_33 - m12 * det_21_33 + m13 * det_21_32);
  72518. var cofact_01 = -(m10 * det_22_33 - m12 * det_20_33 + m13 * det_20_32);
  72519. var cofact_02 = +(m10 * det_21_33 - m11 * det_20_33 + m13 * det_20_31);
  72520. var cofact_03 = -(m10 * det_21_32 - m11 * det_20_32 + m12 * det_20_31);
  72521. var det = m00 * cofact_00 + m01 * cofact_01 + m02 * cofact_02 + m03 * cofact_03;
  72522. if (det === 0) {
  72523. // not invertible
  72524. other.copyFrom(this);
  72525. return this;
  72526. }
  72527. var detInv = 1 / det;
  72528. var det_12_33 = m12 * m33 - m32 * m13;
  72529. var det_11_33 = m11 * m33 - m31 * m13;
  72530. var det_11_32 = m11 * m32 - m31 * m12;
  72531. var det_10_33 = m10 * m33 - m30 * m13;
  72532. var det_10_32 = m10 * m32 - m30 * m12;
  72533. var det_10_31 = m10 * m31 - m30 * m11;
  72534. var det_12_23 = m12 * m23 - m22 * m13;
  72535. var det_11_23 = m11 * m23 - m21 * m13;
  72536. var det_11_22 = m11 * m22 - m21 * m12;
  72537. var det_10_23 = m10 * m23 - m20 * m13;
  72538. var det_10_22 = m10 * m22 - m20 * m12;
  72539. var det_10_21 = m10 * m21 - m20 * m11;
  72540. var cofact_10 = -(m01 * det_22_33 - m02 * det_21_33 + m03 * det_21_32);
  72541. var cofact_11 = +(m00 * det_22_33 - m02 * det_20_33 + m03 * det_20_32);
  72542. var cofact_12 = -(m00 * det_21_33 - m01 * det_20_33 + m03 * det_20_31);
  72543. var cofact_13 = +(m00 * det_21_32 - m01 * det_20_32 + m02 * det_20_31);
  72544. var cofact_20 = +(m01 * det_12_33 - m02 * det_11_33 + m03 * det_11_32);
  72545. var cofact_21 = -(m00 * det_12_33 - m02 * det_10_33 + m03 * det_10_32);
  72546. var cofact_22 = +(m00 * det_11_33 - m01 * det_10_33 + m03 * det_10_31);
  72547. var cofact_23 = -(m00 * det_11_32 - m01 * det_10_32 + m02 * det_10_31);
  72548. var cofact_30 = -(m01 * det_12_23 - m02 * det_11_23 + m03 * det_11_22);
  72549. var cofact_31 = +(m00 * det_12_23 - m02 * det_10_23 + m03 * det_10_22);
  72550. var cofact_32 = -(m00 * det_11_23 - m01 * det_10_23 + m03 * det_10_21);
  72551. var cofact_33 = +(m00 * det_11_22 - m01 * det_10_22 + m02 * det_10_21);
  72552. 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);
  72553. return this;
  72554. };
  72555. /**
  72556. * add a value at the specified position in the current Matrix
  72557. * @param index the index of the value within the matrix. between 0 and 15.
  72558. * @param value the value to be added
  72559. * @returns the current updated matrix
  72560. */
  72561. Matrix.prototype.addAtIndex = function (index, value) {
  72562. this._m[index] += value;
  72563. this._markAsUpdated();
  72564. return this;
  72565. };
  72566. /**
  72567. * mutiply the specified position in the current Matrix by a value
  72568. * @param index the index of the value within the matrix. between 0 and 15.
  72569. * @param value the value to be added
  72570. * @returns the current updated matrix
  72571. */
  72572. Matrix.prototype.multiplyAtIndex = function (index, value) {
  72573. this._m[index] *= value;
  72574. this._markAsUpdated();
  72575. return this;
  72576. };
  72577. /**
  72578. * Inserts the translation vector (using 3 floats) in the current matrix
  72579. * @param x defines the 1st component of the translation
  72580. * @param y defines the 2nd component of the translation
  72581. * @param z defines the 3rd component of the translation
  72582. * @returns the current updated matrix
  72583. */
  72584. Matrix.prototype.setTranslationFromFloats = function (x, y, z) {
  72585. this._m[12] = x;
  72586. this._m[13] = y;
  72587. this._m[14] = z;
  72588. this._markAsUpdated();
  72589. return this;
  72590. };
  72591. /**
  72592. * Inserts the translation vector in the current matrix
  72593. * @param vector3 defines the translation to insert
  72594. * @returns the current updated matrix
  72595. */
  72596. Matrix.prototype.setTranslation = function (vector3) {
  72597. return this.setTranslationFromFloats(vector3.x, vector3.y, vector3.z);
  72598. };
  72599. /**
  72600. * Gets the translation value of the current matrix
  72601. * @returns a new Vector3 as the extracted translation from the matrix
  72602. */
  72603. Matrix.prototype.getTranslation = function () {
  72604. return new Vector3(this._m[12], this._m[13], this._m[14]);
  72605. };
  72606. /**
  72607. * Fill a Vector3 with the extracted translation from the matrix
  72608. * @param result defines the Vector3 where to store the translation
  72609. * @returns the current matrix
  72610. */
  72611. Matrix.prototype.getTranslationToRef = function (result) {
  72612. result.x = this._m[12];
  72613. result.y = this._m[13];
  72614. result.z = this._m[14];
  72615. return this;
  72616. };
  72617. /**
  72618. * Remove rotation and scaling part from the matrix
  72619. * @returns the updated matrix
  72620. */
  72621. Matrix.prototype.removeRotationAndScaling = function () {
  72622. var m = this.m;
  72623. 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);
  72624. this._updateIdentityStatus(m[12] === 0 && m[13] === 0 && m[14] === 0 && m[15] === 1);
  72625. return this;
  72626. };
  72627. /**
  72628. * Multiply two matrices
  72629. * @param other defines the second operand
  72630. * @returns a new matrix set with the multiplication result of the current Matrix and the given one
  72631. */
  72632. Matrix.prototype.multiply = function (other) {
  72633. var result = new Matrix();
  72634. this.multiplyToRef(other, result);
  72635. return result;
  72636. };
  72637. /**
  72638. * Copy the current matrix from the given one
  72639. * @param other defines the source matrix
  72640. * @returns the current updated matrix
  72641. */
  72642. Matrix.prototype.copyFrom = function (other) {
  72643. other.copyToArray(this._m);
  72644. var o = other;
  72645. this._updateIdentityStatus(o._isIdentity, o._isIdentityDirty, o._isIdentity3x2, o._isIdentity3x2Dirty);
  72646. return this;
  72647. };
  72648. /**
  72649. * Populates the given array from the starting index with the current matrix values
  72650. * @param array defines the target array
  72651. * @param offset defines the offset in the target array where to start storing values
  72652. * @returns the current matrix
  72653. */
  72654. Matrix.prototype.copyToArray = function (array, offset) {
  72655. if (offset === void 0) { offset = 0; }
  72656. for (var index = 0; index < 16; index++) {
  72657. array[offset + index] = this._m[index];
  72658. }
  72659. return this;
  72660. };
  72661. /**
  72662. * Sets the given matrix "result" with the multiplication result of the current Matrix and the given one
  72663. * @param other defines the second operand
  72664. * @param result defines the matrix where to store the multiplication
  72665. * @returns the current matrix
  72666. */
  72667. Matrix.prototype.multiplyToRef = function (other, result) {
  72668. if (this._isIdentity) {
  72669. result.copyFrom(other);
  72670. return this;
  72671. }
  72672. if (other._isIdentity) {
  72673. result.copyFrom(this);
  72674. return this;
  72675. }
  72676. this.multiplyToArray(other, result._m, 0);
  72677. result._markAsUpdated();
  72678. return this;
  72679. };
  72680. /**
  72681. * Sets the Float32Array "result" from the given index "offset" with the multiplication of the current matrix and the given one
  72682. * @param other defines the second operand
  72683. * @param result defines the array where to store the multiplication
  72684. * @param offset defines the offset in the target array where to start storing values
  72685. * @returns the current matrix
  72686. */
  72687. Matrix.prototype.multiplyToArray = function (other, result, offset) {
  72688. var m = this._m;
  72689. var otherM = other.m;
  72690. var tm0 = m[0], tm1 = m[1], tm2 = m[2], tm3 = m[3];
  72691. var tm4 = m[4], tm5 = m[5], tm6 = m[6], tm7 = m[7];
  72692. var tm8 = m[8], tm9 = m[9], tm10 = m[10], tm11 = m[11];
  72693. var tm12 = m[12], tm13 = m[13], tm14 = m[14], tm15 = m[15];
  72694. var om0 = otherM[0], om1 = otherM[1], om2 = otherM[2], om3 = otherM[3];
  72695. var om4 = otherM[4], om5 = otherM[5], om6 = otherM[6], om7 = otherM[7];
  72696. var om8 = otherM[8], om9 = otherM[9], om10 = otherM[10], om11 = otherM[11];
  72697. var om12 = otherM[12], om13 = otherM[13], om14 = otherM[14], om15 = otherM[15];
  72698. result[offset] = tm0 * om0 + tm1 * om4 + tm2 * om8 + tm3 * om12;
  72699. result[offset + 1] = tm0 * om1 + tm1 * om5 + tm2 * om9 + tm3 * om13;
  72700. result[offset + 2] = tm0 * om2 + tm1 * om6 + tm2 * om10 + tm3 * om14;
  72701. result[offset + 3] = tm0 * om3 + tm1 * om7 + tm2 * om11 + tm3 * om15;
  72702. result[offset + 4] = tm4 * om0 + tm5 * om4 + tm6 * om8 + tm7 * om12;
  72703. result[offset + 5] = tm4 * om1 + tm5 * om5 + tm6 * om9 + tm7 * om13;
  72704. result[offset + 6] = tm4 * om2 + tm5 * om6 + tm6 * om10 + tm7 * om14;
  72705. result[offset + 7] = tm4 * om3 + tm5 * om7 + tm6 * om11 + tm7 * om15;
  72706. result[offset + 8] = tm8 * om0 + tm9 * om4 + tm10 * om8 + tm11 * om12;
  72707. result[offset + 9] = tm8 * om1 + tm9 * om5 + tm10 * om9 + tm11 * om13;
  72708. result[offset + 10] = tm8 * om2 + tm9 * om6 + tm10 * om10 + tm11 * om14;
  72709. result[offset + 11] = tm8 * om3 + tm9 * om7 + tm10 * om11 + tm11 * om15;
  72710. result[offset + 12] = tm12 * om0 + tm13 * om4 + tm14 * om8 + tm15 * om12;
  72711. result[offset + 13] = tm12 * om1 + tm13 * om5 + tm14 * om9 + tm15 * om13;
  72712. result[offset + 14] = tm12 * om2 + tm13 * om6 + tm14 * om10 + tm15 * om14;
  72713. result[offset + 15] = tm12 * om3 + tm13 * om7 + tm14 * om11 + tm15 * om15;
  72714. return this;
  72715. };
  72716. /**
  72717. * Check equality between this matrix and a second one
  72718. * @param value defines the second matrix to compare
  72719. * @returns true is the current matrix and the given one values are strictly equal
  72720. */
  72721. Matrix.prototype.equals = function (value) {
  72722. var other = value;
  72723. if (!other) {
  72724. return false;
  72725. }
  72726. if (this._isIdentity || other._isIdentity) {
  72727. if (!this._isIdentityDirty && !other._isIdentityDirty) {
  72728. return this._isIdentity && other._isIdentity;
  72729. }
  72730. }
  72731. var m = this.m;
  72732. var om = other.m;
  72733. return (m[0] === om[0] && m[1] === om[1] && m[2] === om[2] && m[3] === om[3] &&
  72734. m[4] === om[4] && m[5] === om[5] && m[6] === om[6] && m[7] === om[7] &&
  72735. m[8] === om[8] && m[9] === om[9] && m[10] === om[10] && m[11] === om[11] &&
  72736. m[12] === om[12] && m[13] === om[13] && m[14] === om[14] && m[15] === om[15]);
  72737. };
  72738. /**
  72739. * Clone the current matrix
  72740. * @returns a new matrix from the current matrix
  72741. */
  72742. Matrix.prototype.clone = function () {
  72743. var matrix = new Matrix();
  72744. matrix.copyFrom(this);
  72745. return matrix;
  72746. };
  72747. /**
  72748. * Returns the name of the current matrix class
  72749. * @returns the string "Matrix"
  72750. */
  72751. Matrix.prototype.getClassName = function () {
  72752. return "Matrix";
  72753. };
  72754. /**
  72755. * Gets the hash code of the current matrix
  72756. * @returns the hash code
  72757. */
  72758. Matrix.prototype.getHashCode = function () {
  72759. var hash = this._m[0] || 0;
  72760. for (var i = 1; i < 16; i++) {
  72761. hash = (hash * 397) ^ (this._m[i] || 0);
  72762. }
  72763. return hash;
  72764. };
  72765. /**
  72766. * Decomposes the current Matrix into a translation, rotation and scaling components
  72767. * @param scale defines the scale vector3 given as a reference to update
  72768. * @param rotation defines the rotation quaternion given as a reference to update
  72769. * @param translation defines the translation vector3 given as a reference to update
  72770. * @returns true if operation was successful
  72771. */
  72772. Matrix.prototype.decompose = function (scale, rotation, translation) {
  72773. if (this._isIdentity) {
  72774. if (translation) {
  72775. translation.setAll(0);
  72776. }
  72777. if (scale) {
  72778. scale.setAll(1);
  72779. }
  72780. if (rotation) {
  72781. rotation.copyFromFloats(0, 0, 0, 1);
  72782. }
  72783. return true;
  72784. }
  72785. var m = this._m;
  72786. if (translation) {
  72787. translation.copyFromFloats(m[12], m[13], m[14]);
  72788. }
  72789. scale = scale || MathTmp.Vector3[0];
  72790. scale.x = Math.sqrt(m[0] * m[0] + m[1] * m[1] + m[2] * m[2]);
  72791. scale.y = Math.sqrt(m[4] * m[4] + m[5] * m[5] + m[6] * m[6]);
  72792. scale.z = Math.sqrt(m[8] * m[8] + m[9] * m[9] + m[10] * m[10]);
  72793. if (this.determinant() <= 0) {
  72794. scale.y *= -1;
  72795. }
  72796. if (scale.x === 0 || scale.y === 0 || scale.z === 0) {
  72797. if (rotation) {
  72798. rotation.copyFromFloats(0.0, 0.0, 0.0, 1.0);
  72799. }
  72800. return false;
  72801. }
  72802. if (rotation) {
  72803. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72804. 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]);
  72805. Quaternion.FromRotationMatrixToRef(MathTmp.Matrix[0], rotation);
  72806. }
  72807. return true;
  72808. };
  72809. /**
  72810. * Gets specific row of the matrix
  72811. * @param index defines the number of the row to get
  72812. * @returns the index-th row of the current matrix as a new Vector4
  72813. */
  72814. Matrix.prototype.getRow = function (index) {
  72815. if (index < 0 || index > 3) {
  72816. return null;
  72817. }
  72818. var i = index * 4;
  72819. return new Vector4(this._m[i + 0], this._m[i + 1], this._m[i + 2], this._m[i + 3]);
  72820. };
  72821. /**
  72822. * Sets the index-th row of the current matrix to the vector4 values
  72823. * @param index defines the number of the row to set
  72824. * @param row defines the target vector4
  72825. * @returns the updated current matrix
  72826. */
  72827. Matrix.prototype.setRow = function (index, row) {
  72828. return this.setRowFromFloats(index, row.x, row.y, row.z, row.w);
  72829. };
  72830. /**
  72831. * Compute the transpose of the matrix
  72832. * @returns the new transposed matrix
  72833. */
  72834. Matrix.prototype.transpose = function () {
  72835. return Matrix.Transpose(this);
  72836. };
  72837. /**
  72838. * Compute the transpose of the matrix and store it in a given matrix
  72839. * @param result defines the target matrix
  72840. * @returns the current matrix
  72841. */
  72842. Matrix.prototype.transposeToRef = function (result) {
  72843. Matrix.TransposeToRef(this, result);
  72844. return this;
  72845. };
  72846. /**
  72847. * Sets the index-th row of the current matrix with the given 4 x float values
  72848. * @param index defines the row index
  72849. * @param x defines the x component to set
  72850. * @param y defines the y component to set
  72851. * @param z defines the z component to set
  72852. * @param w defines the w component to set
  72853. * @returns the updated current matrix
  72854. */
  72855. Matrix.prototype.setRowFromFloats = function (index, x, y, z, w) {
  72856. if (index < 0 || index > 3) {
  72857. return this;
  72858. }
  72859. var i = index * 4;
  72860. this._m[i + 0] = x;
  72861. this._m[i + 1] = y;
  72862. this._m[i + 2] = z;
  72863. this._m[i + 3] = w;
  72864. this._markAsUpdated();
  72865. return this;
  72866. };
  72867. /**
  72868. * Compute a new matrix set with the current matrix values multiplied by scale (float)
  72869. * @param scale defines the scale factor
  72870. * @returns a new matrix
  72871. */
  72872. Matrix.prototype.scale = function (scale) {
  72873. var result = new Matrix();
  72874. this.scaleToRef(scale, result);
  72875. return result;
  72876. };
  72877. /**
  72878. * Scale the current matrix values by a factor to a given result matrix
  72879. * @param scale defines the scale factor
  72880. * @param result defines the matrix to store the result
  72881. * @returns the current matrix
  72882. */
  72883. Matrix.prototype.scaleToRef = function (scale, result) {
  72884. for (var index = 0; index < 16; index++) {
  72885. result._m[index] = this._m[index] * scale;
  72886. }
  72887. result._markAsUpdated();
  72888. return this;
  72889. };
  72890. /**
  72891. * Scale the current matrix values by a factor and add the result to a given matrix
  72892. * @param scale defines the scale factor
  72893. * @param result defines the Matrix to store the result
  72894. * @returns the current matrix
  72895. */
  72896. Matrix.prototype.scaleAndAddToRef = function (scale, result) {
  72897. for (var index = 0; index < 16; index++) {
  72898. result._m[index] += this._m[index] * scale;
  72899. }
  72900. result._markAsUpdated();
  72901. return this;
  72902. };
  72903. /**
  72904. * Writes to the given matrix a normal matrix, computed from this one (using values from identity matrix for fourth row and column).
  72905. * @param ref matrix to store the result
  72906. */
  72907. Matrix.prototype.toNormalMatrix = function (ref) {
  72908. var tmp = MathTmp.Matrix[0];
  72909. this.invertToRef(tmp);
  72910. tmp.transposeToRef(ref);
  72911. var m = ref._m;
  72912. 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);
  72913. };
  72914. /**
  72915. * Gets only rotation part of the current matrix
  72916. * @returns a new matrix sets to the extracted rotation matrix from the current one
  72917. */
  72918. Matrix.prototype.getRotationMatrix = function () {
  72919. var result = new Matrix();
  72920. this.getRotationMatrixToRef(result);
  72921. return result;
  72922. };
  72923. /**
  72924. * Extracts the rotation matrix from the current one and sets it as the given "result"
  72925. * @param result defines the target matrix to store data to
  72926. * @returns the current matrix
  72927. */
  72928. Matrix.prototype.getRotationMatrixToRef = function (result) {
  72929. var scale = MathTmp.Vector3[0];
  72930. if (!this.decompose(scale)) {
  72931. Matrix.IdentityToRef(result);
  72932. return this;
  72933. }
  72934. var m = this._m;
  72935. var sx = 1 / scale.x, sy = 1 / scale.y, sz = 1 / scale.z;
  72936. 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);
  72937. return this;
  72938. };
  72939. /**
  72940. * Toggles model matrix from being right handed to left handed in place and vice versa
  72941. */
  72942. Matrix.prototype.toggleModelMatrixHandInPlace = function () {
  72943. var m = this._m;
  72944. m[2] *= -1;
  72945. m[6] *= -1;
  72946. m[8] *= -1;
  72947. m[9] *= -1;
  72948. m[14] *= -1;
  72949. this._markAsUpdated();
  72950. };
  72951. /**
  72952. * Toggles projection matrix from being right handed to left handed in place and vice versa
  72953. */
  72954. Matrix.prototype.toggleProjectionMatrixHandInPlace = function () {
  72955. var m = this._m;
  72956. m[8] *= -1;
  72957. m[9] *= -1;
  72958. m[10] *= -1;
  72959. m[11] *= -1;
  72960. this._markAsUpdated();
  72961. };
  72962. // Statics
  72963. /**
  72964. * Creates a matrix from an array
  72965. * @param array defines the source array
  72966. * @param offset defines an offset in the source array
  72967. * @returns a new Matrix set from the starting index of the given array
  72968. */
  72969. Matrix.FromArray = function (array, offset) {
  72970. if (offset === void 0) { offset = 0; }
  72971. var result = new Matrix();
  72972. Matrix.FromArrayToRef(array, offset, result);
  72973. return result;
  72974. };
  72975. /**
  72976. * Copy the content of an array into a given matrix
  72977. * @param array defines the source array
  72978. * @param offset defines an offset in the source array
  72979. * @param result defines the target matrix
  72980. */
  72981. Matrix.FromArrayToRef = function (array, offset, result) {
  72982. for (var index = 0; index < 16; index++) {
  72983. result._m[index] = array[index + offset];
  72984. }
  72985. result._markAsUpdated();
  72986. };
  72987. /**
  72988. * Stores an array into a matrix after having multiplied each component by a given factor
  72989. * @param array defines the source array
  72990. * @param offset defines the offset in the source array
  72991. * @param scale defines the scaling factor
  72992. * @param result defines the target matrix
  72993. */
  72994. Matrix.FromFloat32ArrayToRefScaled = function (array, offset, scale, result) {
  72995. for (var index = 0; index < 16; index++) {
  72996. result._m[index] = array[index + offset] * scale;
  72997. }
  72998. result._markAsUpdated();
  72999. };
  73000. Object.defineProperty(Matrix, "IdentityReadOnly", {
  73001. /**
  73002. * Gets an identity matrix that must not be updated
  73003. */
  73004. get: function () {
  73005. return Matrix._identityReadOnly;
  73006. },
  73007. enumerable: true,
  73008. configurable: true
  73009. });
  73010. /**
  73011. * Stores a list of values (16) inside a given matrix
  73012. * @param initialM11 defines 1st value of 1st row
  73013. * @param initialM12 defines 2nd value of 1st row
  73014. * @param initialM13 defines 3rd value of 1st row
  73015. * @param initialM14 defines 4th value of 1st row
  73016. * @param initialM21 defines 1st value of 2nd row
  73017. * @param initialM22 defines 2nd value of 2nd row
  73018. * @param initialM23 defines 3rd value of 2nd row
  73019. * @param initialM24 defines 4th value of 2nd row
  73020. * @param initialM31 defines 1st value of 3rd row
  73021. * @param initialM32 defines 2nd value of 3rd row
  73022. * @param initialM33 defines 3rd value of 3rd row
  73023. * @param initialM34 defines 4th value of 3rd row
  73024. * @param initialM41 defines 1st value of 4th row
  73025. * @param initialM42 defines 2nd value of 4th row
  73026. * @param initialM43 defines 3rd value of 4th row
  73027. * @param initialM44 defines 4th value of 4th row
  73028. * @param result defines the target matrix
  73029. */
  73030. Matrix.FromValuesToRef = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44, result) {
  73031. var m = result._m;
  73032. m[0] = initialM11;
  73033. m[1] = initialM12;
  73034. m[2] = initialM13;
  73035. m[3] = initialM14;
  73036. m[4] = initialM21;
  73037. m[5] = initialM22;
  73038. m[6] = initialM23;
  73039. m[7] = initialM24;
  73040. m[8] = initialM31;
  73041. m[9] = initialM32;
  73042. m[10] = initialM33;
  73043. m[11] = initialM34;
  73044. m[12] = initialM41;
  73045. m[13] = initialM42;
  73046. m[14] = initialM43;
  73047. m[15] = initialM44;
  73048. result._markAsUpdated();
  73049. };
  73050. /**
  73051. * Creates new matrix from a list of values (16)
  73052. * @param initialM11 defines 1st value of 1st row
  73053. * @param initialM12 defines 2nd value of 1st row
  73054. * @param initialM13 defines 3rd value of 1st row
  73055. * @param initialM14 defines 4th value of 1st row
  73056. * @param initialM21 defines 1st value of 2nd row
  73057. * @param initialM22 defines 2nd value of 2nd row
  73058. * @param initialM23 defines 3rd value of 2nd row
  73059. * @param initialM24 defines 4th value of 2nd row
  73060. * @param initialM31 defines 1st value of 3rd row
  73061. * @param initialM32 defines 2nd value of 3rd row
  73062. * @param initialM33 defines 3rd value of 3rd row
  73063. * @param initialM34 defines 4th value of 3rd row
  73064. * @param initialM41 defines 1st value of 4th row
  73065. * @param initialM42 defines 2nd value of 4th row
  73066. * @param initialM43 defines 3rd value of 4th row
  73067. * @param initialM44 defines 4th value of 4th row
  73068. * @returns the new matrix
  73069. */
  73070. Matrix.FromValues = function (initialM11, initialM12, initialM13, initialM14, initialM21, initialM22, initialM23, initialM24, initialM31, initialM32, initialM33, initialM34, initialM41, initialM42, initialM43, initialM44) {
  73071. var result = new Matrix();
  73072. var m = result._m;
  73073. m[0] = initialM11;
  73074. m[1] = initialM12;
  73075. m[2] = initialM13;
  73076. m[3] = initialM14;
  73077. m[4] = initialM21;
  73078. m[5] = initialM22;
  73079. m[6] = initialM23;
  73080. m[7] = initialM24;
  73081. m[8] = initialM31;
  73082. m[9] = initialM32;
  73083. m[10] = initialM33;
  73084. m[11] = initialM34;
  73085. m[12] = initialM41;
  73086. m[13] = initialM42;
  73087. m[14] = initialM43;
  73088. m[15] = initialM44;
  73089. result._markAsUpdated();
  73090. return result;
  73091. };
  73092. /**
  73093. * Creates a new matrix composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73094. * @param scale defines the scale vector3
  73095. * @param rotation defines the rotation quaternion
  73096. * @param translation defines the translation vector3
  73097. * @returns a new matrix
  73098. */
  73099. Matrix.Compose = function (scale, rotation, translation) {
  73100. var result = new Matrix();
  73101. Matrix.ComposeToRef(scale, rotation, translation, result);
  73102. return result;
  73103. };
  73104. /**
  73105. * Sets a matrix to a value composed by merging scale (vector3), rotation (quaternion) and translation (vector3)
  73106. * @param scale defines the scale vector3
  73107. * @param rotation defines the rotation quaternion
  73108. * @param translation defines the translation vector3
  73109. * @param result defines the target matrix
  73110. */
  73111. Matrix.ComposeToRef = function (scale, rotation, translation, result) {
  73112. Matrix.ScalingToRef(scale.x, scale.y, scale.z, MathTmp.Matrix[1]);
  73113. rotation.toRotationMatrix(MathTmp.Matrix[0]);
  73114. MathTmp.Matrix[1].multiplyToRef(MathTmp.Matrix[0], result);
  73115. result.setTranslation(translation);
  73116. };
  73117. /**
  73118. * Creates a new identity matrix
  73119. * @returns a new identity matrix
  73120. */
  73121. Matrix.Identity = function () {
  73122. 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);
  73123. identity._updateIdentityStatus(true);
  73124. return identity;
  73125. };
  73126. /**
  73127. * Creates a new identity matrix and stores the result in a given matrix
  73128. * @param result defines the target matrix
  73129. */
  73130. Matrix.IdentityToRef = function (result) {
  73131. 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);
  73132. result._updateIdentityStatus(true);
  73133. };
  73134. /**
  73135. * Creates a new zero matrix
  73136. * @returns a new zero matrix
  73137. */
  73138. Matrix.Zero = function () {
  73139. 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);
  73140. zero._updateIdentityStatus(false);
  73141. return zero;
  73142. };
  73143. /**
  73144. * Creates a new rotation matrix for "angle" radians around the X axis
  73145. * @param angle defines the angle (in radians) to use
  73146. * @return the new matrix
  73147. */
  73148. Matrix.RotationX = function (angle) {
  73149. var result = new Matrix();
  73150. Matrix.RotationXToRef(angle, result);
  73151. return result;
  73152. };
  73153. /**
  73154. * Creates a new matrix as the invert of a given matrix
  73155. * @param source defines the source matrix
  73156. * @returns the new matrix
  73157. */
  73158. Matrix.Invert = function (source) {
  73159. var result = new Matrix();
  73160. source.invertToRef(result);
  73161. return result;
  73162. };
  73163. /**
  73164. * Creates a new rotation matrix for "angle" radians around the X axis and stores it in a given matrix
  73165. * @param angle defines the angle (in radians) to use
  73166. * @param result defines the target matrix
  73167. */
  73168. Matrix.RotationXToRef = function (angle, result) {
  73169. var s = Math.sin(angle);
  73170. var c = Math.cos(angle);
  73171. 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);
  73172. result._updateIdentityStatus(c === 1 && s === 0);
  73173. };
  73174. /**
  73175. * Creates a new rotation matrix for "angle" radians around the Y axis
  73176. * @param angle defines the angle (in radians) to use
  73177. * @return the new matrix
  73178. */
  73179. Matrix.RotationY = function (angle) {
  73180. var result = new Matrix();
  73181. Matrix.RotationYToRef(angle, result);
  73182. return result;
  73183. };
  73184. /**
  73185. * Creates a new rotation matrix for "angle" radians around the Y axis and stores it in a given matrix
  73186. * @param angle defines the angle (in radians) to use
  73187. * @param result defines the target matrix
  73188. */
  73189. Matrix.RotationYToRef = function (angle, result) {
  73190. var s = Math.sin(angle);
  73191. var c = Math.cos(angle);
  73192. 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);
  73193. result._updateIdentityStatus(c === 1 && s === 0);
  73194. };
  73195. /**
  73196. * Creates a new rotation matrix for "angle" radians around the Z axis
  73197. * @param angle defines the angle (in radians) to use
  73198. * @return the new matrix
  73199. */
  73200. Matrix.RotationZ = function (angle) {
  73201. var result = new Matrix();
  73202. Matrix.RotationZToRef(angle, result);
  73203. return result;
  73204. };
  73205. /**
  73206. * Creates a new rotation matrix for "angle" radians around the Z axis and stores it in a given matrix
  73207. * @param angle defines the angle (in radians) to use
  73208. * @param result defines the target matrix
  73209. */
  73210. Matrix.RotationZToRef = function (angle, result) {
  73211. var s = Math.sin(angle);
  73212. var c = Math.cos(angle);
  73213. 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);
  73214. result._updateIdentityStatus(c === 1 && s === 0);
  73215. };
  73216. /**
  73217. * Creates a new rotation matrix for "angle" radians around the given axis
  73218. * @param axis defines the axis to use
  73219. * @param angle defines the angle (in radians) to use
  73220. * @return the new matrix
  73221. */
  73222. Matrix.RotationAxis = function (axis, angle) {
  73223. var result = new Matrix();
  73224. Matrix.RotationAxisToRef(axis, angle, result);
  73225. return result;
  73226. };
  73227. /**
  73228. * Creates a new rotation matrix for "angle" radians around the given axis and stores it in a given matrix
  73229. * @param axis defines the axis to use
  73230. * @param angle defines the angle (in radians) to use
  73231. * @param result defines the target matrix
  73232. */
  73233. Matrix.RotationAxisToRef = function (axis, angle, result) {
  73234. var s = Math.sin(-angle);
  73235. var c = Math.cos(-angle);
  73236. var c1 = 1 - c;
  73237. axis.normalize();
  73238. var m = result._m;
  73239. m[0] = (axis.x * axis.x) * c1 + c;
  73240. m[1] = (axis.x * axis.y) * c1 - (axis.z * s);
  73241. m[2] = (axis.x * axis.z) * c1 + (axis.y * s);
  73242. m[3] = 0.0;
  73243. m[4] = (axis.y * axis.x) * c1 + (axis.z * s);
  73244. m[5] = (axis.y * axis.y) * c1 + c;
  73245. m[6] = (axis.y * axis.z) * c1 - (axis.x * s);
  73246. m[7] = 0.0;
  73247. m[8] = (axis.z * axis.x) * c1 - (axis.y * s);
  73248. m[9] = (axis.z * axis.y) * c1 + (axis.x * s);
  73249. m[10] = (axis.z * axis.z) * c1 + c;
  73250. m[11] = 0.0;
  73251. m[12] = 0.0;
  73252. m[13] = 0.0;
  73253. m[14] = 0.0;
  73254. m[15] = 1.0;
  73255. result._markAsUpdated();
  73256. };
  73257. /**
  73258. * Creates a rotation matrix
  73259. * @param yaw defines the yaw angle in radians (Y axis)
  73260. * @param pitch defines the pitch angle in radians (X axis)
  73261. * @param roll defines the roll angle in radians (X axis)
  73262. * @returns the new rotation matrix
  73263. */
  73264. Matrix.RotationYawPitchRoll = function (yaw, pitch, roll) {
  73265. var result = new Matrix();
  73266. Matrix.RotationYawPitchRollToRef(yaw, pitch, roll, result);
  73267. return result;
  73268. };
  73269. /**
  73270. * Creates a rotation matrix and stores it in a given matrix
  73271. * @param yaw defines the yaw angle in radians (Y axis)
  73272. * @param pitch defines the pitch angle in radians (X axis)
  73273. * @param roll defines the roll angle in radians (X axis)
  73274. * @param result defines the target matrix
  73275. */
  73276. Matrix.RotationYawPitchRollToRef = function (yaw, pitch, roll, result) {
  73277. Quaternion.RotationYawPitchRollToRef(yaw, pitch, roll, MathTmp.Quaternion[0]);
  73278. MathTmp.Quaternion[0].toRotationMatrix(result);
  73279. };
  73280. /**
  73281. * Creates a scaling matrix
  73282. * @param x defines the scale factor on X axis
  73283. * @param y defines the scale factor on Y axis
  73284. * @param z defines the scale factor on Z axis
  73285. * @returns the new matrix
  73286. */
  73287. Matrix.Scaling = function (x, y, z) {
  73288. var result = new Matrix();
  73289. Matrix.ScalingToRef(x, y, z, result);
  73290. return result;
  73291. };
  73292. /**
  73293. * Creates a scaling matrix and stores it in a given matrix
  73294. * @param x defines the scale factor on X axis
  73295. * @param y defines the scale factor on Y axis
  73296. * @param z defines the scale factor on Z axis
  73297. * @param result defines the target matrix
  73298. */
  73299. Matrix.ScalingToRef = function (x, y, z, result) {
  73300. 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);
  73301. result._updateIdentityStatus(x === 1 && y === 1 && z === 1);
  73302. };
  73303. /**
  73304. * Creates a translation matrix
  73305. * @param x defines the translation on X axis
  73306. * @param y defines the translation on Y axis
  73307. * @param z defines the translationon Z axis
  73308. * @returns the new matrix
  73309. */
  73310. Matrix.Translation = function (x, y, z) {
  73311. var result = new Matrix();
  73312. Matrix.TranslationToRef(x, y, z, result);
  73313. return result;
  73314. };
  73315. /**
  73316. * Creates a translation matrix and stores it in a given matrix
  73317. * @param x defines the translation on X axis
  73318. * @param y defines the translation on Y axis
  73319. * @param z defines the translationon Z axis
  73320. * @param result defines the target matrix
  73321. */
  73322. Matrix.TranslationToRef = function (x, y, z, result) {
  73323. 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);
  73324. result._updateIdentityStatus(x === 0 && y === 0 && z === 0);
  73325. };
  73326. /**
  73327. * Returns a new Matrix whose values are the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73328. * @param startValue defines the start value
  73329. * @param endValue defines the end value
  73330. * @param gradient defines the gradient factor
  73331. * @returns the new matrix
  73332. */
  73333. Matrix.Lerp = function (startValue, endValue, gradient) {
  73334. var result = new Matrix();
  73335. Matrix.LerpToRef(startValue, endValue, gradient, result);
  73336. return result;
  73337. };
  73338. /**
  73339. * Set the given matrix "result" as the interpolated values for "gradient" (float) between the ones of the matrices "startValue" and "endValue".
  73340. * @param startValue defines the start value
  73341. * @param endValue defines the end value
  73342. * @param gradient defines the gradient factor
  73343. * @param result defines the Matrix object where to store data
  73344. */
  73345. Matrix.LerpToRef = function (startValue, endValue, gradient, result) {
  73346. var resultM = result._m;
  73347. var startM = startValue.m;
  73348. var endM = endValue.m;
  73349. for (var index = 0; index < 16; index++) {
  73350. resultM[index] = startM[index] * (1.0 - gradient) + endM[index] * gradient;
  73351. }
  73352. result._markAsUpdated();
  73353. };
  73354. /**
  73355. * Builds a new matrix whose values are computed by:
  73356. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73357. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73358. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73359. * @param startValue defines the first matrix
  73360. * @param endValue defines the second matrix
  73361. * @param gradient defines the gradient between the two matrices
  73362. * @returns the new matrix
  73363. */
  73364. Matrix.DecomposeLerp = function (startValue, endValue, gradient) {
  73365. var result = new Matrix();
  73366. Matrix.DecomposeLerpToRef(startValue, endValue, gradient, result);
  73367. return result;
  73368. };
  73369. /**
  73370. * Update a matrix to values which are computed by:
  73371. * * decomposing the the "startValue" and "endValue" matrices into their respective scale, rotation and translation matrices
  73372. * * interpolating for "gradient" (float) the values between each of these decomposed matrices between the start and the end
  73373. * * recomposing a new matrix from these 3 interpolated scale, rotation and translation matrices
  73374. * @param startValue defines the first matrix
  73375. * @param endValue defines the second matrix
  73376. * @param gradient defines the gradient between the two matrices
  73377. * @param result defines the target matrix
  73378. */
  73379. Matrix.DecomposeLerpToRef = function (startValue, endValue, gradient, result) {
  73380. var startScale = MathTmp.Vector3[0];
  73381. var startRotation = MathTmp.Quaternion[0];
  73382. var startTranslation = MathTmp.Vector3[1];
  73383. startValue.decompose(startScale, startRotation, startTranslation);
  73384. var endScale = MathTmp.Vector3[2];
  73385. var endRotation = MathTmp.Quaternion[1];
  73386. var endTranslation = MathTmp.Vector3[3];
  73387. endValue.decompose(endScale, endRotation, endTranslation);
  73388. var resultScale = MathTmp.Vector3[4];
  73389. Vector3.LerpToRef(startScale, endScale, gradient, resultScale);
  73390. var resultRotation = MathTmp.Quaternion[2];
  73391. Quaternion.SlerpToRef(startRotation, endRotation, gradient, resultRotation);
  73392. var resultTranslation = MathTmp.Vector3[5];
  73393. Vector3.LerpToRef(startTranslation, endTranslation, gradient, resultTranslation);
  73394. Matrix.ComposeToRef(resultScale, resultRotation, resultTranslation, result);
  73395. };
  73396. /**
  73397. * 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"
  73398. * This function works in left handed mode
  73399. * @param eye defines the final position of the entity
  73400. * @param target defines where the entity should look at
  73401. * @param up defines the up vector for the entity
  73402. * @returns the new matrix
  73403. */
  73404. Matrix.LookAtLH = function (eye, target, up) {
  73405. var result = new Matrix();
  73406. Matrix.LookAtLHToRef(eye, target, up, result);
  73407. return result;
  73408. };
  73409. /**
  73410. * 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".
  73411. * This function works in left handed mode
  73412. * @param eye defines the final position of the entity
  73413. * @param target defines where the entity should look at
  73414. * @param up defines the up vector for the entity
  73415. * @param result defines the target matrix
  73416. */
  73417. Matrix.LookAtLHToRef = function (eye, target, up, result) {
  73418. var xAxis = MathTmp.Vector3[0];
  73419. var yAxis = MathTmp.Vector3[1];
  73420. var zAxis = MathTmp.Vector3[2];
  73421. // Z axis
  73422. target.subtractToRef(eye, zAxis);
  73423. zAxis.normalize();
  73424. // X axis
  73425. Vector3.CrossToRef(up, zAxis, xAxis);
  73426. var xSquareLength = xAxis.lengthSquared();
  73427. if (xSquareLength === 0) {
  73428. xAxis.x = 1.0;
  73429. }
  73430. else {
  73431. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  73432. }
  73433. // Y axis
  73434. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  73435. yAxis.normalize();
  73436. // Eye angles
  73437. var ex = -Vector3.Dot(xAxis, eye);
  73438. var ey = -Vector3.Dot(yAxis, eye);
  73439. var ez = -Vector3.Dot(zAxis, eye);
  73440. 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);
  73441. };
  73442. /**
  73443. * 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"
  73444. * This function works in right handed mode
  73445. * @param eye defines the final position of the entity
  73446. * @param target defines where the entity should look at
  73447. * @param up defines the up vector for the entity
  73448. * @returns the new matrix
  73449. */
  73450. Matrix.LookAtRH = function (eye, target, up) {
  73451. var result = new Matrix();
  73452. Matrix.LookAtRHToRef(eye, target, up, result);
  73453. return result;
  73454. };
  73455. /**
  73456. * 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".
  73457. * This function works in right handed mode
  73458. * @param eye defines the final position of the entity
  73459. * @param target defines where the entity should look at
  73460. * @param up defines the up vector for the entity
  73461. * @param result defines the target matrix
  73462. */
  73463. Matrix.LookAtRHToRef = function (eye, target, up, result) {
  73464. var xAxis = MathTmp.Vector3[0];
  73465. var yAxis = MathTmp.Vector3[1];
  73466. var zAxis = MathTmp.Vector3[2];
  73467. // Z axis
  73468. eye.subtractToRef(target, zAxis);
  73469. zAxis.normalize();
  73470. // X axis
  73471. Vector3.CrossToRef(up, zAxis, xAxis);
  73472. var xSquareLength = xAxis.lengthSquared();
  73473. if (xSquareLength === 0) {
  73474. xAxis.x = 1.0;
  73475. }
  73476. else {
  73477. xAxis.normalizeFromLength(Math.sqrt(xSquareLength));
  73478. }
  73479. // Y axis
  73480. Vector3.CrossToRef(zAxis, xAxis, yAxis);
  73481. yAxis.normalize();
  73482. // Eye angles
  73483. var ex = -Vector3.Dot(xAxis, eye);
  73484. var ey = -Vector3.Dot(yAxis, eye);
  73485. var ez = -Vector3.Dot(zAxis, eye);
  73486. 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);
  73487. };
  73488. /**
  73489. * Create a left-handed orthographic projection matrix
  73490. * @param width defines the viewport width
  73491. * @param height defines the viewport height
  73492. * @param znear defines the near clip plane
  73493. * @param zfar defines the far clip plane
  73494. * @returns a new matrix as a left-handed orthographic projection matrix
  73495. */
  73496. Matrix.OrthoLH = function (width, height, znear, zfar) {
  73497. var matrix = new Matrix();
  73498. Matrix.OrthoLHToRef(width, height, znear, zfar, matrix);
  73499. return matrix;
  73500. };
  73501. /**
  73502. * Store a left-handed orthographic projection to a given matrix
  73503. * @param width defines the viewport width
  73504. * @param height defines the viewport height
  73505. * @param znear defines the near clip plane
  73506. * @param zfar defines the far clip plane
  73507. * @param result defines the target matrix
  73508. */
  73509. Matrix.OrthoLHToRef = function (width, height, znear, zfar, result) {
  73510. var n = znear;
  73511. var f = zfar;
  73512. var a = 2.0 / width;
  73513. var b = 2.0 / height;
  73514. var c = 2.0 / (f - n);
  73515. var d = -(f + n) / (f - n);
  73516. 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);
  73517. result._updateIdentityStatus(a === 1 && b === 1 && c === 1 && d === 0);
  73518. };
  73519. /**
  73520. * Create a left-handed orthographic projection matrix
  73521. * @param left defines the viewport left coordinate
  73522. * @param right defines the viewport right coordinate
  73523. * @param bottom defines the viewport bottom coordinate
  73524. * @param top defines the viewport top coordinate
  73525. * @param znear defines the near clip plane
  73526. * @param zfar defines the far clip plane
  73527. * @returns a new matrix as a left-handed orthographic projection matrix
  73528. */
  73529. Matrix.OrthoOffCenterLH = function (left, right, bottom, top, znear, zfar) {
  73530. var matrix = new Matrix();
  73531. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, matrix);
  73532. return matrix;
  73533. };
  73534. /**
  73535. * Stores a left-handed orthographic projection into a given matrix
  73536. * @param left defines the viewport left coordinate
  73537. * @param right defines the viewport right coordinate
  73538. * @param bottom defines the viewport bottom coordinate
  73539. * @param top defines the viewport top coordinate
  73540. * @param znear defines the near clip plane
  73541. * @param zfar defines the far clip plane
  73542. * @param result defines the target matrix
  73543. */
  73544. Matrix.OrthoOffCenterLHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73545. var n = znear;
  73546. var f = zfar;
  73547. var a = 2.0 / (right - left);
  73548. var b = 2.0 / (top - bottom);
  73549. var c = 2.0 / (f - n);
  73550. var d = -(f + n) / (f - n);
  73551. var i0 = (left + right) / (left - right);
  73552. var i1 = (top + bottom) / (bottom - top);
  73553. 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);
  73554. result._markAsUpdated();
  73555. };
  73556. /**
  73557. * Creates a right-handed orthographic projection matrix
  73558. * @param left defines the viewport left coordinate
  73559. * @param right defines the viewport right coordinate
  73560. * @param bottom defines the viewport bottom coordinate
  73561. * @param top defines the viewport top coordinate
  73562. * @param znear defines the near clip plane
  73563. * @param zfar defines the far clip plane
  73564. * @returns a new matrix as a right-handed orthographic projection matrix
  73565. */
  73566. Matrix.OrthoOffCenterRH = function (left, right, bottom, top, znear, zfar) {
  73567. var matrix = new Matrix();
  73568. Matrix.OrthoOffCenterRHToRef(left, right, bottom, top, znear, zfar, matrix);
  73569. return matrix;
  73570. };
  73571. /**
  73572. * Stores a right-handed orthographic projection into a given matrix
  73573. * @param left defines the viewport left coordinate
  73574. * @param right defines the viewport right coordinate
  73575. * @param bottom defines the viewport bottom coordinate
  73576. * @param top defines the viewport top coordinate
  73577. * @param znear defines the near clip plane
  73578. * @param zfar defines the far clip plane
  73579. * @param result defines the target matrix
  73580. */
  73581. Matrix.OrthoOffCenterRHToRef = function (left, right, bottom, top, znear, zfar, result) {
  73582. Matrix.OrthoOffCenterLHToRef(left, right, bottom, top, znear, zfar, result);
  73583. result._m[10] *= -1; // No need to call _markAsUpdated as previous function already called it and let _isIdentityDirty to true
  73584. };
  73585. /**
  73586. * Creates a left-handed perspective projection matrix
  73587. * @param width defines the viewport width
  73588. * @param height defines the viewport height
  73589. * @param znear defines the near clip plane
  73590. * @param zfar defines the far clip plane
  73591. * @returns a new matrix as a left-handed perspective projection matrix
  73592. */
  73593. Matrix.PerspectiveLH = function (width, height, znear, zfar) {
  73594. var matrix = new Matrix();
  73595. var n = znear;
  73596. var f = zfar;
  73597. var a = 2.0 * n / width;
  73598. var b = 2.0 * n / height;
  73599. var c = (f + n) / (f - n);
  73600. var d = -2.0 * f * n / (f - n);
  73601. 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);
  73602. matrix._updateIdentityStatus(false);
  73603. return matrix;
  73604. };
  73605. /**
  73606. * Creates a left-handed perspective projection matrix
  73607. * @param fov defines the horizontal field of view
  73608. * @param aspect defines the aspect ratio
  73609. * @param znear defines the near clip plane
  73610. * @param zfar defines the far clip plane
  73611. * @returns a new matrix as a left-handed perspective projection matrix
  73612. */
  73613. Matrix.PerspectiveFovLH = function (fov, aspect, znear, zfar) {
  73614. var matrix = new Matrix();
  73615. Matrix.PerspectiveFovLHToRef(fov, aspect, znear, zfar, matrix);
  73616. return matrix;
  73617. };
  73618. /**
  73619. * Stores a left-handed perspective projection into a given matrix
  73620. * @param fov defines the horizontal field of view
  73621. * @param aspect defines the aspect ratio
  73622. * @param znear defines the near clip plane
  73623. * @param zfar defines the far clip plane
  73624. * @param result defines the target matrix
  73625. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73626. */
  73627. Matrix.PerspectiveFovLHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73628. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73629. var n = znear;
  73630. var f = zfar;
  73631. var t = 1.0 / (Math.tan(fov * 0.5));
  73632. var a = isVerticalFovFixed ? (t / aspect) : t;
  73633. var b = isVerticalFovFixed ? t : (t * aspect);
  73634. var c = (f + n) / (f - n);
  73635. var d = -2.0 * f * n / (f - n);
  73636. 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);
  73637. result._updateIdentityStatus(false);
  73638. };
  73639. /**
  73640. * Creates a right-handed perspective projection matrix
  73641. * @param fov defines the horizontal field of view
  73642. * @param aspect defines the aspect ratio
  73643. * @param znear defines the near clip plane
  73644. * @param zfar defines the far clip plane
  73645. * @returns a new matrix as a right-handed perspective projection matrix
  73646. */
  73647. Matrix.PerspectiveFovRH = function (fov, aspect, znear, zfar) {
  73648. var matrix = new Matrix();
  73649. Matrix.PerspectiveFovRHToRef(fov, aspect, znear, zfar, matrix);
  73650. return matrix;
  73651. };
  73652. /**
  73653. * Stores a right-handed perspective projection into a given matrix
  73654. * @param fov defines the horizontal field of view
  73655. * @param aspect defines the aspect ratio
  73656. * @param znear defines the near clip plane
  73657. * @param zfar defines the far clip plane
  73658. * @param result defines the target matrix
  73659. * @param isVerticalFovFixed defines it the fov is vertically fixed (default) or horizontally
  73660. */
  73661. Matrix.PerspectiveFovRHToRef = function (fov, aspect, znear, zfar, result, isVerticalFovFixed) {
  73662. //alternatively this could be expressed as:
  73663. // m = PerspectiveFovLHToRef
  73664. // m[10] *= -1.0;
  73665. // m[11] *= -1.0;
  73666. if (isVerticalFovFixed === void 0) { isVerticalFovFixed = true; }
  73667. var n = znear;
  73668. var f = zfar;
  73669. var t = 1.0 / (Math.tan(fov * 0.5));
  73670. var a = isVerticalFovFixed ? (t / aspect) : t;
  73671. var b = isVerticalFovFixed ? t : (t * aspect);
  73672. var c = -(f + n) / (f - n);
  73673. var d = -2 * f * n / (f - n);
  73674. 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);
  73675. result._updateIdentityStatus(false);
  73676. };
  73677. /**
  73678. * Stores a perspective projection for WebVR info a given matrix
  73679. * @param fov defines the field of view
  73680. * @param znear defines the near clip plane
  73681. * @param zfar defines the far clip plane
  73682. * @param result defines the target matrix
  73683. * @param rightHanded defines if the matrix must be in right-handed mode (false by default)
  73684. */
  73685. Matrix.PerspectiveFovWebVRToRef = function (fov, znear, zfar, result, rightHanded) {
  73686. if (rightHanded === void 0) { rightHanded = false; }
  73687. var rightHandedFactor = rightHanded ? -1 : 1;
  73688. var upTan = Math.tan(fov.upDegrees * Math.PI / 180.0);
  73689. var downTan = Math.tan(fov.downDegrees * Math.PI / 180.0);
  73690. var leftTan = Math.tan(fov.leftDegrees * Math.PI / 180.0);
  73691. var rightTan = Math.tan(fov.rightDegrees * Math.PI / 180.0);
  73692. var xScale = 2.0 / (leftTan + rightTan);
  73693. var yScale = 2.0 / (upTan + downTan);
  73694. var m = result._m;
  73695. m[0] = xScale;
  73696. m[1] = m[2] = m[3] = m[4] = 0.0;
  73697. m[5] = yScale;
  73698. m[6] = m[7] = 0.0;
  73699. m[8] = ((leftTan - rightTan) * xScale * 0.5);
  73700. m[9] = -((upTan - downTan) * yScale * 0.5);
  73701. m[10] = -zfar / (znear - zfar);
  73702. m[11] = 1.0 * rightHandedFactor;
  73703. m[12] = m[13] = m[15] = 0.0;
  73704. m[14] = -(2.0 * zfar * znear) / (zfar - znear);
  73705. result._markAsUpdated();
  73706. };
  73707. /**
  73708. * Computes a complete transformation matrix
  73709. * @param viewport defines the viewport to use
  73710. * @param world defines the world matrix
  73711. * @param view defines the view matrix
  73712. * @param projection defines the projection matrix
  73713. * @param zmin defines the near clip plane
  73714. * @param zmax defines the far clip plane
  73715. * @returns the transformation matrix
  73716. */
  73717. Matrix.GetFinalMatrix = function (viewport, world, view, projection, zmin, zmax) {
  73718. var cw = viewport.width;
  73719. var ch = viewport.height;
  73720. var cx = viewport.x;
  73721. var cy = viewport.y;
  73722. 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);
  73723. var matrix = MathTmp.Matrix[0];
  73724. world.multiplyToRef(view, matrix);
  73725. matrix.multiplyToRef(projection, matrix);
  73726. return matrix.multiply(viewportMatrix);
  73727. };
  73728. /**
  73729. * Extracts a 2x2 matrix from a given matrix and store the result in a Float32Array
  73730. * @param matrix defines the matrix to use
  73731. * @returns a new Float32Array array with 4 elements : the 2x2 matrix extracted from the given matrix
  73732. */
  73733. Matrix.GetAsMatrix2x2 = function (matrix) {
  73734. var m = matrix.m;
  73735. return new Float32Array([m[0], m[1], m[4], m[5]]);
  73736. };
  73737. /**
  73738. * Extracts a 3x3 matrix from a given matrix and store the result in a Float32Array
  73739. * @param matrix defines the matrix to use
  73740. * @returns a new Float32Array array with 9 elements : the 3x3 matrix extracted from the given matrix
  73741. */
  73742. Matrix.GetAsMatrix3x3 = function (matrix) {
  73743. var m = matrix.m;
  73744. return new Float32Array([
  73745. m[0], m[1], m[2],
  73746. m[4], m[5], m[6],
  73747. m[8], m[9], m[10]
  73748. ]);
  73749. };
  73750. /**
  73751. * Compute the transpose of a given matrix
  73752. * @param matrix defines the matrix to transpose
  73753. * @returns the new matrix
  73754. */
  73755. Matrix.Transpose = function (matrix) {
  73756. var result = new Matrix();
  73757. Matrix.TransposeToRef(matrix, result);
  73758. return result;
  73759. };
  73760. /**
  73761. * Compute the transpose of a matrix and store it in a target matrix
  73762. * @param matrix defines the matrix to transpose
  73763. * @param result defines the target matrix
  73764. */
  73765. Matrix.TransposeToRef = function (matrix, result) {
  73766. var rm = result._m;
  73767. var mm = matrix.m;
  73768. rm[0] = mm[0];
  73769. rm[1] = mm[4];
  73770. rm[2] = mm[8];
  73771. rm[3] = mm[12];
  73772. rm[4] = mm[1];
  73773. rm[5] = mm[5];
  73774. rm[6] = mm[9];
  73775. rm[7] = mm[13];
  73776. rm[8] = mm[2];
  73777. rm[9] = mm[6];
  73778. rm[10] = mm[10];
  73779. rm[11] = mm[14];
  73780. rm[12] = mm[3];
  73781. rm[13] = mm[7];
  73782. rm[14] = mm[11];
  73783. rm[15] = mm[15];
  73784. // identity-ness does not change when transposing
  73785. result._updateIdentityStatus(matrix._isIdentity, matrix._isIdentityDirty);
  73786. };
  73787. /**
  73788. * Computes a reflection matrix from a plane
  73789. * @param plane defines the reflection plane
  73790. * @returns a new matrix
  73791. */
  73792. Matrix.Reflection = function (plane) {
  73793. var matrix = new Matrix();
  73794. Matrix.ReflectionToRef(plane, matrix);
  73795. return matrix;
  73796. };
  73797. /**
  73798. * Computes a reflection matrix from a plane
  73799. * @param plane defines the reflection plane
  73800. * @param result defines the target matrix
  73801. */
  73802. Matrix.ReflectionToRef = function (plane, result) {
  73803. plane.normalize();
  73804. var x = plane.normal.x;
  73805. var y = plane.normal.y;
  73806. var z = plane.normal.z;
  73807. var temp = -2 * x;
  73808. var temp2 = -2 * y;
  73809. var temp3 = -2 * z;
  73810. 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);
  73811. };
  73812. /**
  73813. * Sets the given matrix as a rotation matrix composed from the 3 left handed axes
  73814. * @param xaxis defines the value of the 1st axis
  73815. * @param yaxis defines the value of the 2nd axis
  73816. * @param zaxis defines the value of the 3rd axis
  73817. * @param result defines the target matrix
  73818. */
  73819. Matrix.FromXYZAxesToRef = function (xaxis, yaxis, zaxis, result) {
  73820. 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);
  73821. };
  73822. /**
  73823. * Creates a rotation matrix from a quaternion and stores it in a target matrix
  73824. * @param quat defines the quaternion to use
  73825. * @param result defines the target matrix
  73826. */
  73827. Matrix.FromQuaternionToRef = function (quat, result) {
  73828. var xx = quat.x * quat.x;
  73829. var yy = quat.y * quat.y;
  73830. var zz = quat.z * quat.z;
  73831. var xy = quat.x * quat.y;
  73832. var zw = quat.z * quat.w;
  73833. var zx = quat.z * quat.x;
  73834. var yw = quat.y * quat.w;
  73835. var yz = quat.y * quat.z;
  73836. var xw = quat.x * quat.w;
  73837. result._m[0] = 1.0 - (2.0 * (yy + zz));
  73838. result._m[1] = 2.0 * (xy + zw);
  73839. result._m[2] = 2.0 * (zx - yw);
  73840. result._m[3] = 0.0;
  73841. result._m[4] = 2.0 * (xy - zw);
  73842. result._m[5] = 1.0 - (2.0 * (zz + xx));
  73843. result._m[6] = 2.0 * (yz + xw);
  73844. result._m[7] = 0.0;
  73845. result._m[8] = 2.0 * (zx + yw);
  73846. result._m[9] = 2.0 * (yz - xw);
  73847. result._m[10] = 1.0 - (2.0 * (yy + xx));
  73848. result._m[11] = 0.0;
  73849. result._m[12] = 0.0;
  73850. result._m[13] = 0.0;
  73851. result._m[14] = 0.0;
  73852. result._m[15] = 1.0;
  73853. result._markAsUpdated();
  73854. };
  73855. Matrix._updateFlagSeed = 0;
  73856. Matrix._identityReadOnly = Matrix.Identity();
  73857. return Matrix;
  73858. }());
  73859. /**
  73860. * Represens a plane by the equation ax + by + cz + d = 0
  73861. */
  73862. var Plane = /** @class */ (function () {
  73863. /**
  73864. * Creates a Plane object according to the given floats a, b, c, d and the plane equation : ax + by + cz + d = 0
  73865. * @param a a component of the plane
  73866. * @param b b component of the plane
  73867. * @param c c component of the plane
  73868. * @param d d component of the plane
  73869. */
  73870. function Plane(a, b, c, d) {
  73871. this.normal = new Vector3(a, b, c);
  73872. this.d = d;
  73873. }
  73874. /**
  73875. * @returns the plane coordinates as a new array of 4 elements [a, b, c, d].
  73876. */
  73877. Plane.prototype.asArray = function () {
  73878. return [this.normal.x, this.normal.y, this.normal.z, this.d];
  73879. };
  73880. // Methods
  73881. /**
  73882. * @returns a new plane copied from the current Plane.
  73883. */
  73884. Plane.prototype.clone = function () {
  73885. return new Plane(this.normal.x, this.normal.y, this.normal.z, this.d);
  73886. };
  73887. /**
  73888. * @returns the string "Plane".
  73889. */
  73890. Plane.prototype.getClassName = function () {
  73891. return "Plane";
  73892. };
  73893. /**
  73894. * @returns the Plane hash code.
  73895. */
  73896. Plane.prototype.getHashCode = function () {
  73897. var hash = this.normal.getHashCode();
  73898. hash = (hash * 397) ^ (this.d || 0);
  73899. return hash;
  73900. };
  73901. /**
  73902. * Normalize the current Plane in place.
  73903. * @returns the updated Plane.
  73904. */
  73905. Plane.prototype.normalize = function () {
  73906. var norm = (Math.sqrt((this.normal.x * this.normal.x) + (this.normal.y * this.normal.y) + (this.normal.z * this.normal.z)));
  73907. var magnitude = 0.0;
  73908. if (norm !== 0) {
  73909. magnitude = 1.0 / norm;
  73910. }
  73911. this.normal.x *= magnitude;
  73912. this.normal.y *= magnitude;
  73913. this.normal.z *= magnitude;
  73914. this.d *= magnitude;
  73915. return this;
  73916. };
  73917. /**
  73918. * Applies a transformation the plane and returns the result
  73919. * @param transformation the transformation matrix to be applied to the plane
  73920. * @returns a new Plane as the result of the transformation of the current Plane by the given matrix.
  73921. */
  73922. Plane.prototype.transform = function (transformation) {
  73923. var transposedMatrix = MathTmp.Matrix[0];
  73924. Matrix.TransposeToRef(transformation, transposedMatrix);
  73925. var m = transposedMatrix.m;
  73926. var x = this.normal.x;
  73927. var y = this.normal.y;
  73928. var z = this.normal.z;
  73929. var d = this.d;
  73930. var normalX = x * m[0] + y * m[1] + z * m[2] + d * m[3];
  73931. var normalY = x * m[4] + y * m[5] + z * m[6] + d * m[7];
  73932. var normalZ = x * m[8] + y * m[9] + z * m[10] + d * m[11];
  73933. var finalD = x * m[12] + y * m[13] + z * m[14] + d * m[15];
  73934. return new Plane(normalX, normalY, normalZ, finalD);
  73935. };
  73936. /**
  73937. * Calcualtte the dot product between the point and the plane normal
  73938. * @param point point to calculate the dot product with
  73939. * @returns the dot product (float) of the point coordinates and the plane normal.
  73940. */
  73941. Plane.prototype.dotCoordinate = function (point) {
  73942. return ((((this.normal.x * point.x) + (this.normal.y * point.y)) + (this.normal.z * point.z)) + this.d);
  73943. };
  73944. /**
  73945. * Updates the current Plane from the plane defined by the three given points.
  73946. * @param point1 one of the points used to contruct the plane
  73947. * @param point2 one of the points used to contruct the plane
  73948. * @param point3 one of the points used to contruct the plane
  73949. * @returns the updated Plane.
  73950. */
  73951. Plane.prototype.copyFromPoints = function (point1, point2, point3) {
  73952. var x1 = point2.x - point1.x;
  73953. var y1 = point2.y - point1.y;
  73954. var z1 = point2.z - point1.z;
  73955. var x2 = point3.x - point1.x;
  73956. var y2 = point3.y - point1.y;
  73957. var z2 = point3.z - point1.z;
  73958. var yz = (y1 * z2) - (z1 * y2);
  73959. var xz = (z1 * x2) - (x1 * z2);
  73960. var xy = (x1 * y2) - (y1 * x2);
  73961. var pyth = (Math.sqrt((yz * yz) + (xz * xz) + (xy * xy)));
  73962. var invPyth;
  73963. if (pyth !== 0) {
  73964. invPyth = 1.0 / pyth;
  73965. }
  73966. else {
  73967. invPyth = 0.0;
  73968. }
  73969. this.normal.x = yz * invPyth;
  73970. this.normal.y = xz * invPyth;
  73971. this.normal.z = xy * invPyth;
  73972. this.d = -((this.normal.x * point1.x) + (this.normal.y * point1.y) + (this.normal.z * point1.z));
  73973. return this;
  73974. };
  73975. /**
  73976. * Checks if the plane is facing a given direction
  73977. * @param direction the direction to check if the plane is facing
  73978. * @param epsilon value the dot product is compared against (returns true if dot <= epsilon)
  73979. * @returns True is the vector "direction" is the same side than the plane normal.
  73980. */
  73981. Plane.prototype.isFrontFacingTo = function (direction, epsilon) {
  73982. var dot = Vector3.Dot(this.normal, direction);
  73983. return (dot <= epsilon);
  73984. };
  73985. /**
  73986. * Calculates the distance to a point
  73987. * @param point point to calculate distance to
  73988. * @returns the signed distance (float) from the given point to the Plane.
  73989. */
  73990. Plane.prototype.signedDistanceTo = function (point) {
  73991. return Vector3.Dot(point, this.normal) + this.d;
  73992. };
  73993. // Statics
  73994. /**
  73995. * Creates a plane from an array
  73996. * @param array the array to create a plane from
  73997. * @returns a new Plane from the given array.
  73998. */
  73999. Plane.FromArray = function (array) {
  74000. return new Plane(array[0], array[1], array[2], array[3]);
  74001. };
  74002. /**
  74003. * Creates a plane from three points
  74004. * @param point1 point used to create the plane
  74005. * @param point2 point used to create the plane
  74006. * @param point3 point used to create the plane
  74007. * @returns a new Plane defined by the three given points.
  74008. */
  74009. Plane.FromPoints = function (point1, point2, point3) {
  74010. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  74011. result.copyFromPoints(point1, point2, point3);
  74012. return result;
  74013. };
  74014. /**
  74015. * Creates a plane from an origin point and a normal
  74016. * @param origin origin of the plane to be constructed
  74017. * @param normal normal of the plane to be constructed
  74018. * @returns a new Plane the normal vector to this plane at the given origin point.
  74019. * Note : the vector "normal" is updated because normalized.
  74020. */
  74021. Plane.FromPositionAndNormal = function (origin, normal) {
  74022. var result = new Plane(0.0, 0.0, 0.0, 0.0);
  74023. normal.normalize();
  74024. result.normal = normal;
  74025. result.d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  74026. return result;
  74027. };
  74028. /**
  74029. * Calculates the distance from a plane and a point
  74030. * @param origin origin of the plane to be constructed
  74031. * @param normal normal of the plane to be constructed
  74032. * @param point point to calculate distance to
  74033. * @returns the signed distance between the plane defined by the normal vector at the "origin"" point and the given other point.
  74034. */
  74035. Plane.SignedDistanceToPlaneFromPositionAndNormal = function (origin, normal, point) {
  74036. var d = -(normal.x * origin.x + normal.y * origin.y + normal.z * origin.z);
  74037. return Vector3.Dot(point, normal) + d;
  74038. };
  74039. return Plane;
  74040. }());
  74041. /**
  74042. * Class used to represent a viewport on screen
  74043. */
  74044. var Viewport = /** @class */ (function () {
  74045. /**
  74046. * Creates a Viewport object located at (x, y) and sized (width, height)
  74047. * @param x defines viewport left coordinate
  74048. * @param y defines viewport top coordinate
  74049. * @param width defines the viewport width
  74050. * @param height defines the viewport height
  74051. */
  74052. function Viewport(
  74053. /** viewport left coordinate */
  74054. x,
  74055. /** viewport top coordinate */
  74056. y,
  74057. /**viewport width */
  74058. width,
  74059. /** viewport height */
  74060. height) {
  74061. this.x = x;
  74062. this.y = y;
  74063. this.width = width;
  74064. this.height = height;
  74065. }
  74066. /**
  74067. * Creates a new viewport using absolute sizing (from 0-> width, 0-> height instead of 0->1)
  74068. * @param renderWidth defines the rendering width
  74069. * @param renderHeight defines the rendering height
  74070. * @returns a new Viewport
  74071. */
  74072. Viewport.prototype.toGlobal = function (renderWidth, renderHeight) {
  74073. return new Viewport(this.x * renderWidth, this.y * renderHeight, this.width * renderWidth, this.height * renderHeight);
  74074. };
  74075. /**
  74076. * Stores absolute viewport value into a target viewport (from 0-> width, 0-> height instead of 0->1)
  74077. * @param renderWidth defines the rendering width
  74078. * @param renderHeight defines the rendering height
  74079. * @param ref defines the target viewport
  74080. * @returns the current viewport
  74081. */
  74082. Viewport.prototype.toGlobalToRef = function (renderWidth, renderHeight, ref) {
  74083. ref.x = this.x * renderWidth;
  74084. ref.y = this.y * renderHeight;
  74085. ref.width = this.width * renderWidth;
  74086. ref.height = this.height * renderHeight;
  74087. return this;
  74088. };
  74089. /**
  74090. * Returns a new Viewport copied from the current one
  74091. * @returns a new Viewport
  74092. */
  74093. Viewport.prototype.clone = function () {
  74094. return new Viewport(this.x, this.y, this.width, this.height);
  74095. };
  74096. return Viewport;
  74097. }());
  74098. /**
  74099. * Reprasents a camera frustum
  74100. */
  74101. var Frustum = /** @class */ (function () {
  74102. function Frustum() {
  74103. }
  74104. /**
  74105. * Gets the planes representing the frustum
  74106. * @param transform matrix to be applied to the returned planes
  74107. * @returns a new array of 6 Frustum planes computed by the given transformation matrix.
  74108. */
  74109. Frustum.GetPlanes = function (transform) {
  74110. var frustumPlanes = [];
  74111. for (var index = 0; index < 6; index++) {
  74112. frustumPlanes.push(new Plane(0.0, 0.0, 0.0, 0.0));
  74113. }
  74114. Frustum.GetPlanesToRef(transform, frustumPlanes);
  74115. return frustumPlanes;
  74116. };
  74117. /**
  74118. * Gets the near frustum plane transformed by the transform matrix
  74119. * @param transform transformation matrix to be applied to the resulting frustum plane
  74120. * @param frustumPlane the resuling frustum plane
  74121. */
  74122. Frustum.GetNearPlaneToRef = function (transform, frustumPlane) {
  74123. var m = transform.m;
  74124. frustumPlane.normal.x = m[3] + m[2];
  74125. frustumPlane.normal.y = m[7] + m[6];
  74126. frustumPlane.normal.z = m[11] + m[10];
  74127. frustumPlane.d = m[15] + m[14];
  74128. frustumPlane.normalize();
  74129. };
  74130. /**
  74131. * Gets the far frustum plane transformed by the transform matrix
  74132. * @param transform transformation matrix to be applied to the resulting frustum plane
  74133. * @param frustumPlane the resuling frustum plane
  74134. */
  74135. Frustum.GetFarPlaneToRef = function (transform, frustumPlane) {
  74136. var m = transform.m;
  74137. frustumPlane.normal.x = m[3] - m[2];
  74138. frustumPlane.normal.y = m[7] - m[6];
  74139. frustumPlane.normal.z = m[11] - m[10];
  74140. frustumPlane.d = m[15] - m[14];
  74141. frustumPlane.normalize();
  74142. };
  74143. /**
  74144. * Gets the left frustum plane transformed by the transform matrix
  74145. * @param transform transformation matrix to be applied to the resulting frustum plane
  74146. * @param frustumPlane the resuling frustum plane
  74147. */
  74148. Frustum.GetLeftPlaneToRef = function (transform, frustumPlane) {
  74149. var m = transform.m;
  74150. frustumPlane.normal.x = m[3] + m[0];
  74151. frustumPlane.normal.y = m[7] + m[4];
  74152. frustumPlane.normal.z = m[11] + m[8];
  74153. frustumPlane.d = m[15] + m[12];
  74154. frustumPlane.normalize();
  74155. };
  74156. /**
  74157. * Gets the right frustum plane transformed by the transform matrix
  74158. * @param transform transformation matrix to be applied to the resulting frustum plane
  74159. * @param frustumPlane the resuling frustum plane
  74160. */
  74161. Frustum.GetRightPlaneToRef = function (transform, frustumPlane) {
  74162. var m = transform.m;
  74163. frustumPlane.normal.x = m[3] - m[0];
  74164. frustumPlane.normal.y = m[7] - m[4];
  74165. frustumPlane.normal.z = m[11] - m[8];
  74166. frustumPlane.d = m[15] - m[12];
  74167. frustumPlane.normalize();
  74168. };
  74169. /**
  74170. * Gets the top frustum plane transformed by the transform matrix
  74171. * @param transform transformation matrix to be applied to the resulting frustum plane
  74172. * @param frustumPlane the resuling frustum plane
  74173. */
  74174. Frustum.GetTopPlaneToRef = function (transform, frustumPlane) {
  74175. var m = transform.m;
  74176. frustumPlane.normal.x = m[3] - m[1];
  74177. frustumPlane.normal.y = m[7] - m[5];
  74178. frustumPlane.normal.z = m[11] - m[9];
  74179. frustumPlane.d = m[15] - m[13];
  74180. frustumPlane.normalize();
  74181. };
  74182. /**
  74183. * Gets the bottom frustum plane transformed by the transform matrix
  74184. * @param transform transformation matrix to be applied to the resulting frustum plane
  74185. * @param frustumPlane the resuling frustum plane
  74186. */
  74187. Frustum.GetBottomPlaneToRef = function (transform, frustumPlane) {
  74188. var m = transform.m;
  74189. frustumPlane.normal.x = m[3] + m[1];
  74190. frustumPlane.normal.y = m[7] + m[5];
  74191. frustumPlane.normal.z = m[11] + m[9];
  74192. frustumPlane.d = m[15] + m[13];
  74193. frustumPlane.normalize();
  74194. };
  74195. /**
  74196. * Sets the given array "frustumPlanes" with the 6 Frustum planes computed by the given transformation matrix.
  74197. * @param transform transformation matrix to be applied to the resulting frustum planes
  74198. * @param frustumPlanes the resuling frustum planes
  74199. */
  74200. Frustum.GetPlanesToRef = function (transform, frustumPlanes) {
  74201. // Near
  74202. Frustum.GetNearPlaneToRef(transform, frustumPlanes[0]);
  74203. // Far
  74204. Frustum.GetFarPlaneToRef(transform, frustumPlanes[1]);
  74205. // Left
  74206. Frustum.GetLeftPlaneToRef(transform, frustumPlanes[2]);
  74207. // Right
  74208. Frustum.GetRightPlaneToRef(transform, frustumPlanes[3]);
  74209. // Top
  74210. Frustum.GetTopPlaneToRef(transform, frustumPlanes[4]);
  74211. // Bottom
  74212. Frustum.GetBottomPlaneToRef(transform, frustumPlanes[5]);
  74213. };
  74214. return Frustum;
  74215. }());
  74216. /** Defines supported spaces */
  74217. var Space;
  74218. (function (Space) {
  74219. /** Local (object) space */
  74220. Space[Space["LOCAL"] = 0] = "LOCAL";
  74221. /** World space */
  74222. Space[Space["WORLD"] = 1] = "WORLD";
  74223. /** Bone space */
  74224. Space[Space["BONE"] = 2] = "BONE";
  74225. })(Space || (Space = {}));
  74226. /** Defines the 3 main axes */
  74227. var Axis = /** @class */ (function () {
  74228. function Axis() {
  74229. }
  74230. /** X axis */
  74231. Axis.X = new Vector3(1.0, 0.0, 0.0);
  74232. /** Y axis */
  74233. Axis.Y = new Vector3(0.0, 1.0, 0.0);
  74234. /** Z axis */
  74235. Axis.Z = new Vector3(0.0, 0.0, 1.0);
  74236. return Axis;
  74237. }());
  74238. /** Class used to represent a Bezier curve */
  74239. var BezierCurve = /** @class */ (function () {
  74240. function BezierCurve() {
  74241. }
  74242. /**
  74243. * Returns the cubic Bezier interpolated value (float) at "t" (float) from the given x1, y1, x2, y2 floats
  74244. * @param t defines the time
  74245. * @param x1 defines the left coordinate on X axis
  74246. * @param y1 defines the left coordinate on Y axis
  74247. * @param x2 defines the right coordinate on X axis
  74248. * @param y2 defines the right coordinate on Y axis
  74249. * @returns the interpolated value
  74250. */
  74251. BezierCurve.Interpolate = function (t, x1, y1, x2, y2) {
  74252. // Extract X (which is equal to time here)
  74253. var f0 = 1 - 3 * x2 + 3 * x1;
  74254. var f1 = 3 * x2 - 6 * x1;
  74255. var f2 = 3 * x1;
  74256. var refinedT = t;
  74257. for (var i = 0; i < 5; i++) {
  74258. var refinedT2 = refinedT * refinedT;
  74259. var refinedT3 = refinedT2 * refinedT;
  74260. var x = f0 * refinedT3 + f1 * refinedT2 + f2 * refinedT;
  74261. var slope = 1.0 / (3.0 * f0 * refinedT2 + 2.0 * f1 * refinedT + f2);
  74262. refinedT -= (x - t) * slope;
  74263. refinedT = Math.min(1, Math.max(0, refinedT));
  74264. }
  74265. // Resolve cubic bezier for the given x
  74266. return 3 * Math.pow(1 - refinedT, 2) * refinedT * y1 +
  74267. 3 * (1 - refinedT) * Math.pow(refinedT, 2) * y2 +
  74268. Math.pow(refinedT, 3);
  74269. };
  74270. return BezierCurve;
  74271. }());
  74272. /**
  74273. * Defines potential orientation for back face culling
  74274. */
  74275. var Orientation;
  74276. (function (Orientation) {
  74277. /**
  74278. * Clockwise
  74279. */
  74280. Orientation[Orientation["CW"] = 0] = "CW";
  74281. /** Counter clockwise */
  74282. Orientation[Orientation["CCW"] = 1] = "CCW";
  74283. })(Orientation || (Orientation = {}));
  74284. /**
  74285. * Defines angle representation
  74286. */
  74287. var Angle = /** @class */ (function () {
  74288. /**
  74289. * Creates an Angle object of "radians" radians (float).
  74290. * @param radians the angle in radians
  74291. */
  74292. function Angle(radians) {
  74293. this._radians = radians;
  74294. if (this._radians < 0.0) {
  74295. this._radians += (2.0 * Math.PI);
  74296. }
  74297. }
  74298. /**
  74299. * Get value in degrees
  74300. * @returns the Angle value in degrees (float)
  74301. */
  74302. Angle.prototype.degrees = function () {
  74303. return this._radians * 180.0 / Math.PI;
  74304. };
  74305. /**
  74306. * Get value in radians
  74307. * @returns the Angle value in radians (float)
  74308. */
  74309. Angle.prototype.radians = function () {
  74310. return this._radians;
  74311. };
  74312. /**
  74313. * Gets a new Angle object valued with the angle value in radians between the two given vectors
  74314. * @param a defines first vector
  74315. * @param b defines second vector
  74316. * @returns a new Angle
  74317. */
  74318. Angle.BetweenTwoPoints = function (a, b) {
  74319. var delta = b.subtract(a);
  74320. var theta = Math.atan2(delta.y, delta.x);
  74321. return new Angle(theta);
  74322. };
  74323. /**
  74324. * Gets a new Angle object from the given float in radians
  74325. * @param radians defines the angle value in radians
  74326. * @returns a new Angle
  74327. */
  74328. Angle.FromRadians = function (radians) {
  74329. return new Angle(radians);
  74330. };
  74331. /**
  74332. * Gets a new Angle object from the given float in degrees
  74333. * @param degrees defines the angle value in degrees
  74334. * @returns a new Angle
  74335. */
  74336. Angle.FromDegrees = function (degrees) {
  74337. return new Angle(degrees * Math.PI / 180.0);
  74338. };
  74339. return Angle;
  74340. }());
  74341. /**
  74342. * This represents an arc in a 2d space.
  74343. */
  74344. var Arc2 = /** @class */ (function () {
  74345. /**
  74346. * Creates an Arc object from the three given points : start, middle and end.
  74347. * @param startPoint Defines the start point of the arc
  74348. * @param midPoint Defines the midlle point of the arc
  74349. * @param endPoint Defines the end point of the arc
  74350. */
  74351. function Arc2(
  74352. /** Defines the start point of the arc */
  74353. startPoint,
  74354. /** Defines the mid point of the arc */
  74355. midPoint,
  74356. /** Defines the end point of the arc */
  74357. endPoint) {
  74358. this.startPoint = startPoint;
  74359. this.midPoint = midPoint;
  74360. this.endPoint = endPoint;
  74361. var temp = Math.pow(midPoint.x, 2) + Math.pow(midPoint.y, 2);
  74362. var startToMid = (Math.pow(startPoint.x, 2) + Math.pow(startPoint.y, 2) - temp) / 2.;
  74363. var midToEnd = (temp - Math.pow(endPoint.x, 2) - Math.pow(endPoint.y, 2)) / 2.;
  74364. var det = (startPoint.x - midPoint.x) * (midPoint.y - endPoint.y) - (midPoint.x - endPoint.x) * (startPoint.y - midPoint.y);
  74365. 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);
  74366. this.radius = this.centerPoint.subtract(this.startPoint).length();
  74367. this.startAngle = Angle.BetweenTwoPoints(this.centerPoint, this.startPoint);
  74368. var a1 = this.startAngle.degrees();
  74369. var a2 = Angle.BetweenTwoPoints(this.centerPoint, this.midPoint).degrees();
  74370. var a3 = Angle.BetweenTwoPoints(this.centerPoint, this.endPoint).degrees();
  74371. // angles correction
  74372. if (a2 - a1 > +180.0) {
  74373. a2 -= 360.0;
  74374. }
  74375. if (a2 - a1 < -180.0) {
  74376. a2 += 360.0;
  74377. }
  74378. if (a3 - a2 > +180.0) {
  74379. a3 -= 360.0;
  74380. }
  74381. if (a3 - a2 < -180.0) {
  74382. a3 += 360.0;
  74383. }
  74384. this.orientation = (a2 - a1) < 0 ? Orientation.CW : Orientation.CCW;
  74385. this.angle = Angle.FromDegrees(this.orientation === Orientation.CW ? a1 - a3 : a3 - a1);
  74386. }
  74387. return Arc2;
  74388. }());
  74389. /**
  74390. * Represents a 2D path made up of multiple 2D points
  74391. */
  74392. var Path2 = /** @class */ (function () {
  74393. /**
  74394. * Creates a Path2 object from the starting 2D coordinates x and y.
  74395. * @param x the starting points x value
  74396. * @param y the starting points y value
  74397. */
  74398. function Path2(x, y) {
  74399. this._points = new Array();
  74400. this._length = 0.0;
  74401. /**
  74402. * If the path start and end point are the same
  74403. */
  74404. this.closed = false;
  74405. this._points.push(new Vector2(x, y));
  74406. }
  74407. /**
  74408. * Adds a new segment until the given coordinates (x, y) to the current Path2.
  74409. * @param x the added points x value
  74410. * @param y the added points y value
  74411. * @returns the updated Path2.
  74412. */
  74413. Path2.prototype.addLineTo = function (x, y) {
  74414. if (this.closed) {
  74415. return this;
  74416. }
  74417. var newPoint = new Vector2(x, y);
  74418. var previousPoint = this._points[this._points.length - 1];
  74419. this._points.push(newPoint);
  74420. this._length += newPoint.subtract(previousPoint).length();
  74421. return this;
  74422. };
  74423. /**
  74424. * 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.
  74425. * @param midX middle point x value
  74426. * @param midY middle point y value
  74427. * @param endX end point x value
  74428. * @param endY end point y value
  74429. * @param numberOfSegments (default: 36)
  74430. * @returns the updated Path2.
  74431. */
  74432. Path2.prototype.addArcTo = function (midX, midY, endX, endY, numberOfSegments) {
  74433. if (numberOfSegments === void 0) { numberOfSegments = 36; }
  74434. if (this.closed) {
  74435. return this;
  74436. }
  74437. var startPoint = this._points[this._points.length - 1];
  74438. var midPoint = new Vector2(midX, midY);
  74439. var endPoint = new Vector2(endX, endY);
  74440. var arc = new Arc2(startPoint, midPoint, endPoint);
  74441. var increment = arc.angle.radians() / numberOfSegments;
  74442. if (arc.orientation === Orientation.CW) {
  74443. increment *= -1;
  74444. }
  74445. var currentAngle = arc.startAngle.radians() + increment;
  74446. for (var i = 0; i < numberOfSegments; i++) {
  74447. var x = Math.cos(currentAngle) * arc.radius + arc.centerPoint.x;
  74448. var y = Math.sin(currentAngle) * arc.radius + arc.centerPoint.y;
  74449. this.addLineTo(x, y);
  74450. currentAngle += increment;
  74451. }
  74452. return this;
  74453. };
  74454. /**
  74455. * Closes the Path2.
  74456. * @returns the Path2.
  74457. */
  74458. Path2.prototype.close = function () {
  74459. this.closed = true;
  74460. return this;
  74461. };
  74462. /**
  74463. * Gets the sum of the distance between each sequential point in the path
  74464. * @returns the Path2 total length (float).
  74465. */
  74466. Path2.prototype.length = function () {
  74467. var result = this._length;
  74468. if (!this.closed) {
  74469. var lastPoint = this._points[this._points.length - 1];
  74470. var firstPoint = this._points[0];
  74471. result += (firstPoint.subtract(lastPoint).length());
  74472. }
  74473. return result;
  74474. };
  74475. /**
  74476. * Gets the points which construct the path
  74477. * @returns the Path2 internal array of points.
  74478. */
  74479. Path2.prototype.getPoints = function () {
  74480. return this._points;
  74481. };
  74482. /**
  74483. * Retreives the point at the distance aways from the starting point
  74484. * @param normalizedLengthPosition the length along the path to retreive the point from
  74485. * @returns a new Vector2 located at a percentage of the Path2 total length on this path.
  74486. */
  74487. Path2.prototype.getPointAtLengthPosition = function (normalizedLengthPosition) {
  74488. if (normalizedLengthPosition < 0 || normalizedLengthPosition > 1) {
  74489. return Vector2.Zero();
  74490. }
  74491. var lengthPosition = normalizedLengthPosition * this.length();
  74492. var previousOffset = 0;
  74493. for (var i = 0; i < this._points.length; i++) {
  74494. var j = (i + 1) % this._points.length;
  74495. var a = this._points[i];
  74496. var b = this._points[j];
  74497. var bToA = b.subtract(a);
  74498. var nextOffset = (bToA.length() + previousOffset);
  74499. if (lengthPosition >= previousOffset && lengthPosition <= nextOffset) {
  74500. var dir = bToA.normalize();
  74501. var localOffset = lengthPosition - previousOffset;
  74502. return new Vector2(a.x + (dir.x * localOffset), a.y + (dir.y * localOffset));
  74503. }
  74504. previousOffset = nextOffset;
  74505. }
  74506. return Vector2.Zero();
  74507. };
  74508. /**
  74509. * Creates a new path starting from an x and y position
  74510. * @param x starting x value
  74511. * @param y starting y value
  74512. * @returns a new Path2 starting at the coordinates (x, y).
  74513. */
  74514. Path2.StartingAt = function (x, y) {
  74515. return new Path2(x, y);
  74516. };
  74517. return Path2;
  74518. }());
  74519. /**
  74520. * Represents a 3D path made up of multiple 3D points
  74521. */
  74522. var Path3D = /** @class */ (function () {
  74523. /**
  74524. * new Path3D(path, normal, raw)
  74525. * Creates a Path3D. A Path3D is a logical math object, so not a mesh.
  74526. * please read the description in the tutorial : https://doc.babylonjs.com/how_to/how_to_use_path3d
  74527. * @param path an array of Vector3, the curve axis of the Path3D
  74528. * @param firstNormal (options) Vector3, the first wanted normal to the curve. Ex (0, 1, 0) for a vertical normal.
  74529. * @param raw (optional, default false) : boolean, if true the returned Path3D isn't normalized. Useful to depict path acceleration or speed.
  74530. */
  74531. function Path3D(
  74532. /**
  74533. * an array of Vector3, the curve axis of the Path3D
  74534. */
  74535. path, firstNormal, raw) {
  74536. if (firstNormal === void 0) { firstNormal = null; }
  74537. this.path = path;
  74538. this._curve = new Array();
  74539. this._distances = new Array();
  74540. this._tangents = new Array();
  74541. this._normals = new Array();
  74542. this._binormals = new Array();
  74543. for (var p = 0; p < path.length; p++) {
  74544. this._curve[p] = path[p].clone(); // hard copy
  74545. }
  74546. this._raw = raw || false;
  74547. this._compute(firstNormal);
  74548. }
  74549. /**
  74550. * Returns the Path3D array of successive Vector3 designing its curve.
  74551. * @returns the Path3D array of successive Vector3 designing its curve.
  74552. */
  74553. Path3D.prototype.getCurve = function () {
  74554. return this._curve;
  74555. };
  74556. /**
  74557. * Returns an array populated with tangent vectors on each Path3D curve point.
  74558. * @returns an array populated with tangent vectors on each Path3D curve point.
  74559. */
  74560. Path3D.prototype.getTangents = function () {
  74561. return this._tangents;
  74562. };
  74563. /**
  74564. * Returns an array populated with normal vectors on each Path3D curve point.
  74565. * @returns an array populated with normal vectors on each Path3D curve point.
  74566. */
  74567. Path3D.prototype.getNormals = function () {
  74568. return this._normals;
  74569. };
  74570. /**
  74571. * Returns an array populated with binormal vectors on each Path3D curve point.
  74572. * @returns an array populated with binormal vectors on each Path3D curve point.
  74573. */
  74574. Path3D.prototype.getBinormals = function () {
  74575. return this._binormals;
  74576. };
  74577. /**
  74578. * Returns an array populated with distances (float) of the i-th point from the first curve point.
  74579. * @returns an array populated with distances (float) of the i-th point from the first curve point.
  74580. */
  74581. Path3D.prototype.getDistances = function () {
  74582. return this._distances;
  74583. };
  74584. /**
  74585. * Forces the Path3D tangent, normal, binormal and distance recomputation.
  74586. * @param path path which all values are copied into the curves points
  74587. * @param firstNormal which should be projected onto the curve
  74588. * @returns the same object updated.
  74589. */
  74590. Path3D.prototype.update = function (path, firstNormal) {
  74591. if (firstNormal === void 0) { firstNormal = null; }
  74592. for (var p = 0; p < path.length; p++) {
  74593. this._curve[p].x = path[p].x;
  74594. this._curve[p].y = path[p].y;
  74595. this._curve[p].z = path[p].z;
  74596. }
  74597. this._compute(firstNormal);
  74598. return this;
  74599. };
  74600. // private function compute() : computes tangents, normals and binormals
  74601. Path3D.prototype._compute = function (firstNormal) {
  74602. var l = this._curve.length;
  74603. // first and last tangents
  74604. this._tangents[0] = this._getFirstNonNullVector(0);
  74605. if (!this._raw) {
  74606. this._tangents[0].normalize();
  74607. }
  74608. this._tangents[l - 1] = this._curve[l - 1].subtract(this._curve[l - 2]);
  74609. if (!this._raw) {
  74610. this._tangents[l - 1].normalize();
  74611. }
  74612. // normals and binormals at first point : arbitrary vector with _normalVector()
  74613. var tg0 = this._tangents[0];
  74614. var pp0 = this._normalVector(tg0, firstNormal);
  74615. this._normals[0] = pp0;
  74616. if (!this._raw) {
  74617. this._normals[0].normalize();
  74618. }
  74619. this._binormals[0] = Vector3.Cross(tg0, this._normals[0]);
  74620. if (!this._raw) {
  74621. this._binormals[0].normalize();
  74622. }
  74623. this._distances[0] = 0.0;
  74624. // normals and binormals : next points
  74625. var prev; // previous vector (segment)
  74626. var cur; // current vector (segment)
  74627. var curTang; // current tangent
  74628. // previous normal
  74629. var prevBinor; // previous binormal
  74630. for (var i = 1; i < l; i++) {
  74631. // tangents
  74632. prev = this._getLastNonNullVector(i);
  74633. if (i < l - 1) {
  74634. cur = this._getFirstNonNullVector(i);
  74635. this._tangents[i] = prev.add(cur);
  74636. this._tangents[i].normalize();
  74637. }
  74638. this._distances[i] = this._distances[i - 1] + prev.length();
  74639. // normals and binormals
  74640. // http://www.cs.cmu.edu/afs/andrew/scs/cs/15-462/web/old/asst2camera.html
  74641. curTang = this._tangents[i];
  74642. prevBinor = this._binormals[i - 1];
  74643. this._normals[i] = Vector3.Cross(prevBinor, curTang);
  74644. if (!this._raw) {
  74645. this._normals[i].normalize();
  74646. }
  74647. this._binormals[i] = Vector3.Cross(curTang, this._normals[i]);
  74648. if (!this._raw) {
  74649. this._binormals[i].normalize();
  74650. }
  74651. }
  74652. };
  74653. // private function getFirstNonNullVector(index)
  74654. // returns the first non null vector from index : curve[index + N].subtract(curve[index])
  74655. Path3D.prototype._getFirstNonNullVector = function (index) {
  74656. var i = 1;
  74657. var nNVector = this._curve[index + i].subtract(this._curve[index]);
  74658. while (nNVector.length() === 0 && index + i + 1 < this._curve.length) {
  74659. i++;
  74660. nNVector = this._curve[index + i].subtract(this._curve[index]);
  74661. }
  74662. return nNVector;
  74663. };
  74664. // private function getLastNonNullVector(index)
  74665. // returns the last non null vector from index : curve[index].subtract(curve[index - N])
  74666. Path3D.prototype._getLastNonNullVector = function (index) {
  74667. var i = 1;
  74668. var nLVector = this._curve[index].subtract(this._curve[index - i]);
  74669. while (nLVector.length() === 0 && index > i + 1) {
  74670. i++;
  74671. nLVector = this._curve[index].subtract(this._curve[index - i]);
  74672. }
  74673. return nLVector;
  74674. };
  74675. // private function normalVector(v0, vt, va) :
  74676. // returns an arbitrary point in the plane defined by the point v0 and the vector vt orthogonal to this plane
  74677. // if va is passed, it returns the va projection on the plane orthogonal to vt at the point v0
  74678. Path3D.prototype._normalVector = function (vt, va) {
  74679. var normal0;
  74680. var tgl = vt.length();
  74681. if (tgl === 0.0) {
  74682. tgl = 1.0;
  74683. }
  74684. if (va === undefined || va === null) {
  74685. var point;
  74686. if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.y) / tgl, 1.0, Epsilon)) { // search for a point in the plane
  74687. point = new Vector3(0.0, -1.0, 0.0);
  74688. }
  74689. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.x) / tgl, 1.0, Epsilon)) {
  74690. point = new Vector3(1.0, 0.0, 0.0);
  74691. }
  74692. else if (!_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].WithinEpsilon(Math.abs(vt.z) / tgl, 1.0, Epsilon)) {
  74693. point = new Vector3(0.0, 0.0, 1.0);
  74694. }
  74695. else {
  74696. point = Vector3.Zero();
  74697. }
  74698. normal0 = Vector3.Cross(vt, point);
  74699. }
  74700. else {
  74701. normal0 = Vector3.Cross(vt, va);
  74702. Vector3.CrossToRef(normal0, vt, normal0);
  74703. }
  74704. normal0.normalize();
  74705. return normal0;
  74706. };
  74707. return Path3D;
  74708. }());
  74709. /**
  74710. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74711. * A Curve3 is designed from a series of successive Vector3.
  74712. * @see https://doc.babylonjs.com/how_to/how_to_use_curve3
  74713. */
  74714. var Curve3 = /** @class */ (function () {
  74715. /**
  74716. * A Curve3 object is a logical object, so not a mesh, to handle curves in the 3D geometric space.
  74717. * A Curve3 is designed from a series of successive Vector3.
  74718. * Tuto : https://doc.babylonjs.com/how_to/how_to_use_curve3#curve3-object
  74719. * @param points points which make up the curve
  74720. */
  74721. function Curve3(points) {
  74722. this._length = 0.0;
  74723. this._points = points;
  74724. this._length = this._computeLength(points);
  74725. }
  74726. /**
  74727. * Returns a Curve3 object along a Quadratic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#quadratic-bezier-curve
  74728. * @param v0 (Vector3) the origin point of the Quadratic Bezier
  74729. * @param v1 (Vector3) the control point
  74730. * @param v2 (Vector3) the end point of the Quadratic Bezier
  74731. * @param nbPoints (integer) the wanted number of points in the curve
  74732. * @returns the created Curve3
  74733. */
  74734. Curve3.CreateQuadraticBezier = function (v0, v1, v2, nbPoints) {
  74735. nbPoints = nbPoints > 2 ? nbPoints : 3;
  74736. var bez = new Array();
  74737. var equation = function (t, val0, val1, val2) {
  74738. var res = (1.0 - t) * (1.0 - t) * val0 + 2.0 * t * (1.0 - t) * val1 + t * t * val2;
  74739. return res;
  74740. };
  74741. for (var i = 0; i <= nbPoints; i++) {
  74742. 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)));
  74743. }
  74744. return new Curve3(bez);
  74745. };
  74746. /**
  74747. * Returns a Curve3 object along a Cubic Bezier curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#cubic-bezier-curve
  74748. * @param v0 (Vector3) the origin point of the Cubic Bezier
  74749. * @param v1 (Vector3) the first control point
  74750. * @param v2 (Vector3) the second control point
  74751. * @param v3 (Vector3) the end point of the Cubic Bezier
  74752. * @param nbPoints (integer) the wanted number of points in the curve
  74753. * @returns the created Curve3
  74754. */
  74755. Curve3.CreateCubicBezier = function (v0, v1, v2, v3, nbPoints) {
  74756. nbPoints = nbPoints > 3 ? nbPoints : 4;
  74757. var bez = new Array();
  74758. var equation = function (t, val0, val1, val2, val3) {
  74759. 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;
  74760. return res;
  74761. };
  74762. for (var i = 0; i <= nbPoints; i++) {
  74763. 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)));
  74764. }
  74765. return new Curve3(bez);
  74766. };
  74767. /**
  74768. * Returns a Curve3 object along a Hermite Spline curve : https://doc.babylonjs.com/how_to/how_to_use_curve3#hermite-spline
  74769. * @param p1 (Vector3) the origin point of the Hermite Spline
  74770. * @param t1 (Vector3) the tangent vector at the origin point
  74771. * @param p2 (Vector3) the end point of the Hermite Spline
  74772. * @param t2 (Vector3) the tangent vector at the end point
  74773. * @param nbPoints (integer) the wanted number of points in the curve
  74774. * @returns the created Curve3
  74775. */
  74776. Curve3.CreateHermiteSpline = function (p1, t1, p2, t2, nbPoints) {
  74777. var hermite = new Array();
  74778. var step = 1.0 / nbPoints;
  74779. for (var i = 0; i <= nbPoints; i++) {
  74780. hermite.push(Vector3.Hermite(p1, t1, p2, t2, i * step));
  74781. }
  74782. return new Curve3(hermite);
  74783. };
  74784. /**
  74785. * Returns a Curve3 object along a CatmullRom Spline curve :
  74786. * @param points (array of Vector3) the points the spline must pass through. At least, four points required
  74787. * @param nbPoints (integer) the wanted number of points between each curve control points
  74788. * @param closed (boolean) optional with default false, when true forms a closed loop from the points
  74789. * @returns the created Curve3
  74790. */
  74791. Curve3.CreateCatmullRomSpline = function (points, nbPoints, closed) {
  74792. var catmullRom = new Array();
  74793. var step = 1.0 / nbPoints;
  74794. var amount = 0.0;
  74795. if (closed) {
  74796. var pointsCount = points.length;
  74797. for (var i = 0; i < pointsCount; i++) {
  74798. amount = 0;
  74799. for (var c = 0; c < nbPoints; c++) {
  74800. catmullRom.push(Vector3.CatmullRom(points[i % pointsCount], points[(i + 1) % pointsCount], points[(i + 2) % pointsCount], points[(i + 3) % pointsCount], amount));
  74801. amount += step;
  74802. }
  74803. }
  74804. catmullRom.push(catmullRom[0]);
  74805. }
  74806. else {
  74807. var totalPoints = new Array();
  74808. totalPoints.push(points[0].clone());
  74809. Array.prototype.push.apply(totalPoints, points);
  74810. totalPoints.push(points[points.length - 1].clone());
  74811. for (var i = 0; i < totalPoints.length - 3; i++) {
  74812. amount = 0;
  74813. for (var c = 0; c < nbPoints; c++) {
  74814. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74815. amount += step;
  74816. }
  74817. }
  74818. i--;
  74819. catmullRom.push(Vector3.CatmullRom(totalPoints[i], totalPoints[i + 1], totalPoints[i + 2], totalPoints[i + 3], amount));
  74820. }
  74821. return new Curve3(catmullRom);
  74822. };
  74823. /**
  74824. * @returns the Curve3 stored array of successive Vector3
  74825. */
  74826. Curve3.prototype.getPoints = function () {
  74827. return this._points;
  74828. };
  74829. /**
  74830. * @returns the computed length (float) of the curve.
  74831. */
  74832. Curve3.prototype.length = function () {
  74833. return this._length;
  74834. };
  74835. /**
  74836. * Returns a new instance of Curve3 object : var curve = curveA.continue(curveB);
  74837. * This new Curve3 is built by translating and sticking the curveB at the end of the curveA.
  74838. * curveA and curveB keep unchanged.
  74839. * @param curve the curve to continue from this curve
  74840. * @returns the newly constructed curve
  74841. */
  74842. Curve3.prototype.continue = function (curve) {
  74843. var lastPoint = this._points[this._points.length - 1];
  74844. var continuedPoints = this._points.slice();
  74845. var curvePoints = curve.getPoints();
  74846. for (var i = 1; i < curvePoints.length; i++) {
  74847. continuedPoints.push(curvePoints[i].subtract(curvePoints[0]).add(lastPoint));
  74848. }
  74849. var continuedCurve = new Curve3(continuedPoints);
  74850. return continuedCurve;
  74851. };
  74852. Curve3.prototype._computeLength = function (path) {
  74853. var l = 0;
  74854. for (var i = 1; i < path.length; i++) {
  74855. l += (path[i].subtract(path[i - 1])).length();
  74856. }
  74857. return l;
  74858. };
  74859. return Curve3;
  74860. }());
  74861. // Vertex formats
  74862. /**
  74863. * Contains position and normal vectors for a vertex
  74864. */
  74865. var PositionNormalVertex = /** @class */ (function () {
  74866. /**
  74867. * Creates a PositionNormalVertex
  74868. * @param position the position of the vertex (defaut: 0,0,0)
  74869. * @param normal the normal of the vertex (defaut: 0,1,0)
  74870. */
  74871. function PositionNormalVertex(
  74872. /** the position of the vertex (defaut: 0,0,0) */
  74873. position,
  74874. /** the normal of the vertex (defaut: 0,1,0) */
  74875. normal) {
  74876. if (position === void 0) { position = Vector3.Zero(); }
  74877. if (normal === void 0) { normal = Vector3.Up(); }
  74878. this.position = position;
  74879. this.normal = normal;
  74880. }
  74881. /**
  74882. * Clones the PositionNormalVertex
  74883. * @returns the cloned PositionNormalVertex
  74884. */
  74885. PositionNormalVertex.prototype.clone = function () {
  74886. return new PositionNormalVertex(this.position.clone(), this.normal.clone());
  74887. };
  74888. return PositionNormalVertex;
  74889. }());
  74890. /**
  74891. * Contains position, normal and uv vectors for a vertex
  74892. */
  74893. var PositionNormalTextureVertex = /** @class */ (function () {
  74894. /**
  74895. * Creates a PositionNormalTextureVertex
  74896. * @param position the position of the vertex (defaut: 0,0,0)
  74897. * @param normal the normal of the vertex (defaut: 0,1,0)
  74898. * @param uv the uv of the vertex (default: 0,0)
  74899. */
  74900. function PositionNormalTextureVertex(
  74901. /** the position of the vertex (defaut: 0,0,0) */
  74902. position,
  74903. /** the normal of the vertex (defaut: 0,1,0) */
  74904. normal,
  74905. /** the uv of the vertex (default: 0,0) */
  74906. uv) {
  74907. if (position === void 0) { position = Vector3.Zero(); }
  74908. if (normal === void 0) { normal = Vector3.Up(); }
  74909. if (uv === void 0) { uv = Vector2.Zero(); }
  74910. this.position = position;
  74911. this.normal = normal;
  74912. this.uv = uv;
  74913. }
  74914. /**
  74915. * Clones the PositionNormalTextureVertex
  74916. * @returns the cloned PositionNormalTextureVertex
  74917. */
  74918. PositionNormalTextureVertex.prototype.clone = function () {
  74919. return new PositionNormalTextureVertex(this.position.clone(), this.normal.clone(), this.uv.clone());
  74920. };
  74921. return PositionNormalTextureVertex;
  74922. }());
  74923. // Temporary pre-allocated objects for engine internal use
  74924. // usage in any internal function :
  74925. // var tmp = Tmp.Vector3[0]; <= gets access to the first pre-created Vector3
  74926. // There's a Tmp array per object type : int, float, Vector2, Vector3, Vector4, Quaternion, Matrix
  74927. /**
  74928. * @hidden
  74929. */
  74930. var Tmp = /** @class */ (function () {
  74931. function Tmp() {
  74932. }
  74933. Tmp.Color3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Color3.Black);
  74934. Tmp.Color4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, function () { return new Color4(0, 0, 0, 0); });
  74935. Tmp.Vector2 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector2.Zero); // 3 temp Vector2 at once should be enough
  74936. Tmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(13, Vector3.Zero); // 13 temp Vector3 at once should be enough
  74937. Tmp.Vector4 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Vector4.Zero); // 3 temp Vector4 at once should be enough
  74938. Tmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Quaternion.Zero); // 2 temp Quaternion at once should be enough
  74939. Tmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(8, Matrix.Identity); // 8 temp Matrices at once should be enough
  74940. return Tmp;
  74941. }());
  74942. /**
  74943. * @hidden
  74944. * Same as Tmp but not exported to keep it only for math functions to avoid conflicts
  74945. */
  74946. var MathTmp = /** @class */ (function () {
  74947. function MathTmp() {
  74948. }
  74949. MathTmp.Vector3 = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(6, Vector3.Zero);
  74950. MathTmp.Matrix = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(2, Matrix.Identity);
  74951. MathTmp.Quaternion = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_0__["ArrayTools"].BuildArray(3, Quaternion.Zero);
  74952. return MathTmp;
  74953. }());
  74954. /***/ }),
  74955. /***/ "./Maths/sphericalPolynomial.ts":
  74956. /*!**************************************!*\
  74957. !*** ./Maths/sphericalPolynomial.ts ***!
  74958. \**************************************/
  74959. /*! exports provided: SphericalPolynomial, SphericalHarmonics */
  74960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  74961. "use strict";
  74962. __webpack_require__.r(__webpack_exports__);
  74963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return SphericalPolynomial; });
  74964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return SphericalHarmonics; });
  74965. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  74966. /**
  74967. * Class representing spherical polynomial coefficients to the 3rd degree
  74968. */
  74969. var SphericalPolynomial = /** @class */ (function () {
  74970. function SphericalPolynomial() {
  74971. /**
  74972. * The x coefficients of the spherical polynomial
  74973. */
  74974. this.x = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74975. /**
  74976. * The y coefficients of the spherical polynomial
  74977. */
  74978. this.y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74979. /**
  74980. * The z coefficients of the spherical polynomial
  74981. */
  74982. this.z = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74983. /**
  74984. * The xx coefficients of the spherical polynomial
  74985. */
  74986. this.xx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74987. /**
  74988. * The yy coefficients of the spherical polynomial
  74989. */
  74990. this.yy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74991. /**
  74992. * The zz coefficients of the spherical polynomial
  74993. */
  74994. this.zz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74995. /**
  74996. * The xy coefficients of the spherical polynomial
  74997. */
  74998. this.xy = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  74999. /**
  75000. * The yz coefficients of the spherical polynomial
  75001. */
  75002. this.yz = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75003. /**
  75004. * The zx coefficients of the spherical polynomial
  75005. */
  75006. this.zx = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75007. }
  75008. /**
  75009. * Adds an ambient color to the spherical polynomial
  75010. * @param color the color to add
  75011. */
  75012. SphericalPolynomial.prototype.addAmbient = function (color) {
  75013. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  75014. this.xx = this.xx.add(colorVector);
  75015. this.yy = this.yy.add(colorVector);
  75016. this.zz = this.zz.add(colorVector);
  75017. };
  75018. /**
  75019. * Scales the spherical polynomial by the given amount
  75020. * @param scale the amount to scale
  75021. */
  75022. SphericalPolynomial.prototype.scale = function (scale) {
  75023. this.x = this.x.scale(scale);
  75024. this.y = this.y.scale(scale);
  75025. this.z = this.z.scale(scale);
  75026. this.xx = this.xx.scale(scale);
  75027. this.yy = this.yy.scale(scale);
  75028. this.zz = this.zz.scale(scale);
  75029. this.yz = this.yz.scale(scale);
  75030. this.zx = this.zx.scale(scale);
  75031. this.xy = this.xy.scale(scale);
  75032. };
  75033. /**
  75034. * Gets the spherical polynomial from harmonics
  75035. * @param harmonics the spherical harmonics
  75036. * @returns the spherical polynomial
  75037. */
  75038. SphericalPolynomial.FromHarmonics = function (harmonics) {
  75039. var result = new SphericalPolynomial();
  75040. result.x = harmonics.l11.scale(1.02333);
  75041. result.y = harmonics.l1_1.scale(1.02333);
  75042. result.z = harmonics.l10.scale(1.02333);
  75043. result.xx = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).add(harmonics.lL22.scale(0.429043));
  75044. result.yy = harmonics.l00.scale(0.886277).subtract(harmonics.l20.scale(0.247708)).subtract(harmonics.lL22.scale(0.429043));
  75045. result.zz = harmonics.l00.scale(0.886277).add(harmonics.l20.scale(0.495417));
  75046. result.yz = harmonics.l2_1.scale(0.858086);
  75047. result.zx = harmonics.l21.scale(0.858086);
  75048. result.xy = harmonics.l2_2.scale(0.858086);
  75049. result.scale(1.0 / Math.PI);
  75050. return result;
  75051. };
  75052. /**
  75053. * Constructs a spherical polynomial from an array.
  75054. * @param data defines the 9x3 coefficients (x, y, z, xx, yy, zz, yz, zx, xy)
  75055. * @returns the spherical polynomial
  75056. */
  75057. SphericalPolynomial.FromArray = function (data) {
  75058. var sp = new SphericalPolynomial();
  75059. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sp.x);
  75060. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sp.y);
  75061. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sp.z);
  75062. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sp.xx);
  75063. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sp.yy);
  75064. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sp.zz);
  75065. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sp.yz);
  75066. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sp.zx);
  75067. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sp.xy);
  75068. return sp;
  75069. };
  75070. return SphericalPolynomial;
  75071. }());
  75072. /**
  75073. * Class representing spherical harmonics coefficients to the 3rd degree
  75074. */
  75075. var SphericalHarmonics = /** @class */ (function () {
  75076. function SphericalHarmonics() {
  75077. /**
  75078. * The l0,0 coefficients of the spherical harmonics
  75079. */
  75080. this.l00 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75081. /**
  75082. * The l1,-1 coefficients of the spherical harmonics
  75083. */
  75084. this.l1_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75085. /**
  75086. * The l1,0 coefficients of the spherical harmonics
  75087. */
  75088. this.l10 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75089. /**
  75090. * The l1,1 coefficients of the spherical harmonics
  75091. */
  75092. this.l11 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75093. /**
  75094. * The l2,-2 coefficients of the spherical harmonics
  75095. */
  75096. this.l2_2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75097. /**
  75098. * The l2,-1 coefficients of the spherical harmonics
  75099. */
  75100. this.l2_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75101. /**
  75102. * The l2,0 coefficients of the spherical harmonics
  75103. */
  75104. this.l20 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75105. /**
  75106. * The l2,1 coefficients of the spherical harmonics
  75107. */
  75108. this.l21 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75109. /**
  75110. * The l2,2 coefficients of the spherical harmonics
  75111. */
  75112. this.lL22 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75113. }
  75114. /**
  75115. * Adds a light to the spherical harmonics
  75116. * @param direction the direction of the light
  75117. * @param color the color of the light
  75118. * @param deltaSolidAngle the delta solid angle of the light
  75119. */
  75120. SphericalHarmonics.prototype.addLight = function (direction, color, deltaSolidAngle) {
  75121. var colorVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](color.r, color.g, color.b);
  75122. var c = colorVector.scale(deltaSolidAngle);
  75123. this.l00 = this.l00.add(c.scale(0.282095));
  75124. this.l1_1 = this.l1_1.add(c.scale(0.488603 * direction.y));
  75125. this.l10 = this.l10.add(c.scale(0.488603 * direction.z));
  75126. this.l11 = this.l11.add(c.scale(0.488603 * direction.x));
  75127. this.l2_2 = this.l2_2.add(c.scale(1.092548 * direction.x * direction.y));
  75128. this.l2_1 = this.l2_1.add(c.scale(1.092548 * direction.y * direction.z));
  75129. this.l21 = this.l21.add(c.scale(1.092548 * direction.x * direction.z));
  75130. this.l20 = this.l20.add(c.scale(0.315392 * (3.0 * direction.z * direction.z - 1.0)));
  75131. this.lL22 = this.lL22.add(c.scale(0.546274 * (direction.x * direction.x - direction.y * direction.y)));
  75132. };
  75133. /**
  75134. * Scales the spherical harmonics by the given amount
  75135. * @param scale the amount to scale
  75136. */
  75137. SphericalHarmonics.prototype.scale = function (scale) {
  75138. this.l00 = this.l00.scale(scale);
  75139. this.l1_1 = this.l1_1.scale(scale);
  75140. this.l10 = this.l10.scale(scale);
  75141. this.l11 = this.l11.scale(scale);
  75142. this.l2_2 = this.l2_2.scale(scale);
  75143. this.l2_1 = this.l2_1.scale(scale);
  75144. this.l20 = this.l20.scale(scale);
  75145. this.l21 = this.l21.scale(scale);
  75146. this.lL22 = this.lL22.scale(scale);
  75147. };
  75148. /**
  75149. * Convert from incident radiance (Li) to irradiance (E) by applying convolution with the cosine-weighted hemisphere.
  75150. *
  75151. * ```
  75152. * E_lm = A_l * L_lm
  75153. * ```
  75154. *
  75155. * In spherical harmonics this convolution amounts to scaling factors for each frequency band.
  75156. * This corresponds to equation 5 in "An Efficient Representation for Irradiance Environment Maps", where
  75157. * the scaling factors are given in equation 9.
  75158. */
  75159. SphericalHarmonics.prototype.convertIncidentRadianceToIrradiance = function () {
  75160. // Constant (Band 0)
  75161. this.l00 = this.l00.scale(3.141593);
  75162. // Linear (Band 1)
  75163. this.l1_1 = this.l1_1.scale(2.094395);
  75164. this.l10 = this.l10.scale(2.094395);
  75165. this.l11 = this.l11.scale(2.094395);
  75166. // Quadratic (Band 2)
  75167. this.l2_2 = this.l2_2.scale(0.785398);
  75168. this.l2_1 = this.l2_1.scale(0.785398);
  75169. this.l20 = this.l20.scale(0.785398);
  75170. this.l21 = this.l21.scale(0.785398);
  75171. this.lL22 = this.lL22.scale(0.785398);
  75172. };
  75173. /**
  75174. * Convert from irradiance to outgoing radiance for Lambertian BDRF, suitable for efficient shader evaluation.
  75175. *
  75176. * ```
  75177. * L = (1/pi) * E * rho
  75178. * ```
  75179. *
  75180. * This is done by an additional scale by 1/pi, so is a fairly trivial operation but important conceptually.
  75181. */
  75182. SphericalHarmonics.prototype.convertIrradianceToLambertianRadiance = function () {
  75183. this.scale(1.0 / Math.PI);
  75184. // The resultant SH now represents outgoing radiance, so includes the Lambert 1/pi normalisation factor but without albedo (rho) applied
  75185. // (The pixel shader must apply albedo after texture fetches, etc).
  75186. };
  75187. /**
  75188. * Gets the spherical harmonics from polynomial
  75189. * @param polynomial the spherical polynomial
  75190. * @returns the spherical harmonics
  75191. */
  75192. SphericalHarmonics.FromPolynomial = function (polynomial) {
  75193. var result = new SphericalHarmonics();
  75194. result.l00 = polynomial.xx.scale(0.376127).add(polynomial.yy.scale(0.376127)).add(polynomial.zz.scale(0.376126));
  75195. result.l1_1 = polynomial.y.scale(0.977204);
  75196. result.l10 = polynomial.z.scale(0.977204);
  75197. result.l11 = polynomial.x.scale(0.977204);
  75198. result.l2_2 = polynomial.xy.scale(1.16538);
  75199. result.l2_1 = polynomial.yz.scale(1.16538);
  75200. result.l20 = polynomial.zz.scale(1.34567).subtract(polynomial.xx.scale(0.672834)).subtract(polynomial.yy.scale(0.672834));
  75201. result.l21 = polynomial.zx.scale(1.16538);
  75202. result.lL22 = polynomial.xx.scale(1.16538).subtract(polynomial.yy.scale(1.16538));
  75203. result.scale(Math.PI);
  75204. return result;
  75205. };
  75206. /**
  75207. * Constructs a spherical harmonics from an array.
  75208. * @param data defines the 9x3 coefficients (l00, l1-1, l10, l11, l2-2, l2-1, l20, l21, l22)
  75209. * @returns the spherical harmonics
  75210. */
  75211. SphericalHarmonics.FromArray = function (data) {
  75212. var sh = new SphericalHarmonics();
  75213. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[0], 0, sh.l00);
  75214. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[1], 0, sh.l1_1);
  75215. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[2], 0, sh.l10);
  75216. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[3], 0, sh.l11);
  75217. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[4], 0, sh.l2_2);
  75218. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[5], 0, sh.l2_1);
  75219. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[6], 0, sh.l20);
  75220. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[7], 0, sh.l21);
  75221. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(data[8], 0, sh.lL22);
  75222. return sh;
  75223. };
  75224. return SphericalHarmonics;
  75225. }());
  75226. /***/ }),
  75227. /***/ "./Meshes/Builders/boxBuilder.ts":
  75228. /*!***************************************!*\
  75229. !*** ./Meshes/Builders/boxBuilder.ts ***!
  75230. \***************************************/
  75231. /*! exports provided: BoxBuilder */
  75232. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75233. "use strict";
  75234. __webpack_require__.r(__webpack_exports__);
  75235. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return BoxBuilder; });
  75236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75237. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75238. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75239. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox = function (options) {
  75240. var normalsSource = [
  75241. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1),
  75242. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1),
  75243. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0),
  75244. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0),
  75245. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0),
  75246. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0)
  75247. ];
  75248. var indices = [];
  75249. var positions = [];
  75250. var normals = [];
  75251. var uvs = [];
  75252. var width = options.width || options.size || 1;
  75253. var height = options.height || options.size || 1;
  75254. var depth = options.depth || options.size || 1;
  75255. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75256. var faceUV = options.faceUV || new Array(6);
  75257. var faceColors = options.faceColors;
  75258. var colors = [];
  75259. // default face colors and UV if undefined
  75260. for (var f = 0; f < 6; f++) {
  75261. if (faceUV[f] === undefined) {
  75262. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  75263. }
  75264. if (faceColors && faceColors[f] === undefined) {
  75265. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  75266. }
  75267. }
  75268. var scaleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](width / 2, height / 2, depth / 2);
  75269. // Create each face in turn.
  75270. for (var index = 0; index < normalsSource.length; index++) {
  75271. var normal = normalsSource[index];
  75272. // Get two vectors perpendicular to the face normal and to each other.
  75273. var side1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normal.y, normal.z, normal.x);
  75274. var side2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(normal, side1);
  75275. // Six indices (two triangles) per face.
  75276. var verticesLength = positions.length / 3;
  75277. indices.push(verticesLength);
  75278. indices.push(verticesLength + 1);
  75279. indices.push(verticesLength + 2);
  75280. indices.push(verticesLength);
  75281. indices.push(verticesLength + 2);
  75282. indices.push(verticesLength + 3);
  75283. // Four vertices per face.
  75284. var vertex = normal.subtract(side1).subtract(side2).multiply(scaleVector);
  75285. positions.push(vertex.x, vertex.y, vertex.z);
  75286. normals.push(normal.x, normal.y, normal.z);
  75287. uvs.push(faceUV[index].z, faceUV[index].w);
  75288. if (faceColors) {
  75289. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  75290. }
  75291. vertex = normal.subtract(side1).add(side2).multiply(scaleVector);
  75292. positions.push(vertex.x, vertex.y, vertex.z);
  75293. normals.push(normal.x, normal.y, normal.z);
  75294. uvs.push(faceUV[index].x, faceUV[index].w);
  75295. if (faceColors) {
  75296. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  75297. }
  75298. vertex = normal.add(side1).add(side2).multiply(scaleVector);
  75299. positions.push(vertex.x, vertex.y, vertex.z);
  75300. normals.push(normal.x, normal.y, normal.z);
  75301. uvs.push(faceUV[index].x, faceUV[index].y);
  75302. if (faceColors) {
  75303. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  75304. }
  75305. vertex = normal.add(side1).subtract(side2).multiply(scaleVector);
  75306. positions.push(vertex.x, vertex.y, vertex.z);
  75307. normals.push(normal.x, normal.y, normal.z);
  75308. uvs.push(faceUV[index].z, faceUV[index].y);
  75309. if (faceColors) {
  75310. colors.push(faceColors[index].r, faceColors[index].g, faceColors[index].b, faceColors[index].a);
  75311. }
  75312. }
  75313. // sides
  75314. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75315. // Result
  75316. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75317. vertexData.indices = indices;
  75318. vertexData.positions = positions;
  75319. vertexData.normals = normals;
  75320. vertexData.uvs = uvs;
  75321. if (faceColors) {
  75322. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  75323. vertexData.colors = totalColors;
  75324. }
  75325. return vertexData;
  75326. };
  75327. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateBox = function (name, size, scene, updatable, sideOrientation) {
  75328. if (scene === void 0) { scene = null; }
  75329. var options = {
  75330. size: size,
  75331. sideOrientation: sideOrientation,
  75332. updatable: updatable
  75333. };
  75334. return BoxBuilder.CreateBox(name, options, scene);
  75335. };
  75336. /**
  75337. * Class containing static functions to help procedurally build meshes
  75338. */
  75339. var BoxBuilder = /** @class */ (function () {
  75340. function BoxBuilder() {
  75341. }
  75342. /**
  75343. * Creates a box mesh
  75344. * * The parameter `size` sets the size (float) of each box side (default 1)
  75345. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  75346. * * 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)
  75347. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  75348. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75349. * * 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
  75350. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75351. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  75352. * @param name defines the name of the mesh
  75353. * @param options defines the options used to create the mesh
  75354. * @param scene defines the hosting scene
  75355. * @returns the box mesh
  75356. */
  75357. BoxBuilder.CreateBox = function (name, options, scene) {
  75358. if (scene === void 0) { scene = null; }
  75359. var box = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75360. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75361. box._originalBuilderSideOrientation = options.sideOrientation;
  75362. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateBox(options);
  75363. vertexData.applyToMesh(box, options.updatable);
  75364. return box;
  75365. };
  75366. return BoxBuilder;
  75367. }());
  75368. /***/ }),
  75369. /***/ "./Meshes/Builders/cylinderBuilder.ts":
  75370. /*!********************************************!*\
  75371. !*** ./Meshes/Builders/cylinderBuilder.ts ***!
  75372. \********************************************/
  75373. /*! exports provided: CylinderBuilder */
  75374. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75375. "use strict";
  75376. __webpack_require__.r(__webpack_exports__);
  75377. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return CylinderBuilder; });
  75378. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75379. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75380. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75381. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  75382. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder = function (options) {
  75383. var height = options.height || 2;
  75384. var diameterTop = (options.diameterTop === 0) ? 0 : options.diameterTop || options.diameter || 1;
  75385. var diameterBottom = (options.diameterBottom === 0) ? 0 : options.diameterBottom || options.diameter || 1;
  75386. var tessellation = options.tessellation || 24;
  75387. var subdivisions = options.subdivisions || 1;
  75388. var hasRings = options.hasRings ? true : false;
  75389. var enclose = options.enclose ? true : false;
  75390. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75391. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  75392. var faceUV = options.faceUV || new Array(3);
  75393. var faceColors = options.faceColors;
  75394. // default face colors and UV if undefined
  75395. var quadNb = (arc !== 1 && enclose) ? 2 : 0;
  75396. var ringNb = (hasRings) ? subdivisions : 1;
  75397. var surfaceNb = 2 + (1 + quadNb) * ringNb;
  75398. var f;
  75399. for (f = 0; f < surfaceNb; f++) {
  75400. if (faceColors && faceColors[f] === undefined) {
  75401. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  75402. }
  75403. }
  75404. for (f = 0; f < surfaceNb; f++) {
  75405. if (faceUV && faceUV[f] === undefined) {
  75406. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  75407. }
  75408. }
  75409. var indices = new Array();
  75410. var positions = new Array();
  75411. var normals = new Array();
  75412. var uvs = new Array();
  75413. var colors = new Array();
  75414. var angle_step = Math.PI * 2 * arc / tessellation;
  75415. var angle;
  75416. var h;
  75417. var radius;
  75418. var tan = (diameterBottom - diameterTop) / 2 / height;
  75419. var ringVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75420. var ringNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75421. var ringFirstVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75422. var ringFirstNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75423. var quadNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75424. var Y = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Y;
  75425. // positions, normals, uvs
  75426. var i;
  75427. var j;
  75428. var r;
  75429. var ringIdx = 1;
  75430. var s = 1; // surface index
  75431. var cs = 0;
  75432. var v = 0;
  75433. for (i = 0; i <= subdivisions; i++) {
  75434. h = i / subdivisions;
  75435. radius = (h * (diameterTop - diameterBottom) + diameterBottom) / 2;
  75436. ringIdx = (hasRings && i !== 0 && i !== subdivisions) ? 2 : 1;
  75437. for (r = 0; r < ringIdx; r++) {
  75438. if (hasRings) {
  75439. s += r;
  75440. }
  75441. if (enclose) {
  75442. s += 2 * r;
  75443. }
  75444. for (j = 0; j <= tessellation; j++) {
  75445. angle = j * angle_step;
  75446. // position
  75447. ringVertex.x = Math.cos(-angle) * radius;
  75448. ringVertex.y = -height / 2 + h * height;
  75449. ringVertex.z = Math.sin(-angle) * radius;
  75450. // normal
  75451. if (diameterTop === 0 && i === subdivisions) {
  75452. // if no top cap, reuse former normals
  75453. ringNormal.x = normals[normals.length - (tessellation + 1) * 3];
  75454. ringNormal.y = normals[normals.length - (tessellation + 1) * 3 + 1];
  75455. ringNormal.z = normals[normals.length - (tessellation + 1) * 3 + 2];
  75456. }
  75457. else {
  75458. ringNormal.x = ringVertex.x;
  75459. ringNormal.z = ringVertex.z;
  75460. ringNormal.y = Math.sqrt(ringNormal.x * ringNormal.x + ringNormal.z * ringNormal.z) * tan;
  75461. ringNormal.normalize();
  75462. }
  75463. // keep first ring vertex values for enclose
  75464. if (j === 0) {
  75465. ringFirstVertex.copyFrom(ringVertex);
  75466. ringFirstNormal.copyFrom(ringNormal);
  75467. }
  75468. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75469. normals.push(ringNormal.x, ringNormal.y, ringNormal.z);
  75470. if (hasRings) {
  75471. v = (cs !== s) ? faceUV[s].y : faceUV[s].w;
  75472. }
  75473. else {
  75474. v = faceUV[s].y + (faceUV[s].w - faceUV[s].y) * h;
  75475. }
  75476. uvs.push(faceUV[s].x + (faceUV[s].z - faceUV[s].x) * j / tessellation, v);
  75477. if (faceColors) {
  75478. colors.push(faceColors[s].r, faceColors[s].g, faceColors[s].b, faceColors[s].a);
  75479. }
  75480. }
  75481. // if enclose, add four vertices and their dedicated normals
  75482. if (arc !== 1 && enclose) {
  75483. positions.push(ringVertex.x, ringVertex.y, ringVertex.z);
  75484. positions.push(0, ringVertex.y, 0);
  75485. positions.push(0, ringVertex.y, 0);
  75486. positions.push(ringFirstVertex.x, ringFirstVertex.y, ringFirstVertex.z);
  75487. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(Y, ringNormal, quadNormal);
  75488. quadNormal.normalize();
  75489. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75490. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(ringFirstNormal, Y, quadNormal);
  75491. quadNormal.normalize();
  75492. normals.push(quadNormal.x, quadNormal.y, quadNormal.z, quadNormal.x, quadNormal.y, quadNormal.z);
  75493. if (hasRings) {
  75494. v = (cs !== s) ? faceUV[s + 1].y : faceUV[s + 1].w;
  75495. }
  75496. else {
  75497. v = faceUV[s + 1].y + (faceUV[s + 1].w - faceUV[s + 1].y) * h;
  75498. }
  75499. uvs.push(faceUV[s + 1].x, v);
  75500. uvs.push(faceUV[s + 1].z, v);
  75501. if (hasRings) {
  75502. v = (cs !== s) ? faceUV[s + 2].y : faceUV[s + 2].w;
  75503. }
  75504. else {
  75505. v = faceUV[s + 2].y + (faceUV[s + 2].w - faceUV[s + 2].y) * h;
  75506. }
  75507. uvs.push(faceUV[s + 2].x, v);
  75508. uvs.push(faceUV[s + 2].z, v);
  75509. if (faceColors) {
  75510. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75511. colors.push(faceColors[s + 1].r, faceColors[s + 1].g, faceColors[s + 1].b, faceColors[s + 1].a);
  75512. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75513. colors.push(faceColors[s + 2].r, faceColors[s + 2].g, faceColors[s + 2].b, faceColors[s + 2].a);
  75514. }
  75515. }
  75516. if (cs !== s) {
  75517. cs = s;
  75518. }
  75519. }
  75520. }
  75521. // indices
  75522. var e = (arc !== 1 && enclose) ? tessellation + 4 : tessellation; // correction of number of iteration if enclose
  75523. var s;
  75524. i = 0;
  75525. for (s = 0; s < subdivisions; s++) {
  75526. var i0 = 0;
  75527. var i1 = 0;
  75528. var i2 = 0;
  75529. var i3 = 0;
  75530. for (j = 0; j < tessellation; j++) {
  75531. i0 = i * (e + 1) + j;
  75532. i1 = (i + 1) * (e + 1) + j;
  75533. i2 = i * (e + 1) + (j + 1);
  75534. i3 = (i + 1) * (e + 1) + (j + 1);
  75535. indices.push(i0, i1, i2);
  75536. indices.push(i3, i2, i1);
  75537. }
  75538. if (arc !== 1 && enclose) { // if enclose, add two quads
  75539. indices.push(i0 + 2, i1 + 2, i2 + 2);
  75540. indices.push(i3 + 2, i2 + 2, i1 + 2);
  75541. indices.push(i0 + 4, i1 + 4, i2 + 4);
  75542. indices.push(i3 + 4, i2 + 4, i1 + 4);
  75543. }
  75544. i = (hasRings) ? (i + 2) : (i + 1);
  75545. }
  75546. // Caps
  75547. var createCylinderCap = function (isTop) {
  75548. var radius = isTop ? diameterTop / 2 : diameterBottom / 2;
  75549. if (radius === 0) {
  75550. return;
  75551. }
  75552. // Cap positions, normals & uvs
  75553. var angle;
  75554. var circleVector;
  75555. var i;
  75556. var u = (isTop) ? faceUV[surfaceNb - 1] : faceUV[0];
  75557. var c = null;
  75558. if (faceColors) {
  75559. c = (isTop) ? faceColors[surfaceNb - 1] : faceColors[0];
  75560. }
  75561. // cap center
  75562. var vbase = positions.length / 3;
  75563. var offset = isTop ? height / 2 : -height / 2;
  75564. var center = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, offset, 0);
  75565. positions.push(center.x, center.y, center.z);
  75566. normals.push(0, isTop ? 1 : -1, 0);
  75567. uvs.push(u.x + (u.z - u.x) * 0.5, u.y + (u.w - u.y) * 0.5);
  75568. if (c) {
  75569. colors.push(c.r, c.g, c.b, c.a);
  75570. }
  75571. var textureScale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0.5, 0.5);
  75572. for (i = 0; i <= tessellation; i++) {
  75573. angle = Math.PI * 2 * i * arc / tessellation;
  75574. var cos = Math.cos(-angle);
  75575. var sin = Math.sin(-angle);
  75576. circleVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](cos * radius, offset, sin * radius);
  75577. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](cos * textureScale.x + 0.5, sin * textureScale.y + 0.5);
  75578. positions.push(circleVector.x, circleVector.y, circleVector.z);
  75579. normals.push(0, isTop ? 1 : -1, 0);
  75580. uvs.push(u.x + (u.z - u.x) * textureCoordinate.x, u.y + (u.w - u.y) * textureCoordinate.y);
  75581. if (c) {
  75582. colors.push(c.r, c.g, c.b, c.a);
  75583. }
  75584. }
  75585. // Cap indices
  75586. for (i = 0; i < tessellation; i++) {
  75587. if (!isTop) {
  75588. indices.push(vbase);
  75589. indices.push(vbase + (i + 1));
  75590. indices.push(vbase + (i + 2));
  75591. }
  75592. else {
  75593. indices.push(vbase);
  75594. indices.push(vbase + (i + 2));
  75595. indices.push(vbase + (i + 1));
  75596. }
  75597. }
  75598. };
  75599. // add caps to geometry
  75600. createCylinderCap(false);
  75601. createCylinderCap(true);
  75602. // Sides
  75603. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75604. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  75605. vertexData.indices = indices;
  75606. vertexData.positions = positions;
  75607. vertexData.normals = normals;
  75608. vertexData.uvs = uvs;
  75609. if (faceColors) {
  75610. vertexData.colors = colors;
  75611. }
  75612. return vertexData;
  75613. };
  75614. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  75615. if (scene === undefined || !(scene instanceof _scene__WEBPACK_IMPORTED_MODULE_3__["Scene"])) {
  75616. if (scene !== undefined) {
  75617. sideOrientation = updatable || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DEFAULTSIDE;
  75618. updatable = scene;
  75619. }
  75620. scene = subdivisions;
  75621. subdivisions = 1;
  75622. }
  75623. var options = {
  75624. height: height,
  75625. diameterTop: diameterTop,
  75626. diameterBottom: diameterBottom,
  75627. tessellation: tessellation,
  75628. subdivisions: subdivisions,
  75629. sideOrientation: sideOrientation,
  75630. updatable: updatable
  75631. };
  75632. return CylinderBuilder.CreateCylinder(name, options, scene);
  75633. };
  75634. /**
  75635. * Class containing static functions to help procedurally build meshes
  75636. */
  75637. var CylinderBuilder = /** @class */ (function () {
  75638. function CylinderBuilder() {
  75639. }
  75640. /**
  75641. * Creates a cylinder or a cone mesh
  75642. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  75643. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  75644. * * 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.
  75645. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  75646. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  75647. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  75648. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  75649. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  75650. * * 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).
  75651. * * 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
  75652. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  75653. * * 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
  75654. * * 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.
  75655. * * If `enclose` is false, a ring surface is one element.
  75656. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  75657. * * 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
  75658. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75659. * * 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
  75660. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  75661. * @param name defines the name of the mesh
  75662. * @param options defines the options used to create the mesh
  75663. * @param scene defines the hosting scene
  75664. * @returns the cylinder mesh
  75665. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  75666. */
  75667. CylinderBuilder.CreateCylinder = function (name, options, scene) {
  75668. var cylinder = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  75669. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75670. cylinder._originalBuilderSideOrientation = options.sideOrientation;
  75671. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateCylinder(options);
  75672. vertexData.applyToMesh(cylinder, options.updatable);
  75673. return cylinder;
  75674. };
  75675. return CylinderBuilder;
  75676. }());
  75677. /***/ }),
  75678. /***/ "./Meshes/Builders/decalBuilder.ts":
  75679. /*!*****************************************!*\
  75680. !*** ./Meshes/Builders/decalBuilder.ts ***!
  75681. \*****************************************/
  75682. /*! exports provided: DecalBuilder */
  75683. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75684. "use strict";
  75685. __webpack_require__.r(__webpack_exports__);
  75686. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return DecalBuilder; });
  75687. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  75688. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75689. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  75690. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75691. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  75692. var options = {
  75693. position: position,
  75694. normal: normal,
  75695. size: size,
  75696. angle: angle
  75697. };
  75698. return DecalBuilder.CreateDecal(name, sourceMesh, options);
  75699. };
  75700. /**
  75701. * Class containing static functions to help procedurally build meshes
  75702. */
  75703. var DecalBuilder = /** @class */ (function () {
  75704. function DecalBuilder() {
  75705. }
  75706. /**
  75707. * Creates a decal mesh.
  75708. * 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
  75709. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  75710. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  75711. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  75712. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  75713. * @param name defines the name of the mesh
  75714. * @param sourceMesh defines the mesh where the decal must be applied
  75715. * @param options defines the options used to create the mesh
  75716. * @param scene defines the hosting scene
  75717. * @returns the decal mesh
  75718. * @see https://doc.babylonjs.com/how_to/decals
  75719. */
  75720. DecalBuilder.CreateDecal = function (name, sourceMesh, options) {
  75721. var indices = sourceMesh.getIndices();
  75722. var positions = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  75723. var normals = sourceMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  75724. var position = options.position || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  75725. var normal = options.normal || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up();
  75726. var size = options.size || _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  75727. var angle = options.angle || 0;
  75728. // Getting correct rotation
  75729. if (!normal) {
  75730. var target = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1);
  75731. var camera = sourceMesh.getScene().activeCamera;
  75732. var cameraWorldTarget = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(target, camera.getWorldMatrix());
  75733. normal = camera.globalPosition.subtract(cameraWorldTarget);
  75734. }
  75735. var yaw = -Math.atan2(normal.z, normal.x) - Math.PI / 2;
  75736. var len = Math.sqrt(normal.x * normal.x + normal.z * normal.z);
  75737. var pitch = Math.atan2(normal.y, len);
  75738. // Matrix
  75739. 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));
  75740. var inverseDecalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Invert(decalWorldMatrix);
  75741. var meshWorldMatrix = sourceMesh.getWorldMatrix();
  75742. var transformMatrix = meshWorldMatrix.multiply(inverseDecalWorldMatrix);
  75743. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  75744. vertexData.indices = [];
  75745. vertexData.positions = [];
  75746. vertexData.normals = [];
  75747. vertexData.uvs = [];
  75748. var currentVertexDataIndex = 0;
  75749. var extractDecalVector3 = function (indexId) {
  75750. var result = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["PositionNormalVertex"]();
  75751. if (!indices || !positions || !normals) {
  75752. return result;
  75753. }
  75754. var vertexId = indices[indexId];
  75755. result.position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](positions[vertexId * 3], positions[vertexId * 3 + 1], positions[vertexId * 3 + 2]);
  75756. // Send vector to decal local world
  75757. result.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(result.position, transformMatrix);
  75758. // Get normal
  75759. result.normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](normals[vertexId * 3], normals[vertexId * 3 + 1], normals[vertexId * 3 + 2]);
  75760. result.normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(result.normal, transformMatrix);
  75761. return result;
  75762. }; // Inspired by https://github.com/mrdoob/three.js/blob/eee231960882f6f3b6113405f524956145148146/examples/js/geometries/DecalGeometry.js
  75763. var clip = function (vertices, axis) {
  75764. if (vertices.length === 0) {
  75765. return vertices;
  75766. }
  75767. var clipSize = 0.5 * Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(size, axis));
  75768. var clipVertices = function (v0, v1) {
  75769. var clipFactor = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].GetClipFactor(v0.position, v1.position, axis, clipSize);
  75770. 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));
  75771. };
  75772. var result = new Array();
  75773. for (var index = 0; index < vertices.length; index += 3) {
  75774. var v1Out;
  75775. var v2Out;
  75776. var v3Out;
  75777. var total = 0;
  75778. var nV1 = null;
  75779. var nV2 = null;
  75780. var nV3 = null;
  75781. var nV4 = null;
  75782. var d1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index].position, axis) - clipSize;
  75783. var d2 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 1].position, axis) - clipSize;
  75784. var d3 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(vertices[index + 2].position, axis) - clipSize;
  75785. v1Out = d1 > 0;
  75786. v2Out = d2 > 0;
  75787. v3Out = d3 > 0;
  75788. total = (v1Out ? 1 : 0) + (v2Out ? 1 : 0) + (v3Out ? 1 : 0);
  75789. switch (total) {
  75790. case 0:
  75791. result.push(vertices[index]);
  75792. result.push(vertices[index + 1]);
  75793. result.push(vertices[index + 2]);
  75794. break;
  75795. case 1:
  75796. if (v1Out) {
  75797. nV1 = vertices[index + 1];
  75798. nV2 = vertices[index + 2];
  75799. nV3 = clipVertices(vertices[index], nV1);
  75800. nV4 = clipVertices(vertices[index], nV2);
  75801. }
  75802. if (v2Out) {
  75803. nV1 = vertices[index];
  75804. nV2 = vertices[index + 2];
  75805. nV3 = clipVertices(vertices[index + 1], nV1);
  75806. nV4 = clipVertices(vertices[index + 1], nV2);
  75807. result.push(nV3);
  75808. result.push(nV2.clone());
  75809. result.push(nV1.clone());
  75810. result.push(nV2.clone());
  75811. result.push(nV3.clone());
  75812. result.push(nV4);
  75813. break;
  75814. }
  75815. if (v3Out) {
  75816. nV1 = vertices[index];
  75817. nV2 = vertices[index + 1];
  75818. nV3 = clipVertices(vertices[index + 2], nV1);
  75819. nV4 = clipVertices(vertices[index + 2], nV2);
  75820. }
  75821. if (nV1 && nV2 && nV3 && nV4) {
  75822. result.push(nV1.clone());
  75823. result.push(nV2.clone());
  75824. result.push(nV3);
  75825. result.push(nV4);
  75826. result.push(nV3.clone());
  75827. result.push(nV2.clone());
  75828. }
  75829. break;
  75830. case 2:
  75831. if (!v1Out) {
  75832. nV1 = vertices[index].clone();
  75833. nV2 = clipVertices(nV1, vertices[index + 1]);
  75834. nV3 = clipVertices(nV1, vertices[index + 2]);
  75835. result.push(nV1);
  75836. result.push(nV2);
  75837. result.push(nV3);
  75838. }
  75839. if (!v2Out) {
  75840. nV1 = vertices[index + 1].clone();
  75841. nV2 = clipVertices(nV1, vertices[index + 2]);
  75842. nV3 = clipVertices(nV1, vertices[index]);
  75843. result.push(nV1);
  75844. result.push(nV2);
  75845. result.push(nV3);
  75846. }
  75847. if (!v3Out) {
  75848. nV1 = vertices[index + 2].clone();
  75849. nV2 = clipVertices(nV1, vertices[index]);
  75850. nV3 = clipVertices(nV1, vertices[index + 1]);
  75851. result.push(nV1);
  75852. result.push(nV2);
  75853. result.push(nV3);
  75854. }
  75855. break;
  75856. case 3:
  75857. break;
  75858. }
  75859. }
  75860. return result;
  75861. };
  75862. for (var index = 0; index < indices.length; index += 3) {
  75863. var faceVertices = new Array();
  75864. faceVertices.push(extractDecalVector3(index));
  75865. faceVertices.push(extractDecalVector3(index + 1));
  75866. faceVertices.push(extractDecalVector3(index + 2));
  75867. // Clip
  75868. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1, 0, 0));
  75869. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1, 0, 0));
  75870. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1, 0));
  75871. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -1, 0));
  75872. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 1));
  75873. faceVertices = clip(faceVertices, new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, -1));
  75874. if (faceVertices.length === 0) {
  75875. continue;
  75876. }
  75877. // Add UVs and get back to world
  75878. for (var vIndex = 0; vIndex < faceVertices.length; vIndex++) {
  75879. var vertex = faceVertices[vIndex];
  75880. //TODO check for Int32Array | Uint32Array | Uint16Array
  75881. vertexData.indices.push(currentVertexDataIndex);
  75882. vertex.position.toArray(vertexData.positions, currentVertexDataIndex * 3);
  75883. vertex.normal.toArray(vertexData.normals, currentVertexDataIndex * 3);
  75884. vertexData.uvs.push(0.5 + vertex.position.x / size.x);
  75885. vertexData.uvs.push(0.5 + vertex.position.y / size.y);
  75886. currentVertexDataIndex++;
  75887. }
  75888. }
  75889. // Return mesh
  75890. var decal = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, sourceMesh.getScene());
  75891. vertexData.applyToMesh(decal);
  75892. decal.position = position.clone();
  75893. decal.rotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pitch, yaw, angle);
  75894. return decal;
  75895. };
  75896. return DecalBuilder;
  75897. }());
  75898. /***/ }),
  75899. /***/ "./Meshes/Builders/discBuilder.ts":
  75900. /*!****************************************!*\
  75901. !*** ./Meshes/Builders/discBuilder.ts ***!
  75902. \****************************************/
  75903. /*! exports provided: DiscBuilder */
  75904. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75905. "use strict";
  75906. __webpack_require__.r(__webpack_exports__);
  75907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return DiscBuilder; });
  75908. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  75909. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  75910. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc = function (options) {
  75911. var positions = new Array();
  75912. var indices = new Array();
  75913. var normals = new Array();
  75914. var uvs = new Array();
  75915. var radius = options.radius || 0.5;
  75916. var tessellation = options.tessellation || 64;
  75917. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  75918. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  75919. // positions and uvs
  75920. positions.push(0, 0, 0); // disc center first
  75921. uvs.push(0.5, 0.5);
  75922. var theta = Math.PI * 2 * arc;
  75923. var step = theta / tessellation;
  75924. for (var a = 0; a < theta; a += step) {
  75925. var x = Math.cos(a);
  75926. var y = Math.sin(a);
  75927. var u = (x + 1) / 2;
  75928. var v = (1 - y) / 2;
  75929. positions.push(radius * x, radius * y, 0);
  75930. uvs.push(u, v);
  75931. }
  75932. if (arc === 1) {
  75933. positions.push(positions[3], positions[4], positions[5]); // close the circle
  75934. uvs.push(uvs[2], uvs[3]);
  75935. }
  75936. //indices
  75937. var vertexNb = positions.length / 3;
  75938. for (var i = 1; i < vertexNb - 1; i++) {
  75939. indices.push(i + 1, 0, i);
  75940. }
  75941. // result
  75942. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ComputeNormals(positions, indices, normals);
  75943. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  75944. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  75945. vertexData.indices = indices;
  75946. vertexData.positions = positions;
  75947. vertexData.normals = normals;
  75948. vertexData.uvs = uvs;
  75949. return vertexData;
  75950. };
  75951. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  75952. if (scene === void 0) { scene = null; }
  75953. var options = {
  75954. radius: radius,
  75955. tessellation: tessellation,
  75956. sideOrientation: sideOrientation,
  75957. updatable: updatable
  75958. };
  75959. return DiscBuilder.CreateDisc(name, options, scene);
  75960. };
  75961. /**
  75962. * Class containing static functions to help procedurally build meshes
  75963. */
  75964. var DiscBuilder = /** @class */ (function () {
  75965. function DiscBuilder() {
  75966. }
  75967. /**
  75968. * Creates a plane polygonal mesh. By default, this is a disc
  75969. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  75970. * * 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
  75971. * * 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
  75972. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  75973. * * 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
  75974. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  75975. * @param name defines the name of the mesh
  75976. * @param options defines the options used to create the mesh
  75977. * @param scene defines the hosting scene
  75978. * @returns the plane polygonal mesh
  75979. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  75980. */
  75981. DiscBuilder.CreateDisc = function (name, options, scene) {
  75982. if (scene === void 0) { scene = null; }
  75983. var disc = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  75984. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  75985. disc._originalBuilderSideOrientation = options.sideOrientation;
  75986. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreateDisc(options);
  75987. vertexData.applyToMesh(disc, options.updatable);
  75988. return disc;
  75989. };
  75990. return DiscBuilder;
  75991. }());
  75992. /***/ }),
  75993. /***/ "./Meshes/Builders/groundBuilder.ts":
  75994. /*!******************************************!*\
  75995. !*** ./Meshes/Builders/groundBuilder.ts ***!
  75996. \******************************************/
  75997. /*! exports provided: GroundBuilder */
  75998. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  75999. "use strict";
  76000. __webpack_require__.r(__webpack_exports__);
  76001. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return GroundBuilder; });
  76002. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76003. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76004. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76005. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../groundMesh */ "./Meshes/groundMesh.ts");
  76006. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  76007. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround = function (options) {
  76008. var indices = [];
  76009. var positions = [];
  76010. var normals = [];
  76011. var uvs = [];
  76012. var row, col;
  76013. var width = options.width || 1;
  76014. var height = options.height || 1;
  76015. var subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  76016. var subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  76017. for (row = 0; row <= subdivisionsY; row++) {
  76018. for (col = 0; col <= subdivisionsX; col++) {
  76019. var position = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]((col * width) / subdivisionsX - (width / 2.0), 0, ((subdivisionsY - row) * height) / subdivisionsY - (height / 2.0));
  76020. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  76021. positions.push(position.x, position.y, position.z);
  76022. normals.push(normal.x, normal.y, normal.z);
  76023. uvs.push(col / subdivisionsX, 1.0 - row / subdivisionsY);
  76024. }
  76025. }
  76026. for (row = 0; row < subdivisionsY; row++) {
  76027. for (col = 0; col < subdivisionsX; col++) {
  76028. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  76029. indices.push(col + 1 + row * (subdivisionsX + 1));
  76030. indices.push(col + row * (subdivisionsX + 1));
  76031. indices.push(col + (row + 1) * (subdivisionsX + 1));
  76032. indices.push(col + 1 + (row + 1) * (subdivisionsX + 1));
  76033. indices.push(col + row * (subdivisionsX + 1));
  76034. }
  76035. }
  76036. // Result
  76037. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76038. vertexData.indices = indices;
  76039. vertexData.positions = positions;
  76040. vertexData.normals = normals;
  76041. vertexData.uvs = uvs;
  76042. return vertexData;
  76043. };
  76044. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround = function (options) {
  76045. var xmin = (options.xmin !== undefined && options.xmin !== null) ? options.xmin : -1.0;
  76046. var zmin = (options.zmin !== undefined && options.zmin !== null) ? options.zmin : -1.0;
  76047. var xmax = (options.xmax !== undefined && options.xmax !== null) ? options.xmax : 1.0;
  76048. var zmax = (options.zmax !== undefined && options.zmax !== null) ? options.zmax : 1.0;
  76049. var subdivisions = options.subdivisions || { w: 1, h: 1 };
  76050. var precision = options.precision || { w: 1, h: 1 };
  76051. var indices = new Array();
  76052. var positions = new Array();
  76053. var normals = new Array();
  76054. var uvs = new Array();
  76055. var row, col, tileRow, tileCol;
  76056. subdivisions.h = (subdivisions.h < 1) ? 1 : subdivisions.h;
  76057. subdivisions.w = (subdivisions.w < 1) ? 1 : subdivisions.w;
  76058. precision.w = (precision.w < 1) ? 1 : precision.w;
  76059. precision.h = (precision.h < 1) ? 1 : precision.h;
  76060. var tileSize = {
  76061. 'w': (xmax - xmin) / subdivisions.w,
  76062. 'h': (zmax - zmin) / subdivisions.h
  76063. };
  76064. function applyTile(xTileMin, zTileMin, xTileMax, zTileMax) {
  76065. // Indices
  76066. var base = positions.length / 3;
  76067. var rowLength = precision.w + 1;
  76068. for (row = 0; row < precision.h; row++) {
  76069. for (col = 0; col < precision.w; col++) {
  76070. var square = [
  76071. base + col + row * rowLength,
  76072. base + (col + 1) + row * rowLength,
  76073. base + (col + 1) + (row + 1) * rowLength,
  76074. base + col + (row + 1) * rowLength
  76075. ];
  76076. indices.push(square[1]);
  76077. indices.push(square[2]);
  76078. indices.push(square[3]);
  76079. indices.push(square[0]);
  76080. indices.push(square[1]);
  76081. indices.push(square[3]);
  76082. }
  76083. }
  76084. // Position, normals and uvs
  76085. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76086. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0);
  76087. for (row = 0; row <= precision.h; row++) {
  76088. position.z = (row * (zTileMax - zTileMin)) / precision.h + zTileMin;
  76089. for (col = 0; col <= precision.w; col++) {
  76090. position.x = (col * (xTileMax - xTileMin)) / precision.w + xTileMin;
  76091. position.y = 0;
  76092. positions.push(position.x, position.y, position.z);
  76093. normals.push(normal.x, normal.y, normal.z);
  76094. uvs.push(col / precision.w, row / precision.h);
  76095. }
  76096. }
  76097. }
  76098. for (tileRow = 0; tileRow < subdivisions.h; tileRow++) {
  76099. for (tileCol = 0; tileCol < subdivisions.w; tileCol++) {
  76100. applyTile(xmin + tileCol * tileSize.w, zmin + tileRow * tileSize.h, xmin + (tileCol + 1) * tileSize.w, zmin + (tileRow + 1) * tileSize.h);
  76101. }
  76102. }
  76103. // Result
  76104. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76105. vertexData.indices = indices;
  76106. vertexData.positions = positions;
  76107. vertexData.normals = normals;
  76108. vertexData.uvs = uvs;
  76109. return vertexData;
  76110. };
  76111. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap = function (options) {
  76112. var indices = [];
  76113. var positions = [];
  76114. var normals = [];
  76115. var uvs = [];
  76116. var row, col;
  76117. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  76118. var alphaFilter = options.alphaFilter || 0.0;
  76119. // Vertices
  76120. for (row = 0; row <= options.subdivisions; row++) {
  76121. for (col = 0; col <= options.subdivisions; col++) {
  76122. 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));
  76123. // Compute height
  76124. var heightMapX = (((position.x + options.width / 2) / options.width) * (options.bufferWidth - 1)) | 0;
  76125. var heightMapY = ((1.0 - (position.z + options.height / 2) / options.height) * (options.bufferHeight - 1)) | 0;
  76126. var pos = (heightMapX + heightMapY * options.bufferWidth) * 4;
  76127. var r = options.buffer[pos] / 255.0;
  76128. var g = options.buffer[pos + 1] / 255.0;
  76129. var b = options.buffer[pos + 2] / 255.0;
  76130. var a = options.buffer[pos + 3] / 255.0;
  76131. var gradient = r * filter.r + g * filter.g + b * filter.b;
  76132. // If our alpha channel is not within our filter then we will assign a 'special' height
  76133. // Then when building the indices, we will ignore any vertex that is using the special height
  76134. if (a >= alphaFilter) {
  76135. position.y = options.minHeight + (options.maxHeight - options.minHeight) * gradient;
  76136. }
  76137. else {
  76138. position.y = options.minHeight - _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"]; // We can't have a height below minHeight, normally.
  76139. }
  76140. // Add vertex
  76141. positions.push(position.x, position.y, position.z);
  76142. normals.push(0, 0, 0);
  76143. uvs.push(col / options.subdivisions, 1.0 - row / options.subdivisions);
  76144. }
  76145. }
  76146. // Indices
  76147. for (row = 0; row < options.subdivisions; row++) {
  76148. for (col = 0; col < options.subdivisions; col++) {
  76149. // Calculate Indices
  76150. var idx1 = (col + 1 + (row + 1) * (options.subdivisions + 1));
  76151. var idx2 = (col + 1 + row * (options.subdivisions + 1));
  76152. var idx3 = (col + row * (options.subdivisions + 1));
  76153. var idx4 = (col + (row + 1) * (options.subdivisions + 1));
  76154. // Check that all indices are visible (based on our special height)
  76155. // Only display the vertex if all Indices are visible
  76156. // Positions are stored x,y,z for each vertex, hence the * 3 and + 1 for height
  76157. var isVisibleIdx1 = positions[idx1 * 3 + 1] >= options.minHeight;
  76158. var isVisibleIdx2 = positions[idx2 * 3 + 1] >= options.minHeight;
  76159. var isVisibleIdx3 = positions[idx3 * 3 + 1] >= options.minHeight;
  76160. if (isVisibleIdx1 && isVisibleIdx2 && isVisibleIdx3) {
  76161. indices.push(idx1);
  76162. indices.push(idx2);
  76163. indices.push(idx3);
  76164. }
  76165. var isVisibleIdx4 = positions[idx4 * 3 + 1] >= options.minHeight;
  76166. if (isVisibleIdx4 && isVisibleIdx1 && isVisibleIdx3) {
  76167. indices.push(idx4);
  76168. indices.push(idx1);
  76169. indices.push(idx3);
  76170. }
  76171. }
  76172. }
  76173. // Normals
  76174. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  76175. // Result
  76176. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76177. vertexData.indices = indices;
  76178. vertexData.positions = positions;
  76179. vertexData.normals = normals;
  76180. vertexData.uvs = uvs;
  76181. return vertexData;
  76182. };
  76183. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  76184. var options = {
  76185. width: width,
  76186. height: height,
  76187. subdivisions: subdivisions,
  76188. updatable: updatable
  76189. };
  76190. return GroundBuilder.CreateGround(name, options, scene);
  76191. };
  76192. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  76193. var options = {
  76194. xmin: xmin,
  76195. zmin: zmin,
  76196. xmax: xmax,
  76197. zmax: zmax,
  76198. subdivisions: subdivisions,
  76199. precision: precision,
  76200. updatable: updatable
  76201. };
  76202. return GroundBuilder.CreateTiledGround(name, options, scene);
  76203. };
  76204. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  76205. var options = {
  76206. width: width,
  76207. height: height,
  76208. subdivisions: subdivisions,
  76209. minHeight: minHeight,
  76210. maxHeight: maxHeight,
  76211. updatable: updatable,
  76212. onReady: onReady,
  76213. alphaFilter: alphaFilter
  76214. };
  76215. return GroundBuilder.CreateGroundFromHeightMap(name, url, options, scene);
  76216. };
  76217. /**
  76218. * Class containing static functions to help procedurally build meshes
  76219. */
  76220. var GroundBuilder = /** @class */ (function () {
  76221. function GroundBuilder() {
  76222. }
  76223. /**
  76224. * Creates a ground mesh
  76225. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  76226. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  76227. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76228. * @param name defines the name of the mesh
  76229. * @param options defines the options used to create the mesh
  76230. * @param scene defines the hosting scene
  76231. * @returns the ground mesh
  76232. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  76233. */
  76234. GroundBuilder.CreateGround = function (name, options, scene) {
  76235. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  76236. ground._setReady(false);
  76237. ground._subdivisionsX = options.subdivisionsX || options.subdivisions || 1;
  76238. ground._subdivisionsY = options.subdivisionsY || options.subdivisions || 1;
  76239. ground._width = options.width || 1;
  76240. ground._height = options.height || 1;
  76241. ground._maxX = ground._width / 2;
  76242. ground._maxZ = ground._height / 2;
  76243. ground._minX = -ground._maxX;
  76244. ground._minZ = -ground._maxZ;
  76245. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGround(options);
  76246. vertexData.applyToMesh(ground, options.updatable);
  76247. ground._setReady(true);
  76248. return ground;
  76249. };
  76250. /**
  76251. * Creates a tiled ground mesh
  76252. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  76253. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  76254. * * 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
  76255. * * 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
  76256. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76257. * @param name defines the name of the mesh
  76258. * @param options defines the options used to create the mesh
  76259. * @param scene defines the hosting scene
  76260. * @returns the tiled ground mesh
  76261. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  76262. */
  76263. GroundBuilder.CreateTiledGround = function (name, options, scene) {
  76264. var tiledGround = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76265. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTiledGround(options);
  76266. vertexData.applyToMesh(tiledGround, options.updatable);
  76267. return tiledGround;
  76268. };
  76269. /**
  76270. * Creates a ground mesh from a height map
  76271. * * The parameter `url` sets the URL of the height map image resource.
  76272. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  76273. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  76274. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  76275. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  76276. * * 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.
  76277. * * 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).
  76278. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  76279. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  76280. * @param name defines the name of the mesh
  76281. * @param url defines the url to the height map
  76282. * @param options defines the options used to create the mesh
  76283. * @param scene defines the hosting scene
  76284. * @returns the ground mesh
  76285. * @see https://doc.babylonjs.com/babylon101/height_map
  76286. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  76287. */
  76288. GroundBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  76289. var width = options.width || 10.0;
  76290. var height = options.height || 10.0;
  76291. var subdivisions = options.subdivisions || 1 | 0;
  76292. var minHeight = options.minHeight || 0.0;
  76293. var maxHeight = options.maxHeight || 1.0;
  76294. var filter = options.colorFilter || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](0.3, 0.59, 0.11);
  76295. var alphaFilter = options.alphaFilter || 0.0;
  76296. var updatable = options.updatable;
  76297. var onReady = options.onReady;
  76298. var ground = new _groundMesh__WEBPACK_IMPORTED_MODULE_3__["GroundMesh"](name, scene);
  76299. ground._subdivisionsX = subdivisions;
  76300. ground._subdivisionsY = subdivisions;
  76301. ground._width = width;
  76302. ground._height = height;
  76303. ground._maxX = ground._width / 2.0;
  76304. ground._maxZ = ground._height / 2.0;
  76305. ground._minX = -ground._maxX;
  76306. ground._minZ = -ground._maxZ;
  76307. ground._setReady(false);
  76308. var onload = function (img) {
  76309. // Getting height map data
  76310. var canvas = document.createElement("canvas");
  76311. var context = canvas.getContext("2d");
  76312. if (!context) {
  76313. throw new Error("Unable to get 2d context for CreateGroundFromHeightMap");
  76314. }
  76315. if (scene.isDisposed) {
  76316. return;
  76317. }
  76318. var bufferWidth = img.width;
  76319. var bufferHeight = img.height;
  76320. canvas.width = bufferWidth;
  76321. canvas.height = bufferHeight;
  76322. context.drawImage(img, 0, 0);
  76323. // Create VertexData from map data
  76324. // Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  76325. var buffer = context.getImageData(0, 0, bufferWidth, bufferHeight).data;
  76326. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateGroundFromHeightMap({
  76327. width: width, height: height,
  76328. subdivisions: subdivisions,
  76329. minHeight: minHeight, maxHeight: maxHeight, colorFilter: filter,
  76330. buffer: buffer, bufferWidth: bufferWidth, bufferHeight: bufferHeight,
  76331. alphaFilter: alphaFilter
  76332. });
  76333. vertexData.applyToMesh(ground, updatable);
  76334. //execute ready callback, if set
  76335. if (onReady) {
  76336. onReady(ground);
  76337. }
  76338. ground._setReady(true);
  76339. };
  76340. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  76341. return ground;
  76342. };
  76343. return GroundBuilder;
  76344. }());
  76345. /***/ }),
  76346. /***/ "./Meshes/Builders/icoSphereBuilder.ts":
  76347. /*!*********************************************!*\
  76348. !*** ./Meshes/Builders/icoSphereBuilder.ts ***!
  76349. \*********************************************/
  76350. /*! exports provided: IcoSphereBuilder */
  76351. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76352. "use strict";
  76353. __webpack_require__.r(__webpack_exports__);
  76354. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return IcoSphereBuilder; });
  76355. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76356. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76357. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76358. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere = function (options) {
  76359. var sideOrientation = options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  76360. var radius = options.radius || 1;
  76361. var flat = (options.flat === undefined) ? true : options.flat;
  76362. var subdivisions = options.subdivisions || 4;
  76363. var radiusX = options.radiusX || radius;
  76364. var radiusY = options.radiusY || radius;
  76365. var radiusZ = options.radiusZ || radius;
  76366. var t = (1 + Math.sqrt(5)) / 2;
  76367. // 12 vertex x,y,z
  76368. var ico_vertices = [
  76369. -1, t, -0, 1, t, 0, -1, -t, 0, 1, -t, 0,
  76370. 0, -1, -t, 0, 1, -t, 0, -1, t, 0, 1, t,
  76371. t, 0, 1, t, 0, -1, -t, 0, 1, -t, 0, -1 // v8-11
  76372. ];
  76373. // index of 3 vertex makes a face of icopshere
  76374. var ico_indices = [
  76375. 0, 11, 5, 0, 5, 1, 0, 1, 7, 0, 7, 10, 12, 22, 23,
  76376. 1, 5, 20, 5, 11, 4, 23, 22, 13, 22, 18, 6, 7, 1, 8,
  76377. 14, 21, 4, 14, 4, 2, 16, 13, 6, 15, 6, 19, 3, 8, 9,
  76378. 4, 21, 5, 13, 17, 23, 6, 13, 22, 19, 6, 18, 9, 8, 1
  76379. ];
  76380. // vertex for uv have aliased position, not for UV
  76381. var vertices_unalias_id = [
  76382. 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
  76383. // vertex alias
  76384. 0,
  76385. 2,
  76386. 3,
  76387. 3,
  76388. 3,
  76389. 4,
  76390. 7,
  76391. 8,
  76392. 9,
  76393. 9,
  76394. 10,
  76395. 11 // 23: B + 12
  76396. ];
  76397. // uv as integer step (not pixels !)
  76398. var ico_vertexuv = [
  76399. 5, 1, 3, 1, 6, 4, 0, 0,
  76400. 5, 3, 4, 2, 2, 2, 4, 0,
  76401. 2, 0, 1, 1, 6, 0, 6, 2,
  76402. // vertex alias (for same vertex on different faces)
  76403. 0, 4,
  76404. 3, 3,
  76405. 4, 4,
  76406. 3, 1,
  76407. 4, 2,
  76408. 4, 4,
  76409. 0, 2,
  76410. 1, 1,
  76411. 2, 2,
  76412. 3, 3,
  76413. 1, 3,
  76414. 2, 4 // 23: B + 12
  76415. ];
  76416. // Vertices[0, 1, ...9, A, B] : position on UV plane
  76417. // '+' indicate duplicate position to be fixed (3,9:0,2,3,4,7,8,A,B)
  76418. // First island of uv mapping
  76419. // v = 4h 3+ 2
  76420. // v = 3h 9+ 4
  76421. // v = 2h 9+ 5 B
  76422. // v = 1h 9 1 0
  76423. // v = 0h 3 8 7 A
  76424. // u = 0 1 2 3 4 5 6 *a
  76425. // Second island of uv mapping
  76426. // v = 4h 0+ B+ 4+
  76427. // v = 3h A+ 2+
  76428. // v = 2h 7+ 6 3+
  76429. // v = 1h 8+ 3+
  76430. // v = 0h
  76431. // u = 0 1 2 3 4 5 6 *a
  76432. // Face layout on texture UV mapping
  76433. // ============
  76434. // \ 4 /\ 16 / ======
  76435. // \ / \ / /\ 11 /
  76436. // \/ 7 \/ / \ /
  76437. // ======= / 10 \/
  76438. // /\ 17 /\ =======
  76439. // / \ / \ \ 15 /\
  76440. // / 8 \/ 12 \ \ / \
  76441. // ============ \/ 6 \
  76442. // \ 18 /\ ============
  76443. // \ / \ \ 5 /\ 0 /
  76444. // \/ 13 \ \ / \ /
  76445. // ======= \/ 1 \/
  76446. // =============
  76447. // /\ 19 /\ 2 /\
  76448. // / \ / \ / \
  76449. // / 14 \/ 9 \/ 3 \
  76450. // ===================
  76451. // uv step is u:1 or 0.5, v:cos(30)=sqrt(3)/2, ratio approx is 84/97
  76452. var ustep = 138 / 1024;
  76453. var vstep = 239 / 1024;
  76454. var uoffset = 60 / 1024;
  76455. var voffset = 26 / 1024;
  76456. // Second island should have margin, not to touch the first island
  76457. // avoid any borderline artefact in pixel rounding
  76458. var island_u_offset = -40 / 1024;
  76459. var island_v_offset = +20 / 1024;
  76460. // face is either island 0 or 1 :
  76461. // second island is for faces : [4, 7, 8, 12, 13, 16, 17, 18]
  76462. var island = [
  76463. 0, 0, 0, 0, 1,
  76464. 0, 0, 1, 1, 0,
  76465. 0, 0, 1, 1, 0,
  76466. 0, 1, 1, 1, 0 // 15 - 19
  76467. ];
  76468. var indices = new Array();
  76469. var positions = new Array();
  76470. var normals = new Array();
  76471. var uvs = new Array();
  76472. var current_indice = 0;
  76473. // prepare array of 3 vector (empty) (to be worked in place, shared for each face)
  76474. var face_vertex_pos = new Array(3);
  76475. var face_vertex_uv = new Array(3);
  76476. var v012;
  76477. for (v012 = 0; v012 < 3; v012++) {
  76478. face_vertex_pos[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76479. face_vertex_uv[v012] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Zero();
  76480. }
  76481. // create all with normals
  76482. for (var face = 0; face < 20; face++) {
  76483. // 3 vertex per face
  76484. for (v012 = 0; v012 < 3; v012++) {
  76485. // look up vertex 0,1,2 to its index in 0 to 11 (or 23 including alias)
  76486. var v_id = ico_indices[3 * face + v012];
  76487. // vertex have 3D position (x,y,z)
  76488. 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]);
  76489. // Normalize to get normal, then scale to radius
  76490. face_vertex_pos[v012].normalize().scaleInPlace(radius);
  76491. // uv Coordinates from vertex ID
  76492. 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);
  76493. }
  76494. // Subdivide the face (interpolate pos, norm, uv)
  76495. // - pos is linear interpolation, then projected to sphere (converge polyhedron to sphere)
  76496. // - norm is linear interpolation of vertex corner normal
  76497. // (to be checked if better to re-calc from face vertex, or if approximation is OK ??? )
  76498. // - uv is linear interpolation
  76499. //
  76500. // Topology is as below for sub-divide by 2
  76501. // vertex shown as v0,v1,v2
  76502. // interp index is i1 to progress in range [v0,v1[
  76503. // interp index is i2 to progress in range [v0,v2[
  76504. // face index as (i1,i2) for /\ : (i1,i2),(i1+1,i2),(i1,i2+1)
  76505. // and (i1,i2)' for \/ : (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76506. //
  76507. //
  76508. // i2 v2
  76509. // ^ ^
  76510. // / / \
  76511. // / / \
  76512. // / / \
  76513. // / / (0,1) \
  76514. // / #---------\
  76515. // / / \ (0,0)'/ \
  76516. // / / \ / \
  76517. // / / \ / \
  76518. // / / (0,0) \ / (1,0) \
  76519. // / #---------#---------\
  76520. // v0 v1
  76521. //
  76522. // --------------------> i1
  76523. //
  76524. // interp of (i1,i2):
  76525. // along i2 : x0=lerp(v0,v2, i2/S) <---> x1=lerp(v1,v2, i2/S)
  76526. // along i1 : lerp(x0,x1, i1/(S-i2))
  76527. //
  76528. // centroid of triangle is needed to get help normal computation
  76529. // (c1,c2) are used for centroid location
  76530. var interp_vertex = function (i1, i2, c1, c2) {
  76531. // vertex is interpolated from
  76532. // - face_vertex_pos[0..2]
  76533. // - face_vertex_uv[0..2]
  76534. var pos_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], i2 / subdivisions);
  76535. var pos_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], i2 / subdivisions);
  76536. var pos_interp = (subdivisions === i2) ? face_vertex_pos[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(pos_x0, pos_x1, i1 / (subdivisions - i2));
  76537. pos_interp.normalize();
  76538. var vertex_normal;
  76539. if (flat) {
  76540. // in flat mode, recalculate normal as face centroid normal
  76541. var centroid_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[0], face_vertex_pos[2], c2 / subdivisions);
  76542. var centroid_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(face_vertex_pos[1], face_vertex_pos[2], c2 / subdivisions);
  76543. vertex_normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Lerp(centroid_x0, centroid_x1, c1 / (subdivisions - c2));
  76544. }
  76545. else {
  76546. // in smooth mode, recalculate normal from each single vertex position
  76547. vertex_normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](pos_interp.x, pos_interp.y, pos_interp.z);
  76548. }
  76549. // Vertex normal need correction due to X,Y,Z radius scaling
  76550. vertex_normal.x /= radiusX;
  76551. vertex_normal.y /= radiusY;
  76552. vertex_normal.z /= radiusZ;
  76553. vertex_normal.normalize();
  76554. var uv_x0 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[0], face_vertex_uv[2], i2 / subdivisions);
  76555. var uv_x1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(face_vertex_uv[1], face_vertex_uv[2], i2 / subdivisions);
  76556. var uv_interp = (subdivisions === i2) ? face_vertex_uv[2] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"].Lerp(uv_x0, uv_x1, i1 / (subdivisions - i2));
  76557. positions.push(pos_interp.x * radiusX, pos_interp.y * radiusY, pos_interp.z * radiusZ);
  76558. normals.push(vertex_normal.x, vertex_normal.y, vertex_normal.z);
  76559. uvs.push(uv_interp.x, uv_interp.y);
  76560. // push each vertex has member of a face
  76561. // Same vertex can bleong to multiple face, it is pushed multiple time (duplicate vertex are present)
  76562. indices.push(current_indice);
  76563. current_indice++;
  76564. };
  76565. for (var i2 = 0; i2 < subdivisions; i2++) {
  76566. for (var i1 = 0; i1 + i2 < subdivisions; i1++) {
  76567. // face : (i1,i2) for /\ :
  76568. // interp for : (i1,i2),(i1+1,i2),(i1,i2+1)
  76569. interp_vertex(i1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76570. interp_vertex(i1 + 1, i2, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76571. interp_vertex(i1, i2 + 1, i1 + 1.0 / 3, i2 + 1.0 / 3);
  76572. if (i1 + i2 + 1 < subdivisions) {
  76573. // face : (i1,i2)' for \/ :
  76574. // interp for (i1+1,i2),(i1+1,i2+1),(i1,i2+1)
  76575. interp_vertex(i1 + 1, i2, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76576. interp_vertex(i1 + 1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76577. interp_vertex(i1, i2 + 1, i1 + 2.0 / 3, i2 + 2.0 / 3);
  76578. }
  76579. }
  76580. }
  76581. }
  76582. // Sides
  76583. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  76584. // Result
  76585. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76586. vertexData.indices = indices;
  76587. vertexData.positions = positions;
  76588. vertexData.normals = normals;
  76589. vertexData.uvs = uvs;
  76590. return vertexData;
  76591. };
  76592. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateIcoSphere = function (name, options, scene) {
  76593. return IcoSphereBuilder.CreateIcoSphere(name, options, scene);
  76594. };
  76595. /**
  76596. * Class containing static functions to help procedurally build meshes
  76597. */
  76598. var IcoSphereBuilder = /** @class */ (function () {
  76599. function IcoSphereBuilder() {
  76600. }
  76601. /**
  76602. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  76603. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  76604. * * 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`)
  76605. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  76606. * * 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
  76607. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76608. * * 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
  76609. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76610. * @param name defines the name of the mesh
  76611. * @param options defines the options used to create the mesh
  76612. * @param scene defines the hosting scene
  76613. * @returns the icosahedron mesh
  76614. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  76615. */
  76616. IcoSphereBuilder.CreateIcoSphere = function (name, options, scene) {
  76617. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  76618. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76619. sphere._originalBuilderSideOrientation = options.sideOrientation;
  76620. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateIcoSphere(options);
  76621. vertexData.applyToMesh(sphere, options.updatable);
  76622. return sphere;
  76623. };
  76624. return IcoSphereBuilder;
  76625. }());
  76626. /***/ }),
  76627. /***/ "./Meshes/Builders/index.ts":
  76628. /*!**********************************!*\
  76629. !*** ./Meshes/Builders/index.ts ***!
  76630. \**********************************/
  76631. /*! exports provided: BoxBuilder, SphereBuilder, CylinderBuilder, LinesBuilder, PlaneBuilder, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  76632. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76633. "use strict";
  76634. __webpack_require__.r(__webpack_exports__);
  76635. /* harmony import */ var _boxBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  76636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _boxBuilder__WEBPACK_IMPORTED_MODULE_0__["BoxBuilder"]; });
  76637. /* harmony import */ var _discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./discBuilder */ "./Meshes/Builders/discBuilder.ts");
  76638. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"]; });
  76639. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"]; });
  76641. /* harmony import */ var _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  76642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"]; });
  76643. /* harmony import */ var _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  76644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"]; });
  76645. /* harmony import */ var _torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  76646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"]; });
  76647. /* harmony import */ var _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  76648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"]; });
  76649. /* harmony import */ var _linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  76650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"]; });
  76651. /* harmony import */ var _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  76652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"]; });
  76653. /* harmony import */ var _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  76654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"]; });
  76655. /* harmony import */ var _latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  76656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"]; });
  76657. /* harmony import */ var _planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  76658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"]; });
  76659. /* harmony import */ var _groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  76660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"]; });
  76661. /* harmony import */ var _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  76662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"]; });
  76663. /* harmony import */ var _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  76664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"]; });
  76665. /* harmony import */ var _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  76666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"]; });
  76667. /* harmony import */ var _decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  76668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"]; });
  76669. /***/ }),
  76670. /***/ "./Meshes/Builders/latheBuilder.ts":
  76671. /*!*****************************************!*\
  76672. !*** ./Meshes/Builders/latheBuilder.ts ***!
  76673. \*****************************************/
  76674. /*! exports provided: LatheBuilder */
  76675. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76676. "use strict";
  76677. __webpack_require__.r(__webpack_exports__);
  76678. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return LatheBuilder; });
  76679. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76680. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76681. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  76682. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  76683. var options = {
  76684. shape: shape,
  76685. radius: radius,
  76686. tessellation: tessellation,
  76687. sideOrientation: sideOrientation,
  76688. updatable: updatable
  76689. };
  76690. return LatheBuilder.CreateLathe(name, options, scene);
  76691. };
  76692. /**
  76693. * Class containing static functions to help procedurally build meshes
  76694. */
  76695. var LatheBuilder = /** @class */ (function () {
  76696. function LatheBuilder() {
  76697. }
  76698. /**
  76699. * Creates lathe mesh.
  76700. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  76701. * * 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
  76702. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  76703. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  76704. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  76705. * * 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
  76706. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  76707. * * 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
  76708. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  76709. * * 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
  76710. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  76711. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76712. * @param name defines the name of the mesh
  76713. * @param options defines the options used to create the mesh
  76714. * @param scene defines the hosting scene
  76715. * @returns the lathe mesh
  76716. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  76717. */
  76718. LatheBuilder.CreateLathe = function (name, options, scene) {
  76719. var arc = options.arc ? ((options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc) : 1.0;
  76720. var closed = (options.closed === undefined) ? true : options.closed;
  76721. var shape = options.shape;
  76722. var radius = options.radius || 1;
  76723. var tessellation = options.tessellation || 64;
  76724. var clip = options.clip || 0;
  76725. var updatable = options.updatable;
  76726. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  76727. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  76728. var pi2 = Math.PI * 2;
  76729. var paths = new Array();
  76730. var invertUV = options.invertUV || false;
  76731. var i = 0;
  76732. var p = 0;
  76733. var step = pi2 / tessellation * arc;
  76734. var rotated;
  76735. var path = new Array();
  76736. for (i = 0; i <= tessellation - clip; i++) {
  76737. var path = [];
  76738. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76739. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[0].y, 0));
  76740. 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));
  76741. }
  76742. for (p = 0; p < shape.length; p++) {
  76743. 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);
  76744. path.push(rotated);
  76745. }
  76746. if (cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END || cap == _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL) {
  76747. 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));
  76748. path.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, shape[shape.length - 1].y, 0));
  76749. }
  76750. paths.push(path);
  76751. }
  76752. // lathe ribbon
  76753. 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);
  76754. return lathe;
  76755. };
  76756. return LatheBuilder;
  76757. }());
  76758. /***/ }),
  76759. /***/ "./Meshes/Builders/linesBuilder.ts":
  76760. /*!*****************************************!*\
  76761. !*** ./Meshes/Builders/linesBuilder.ts ***!
  76762. \*****************************************/
  76763. /*! exports provided: LinesBuilder */
  76764. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  76765. "use strict";
  76766. __webpack_require__.r(__webpack_exports__);
  76767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return LinesBuilder; });
  76768. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  76769. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  76770. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  76771. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  76772. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  76773. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem = function (options) {
  76774. var indices = [];
  76775. var positions = [];
  76776. var lines = options.lines;
  76777. var colors = options.colors;
  76778. var vertexColors = [];
  76779. var idx = 0;
  76780. for (var l = 0; l < lines.length; l++) {
  76781. var points = lines[l];
  76782. for (var index = 0; index < points.length; index++) {
  76783. positions.push(points[index].x, points[index].y, points[index].z);
  76784. if (colors) {
  76785. var color = colors[l];
  76786. vertexColors.push(color[index].r, color[index].g, color[index].b, color[index].a);
  76787. }
  76788. if (index > 0) {
  76789. indices.push(idx - 1);
  76790. indices.push(idx);
  76791. }
  76792. idx++;
  76793. }
  76794. }
  76795. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76796. vertexData.indices = indices;
  76797. vertexData.positions = positions;
  76798. if (colors) {
  76799. vertexData.colors = vertexColors;
  76800. }
  76801. return vertexData;
  76802. };
  76803. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines = function (options) {
  76804. var dashSize = options.dashSize || 3;
  76805. var gapSize = options.gapSize || 1;
  76806. var dashNb = options.dashNb || 200;
  76807. var points = options.points;
  76808. var positions = new Array();
  76809. var indices = new Array();
  76810. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76811. var lg = 0;
  76812. var nb = 0;
  76813. var shft = 0;
  76814. var dashshft = 0;
  76815. var curshft = 0;
  76816. var idx = 0;
  76817. var i = 0;
  76818. for (i = 0; i < points.length - 1; i++) {
  76819. points[i + 1].subtractToRef(points[i], curvect);
  76820. lg += curvect.length();
  76821. }
  76822. shft = lg / dashNb;
  76823. dashshft = dashSize * shft / (dashSize + gapSize);
  76824. for (i = 0; i < points.length - 1; i++) {
  76825. points[i + 1].subtractToRef(points[i], curvect);
  76826. nb = Math.floor(curvect.length() / shft);
  76827. curvect.normalize();
  76828. for (var j = 0; j < nb; j++) {
  76829. curshft = shft * j;
  76830. positions.push(points[i].x + curshft * curvect.x, points[i].y + curshft * curvect.y, points[i].z + curshft * curvect.z);
  76831. positions.push(points[i].x + (curshft + dashshft) * curvect.x, points[i].y + (curshft + dashshft) * curvect.y, points[i].z + (curshft + dashshft) * curvect.z);
  76832. indices.push(idx, idx + 1);
  76833. idx += 2;
  76834. }
  76835. }
  76836. // Result
  76837. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  76838. vertexData.positions = positions;
  76839. vertexData.indices = indices;
  76840. return vertexData;
  76841. };
  76842. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateLines = function (name, points, scene, updatable, instance) {
  76843. if (scene === void 0) { scene = null; }
  76844. if (updatable === void 0) { updatable = false; }
  76845. if (instance === void 0) { instance = null; }
  76846. var options = {
  76847. points: points,
  76848. updatable: updatable,
  76849. instance: instance
  76850. };
  76851. return LinesBuilder.CreateLines(name, options, scene);
  76852. };
  76853. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  76854. if (scene === void 0) { scene = null; }
  76855. var options = {
  76856. points: points,
  76857. dashSize: dashSize,
  76858. gapSize: gapSize,
  76859. dashNb: dashNb,
  76860. updatable: updatable,
  76861. instance: instance
  76862. };
  76863. return LinesBuilder.CreateDashedLines(name, options, scene);
  76864. };
  76865. /**
  76866. * Class containing static functions to help procedurally build meshes
  76867. */
  76868. var LinesBuilder = /** @class */ (function () {
  76869. function LinesBuilder() {
  76870. }
  76871. /**
  76872. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  76873. * * 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
  76874. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  76875. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  76876. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  76877. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  76878. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  76879. * * 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
  76880. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  76881. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76882. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  76883. * @param name defines the name of the new line system
  76884. * @param options defines the options used to create the line system
  76885. * @param scene defines the hosting scene
  76886. * @returns a new line system mesh
  76887. */
  76888. LinesBuilder.CreateLineSystem = function (name, options, scene) {
  76889. var instance = options.instance;
  76890. var lines = options.lines;
  76891. var colors = options.colors;
  76892. if (instance) { // lines update
  76893. var positions = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  76894. var vertexColor;
  76895. var lineColors;
  76896. if (colors) {
  76897. vertexColor = instance.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind);
  76898. }
  76899. var i = 0;
  76900. var c = 0;
  76901. for (var l = 0; l < lines.length; l++) {
  76902. var points = lines[l];
  76903. for (var p = 0; p < points.length; p++) {
  76904. positions[i] = points[p].x;
  76905. positions[i + 1] = points[p].y;
  76906. positions[i + 2] = points[p].z;
  76907. if (colors && vertexColor) {
  76908. lineColors = colors[l];
  76909. vertexColor[c] = lineColors[p].r;
  76910. vertexColor[c + 1] = lineColors[p].g;
  76911. vertexColor[c + 2] = lineColors[p].b;
  76912. vertexColor[c + 3] = lineColors[p].a;
  76913. c += 4;
  76914. }
  76915. i += 3;
  76916. }
  76917. }
  76918. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind, positions, false, false);
  76919. if (colors && vertexColor) {
  76920. instance.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].ColorKind, vertexColor, false, false);
  76921. }
  76922. return instance;
  76923. }
  76924. // line system creation
  76925. var useVertexColor = (colors) ? true : false;
  76926. var lineSystem = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene, null, undefined, undefined, useVertexColor, options.useVertexAlpha);
  76927. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateLineSystem(options);
  76928. vertexData.applyToMesh(lineSystem, options.updatable);
  76929. return lineSystem;
  76930. };
  76931. /**
  76932. * Creates a line mesh
  76933. * 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
  76934. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76935. * * The parameter `points` is an array successive Vector3
  76936. * * 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
  76937. * * The optional parameter `colors` is an array of successive Color4, one per line point
  76938. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  76939. * * When updating an instance, remember that only point positions can change, not the number of points
  76940. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76941. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  76942. * @param name defines the name of the new line system
  76943. * @param options defines the options used to create the line system
  76944. * @param scene defines the hosting scene
  76945. * @returns a new line mesh
  76946. */
  76947. LinesBuilder.CreateLines = function (name, options, scene) {
  76948. if (scene === void 0) { scene = null; }
  76949. var colors = (options.colors) ? [options.colors] : null;
  76950. var lines = LinesBuilder.CreateLineSystem(name, { lines: [options.points], updatable: options.updatable, instance: options.instance, colors: colors, useVertexAlpha: options.useVertexAlpha }, scene);
  76951. return lines;
  76952. };
  76953. /**
  76954. * Creates a dashed line mesh
  76955. * * 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
  76956. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  76957. * * The parameter `points` is an array successive Vector3
  76958. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  76959. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  76960. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  76961. * * 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
  76962. * * When updating an instance, remember that only point positions can change, not the number of points
  76963. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  76964. * @param name defines the name of the mesh
  76965. * @param options defines the options used to create the mesh
  76966. * @param scene defines the hosting scene
  76967. * @returns the dashed line mesh
  76968. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  76969. */
  76970. LinesBuilder.CreateDashedLines = function (name, options, scene) {
  76971. if (scene === void 0) { scene = null; }
  76972. var points = options.points;
  76973. var instance = options.instance;
  76974. var gapSize = options.gapSize || 1;
  76975. var dashSize = options.dashSize || 3;
  76976. if (instance) { // dashed lines update
  76977. var positionFunction = function (positions) {
  76978. var curvect = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  76979. var nbSeg = positions.length / 6;
  76980. var lg = 0;
  76981. var nb = 0;
  76982. var shft = 0;
  76983. var dashshft = 0;
  76984. var curshft = 0;
  76985. var p = 0;
  76986. var i = 0;
  76987. var j = 0;
  76988. for (i = 0; i < points.length - 1; i++) {
  76989. points[i + 1].subtractToRef(points[i], curvect);
  76990. lg += curvect.length();
  76991. }
  76992. shft = lg / nbSeg;
  76993. var dashSize = instance._creationDataStorage.dashSize;
  76994. var gapSize = instance._creationDataStorage.gapSize;
  76995. dashshft = dashSize * shft / (dashSize + gapSize);
  76996. for (i = 0; i < points.length - 1; i++) {
  76997. points[i + 1].subtractToRef(points[i], curvect);
  76998. nb = Math.floor(curvect.length() / shft);
  76999. curvect.normalize();
  77000. j = 0;
  77001. while (j < nb && p < positions.length) {
  77002. curshft = shft * j;
  77003. positions[p] = points[i].x + curshft * curvect.x;
  77004. positions[p + 1] = points[i].y + curshft * curvect.y;
  77005. positions[p + 2] = points[i].z + curshft * curvect.z;
  77006. positions[p + 3] = points[i].x + (curshft + dashshft) * curvect.x;
  77007. positions[p + 4] = points[i].y + (curshft + dashshft) * curvect.y;
  77008. positions[p + 5] = points[i].z + (curshft + dashshft) * curvect.z;
  77009. p += 6;
  77010. j++;
  77011. }
  77012. }
  77013. while (p < positions.length) {
  77014. positions[p] = points[i].x;
  77015. positions[p + 1] = points[i].y;
  77016. positions[p + 2] = points[i].z;
  77017. p += 3;
  77018. }
  77019. };
  77020. instance.updateMeshPositions(positionFunction, false);
  77021. return instance;
  77022. }
  77023. // dashed lines creation
  77024. var dashedLines = new _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"](name, scene);
  77025. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateDashedLines(options);
  77026. vertexData.applyToMesh(dashedLines, options.updatable);
  77027. dashedLines._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77028. dashedLines._creationDataStorage.dashSize = dashSize;
  77029. dashedLines._creationDataStorage.gapSize = gapSize;
  77030. return dashedLines;
  77031. };
  77032. return LinesBuilder;
  77033. }());
  77034. /***/ }),
  77035. /***/ "./Meshes/Builders/planeBuilder.ts":
  77036. /*!*****************************************!*\
  77037. !*** ./Meshes/Builders/planeBuilder.ts ***!
  77038. \*****************************************/
  77039. /*! exports provided: PlaneBuilder */
  77040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77041. "use strict";
  77042. __webpack_require__.r(__webpack_exports__);
  77043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return PlaneBuilder; });
  77044. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77045. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77046. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane = function (options) {
  77047. var indices = [];
  77048. var positions = [];
  77049. var normals = [];
  77050. var uvs = [];
  77051. var width = options.width || options.size || 1;
  77052. var height = options.height || options.size || 1;
  77053. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].DEFAULTSIDE;
  77054. // Vertices
  77055. var halfWidth = width / 2.0;
  77056. var halfHeight = height / 2.0;
  77057. positions.push(-halfWidth, -halfHeight, 0);
  77058. normals.push(0, 0, -1.0);
  77059. uvs.push(0.0, 0.0);
  77060. positions.push(halfWidth, -halfHeight, 0);
  77061. normals.push(0, 0, -1.0);
  77062. uvs.push(1.0, 0.0);
  77063. positions.push(halfWidth, halfHeight, 0);
  77064. normals.push(0, 0, -1.0);
  77065. uvs.push(1.0, 1.0);
  77066. positions.push(-halfWidth, halfHeight, 0);
  77067. normals.push(0, 0, -1.0);
  77068. uvs.push(0.0, 1.0);
  77069. // Indices
  77070. indices.push(0);
  77071. indices.push(1);
  77072. indices.push(2);
  77073. indices.push(0);
  77074. indices.push(2);
  77075. indices.push(3);
  77076. // Sides
  77077. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77078. // Result
  77079. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  77080. vertexData.indices = indices;
  77081. vertexData.positions = positions;
  77082. vertexData.normals = normals;
  77083. vertexData.uvs = uvs;
  77084. return vertexData;
  77085. };
  77086. _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  77087. var options = {
  77088. size: size,
  77089. width: size,
  77090. height: size,
  77091. sideOrientation: sideOrientation,
  77092. updatable: updatable
  77093. };
  77094. return PlaneBuilder.CreatePlane(name, options, scene);
  77095. };
  77096. /**
  77097. * Class containing static functions to help procedurally build meshes
  77098. */
  77099. var PlaneBuilder = /** @class */ (function () {
  77100. function PlaneBuilder() {
  77101. }
  77102. /**
  77103. * Creates a plane mesh
  77104. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  77105. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  77106. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  77107. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77108. * * 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
  77109. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77110. * @param name defines the name of the mesh
  77111. * @param options defines the options used to create the mesh
  77112. * @param scene defines the hosting scene
  77113. * @returns the plane mesh
  77114. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  77115. */
  77116. PlaneBuilder.CreatePlane = function (name, options, scene) {
  77117. var plane = new _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"](name, scene);
  77118. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77119. plane._originalBuilderSideOrientation = options.sideOrientation;
  77120. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].CreatePlane(options);
  77121. vertexData.applyToMesh(plane, options.updatable);
  77122. if (options.sourcePlane) {
  77123. plane.translate(options.sourcePlane.normal, -options.sourcePlane.d);
  77124. plane.setDirection(options.sourcePlane.normal.scale(-1));
  77125. }
  77126. return plane;
  77127. };
  77128. return PlaneBuilder;
  77129. }());
  77130. /***/ }),
  77131. /***/ "./Meshes/Builders/polygonBuilder.ts":
  77132. /*!*******************************************!*\
  77133. !*** ./Meshes/Builders/polygonBuilder.ts ***!
  77134. \*******************************************/
  77135. /*! exports provided: PolygonBuilder */
  77136. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77137. "use strict";
  77138. __webpack_require__.r(__webpack_exports__);
  77139. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return PolygonBuilder; });
  77140. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77141. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77142. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77143. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../polygonMesh */ "./Meshes/polygonMesh.ts");
  77144. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  77145. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  77146. var faceUV = fUV || new Array(3);
  77147. var faceColors = fColors;
  77148. var colors = [];
  77149. // default face colors and UV if undefined
  77150. for (var f = 0; f < 3; f++) {
  77151. if (faceUV[f] === undefined) {
  77152. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77153. }
  77154. if (faceColors && faceColors[f] === undefined) {
  77155. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77156. }
  77157. }
  77158. var positions = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  77159. var normals = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].NormalKind);
  77160. var uvs = polygon.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  77161. var indices = polygon.getIndices();
  77162. // set face colours and textures
  77163. var idx = 0;
  77164. var face = 0;
  77165. for (var index = 0; index < normals.length; index += 3) {
  77166. //Edge Face no. 1
  77167. if (Math.abs(normals[index + 1]) < 0.001) {
  77168. face = 1;
  77169. }
  77170. //Top Face no. 0
  77171. if (Math.abs(normals[index + 1] - 1) < 0.001) {
  77172. face = 0;
  77173. }
  77174. //Bottom Face no. 2
  77175. if (Math.abs(normals[index + 1] + 1) < 0.001) {
  77176. face = 2;
  77177. }
  77178. idx = index / 3;
  77179. uvs[2 * idx] = (1 - uvs[2 * idx]) * faceUV[face].x + uvs[2 * idx] * faceUV[face].z;
  77180. uvs[2 * idx + 1] = (1 - uvs[2 * idx + 1]) * faceUV[face].y + uvs[2 * idx + 1] * faceUV[face].w;
  77181. if (faceColors) {
  77182. colors.push(faceColors[face].r, faceColors[face].g, faceColors[face].b, faceColors[face].a);
  77183. }
  77184. }
  77185. // sides
  77186. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs);
  77187. // Result
  77188. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77189. vertexData.indices = indices;
  77190. vertexData.positions = positions;
  77191. vertexData.normals = normals;
  77192. vertexData.uvs = uvs;
  77193. if (faceColors) {
  77194. var totalColors = (sideOrientation === _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DOUBLESIDE) ? colors.concat(colors) : colors;
  77195. vertexData.colors = totalColors;
  77196. }
  77197. return vertexData;
  77198. };
  77199. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  77200. if (earcutInjection === void 0) { earcutInjection = earcut; }
  77201. var options = {
  77202. shape: shape,
  77203. holes: holes,
  77204. updatable: updatable,
  77205. sideOrientation: sideOrientation
  77206. };
  77207. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  77208. };
  77209. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  77210. if (earcutInjection === void 0) { earcutInjection = earcut; }
  77211. var options = {
  77212. shape: shape,
  77213. holes: holes,
  77214. depth: depth,
  77215. updatable: updatable,
  77216. sideOrientation: sideOrientation
  77217. };
  77218. return PolygonBuilder.ExtrudePolygon(name, options, scene, earcutInjection);
  77219. };
  77220. /**
  77221. * Class containing static functions to help procedurally build meshes
  77222. */
  77223. var PolygonBuilder = /** @class */ (function () {
  77224. function PolygonBuilder() {
  77225. }
  77226. /**
  77227. * Creates a polygon mesh
  77228. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  77229. * * 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
  77230. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  77231. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77232. * * 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)
  77233. * * Remember you can only change the shape positions, not their number when updating a polygon
  77234. * @param name defines the name of the mesh
  77235. * @param options defines the options used to create the mesh
  77236. * @param scene defines the hosting scene
  77237. * @param earcutInjection can be used to inject your own earcut reference
  77238. * @returns the polygon mesh
  77239. */
  77240. PolygonBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  77241. if (earcutInjection === void 0) { earcutInjection = earcut; }
  77242. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77243. var shape = options.shape;
  77244. var holes = options.holes || [];
  77245. var depth = options.depth || 0;
  77246. var contours = [];
  77247. var hole = [];
  77248. for (var i = 0; i < shape.length; i++) {
  77249. contours[i] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](shape[i].x, shape[i].z);
  77250. }
  77251. var epsilon = 0.00000001;
  77252. if (contours[0].equalsWithEpsilon(contours[contours.length - 1], epsilon)) {
  77253. contours.pop();
  77254. }
  77255. var polygonTriangulation = new _polygonMesh__WEBPACK_IMPORTED_MODULE_3__["PolygonMeshBuilder"](name, contours, scene, earcutInjection);
  77256. for (var hNb = 0; hNb < holes.length; hNb++) {
  77257. hole = [];
  77258. for (var hPoint = 0; hPoint < holes[hNb].length; hPoint++) {
  77259. hole.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](holes[hNb][hPoint].x, holes[hNb][hPoint].z));
  77260. }
  77261. polygonTriangulation.addHole(hole);
  77262. }
  77263. var polygon = polygonTriangulation.build(options.updatable, depth);
  77264. polygon._originalBuilderSideOrientation = options.sideOrientation;
  77265. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolygon(polygon, options.sideOrientation, options.faceUV, options.faceColors, options.frontUVs, options.backUVs);
  77266. vertexData.applyToMesh(polygon, options.updatable);
  77267. return polygon;
  77268. };
  77269. /**
  77270. * Creates an extruded polygon mesh, with depth in the Y direction.
  77271. * * 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)
  77272. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  77273. * @param name defines the name of the mesh
  77274. * @param options defines the options used to create the mesh
  77275. * @param scene defines the hosting scene
  77276. * @param earcutInjection can be used to inject your own earcut reference
  77277. * @returns the polygon mesh
  77278. */
  77279. PolygonBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  77280. if (earcutInjection === void 0) { earcutInjection = earcut; }
  77281. return PolygonBuilder.CreatePolygon(name, options, scene, earcutInjection);
  77282. };
  77283. return PolygonBuilder;
  77284. }());
  77285. /***/ }),
  77286. /***/ "./Meshes/Builders/polyhedronBuilder.ts":
  77287. /*!**********************************************!*\
  77288. !*** ./Meshes/Builders/polyhedronBuilder.ts ***!
  77289. \**********************************************/
  77290. /*! exports provided: PolyhedronBuilder */
  77291. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77292. "use strict";
  77293. __webpack_require__.r(__webpack_exports__);
  77294. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return PolyhedronBuilder; });
  77295. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77296. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77297. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77298. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron = function (options) {
  77299. // provided polyhedron types :
  77300. // 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  77301. // 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)
  77302. var polyhedra = [];
  77303. 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]] };
  77304. 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]] };
  77305. polyhedra[2] = {
  77306. 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]],
  77307. 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]]
  77308. };
  77309. polyhedra[3] = {
  77310. 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]],
  77311. 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]]
  77312. };
  77313. polyhedra[4] = {
  77314. 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]],
  77315. 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]]
  77316. };
  77317. 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]] };
  77318. 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]] };
  77319. 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]] };
  77320. 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]] };
  77321. 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]] };
  77322. 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]] };
  77323. 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]] };
  77324. 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]] };
  77325. 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]] };
  77326. polyhedra[14] = {
  77327. 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]],
  77328. 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]]
  77329. };
  77330. var type = options.type && (options.type < 0 || options.type >= polyhedra.length) ? 0 : options.type || 0;
  77331. var size = options.size;
  77332. var sizeX = options.sizeX || size || 1;
  77333. var sizeY = options.sizeY || size || 1;
  77334. var sizeZ = options.sizeZ || size || 1;
  77335. var data = options.custom || polyhedra[type];
  77336. var nbfaces = data.face.length;
  77337. var faceUV = options.faceUV || new Array(nbfaces);
  77338. var faceColors = options.faceColors;
  77339. var flat = (options.flat === undefined) ? true : options.flat;
  77340. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  77341. var positions = new Array();
  77342. var indices = new Array();
  77343. var normals = new Array();
  77344. var uvs = new Array();
  77345. var colors = new Array();
  77346. var index = 0;
  77347. var faceIdx = 0; // face cursor in the array "indexes"
  77348. var indexes = new Array();
  77349. var i = 0;
  77350. var f = 0;
  77351. var u, v, ang, x, y, tmp;
  77352. // default face colors and UV if undefined
  77353. if (flat) {
  77354. for (f = 0; f < nbfaces; f++) {
  77355. if (faceColors && faceColors[f] === undefined) {
  77356. faceColors[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1, 1, 1, 1);
  77357. }
  77358. if (faceUV && faceUV[f] === undefined) {
  77359. faceUV[f] = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0, 0, 1, 1);
  77360. }
  77361. }
  77362. }
  77363. if (!flat) {
  77364. for (i = 0; i < data.vertex.length; i++) {
  77365. positions.push(data.vertex[i][0] * sizeX, data.vertex[i][1] * sizeY, data.vertex[i][2] * sizeZ);
  77366. uvs.push(0, 0);
  77367. }
  77368. for (f = 0; f < nbfaces; f++) {
  77369. for (i = 0; i < data.face[f].length - 2; i++) {
  77370. indices.push(data.face[f][0], data.face[f][i + 2], data.face[f][i + 1]);
  77371. }
  77372. }
  77373. }
  77374. else {
  77375. for (f = 0; f < nbfaces; f++) {
  77376. var fl = data.face[f].length; // number of vertices of the current face
  77377. ang = 2 * Math.PI / fl;
  77378. x = 0.5 * Math.tan(ang / 2);
  77379. y = 0.5;
  77380. // positions, uvs, colors
  77381. for (i = 0; i < fl; i++) {
  77382. // positions
  77383. 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);
  77384. indexes.push(index);
  77385. index++;
  77386. // uvs
  77387. u = faceUV[f].x + (faceUV[f].z - faceUV[f].x) * (0.5 + x);
  77388. v = faceUV[f].y + (faceUV[f].w - faceUV[f].y) * (y - 0.5);
  77389. uvs.push(u, v);
  77390. tmp = x * Math.cos(ang) - y * Math.sin(ang);
  77391. y = x * Math.sin(ang) + y * Math.cos(ang);
  77392. x = tmp;
  77393. // colors
  77394. if (faceColors) {
  77395. colors.push(faceColors[f].r, faceColors[f].g, faceColors[f].b, faceColors[f].a);
  77396. }
  77397. }
  77398. // indices from indexes
  77399. for (i = 0; i < fl - 2; i++) {
  77400. indices.push(indexes[0 + faceIdx], indexes[i + 2 + faceIdx], indexes[i + 1 + faceIdx]);
  77401. }
  77402. faceIdx += fl;
  77403. }
  77404. }
  77405. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  77406. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77407. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  77408. vertexData.positions = positions;
  77409. vertexData.indices = indices;
  77410. vertexData.normals = normals;
  77411. vertexData.uvs = uvs;
  77412. if (faceColors && flat) {
  77413. vertexData.colors = colors;
  77414. }
  77415. return vertexData;
  77416. };
  77417. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreatePolyhedron = function (name, options, scene) {
  77418. return PolyhedronBuilder.CreatePolyhedron(name, options, scene);
  77419. };
  77420. /**
  77421. * Class containing static functions to help procedurally build meshes
  77422. */
  77423. var PolyhedronBuilder = /** @class */ (function () {
  77424. function PolyhedronBuilder() {
  77425. }
  77426. /**
  77427. * Creates a polyhedron mesh
  77428. * * 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
  77429. * * The parameter `size` (positive float, default 1) sets the polygon size
  77430. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  77431. * * 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`
  77432. * * 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
  77433. * * 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)`)
  77434. * * 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
  77435. * * 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
  77436. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77437. * * 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
  77438. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77439. * @param name defines the name of the mesh
  77440. * @param options defines the options used to create the mesh
  77441. * @param scene defines the hosting scene
  77442. * @returns the polyhedron mesh
  77443. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  77444. */
  77445. PolyhedronBuilder.CreatePolyhedron = function (name, options, scene) {
  77446. var polyhedron = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77447. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77448. polyhedron._originalBuilderSideOrientation = options.sideOrientation;
  77449. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreatePolyhedron(options);
  77450. vertexData.applyToMesh(polyhedron, options.updatable);
  77451. return polyhedron;
  77452. };
  77453. return PolyhedronBuilder;
  77454. }());
  77455. /***/ }),
  77456. /***/ "./Meshes/Builders/ribbonBuilder.ts":
  77457. /*!******************************************!*\
  77458. !*** ./Meshes/Builders/ribbonBuilder.ts ***!
  77459. \******************************************/
  77460. /*! exports provided: RibbonBuilder */
  77461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77462. "use strict";
  77463. __webpack_require__.r(__webpack_exports__);
  77464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return RibbonBuilder; });
  77465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77466. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77467. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../buffer */ "./Meshes/buffer.ts");
  77468. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  77469. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  77470. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon = function (options) {
  77471. var pathArray = options.pathArray;
  77472. var closeArray = options.closeArray || false;
  77473. var closePath = options.closePath || false;
  77474. var invertUV = options.invertUV || false;
  77475. var defaultOffset = Math.floor(pathArray[0].length / 2);
  77476. var offset = options.offset || defaultOffset;
  77477. offset = offset > defaultOffset ? defaultOffset : Math.floor(offset); // offset max allowed : defaultOffset
  77478. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].DEFAULTSIDE;
  77479. var customUV = options.uvs;
  77480. var customColors = options.colors;
  77481. var positions = [];
  77482. var indices = [];
  77483. var normals = [];
  77484. var uvs = [];
  77485. var us = []; // us[path_id] = [uDist1, uDist2, uDist3 ... ] distances between points on path path_id
  77486. var vs = []; // vs[i] = [vDist1, vDist2, vDist3, ... ] distances between points i of consecutives paths from pathArray
  77487. var uTotalDistance = []; // uTotalDistance[p] : total distance of path p
  77488. var vTotalDistance = []; // vTotalDistance[i] : total distance between points i of first and last path from pathArray
  77489. var minlg; // minimal length among all paths from pathArray
  77490. var lg = []; // array of path lengths : nb of vertex per path
  77491. var idx = []; // array of path indexes : index of each path (first vertex) in the total vertex number
  77492. var p; // path iterator
  77493. var i; // point iterator
  77494. var j; // point iterator
  77495. // if single path in pathArray
  77496. if (pathArray.length < 2) {
  77497. var ar1 = [];
  77498. var ar2 = [];
  77499. for (i = 0; i < pathArray[0].length - offset; i++) {
  77500. ar1.push(pathArray[0][i]);
  77501. ar2.push(pathArray[0][i + offset]);
  77502. }
  77503. pathArray = [ar1, ar2];
  77504. }
  77505. // positions and horizontal distances (u)
  77506. var idc = 0;
  77507. var closePathCorr = (closePath) ? 1 : 0; // the final index will be +1 if closePath
  77508. var path;
  77509. var l;
  77510. minlg = pathArray[0].length;
  77511. var vectlg;
  77512. var dist;
  77513. for (p = 0; p < pathArray.length; p++) {
  77514. uTotalDistance[p] = 0;
  77515. us[p] = [0];
  77516. path = pathArray[p];
  77517. l = path.length;
  77518. minlg = (minlg < l) ? minlg : l;
  77519. j = 0;
  77520. while (j < l) {
  77521. positions.push(path[j].x, path[j].y, path[j].z);
  77522. if (j > 0) {
  77523. vectlg = path[j].subtract(path[j - 1]).length();
  77524. dist = vectlg + uTotalDistance[p];
  77525. us[p].push(dist);
  77526. uTotalDistance[p] = dist;
  77527. }
  77528. j++;
  77529. }
  77530. if (closePath) { // an extra hidden vertex is added in the "positions" array
  77531. j--;
  77532. positions.push(path[0].x, path[0].y, path[0].z);
  77533. vectlg = path[j].subtract(path[0]).length();
  77534. dist = vectlg + uTotalDistance[p];
  77535. us[p].push(dist);
  77536. uTotalDistance[p] = dist;
  77537. }
  77538. lg[p] = l + closePathCorr;
  77539. idx[p] = idc;
  77540. idc += (l + closePathCorr);
  77541. }
  77542. // vertical distances (v)
  77543. var path1;
  77544. var path2;
  77545. var vertex1 = null;
  77546. var vertex2 = null;
  77547. for (i = 0; i < minlg + closePathCorr; i++) {
  77548. vTotalDistance[i] = 0;
  77549. vs[i] = [0];
  77550. for (p = 0; p < pathArray.length - 1; p++) {
  77551. path1 = pathArray[p];
  77552. path2 = pathArray[p + 1];
  77553. if (i === minlg) { // closePath
  77554. vertex1 = path1[0];
  77555. vertex2 = path2[0];
  77556. }
  77557. else {
  77558. vertex1 = path1[i];
  77559. vertex2 = path2[i];
  77560. }
  77561. vectlg = vertex2.subtract(vertex1).length();
  77562. dist = vectlg + vTotalDistance[i];
  77563. vs[i].push(dist);
  77564. vTotalDistance[i] = dist;
  77565. }
  77566. if (closeArray && vertex2 && vertex1) {
  77567. path1 = pathArray[p];
  77568. path2 = pathArray[0];
  77569. if (i === minlg) { // closePath
  77570. vertex2 = path2[0];
  77571. }
  77572. vectlg = vertex2.subtract(vertex1).length();
  77573. dist = vectlg + vTotalDistance[i];
  77574. vTotalDistance[i] = dist;
  77575. }
  77576. }
  77577. // uvs
  77578. var u;
  77579. var v;
  77580. if (customUV) {
  77581. for (p = 0; p < customUV.length; p++) {
  77582. uvs.push(customUV[p].x, customUV[p].y);
  77583. }
  77584. }
  77585. else {
  77586. for (p = 0; p < pathArray.length; p++) {
  77587. for (i = 0; i < minlg + closePathCorr; i++) {
  77588. u = (uTotalDistance[p] != 0.0) ? us[p][i] / uTotalDistance[p] : 0.0;
  77589. v = (vTotalDistance[i] != 0.0) ? vs[i][p] / vTotalDistance[i] : 0.0;
  77590. if (invertUV) {
  77591. uvs.push(v, u);
  77592. }
  77593. else {
  77594. uvs.push(u, v);
  77595. }
  77596. }
  77597. }
  77598. }
  77599. // indices
  77600. p = 0; // path index
  77601. var pi = 0; // positions array index
  77602. var l1 = lg[p] - 1; // path1 length
  77603. var l2 = lg[p + 1] - 1; // path2 length
  77604. var min = (l1 < l2) ? l1 : l2; // current path stop index
  77605. var shft = idx[1] - idx[0]; // shift
  77606. var path1nb = closeArray ? lg.length : lg.length - 1; // number of path1 to iterate on
  77607. while (pi <= min && p < path1nb) { // stay under min and don't go over next to last path
  77608. // 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
  77609. indices.push(pi, pi + shft, pi + 1);
  77610. indices.push(pi + shft + 1, pi + 1, pi + shft);
  77611. pi += 1;
  77612. if (pi === min) { // if end of one of two consecutive paths reached, go to next existing path
  77613. p++;
  77614. if (p === lg.length - 1) { // last path of pathArray reached <=> closeArray == true
  77615. shft = idx[0] - idx[p];
  77616. l1 = lg[p] - 1;
  77617. l2 = lg[0] - 1;
  77618. }
  77619. else {
  77620. shft = idx[p + 1] - idx[p];
  77621. l1 = lg[p] - 1;
  77622. l2 = lg[p + 1] - 1;
  77623. }
  77624. pi = idx[p];
  77625. min = (l1 < l2) ? l1 + pi : l2 + pi;
  77626. }
  77627. }
  77628. // normals
  77629. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals);
  77630. if (closePath) { // update both the first and last vertex normals to their average value
  77631. var indexFirst = 0;
  77632. var indexLast = 0;
  77633. for (p = 0; p < pathArray.length; p++) {
  77634. indexFirst = idx[p] * 3;
  77635. if (p + 1 < pathArray.length) {
  77636. indexLast = (idx[p + 1] - 1) * 3;
  77637. }
  77638. else {
  77639. indexLast = normals.length - 3;
  77640. }
  77641. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77642. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77643. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77644. normals[indexLast] = normals[indexFirst];
  77645. normals[indexLast + 1] = normals[indexFirst + 1];
  77646. normals[indexLast + 2] = normals[indexFirst + 2];
  77647. }
  77648. }
  77649. // sides
  77650. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  77651. // Colors
  77652. var colors = null;
  77653. if (customColors) {
  77654. colors = new Float32Array(customColors.length * 4);
  77655. for (var c = 0; c < customColors.length; c++) {
  77656. colors[c * 4] = customColors[c].r;
  77657. colors[c * 4 + 1] = customColors[c].g;
  77658. colors[c * 4 + 2] = customColors[c].b;
  77659. colors[c * 4 + 3] = customColors[c].a;
  77660. }
  77661. }
  77662. // Result
  77663. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"]();
  77664. var positions32 = new Float32Array(positions);
  77665. var normals32 = new Float32Array(normals);
  77666. var uvs32 = new Float32Array(uvs);
  77667. vertexData.indices = indices;
  77668. vertexData.positions = positions32;
  77669. vertexData.normals = normals32;
  77670. vertexData.uvs = uvs32;
  77671. if (colors) {
  77672. vertexData.set(colors, _buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77673. }
  77674. if (closePath) {
  77675. vertexData._idx = idx;
  77676. }
  77677. return vertexData;
  77678. };
  77679. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  77680. if (closeArray === void 0) { closeArray = false; }
  77681. if (updatable === void 0) { updatable = false; }
  77682. return RibbonBuilder.CreateRibbon(name, {
  77683. pathArray: pathArray,
  77684. closeArray: closeArray,
  77685. closePath: closePath,
  77686. offset: offset,
  77687. updatable: updatable,
  77688. sideOrientation: sideOrientation,
  77689. instance: instance
  77690. }, scene);
  77691. };
  77692. /**
  77693. * Class containing static functions to help procedurally build meshes
  77694. */
  77695. var RibbonBuilder = /** @class */ (function () {
  77696. function RibbonBuilder() {
  77697. }
  77698. /**
  77699. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  77700. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  77701. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  77702. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  77703. * * 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
  77704. * * 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
  77705. * * 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
  77706. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77707. * * 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
  77708. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77709. * * 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
  77710. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  77711. * * 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
  77712. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  77713. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77714. * @param name defines the name of the mesh
  77715. * @param options defines the options used to create the mesh
  77716. * @param scene defines the hosting scene
  77717. * @returns the ribbon mesh
  77718. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  77719. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77720. */
  77721. RibbonBuilder.CreateRibbon = function (name, options, scene) {
  77722. if (scene === void 0) { scene = null; }
  77723. var pathArray = options.pathArray;
  77724. var closeArray = options.closeArray;
  77725. var closePath = options.closePath;
  77726. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77727. var instance = options.instance;
  77728. var updatable = options.updatable;
  77729. if (instance) { // existing ribbon instance update
  77730. // positionFunction : ribbon case
  77731. // only pathArray and sideOrientation parameters are taken into account for positions update
  77732. var minimum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0].setAll(Number.MAX_VALUE);
  77733. var maximum_1 = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1].setAll(-Number.MAX_VALUE);
  77734. var positionFunction = function (positions) {
  77735. var minlg = pathArray[0].length;
  77736. var mesh = instance;
  77737. var i = 0;
  77738. var ns = (mesh._originalBuilderSideOrientation === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].DOUBLESIDE) ? 2 : 1;
  77739. for (var si = 1; si <= ns; ++si) {
  77740. for (var p = 0; p < pathArray.length; ++p) {
  77741. var path = pathArray[p];
  77742. var l = path.length;
  77743. minlg = (minlg < l) ? minlg : l;
  77744. for (var j = 0; j < minlg; ++j) {
  77745. var pathPoint = path[j];
  77746. positions[i] = pathPoint.x;
  77747. positions[i + 1] = pathPoint.y;
  77748. positions[i + 2] = pathPoint.z;
  77749. minimum_1.minimizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77750. maximum_1.maximizeInPlaceFromFloats(pathPoint.x, pathPoint.y, pathPoint.z);
  77751. i += 3;
  77752. }
  77753. if (mesh._creationDataStorage && mesh._creationDataStorage.closePath) {
  77754. var pathPoint = path[0];
  77755. positions[i] = pathPoint.x;
  77756. positions[i + 1] = pathPoint.y;
  77757. positions[i + 2] = pathPoint.z;
  77758. i += 3;
  77759. }
  77760. }
  77761. }
  77762. };
  77763. var positions = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  77764. positionFunction(positions);
  77765. if (instance._boundingInfo) {
  77766. instance._boundingInfo.reConstruct(minimum_1, maximum_1, instance._worldMatrix);
  77767. }
  77768. else {
  77769. instance._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](minimum_1, maximum_1, instance._worldMatrix);
  77770. }
  77771. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positions, false, false);
  77772. if (options.colors) {
  77773. var colors = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  77774. for (var c = 0, colorIndex = 0; c < options.colors.length; c++, colorIndex += 4) {
  77775. var color = options.colors[c];
  77776. colors[colorIndex] = color.r;
  77777. colors[colorIndex + 1] = color.g;
  77778. colors[colorIndex + 2] = color.b;
  77779. colors[colorIndex + 3] = color.a;
  77780. }
  77781. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colors, false, false);
  77782. }
  77783. if (options.uvs) {
  77784. var uvs = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  77785. for (var i = 0; i < options.uvs.length; i++) {
  77786. uvs[i * 2] = options.uvs[i].x;
  77787. uvs[i * 2 + 1] = options.uvs[i].y;
  77788. }
  77789. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvs, false, false);
  77790. }
  77791. if (!instance.areNormalsFrozen || instance.isFacetDataEnabled) {
  77792. var indices = instance.getIndices();
  77793. var normals = instance.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind);
  77794. var params = instance.isFacetDataEnabled ? instance.getFacetDataParameters() : null;
  77795. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].ComputeNormals(positions, indices, normals, params);
  77796. if (instance._creationDataStorage && instance._creationDataStorage.closePath) {
  77797. var indexFirst = 0;
  77798. var indexLast = 0;
  77799. for (var p = 0; p < pathArray.length; p++) {
  77800. indexFirst = instance._creationDataStorage.idx[p] * 3;
  77801. if (p + 1 < pathArray.length) {
  77802. indexLast = (instance._creationDataStorage.idx[p + 1] - 1) * 3;
  77803. }
  77804. else {
  77805. indexLast = normals.length - 3;
  77806. }
  77807. normals[indexFirst] = (normals[indexFirst] + normals[indexLast]) * 0.5;
  77808. normals[indexFirst + 1] = (normals[indexFirst + 1] + normals[indexLast + 1]) * 0.5;
  77809. normals[indexFirst + 2] = (normals[indexFirst + 2] + normals[indexLast + 2]) * 0.5;
  77810. normals[indexLast] = normals[indexFirst];
  77811. normals[indexLast + 1] = normals[indexFirst + 1];
  77812. normals[indexLast + 2] = normals[indexFirst + 2];
  77813. }
  77814. }
  77815. if (!(instance.areNormalsFrozen)) {
  77816. instance.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normals, false, false);
  77817. }
  77818. }
  77819. return instance;
  77820. }
  77821. else { // new ribbon creation
  77822. var ribbon = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  77823. ribbon._originalBuilderSideOrientation = sideOrientation;
  77824. ribbon._creationDataStorage = new _mesh__WEBPACK_IMPORTED_MODULE_1__["_CreationDataStorage"]();
  77825. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateRibbon(options);
  77826. if (closePath) {
  77827. ribbon._creationDataStorage.idx = vertexData._idx;
  77828. }
  77829. ribbon._creationDataStorage.closePath = closePath;
  77830. ribbon._creationDataStorage.closeArray = closeArray;
  77831. vertexData.applyToMesh(ribbon, updatable);
  77832. return ribbon;
  77833. }
  77834. };
  77835. return RibbonBuilder;
  77836. }());
  77837. /***/ }),
  77838. /***/ "./Meshes/Builders/shapeBuilder.ts":
  77839. /*!*****************************************!*\
  77840. !*** ./Meshes/Builders/shapeBuilder.ts ***!
  77841. \*****************************************/
  77842. /*! exports provided: ShapeBuilder */
  77843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  77844. "use strict";
  77845. __webpack_require__.r(__webpack_exports__);
  77846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return ShapeBuilder; });
  77847. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  77848. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  77849. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  77850. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  77851. if (scene === void 0) { scene = null; }
  77852. var options = {
  77853. shape: shape,
  77854. path: path,
  77855. scale: scale,
  77856. rotation: rotation,
  77857. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77858. sideOrientation: sideOrientation,
  77859. instance: instance,
  77860. updatable: updatable
  77861. };
  77862. return ShapeBuilder.ExtrudeShape(name, options, scene);
  77863. };
  77864. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  77865. var options = {
  77866. shape: shape,
  77867. path: path,
  77868. scaleFunction: scaleFunction,
  77869. rotationFunction: rotationFunction,
  77870. ribbonCloseArray: ribbonCloseArray,
  77871. ribbonClosePath: ribbonClosePath,
  77872. cap: (cap === 0) ? 0 : cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP,
  77873. sideOrientation: sideOrientation,
  77874. instance: instance,
  77875. updatable: updatable
  77876. };
  77877. return ShapeBuilder.ExtrudeShapeCustom(name, options, scene);
  77878. };
  77879. /**
  77880. * Class containing static functions to help procedurally build meshes
  77881. */
  77882. var ShapeBuilder = /** @class */ (function () {
  77883. function ShapeBuilder() {
  77884. }
  77885. /**
  77886. * 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.
  77887. * * 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.
  77888. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77889. * * 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.
  77890. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  77891. * * 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
  77892. * * 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
  77893. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  77894. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77895. * * 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
  77896. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  77897. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  77898. * @param name defines the name of the mesh
  77899. * @param options defines the options used to create the mesh
  77900. * @param scene defines the hosting scene
  77901. * @returns the extruded shape mesh
  77902. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77903. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77904. */
  77905. ShapeBuilder.ExtrudeShape = function (name, options, scene) {
  77906. if (scene === void 0) { scene = null; }
  77907. var path = options.path;
  77908. var shape = options.shape;
  77909. var scale = options.scale || 1;
  77910. var rotation = options.rotation || 0;
  77911. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77912. var updatable = options.updatable;
  77913. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77914. var instance = options.instance || null;
  77915. var invertUV = options.invertUV || false;
  77916. 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);
  77917. };
  77918. /**
  77919. * Creates an custom extruded shape mesh.
  77920. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  77921. * * 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.
  77922. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  77923. * * 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
  77924. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  77925. * * 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
  77926. * * It must returns a float value that will be the scale value applied to the shape on each path point
  77927. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  77928. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  77929. * * 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
  77930. * * 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
  77931. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  77932. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  77933. * * 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
  77934. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  77935. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  77936. * @param name defines the name of the mesh
  77937. * @param options defines the options used to create the mesh
  77938. * @param scene defines the hosting scene
  77939. * @returns the custom extruded shape mesh
  77940. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  77941. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  77942. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  77943. */
  77944. ShapeBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  77945. var path = options.path;
  77946. var shape = options.shape;
  77947. var scaleFunction = options.scaleFunction || (function () { return 1; });
  77948. var rotationFunction = options.rotationFunction || (function () { return 0; });
  77949. var ribbonCloseArray = options.ribbonCloseArray || false;
  77950. var ribbonClosePath = options.ribbonClosePath || false;
  77951. var cap = (options.cap === 0) ? 0 : options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  77952. var updatable = options.updatable;
  77953. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  77954. var instance = options.instance;
  77955. var invertUV = options.invertUV || false;
  77956. 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);
  77957. };
  77958. ShapeBuilder._ExtrudeShapeGeneric = function (name, shape, curve, scale, rotation, scaleFunction, rotateFunction, rbCA, rbCP, cap, custom, scene, updtbl, side, instance, invertUV, frontUVs, backUVs) {
  77959. // extrusion geometry
  77960. var extrusionPathArray = function (shape, curve, path3D, shapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom) {
  77961. var tangents = path3D.getTangents();
  77962. var normals = path3D.getNormals();
  77963. var binormals = path3D.getBinormals();
  77964. var distances = path3D.getDistances();
  77965. var angle = 0;
  77966. var returnScale = function () { return scale !== null ? scale : 1; };
  77967. var returnRotation = function () { return rotation !== null ? rotation : 0; };
  77968. var rotate = custom && rotateFunction ? rotateFunction : returnRotation;
  77969. var scl = custom && scaleFunction ? scaleFunction : returnScale;
  77970. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  77971. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  77972. for (var i = 0; i < curve.length; i++) {
  77973. var shapePath = new Array();
  77974. var angleStep = rotate(i, distances[i]);
  77975. var scaleRatio = scl(i, distances[i]);
  77976. for (var p = 0; p < shape.length; p++) {
  77977. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], angle, rotationMatrix);
  77978. var planed = ((tangents[i].scale(shape[p].z)).add(normals[i].scale(shape[p].x)).add(binormals[i].scale(shape[p].y)));
  77979. var rotated = shapePath[p] ? shapePath[p] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77980. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(planed, rotationMatrix, rotated);
  77981. rotated.scaleInPlace(scaleRatio).addInPlace(curve[i]);
  77982. shapePath[p] = rotated;
  77983. }
  77984. shapePaths[index] = shapePath;
  77985. angle += angleStep;
  77986. index++;
  77987. }
  77988. // cap
  77989. var capPath = function (shapePath) {
  77990. var pointCap = Array();
  77991. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  77992. var i;
  77993. for (i = 0; i < shapePath.length; i++) {
  77994. barycenter.addInPlace(shapePath[i]);
  77995. }
  77996. barycenter.scaleInPlace(1.0 / shapePath.length);
  77997. for (i = 0; i < shapePath.length; i++) {
  77998. pointCap.push(barycenter);
  77999. }
  78000. return pointCap;
  78001. };
  78002. switch (cap) {
  78003. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78004. break;
  78005. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78006. shapePaths[0] = capPath(shapePaths[2]);
  78007. shapePaths[1] = shapePaths[2];
  78008. break;
  78009. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78010. shapePaths[index] = shapePaths[index - 1];
  78011. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  78012. break;
  78013. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78014. shapePaths[0] = capPath(shapePaths[2]);
  78015. shapePaths[1] = shapePaths[2];
  78016. shapePaths[index] = shapePaths[index - 1];
  78017. shapePaths[index + 1] = capPath(shapePaths[index - 1]);
  78018. break;
  78019. default:
  78020. break;
  78021. }
  78022. return shapePaths;
  78023. };
  78024. var path3D;
  78025. var pathArray;
  78026. if (instance) { // instance update
  78027. var storage = instance._creationDataStorage;
  78028. path3D = storage.path3D.update(curve);
  78029. pathArray = extrusionPathArray(shape, curve, storage.path3D, storage.pathArray, scale, rotation, scaleFunction, rotateFunction, storage.cap, custom);
  78030. instance = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateRibbon("", pathArray, false, false, 0, scene || undefined, false, 0, instance);
  78031. return instance;
  78032. }
  78033. // extruded shape creation
  78034. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](curve);
  78035. var newShapePaths = new Array();
  78036. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78037. pathArray = extrusionPathArray(shape, curve, path3D, newShapePaths, scale, rotation, scaleFunction, rotateFunction, cap, custom);
  78038. 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);
  78039. extrudedGeneric._creationDataStorage.pathArray = pathArray;
  78040. extrudedGeneric._creationDataStorage.path3D = path3D;
  78041. extrudedGeneric._creationDataStorage.cap = cap;
  78042. return extrudedGeneric;
  78043. };
  78044. return ShapeBuilder;
  78045. }());
  78046. /***/ }),
  78047. /***/ "./Meshes/Builders/sphereBuilder.ts":
  78048. /*!******************************************!*\
  78049. !*** ./Meshes/Builders/sphereBuilder.ts ***!
  78050. \******************************************/
  78051. /*! exports provided: SphereBuilder */
  78052. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78053. "use strict";
  78054. __webpack_require__.r(__webpack_exports__);
  78055. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return SphereBuilder; });
  78056. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78057. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78058. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78059. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere = function (options) {
  78060. var segments = options.segments || 32;
  78061. var diameterX = options.diameterX || options.diameter || 1;
  78062. var diameterY = options.diameterY || options.diameter || 1;
  78063. var diameterZ = options.diameterZ || options.diameter || 1;
  78064. var arc = options.arc && (options.arc <= 0 || options.arc > 1) ? 1.0 : options.arc || 1.0;
  78065. var slice = options.slice && (options.slice <= 0) ? 1.0 : options.slice || 1.0;
  78066. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78067. var radius = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](diameterX / 2, diameterY / 2, diameterZ / 2);
  78068. var totalZRotationSteps = 2 + segments;
  78069. var totalYRotationSteps = 2 * totalZRotationSteps;
  78070. var indices = [];
  78071. var positions = [];
  78072. var normals = [];
  78073. var uvs = [];
  78074. for (var zRotationStep = 0; zRotationStep <= totalZRotationSteps; zRotationStep++) {
  78075. var normalizedZ = zRotationStep / totalZRotationSteps;
  78076. var angleZ = normalizedZ * Math.PI * slice;
  78077. for (var yRotationStep = 0; yRotationStep <= totalYRotationSteps; yRotationStep++) {
  78078. var normalizedY = yRotationStep / totalYRotationSteps;
  78079. var angleY = normalizedY * Math.PI * 2 * arc;
  78080. var rotationZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationZ(-angleZ);
  78081. var rotationY = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationY(angleY);
  78082. var afterRotZ = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Up(), rotationZ);
  78083. var complete = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(afterRotZ, rotationY);
  78084. var vertex = complete.multiply(radius);
  78085. var normal = complete.divide(radius).normalize();
  78086. positions.push(vertex.x, vertex.y, vertex.z);
  78087. normals.push(normal.x, normal.y, normal.z);
  78088. uvs.push(normalizedY, normalizedZ);
  78089. }
  78090. if (zRotationStep > 0) {
  78091. var verticesCount = positions.length / 3;
  78092. for (var firstIndex = verticesCount - 2 * (totalYRotationSteps + 1); (firstIndex + totalYRotationSteps + 2) < verticesCount; firstIndex++) {
  78093. indices.push((firstIndex));
  78094. indices.push((firstIndex + 1));
  78095. indices.push(firstIndex + totalYRotationSteps + 1);
  78096. indices.push((firstIndex + totalYRotationSteps + 1));
  78097. indices.push((firstIndex + 1));
  78098. indices.push((firstIndex + totalYRotationSteps + 2));
  78099. }
  78100. }
  78101. }
  78102. // Sides
  78103. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78104. // Result
  78105. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78106. vertexData.indices = indices;
  78107. vertexData.positions = positions;
  78108. vertexData.normals = normals;
  78109. vertexData.uvs = uvs;
  78110. return vertexData;
  78111. };
  78112. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  78113. var options = {
  78114. segments: segments,
  78115. diameterX: diameter,
  78116. diameterY: diameter,
  78117. diameterZ: diameter,
  78118. sideOrientation: sideOrientation,
  78119. updatable: updatable
  78120. };
  78121. return SphereBuilder.CreateSphere(name, options, scene);
  78122. };
  78123. /**
  78124. * Class containing static functions to help procedurally build meshes
  78125. */
  78126. var SphereBuilder = /** @class */ (function () {
  78127. function SphereBuilder() {
  78128. }
  78129. /**
  78130. * Creates a sphere mesh
  78131. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  78132. * * 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`)
  78133. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  78134. * * 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
  78135. * * 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)
  78136. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78137. * * 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
  78138. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78139. * @param name defines the name of the mesh
  78140. * @param options defines the options used to create the mesh
  78141. * @param scene defines the hosting scene
  78142. * @returns the sphere mesh
  78143. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  78144. */
  78145. SphereBuilder.CreateSphere = function (name, options, scene) {
  78146. var sphere = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78147. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78148. sphere._originalBuilderSideOrientation = options.sideOrientation;
  78149. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateSphere(options);
  78150. vertexData.applyToMesh(sphere, options.updatable);
  78151. return sphere;
  78152. };
  78153. return SphereBuilder;
  78154. }());
  78155. /***/ }),
  78156. /***/ "./Meshes/Builders/torusBuilder.ts":
  78157. /*!*****************************************!*\
  78158. !*** ./Meshes/Builders/torusBuilder.ts ***!
  78159. \*****************************************/
  78160. /*! exports provided: TorusBuilder */
  78161. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78162. "use strict";
  78163. __webpack_require__.r(__webpack_exports__);
  78164. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return TorusBuilder; });
  78165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78166. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78167. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78168. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus = function (options) {
  78169. var indices = [];
  78170. var positions = [];
  78171. var normals = [];
  78172. var uvs = [];
  78173. var diameter = options.diameter || 1;
  78174. var thickness = options.thickness || 0.5;
  78175. var tessellation = options.tessellation || 16;
  78176. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78177. var stride = tessellation + 1;
  78178. for (var i = 0; i <= tessellation; i++) {
  78179. var u = i / tessellation;
  78180. var outerAngle = i * Math.PI * 2.0 / tessellation - Math.PI / 2.0;
  78181. 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));
  78182. for (var j = 0; j <= tessellation; j++) {
  78183. var v = 1 - j / tessellation;
  78184. var innerAngle = j * Math.PI * 2.0 / tessellation + Math.PI;
  78185. var dx = Math.cos(innerAngle);
  78186. var dy = Math.sin(innerAngle);
  78187. // Create a vertex.
  78188. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](dx, dy, 0);
  78189. var position = normal.scale(thickness / 2);
  78190. var textureCoordinate = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](u, v);
  78191. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(position, transform);
  78192. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, transform);
  78193. positions.push(position.x, position.y, position.z);
  78194. normals.push(normal.x, normal.y, normal.z);
  78195. uvs.push(textureCoordinate.x, textureCoordinate.y);
  78196. // And create indices for two triangles.
  78197. var nextI = (i + 1) % stride;
  78198. var nextJ = (j + 1) % stride;
  78199. indices.push(i * stride + j);
  78200. indices.push(i * stride + nextJ);
  78201. indices.push(nextI * stride + j);
  78202. indices.push(i * stride + nextJ);
  78203. indices.push(nextI * stride + nextJ);
  78204. indices.push(nextI * stride + j);
  78205. }
  78206. }
  78207. // Sides
  78208. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78209. // Result
  78210. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78211. vertexData.indices = indices;
  78212. vertexData.positions = positions;
  78213. vertexData.normals = normals;
  78214. vertexData.uvs = uvs;
  78215. return vertexData;
  78216. };
  78217. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  78218. var options = {
  78219. diameter: diameter,
  78220. thickness: thickness,
  78221. tessellation: tessellation,
  78222. sideOrientation: sideOrientation,
  78223. updatable: updatable
  78224. };
  78225. return TorusBuilder.CreateTorus(name, options, scene);
  78226. };
  78227. /**
  78228. * Class containing static functions to help procedurally build meshes
  78229. */
  78230. var TorusBuilder = /** @class */ (function () {
  78231. function TorusBuilder() {
  78232. }
  78233. /**
  78234. * Creates a torus mesh
  78235. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  78236. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  78237. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  78238. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78239. * * 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
  78240. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78241. * @param name defines the name of the mesh
  78242. * @param options defines the options used to create the mesh
  78243. * @param scene defines the hosting scene
  78244. * @returns the torus mesh
  78245. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  78246. */
  78247. TorusBuilder.CreateTorus = function (name, options, scene) {
  78248. var torus = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78249. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78250. torus._originalBuilderSideOrientation = options.sideOrientation;
  78251. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorus(options);
  78252. vertexData.applyToMesh(torus, options.updatable);
  78253. return torus;
  78254. };
  78255. return TorusBuilder;
  78256. }());
  78257. /***/ }),
  78258. /***/ "./Meshes/Builders/torusKnotBuilder.ts":
  78259. /*!*********************************************!*\
  78260. !*** ./Meshes/Builders/torusKnotBuilder.ts ***!
  78261. \*********************************************/
  78262. /*! exports provided: TorusKnotBuilder */
  78263. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78264. "use strict";
  78265. __webpack_require__.r(__webpack_exports__);
  78266. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return TorusKnotBuilder; });
  78267. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78268. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78269. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78270. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot = function (options) {
  78271. var indices = new Array();
  78272. var positions = new Array();
  78273. var normals = new Array();
  78274. var uvs = new Array();
  78275. var radius = options.radius || 2;
  78276. var tube = options.tube || 0.5;
  78277. var radialSegments = options.radialSegments || 32;
  78278. var tubularSegments = options.tubularSegments || 32;
  78279. var p = options.p || 2;
  78280. var q = options.q || 3;
  78281. var sideOrientation = (options.sideOrientation === 0) ? 0 : options.sideOrientation || _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].DEFAULTSIDE;
  78282. // Helper
  78283. var getPos = function (angle) {
  78284. var cu = Math.cos(angle);
  78285. var su = Math.sin(angle);
  78286. var quOverP = q / p * angle;
  78287. var cs = Math.cos(quOverP);
  78288. var tx = radius * (2 + cs) * 0.5 * cu;
  78289. var ty = radius * (2 + cs) * su * 0.5;
  78290. var tz = radius * Math.sin(quOverP) * 0.5;
  78291. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](tx, ty, tz);
  78292. };
  78293. // Vertices
  78294. var i;
  78295. var j;
  78296. for (i = 0; i <= radialSegments; i++) {
  78297. var modI = i % radialSegments;
  78298. var u = modI / radialSegments * 2 * p * Math.PI;
  78299. var p1 = getPos(u);
  78300. var p2 = getPos(u + 0.01);
  78301. var tang = p2.subtract(p1);
  78302. var n = p2.add(p1);
  78303. var bitan = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(tang, n);
  78304. n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(bitan, tang);
  78305. bitan.normalize();
  78306. n.normalize();
  78307. for (j = 0; j < tubularSegments; j++) {
  78308. var modJ = j % tubularSegments;
  78309. var v = modJ / tubularSegments * 2 * Math.PI;
  78310. var cx = -tube * Math.cos(v);
  78311. var cy = tube * Math.sin(v);
  78312. positions.push(p1.x + cx * n.x + cy * bitan.x);
  78313. positions.push(p1.y + cx * n.y + cy * bitan.y);
  78314. positions.push(p1.z + cx * n.z + cy * bitan.z);
  78315. uvs.push(i / radialSegments);
  78316. uvs.push(j / tubularSegments);
  78317. }
  78318. }
  78319. for (i = 0; i < radialSegments; i++) {
  78320. for (j = 0; j < tubularSegments; j++) {
  78321. var jNext = (j + 1) % tubularSegments;
  78322. var a = i * tubularSegments + j;
  78323. var b = (i + 1) * tubularSegments + j;
  78324. var c = (i + 1) * tubularSegments + jNext;
  78325. var d = i * tubularSegments + jNext;
  78326. indices.push(d);
  78327. indices.push(b);
  78328. indices.push(a);
  78329. indices.push(d);
  78330. indices.push(c);
  78331. indices.push(b);
  78332. }
  78333. }
  78334. // Normals
  78335. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions, indices, normals);
  78336. // Sides
  78337. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]._ComputeSides(sideOrientation, positions, indices, normals, uvs, options.frontUVs, options.backUVs);
  78338. // Result
  78339. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  78340. vertexData.indices = indices;
  78341. vertexData.positions = positions;
  78342. vertexData.normals = normals;
  78343. vertexData.uvs = uvs;
  78344. return vertexData;
  78345. };
  78346. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  78347. var options = {
  78348. radius: radius,
  78349. tube: tube,
  78350. radialSegments: radialSegments,
  78351. tubularSegments: tubularSegments,
  78352. p: p,
  78353. q: q,
  78354. sideOrientation: sideOrientation,
  78355. updatable: updatable
  78356. };
  78357. return TorusKnotBuilder.CreateTorusKnot(name, options, scene);
  78358. };
  78359. /**
  78360. * Class containing static functions to help procedurally build meshes
  78361. */
  78362. var TorusKnotBuilder = /** @class */ (function () {
  78363. function TorusKnotBuilder() {
  78364. }
  78365. /**
  78366. * Creates a torus knot mesh
  78367. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  78368. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  78369. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  78370. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  78371. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78372. * * 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
  78373. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  78374. * @param name defines the name of the mesh
  78375. * @param options defines the options used to create the mesh
  78376. * @param scene defines the hosting scene
  78377. * @returns the torus knot mesh
  78378. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  78379. */
  78380. TorusKnotBuilder.CreateTorusKnot = function (name, options, scene) {
  78381. var torusKnot = new _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"](name, scene);
  78382. options.sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78383. torusKnot._originalBuilderSideOrientation = options.sideOrientation;
  78384. var vertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].CreateTorusKnot(options);
  78385. vertexData.applyToMesh(torusKnot, options.updatable);
  78386. return torusKnot;
  78387. };
  78388. return TorusKnotBuilder;
  78389. }());
  78390. /***/ }),
  78391. /***/ "./Meshes/Builders/tubeBuilder.ts":
  78392. /*!****************************************!*\
  78393. !*** ./Meshes/Builders/tubeBuilder.ts ***!
  78394. \****************************************/
  78395. /*! exports provided: TubeBuilder */
  78396. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78397. "use strict";
  78398. __webpack_require__.r(__webpack_exports__);
  78399. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return TubeBuilder; });
  78400. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  78401. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../mesh */ "./Meshes/mesh.ts");
  78402. /* harmony import */ var _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  78403. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  78404. var options = {
  78405. path: path,
  78406. radius: radius,
  78407. tessellation: tessellation,
  78408. radiusFunction: radiusFunction,
  78409. arc: 1,
  78410. cap: cap,
  78411. updatable: updatable,
  78412. sideOrientation: sideOrientation,
  78413. instance: instance
  78414. };
  78415. return TubeBuilder.CreateTube(name, options, scene);
  78416. };
  78417. /**
  78418. * Class containing static functions to help procedurally build meshes
  78419. */
  78420. var TubeBuilder = /** @class */ (function () {
  78421. function TubeBuilder() {
  78422. }
  78423. /**
  78424. * Creates a tube mesh.
  78425. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  78426. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  78427. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  78428. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  78429. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  78430. * * 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)
  78431. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  78432. * * 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
  78433. * * 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
  78434. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  78435. * * 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
  78436. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  78437. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  78438. * @param name defines the name of the mesh
  78439. * @param options defines the options used to create the mesh
  78440. * @param scene defines the hosting scene
  78441. * @returns the tube mesh
  78442. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  78443. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  78444. */
  78445. TubeBuilder.CreateTube = function (name, options, scene) {
  78446. var path = options.path;
  78447. var instance = options.instance;
  78448. var radius = 1.0;
  78449. if (options.radius !== undefined) {
  78450. radius = options.radius;
  78451. }
  78452. else if (instance) {
  78453. radius = instance._creationDataStorage.radius;
  78454. }
  78455. var tessellation = options.tessellation || 64 | 0;
  78456. var radiusFunction = options.radiusFunction || null;
  78457. var cap = options.cap || _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP;
  78458. var invertUV = options.invertUV || false;
  78459. var updatable = options.updatable;
  78460. var sideOrientation = _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]._GetDefaultSideOrientation(options.sideOrientation);
  78461. options.arc = options.arc && (options.arc <= 0.0 || options.arc > 1.0) ? 1.0 : options.arc || 1.0;
  78462. // tube geometry
  78463. var tubePathArray = function (path, path3D, circlePaths, radius, tessellation, radiusFunction, cap, arc) {
  78464. var tangents = path3D.getTangents();
  78465. var normals = path3D.getNormals();
  78466. var distances = path3D.getDistances();
  78467. var pi2 = Math.PI * 2;
  78468. var step = pi2 / tessellation * arc;
  78469. var returnRadius = function () { return radius; };
  78470. var radiusFunctionFinal = radiusFunction || returnRadius;
  78471. var circlePath;
  78472. var rad;
  78473. var normal;
  78474. var rotated;
  78475. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  78476. var index = (cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP || cap === _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END) ? 0 : 2;
  78477. for (var i = 0; i < path.length; i++) {
  78478. rad = radiusFunctionFinal(i, distances[i]); // current radius
  78479. circlePath = Array(); // current circle array
  78480. normal = normals[i]; // current normal
  78481. for (var t = 0; t < tessellation; t++) {
  78482. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].RotationAxisToRef(tangents[i], step * t, rotationMatrix);
  78483. rotated = circlePath[t] ? circlePath[t] : _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  78484. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(normal, rotationMatrix, rotated);
  78485. rotated.scaleInPlace(rad).addInPlace(path[i]);
  78486. circlePath[t] = rotated;
  78487. }
  78488. circlePaths[index] = circlePath;
  78489. index++;
  78490. }
  78491. // cap
  78492. var capPath = function (nbPoints, pathIndex) {
  78493. var pointCap = Array();
  78494. for (var i = 0; i < nbPoints; i++) {
  78495. pointCap.push(path[pathIndex]);
  78496. }
  78497. return pointCap;
  78498. };
  78499. switch (cap) {
  78500. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].NO_CAP:
  78501. break;
  78502. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_START:
  78503. circlePaths[0] = capPath(tessellation, 0);
  78504. circlePaths[1] = circlePaths[2].slice(0);
  78505. break;
  78506. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_END:
  78507. circlePaths[index] = circlePaths[index - 1].slice(0);
  78508. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78509. break;
  78510. case _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].CAP_ALL:
  78511. circlePaths[0] = capPath(tessellation, 0);
  78512. circlePaths[1] = circlePaths[2].slice(0);
  78513. circlePaths[index] = circlePaths[index - 1].slice(0);
  78514. circlePaths[index + 1] = capPath(tessellation, path.length - 1);
  78515. break;
  78516. default:
  78517. break;
  78518. }
  78519. return circlePaths;
  78520. };
  78521. var path3D;
  78522. var pathArray;
  78523. if (instance) { // tube update
  78524. var storage = instance._creationDataStorage;
  78525. var arc = options.arc || storage.arc;
  78526. path3D = storage.path3D.update(path);
  78527. pathArray = tubePathArray(path, path3D, storage.pathArray, radius, storage.tessellation, radiusFunction, storage.cap, arc);
  78528. instance = _ribbonBuilder__WEBPACK_IMPORTED_MODULE_2__["RibbonBuilder"].CreateRibbon("", { pathArray: pathArray, instance: instance });
  78529. // Update mode, no need to recreate the storage.
  78530. storage.path3D = path3D;
  78531. storage.pathArray = pathArray;
  78532. storage.arc = arc;
  78533. storage.radius = radius;
  78534. return instance;
  78535. }
  78536. // tube creation
  78537. path3D = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Path3D"](path);
  78538. var newPathArray = new Array();
  78539. cap = (cap < 0 || cap > 3) ? 0 : cap;
  78540. pathArray = tubePathArray(path, path3D, newPathArray, radius, tessellation, radiusFunction, cap, options.arc);
  78541. 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);
  78542. tube._creationDataStorage.pathArray = pathArray;
  78543. tube._creationDataStorage.path3D = path3D;
  78544. tube._creationDataStorage.tessellation = tessellation;
  78545. tube._creationDataStorage.cap = cap;
  78546. tube._creationDataStorage.arc = options.arc;
  78547. tube._creationDataStorage.radius = radius;
  78548. return tube;
  78549. };
  78550. return TubeBuilder;
  78551. }());
  78552. /***/ }),
  78553. /***/ "./Meshes/Compression/dracoCompression.ts":
  78554. /*!************************************************!*\
  78555. !*** ./Meshes/Compression/dracoCompression.ts ***!
  78556. \************************************************/
  78557. /*! exports provided: DracoCompression */
  78558. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78559. "use strict";
  78560. __webpack_require__.r(__webpack_exports__);
  78561. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return DracoCompression; });
  78562. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  78563. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78564. /**
  78565. * Draco compression (https://google.github.io/draco/)
  78566. *
  78567. * This class wraps the Draco module.
  78568. *
  78569. * **Encoder**
  78570. *
  78571. * The encoder is not currently implemented.
  78572. *
  78573. * **Decoder**
  78574. *
  78575. * 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.
  78576. *
  78577. * To update the configuration, use the following code:
  78578. * ```javascript
  78579. * DracoCompression.Configuration = {
  78580. * decoder: {
  78581. * wasmUrl: "<url to the WebAssembly library>",
  78582. * wasmBinaryUrl: "<url to the WebAssembly binary>",
  78583. * fallbackUrl: "<url to the fallback JavaScript library>",
  78584. * }
  78585. * };
  78586. * ```
  78587. *
  78588. * 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.
  78589. * Decoding will automatically fallback to the JavaScript version if WebAssembly version is not configured or if WebAssembly is not supported by the browser.
  78590. * Use `DracoCompression.DecoderAvailable` to determine if the decoder is available for the current session.
  78591. *
  78592. * To decode Draco compressed data, create a DracoCompression object and call decodeMeshAsync:
  78593. * ```javascript
  78594. * var dracoCompression = new DracoCompression();
  78595. * var vertexData = await dracoCompression.decodeMeshAsync(data, {
  78596. * [VertexBuffer.PositionKind]: 0
  78597. * });
  78598. * ```
  78599. *
  78600. * @see https://www.babylonjs-playground.com/#N3EK4B#0
  78601. */
  78602. var DracoCompression = /** @class */ (function () {
  78603. /**
  78604. * Constructor
  78605. */
  78606. function DracoCompression() {
  78607. }
  78608. Object.defineProperty(DracoCompression, "DecoderAvailable", {
  78609. /**
  78610. * Returns true if the decoder is available.
  78611. */
  78612. get: function () {
  78613. if (typeof DracoDecoderModule !== "undefined") {
  78614. return true;
  78615. }
  78616. var decoder = DracoCompression.Configuration.decoder;
  78617. if (decoder) {
  78618. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78619. return true;
  78620. }
  78621. if (decoder.fallbackUrl) {
  78622. return true;
  78623. }
  78624. }
  78625. return false;
  78626. },
  78627. enumerable: true,
  78628. configurable: true
  78629. });
  78630. /**
  78631. * Stop all async operations and release resources.
  78632. */
  78633. DracoCompression.prototype.dispose = function () {
  78634. };
  78635. /**
  78636. * Decode Draco compressed mesh data to vertex data.
  78637. * @param data The ArrayBuffer or ArrayBufferView for the Draco compression data
  78638. * @param attributes A map of attributes from vertex buffer kinds to Draco unique ids
  78639. * @returns A promise that resolves with the decoded vertex data
  78640. */
  78641. DracoCompression.prototype.decodeMeshAsync = function (data, attributes) {
  78642. var dataView = data instanceof ArrayBuffer ? new Uint8Array(data) : data;
  78643. return DracoCompression._GetDecoderModule().then(function (wrappedModule) {
  78644. var module = wrappedModule.module;
  78645. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  78646. var buffer = new module.DecoderBuffer();
  78647. buffer.Init(dataView, dataView.byteLength);
  78648. var decoder = new module.Decoder();
  78649. var geometry;
  78650. var status;
  78651. try {
  78652. var type = decoder.GetEncodedGeometryType(buffer);
  78653. switch (type) {
  78654. case module.TRIANGULAR_MESH:
  78655. geometry = new module.Mesh();
  78656. status = decoder.DecodeBufferToMesh(buffer, geometry);
  78657. break;
  78658. case module.POINT_CLOUD:
  78659. geometry = new module.PointCloud();
  78660. status = decoder.DecodeBufferToPointCloud(buffer, geometry);
  78661. break;
  78662. default:
  78663. throw new Error("Invalid geometry type " + type);
  78664. }
  78665. if (!status.ok() || !geometry.ptr) {
  78666. throw new Error(status.error_msg());
  78667. }
  78668. var numPoints = geometry.num_points();
  78669. if (type === module.TRIANGULAR_MESH) {
  78670. var numFaces = geometry.num_faces();
  78671. var faceIndices = new module.DracoInt32Array();
  78672. try {
  78673. var indices = new Uint32Array(numFaces * 3);
  78674. for (var i = 0; i < numFaces; i++) {
  78675. decoder.GetFaceFromMesh(geometry, i, faceIndices);
  78676. var offset = i * 3;
  78677. indices[offset + 0] = faceIndices.GetValue(0);
  78678. indices[offset + 1] = faceIndices.GetValue(1);
  78679. indices[offset + 2] = faceIndices.GetValue(2);
  78680. }
  78681. vertexData.indices = indices;
  78682. }
  78683. finally {
  78684. module.destroy(faceIndices);
  78685. }
  78686. }
  78687. for (var kind in attributes) {
  78688. var uniqueId = attributes[kind];
  78689. var attribute = decoder.GetAttributeByUniqueId(geometry, uniqueId);
  78690. var dracoData = new module.DracoFloat32Array();
  78691. try {
  78692. decoder.GetAttributeFloatForAllPoints(geometry, attribute, dracoData);
  78693. var babylonData = new Float32Array(numPoints * attribute.num_components());
  78694. for (var i = 0; i < babylonData.length; i++) {
  78695. babylonData[i] = dracoData.GetValue(i);
  78696. }
  78697. vertexData.set(babylonData, kind);
  78698. }
  78699. finally {
  78700. module.destroy(dracoData);
  78701. }
  78702. }
  78703. }
  78704. finally {
  78705. if (geometry) {
  78706. module.destroy(geometry);
  78707. }
  78708. module.destroy(decoder);
  78709. module.destroy(buffer);
  78710. }
  78711. return vertexData;
  78712. });
  78713. };
  78714. DracoCompression._GetDecoderModule = function () {
  78715. if (!DracoCompression._DecoderModulePromise) {
  78716. var promise = null;
  78717. var config_1 = {};
  78718. if (typeof DracoDecoderModule !== "undefined") {
  78719. promise = Promise.resolve();
  78720. }
  78721. else {
  78722. var decoder = DracoCompression.Configuration.decoder;
  78723. if (decoder) {
  78724. if (decoder.wasmUrl && decoder.wasmBinaryUrl && typeof WebAssembly === "object") {
  78725. promise = Promise.all([
  78726. DracoCompression._LoadScriptAsync(decoder.wasmUrl),
  78727. DracoCompression._LoadFileAsync(decoder.wasmBinaryUrl).then(function (data) {
  78728. config_1.wasmBinary = data;
  78729. })
  78730. ]);
  78731. }
  78732. else if (decoder.fallbackUrl) {
  78733. promise = DracoCompression._LoadScriptAsync(decoder.fallbackUrl);
  78734. }
  78735. }
  78736. }
  78737. if (!promise) {
  78738. throw new Error("Draco decoder module is not available");
  78739. }
  78740. DracoCompression._DecoderModulePromise = promise.then(function () {
  78741. return new Promise(function (resolve) {
  78742. config_1.onModuleLoaded = function (decoderModule) {
  78743. // decoderModule is Promise-like. Wrap before resolving to avoid loop.
  78744. resolve({ module: decoderModule });
  78745. };
  78746. DracoDecoderModule(config_1);
  78747. });
  78748. });
  78749. }
  78750. return DracoCompression._DecoderModulePromise;
  78751. };
  78752. DracoCompression._LoadScriptAsync = function (url) {
  78753. return new Promise(function (resolve, reject) {
  78754. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadScript(url, function () {
  78755. resolve();
  78756. }, function (message) {
  78757. reject(new Error(message));
  78758. });
  78759. });
  78760. };
  78761. DracoCompression._LoadFileAsync = function (url) {
  78762. return new Promise(function (resolve, reject) {
  78763. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(url, function (data) {
  78764. resolve(data);
  78765. }, undefined, undefined, true, function (request, exception) {
  78766. reject(exception);
  78767. });
  78768. });
  78769. };
  78770. /**
  78771. * The configuration. Defaults to the following urls:
  78772. * - wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js"
  78773. * - wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm"
  78774. * - fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78775. */
  78776. DracoCompression.Configuration = {
  78777. decoder: {
  78778. wasmUrl: "https://preview.babylonjs.com/draco_wasm_wrapper_gltf.js",
  78779. wasmBinaryUrl: "https://preview.babylonjs.com/draco_decoder_gltf.wasm",
  78780. fallbackUrl: "https://preview.babylonjs.com/draco_decoder_gltf.js"
  78781. }
  78782. };
  78783. return DracoCompression;
  78784. }());
  78785. /***/ }),
  78786. /***/ "./Meshes/Compression/index.ts":
  78787. /*!*************************************!*\
  78788. !*** ./Meshes/Compression/index.ts ***!
  78789. \*************************************/
  78790. /*! exports provided: DracoCompression */
  78791. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78792. "use strict";
  78793. __webpack_require__.r(__webpack_exports__);
  78794. /* harmony import */ var _dracoCompression__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./dracoCompression */ "./Meshes/Compression/dracoCompression.ts");
  78795. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _dracoCompression__WEBPACK_IMPORTED_MODULE_0__["DracoCompression"]; });
  78796. /***/ }),
  78797. /***/ "./Meshes/abstractMesh.ts":
  78798. /*!********************************!*\
  78799. !*** ./Meshes/abstractMesh.ts ***!
  78800. \********************************/
  78801. /*! exports provided: AbstractMesh */
  78802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  78803. "use strict";
  78804. __webpack_require__.r(__webpack_exports__);
  78805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return AbstractMesh; });
  78806. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  78807. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  78808. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  78809. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  78810. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  78811. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  78812. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  78813. /* harmony import */ var _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Meshes/transformNode */ "./Meshes/transformNode.ts");
  78814. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  78815. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  78816. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  78817. /** @hidden */
  78818. var _FacetDataStorage = /** @class */ (function () {
  78819. function _FacetDataStorage() {
  78820. this.facetNb = 0; // facet number
  78821. this.partitioningSubdivisions = 10; // number of subdivisions per axis in the partioning space
  78822. this.partitioningBBoxRatio = 1.01; // the partioning array space is by default 1% bigger than the bounding box
  78823. this.facetDataEnabled = false; // is the facet data feature enabled on this mesh ?
  78824. this.facetParameters = {}; // keep a reference to the object parameters to avoid memory re-allocation
  78825. this.bbSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero(); // bbox size approximated for facet data
  78826. this.subDiv = {
  78827. max: 1,
  78828. X: 1,
  78829. Y: 1,
  78830. Z: 1
  78831. };
  78832. this.facetDepthSort = false; // is the facet depth sort to be computed
  78833. this.facetDepthSortEnabled = false; // is the facet depth sort initialized
  78834. }
  78835. return _FacetDataStorage;
  78836. }());
  78837. /**
  78838. * Class used to store all common mesh properties
  78839. */
  78840. var AbstractMesh = /** @class */ (function (_super) {
  78841. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AbstractMesh, _super);
  78842. // Constructor
  78843. /**
  78844. * Creates a new AbstractMesh
  78845. * @param name defines the name of the mesh
  78846. * @param scene defines the hosting scene
  78847. */
  78848. function AbstractMesh(name, scene) {
  78849. if (scene === void 0) { scene = null; }
  78850. var _this = _super.call(this, name, scene, false) || this;
  78851. _this._facetData = new _FacetDataStorage();
  78852. /**
  78853. * The culling strategy to use to check whether the mesh must be rendered or not.
  78854. * This value can be changed at any time and will be used on the next render mesh selection.
  78855. * The possible values are :
  78856. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  78857. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  78858. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  78859. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  78860. * Please read each static variable documentation to get details about the culling process.
  78861. * */
  78862. _this.cullingStrategy = AbstractMesh.CULLINGSTRATEGY_STANDARD;
  78863. // Events
  78864. /**
  78865. * An event triggered when this mesh collides with another one
  78866. */
  78867. _this.onCollideObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78868. /**
  78869. * An event triggered when the collision's position changes
  78870. */
  78871. _this.onCollisionPositionChangeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78872. /**
  78873. * An event triggered when material is changed
  78874. */
  78875. _this.onMaterialChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78876. // Properties
  78877. /**
  78878. * Gets or sets the orientation for POV movement & rotation
  78879. */
  78880. _this.definedFacingForward = true;
  78881. _this._visibility = 1.0;
  78882. /** Gets or sets the alpha index used to sort transparent meshes
  78883. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#alpha-index
  78884. */
  78885. _this.alphaIndex = Number.MAX_VALUE;
  78886. /**
  78887. * Gets or sets a boolean indicating if the mesh is visible (renderable). Default is true
  78888. */
  78889. _this.isVisible = true;
  78890. /**
  78891. * Gets or sets a boolean indicating if the mesh can be picked (by scene.pick for instance or through actions). Default is true
  78892. */
  78893. _this.isPickable = true;
  78894. /** Gets or sets a boolean indicating that bounding boxes of subMeshes must be rendered as well (false by default) */
  78895. _this.showSubMeshesBoundingBox = false;
  78896. /** Gets or sets a boolean indicating if the mesh must be considered as a ray blocker for lens flares (false by default)
  78897. * @see http://doc.babylonjs.com/how_to/how_to_use_lens_flares
  78898. */
  78899. _this.isBlocker = false;
  78900. /**
  78901. * Gets or sets a boolean indicating that pointer move events must be supported on this mesh (false by default)
  78902. */
  78903. _this.enablePointerMoveEvents = false;
  78904. /**
  78905. * Specifies the rendering group id for this mesh (0 by default)
  78906. * @see http://doc.babylonjs.com/resources/transparency_and_how_meshes_are_rendered#rendering-groups
  78907. */
  78908. _this.renderingGroupId = 0;
  78909. _this._receiveShadows = false;
  78910. /** Defines color to use when rendering outline */
  78911. _this.outlineColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78912. /** Define width to use when rendering outline */
  78913. _this.outlineWidth = 0.02;
  78914. /** Defines color to use when rendering overlay */
  78915. _this.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].Red();
  78916. /** Defines alpha to use when rendering overlay */
  78917. _this.overlayAlpha = 0.5;
  78918. _this._hasVertexAlpha = false;
  78919. _this._useVertexColors = true;
  78920. _this._computeBonesUsingShaders = true;
  78921. _this._numBoneInfluencers = 4;
  78922. _this._applyFog = true;
  78923. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes selection (true by default) */
  78924. _this.useOctreeForRenderingSelection = true;
  78925. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes picking (true by default) */
  78926. _this.useOctreeForPicking = true;
  78927. /** Gets or sets a boolean indicating that internal octree (if available) can be used to boost submeshes collision (true by default) */
  78928. _this.useOctreeForCollisions = true;
  78929. _this._layerMask = 0x0FFFFFFF;
  78930. /**
  78931. * True if the mesh must be rendered in any case (this will shortcut the frustum clipping phase)
  78932. */
  78933. _this.alwaysSelectAsActiveMesh = false;
  78934. /**
  78935. * Gets or sets the current action manager
  78936. * @see http://doc.babylonjs.com/how_to/how_to_use_actions
  78937. */
  78938. _this.actionManager = null;
  78939. // Collisions
  78940. _this._checkCollisions = false;
  78941. _this._collisionMask = -1;
  78942. _this._collisionGroup = -1;
  78943. /**
  78944. * Gets or sets the ellipsoid used to impersonate this mesh when using collision engine (default is (0.5, 1, 0.5))
  78945. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78946. */
  78947. _this.ellipsoid = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0.5, 1, 0.5);
  78948. /**
  78949. * Gets or sets the ellipsoid offset used to impersonate this mesh when using collision engine (default is (0, 0, 0))
  78950. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  78951. */
  78952. _this.ellipsoidOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78953. _this._oldPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78954. _this._diffPositionForCollisions = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  78955. // Edges
  78956. /**
  78957. * Defines edge width used when edgesRenderer is enabled
  78958. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78959. */
  78960. _this.edgesWidth = 1;
  78961. /**
  78962. * Defines edge color used when edgesRenderer is enabled
  78963. * @see https://www.babylonjs-playground.com/#10OJSG#13
  78964. */
  78965. _this.edgesColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](1, 0, 0, 1);
  78966. /** @hidden */
  78967. _this._renderId = 0;
  78968. /** @hidden */
  78969. _this._intersectionsInProgress = new Array();
  78970. /** @hidden */
  78971. _this._unIndexed = false;
  78972. /** @hidden */
  78973. _this._lightSources = new Array();
  78974. /**
  78975. * An event triggered when the mesh is rebuilt.
  78976. */
  78977. _this.onRebuildObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  78978. _this._onCollisionPositionChange = function (collisionId, newPosition, collidedMesh) {
  78979. if (collidedMesh === void 0) { collidedMesh = null; }
  78980. newPosition.subtractToRef(_this._oldPositionForCollisions, _this._diffPositionForCollisions);
  78981. if (_this._diffPositionForCollisions.length() > _Engines_engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].CollisionsEpsilon) {
  78982. _this.position.addInPlace(_this._diffPositionForCollisions);
  78983. }
  78984. if (collidedMesh) {
  78985. _this.onCollideObservable.notifyObservers(collidedMesh);
  78986. }
  78987. _this.onCollisionPositionChangeObservable.notifyObservers(_this.position);
  78988. };
  78989. _this.getScene().addMesh(_this);
  78990. _this._resyncLightSources();
  78991. return _this;
  78992. }
  78993. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_NONE", {
  78994. /**
  78995. * No billboard
  78996. */
  78997. get: function () {
  78998. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_NONE;
  78999. },
  79000. enumerable: true,
  79001. configurable: true
  79002. });
  79003. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_X", {
  79004. /** Billboard on X axis */
  79005. get: function () {
  79006. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_X;
  79007. },
  79008. enumerable: true,
  79009. configurable: true
  79010. });
  79011. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Y", {
  79012. /** Billboard on Y axis */
  79013. get: function () {
  79014. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Y;
  79015. },
  79016. enumerable: true,
  79017. configurable: true
  79018. });
  79019. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_Z", {
  79020. /** Billboard on Z axis */
  79021. get: function () {
  79022. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_Z;
  79023. },
  79024. enumerable: true,
  79025. configurable: true
  79026. });
  79027. Object.defineProperty(AbstractMesh, "BILLBOARDMODE_ALL", {
  79028. /** Billboard on all axes */
  79029. get: function () {
  79030. return _Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"].BILLBOARDMODE_ALL;
  79031. },
  79032. enumerable: true,
  79033. configurable: true
  79034. });
  79035. Object.defineProperty(AbstractMesh.prototype, "facetNb", {
  79036. /**
  79037. * Gets the number of facets in the mesh
  79038. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79039. */
  79040. get: function () {
  79041. return this._facetData.facetNb;
  79042. },
  79043. enumerable: true,
  79044. configurable: true
  79045. });
  79046. Object.defineProperty(AbstractMesh.prototype, "partitioningSubdivisions", {
  79047. /**
  79048. * Gets or set the number (integer) of subdivisions per axis in the partioning space
  79049. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79050. */
  79051. get: function () {
  79052. return this._facetData.partitioningSubdivisions;
  79053. },
  79054. set: function (nb) {
  79055. this._facetData.partitioningSubdivisions = nb;
  79056. },
  79057. enumerable: true,
  79058. configurable: true
  79059. });
  79060. Object.defineProperty(AbstractMesh.prototype, "partitioningBBoxRatio", {
  79061. /**
  79062. * The ratio (float) to apply to the bouding box size to set to the partioning space.
  79063. * Ex : 1.01 (default) the partioning space is 1% bigger than the bounding box
  79064. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#tweaking-the-partitioning
  79065. */
  79066. get: function () {
  79067. return this._facetData.partitioningBBoxRatio;
  79068. },
  79069. set: function (ratio) {
  79070. this._facetData.partitioningBBoxRatio = ratio;
  79071. },
  79072. enumerable: true,
  79073. configurable: true
  79074. });
  79075. Object.defineProperty(AbstractMesh.prototype, "mustDepthSortFacets", {
  79076. /**
  79077. * Gets or sets a boolean indicating that the facets must be depth sorted on next call to `updateFacetData()`.
  79078. * Works only for updatable meshes.
  79079. * Doesn't work with multi-materials
  79080. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79081. */
  79082. get: function () {
  79083. return this._facetData.facetDepthSort;
  79084. },
  79085. set: function (sort) {
  79086. this._facetData.facetDepthSort = sort;
  79087. },
  79088. enumerable: true,
  79089. configurable: true
  79090. });
  79091. Object.defineProperty(AbstractMesh.prototype, "facetDepthSortFrom", {
  79092. /**
  79093. * The location (Vector3) where the facet depth sort must be computed from.
  79094. * By default, the active camera position.
  79095. * Used only when facet depth sort is enabled
  79096. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#facet-depth-sort
  79097. */
  79098. get: function () {
  79099. return this._facetData.facetDepthSortFrom;
  79100. },
  79101. set: function (location) {
  79102. this._facetData.facetDepthSortFrom = location;
  79103. },
  79104. enumerable: true,
  79105. configurable: true
  79106. });
  79107. Object.defineProperty(AbstractMesh.prototype, "isFacetDataEnabled", {
  79108. /**
  79109. * gets a boolean indicating if facetData is enabled
  79110. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata#what-is-a-mesh-facet
  79111. */
  79112. get: function () {
  79113. return this._facetData.facetDataEnabled;
  79114. },
  79115. enumerable: true,
  79116. configurable: true
  79117. });
  79118. /** @hidden */
  79119. AbstractMesh.prototype._updateNonUniformScalingState = function (value) {
  79120. if (!_super.prototype._updateNonUniformScalingState.call(this, value)) {
  79121. return false;
  79122. }
  79123. this._markSubMeshesAsMiscDirty();
  79124. return true;
  79125. };
  79126. Object.defineProperty(AbstractMesh.prototype, "onCollide", {
  79127. /** Set a function to call when this mesh collides with another one */
  79128. set: function (callback) {
  79129. if (this._onCollideObserver) {
  79130. this.onCollideObservable.remove(this._onCollideObserver);
  79131. }
  79132. this._onCollideObserver = this.onCollideObservable.add(callback);
  79133. },
  79134. enumerable: true,
  79135. configurable: true
  79136. });
  79137. Object.defineProperty(AbstractMesh.prototype, "onCollisionPositionChange", {
  79138. /** Set a function to call when the collision's position changes */
  79139. set: function (callback) {
  79140. if (this._onCollisionPositionChangeObserver) {
  79141. this.onCollisionPositionChangeObservable.remove(this._onCollisionPositionChangeObserver);
  79142. }
  79143. this._onCollisionPositionChangeObserver = this.onCollisionPositionChangeObservable.add(callback);
  79144. },
  79145. enumerable: true,
  79146. configurable: true
  79147. });
  79148. Object.defineProperty(AbstractMesh.prototype, "visibility", {
  79149. /**
  79150. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79151. */
  79152. get: function () {
  79153. return this._visibility;
  79154. },
  79155. /**
  79156. * Gets or sets mesh visibility between 0 and 1 (default is 1)
  79157. */
  79158. set: function (value) {
  79159. if (this._visibility === value) {
  79160. return;
  79161. }
  79162. this._visibility = value;
  79163. this._markSubMeshesAsMiscDirty();
  79164. },
  79165. enumerable: true,
  79166. configurable: true
  79167. });
  79168. Object.defineProperty(AbstractMesh.prototype, "material", {
  79169. /** Gets or sets current material */
  79170. get: function () {
  79171. return this._material;
  79172. },
  79173. set: function (value) {
  79174. if (this._material === value) {
  79175. return;
  79176. }
  79177. // remove from material mesh map id needed
  79178. if (this._material && this._material.meshMap) {
  79179. this._material.meshMap[this.uniqueId] = undefined;
  79180. }
  79181. this._material = value;
  79182. if (value && value.meshMap) {
  79183. value.meshMap[this.uniqueId] = this;
  79184. }
  79185. if (this.onMaterialChangedObservable.hasObservers) {
  79186. this.onMaterialChangedObservable.notifyObservers(this);
  79187. }
  79188. if (!this.subMeshes) {
  79189. return;
  79190. }
  79191. this._unBindEffect();
  79192. },
  79193. enumerable: true,
  79194. configurable: true
  79195. });
  79196. Object.defineProperty(AbstractMesh.prototype, "receiveShadows", {
  79197. /**
  79198. * Gets or sets a boolean indicating that this mesh can receive realtime shadows
  79199. * @see http://doc.babylonjs.com/babylon101/shadows
  79200. */
  79201. get: function () {
  79202. return this._receiveShadows;
  79203. },
  79204. set: function (value) {
  79205. if (this._receiveShadows === value) {
  79206. return;
  79207. }
  79208. this._receiveShadows = value;
  79209. this._markSubMeshesAsLightDirty();
  79210. },
  79211. enumerable: true,
  79212. configurable: true
  79213. });
  79214. Object.defineProperty(AbstractMesh.prototype, "hasVertexAlpha", {
  79215. /** Gets or sets a boolean indicating that this mesh contains vertex color data with alpha values */
  79216. get: function () {
  79217. return this._hasVertexAlpha;
  79218. },
  79219. set: function (value) {
  79220. if (this._hasVertexAlpha === value) {
  79221. return;
  79222. }
  79223. this._hasVertexAlpha = value;
  79224. this._markSubMeshesAsAttributesDirty();
  79225. this._markSubMeshesAsMiscDirty();
  79226. },
  79227. enumerable: true,
  79228. configurable: true
  79229. });
  79230. Object.defineProperty(AbstractMesh.prototype, "useVertexColors", {
  79231. /** 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) */
  79232. get: function () {
  79233. return this._useVertexColors;
  79234. },
  79235. set: function (value) {
  79236. if (this._useVertexColors === value) {
  79237. return;
  79238. }
  79239. this._useVertexColors = value;
  79240. this._markSubMeshesAsAttributesDirty();
  79241. },
  79242. enumerable: true,
  79243. configurable: true
  79244. });
  79245. Object.defineProperty(AbstractMesh.prototype, "computeBonesUsingShaders", {
  79246. /**
  79247. * Gets or sets a boolean indicating that bone animations must be computed by the CPU (false by default)
  79248. */
  79249. get: function () {
  79250. return this._computeBonesUsingShaders;
  79251. },
  79252. set: function (value) {
  79253. if (this._computeBonesUsingShaders === value) {
  79254. return;
  79255. }
  79256. this._computeBonesUsingShaders = value;
  79257. this._markSubMeshesAsAttributesDirty();
  79258. },
  79259. enumerable: true,
  79260. configurable: true
  79261. });
  79262. Object.defineProperty(AbstractMesh.prototype, "numBoneInfluencers", {
  79263. /** Gets or sets the number of allowed bone influences per vertex (4 by default) */
  79264. get: function () {
  79265. return this._numBoneInfluencers;
  79266. },
  79267. set: function (value) {
  79268. if (this._numBoneInfluencers === value) {
  79269. return;
  79270. }
  79271. this._numBoneInfluencers = value;
  79272. this._markSubMeshesAsAttributesDirty();
  79273. },
  79274. enumerable: true,
  79275. configurable: true
  79276. });
  79277. Object.defineProperty(AbstractMesh.prototype, "applyFog", {
  79278. /** Gets or sets a boolean indicating that this mesh will allow fog to be rendered on it (true by default) */
  79279. get: function () {
  79280. return this._applyFog;
  79281. },
  79282. set: function (value) {
  79283. if (this._applyFog === value) {
  79284. return;
  79285. }
  79286. this._applyFog = value;
  79287. this._markSubMeshesAsMiscDirty();
  79288. },
  79289. enumerable: true,
  79290. configurable: true
  79291. });
  79292. Object.defineProperty(AbstractMesh.prototype, "layerMask", {
  79293. /**
  79294. * Gets or sets the current layer mask (default is 0x0FFFFFFF)
  79295. * @see http://doc.babylonjs.com/how_to/layermasks_and_multi-cam_textures
  79296. */
  79297. get: function () {
  79298. return this._layerMask;
  79299. },
  79300. set: function (value) {
  79301. if (value === this._layerMask) {
  79302. return;
  79303. }
  79304. this._layerMask = value;
  79305. this._resyncLightSources();
  79306. },
  79307. enumerable: true,
  79308. configurable: true
  79309. });
  79310. Object.defineProperty(AbstractMesh.prototype, "collisionMask", {
  79311. /**
  79312. * Gets or sets a collision mask used to mask collisions (default is -1).
  79313. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79314. */
  79315. get: function () {
  79316. return this._collisionMask;
  79317. },
  79318. set: function (mask) {
  79319. this._collisionMask = !isNaN(mask) ? mask : -1;
  79320. },
  79321. enumerable: true,
  79322. configurable: true
  79323. });
  79324. Object.defineProperty(AbstractMesh.prototype, "collisionGroup", {
  79325. /**
  79326. * Gets or sets the current collision group mask (-1 by default).
  79327. * A collision between A and B will happen if A.collisionGroup & b.collisionMask !== 0
  79328. */
  79329. get: function () {
  79330. return this._collisionGroup;
  79331. },
  79332. set: function (mask) {
  79333. this._collisionGroup = !isNaN(mask) ? mask : -1;
  79334. },
  79335. enumerable: true,
  79336. configurable: true
  79337. });
  79338. Object.defineProperty(AbstractMesh.prototype, "_positions", {
  79339. /** @hidden */
  79340. get: function () {
  79341. return null;
  79342. },
  79343. enumerable: true,
  79344. configurable: true
  79345. });
  79346. Object.defineProperty(AbstractMesh.prototype, "skeleton", {
  79347. get: function () {
  79348. return this._skeleton;
  79349. },
  79350. /**
  79351. * Gets or sets a skeleton to apply skining transformations
  79352. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  79353. */
  79354. set: function (value) {
  79355. if (this._skeleton && this._skeleton.needInitialSkinMatrix) {
  79356. this._skeleton._unregisterMeshWithPoseMatrix(this);
  79357. }
  79358. if (value && value.needInitialSkinMatrix) {
  79359. value._registerMeshWithPoseMatrix(this);
  79360. }
  79361. this._skeleton = value;
  79362. if (!this._skeleton) {
  79363. this._bonesTransformMatrices = null;
  79364. }
  79365. this._markSubMeshesAsAttributesDirty();
  79366. },
  79367. enumerable: true,
  79368. configurable: true
  79369. });
  79370. /**
  79371. * Returns the string "AbstractMesh"
  79372. * @returns "AbstractMesh"
  79373. */
  79374. AbstractMesh.prototype.getClassName = function () {
  79375. return "AbstractMesh";
  79376. };
  79377. /**
  79378. * Gets a string representation of the current mesh
  79379. * @param fullDetails defines a boolean indicating if full details must be included
  79380. * @returns a string representation of the current mesh
  79381. */
  79382. AbstractMesh.prototype.toString = function (fullDetails) {
  79383. var ret = "Name: " + this.name + ", isInstance: " + (this.getClassName() !== "InstancedMesh" ? "YES" : "NO");
  79384. ret += ", # of submeshes: " + (this.subMeshes ? this.subMeshes.length : 0);
  79385. if (this._skeleton) {
  79386. ret += ", skeleton: " + this._skeleton.name;
  79387. }
  79388. if (fullDetails) {
  79389. ret += ", billboard mode: " + (["NONE", "X", "Y", null, "Z", null, null, "ALL"])[this.billboardMode];
  79390. ret += ", freeze wrld mat: " + (this._isWorldMatrixFrozen || this._waitingFreezeWorldMatrix ? "YES" : "NO");
  79391. }
  79392. return ret;
  79393. };
  79394. /** @hidden */
  79395. AbstractMesh.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  79396. if (initialCall === void 0) { initialCall = true; }
  79397. if (this.actionManager && (initialCall || this.actionManager.isRecursive)) {
  79398. if (trigger) {
  79399. if (this.actionManager.hasSpecificTrigger(trigger)) {
  79400. return this.actionManager;
  79401. }
  79402. }
  79403. else {
  79404. return this.actionManager;
  79405. }
  79406. }
  79407. if (!this.parent) {
  79408. return null;
  79409. }
  79410. return this.parent._getActionManagerForTrigger(trigger, false);
  79411. };
  79412. /** @hidden */
  79413. AbstractMesh.prototype._rebuild = function () {
  79414. this.onRebuildObservable.notifyObservers(this);
  79415. if (this._occlusionQuery) {
  79416. this._occlusionQuery = null;
  79417. }
  79418. if (!this.subMeshes) {
  79419. return;
  79420. }
  79421. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79422. var subMesh = _a[_i];
  79423. subMesh._rebuild();
  79424. }
  79425. };
  79426. /** @hidden */
  79427. AbstractMesh.prototype._resyncLightSources = function () {
  79428. this._lightSources.length = 0;
  79429. for (var _i = 0, _a = this.getScene().lights; _i < _a.length; _i++) {
  79430. var light = _a[_i];
  79431. if (!light.isEnabled()) {
  79432. continue;
  79433. }
  79434. if (light.canAffectMesh(this)) {
  79435. this._lightSources.push(light);
  79436. }
  79437. }
  79438. this._markSubMeshesAsLightDirty();
  79439. };
  79440. /** @hidden */
  79441. AbstractMesh.prototype._resyncLighSource = function (light) {
  79442. var isIn = light.isEnabled() && light.canAffectMesh(this);
  79443. var index = this._lightSources.indexOf(light);
  79444. if (index === -1) {
  79445. if (!isIn) {
  79446. return;
  79447. }
  79448. this._lightSources.push(light);
  79449. }
  79450. else {
  79451. if (isIn) {
  79452. return;
  79453. }
  79454. this._lightSources.splice(index, 1);
  79455. }
  79456. this._markSubMeshesAsLightDirty();
  79457. };
  79458. /** @hidden */
  79459. AbstractMesh.prototype._unBindEffect = function () {
  79460. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79461. var subMesh = _a[_i];
  79462. subMesh.setEffect(null);
  79463. }
  79464. };
  79465. /** @hidden */
  79466. AbstractMesh.prototype._removeLightSource = function (light) {
  79467. var index = this._lightSources.indexOf(light);
  79468. if (index === -1) {
  79469. return;
  79470. }
  79471. this._lightSources.splice(index, 1);
  79472. this._markSubMeshesAsLightDirty();
  79473. };
  79474. AbstractMesh.prototype._markSubMeshesAsDirty = function (func) {
  79475. if (!this.subMeshes) {
  79476. return;
  79477. }
  79478. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79479. var subMesh = _a[_i];
  79480. if (subMesh._materialDefines) {
  79481. func(subMesh._materialDefines);
  79482. }
  79483. }
  79484. };
  79485. /** @hidden */
  79486. AbstractMesh.prototype._markSubMeshesAsLightDirty = function () {
  79487. this._markSubMeshesAsDirty(function (defines) { return defines.markAsLightDirty(); });
  79488. };
  79489. /** @hidden */
  79490. AbstractMesh.prototype._markSubMeshesAsAttributesDirty = function () {
  79491. this._markSubMeshesAsDirty(function (defines) { return defines.markAsAttributesDirty(); });
  79492. };
  79493. /** @hidden */
  79494. AbstractMesh.prototype._markSubMeshesAsMiscDirty = function () {
  79495. if (!this.subMeshes) {
  79496. return;
  79497. }
  79498. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  79499. var subMesh = _a[_i];
  79500. var material = subMesh.getMaterial();
  79501. if (material) {
  79502. material.markAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MATERIAL_MiscDirtyFlag);
  79503. }
  79504. }
  79505. };
  79506. Object.defineProperty(AbstractMesh.prototype, "scaling", {
  79507. /**
  79508. * Gets or sets a Vector3 depicting the mesh scaling along each local axis X, Y, Z. Default is (1.0, 1.0, 1.0)
  79509. */
  79510. get: function () {
  79511. return this._scaling;
  79512. },
  79513. set: function (newScaling) {
  79514. this._scaling = newScaling;
  79515. if (this.physicsImpostor) {
  79516. this.physicsImpostor.forceUpdate();
  79517. }
  79518. },
  79519. enumerable: true,
  79520. configurable: true
  79521. });
  79522. Object.defineProperty(AbstractMesh.prototype, "isBlocked", {
  79523. // Methods
  79524. /**
  79525. * Returns true if the mesh is blocked. Implemented by child classes
  79526. */
  79527. get: function () {
  79528. return false;
  79529. },
  79530. enumerable: true,
  79531. configurable: true
  79532. });
  79533. /**
  79534. * Returns the mesh itself by default. Implemented by child classes
  79535. * @param camera defines the camera to use to pick the right LOD level
  79536. * @returns the currentAbstractMesh
  79537. */
  79538. AbstractMesh.prototype.getLOD = function (camera) {
  79539. return this;
  79540. };
  79541. /**
  79542. * Returns 0 by default. Implemented by child classes
  79543. * @returns an integer
  79544. */
  79545. AbstractMesh.prototype.getTotalVertices = function () {
  79546. return 0;
  79547. };
  79548. /**
  79549. * Returns a positive integer : the total number of indices in this mesh geometry.
  79550. * @returns the numner of indices or zero if the mesh has no geometry.
  79551. */
  79552. AbstractMesh.prototype.getTotalIndices = function () {
  79553. return 0;
  79554. };
  79555. /**
  79556. * Returns null by default. Implemented by child classes
  79557. * @returns null
  79558. */
  79559. AbstractMesh.prototype.getIndices = function () {
  79560. return null;
  79561. };
  79562. /**
  79563. * Returns the array of the requested vertex data kind. Implemented by child classes
  79564. * @param kind defines the vertex data kind to use
  79565. * @returns null
  79566. */
  79567. AbstractMesh.prototype.getVerticesData = function (kind) {
  79568. return null;
  79569. };
  79570. /**
  79571. * Sets the vertex data of the mesh geometry for the requested `kind`.
  79572. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  79573. * Note that a new underlying VertexBuffer object is created each call.
  79574. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  79575. * @param kind defines vertex data kind:
  79576. * * VertexBuffer.PositionKind
  79577. * * VertexBuffer.UVKind
  79578. * * VertexBuffer.UV2Kind
  79579. * * VertexBuffer.UV3Kind
  79580. * * VertexBuffer.UV4Kind
  79581. * * VertexBuffer.UV5Kind
  79582. * * VertexBuffer.UV6Kind
  79583. * * VertexBuffer.ColorKind
  79584. * * VertexBuffer.MatricesIndicesKind
  79585. * * VertexBuffer.MatricesIndicesExtraKind
  79586. * * VertexBuffer.MatricesWeightsKind
  79587. * * VertexBuffer.MatricesWeightsExtraKind
  79588. * @param data defines the data source
  79589. * @param updatable defines if the data must be flagged as updatable (or static)
  79590. * @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
  79591. * @returns the current mesh
  79592. */
  79593. AbstractMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  79594. return this;
  79595. };
  79596. /**
  79597. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  79598. * If the mesh has no geometry, it is simply returned as it is.
  79599. * @param kind defines vertex data kind:
  79600. * * VertexBuffer.PositionKind
  79601. * * VertexBuffer.UVKind
  79602. * * VertexBuffer.UV2Kind
  79603. * * VertexBuffer.UV3Kind
  79604. * * VertexBuffer.UV4Kind
  79605. * * VertexBuffer.UV5Kind
  79606. * * VertexBuffer.UV6Kind
  79607. * * VertexBuffer.ColorKind
  79608. * * VertexBuffer.MatricesIndicesKind
  79609. * * VertexBuffer.MatricesIndicesExtraKind
  79610. * * VertexBuffer.MatricesWeightsKind
  79611. * * VertexBuffer.MatricesWeightsExtraKind
  79612. * @param data defines the data source
  79613. * @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
  79614. * @param makeItUnique If true, a new global geometry is created from this data and is set to the mesh
  79615. * @returns the current mesh
  79616. */
  79617. AbstractMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  79618. return this;
  79619. };
  79620. /**
  79621. * Sets the mesh indices,
  79622. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  79623. * @param indices Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array)
  79624. * @param totalVertices Defines the total number of vertices
  79625. * @returns the current mesh
  79626. */
  79627. AbstractMesh.prototype.setIndices = function (indices, totalVertices) {
  79628. return this;
  79629. };
  79630. /**
  79631. * Gets a boolean indicating if specific vertex data is present
  79632. * @param kind defines the vertex data kind to use
  79633. * @returns true is data kind is present
  79634. */
  79635. AbstractMesh.prototype.isVerticesDataPresent = function (kind) {
  79636. return false;
  79637. };
  79638. /**
  79639. * Returns the mesh BoundingInfo object or creates a new one and returns if it was undefined
  79640. * @returns a BoundingInfo
  79641. */
  79642. AbstractMesh.prototype.getBoundingInfo = function () {
  79643. if (this._masterMesh) {
  79644. return this._masterMesh.getBoundingInfo();
  79645. }
  79646. if (!this._boundingInfo) {
  79647. // this._boundingInfo is being created here
  79648. this._updateBoundingInfo();
  79649. }
  79650. // cannot be null.
  79651. return this._boundingInfo;
  79652. };
  79653. /**
  79654. * Uniformly scales the mesh to fit inside of a unit cube (1 X 1 X 1 units)
  79655. * @param includeDescendants Use the hierarchy's bounding box instead of the mesh's bounding box
  79656. * @returns the current mesh
  79657. */
  79658. AbstractMesh.prototype.normalizeToUnitCube = function (includeDescendants) {
  79659. if (includeDescendants === void 0) { includeDescendants = true; }
  79660. var boundingVectors = this.getHierarchyBoundingVectors(includeDescendants);
  79661. var sizeVec = boundingVectors.max.subtract(boundingVectors.min);
  79662. var maxDimension = Math.max(sizeVec.x, sizeVec.y, sizeVec.z);
  79663. if (maxDimension === 0) {
  79664. return this;
  79665. }
  79666. var scale = 1 / maxDimension;
  79667. this.scaling.scaleInPlace(scale);
  79668. return this;
  79669. };
  79670. /**
  79671. * Overwrite the current bounding info
  79672. * @param boundingInfo defines the new bounding info
  79673. * @returns the current mesh
  79674. */
  79675. AbstractMesh.prototype.setBoundingInfo = function (boundingInfo) {
  79676. this._boundingInfo = boundingInfo;
  79677. return this;
  79678. };
  79679. Object.defineProperty(AbstractMesh.prototype, "useBones", {
  79680. /** Gets a boolean indicating if this mesh has skinning data and an attached skeleton */
  79681. get: function () {
  79682. 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));
  79683. },
  79684. enumerable: true,
  79685. configurable: true
  79686. });
  79687. /** @hidden */
  79688. AbstractMesh.prototype._preActivate = function () {
  79689. };
  79690. /** @hidden */
  79691. AbstractMesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  79692. };
  79693. /** @hidden */
  79694. AbstractMesh.prototype._activate = function (renderId) {
  79695. this._renderId = renderId;
  79696. };
  79697. /**
  79698. * Gets the current world matrix
  79699. * @returns a Matrix
  79700. */
  79701. AbstractMesh.prototype.getWorldMatrix = function () {
  79702. if (this._masterMesh) {
  79703. return this._masterMesh.getWorldMatrix();
  79704. }
  79705. return _super.prototype.getWorldMatrix.call(this);
  79706. };
  79707. /** @hidden */
  79708. AbstractMesh.prototype._getWorldMatrixDeterminant = function () {
  79709. if (this._masterMesh) {
  79710. return this._masterMesh._getWorldMatrixDeterminant();
  79711. }
  79712. return _super.prototype._getWorldMatrixDeterminant.call(this);
  79713. };
  79714. // ================================== Point of View Movement =================================
  79715. /**
  79716. * Perform relative position change from the point of view of behind the front of the mesh.
  79717. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79718. * Supports definition of mesh facing forward or backward
  79719. * @param amountRight defines the distance on the right axis
  79720. * @param amountUp defines the distance on the up axis
  79721. * @param amountForward defines the distance on the forward axis
  79722. * @returns the current mesh
  79723. */
  79724. AbstractMesh.prototype.movePOV = function (amountRight, amountUp, amountForward) {
  79725. this.position.addInPlace(this.calcMovePOV(amountRight, amountUp, amountForward));
  79726. return this;
  79727. };
  79728. /**
  79729. * Calculate relative position change from the point of view of behind the front of the mesh.
  79730. * This is performed taking into account the meshes current rotation, so you do not have to care.
  79731. * Supports definition of mesh facing forward or backward
  79732. * @param amountRight defines the distance on the right axis
  79733. * @param amountUp defines the distance on the up axis
  79734. * @param amountForward defines the distance on the forward axis
  79735. * @returns the new displacement vector
  79736. */
  79737. AbstractMesh.prototype.calcMovePOV = function (amountRight, amountUp, amountForward) {
  79738. var rotMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"]();
  79739. var rotQuaternion = (this.rotationQuaternion) ? this.rotationQuaternion : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  79740. rotQuaternion.toRotationMatrix(rotMatrix);
  79741. var translationDelta = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  79742. var defForwardMult = this.definedFacingForward ? -1 : 1;
  79743. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(amountRight * defForwardMult, amountUp, amountForward * defForwardMult, rotMatrix, translationDelta);
  79744. return translationDelta;
  79745. };
  79746. // ================================== Point of View Rotation =================================
  79747. /**
  79748. * Perform relative rotation change from the point of view of behind the front of the mesh.
  79749. * Supports definition of mesh facing forward or backward
  79750. * @param flipBack defines the flip
  79751. * @param twirlClockwise defines the twirl
  79752. * @param tiltRight defines the tilt
  79753. * @returns the current mesh
  79754. */
  79755. AbstractMesh.prototype.rotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79756. this.rotation.addInPlace(this.calcRotatePOV(flipBack, twirlClockwise, tiltRight));
  79757. return this;
  79758. };
  79759. /**
  79760. * Calculate relative rotation change from the point of view of behind the front of the mesh.
  79761. * Supports definition of mesh facing forward or backward.
  79762. * @param flipBack defines the flip
  79763. * @param twirlClockwise defines the twirl
  79764. * @param tiltRight defines the tilt
  79765. * @returns the new rotation vector
  79766. */
  79767. AbstractMesh.prototype.calcRotatePOV = function (flipBack, twirlClockwise, tiltRight) {
  79768. var defForwardMult = this.definedFacingForward ? 1 : -1;
  79769. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](flipBack * defForwardMult, twirlClockwise, tiltRight * defForwardMult);
  79770. };
  79771. /**
  79772. * Return the minimum and maximum world vectors of the entire hierarchy under current mesh
  79773. * @param includeDescendants Include bounding info from descendants as well (true by default)
  79774. * @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
  79775. * @returns the new bounding vectors
  79776. */
  79777. AbstractMesh.prototype.getHierarchyBoundingVectors = function (includeDescendants, predicate) {
  79778. if (includeDescendants === void 0) { includeDescendants = true; }
  79779. if (predicate === void 0) { predicate = null; }
  79780. // Ensures that all world matrix will be recomputed.
  79781. this.getScene().incrementRenderId();
  79782. this.computeWorldMatrix(true);
  79783. var min;
  79784. var max;
  79785. var boundingInfo = this.getBoundingInfo();
  79786. if (!this.subMeshes) {
  79787. min = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  79788. max = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  79789. }
  79790. else {
  79791. min = boundingInfo.boundingBox.minimumWorld;
  79792. max = boundingInfo.boundingBox.maximumWorld;
  79793. }
  79794. if (includeDescendants) {
  79795. var descendants = this.getDescendants(false);
  79796. for (var _i = 0, descendants_1 = descendants; _i < descendants_1.length; _i++) {
  79797. var descendant = descendants_1[_i];
  79798. var childMesh = descendant;
  79799. childMesh.computeWorldMatrix(true);
  79800. // Filters meshes based on custom predicate function.
  79801. if (predicate && !predicate(childMesh)) {
  79802. continue;
  79803. }
  79804. //make sure we have the needed params to get mix and max
  79805. if (!childMesh.getBoundingInfo || childMesh.getTotalVertices() === 0) {
  79806. continue;
  79807. }
  79808. var childBoundingInfo = childMesh.getBoundingInfo();
  79809. var boundingBox = childBoundingInfo.boundingBox;
  79810. var minBox = boundingBox.minimumWorld;
  79811. var maxBox = boundingBox.maximumWorld;
  79812. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  79813. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  79814. }
  79815. }
  79816. return {
  79817. min: min,
  79818. max: max
  79819. };
  79820. };
  79821. /**
  79822. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  79823. * This means the mesh underlying bounding box and sphere are recomputed.
  79824. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  79825. * @returns the current mesh
  79826. */
  79827. AbstractMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  79828. if (applySkeleton === void 0) { applySkeleton = false; }
  79829. if (this._boundingInfo && this._boundingInfo.isLocked) {
  79830. return this;
  79831. }
  79832. this._refreshBoundingInfo(this._getPositionData(applySkeleton), null);
  79833. return this;
  79834. };
  79835. /** @hidden */
  79836. AbstractMesh.prototype._refreshBoundingInfo = function (data, bias) {
  79837. if (data) {
  79838. var extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMax(data, 0, this.getTotalVertices(), bias);
  79839. if (this._boundingInfo) {
  79840. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  79841. }
  79842. else {
  79843. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](extend.minimum, extend.maximum);
  79844. }
  79845. }
  79846. if (this.subMeshes) {
  79847. for (var index = 0; index < this.subMeshes.length; index++) {
  79848. this.subMeshes[index].refreshBoundingInfo();
  79849. }
  79850. }
  79851. this._updateBoundingInfo();
  79852. };
  79853. /** @hidden */
  79854. AbstractMesh.prototype._getPositionData = function (applySkeleton) {
  79855. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  79856. if (data && applySkeleton && this.skeleton) {
  79857. data = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Slice(data);
  79858. var matricesIndicesData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesKind);
  79859. var matricesWeightsData = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsKind);
  79860. if (matricesWeightsData && matricesIndicesData) {
  79861. var needExtras = this.numBoneInfluencers > 4;
  79862. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  79863. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  79864. var skeletonMatrices = this.skeleton.getTransformMatrices(this);
  79865. var tempVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  79866. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  79867. var tempMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  79868. var matWeightIdx = 0;
  79869. for (var index = 0; index < data.length; index += 3, matWeightIdx += 4) {
  79870. finalMatrix.reset();
  79871. var inf;
  79872. var weight;
  79873. for (inf = 0; inf < 4; inf++) {
  79874. weight = matricesWeightsData[matWeightIdx + inf];
  79875. if (weight > 0) {
  79876. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79877. finalMatrix.addToSelf(tempMatrix);
  79878. }
  79879. }
  79880. if (needExtras) {
  79881. for (inf = 0; inf < 4; inf++) {
  79882. weight = matricesWeightsExtraData[matWeightIdx + inf];
  79883. if (weight > 0) {
  79884. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  79885. finalMatrix.addToSelf(tempMatrix);
  79886. }
  79887. }
  79888. }
  79889. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(data[index], data[index + 1], data[index + 2], finalMatrix, tempVector);
  79890. tempVector.toArray(data, index);
  79891. }
  79892. }
  79893. }
  79894. return data;
  79895. };
  79896. /** @hidden */
  79897. AbstractMesh.prototype._updateBoundingInfo = function () {
  79898. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  79899. if (this._boundingInfo) {
  79900. this._boundingInfo.update(effectiveMesh.worldMatrixFromCache);
  79901. }
  79902. else {
  79903. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"](this.absolutePosition, this.absolutePosition, effectiveMesh.worldMatrixFromCache);
  79904. }
  79905. this._updateSubMeshesBoundingInfo(effectiveMesh.worldMatrixFromCache);
  79906. return this;
  79907. };
  79908. /** @hidden */
  79909. AbstractMesh.prototype._updateSubMeshesBoundingInfo = function (matrix) {
  79910. if (!this.subMeshes) {
  79911. return this;
  79912. }
  79913. var count = this.subMeshes.length;
  79914. for (var subIndex = 0; subIndex < count; subIndex++) {
  79915. var subMesh = this.subMeshes[subIndex];
  79916. if (count > 1 || !subMesh.IsGlobal) {
  79917. subMesh.updateBoundingInfo(matrix);
  79918. }
  79919. }
  79920. return this;
  79921. };
  79922. /** @hidden */
  79923. AbstractMesh.prototype._afterComputeWorldMatrix = function () {
  79924. // Bounding info
  79925. this._updateBoundingInfo();
  79926. };
  79927. /**
  79928. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  79929. * A mesh is in the frustum if its bounding box intersects the frustum
  79930. * @param frustumPlanes defines the frustum to test
  79931. * @returns true if the mesh is in the frustum planes
  79932. */
  79933. AbstractMesh.prototype.isInFrustum = function (frustumPlanes) {
  79934. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  79935. };
  79936. /**
  79937. * Returns `true` if the mesh is completely in the frustum defined be the passed array of planes.
  79938. * A mesh is completely in the frustum if its bounding box it completely inside the frustum.
  79939. * @param frustumPlanes defines the frustum to test
  79940. * @returns true if the mesh is completely in the frustum planes
  79941. */
  79942. AbstractMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  79943. return this._boundingInfo !== null && this._boundingInfo.isCompletelyInFrustum(frustumPlanes);
  79944. };
  79945. /**
  79946. * True if the mesh intersects another mesh or a SolidParticle object
  79947. * @param mesh defines a target mesh or SolidParticle to test
  79948. * @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)
  79949. * @param includeDescendants Can be set to true to test if the mesh defined in parameters intersects with the current mesh or any child meshes
  79950. * @returns true if there is an intersection
  79951. */
  79952. AbstractMesh.prototype.intersectsMesh = function (mesh, precise, includeDescendants) {
  79953. if (precise === void 0) { precise = false; }
  79954. if (!this._boundingInfo || !mesh._boundingInfo) {
  79955. return false;
  79956. }
  79957. if (this._boundingInfo.intersects(mesh._boundingInfo, precise)) {
  79958. return true;
  79959. }
  79960. if (includeDescendants) {
  79961. for (var _i = 0, _a = this.getChildMeshes(); _i < _a.length; _i++) {
  79962. var child = _a[_i];
  79963. if (child.intersectsMesh(mesh, precise, true)) {
  79964. return true;
  79965. }
  79966. }
  79967. }
  79968. return false;
  79969. };
  79970. /**
  79971. * Returns true if the passed point (Vector3) is inside the mesh bounding box
  79972. * @param point defines the point to test
  79973. * @returns true if there is an intersection
  79974. */
  79975. AbstractMesh.prototype.intersectsPoint = function (point) {
  79976. if (!this._boundingInfo) {
  79977. return false;
  79978. }
  79979. return this._boundingInfo.intersectsPoint(point);
  79980. };
  79981. Object.defineProperty(AbstractMesh.prototype, "checkCollisions", {
  79982. // Collisions
  79983. /**
  79984. * Gets or sets a boolean indicating that this mesh can be used in the collision engine
  79985. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  79986. */
  79987. get: function () {
  79988. return this._checkCollisions;
  79989. },
  79990. set: function (collisionEnabled) {
  79991. this._checkCollisions = collisionEnabled;
  79992. },
  79993. enumerable: true,
  79994. configurable: true
  79995. });
  79996. Object.defineProperty(AbstractMesh.prototype, "collider", {
  79997. /**
  79998. * Gets Collider object used to compute collisions (not physics)
  79999. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80000. */
  80001. get: function () {
  80002. return this._collider;
  80003. },
  80004. enumerable: true,
  80005. configurable: true
  80006. });
  80007. /**
  80008. * Move the mesh using collision engine
  80009. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  80010. * @param displacement defines the requested displacement vector
  80011. * @returns the current mesh
  80012. */
  80013. AbstractMesh.prototype.moveWithCollisions = function (displacement) {
  80014. var globalPosition = this.getAbsolutePosition();
  80015. globalPosition.addToRef(this.ellipsoidOffset, this._oldPositionForCollisions);
  80016. var coordinator = this.getScene().collisionCoordinator;
  80017. if (!this._collider) {
  80018. this._collider = coordinator.createCollider();
  80019. }
  80020. this._collider._radius = this.ellipsoid;
  80021. coordinator.getNewPosition(this._oldPositionForCollisions, displacement, this._collider, 3, this, this._onCollisionPositionChange, this.uniqueId);
  80022. return this;
  80023. };
  80024. // Collisions
  80025. /** @hidden */
  80026. AbstractMesh.prototype._collideForSubMesh = function (subMesh, transformMatrix, collider) {
  80027. this._generatePointsArray();
  80028. if (!this._positions) {
  80029. return this;
  80030. }
  80031. // Transformation
  80032. if (!subMesh._lastColliderWorldVertices || !subMesh._lastColliderTransformMatrix.equals(transformMatrix)) {
  80033. subMesh._lastColliderTransformMatrix = transformMatrix.clone();
  80034. subMesh._lastColliderWorldVertices = [];
  80035. subMesh._trianglePlanes = [];
  80036. var start = subMesh.verticesStart;
  80037. var end = (subMesh.verticesStart + subMesh.verticesCount);
  80038. for (var i = start; i < end; i++) {
  80039. subMesh._lastColliderWorldVertices.push(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this._positions[i], transformMatrix));
  80040. }
  80041. }
  80042. // Collide
  80043. collider._collide(subMesh._trianglePlanes, subMesh._lastColliderWorldVertices, this.getIndices(), subMesh.indexStart, subMesh.indexStart + subMesh.indexCount, subMesh.verticesStart, !!subMesh.getMaterial());
  80044. if (collider.collisionFound) {
  80045. collider.collidedMesh = this;
  80046. }
  80047. return this;
  80048. };
  80049. /** @hidden */
  80050. AbstractMesh.prototype._processCollisionsForSubMeshes = function (collider, transformMatrix) {
  80051. var subMeshes = this._scene.getCollidingSubMeshCandidates(this, collider);
  80052. var len = subMeshes.length;
  80053. for (var index = 0; index < len; index++) {
  80054. var subMesh = subMeshes.data[index];
  80055. // Bounding test
  80056. if (len > 1 && !subMesh._checkCollision(collider)) {
  80057. continue;
  80058. }
  80059. this._collideForSubMesh(subMesh, transformMatrix, collider);
  80060. }
  80061. return this;
  80062. };
  80063. /** @hidden */
  80064. AbstractMesh.prototype._checkCollision = function (collider) {
  80065. // Bounding box test
  80066. if (!this._boundingInfo || !this._boundingInfo._checkCollision(collider)) {
  80067. return this;
  80068. }
  80069. // Transformation matrix
  80070. var collisionsScalingMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  80071. var collisionsTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  80072. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(1.0 / collider._radius.x, 1.0 / collider._radius.y, 1.0 / collider._radius.z, collisionsScalingMatrix);
  80073. this.worldMatrixFromCache.multiplyToRef(collisionsScalingMatrix, collisionsTransformMatrix);
  80074. this._processCollisionsForSubMeshes(collider, collisionsTransformMatrix);
  80075. return this;
  80076. };
  80077. // Picking
  80078. /** @hidden */
  80079. AbstractMesh.prototype._generatePointsArray = function () {
  80080. return false;
  80081. };
  80082. /**
  80083. * Checks if the passed Ray intersects with the mesh
  80084. * @param ray defines the ray to use
  80085. * @param fastCheck defines if fast mode (but less precise) must be used (false by default)
  80086. * @returns the picking info
  80087. * @see http://doc.babylonjs.com/babylon101/intersect_collisions_-_mesh
  80088. */
  80089. AbstractMesh.prototype.intersects = function (ray, fastCheck) {
  80090. var pickingInfo = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]();
  80091. var intersectionThreshold = this.getClassName() === "InstancedLinesMesh" || this.getClassName() === "LinesMesh" ? this.intersectionThreshold : 0;
  80092. var boundingInfo = this._boundingInfo;
  80093. if (!this.subMeshes || !boundingInfo || !ray.intersectsSphere(boundingInfo.boundingSphere, intersectionThreshold) || !ray.intersectsBox(boundingInfo.boundingBox, intersectionThreshold)) {
  80094. return pickingInfo;
  80095. }
  80096. if (!this._generatePointsArray()) {
  80097. return pickingInfo;
  80098. }
  80099. var intersectInfo = null;
  80100. var subMeshes = this._scene.getIntersectingSubMeshCandidates(this, ray);
  80101. var len = subMeshes.length;
  80102. for (var index = 0; index < len; index++) {
  80103. var subMesh = subMeshes.data[index];
  80104. // Bounding test
  80105. if (len > 1 && !subMesh.canIntersects(ray)) {
  80106. continue;
  80107. }
  80108. var currentIntersectInfo = subMesh.intersects(ray, this._positions, this.getIndices(), fastCheck);
  80109. if (currentIntersectInfo) {
  80110. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  80111. intersectInfo = currentIntersectInfo;
  80112. intersectInfo.subMeshId = index;
  80113. if (fastCheck) {
  80114. break;
  80115. }
  80116. }
  80117. }
  80118. }
  80119. if (intersectInfo) {
  80120. // Get picked point
  80121. var world = this.getWorldMatrix();
  80122. var worldOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80123. var direction = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80124. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(ray.origin, world, worldOrigin);
  80125. ray.direction.scaleToRef(intersectInfo.distance, direction);
  80126. var worldDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(direction, world);
  80127. var pickedPoint = worldDirection.addInPlace(worldOrigin);
  80128. // Return result
  80129. pickingInfo.hit = true;
  80130. pickingInfo.distance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(worldOrigin, pickedPoint);
  80131. pickingInfo.pickedPoint = pickedPoint;
  80132. pickingInfo.pickedMesh = this;
  80133. pickingInfo.bu = intersectInfo.bu || 0;
  80134. pickingInfo.bv = intersectInfo.bv || 0;
  80135. pickingInfo.faceId = intersectInfo.faceId;
  80136. pickingInfo.subMeshId = intersectInfo.subMeshId;
  80137. return pickingInfo;
  80138. }
  80139. return pickingInfo;
  80140. };
  80141. /**
  80142. * Clones the current mesh
  80143. * @param name defines the mesh name
  80144. * @param newParent defines the new mesh parent
  80145. * @param doNotCloneChildren defines a boolean indicating that children must not be cloned (false by default)
  80146. * @returns the new mesh
  80147. */
  80148. AbstractMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  80149. return null;
  80150. };
  80151. /**
  80152. * Disposes all the submeshes of the current meshnp
  80153. * @returns the current mesh
  80154. */
  80155. AbstractMesh.prototype.releaseSubMeshes = function () {
  80156. if (this.subMeshes) {
  80157. while (this.subMeshes.length) {
  80158. this.subMeshes[0].dispose();
  80159. }
  80160. }
  80161. else {
  80162. this.subMeshes = new Array();
  80163. }
  80164. return this;
  80165. };
  80166. /**
  80167. * Releases resources associated with this abstract mesh.
  80168. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  80169. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  80170. */
  80171. AbstractMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  80172. var _this = this;
  80173. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  80174. var index;
  80175. // Smart Array Retainers.
  80176. this.getScene().freeActiveMeshes();
  80177. this.getScene().freeRenderingGroups();
  80178. // Action manager
  80179. if (this.actionManager !== undefined && this.actionManager !== null) {
  80180. this.actionManager.dispose();
  80181. this.actionManager = null;
  80182. }
  80183. // Skeleton
  80184. this._skeleton = null;
  80185. // Intersections in progress
  80186. for (index = 0; index < this._intersectionsInProgress.length; index++) {
  80187. var other = this._intersectionsInProgress[index];
  80188. var pos = other._intersectionsInProgress.indexOf(this);
  80189. other._intersectionsInProgress.splice(pos, 1);
  80190. }
  80191. this._intersectionsInProgress = [];
  80192. // Lights
  80193. var lights = this.getScene().lights;
  80194. lights.forEach(function (light) {
  80195. var meshIndex = light.includedOnlyMeshes.indexOf(_this);
  80196. if (meshIndex !== -1) {
  80197. light.includedOnlyMeshes.splice(meshIndex, 1);
  80198. }
  80199. meshIndex = light.excludedMeshes.indexOf(_this);
  80200. if (meshIndex !== -1) {
  80201. light.excludedMeshes.splice(meshIndex, 1);
  80202. }
  80203. // Shadow generators
  80204. var generator = light.getShadowGenerator();
  80205. if (generator) {
  80206. var shadowMap = generator.getShadowMap();
  80207. if (shadowMap && shadowMap.renderList) {
  80208. meshIndex = shadowMap.renderList.indexOf(_this);
  80209. if (meshIndex !== -1) {
  80210. shadowMap.renderList.splice(meshIndex, 1);
  80211. }
  80212. }
  80213. }
  80214. });
  80215. // SubMeshes
  80216. if (this.getClassName() !== "InstancedMesh" || this.getClassName() !== "InstancedLinesMesh") {
  80217. this.releaseSubMeshes();
  80218. }
  80219. // Query
  80220. var engine = this.getScene().getEngine();
  80221. if (this._occlusionQuery) {
  80222. this.isOcclusionQueryInProgress = false;
  80223. engine.deleteQuery(this._occlusionQuery);
  80224. this._occlusionQuery = null;
  80225. }
  80226. // Engine
  80227. engine.wipeCaches();
  80228. // Remove from scene
  80229. this.getScene().removeMesh(this);
  80230. if (disposeMaterialAndTextures) {
  80231. if (this.material) {
  80232. this.material.dispose(false, true);
  80233. }
  80234. }
  80235. if (!doNotRecurse) {
  80236. // Particles
  80237. for (index = 0; index < this.getScene().particleSystems.length; index++) {
  80238. if (this.getScene().particleSystems[index].emitter === this) {
  80239. this.getScene().particleSystems[index].dispose();
  80240. index--;
  80241. }
  80242. }
  80243. }
  80244. // facet data
  80245. if (this._facetData.facetDataEnabled) {
  80246. this.disableFacetData();
  80247. }
  80248. this.onAfterWorldMatrixUpdateObservable.clear();
  80249. this.onCollideObservable.clear();
  80250. this.onCollisionPositionChangeObservable.clear();
  80251. this.onRebuildObservable.clear();
  80252. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  80253. };
  80254. /**
  80255. * Adds the passed mesh as a child to the current mesh
  80256. * @param mesh defines the child mesh
  80257. * @returns the current mesh
  80258. */
  80259. AbstractMesh.prototype.addChild = function (mesh) {
  80260. mesh.setParent(this);
  80261. return this;
  80262. };
  80263. /**
  80264. * Removes the passed mesh from the current mesh children list
  80265. * @param mesh defines the child mesh
  80266. * @returns the current mesh
  80267. */
  80268. AbstractMesh.prototype.removeChild = function (mesh) {
  80269. mesh.setParent(null);
  80270. return this;
  80271. };
  80272. // Facet data
  80273. /** @hidden */
  80274. AbstractMesh.prototype._initFacetData = function () {
  80275. var data = this._facetData;
  80276. if (!data.facetNormals) {
  80277. data.facetNormals = new Array();
  80278. }
  80279. if (!data.facetPositions) {
  80280. data.facetPositions = new Array();
  80281. }
  80282. if (!data.facetPartitioning) {
  80283. data.facetPartitioning = new Array();
  80284. }
  80285. data.facetNb = (this.getIndices().length / 3) | 0;
  80286. data.partitioningSubdivisions = (data.partitioningSubdivisions) ? data.partitioningSubdivisions : 10; // default nb of partitioning subdivisions = 10
  80287. data.partitioningBBoxRatio = (data.partitioningBBoxRatio) ? data.partitioningBBoxRatio : 1.01; // default ratio 1.01 = the partitioning is 1% bigger than the bounding box
  80288. for (var f = 0; f < data.facetNb; f++) {
  80289. data.facetNormals[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80290. data.facetPositions[f] = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80291. }
  80292. data.facetDataEnabled = true;
  80293. return this;
  80294. };
  80295. /**
  80296. * Updates the mesh facetData arrays and the internal partitioning when the mesh is morphed or updated.
  80297. * This method can be called within the render loop.
  80298. * 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
  80299. * @returns the current mesh
  80300. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80301. */
  80302. AbstractMesh.prototype.updateFacetData = function () {
  80303. var data = this._facetData;
  80304. if (!data.facetDataEnabled) {
  80305. this._initFacetData();
  80306. }
  80307. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80308. var indices = this.getIndices();
  80309. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80310. var bInfo = this.getBoundingInfo();
  80311. if (data.facetDepthSort && !data.facetDepthSortEnabled) {
  80312. // init arrays, matrix and sort function on first call
  80313. data.facetDepthSortEnabled = true;
  80314. if (indices instanceof Uint16Array) {
  80315. data.depthSortedIndices = new Uint16Array(indices);
  80316. }
  80317. else if (indices instanceof Uint32Array) {
  80318. data.depthSortedIndices = new Uint32Array(indices);
  80319. }
  80320. else {
  80321. var needs32bits = false;
  80322. for (var i = 0; i < indices.length; i++) {
  80323. if (indices[i] > 65535) {
  80324. needs32bits = true;
  80325. break;
  80326. }
  80327. }
  80328. if (needs32bits) {
  80329. data.depthSortedIndices = new Uint32Array(indices);
  80330. }
  80331. else {
  80332. data.depthSortedIndices = new Uint16Array(indices);
  80333. }
  80334. }
  80335. data.facetDepthSortFunction = function (f1, f2) {
  80336. return (f2.sqDistance - f1.sqDistance);
  80337. };
  80338. if (!data.facetDepthSortFrom) {
  80339. var camera = this.getScene().activeCamera;
  80340. data.facetDepthSortFrom = (camera) ? camera.position : _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80341. }
  80342. data.depthSortedFacets = [];
  80343. for (var f = 0; f < data.facetNb; f++) {
  80344. var depthSortedFacet = { ind: f * 3, sqDistance: 0.0 };
  80345. data.depthSortedFacets.push(depthSortedFacet);
  80346. }
  80347. data.invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  80348. data.facetDepthSortOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80349. }
  80350. 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"];
  80351. 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"];
  80352. 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"];
  80353. var bbSizeMax = (data.bbSize.x > data.bbSize.y) ? data.bbSize.x : data.bbSize.y;
  80354. bbSizeMax = (bbSizeMax > data.bbSize.z) ? bbSizeMax : data.bbSize.z;
  80355. data.subDiv.max = data.partitioningSubdivisions;
  80356. data.subDiv.X = Math.floor(data.subDiv.max * data.bbSize.x / bbSizeMax); // adjust the number of subdivisions per axis
  80357. data.subDiv.Y = Math.floor(data.subDiv.max * data.bbSize.y / bbSizeMax); // according to each bbox size per axis
  80358. data.subDiv.Z = Math.floor(data.subDiv.max * data.bbSize.z / bbSizeMax);
  80359. data.subDiv.X = data.subDiv.X < 1 ? 1 : data.subDiv.X; // at least one subdivision
  80360. data.subDiv.Y = data.subDiv.Y < 1 ? 1 : data.subDiv.Y;
  80361. data.subDiv.Z = data.subDiv.Z < 1 ? 1 : data.subDiv.Z;
  80362. // set the parameters for ComputeNormals()
  80363. data.facetParameters.facetNormals = this.getFacetLocalNormals();
  80364. data.facetParameters.facetPositions = this.getFacetLocalPositions();
  80365. data.facetParameters.facetPartitioning = this.getFacetLocalPartitioning();
  80366. data.facetParameters.bInfo = bInfo;
  80367. data.facetParameters.bbSize = data.bbSize;
  80368. data.facetParameters.subDiv = data.subDiv;
  80369. data.facetParameters.ratio = this.partitioningBBoxRatio;
  80370. data.facetParameters.depthSort = data.facetDepthSort;
  80371. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  80372. this.computeWorldMatrix(true);
  80373. this._worldMatrix.invertToRef(data.invertedMatrix);
  80374. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(data.facetDepthSortFrom, data.invertedMatrix, data.facetDepthSortOrigin);
  80375. data.facetParameters.distanceTo = data.facetDepthSortOrigin;
  80376. }
  80377. data.facetParameters.depthSortedFacets = data.depthSortedFacets;
  80378. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, data.facetParameters);
  80379. if (data.facetDepthSort && data.facetDepthSortEnabled) {
  80380. data.depthSortedFacets.sort(data.facetDepthSortFunction);
  80381. var l = (data.depthSortedIndices.length / 3) | 0;
  80382. for (var f = 0; f < l; f++) {
  80383. var sind = data.depthSortedFacets[f].ind;
  80384. data.depthSortedIndices[f * 3] = indices[sind];
  80385. data.depthSortedIndices[f * 3 + 1] = indices[sind + 1];
  80386. data.depthSortedIndices[f * 3 + 2] = indices[sind + 2];
  80387. }
  80388. this.updateIndices(data.depthSortedIndices);
  80389. }
  80390. return this;
  80391. };
  80392. /**
  80393. * Returns the facetLocalNormals array.
  80394. * The normals are expressed in the mesh local spac
  80395. * @returns an array of Vector3
  80396. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80397. */
  80398. AbstractMesh.prototype.getFacetLocalNormals = function () {
  80399. if (!this._facetData.facetNormals) {
  80400. this.updateFacetData();
  80401. }
  80402. return this._facetData.facetNormals;
  80403. };
  80404. /**
  80405. * Returns the facetLocalPositions array.
  80406. * The facet positions are expressed in the mesh local space
  80407. * @returns an array of Vector3
  80408. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80409. */
  80410. AbstractMesh.prototype.getFacetLocalPositions = function () {
  80411. if (!this._facetData.facetPositions) {
  80412. this.updateFacetData();
  80413. }
  80414. return this._facetData.facetPositions;
  80415. };
  80416. /**
  80417. * Returns the facetLocalPartioning array
  80418. * @returns an array of array of numbers
  80419. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80420. */
  80421. AbstractMesh.prototype.getFacetLocalPartitioning = function () {
  80422. if (!this._facetData.facetPartitioning) {
  80423. this.updateFacetData();
  80424. }
  80425. return this._facetData.facetPartitioning;
  80426. };
  80427. /**
  80428. * Returns the i-th facet position in the world system.
  80429. * This method allocates a new Vector3 per call
  80430. * @param i defines the facet index
  80431. * @returns a new Vector3
  80432. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80433. */
  80434. AbstractMesh.prototype.getFacetPosition = function (i) {
  80435. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80436. this.getFacetPositionToRef(i, pos);
  80437. return pos;
  80438. };
  80439. /**
  80440. * Sets the reference Vector3 with the i-th facet position in the world system
  80441. * @param i defines the facet index
  80442. * @param ref defines the target vector
  80443. * @returns the current mesh
  80444. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80445. */
  80446. AbstractMesh.prototype.getFacetPositionToRef = function (i, ref) {
  80447. var localPos = (this.getFacetLocalPositions())[i];
  80448. var world = this.getWorldMatrix();
  80449. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(localPos, world, ref);
  80450. return this;
  80451. };
  80452. /**
  80453. * Returns the i-th facet normal in the world system.
  80454. * This method allocates a new Vector3 per call
  80455. * @param i defines the facet index
  80456. * @returns a new Vector3
  80457. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80458. */
  80459. AbstractMesh.prototype.getFacetNormal = function (i) {
  80460. var norm = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  80461. this.getFacetNormalToRef(i, norm);
  80462. return norm;
  80463. };
  80464. /**
  80465. * Sets the reference Vector3 with the i-th facet normal in the world system
  80466. * @param i defines the facet index
  80467. * @param ref defines the target vector
  80468. * @returns the current mesh
  80469. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80470. */
  80471. AbstractMesh.prototype.getFacetNormalToRef = function (i, ref) {
  80472. var localNorm = (this.getFacetLocalNormals())[i];
  80473. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localNorm, this.getWorldMatrix(), ref);
  80474. return this;
  80475. };
  80476. /**
  80477. * 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)
  80478. * @param x defines x coordinate
  80479. * @param y defines y coordinate
  80480. * @param z defines z coordinate
  80481. * @returns the array of facet indexes
  80482. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80483. */
  80484. AbstractMesh.prototype.getFacetsAtLocalCoordinates = function (x, y, z) {
  80485. var bInfo = this.getBoundingInfo();
  80486. var data = this._facetData;
  80487. var ox = Math.floor((x - bInfo.minimum.x * data.partitioningBBoxRatio) * data.subDiv.X * data.partitioningBBoxRatio / data.bbSize.x);
  80488. var oy = Math.floor((y - bInfo.minimum.y * data.partitioningBBoxRatio) * data.subDiv.Y * data.partitioningBBoxRatio / data.bbSize.y);
  80489. var oz = Math.floor((z - bInfo.minimum.z * data.partitioningBBoxRatio) * data.subDiv.Z * data.partitioningBBoxRatio / data.bbSize.z);
  80490. if (ox < 0 || ox > data.subDiv.max || oy < 0 || oy > data.subDiv.max || oz < 0 || oz > data.subDiv.max) {
  80491. return null;
  80492. }
  80493. return data.facetPartitioning[ox + data.subDiv.max * oy + data.subDiv.max * data.subDiv.max * oz];
  80494. };
  80495. /**
  80496. * Returns the closest mesh facet index at (x,y,z) World coordinates, null if not found
  80497. * @param projected sets as the (x,y,z) world projection on the facet
  80498. * @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
  80499. * @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
  80500. * @param x defines x coordinate
  80501. * @param y defines y coordinate
  80502. * @param z defines z coordinate
  80503. * @returns the face index if found (or null instead)
  80504. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80505. */
  80506. AbstractMesh.prototype.getClosestFacetAtCoordinates = function (x, y, z, projected, checkFace, facing) {
  80507. if (checkFace === void 0) { checkFace = false; }
  80508. if (facing === void 0) { facing = true; }
  80509. var world = this.getWorldMatrix();
  80510. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5];
  80511. world.invertToRef(invMat);
  80512. var invVect = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[8];
  80513. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(x, y, z, invMat, invVect); // transform (x,y,z) to coordinates in the mesh local space
  80514. var closest = this.getClosestFacetAtLocalCoordinates(invVect.x, invVect.y, invVect.z, projected, checkFace, facing);
  80515. if (projected) {
  80516. // tranform the local computed projected vector to world coordinates
  80517. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(projected.x, projected.y, projected.z, world, projected);
  80518. }
  80519. return closest;
  80520. };
  80521. /**
  80522. * Returns the closest mesh facet index at (x,y,z) local coordinates, null if not found
  80523. * @param projected sets as the (x,y,z) local projection on the facet
  80524. * @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
  80525. * @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
  80526. * @param x defines x coordinate
  80527. * @param y defines y coordinate
  80528. * @param z defines z coordinate
  80529. * @returns the face index if found (or null instead)
  80530. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80531. */
  80532. AbstractMesh.prototype.getClosestFacetAtLocalCoordinates = function (x, y, z, projected, checkFace, facing) {
  80533. if (checkFace === void 0) { checkFace = false; }
  80534. if (facing === void 0) { facing = true; }
  80535. var closest = null;
  80536. var tmpx = 0.0;
  80537. var tmpy = 0.0;
  80538. var tmpz = 0.0;
  80539. var d = 0.0; // tmp dot facet normal * facet position
  80540. var t0 = 0.0;
  80541. var projx = 0.0;
  80542. var projy = 0.0;
  80543. var projz = 0.0;
  80544. // Get all the facets in the same partitioning block than (x, y, z)
  80545. var facetPositions = this.getFacetLocalPositions();
  80546. var facetNormals = this.getFacetLocalNormals();
  80547. var facetsInBlock = this.getFacetsAtLocalCoordinates(x, y, z);
  80548. if (!facetsInBlock) {
  80549. return null;
  80550. }
  80551. // Get the closest facet to (x, y, z)
  80552. var shortest = Number.MAX_VALUE; // init distance vars
  80553. var tmpDistance = shortest;
  80554. var fib; // current facet in the block
  80555. var norm; // current facet normal
  80556. var p0; // current facet barycenter position
  80557. // loop on all the facets in the current partitioning block
  80558. for (var idx = 0; idx < facetsInBlock.length; idx++) {
  80559. fib = facetsInBlock[idx];
  80560. norm = facetNormals[fib];
  80561. p0 = facetPositions[fib];
  80562. d = (x - p0.x) * norm.x + (y - p0.y) * norm.y + (z - p0.z) * norm.z;
  80563. if (!checkFace || (checkFace && facing && d >= 0.0) || (checkFace && !facing && d <= 0.0)) {
  80564. // compute (x,y,z) projection on the facet = (projx, projy, projz)
  80565. d = norm.x * p0.x + norm.y * p0.y + norm.z * p0.z;
  80566. t0 = -(norm.x * x + norm.y * y + norm.z * z - d) / (norm.x * norm.x + norm.y * norm.y + norm.z * norm.z);
  80567. projx = x + norm.x * t0;
  80568. projy = y + norm.y * t0;
  80569. projz = z + norm.z * t0;
  80570. tmpx = projx - x;
  80571. tmpy = projy - y;
  80572. tmpz = projz - z;
  80573. tmpDistance = tmpx * tmpx + tmpy * tmpy + tmpz * tmpz; // compute length between (x, y, z) and its projection on the facet
  80574. if (tmpDistance < shortest) { // just keep the closest facet to (x, y, z)
  80575. shortest = tmpDistance;
  80576. closest = fib;
  80577. if (projected) {
  80578. projected.x = projx;
  80579. projected.y = projy;
  80580. projected.z = projz;
  80581. }
  80582. }
  80583. }
  80584. }
  80585. return closest;
  80586. };
  80587. /**
  80588. * Returns the object "parameter" set with all the expected parameters for facetData computation by ComputeNormals()
  80589. * @returns the parameters
  80590. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80591. */
  80592. AbstractMesh.prototype.getFacetDataParameters = function () {
  80593. return this._facetData.facetParameters;
  80594. };
  80595. /**
  80596. * Disables the feature FacetData and frees the related memory
  80597. * @returns the current mesh
  80598. * @see http://doc.babylonjs.com/how_to/how_to_use_facetdata
  80599. */
  80600. AbstractMesh.prototype.disableFacetData = function () {
  80601. if (this._facetData.facetDataEnabled) {
  80602. this._facetData.facetDataEnabled = false;
  80603. this._facetData.facetPositions = new Array();
  80604. this._facetData.facetNormals = new Array();
  80605. this._facetData.facetPartitioning = new Array();
  80606. this._facetData.facetParameters = null;
  80607. this._facetData.depthSortedIndices = new Uint32Array(0);
  80608. }
  80609. return this;
  80610. };
  80611. /**
  80612. * Updates the AbstractMesh indices array
  80613. * @param indices defines the data source
  80614. * @returns the current mesh
  80615. */
  80616. AbstractMesh.prototype.updateIndices = function (indices) {
  80617. return this;
  80618. };
  80619. /**
  80620. * Creates new normals data for the mesh
  80621. * @param updatable defines if the normal vertex buffer must be flagged as updatable
  80622. * @returns the current mesh
  80623. */
  80624. AbstractMesh.prototype.createNormals = function (updatable) {
  80625. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind);
  80626. var indices = this.getIndices();
  80627. var normals;
  80628. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind)) {
  80629. normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind);
  80630. }
  80631. else {
  80632. normals = [];
  80633. }
  80634. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_6__["VertexData"].ComputeNormals(positions, indices, normals, { useRightHandedSystem: this.getScene().useRightHandedSystem });
  80635. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].NormalKind, normals, updatable);
  80636. return this;
  80637. };
  80638. /**
  80639. * Align the mesh with a normal
  80640. * @param normal defines the normal to use
  80641. * @param upDirection can be used to redefined the up vector to use (will use the (0, 1, 0) by default)
  80642. * @returns the current mesh
  80643. */
  80644. AbstractMesh.prototype.alignWithNormal = function (normal, upDirection) {
  80645. if (!upDirection) {
  80646. upDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Axis"].Y;
  80647. }
  80648. var axisX = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  80649. var axisZ = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  80650. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(upDirection, normal, axisZ);
  80651. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].CrossToRef(normal, axisZ, axisX);
  80652. if (this.rotationQuaternion) {
  80653. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationQuaternionFromAxisToRef(axisX, normal, axisZ, this.rotationQuaternion);
  80654. }
  80655. else {
  80656. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].RotationFromAxisToRef(axisX, normal, axisZ, this.rotation);
  80657. }
  80658. return this;
  80659. };
  80660. /** @hidden */
  80661. AbstractMesh.prototype._checkOcclusionQuery = function () {
  80662. return false;
  80663. };
  80664. /** No occlusion */
  80665. AbstractMesh.OCCLUSION_TYPE_NONE = 0;
  80666. /** Occlusion set to optimisitic */
  80667. AbstractMesh.OCCLUSION_TYPE_OPTIMISTIC = 1;
  80668. /** Occlusion set to strict */
  80669. AbstractMesh.OCCLUSION_TYPE_STRICT = 2;
  80670. /** Use an accurante occlusion algorithm */
  80671. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_ACCURATE = 0;
  80672. /** Use a conservative occlusion algorithm */
  80673. AbstractMesh.OCCLUSION_ALGORITHM_TYPE_CONSERVATIVE = 1;
  80674. /** Default culling strategy : this is an exclusion test and it's the more accurate.
  80675. * Test order :
  80676. * Is the bounding sphere outside the frustum ?
  80677. * If not, are the bounding box vertices outside the frustum ?
  80678. * It not, then the cullable object is in the frustum.
  80679. */
  80680. AbstractMesh.CULLINGSTRATEGY_STANDARD = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_STANDARD;
  80681. /** Culling strategy : Bounding Sphere Only.
  80682. * This is an exclusion test. It's faster than the standard strategy because the bounding box is not tested.
  80683. * It's also less accurate than the standard because some not visible objects can still be selected.
  80684. * Test : is the bounding sphere outside the frustum ?
  80685. * If not, then the cullable object is in the frustum.
  80686. */
  80687. AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  80688. /** Culling strategy : Optimistic Inclusion.
  80689. * This in an inclusion test first, then the standard exclusion test.
  80690. * This can be faster when a cullable object is expected to be almost always in the camera frustum.
  80691. * 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.
  80692. * Anyway, it's as accurate as the standard strategy.
  80693. * Test :
  80694. * Is the cullable object bounding sphere center in the frustum ?
  80695. * If not, apply the default culling strategy.
  80696. */
  80697. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION;
  80698. /** Culling strategy : Optimistic Inclusion then Bounding Sphere Only.
  80699. * This in an inclusion test first, then the bounding sphere only exclusion test.
  80700. * This can be the fastest test when a cullable object is expected to be almost always in the camera frustum.
  80701. * 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.
  80702. * It's less accurate than the standard strategy and as accurate as the BoundingSphereOnly strategy.
  80703. * Test :
  80704. * Is the cullable object bounding sphere center in the frustum ?
  80705. * If not, apply the Bounding Sphere Only strategy. No Bounding Box is tested here.
  80706. */
  80707. AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY = _Engines_constants__WEBPACK_IMPORTED_MODULE_10__["Constants"].MESHES_CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY;
  80708. return AbstractMesh;
  80709. }(_Meshes_transformNode__WEBPACK_IMPORTED_MODULE_7__["TransformNode"]));
  80710. /***/ }),
  80711. /***/ "./Meshes/buffer.ts":
  80712. /*!**************************!*\
  80713. !*** ./Meshes/buffer.ts ***!
  80714. \**************************/
  80715. /*! exports provided: Buffer, VertexBuffer */
  80716. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  80717. "use strict";
  80718. __webpack_require__.r(__webpack_exports__);
  80719. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return Buffer; });
  80720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return VertexBuffer; });
  80721. /**
  80722. * Class used to store data that will be store in GPU memory
  80723. */
  80724. var Buffer = /** @class */ (function () {
  80725. /**
  80726. * Constructor
  80727. * @param engine the engine
  80728. * @param data the data to use for this buffer
  80729. * @param updatable whether the data is updatable
  80730. * @param stride the stride (optional)
  80731. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80732. * @param instanced whether the buffer is instanced (optional)
  80733. * @param useBytes set to true if the stride in in bytes (optional)
  80734. */
  80735. function Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes) {
  80736. if (stride === void 0) { stride = 0; }
  80737. if (postponeInternalCreation === void 0) { postponeInternalCreation = false; }
  80738. if (instanced === void 0) { instanced = false; }
  80739. if (useBytes === void 0) { useBytes = false; }
  80740. if (engine.getScene) { // old versions of VertexBuffer accepted 'mesh' instead of 'engine'
  80741. this._engine = engine.getScene().getEngine();
  80742. }
  80743. else {
  80744. this._engine = engine;
  80745. }
  80746. this._updatable = updatable;
  80747. this._instanced = instanced;
  80748. this._data = data;
  80749. this.byteStride = useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT;
  80750. if (!postponeInternalCreation) { // by default
  80751. this.create();
  80752. }
  80753. }
  80754. /**
  80755. * Create a new VertexBuffer based on the current buffer
  80756. * @param kind defines the vertex buffer kind (position, normal, etc.)
  80757. * @param offset defines offset in the buffer (0 by default)
  80758. * @param size defines the size in floats of attributes (position is 3 for instance)
  80759. * @param stride defines the stride size in floats in the buffer (the offset to apply to reach next value when data is interleaved)
  80760. * @param instanced defines if the vertex buffer contains indexed data
  80761. * @param useBytes defines if the offset and stride are in bytes
  80762. * @returns the new vertex buffer
  80763. */
  80764. Buffer.prototype.createVertexBuffer = function (kind, offset, size, stride, instanced, useBytes) {
  80765. if (useBytes === void 0) { useBytes = false; }
  80766. var byteOffset = useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT;
  80767. var byteStride = stride ? (useBytes ? stride : stride * Float32Array.BYTES_PER_ELEMENT) : this.byteStride;
  80768. // a lot of these parameters are ignored as they are overriden by the buffer
  80769. return new VertexBuffer(this._engine, this, kind, this._updatable, true, byteStride, instanced === undefined ? this._instanced : instanced, byteOffset, size, undefined, undefined, true);
  80770. };
  80771. // Properties
  80772. /**
  80773. * Gets a boolean indicating if the Buffer is updatable?
  80774. * @returns true if the buffer is updatable
  80775. */
  80776. Buffer.prototype.isUpdatable = function () {
  80777. return this._updatable;
  80778. };
  80779. /**
  80780. * Gets current buffer's data
  80781. * @returns a DataArray or null
  80782. */
  80783. Buffer.prototype.getData = function () {
  80784. return this._data;
  80785. };
  80786. /**
  80787. * Gets underlying native buffer
  80788. * @returns underlying native buffer
  80789. */
  80790. Buffer.prototype.getBuffer = function () {
  80791. return this._buffer;
  80792. };
  80793. /**
  80794. * Gets the stride in float32 units (i.e. byte stride / 4).
  80795. * May not be an integer if the byte stride is not divisible by 4.
  80796. * DEPRECATED. Use byteStride instead.
  80797. * @returns the stride in float32 units
  80798. */
  80799. Buffer.prototype.getStrideSize = function () {
  80800. return this.byteStride / Float32Array.BYTES_PER_ELEMENT;
  80801. };
  80802. // Methods
  80803. /**
  80804. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  80805. * @param data defines the data to store
  80806. */
  80807. Buffer.prototype.create = function (data) {
  80808. if (data === void 0) { data = null; }
  80809. if (!data && this._buffer) {
  80810. return; // nothing to do
  80811. }
  80812. data = data || this._data;
  80813. if (!data) {
  80814. return;
  80815. }
  80816. if (!this._buffer) { // create buffer
  80817. if (this._updatable) {
  80818. this._buffer = this._engine.createDynamicVertexBuffer(data);
  80819. this._data = data;
  80820. }
  80821. else {
  80822. this._buffer = this._engine.createVertexBuffer(data);
  80823. }
  80824. }
  80825. else if (this._updatable) { // update buffer
  80826. this._engine.updateDynamicVertexBuffer(this._buffer, data);
  80827. this._data = data;
  80828. }
  80829. };
  80830. /** @hidden */
  80831. Buffer.prototype._rebuild = function () {
  80832. this._buffer = null;
  80833. this.create(this._data);
  80834. };
  80835. /**
  80836. * Update current buffer data
  80837. * @param data defines the data to store
  80838. */
  80839. Buffer.prototype.update = function (data) {
  80840. this.create(data);
  80841. };
  80842. /**
  80843. * Updates the data directly.
  80844. * @param data the new data
  80845. * @param offset the new offset
  80846. * @param vertexCount the vertex count (optional)
  80847. * @param useBytes set to true if the offset is in bytes
  80848. */
  80849. Buffer.prototype.updateDirectly = function (data, offset, vertexCount, useBytes) {
  80850. if (useBytes === void 0) { useBytes = false; }
  80851. if (!this._buffer) {
  80852. return;
  80853. }
  80854. if (this._updatable) { // update buffer
  80855. this._engine.updateDynamicVertexBuffer(this._buffer, data, useBytes ? offset : offset * Float32Array.BYTES_PER_ELEMENT, (vertexCount ? vertexCount * this.byteStride : undefined));
  80856. this._data = null;
  80857. }
  80858. };
  80859. /**
  80860. * Release all resources
  80861. */
  80862. Buffer.prototype.dispose = function () {
  80863. if (!this._buffer) {
  80864. return;
  80865. }
  80866. if (this._engine._releaseBuffer(this._buffer)) {
  80867. this._buffer = null;
  80868. }
  80869. };
  80870. return Buffer;
  80871. }());
  80872. /**
  80873. * Specialized buffer used to store vertex data
  80874. */
  80875. var VertexBuffer = /** @class */ (function () {
  80876. /**
  80877. * Constructor
  80878. * @param engine the engine
  80879. * @param data the data to use for this vertex buffer
  80880. * @param kind the vertex buffer kind
  80881. * @param updatable whether the data is updatable
  80882. * @param postponeInternalCreation whether to postpone creating the internal WebGL buffer (optional)
  80883. * @param stride the stride (optional)
  80884. * @param instanced whether the buffer is instanced (optional)
  80885. * @param offset the offset of the data (optional)
  80886. * @param size the number of components (optional)
  80887. * @param type the type of the component (optional)
  80888. * @param normalized whether the data contains normalized data (optional)
  80889. * @param useBytes set to true if stride and offset are in bytes (optional)
  80890. */
  80891. function VertexBuffer(engine, data, kind, updatable, postponeInternalCreation, stride, instanced, offset, size, type, normalized, useBytes) {
  80892. if (normalized === void 0) { normalized = false; }
  80893. if (useBytes === void 0) { useBytes = false; }
  80894. if (data instanceof Buffer) {
  80895. this._buffer = data;
  80896. this._ownsBuffer = false;
  80897. }
  80898. else {
  80899. this._buffer = new Buffer(engine, data, updatable, stride, postponeInternalCreation, instanced, useBytes);
  80900. this._ownsBuffer = true;
  80901. }
  80902. this._kind = kind;
  80903. if (type == undefined) {
  80904. var data_1 = this.getData();
  80905. this.type = VertexBuffer.FLOAT;
  80906. if (data_1 instanceof Int8Array) {
  80907. this.type = VertexBuffer.BYTE;
  80908. }
  80909. else if (data_1 instanceof Uint8Array) {
  80910. this.type = VertexBuffer.UNSIGNED_BYTE;
  80911. }
  80912. else if (data_1 instanceof Int16Array) {
  80913. this.type = VertexBuffer.SHORT;
  80914. }
  80915. else if (data_1 instanceof Uint16Array) {
  80916. this.type = VertexBuffer.UNSIGNED_SHORT;
  80917. }
  80918. else if (data_1 instanceof Int32Array) {
  80919. this.type = VertexBuffer.INT;
  80920. }
  80921. else if (data_1 instanceof Uint32Array) {
  80922. this.type = VertexBuffer.UNSIGNED_INT;
  80923. }
  80924. }
  80925. else {
  80926. this.type = type;
  80927. }
  80928. var typeByteLength = VertexBuffer.GetTypeByteLength(this.type);
  80929. if (useBytes) {
  80930. this._size = size || (stride ? (stride / typeByteLength) : VertexBuffer.DeduceStride(kind));
  80931. this.byteStride = stride || this._buffer.byteStride || (this._size * typeByteLength);
  80932. this.byteOffset = offset || 0;
  80933. }
  80934. else {
  80935. this._size = size || stride || VertexBuffer.DeduceStride(kind);
  80936. this.byteStride = stride ? (stride * typeByteLength) : (this._buffer.byteStride || (this._size * typeByteLength));
  80937. this.byteOffset = (offset || 0) * typeByteLength;
  80938. }
  80939. this.normalized = normalized;
  80940. this._instanced = instanced !== undefined ? instanced : false;
  80941. this._instanceDivisor = instanced ? 1 : 0;
  80942. }
  80943. Object.defineProperty(VertexBuffer.prototype, "instanceDivisor", {
  80944. /**
  80945. * Gets or sets the instance divisor when in instanced mode
  80946. */
  80947. get: function () {
  80948. return this._instanceDivisor;
  80949. },
  80950. set: function (value) {
  80951. this._instanceDivisor = value;
  80952. if (value == 0) {
  80953. this._instanced = false;
  80954. }
  80955. else {
  80956. this._instanced = true;
  80957. }
  80958. },
  80959. enumerable: true,
  80960. configurable: true
  80961. });
  80962. /** @hidden */
  80963. VertexBuffer.prototype._rebuild = function () {
  80964. if (!this._buffer) {
  80965. return;
  80966. }
  80967. this._buffer._rebuild();
  80968. };
  80969. /**
  80970. * Returns the kind of the VertexBuffer (string)
  80971. * @returns a string
  80972. */
  80973. VertexBuffer.prototype.getKind = function () {
  80974. return this._kind;
  80975. };
  80976. // Properties
  80977. /**
  80978. * Gets a boolean indicating if the VertexBuffer is updatable?
  80979. * @returns true if the buffer is updatable
  80980. */
  80981. VertexBuffer.prototype.isUpdatable = function () {
  80982. return this._buffer.isUpdatable();
  80983. };
  80984. /**
  80985. * Gets current buffer's data
  80986. * @returns a DataArray or null
  80987. */
  80988. VertexBuffer.prototype.getData = function () {
  80989. return this._buffer.getData();
  80990. };
  80991. /**
  80992. * Gets underlying native buffer
  80993. * @returns underlying native buffer
  80994. */
  80995. VertexBuffer.prototype.getBuffer = function () {
  80996. return this._buffer.getBuffer();
  80997. };
  80998. /**
  80999. * Gets the stride in float32 units (i.e. byte stride / 4).
  81000. * May not be an integer if the byte stride is not divisible by 4.
  81001. * DEPRECATED. Use byteStride instead.
  81002. * @returns the stride in float32 units
  81003. */
  81004. VertexBuffer.prototype.getStrideSize = function () {
  81005. return this.byteStride / VertexBuffer.GetTypeByteLength(this.type);
  81006. };
  81007. /**
  81008. * Returns the offset as a multiple of the type byte length.
  81009. * DEPRECATED. Use byteOffset instead.
  81010. * @returns the offset in bytes
  81011. */
  81012. VertexBuffer.prototype.getOffset = function () {
  81013. return this.byteOffset / VertexBuffer.GetTypeByteLength(this.type);
  81014. };
  81015. /**
  81016. * Returns the number of components per vertex attribute (integer)
  81017. * @returns the size in float
  81018. */
  81019. VertexBuffer.prototype.getSize = function () {
  81020. return this._size;
  81021. };
  81022. /**
  81023. * Gets a boolean indicating is the internal buffer of the VertexBuffer is instanced
  81024. * @returns true if this buffer is instanced
  81025. */
  81026. VertexBuffer.prototype.getIsInstanced = function () {
  81027. return this._instanced;
  81028. };
  81029. /**
  81030. * Returns the instancing divisor, zero for non-instanced (integer).
  81031. * @returns a number
  81032. */
  81033. VertexBuffer.prototype.getInstanceDivisor = function () {
  81034. return this._instanceDivisor;
  81035. };
  81036. // Methods
  81037. /**
  81038. * Store data into the buffer. If the buffer was already used it will be either recreated or updated depending on isUpdatable property
  81039. * @param data defines the data to store
  81040. */
  81041. VertexBuffer.prototype.create = function (data) {
  81042. this._buffer.create(data);
  81043. };
  81044. /**
  81045. * Updates the underlying buffer according to the passed numeric array or Float32Array.
  81046. * This function will create a new buffer if the current one is not updatable
  81047. * @param data defines the data to store
  81048. */
  81049. VertexBuffer.prototype.update = function (data) {
  81050. this._buffer.update(data);
  81051. };
  81052. /**
  81053. * Updates directly the underlying WebGLBuffer according to the passed numeric array or Float32Array.
  81054. * Returns the directly updated WebGLBuffer.
  81055. * @param data the new data
  81056. * @param offset the new offset
  81057. * @param useBytes set to true if the offset is in bytes
  81058. */
  81059. VertexBuffer.prototype.updateDirectly = function (data, offset, useBytes) {
  81060. if (useBytes === void 0) { useBytes = false; }
  81061. this._buffer.updateDirectly(data, offset, undefined, useBytes);
  81062. };
  81063. /**
  81064. * Disposes the VertexBuffer and the underlying WebGLBuffer.
  81065. */
  81066. VertexBuffer.prototype.dispose = function () {
  81067. if (this._ownsBuffer) {
  81068. this._buffer.dispose();
  81069. }
  81070. };
  81071. /**
  81072. * Enumerates each value of this vertex buffer as numbers.
  81073. * @param count the number of values to enumerate
  81074. * @param callback the callback function called for each value
  81075. */
  81076. VertexBuffer.prototype.forEach = function (count, callback) {
  81077. VertexBuffer.ForEach(this._buffer.getData(), this.byteOffset, this.byteStride, this._size, this.type, count, this.normalized, callback);
  81078. };
  81079. /**
  81080. * Deduces the stride given a kind.
  81081. * @param kind The kind string to deduce
  81082. * @returns The deduced stride
  81083. */
  81084. VertexBuffer.DeduceStride = function (kind) {
  81085. switch (kind) {
  81086. case VertexBuffer.UVKind:
  81087. case VertexBuffer.UV2Kind:
  81088. case VertexBuffer.UV3Kind:
  81089. case VertexBuffer.UV4Kind:
  81090. case VertexBuffer.UV5Kind:
  81091. case VertexBuffer.UV6Kind:
  81092. return 2;
  81093. case VertexBuffer.NormalKind:
  81094. case VertexBuffer.PositionKind:
  81095. return 3;
  81096. case VertexBuffer.ColorKind:
  81097. case VertexBuffer.MatricesIndicesKind:
  81098. case VertexBuffer.MatricesIndicesExtraKind:
  81099. case VertexBuffer.MatricesWeightsKind:
  81100. case VertexBuffer.MatricesWeightsExtraKind:
  81101. case VertexBuffer.TangentKind:
  81102. return 4;
  81103. default:
  81104. throw new Error("Invalid kind '" + kind + "'");
  81105. }
  81106. };
  81107. /**
  81108. * Gets the byte length of the given type.
  81109. * @param type the type
  81110. * @returns the number of bytes
  81111. */
  81112. VertexBuffer.GetTypeByteLength = function (type) {
  81113. switch (type) {
  81114. case VertexBuffer.BYTE:
  81115. case VertexBuffer.UNSIGNED_BYTE:
  81116. return 1;
  81117. case VertexBuffer.SHORT:
  81118. case VertexBuffer.UNSIGNED_SHORT:
  81119. return 2;
  81120. case VertexBuffer.INT:
  81121. case VertexBuffer.FLOAT:
  81122. return 4;
  81123. default:
  81124. throw new Error("Invalid type '" + type + "'");
  81125. }
  81126. };
  81127. /**
  81128. * Enumerates each value of the given parameters as numbers.
  81129. * @param data the data to enumerate
  81130. * @param byteOffset the byte offset of the data
  81131. * @param byteStride the byte stride of the data
  81132. * @param componentCount the number of components per element
  81133. * @param componentType the type of the component
  81134. * @param count the total number of components
  81135. * @param normalized whether the data is normalized
  81136. * @param callback the callback function called for each value
  81137. */
  81138. VertexBuffer.ForEach = function (data, byteOffset, byteStride, componentCount, componentType, count, normalized, callback) {
  81139. if (data instanceof Array) {
  81140. var offset = byteOffset / 4;
  81141. var stride = byteStride / 4;
  81142. for (var index = 0; index < count; index += componentCount) {
  81143. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  81144. callback(data[offset + componentIndex], index + componentIndex);
  81145. }
  81146. offset += stride;
  81147. }
  81148. }
  81149. else {
  81150. var dataView = data instanceof ArrayBuffer ? new DataView(data) : new DataView(data.buffer, data.byteOffset, data.byteLength);
  81151. var componentByteLength = VertexBuffer.GetTypeByteLength(componentType);
  81152. for (var index = 0; index < count; index += componentCount) {
  81153. var componentByteOffset = byteOffset;
  81154. for (var componentIndex = 0; componentIndex < componentCount; componentIndex++) {
  81155. var value = VertexBuffer._GetFloatValue(dataView, componentType, componentByteOffset, normalized);
  81156. callback(value, index + componentIndex);
  81157. componentByteOffset += componentByteLength;
  81158. }
  81159. byteOffset += byteStride;
  81160. }
  81161. }
  81162. };
  81163. VertexBuffer._GetFloatValue = function (dataView, type, byteOffset, normalized) {
  81164. switch (type) {
  81165. case VertexBuffer.BYTE: {
  81166. var value = dataView.getInt8(byteOffset);
  81167. if (normalized) {
  81168. value = Math.max(value / 127, -1);
  81169. }
  81170. return value;
  81171. }
  81172. case VertexBuffer.UNSIGNED_BYTE: {
  81173. var value = dataView.getUint8(byteOffset);
  81174. if (normalized) {
  81175. value = value / 255;
  81176. }
  81177. return value;
  81178. }
  81179. case VertexBuffer.SHORT: {
  81180. var value = dataView.getInt16(byteOffset, true);
  81181. if (normalized) {
  81182. value = Math.max(value / 16383, -1);
  81183. }
  81184. return value;
  81185. }
  81186. case VertexBuffer.UNSIGNED_SHORT: {
  81187. var value = dataView.getUint16(byteOffset, true);
  81188. if (normalized) {
  81189. value = value / 65535;
  81190. }
  81191. return value;
  81192. }
  81193. case VertexBuffer.FLOAT: {
  81194. return dataView.getFloat32(byteOffset, true);
  81195. }
  81196. default: {
  81197. throw new Error("Invalid component type " + type);
  81198. }
  81199. }
  81200. };
  81201. /**
  81202. * The byte type.
  81203. */
  81204. VertexBuffer.BYTE = 5120;
  81205. /**
  81206. * The unsigned byte type.
  81207. */
  81208. VertexBuffer.UNSIGNED_BYTE = 5121;
  81209. /**
  81210. * The short type.
  81211. */
  81212. VertexBuffer.SHORT = 5122;
  81213. /**
  81214. * The unsigned short type.
  81215. */
  81216. VertexBuffer.UNSIGNED_SHORT = 5123;
  81217. /**
  81218. * The integer type.
  81219. */
  81220. VertexBuffer.INT = 5124;
  81221. /**
  81222. * The unsigned integer type.
  81223. */
  81224. VertexBuffer.UNSIGNED_INT = 5125;
  81225. /**
  81226. * The float type.
  81227. */
  81228. VertexBuffer.FLOAT = 5126;
  81229. // Enums
  81230. /**
  81231. * Positions
  81232. */
  81233. VertexBuffer.PositionKind = "position";
  81234. /**
  81235. * Normals
  81236. */
  81237. VertexBuffer.NormalKind = "normal";
  81238. /**
  81239. * Tangents
  81240. */
  81241. VertexBuffer.TangentKind = "tangent";
  81242. /**
  81243. * Texture coordinates
  81244. */
  81245. VertexBuffer.UVKind = "uv";
  81246. /**
  81247. * Texture coordinates 2
  81248. */
  81249. VertexBuffer.UV2Kind = "uv2";
  81250. /**
  81251. * Texture coordinates 3
  81252. */
  81253. VertexBuffer.UV3Kind = "uv3";
  81254. /**
  81255. * Texture coordinates 4
  81256. */
  81257. VertexBuffer.UV4Kind = "uv4";
  81258. /**
  81259. * Texture coordinates 5
  81260. */
  81261. VertexBuffer.UV5Kind = "uv5";
  81262. /**
  81263. * Texture coordinates 6
  81264. */
  81265. VertexBuffer.UV6Kind = "uv6";
  81266. /**
  81267. * Colors
  81268. */
  81269. VertexBuffer.ColorKind = "color";
  81270. /**
  81271. * Matrix indices (for bones)
  81272. */
  81273. VertexBuffer.MatricesIndicesKind = "matricesIndices";
  81274. /**
  81275. * Matrix weights (for bones)
  81276. */
  81277. VertexBuffer.MatricesWeightsKind = "matricesWeights";
  81278. /**
  81279. * Additional matrix indices (for bones)
  81280. */
  81281. VertexBuffer.MatricesIndicesExtraKind = "matricesIndicesExtra";
  81282. /**
  81283. * Additional matrix weights (for bones)
  81284. */
  81285. VertexBuffer.MatricesWeightsExtraKind = "matricesWeightsExtra";
  81286. return VertexBuffer;
  81287. }());
  81288. /***/ }),
  81289. /***/ "./Meshes/csg.ts":
  81290. /*!***********************!*\
  81291. !*** ./Meshes/csg.ts ***!
  81292. \***********************/
  81293. /*! exports provided: CSG */
  81294. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81295. "use strict";
  81296. __webpack_require__.r(__webpack_exports__);
  81297. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return CSG; });
  81298. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81299. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81300. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81301. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  81302. /**
  81303. * Unique ID when we import meshes from Babylon to CSG
  81304. */
  81305. var currentCSGMeshId = 0;
  81306. /**
  81307. * Represents a vertex of a polygon. Use your own vertex class instead of this
  81308. * one to provide additional features like texture coordinates and vertex
  81309. * colors. Custom vertex classes need to provide a `pos` property and `clone()`,
  81310. * `flip()`, and `interpolate()` methods that behave analogous to the ones
  81311. * defined by `BABYLON.CSG.Vertex`. This class provides `normal` so convenience
  81312. * functions like `BABYLON.CSG.sphere()` can return a smooth vertex normal, but `normal`
  81313. * is not used anywhere else.
  81314. * Same goes for uv, it allows to keep the original vertex uv coordinates of the 2 meshes
  81315. */
  81316. var Vertex = /** @class */ (function () {
  81317. /**
  81318. * Initializes the vertex
  81319. * @param pos The position of the vertex
  81320. * @param normal The normal of the vertex
  81321. * @param uv The texture coordinate of the vertex
  81322. */
  81323. function Vertex(
  81324. /**
  81325. * The position of the vertex
  81326. */
  81327. pos,
  81328. /**
  81329. * The normal of the vertex
  81330. */
  81331. normal,
  81332. /**
  81333. * The texture coordinate of the vertex
  81334. */
  81335. uv) {
  81336. this.pos = pos;
  81337. this.normal = normal;
  81338. this.uv = uv;
  81339. }
  81340. /**
  81341. * Make a clone, or deep copy, of the vertex
  81342. * @returns A new Vertex
  81343. */
  81344. Vertex.prototype.clone = function () {
  81345. return new Vertex(this.pos.clone(), this.normal.clone(), this.uv.clone());
  81346. };
  81347. /**
  81348. * Invert all orientation-specific data (e.g. vertex normal). Called when the
  81349. * orientation of a polygon is flipped.
  81350. */
  81351. Vertex.prototype.flip = function () {
  81352. this.normal = this.normal.scale(-1);
  81353. };
  81354. /**
  81355. * Create a new vertex between this vertex and `other` by linearly
  81356. * interpolating all properties using a parameter of `t`. Subclasses should
  81357. * override this to interpolate additional properties.
  81358. * @param other the vertex to interpolate against
  81359. * @param t The factor used to linearly interpolate between the vertices
  81360. */
  81361. Vertex.prototype.interpolate = function (other, t) {
  81362. 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));
  81363. };
  81364. return Vertex;
  81365. }());
  81366. /**
  81367. * Represents a plane in 3D space.
  81368. */
  81369. var Plane = /** @class */ (function () {
  81370. /**
  81371. * Initializes the plane
  81372. * @param normal The normal for the plane
  81373. * @param w
  81374. */
  81375. function Plane(normal, w) {
  81376. this.normal = normal;
  81377. this.w = w;
  81378. }
  81379. /**
  81380. * Construct a plane from three points
  81381. * @param a Point a
  81382. * @param b Point b
  81383. * @param c Point c
  81384. */
  81385. Plane.FromPoints = function (a, b, c) {
  81386. var v0 = c.subtract(a);
  81387. var v1 = b.subtract(a);
  81388. if (v0.lengthSquared() === 0 || v1.lengthSquared() === 0) {
  81389. return null;
  81390. }
  81391. var n = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(v0, v1));
  81392. return new Plane(n, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(n, a));
  81393. };
  81394. /**
  81395. * Clone, or make a deep copy of the plane
  81396. * @returns a new Plane
  81397. */
  81398. Plane.prototype.clone = function () {
  81399. return new Plane(this.normal.clone(), this.w);
  81400. };
  81401. /**
  81402. * Flip the face of the plane
  81403. */
  81404. Plane.prototype.flip = function () {
  81405. this.normal.scaleInPlace(-1);
  81406. this.w = -this.w;
  81407. };
  81408. /**
  81409. * Split `polygon` by this plane if needed, then put the polygon or polygon
  81410. * fragments in the appropriate lists. Coplanar polygons go into either
  81411. `* coplanarFront` or `coplanarBack` depending on their orientation with
  81412. * respect to this plane. Polygons in front or in back of this plane go into
  81413. * either `front` or `back`
  81414. * @param polygon The polygon to be split
  81415. * @param coplanarFront Will contain polygons coplanar with the plane that are oriented to the front of the plane
  81416. * @param coplanarBack Will contain polygons coplanar with the plane that are oriented to the back of the plane
  81417. * @param front Will contain the polygons in front of the plane
  81418. * @param back Will contain the polygons begind the plane
  81419. */
  81420. Plane.prototype.splitPolygon = function (polygon, coplanarFront, coplanarBack, front, back) {
  81421. var COPLANAR = 0;
  81422. var FRONT = 1;
  81423. var BACK = 2;
  81424. var SPANNING = 3;
  81425. // Classify each point as well as the entire polygon into one of the above
  81426. // four classes.
  81427. var polygonType = 0;
  81428. var types = [];
  81429. var i;
  81430. var t;
  81431. for (i = 0; i < polygon.vertices.length; i++) {
  81432. t = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.vertices[i].pos) - this.w;
  81433. var type = (t < -Plane.EPSILON) ? BACK : (t > Plane.EPSILON) ? FRONT : COPLANAR;
  81434. polygonType |= type;
  81435. types.push(type);
  81436. }
  81437. // Put the polygon in the correct list, splitting it when necessary
  81438. switch (polygonType) {
  81439. case COPLANAR:
  81440. (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(this.normal, polygon.plane.normal) > 0 ? coplanarFront : coplanarBack).push(polygon);
  81441. break;
  81442. case FRONT:
  81443. front.push(polygon);
  81444. break;
  81445. case BACK:
  81446. back.push(polygon);
  81447. break;
  81448. case SPANNING:
  81449. var f = [], b = [];
  81450. for (i = 0; i < polygon.vertices.length; i++) {
  81451. var j = (i + 1) % polygon.vertices.length;
  81452. var ti = types[i], tj = types[j];
  81453. var vi = polygon.vertices[i], vj = polygon.vertices[j];
  81454. if (ti !== BACK) {
  81455. f.push(vi);
  81456. }
  81457. if (ti !== FRONT) {
  81458. b.push(ti !== BACK ? vi.clone() : vi);
  81459. }
  81460. if ((ti | tj) === SPANNING) {
  81461. 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));
  81462. var v = vi.interpolate(vj, t);
  81463. f.push(v);
  81464. b.push(v.clone());
  81465. }
  81466. }
  81467. var poly;
  81468. if (f.length >= 3) {
  81469. poly = new Polygon(f, polygon.shared);
  81470. if (poly.plane) {
  81471. front.push(poly);
  81472. }
  81473. }
  81474. if (b.length >= 3) {
  81475. poly = new Polygon(b, polygon.shared);
  81476. if (poly.plane) {
  81477. back.push(poly);
  81478. }
  81479. }
  81480. break;
  81481. }
  81482. };
  81483. /**
  81484. * `CSG.Plane.EPSILON` is the tolerance used by `splitPolygon()` to decide if a
  81485. * point is on the plane
  81486. */
  81487. Plane.EPSILON = 1e-5;
  81488. return Plane;
  81489. }());
  81490. /**
  81491. * Represents a convex polygon. The vertices used to initialize a polygon must
  81492. * be coplanar and form a convex loop.
  81493. *
  81494. * Each convex polygon has a `shared` property, which is shared between all
  81495. * polygons that are clones of each other or were split from the same polygon.
  81496. * This can be used to define per-polygon properties (such as surface color)
  81497. */
  81498. var Polygon = /** @class */ (function () {
  81499. /**
  81500. * Initializes the polygon
  81501. * @param vertices The vertices of the polygon
  81502. * @param shared The properties shared across all polygons
  81503. */
  81504. function Polygon(vertices, shared) {
  81505. this.vertices = vertices;
  81506. this.shared = shared;
  81507. this.plane = Plane.FromPoints(vertices[0].pos, vertices[1].pos, vertices[2].pos);
  81508. }
  81509. /**
  81510. * Clones, or makes a deep copy, or the polygon
  81511. */
  81512. Polygon.prototype.clone = function () {
  81513. var vertices = this.vertices.map(function (v) { return v.clone(); });
  81514. return new Polygon(vertices, this.shared);
  81515. };
  81516. /**
  81517. * Flips the faces of the polygon
  81518. */
  81519. Polygon.prototype.flip = function () {
  81520. this.vertices.reverse().map(function (v) { v.flip(); });
  81521. this.plane.flip();
  81522. };
  81523. return Polygon;
  81524. }());
  81525. /**
  81526. * Holds a node in a BSP tree. A BSP tree is built from a collection of polygons
  81527. * by picking a polygon to split along. That polygon (and all other coplanar
  81528. * polygons) are added directly to that node and the other polygons are added to
  81529. * the front and/or back subtrees. This is not a leafy BSP tree since there is
  81530. * no distinction between internal and leaf nodes
  81531. */
  81532. var Node = /** @class */ (function () {
  81533. /**
  81534. * Initializes the node
  81535. * @param polygons A collection of polygons held in the node
  81536. */
  81537. function Node(polygons) {
  81538. this.plane = null;
  81539. this.front = null;
  81540. this.back = null;
  81541. this.polygons = new Array();
  81542. if (polygons) {
  81543. this.build(polygons);
  81544. }
  81545. }
  81546. /**
  81547. * Clones, or makes a deep copy, of the node
  81548. * @returns The cloned node
  81549. */
  81550. Node.prototype.clone = function () {
  81551. var node = new Node();
  81552. node.plane = this.plane && this.plane.clone();
  81553. node.front = this.front && this.front.clone();
  81554. node.back = this.back && this.back.clone();
  81555. node.polygons = this.polygons.map(function (p) { return p.clone(); });
  81556. return node;
  81557. };
  81558. /**
  81559. * Convert solid space to empty space and empty space to solid space
  81560. */
  81561. Node.prototype.invert = function () {
  81562. for (var i = 0; i < this.polygons.length; i++) {
  81563. this.polygons[i].flip();
  81564. }
  81565. if (this.plane) {
  81566. this.plane.flip();
  81567. }
  81568. if (this.front) {
  81569. this.front.invert();
  81570. }
  81571. if (this.back) {
  81572. this.back.invert();
  81573. }
  81574. var temp = this.front;
  81575. this.front = this.back;
  81576. this.back = temp;
  81577. };
  81578. /**
  81579. * Recursively remove all polygons in `polygons` that are inside this BSP
  81580. * tree.
  81581. * @param polygons Polygons to remove from the BSP
  81582. * @returns Polygons clipped from the BSP
  81583. */
  81584. Node.prototype.clipPolygons = function (polygons) {
  81585. if (!this.plane) {
  81586. return polygons.slice();
  81587. }
  81588. var front = new Array(), back = new Array();
  81589. for (var i = 0; i < polygons.length; i++) {
  81590. this.plane.splitPolygon(polygons[i], front, back, front, back);
  81591. }
  81592. if (this.front) {
  81593. front = this.front.clipPolygons(front);
  81594. }
  81595. if (this.back) {
  81596. back = this.back.clipPolygons(back);
  81597. }
  81598. else {
  81599. back = [];
  81600. }
  81601. return front.concat(back);
  81602. };
  81603. /**
  81604. * Remove all polygons in this BSP tree that are inside the other BSP tree
  81605. * `bsp`.
  81606. * @param bsp BSP containing polygons to remove from this BSP
  81607. */
  81608. Node.prototype.clipTo = function (bsp) {
  81609. this.polygons = bsp.clipPolygons(this.polygons);
  81610. if (this.front) {
  81611. this.front.clipTo(bsp);
  81612. }
  81613. if (this.back) {
  81614. this.back.clipTo(bsp);
  81615. }
  81616. };
  81617. /**
  81618. * Return a list of all polygons in this BSP tree
  81619. * @returns List of all polygons in this BSP tree
  81620. */
  81621. Node.prototype.allPolygons = function () {
  81622. var polygons = this.polygons.slice();
  81623. if (this.front) {
  81624. polygons = polygons.concat(this.front.allPolygons());
  81625. }
  81626. if (this.back) {
  81627. polygons = polygons.concat(this.back.allPolygons());
  81628. }
  81629. return polygons;
  81630. };
  81631. /**
  81632. * Build a BSP tree out of `polygons`. When called on an existing tree, the
  81633. * new polygons are filtered down to the bottom of the tree and become new
  81634. * nodes there. Each set of polygons is partitioned using the first polygon
  81635. * (no heuristic is used to pick a good split)
  81636. * @param polygons Polygons used to construct the BSP tree
  81637. */
  81638. Node.prototype.build = function (polygons) {
  81639. if (!polygons.length) {
  81640. return;
  81641. }
  81642. if (!this.plane) {
  81643. this.plane = polygons[0].plane.clone();
  81644. }
  81645. var front = new Array(), back = new Array();
  81646. for (var i = 0; i < polygons.length; i++) {
  81647. this.plane.splitPolygon(polygons[i], this.polygons, this.polygons, front, back);
  81648. }
  81649. if (front.length) {
  81650. if (!this.front) {
  81651. this.front = new Node();
  81652. }
  81653. this.front.build(front);
  81654. }
  81655. if (back.length) {
  81656. if (!this.back) {
  81657. this.back = new Node();
  81658. }
  81659. this.back.build(back);
  81660. }
  81661. };
  81662. return Node;
  81663. }());
  81664. /**
  81665. * Class for building Constructive Solid Geometry
  81666. */
  81667. var CSG = /** @class */ (function () {
  81668. function CSG() {
  81669. this.polygons = new Array();
  81670. }
  81671. /**
  81672. * Convert the Mesh to CSG
  81673. * @param mesh The Mesh to convert to CSG
  81674. * @returns A new CSG from the Mesh
  81675. */
  81676. CSG.FromMesh = function (mesh) {
  81677. var vertex, normal, uv, position, polygon, polygons = new Array(), vertices;
  81678. var matrix, meshPosition, meshRotation, meshRotationQuaternion = null, meshScaling;
  81679. if (mesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]) {
  81680. mesh.computeWorldMatrix(true);
  81681. matrix = mesh.getWorldMatrix();
  81682. meshPosition = mesh.position.clone();
  81683. meshRotation = mesh.rotation.clone();
  81684. if (mesh.rotationQuaternion) {
  81685. meshRotationQuaternion = mesh.rotationQuaternion.clone();
  81686. }
  81687. meshScaling = mesh.scaling.clone();
  81688. }
  81689. else {
  81690. throw 'BABYLON.CSG: Wrong Mesh type, must be BABYLON.Mesh';
  81691. }
  81692. 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);
  81693. var subMeshes = mesh.subMeshes;
  81694. for (var sm = 0, sml = subMeshes.length; sm < sml; sm++) {
  81695. for (var i = subMeshes[sm].indexStart, il = subMeshes[sm].indexCount + subMeshes[sm].indexStart; i < il; i += 3) {
  81696. vertices = [];
  81697. for (var j = 0; j < 3; j++) {
  81698. 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]);
  81699. uv = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](uvs[indices[i + j] * 2], uvs[indices[i + j] * 2 + 1]);
  81700. 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]);
  81701. position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(sourcePosition, matrix);
  81702. normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(sourceNormal, matrix);
  81703. vertex = new Vertex(position, normal, uv);
  81704. vertices.push(vertex);
  81705. }
  81706. polygon = new Polygon(vertices, { subMeshId: sm, meshId: currentCSGMeshId, materialIndex: subMeshes[sm].materialIndex });
  81707. // To handle the case of degenerated triangle
  81708. // polygon.plane == null <=> the polygon does not represent 1 single plane <=> the triangle is degenerated
  81709. if (polygon.plane) {
  81710. polygons.push(polygon);
  81711. }
  81712. }
  81713. }
  81714. var csg = CSG.FromPolygons(polygons);
  81715. csg.matrix = matrix;
  81716. csg.position = meshPosition;
  81717. csg.rotation = meshRotation;
  81718. csg.scaling = meshScaling;
  81719. csg.rotationQuaternion = meshRotationQuaternion;
  81720. currentCSGMeshId++;
  81721. return csg;
  81722. };
  81723. /**
  81724. * Construct a CSG solid from a list of `CSG.Polygon` instances.
  81725. * @param polygons Polygons used to construct a CSG solid
  81726. */
  81727. CSG.FromPolygons = function (polygons) {
  81728. var csg = new CSG();
  81729. csg.polygons = polygons;
  81730. return csg;
  81731. };
  81732. /**
  81733. * Clones, or makes a deep copy, of the CSG
  81734. * @returns A new CSG
  81735. */
  81736. CSG.prototype.clone = function () {
  81737. var csg = new CSG();
  81738. csg.polygons = this.polygons.map(function (p) { return p.clone(); });
  81739. csg.copyTransformAttributes(this);
  81740. return csg;
  81741. };
  81742. /**
  81743. * Unions this CSG with another CSG
  81744. * @param csg The CSG to union against this CSG
  81745. * @returns The unioned CSG
  81746. */
  81747. CSG.prototype.union = function (csg) {
  81748. var a = new Node(this.clone().polygons);
  81749. var b = new Node(csg.clone().polygons);
  81750. a.clipTo(b);
  81751. b.clipTo(a);
  81752. b.invert();
  81753. b.clipTo(a);
  81754. b.invert();
  81755. a.build(b.allPolygons());
  81756. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81757. };
  81758. /**
  81759. * Unions this CSG with another CSG in place
  81760. * @param csg The CSG to union against this CSG
  81761. */
  81762. CSG.prototype.unionInPlace = function (csg) {
  81763. var a = new Node(this.polygons);
  81764. var b = new Node(csg.polygons);
  81765. a.clipTo(b);
  81766. b.clipTo(a);
  81767. b.invert();
  81768. b.clipTo(a);
  81769. b.invert();
  81770. a.build(b.allPolygons());
  81771. this.polygons = a.allPolygons();
  81772. };
  81773. /**
  81774. * Subtracts this CSG with another CSG
  81775. * @param csg The CSG to subtract against this CSG
  81776. * @returns A new CSG
  81777. */
  81778. CSG.prototype.subtract = function (csg) {
  81779. var a = new Node(this.clone().polygons);
  81780. var b = new Node(csg.clone().polygons);
  81781. a.invert();
  81782. a.clipTo(b);
  81783. b.clipTo(a);
  81784. b.invert();
  81785. b.clipTo(a);
  81786. b.invert();
  81787. a.build(b.allPolygons());
  81788. a.invert();
  81789. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81790. };
  81791. /**
  81792. * Subtracts this CSG with another CSG in place
  81793. * @param csg The CSG to subtact against this CSG
  81794. */
  81795. CSG.prototype.subtractInPlace = function (csg) {
  81796. var a = new Node(this.polygons);
  81797. var b = new Node(csg.polygons);
  81798. a.invert();
  81799. a.clipTo(b);
  81800. b.clipTo(a);
  81801. b.invert();
  81802. b.clipTo(a);
  81803. b.invert();
  81804. a.build(b.allPolygons());
  81805. a.invert();
  81806. this.polygons = a.allPolygons();
  81807. };
  81808. /**
  81809. * Intersect this CSG with another CSG
  81810. * @param csg The CSG to intersect against this CSG
  81811. * @returns A new CSG
  81812. */
  81813. CSG.prototype.intersect = function (csg) {
  81814. var a = new Node(this.clone().polygons);
  81815. var b = new Node(csg.clone().polygons);
  81816. a.invert();
  81817. b.clipTo(a);
  81818. b.invert();
  81819. a.clipTo(b);
  81820. b.clipTo(a);
  81821. a.build(b.allPolygons());
  81822. a.invert();
  81823. return CSG.FromPolygons(a.allPolygons()).copyTransformAttributes(this);
  81824. };
  81825. /**
  81826. * Intersects this CSG with another CSG in place
  81827. * @param csg The CSG to intersect against this CSG
  81828. */
  81829. CSG.prototype.intersectInPlace = function (csg) {
  81830. var a = new Node(this.polygons);
  81831. var b = new Node(csg.polygons);
  81832. a.invert();
  81833. b.clipTo(a);
  81834. b.invert();
  81835. a.clipTo(b);
  81836. b.clipTo(a);
  81837. a.build(b.allPolygons());
  81838. a.invert();
  81839. this.polygons = a.allPolygons();
  81840. };
  81841. /**
  81842. * Return a new CSG solid with solid and empty space switched. This solid is
  81843. * not modified.
  81844. * @returns A new CSG solid with solid and empty space switched
  81845. */
  81846. CSG.prototype.inverse = function () {
  81847. var csg = this.clone();
  81848. csg.inverseInPlace();
  81849. return csg;
  81850. };
  81851. /**
  81852. * Inverses the CSG in place
  81853. */
  81854. CSG.prototype.inverseInPlace = function () {
  81855. this.polygons.map(function (p) { p.flip(); });
  81856. };
  81857. /**
  81858. * This is used to keep meshes transformations so they can be restored
  81859. * when we build back a Babylon Mesh
  81860. * NB : All CSG operations are performed in world coordinates
  81861. * @param csg The CSG to copy the transform attributes from
  81862. * @returns This CSG
  81863. */
  81864. CSG.prototype.copyTransformAttributes = function (csg) {
  81865. this.matrix = csg.matrix;
  81866. this.position = csg.position;
  81867. this.rotation = csg.rotation;
  81868. this.scaling = csg.scaling;
  81869. this.rotationQuaternion = csg.rotationQuaternion;
  81870. return this;
  81871. };
  81872. /**
  81873. * Build Raw mesh from CSG
  81874. * Coordinates here are in world space
  81875. * @param name The name of the mesh geometry
  81876. * @param scene The Scene
  81877. * @param keepSubMeshes Specifies if the submeshes should be kept
  81878. * @returns A new Mesh
  81879. */
  81880. CSG.prototype.buildMeshGeometry = function (name, scene, keepSubMeshes) {
  81881. var matrix = this.matrix.clone();
  81882. matrix.invert();
  81883. 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;
  81884. if (keepSubMeshes) {
  81885. // Sort Polygons, since subMeshes are indices range
  81886. polygons.sort(function (a, b) {
  81887. if (a.shared.meshId === b.shared.meshId) {
  81888. return a.shared.subMeshId - b.shared.subMeshId;
  81889. }
  81890. else {
  81891. return a.shared.meshId - b.shared.meshId;
  81892. }
  81893. });
  81894. }
  81895. for (var i = 0, il = polygons.length; i < il; i++) {
  81896. polygon = polygons[i];
  81897. // Building SubMeshes
  81898. if (!subMesh_dict[polygon.shared.meshId]) {
  81899. subMesh_dict[polygon.shared.meshId] = {};
  81900. }
  81901. if (!subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId]) {
  81902. subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId] = {
  81903. indexStart: +Infinity,
  81904. indexEnd: -Infinity,
  81905. materialIndex: polygon.shared.materialIndex
  81906. };
  81907. }
  81908. subMesh_obj = subMesh_dict[polygon.shared.meshId][polygon.shared.subMeshId];
  81909. for (var j = 2, jl = polygon.vertices.length; j < jl; j++) {
  81910. polygonIndices[0] = 0;
  81911. polygonIndices[1] = j - 1;
  81912. polygonIndices[2] = j;
  81913. for (var k = 0; k < 3; k++) {
  81914. vertex.copyFrom(polygon.vertices[polygonIndices[k]].pos);
  81915. normal.copyFrom(polygon.vertices[polygonIndices[k]].normal);
  81916. uv.copyFrom(polygon.vertices[polygonIndices[k]].uv);
  81917. var localVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(vertex, matrix);
  81918. var localNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormal(normal, matrix);
  81919. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z];
  81920. // Check if 2 points can be merged
  81921. if (!(typeof vertex_idx !== 'undefined' &&
  81922. normals[vertex_idx * 3] === localNormal.x &&
  81923. normals[vertex_idx * 3 + 1] === localNormal.y &&
  81924. normals[vertex_idx * 3 + 2] === localNormal.z &&
  81925. uvs[vertex_idx * 2] === uv.x &&
  81926. uvs[vertex_idx * 2 + 1] === uv.y)) {
  81927. vertices.push(localVertex.x, localVertex.y, localVertex.z);
  81928. uvs.push(uv.x, uv.y);
  81929. normals.push(normal.x, normal.y, normal.z);
  81930. vertex_idx = vertice_dict[localVertex.x + ',' + localVertex.y + ',' + localVertex.z] = (vertices.length / 3) - 1;
  81931. }
  81932. indices.push(vertex_idx);
  81933. subMesh_obj.indexStart = Math.min(currentIndex, subMesh_obj.indexStart);
  81934. subMesh_obj.indexEnd = Math.max(currentIndex, subMesh_obj.indexEnd);
  81935. currentIndex++;
  81936. }
  81937. }
  81938. }
  81939. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, vertices);
  81940. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals);
  81941. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs);
  81942. mesh.setIndices(indices, null);
  81943. if (keepSubMeshes) {
  81944. // We offset the materialIndex by the previous number of materials in the CSG mixed meshes
  81945. var materialIndexOffset = 0, materialMaxIndex;
  81946. mesh.subMeshes = new Array();
  81947. for (var m in subMesh_dict) {
  81948. materialMaxIndex = -1;
  81949. for (var sm in subMesh_dict[m]) {
  81950. subMesh_obj = subMesh_dict[m][sm];
  81951. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].CreateFromIndices(subMesh_obj.materialIndex + materialIndexOffset, subMesh_obj.indexStart, subMesh_obj.indexEnd - subMesh_obj.indexStart + 1, mesh);
  81952. materialMaxIndex = Math.max(subMesh_obj.materialIndex, materialMaxIndex);
  81953. }
  81954. materialIndexOffset += ++materialMaxIndex;
  81955. }
  81956. }
  81957. return mesh;
  81958. };
  81959. /**
  81960. * Build Mesh from CSG taking material and transforms into account
  81961. * @param name The name of the Mesh
  81962. * @param material The material of the Mesh
  81963. * @param scene The Scene
  81964. * @param keepSubMeshes Specifies if submeshes should be kept
  81965. * @returns The new Mesh
  81966. */
  81967. CSG.prototype.toMesh = function (name, material, scene, keepSubMeshes) {
  81968. var mesh = this.buildMeshGeometry(name, scene, keepSubMeshes);
  81969. mesh.material = material;
  81970. mesh.position.copyFrom(this.position);
  81971. mesh.rotation.copyFrom(this.rotation);
  81972. if (this.rotationQuaternion) {
  81973. mesh.rotationQuaternion = this.rotationQuaternion.clone();
  81974. }
  81975. mesh.scaling.copyFrom(this.scaling);
  81976. mesh.computeWorldMatrix(true);
  81977. return mesh;
  81978. };
  81979. return CSG;
  81980. }());
  81981. /***/ }),
  81982. /***/ "./Meshes/geometry.ts":
  81983. /*!****************************!*\
  81984. !*** ./Meshes/geometry.ts ***!
  81985. \****************************/
  81986. /*! exports provided: Geometry */
  81987. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  81988. "use strict";
  81989. __webpack_require__.r(__webpack_exports__);
  81990. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return Geometry; });
  81991. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  81992. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  81993. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  81994. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  81995. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  81996. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  81997. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  81998. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  81999. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  82000. /**
  82001. * Class used to store geometry data (vertex buffers + index buffer)
  82002. */
  82003. var Geometry = /** @class */ (function () {
  82004. /**
  82005. * Creates a new geometry
  82006. * @param id defines the unique ID
  82007. * @param scene defines the hosting scene
  82008. * @param vertexData defines the VertexData used to get geometry data
  82009. * @param updatable defines if geometry must be updatable (false by default)
  82010. * @param mesh defines the mesh that will be associated with the geometry
  82011. */
  82012. function Geometry(id, scene, vertexData, updatable, mesh) {
  82013. if (updatable === void 0) { updatable = false; }
  82014. if (mesh === void 0) { mesh = null; }
  82015. /**
  82016. * Gets the delay loading state of the geometry (none by default which means not delayed)
  82017. */
  82018. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82019. this._totalVertices = 0;
  82020. this._isDisposed = false;
  82021. this._indexBufferIsUpdatable = false;
  82022. this.id = id;
  82023. this.uniqueId = scene.getUniqueId();
  82024. this._engine = scene.getEngine();
  82025. this._meshes = [];
  82026. this._scene = scene;
  82027. //Init vertex buffer cache
  82028. this._vertexBuffers = {};
  82029. this._indices = [];
  82030. this._updatable = updatable;
  82031. // vertexData
  82032. if (vertexData) {
  82033. this.setAllVerticesData(vertexData, updatable);
  82034. }
  82035. else {
  82036. this._totalVertices = 0;
  82037. this._indices = [];
  82038. }
  82039. if (this._engine.getCaps().vertexArrayObject) {
  82040. this._vertexArrayObjects = {};
  82041. }
  82042. // applyToMesh
  82043. if (mesh) {
  82044. this.applyToMesh(mesh);
  82045. mesh.computeWorldMatrix(true);
  82046. }
  82047. }
  82048. Object.defineProperty(Geometry.prototype, "boundingBias", {
  82049. /**
  82050. * 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
  82051. */
  82052. get: function () {
  82053. return this._boundingBias;
  82054. },
  82055. /**
  82056. * 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
  82057. */
  82058. set: function (value) {
  82059. if (this._boundingBias) {
  82060. this._boundingBias.copyFrom(value);
  82061. }
  82062. else {
  82063. this._boundingBias = value.clone();
  82064. }
  82065. this._updateBoundingInfo(true, null);
  82066. },
  82067. enumerable: true,
  82068. configurable: true
  82069. });
  82070. /**
  82071. * Static function used to attach a new empty geometry to a mesh
  82072. * @param mesh defines the mesh to attach the geometry to
  82073. * @returns the new Geometry
  82074. */
  82075. Geometry.CreateGeometryForMesh = function (mesh) {
  82076. var geometry = new Geometry(Geometry.RandomId(), mesh.getScene());
  82077. geometry.applyToMesh(mesh);
  82078. return geometry;
  82079. };
  82080. Object.defineProperty(Geometry.prototype, "extend", {
  82081. /**
  82082. * Gets the current extend of the geometry
  82083. */
  82084. get: function () {
  82085. return this._extend;
  82086. },
  82087. enumerable: true,
  82088. configurable: true
  82089. });
  82090. /**
  82091. * Gets the hosting scene
  82092. * @returns the hosting Scene
  82093. */
  82094. Geometry.prototype.getScene = function () {
  82095. return this._scene;
  82096. };
  82097. /**
  82098. * Gets the hosting engine
  82099. * @returns the hosting Engine
  82100. */
  82101. Geometry.prototype.getEngine = function () {
  82102. return this._engine;
  82103. };
  82104. /**
  82105. * Defines if the geometry is ready to use
  82106. * @returns true if the geometry is ready to be used
  82107. */
  82108. Geometry.prototype.isReady = function () {
  82109. return this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED || this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82110. };
  82111. Object.defineProperty(Geometry.prototype, "doNotSerialize", {
  82112. /**
  82113. * Gets a value indicating that the geometry should not be serialized
  82114. */
  82115. get: function () {
  82116. for (var index = 0; index < this._meshes.length; index++) {
  82117. if (!this._meshes[index].doNotSerialize) {
  82118. return false;
  82119. }
  82120. }
  82121. return true;
  82122. },
  82123. enumerable: true,
  82124. configurable: true
  82125. });
  82126. /** @hidden */
  82127. Geometry.prototype._rebuild = function () {
  82128. if (this._vertexArrayObjects) {
  82129. this._vertexArrayObjects = {};
  82130. }
  82131. // Index buffer
  82132. if (this._meshes.length !== 0 && this._indices) {
  82133. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  82134. }
  82135. // Vertex buffers
  82136. for (var key in this._vertexBuffers) {
  82137. var vertexBuffer = this._vertexBuffers[key];
  82138. vertexBuffer._rebuild();
  82139. }
  82140. };
  82141. /**
  82142. * Affects all geometry data in one call
  82143. * @param vertexData defines the geometry data
  82144. * @param updatable defines if the geometry must be flagged as updatable (false as default)
  82145. */
  82146. Geometry.prototype.setAllVerticesData = function (vertexData, updatable) {
  82147. vertexData.applyToGeometry(this, updatable);
  82148. this.notifyUpdate();
  82149. };
  82150. /**
  82151. * Set specific vertex data
  82152. * @param kind defines the data kind (Position, normal, etc...)
  82153. * @param data defines the vertex data to use
  82154. * @param updatable defines if the vertex must be flagged as updatable (false as default)
  82155. * @param stride defines the stride to use (0 by default). This value is deduced from the kind value if not specified
  82156. */
  82157. Geometry.prototype.setVerticesData = function (kind, data, updatable, stride) {
  82158. if (updatable === void 0) { updatable = false; }
  82159. var buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"](this._engine, data, kind, updatable, this._meshes.length === 0, stride);
  82160. this.setVerticesBuffer(buffer);
  82161. };
  82162. /**
  82163. * Removes a specific vertex data
  82164. * @param kind defines the data kind (Position, normal, etc...)
  82165. */
  82166. Geometry.prototype.removeVerticesData = function (kind) {
  82167. if (this._vertexBuffers[kind]) {
  82168. this._vertexBuffers[kind].dispose();
  82169. delete this._vertexBuffers[kind];
  82170. }
  82171. };
  82172. /**
  82173. * Affect a vertex buffer to the geometry. the vertexBuffer.getKind() function is used to determine where to store the data
  82174. * @param buffer defines the vertex buffer to use
  82175. * @param totalVertices defines the total number of vertices for position kind (could be null)
  82176. */
  82177. Geometry.prototype.setVerticesBuffer = function (buffer, totalVertices) {
  82178. if (totalVertices === void 0) { totalVertices = null; }
  82179. var kind = buffer.getKind();
  82180. if (this._vertexBuffers[kind]) {
  82181. this._vertexBuffers[kind].dispose();
  82182. }
  82183. this._vertexBuffers[kind] = buffer;
  82184. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82185. var data = buffer.getData();
  82186. if (totalVertices != null) {
  82187. this._totalVertices = totalVertices;
  82188. }
  82189. else {
  82190. if (data != null) {
  82191. this._totalVertices = data.length / (buffer.byteStride / 4);
  82192. }
  82193. }
  82194. this._updateExtend(data);
  82195. this._resetPointsArrayCache();
  82196. var meshes = this._meshes;
  82197. var numOfMeshes = meshes.length;
  82198. for (var index = 0; index < numOfMeshes; index++) {
  82199. var mesh = meshes[index];
  82200. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82201. mesh._createGlobalSubMesh(false);
  82202. mesh.computeWorldMatrix(true);
  82203. }
  82204. }
  82205. this.notifyUpdate(kind);
  82206. if (this._vertexArrayObjects) {
  82207. this._disposeVertexArrayObjects();
  82208. this._vertexArrayObjects = {}; // Will trigger a rebuild of the VAO if supported
  82209. }
  82210. };
  82211. /**
  82212. * Update a specific vertex buffer
  82213. * This function will directly update the underlying WebGLBuffer according to the passed numeric array or Float32Array
  82214. * It will do nothing if the buffer is not updatable
  82215. * @param kind defines the data kind (Position, normal, etc...)
  82216. * @param data defines the data to use
  82217. * @param offset defines the offset in the target buffer where to store the data
  82218. * @param useBytes set to true if the offset is in bytes
  82219. */
  82220. Geometry.prototype.updateVerticesDataDirectly = function (kind, data, offset, useBytes) {
  82221. if (useBytes === void 0) { useBytes = false; }
  82222. var vertexBuffer = this.getVertexBuffer(kind);
  82223. if (!vertexBuffer) {
  82224. return;
  82225. }
  82226. vertexBuffer.updateDirectly(data, offset, useBytes);
  82227. this.notifyUpdate(kind);
  82228. };
  82229. /**
  82230. * Update a specific vertex buffer
  82231. * This function will create a new buffer if the current one is not updatable
  82232. * @param kind defines the data kind (Position, normal, etc...)
  82233. * @param data defines the data to use
  82234. * @param updateExtends defines if the geometry extends must be recomputed (false by default)
  82235. */
  82236. Geometry.prototype.updateVerticesData = function (kind, data, updateExtends) {
  82237. if (updateExtends === void 0) { updateExtends = false; }
  82238. var vertexBuffer = this.getVertexBuffer(kind);
  82239. if (!vertexBuffer) {
  82240. return;
  82241. }
  82242. vertexBuffer.update(data);
  82243. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82244. this._updateBoundingInfo(updateExtends, data);
  82245. }
  82246. this.notifyUpdate(kind);
  82247. };
  82248. Geometry.prototype._updateBoundingInfo = function (updateExtends, data) {
  82249. if (updateExtends) {
  82250. this._updateExtend(data);
  82251. }
  82252. this._resetPointsArrayCache();
  82253. if (updateExtends) {
  82254. var meshes = this._meshes;
  82255. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  82256. var mesh = meshes_1[_i];
  82257. if (mesh._boundingInfo) {
  82258. mesh._boundingInfo.reConstruct(this._extend.minimum, this._extend.maximum);
  82259. }
  82260. else {
  82261. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82262. }
  82263. var subMeshes = mesh.subMeshes;
  82264. for (var _a = 0, subMeshes_1 = subMeshes; _a < subMeshes_1.length; _a++) {
  82265. var subMesh = subMeshes_1[_a];
  82266. subMesh.refreshBoundingInfo();
  82267. }
  82268. }
  82269. }
  82270. };
  82271. /** @hidden */
  82272. Geometry.prototype._bind = function (effect, indexToBind) {
  82273. if (!effect) {
  82274. return;
  82275. }
  82276. if (indexToBind === undefined) {
  82277. indexToBind = this._indexBuffer;
  82278. }
  82279. var vbs = this.getVertexBuffers();
  82280. if (!vbs) {
  82281. return;
  82282. }
  82283. if (indexToBind != this._indexBuffer || !this._vertexArrayObjects) {
  82284. this._engine.bindBuffers(vbs, indexToBind, effect);
  82285. return;
  82286. }
  82287. // Using VAO
  82288. if (!this._vertexArrayObjects[effect.key]) {
  82289. this._vertexArrayObjects[effect.key] = this._engine.recordVertexArrayObject(vbs, indexToBind, effect);
  82290. }
  82291. this._engine.bindVertexArrayObject(this._vertexArrayObjects[effect.key], indexToBind);
  82292. };
  82293. /**
  82294. * Gets total number of vertices
  82295. * @returns the total number of vertices
  82296. */
  82297. Geometry.prototype.getTotalVertices = function () {
  82298. if (!this.isReady()) {
  82299. return 0;
  82300. }
  82301. return this._totalVertices;
  82302. };
  82303. /**
  82304. * Gets a specific vertex data attached to this geometry. Float data is constructed if the vertex buffer data cannot be returned directly.
  82305. * @param kind defines the data kind (Position, normal, etc...)
  82306. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82307. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82308. * @returns a float array containing vertex data
  82309. */
  82310. Geometry.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  82311. var vertexBuffer = this.getVertexBuffer(kind);
  82312. if (!vertexBuffer) {
  82313. return null;
  82314. }
  82315. var data = vertexBuffer.getData();
  82316. if (!data) {
  82317. return null;
  82318. }
  82319. var tightlyPackedByteStride = vertexBuffer.getSize() * _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].GetTypeByteLength(vertexBuffer.type);
  82320. var count = this._totalVertices * vertexBuffer.getSize();
  82321. if (vertexBuffer.type !== _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].FLOAT || vertexBuffer.byteStride !== tightlyPackedByteStride) {
  82322. var copy_1 = [];
  82323. vertexBuffer.forEach(count, function (value) { return copy_1.push(value); });
  82324. return copy_1;
  82325. }
  82326. if (!((data instanceof Array) || (data instanceof Float32Array)) || vertexBuffer.byteOffset !== 0 || data.length !== count) {
  82327. if (data instanceof Array) {
  82328. var offset = vertexBuffer.byteOffset / 4;
  82329. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data, offset, offset + count);
  82330. }
  82331. else if (data instanceof ArrayBuffer) {
  82332. return new Float32Array(data, vertexBuffer.byteOffset, count);
  82333. }
  82334. else {
  82335. var offset = data.byteOffset + vertexBuffer.byteOffset;
  82336. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  82337. var result = new Float32Array(count);
  82338. var source = new Float32Array(data.buffer, offset, count);
  82339. result.set(source);
  82340. return result;
  82341. }
  82342. return new Float32Array(data.buffer, offset, count);
  82343. }
  82344. }
  82345. if (forceCopy || (copyWhenShared && this._meshes.length !== 1)) {
  82346. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].Slice(data);
  82347. }
  82348. return data;
  82349. };
  82350. /**
  82351. * Returns a boolean defining if the vertex data for the requested `kind` is updatable
  82352. * @param kind defines the data kind (Position, normal, etc...)
  82353. * @returns true if the vertex buffer with the specified kind is updatable
  82354. */
  82355. Geometry.prototype.isVertexBufferUpdatable = function (kind) {
  82356. var vb = this._vertexBuffers[kind];
  82357. if (!vb) {
  82358. return false;
  82359. }
  82360. return vb.isUpdatable();
  82361. };
  82362. /**
  82363. * Gets a specific vertex buffer
  82364. * @param kind defines the data kind (Position, normal, etc...)
  82365. * @returns a VertexBuffer
  82366. */
  82367. Geometry.prototype.getVertexBuffer = function (kind) {
  82368. if (!this.isReady()) {
  82369. return null;
  82370. }
  82371. return this._vertexBuffers[kind];
  82372. };
  82373. /**
  82374. * Returns all vertex buffers
  82375. * @return an object holding all vertex buffers indexed by kind
  82376. */
  82377. Geometry.prototype.getVertexBuffers = function () {
  82378. if (!this.isReady()) {
  82379. return null;
  82380. }
  82381. return this._vertexBuffers;
  82382. };
  82383. /**
  82384. * Gets a boolean indicating if specific vertex buffer is present
  82385. * @param kind defines the data kind (Position, normal, etc...)
  82386. * @returns true if data is present
  82387. */
  82388. Geometry.prototype.isVerticesDataPresent = function (kind) {
  82389. if (!this._vertexBuffers) {
  82390. if (this._delayInfo) {
  82391. return this._delayInfo.indexOf(kind) !== -1;
  82392. }
  82393. return false;
  82394. }
  82395. return this._vertexBuffers[kind] !== undefined;
  82396. };
  82397. /**
  82398. * Gets a list of all attached data kinds (Position, normal, etc...)
  82399. * @returns a list of string containing all kinds
  82400. */
  82401. Geometry.prototype.getVerticesDataKinds = function () {
  82402. var result = [];
  82403. var kind;
  82404. if (!this._vertexBuffers && this._delayInfo) {
  82405. for (kind in this._delayInfo) {
  82406. result.push(kind);
  82407. }
  82408. }
  82409. else {
  82410. for (kind in this._vertexBuffers) {
  82411. result.push(kind);
  82412. }
  82413. }
  82414. return result;
  82415. };
  82416. /**
  82417. * Update index buffer
  82418. * @param indices defines the indices to store in the index buffer
  82419. * @param offset defines the offset in the target buffer where to store the data
  82420. */
  82421. Geometry.prototype.updateIndices = function (indices, offset) {
  82422. if (!this._indexBuffer) {
  82423. return;
  82424. }
  82425. if (!this._indexBufferIsUpdatable) {
  82426. this.setIndices(indices, null, true);
  82427. }
  82428. else {
  82429. var needToUpdateSubMeshes = indices.length !== this._indices.length;
  82430. this._indices = indices;
  82431. this._engine.updateDynamicIndexBuffer(this._indexBuffer, indices, offset);
  82432. if (needToUpdateSubMeshes) {
  82433. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82434. var mesh = _a[_i];
  82435. mesh._createGlobalSubMesh(true);
  82436. }
  82437. }
  82438. }
  82439. };
  82440. /**
  82441. * Creates a new index buffer
  82442. * @param indices defines the indices to store in the index buffer
  82443. * @param totalVertices defines the total number of vertices (could be null)
  82444. * @param updatable defines if the index buffer must be flagged as updatable (false by default)
  82445. */
  82446. Geometry.prototype.setIndices = function (indices, totalVertices, updatable) {
  82447. if (totalVertices === void 0) { totalVertices = null; }
  82448. if (updatable === void 0) { updatable = false; }
  82449. if (this._indexBuffer) {
  82450. this._engine._releaseBuffer(this._indexBuffer);
  82451. }
  82452. this._disposeVertexArrayObjects();
  82453. this._indices = indices;
  82454. this._indexBufferIsUpdatable = updatable;
  82455. if (this._meshes.length !== 0 && this._indices) {
  82456. this._indexBuffer = this._engine.createIndexBuffer(this._indices, updatable);
  82457. }
  82458. if (totalVertices != undefined) { // including null and undefined
  82459. this._totalVertices = totalVertices;
  82460. }
  82461. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82462. var mesh = _a[_i];
  82463. mesh._createGlobalSubMesh(true);
  82464. }
  82465. this.notifyUpdate();
  82466. };
  82467. /**
  82468. * Return the total number of indices
  82469. * @returns the total number of indices
  82470. */
  82471. Geometry.prototype.getTotalIndices = function () {
  82472. if (!this.isReady()) {
  82473. return 0;
  82474. }
  82475. return this._indices.length;
  82476. };
  82477. /**
  82478. * Gets the index buffer array
  82479. * @param copyWhenShared defines if the returned array must be cloned upon returning it if the current geometry is shared between multiple meshes
  82480. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  82481. * @returns the index buffer array
  82482. */
  82483. Geometry.prototype.getIndices = function (copyWhenShared, forceCopy) {
  82484. if (!this.isReady()) {
  82485. return null;
  82486. }
  82487. var orig = this._indices;
  82488. if (!forceCopy && (!copyWhenShared || this._meshes.length === 1)) {
  82489. return orig;
  82490. }
  82491. else {
  82492. var len = orig.length;
  82493. var copy = [];
  82494. for (var i = 0; i < len; i++) {
  82495. copy.push(orig[i]);
  82496. }
  82497. return copy;
  82498. }
  82499. };
  82500. /**
  82501. * Gets the index buffer
  82502. * @return the index buffer
  82503. */
  82504. Geometry.prototype.getIndexBuffer = function () {
  82505. if (!this.isReady()) {
  82506. return null;
  82507. }
  82508. return this._indexBuffer;
  82509. };
  82510. /** @hidden */
  82511. Geometry.prototype._releaseVertexArrayObject = function (effect) {
  82512. if (effect === void 0) { effect = null; }
  82513. if (!effect || !this._vertexArrayObjects) {
  82514. return;
  82515. }
  82516. if (this._vertexArrayObjects[effect.key]) {
  82517. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[effect.key]);
  82518. delete this._vertexArrayObjects[effect.key];
  82519. }
  82520. };
  82521. /**
  82522. * Release the associated resources for a specific mesh
  82523. * @param mesh defines the source mesh
  82524. * @param shouldDispose defines if the geometry must be disposed if there is no more mesh pointing to it
  82525. */
  82526. Geometry.prototype.releaseForMesh = function (mesh, shouldDispose) {
  82527. var meshes = this._meshes;
  82528. var index = meshes.indexOf(mesh);
  82529. if (index === -1) {
  82530. return;
  82531. }
  82532. meshes.splice(index, 1);
  82533. mesh._geometry = null;
  82534. if (meshes.length === 0 && shouldDispose) {
  82535. this.dispose();
  82536. }
  82537. };
  82538. /**
  82539. * Apply current geometry to a given mesh
  82540. * @param mesh defines the mesh to apply geometry to
  82541. */
  82542. Geometry.prototype.applyToMesh = function (mesh) {
  82543. if (mesh._geometry === this) {
  82544. return;
  82545. }
  82546. var previousGeometry = mesh._geometry;
  82547. if (previousGeometry) {
  82548. previousGeometry.releaseForMesh(mesh);
  82549. }
  82550. var meshes = this._meshes;
  82551. // must be done before setting vertexBuffers because of mesh._createGlobalSubMesh()
  82552. mesh._geometry = this;
  82553. this._scene.pushGeometry(this);
  82554. meshes.push(mesh);
  82555. if (this.isReady()) {
  82556. this._applyToMesh(mesh);
  82557. }
  82558. else {
  82559. mesh._boundingInfo = this._boundingInfo;
  82560. }
  82561. };
  82562. Geometry.prototype._updateExtend = function (data) {
  82563. if (data === void 0) { data = null; }
  82564. if (!data) {
  82565. data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82566. }
  82567. this._extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].ExtractMinAndMax(data, 0, this._totalVertices, this.boundingBias, 3);
  82568. };
  82569. Geometry.prototype._applyToMesh = function (mesh) {
  82570. var numOfMeshes = this._meshes.length;
  82571. // vertexBuffers
  82572. for (var kind in this._vertexBuffers) {
  82573. if (numOfMeshes === 1) {
  82574. this._vertexBuffers[kind].create();
  82575. }
  82576. var buffer = this._vertexBuffers[kind].getBuffer();
  82577. if (buffer) {
  82578. buffer.references = numOfMeshes;
  82579. }
  82580. if (kind === _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) {
  82581. if (!this._extend) {
  82582. this._updateExtend();
  82583. }
  82584. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82585. mesh._createGlobalSubMesh(false);
  82586. //bounding info was just created again, world matrix should be applied again.
  82587. mesh._updateBoundingInfo();
  82588. }
  82589. }
  82590. // indexBuffer
  82591. if (numOfMeshes === 1 && this._indices && this._indices.length > 0) {
  82592. this._indexBuffer = this._engine.createIndexBuffer(this._indices);
  82593. }
  82594. if (this._indexBuffer) {
  82595. this._indexBuffer.references = numOfMeshes;
  82596. }
  82597. // morphTargets
  82598. mesh._syncGeometryWithMorphTargetManager();
  82599. // instances
  82600. mesh.synchronizeInstances();
  82601. };
  82602. Geometry.prototype.notifyUpdate = function (kind) {
  82603. if (this.onGeometryUpdated) {
  82604. this.onGeometryUpdated(this, kind);
  82605. }
  82606. for (var _i = 0, _a = this._meshes; _i < _a.length; _i++) {
  82607. var mesh = _a[_i];
  82608. mesh._markSubMeshesAsAttributesDirty();
  82609. }
  82610. };
  82611. /**
  82612. * Load the geometry if it was flagged as delay loaded
  82613. * @param scene defines the hosting scene
  82614. * @param onLoaded defines a callback called when the geometry is loaded
  82615. */
  82616. Geometry.prototype.load = function (scene, onLoaded) {
  82617. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING) {
  82618. return;
  82619. }
  82620. if (this.isReady()) {
  82621. if (onLoaded) {
  82622. onLoaded();
  82623. }
  82624. return;
  82625. }
  82626. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADING;
  82627. this._queueLoad(scene, onLoaded);
  82628. };
  82629. Geometry.prototype._queueLoad = function (scene, onLoaded) {
  82630. var _this = this;
  82631. if (!this.delayLoadingFile) {
  82632. return;
  82633. }
  82634. scene._addPendingData(this);
  82635. scene._loadFile(this.delayLoadingFile, function (data) {
  82636. if (!_this._delayLoadingFunction) {
  82637. return;
  82638. }
  82639. _this._delayLoadingFunction(JSON.parse(data), _this);
  82640. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_LOADED;
  82641. _this._delayInfo = [];
  82642. scene._removePendingData(_this);
  82643. var meshes = _this._meshes;
  82644. var numOfMeshes = meshes.length;
  82645. for (var index = 0; index < numOfMeshes; index++) {
  82646. _this._applyToMesh(meshes[index]);
  82647. }
  82648. if (onLoaded) {
  82649. onLoaded();
  82650. }
  82651. }, undefined, true);
  82652. };
  82653. /**
  82654. * Invert the geometry to move from a right handed system to a left handed one.
  82655. */
  82656. Geometry.prototype.toLeftHanded = function () {
  82657. // Flip faces
  82658. var tIndices = this.getIndices(false);
  82659. if (tIndices != null && tIndices.length > 0) {
  82660. for (var i = 0; i < tIndices.length; i += 3) {
  82661. var tTemp = tIndices[i + 0];
  82662. tIndices[i + 0] = tIndices[i + 2];
  82663. tIndices[i + 2] = tTemp;
  82664. }
  82665. this.setIndices(tIndices);
  82666. }
  82667. // Negate position.z
  82668. var tPositions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, false);
  82669. if (tPositions != null && tPositions.length > 0) {
  82670. for (var i = 0; i < tPositions.length; i += 3) {
  82671. tPositions[i + 2] = -tPositions[i + 2];
  82672. }
  82673. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, tPositions, false);
  82674. }
  82675. // Negate normal.z
  82676. var tNormals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, false);
  82677. if (tNormals != null && tNormals.length > 0) {
  82678. for (var i = 0; i < tNormals.length; i += 3) {
  82679. tNormals[i + 2] = -tNormals[i + 2];
  82680. }
  82681. this.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, tNormals, false);
  82682. }
  82683. };
  82684. // Cache
  82685. /** @hidden */
  82686. Geometry.prototype._resetPointsArrayCache = function () {
  82687. this._positions = null;
  82688. };
  82689. /** @hidden */
  82690. Geometry.prototype._generatePointsArray = function () {
  82691. if (this._positions) {
  82692. return true;
  82693. }
  82694. var data = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  82695. if (!data || data.length === 0) {
  82696. return false;
  82697. }
  82698. this._positions = [];
  82699. for (var index = 0; index < data.length; index += 3) {
  82700. this._positions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(data, index));
  82701. }
  82702. return true;
  82703. };
  82704. /**
  82705. * Gets a value indicating if the geometry is disposed
  82706. * @returns true if the geometry was disposed
  82707. */
  82708. Geometry.prototype.isDisposed = function () {
  82709. return this._isDisposed;
  82710. };
  82711. Geometry.prototype._disposeVertexArrayObjects = function () {
  82712. if (this._vertexArrayObjects) {
  82713. for (var kind in this._vertexArrayObjects) {
  82714. this._engine.releaseVertexArrayObject(this._vertexArrayObjects[kind]);
  82715. }
  82716. this._vertexArrayObjects = {};
  82717. }
  82718. };
  82719. /**
  82720. * Free all associated resources
  82721. */
  82722. Geometry.prototype.dispose = function () {
  82723. var meshes = this._meshes;
  82724. var numOfMeshes = meshes.length;
  82725. var index;
  82726. for (index = 0; index < numOfMeshes; index++) {
  82727. this.releaseForMesh(meshes[index]);
  82728. }
  82729. this._meshes = [];
  82730. this._disposeVertexArrayObjects();
  82731. for (var kind in this._vertexBuffers) {
  82732. this._vertexBuffers[kind].dispose();
  82733. }
  82734. this._vertexBuffers = {};
  82735. this._totalVertices = 0;
  82736. if (this._indexBuffer) {
  82737. this._engine._releaseBuffer(this._indexBuffer);
  82738. }
  82739. this._indexBuffer = null;
  82740. this._indices = [];
  82741. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NONE;
  82742. this.delayLoadingFile = null;
  82743. this._delayLoadingFunction = null;
  82744. this._delayInfo = [];
  82745. this._boundingInfo = null;
  82746. this._scene.removeGeometry(this);
  82747. this._isDisposed = true;
  82748. };
  82749. /**
  82750. * Clone the current geometry into a new geometry
  82751. * @param id defines the unique ID of the new geometry
  82752. * @returns a new geometry object
  82753. */
  82754. Geometry.prototype.copy = function (id) {
  82755. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"]();
  82756. vertexData.indices = [];
  82757. var indices = this.getIndices();
  82758. if (indices) {
  82759. for (var index = 0; index < indices.length; index++) {
  82760. vertexData.indices.push(indices[index]);
  82761. }
  82762. }
  82763. var updatable = false;
  82764. var stopChecking = false;
  82765. var kind;
  82766. for (kind in this._vertexBuffers) {
  82767. // using slice() to make a copy of the array and not just reference it
  82768. var data = this.getVerticesData(kind);
  82769. if (data) {
  82770. if (data instanceof Float32Array) {
  82771. vertexData.set(new Float32Array(data), kind);
  82772. }
  82773. else {
  82774. vertexData.set(data.slice(0), kind);
  82775. }
  82776. if (!stopChecking) {
  82777. var vb = this.getVertexBuffer(kind);
  82778. if (vb) {
  82779. updatable = vb.isUpdatable();
  82780. stopChecking = !updatable;
  82781. }
  82782. }
  82783. }
  82784. }
  82785. var geometry = new Geometry(id, this._scene, vertexData, updatable);
  82786. geometry.delayLoadState = this.delayLoadState;
  82787. geometry.delayLoadingFile = this.delayLoadingFile;
  82788. geometry._delayLoadingFunction = this._delayLoadingFunction;
  82789. for (kind in this._delayInfo) {
  82790. geometry._delayInfo = geometry._delayInfo || [];
  82791. geometry._delayInfo.push(kind);
  82792. }
  82793. // Bounding info
  82794. geometry._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_5__["BoundingInfo"](this._extend.minimum, this._extend.maximum);
  82795. return geometry;
  82796. };
  82797. /**
  82798. * Serialize the current geometry info (and not the vertices data) into a JSON object
  82799. * @return a JSON representation of the current geometry data (without the vertices data)
  82800. */
  82801. Geometry.prototype.serialize = function () {
  82802. var serializationObject = {};
  82803. serializationObject.id = this.id;
  82804. serializationObject.updatable = this._updatable;
  82805. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].HasTags(this)) {
  82806. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].GetTags(this);
  82807. }
  82808. return serializationObject;
  82809. };
  82810. Geometry.prototype.toNumberArray = function (origin) {
  82811. if (Array.isArray(origin)) {
  82812. return origin;
  82813. }
  82814. else {
  82815. return Array.prototype.slice.call(origin);
  82816. }
  82817. };
  82818. /**
  82819. * Serialize all vertices data into a JSON oject
  82820. * @returns a JSON representation of the current geometry data
  82821. */
  82822. Geometry.prototype.serializeVerticeData = function () {
  82823. var serializationObject = this.serialize();
  82824. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82825. serializationObject.positions = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  82826. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind)) {
  82827. serializationObject.positions._updatable = true;
  82828. }
  82829. }
  82830. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82831. serializationObject.normals = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind));
  82832. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind)) {
  82833. serializationObject.normals._updatable = true;
  82834. }
  82835. }
  82836. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82837. serializationObject.tangets = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind));
  82838. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind)) {
  82839. serializationObject.tangets._updatable = true;
  82840. }
  82841. }
  82842. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82843. serializationObject.uvs = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind));
  82844. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind)) {
  82845. serializationObject.uvs._updatable = true;
  82846. }
  82847. }
  82848. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82849. serializationObject.uv2s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind));
  82850. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind)) {
  82851. serializationObject.uv2s._updatable = true;
  82852. }
  82853. }
  82854. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82855. serializationObject.uv3s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind));
  82856. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind)) {
  82857. serializationObject.uv3s._updatable = true;
  82858. }
  82859. }
  82860. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82861. serializationObject.uv4s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind));
  82862. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind)) {
  82863. serializationObject.uv4s._updatable = true;
  82864. }
  82865. }
  82866. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82867. serializationObject.uv5s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind));
  82868. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind)) {
  82869. serializationObject.uv5s._updatable = true;
  82870. }
  82871. }
  82872. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82873. serializationObject.uv6s = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind));
  82874. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind)) {
  82875. serializationObject.uv6s._updatable = true;
  82876. }
  82877. }
  82878. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82879. serializationObject.colors = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind));
  82880. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind)) {
  82881. serializationObject.colors._updatable = true;
  82882. }
  82883. }
  82884. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82885. serializationObject.matricesIndices = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind));
  82886. serializationObject.matricesIndices._isExpanded = true;
  82887. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind)) {
  82888. serializationObject.matricesIndices._updatable = true;
  82889. }
  82890. }
  82891. if (this.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82892. serializationObject.matricesWeights = this.toNumberArray(this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind));
  82893. if (this.isVertexBufferUpdatable(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind)) {
  82894. serializationObject.matricesWeights._updatable = true;
  82895. }
  82896. }
  82897. serializationObject.indices = this.toNumberArray(this.getIndices());
  82898. return serializationObject;
  82899. };
  82900. // Statics
  82901. /**
  82902. * Extracts a clone of a mesh geometry
  82903. * @param mesh defines the source mesh
  82904. * @param id defines the unique ID of the new geometry object
  82905. * @returns the new geometry object
  82906. */
  82907. Geometry.ExtractFromMesh = function (mesh, id) {
  82908. var geometry = mesh._geometry;
  82909. if (!geometry) {
  82910. return null;
  82911. }
  82912. return geometry.copy(id);
  82913. };
  82914. /**
  82915. * You should now use Tools.RandomId(), this method is still here for legacy reasons.
  82916. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  82917. * Be aware Math.random() could cause collisions, but:
  82918. * "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"
  82919. * @returns a string containing a new GUID
  82920. */
  82921. Geometry.RandomId = function () {
  82922. return _Misc_tools__WEBPACK_IMPORTED_MODULE_7__["Tools"].RandomId();
  82923. };
  82924. /** @hidden */
  82925. Geometry._ImportGeometry = function (parsedGeometry, mesh) {
  82926. var scene = mesh.getScene();
  82927. // Geometry
  82928. var geometryId = parsedGeometry.geometryId;
  82929. if (geometryId) {
  82930. var geometry = scene.getGeometryByID(geometryId);
  82931. if (geometry) {
  82932. geometry.applyToMesh(mesh);
  82933. }
  82934. }
  82935. else if (parsedGeometry instanceof ArrayBuffer) {
  82936. var binaryInfo = mesh._binaryInfo;
  82937. if (binaryInfo.positionsAttrDesc && binaryInfo.positionsAttrDesc.count > 0) {
  82938. var positionsData = new Float32Array(parsedGeometry, binaryInfo.positionsAttrDesc.offset, binaryInfo.positionsAttrDesc.count);
  82939. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, positionsData, false);
  82940. }
  82941. if (binaryInfo.normalsAttrDesc && binaryInfo.normalsAttrDesc.count > 0) {
  82942. var normalsData = new Float32Array(parsedGeometry, binaryInfo.normalsAttrDesc.offset, binaryInfo.normalsAttrDesc.count);
  82943. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, normalsData, false);
  82944. }
  82945. if (binaryInfo.tangetsAttrDesc && binaryInfo.tangetsAttrDesc.count > 0) {
  82946. var tangentsData = new Float32Array(parsedGeometry, binaryInfo.tangetsAttrDesc.offset, binaryInfo.tangetsAttrDesc.count);
  82947. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, tangentsData, false);
  82948. }
  82949. if (binaryInfo.uvsAttrDesc && binaryInfo.uvsAttrDesc.count > 0) {
  82950. var uvsData = new Float32Array(parsedGeometry, binaryInfo.uvsAttrDesc.offset, binaryInfo.uvsAttrDesc.count);
  82951. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, uvsData, false);
  82952. }
  82953. if (binaryInfo.uvs2AttrDesc && binaryInfo.uvs2AttrDesc.count > 0) {
  82954. var uvs2Data = new Float32Array(parsedGeometry, binaryInfo.uvs2AttrDesc.offset, binaryInfo.uvs2AttrDesc.count);
  82955. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, uvs2Data, false);
  82956. }
  82957. if (binaryInfo.uvs3AttrDesc && binaryInfo.uvs3AttrDesc.count > 0) {
  82958. var uvs3Data = new Float32Array(parsedGeometry, binaryInfo.uvs3AttrDesc.offset, binaryInfo.uvs3AttrDesc.count);
  82959. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, uvs3Data, false);
  82960. }
  82961. if (binaryInfo.uvs4AttrDesc && binaryInfo.uvs4AttrDesc.count > 0) {
  82962. var uvs4Data = new Float32Array(parsedGeometry, binaryInfo.uvs4AttrDesc.offset, binaryInfo.uvs4AttrDesc.count);
  82963. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, uvs4Data, false);
  82964. }
  82965. if (binaryInfo.uvs5AttrDesc && binaryInfo.uvs5AttrDesc.count > 0) {
  82966. var uvs5Data = new Float32Array(parsedGeometry, binaryInfo.uvs5AttrDesc.offset, binaryInfo.uvs5AttrDesc.count);
  82967. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, uvs5Data, false);
  82968. }
  82969. if (binaryInfo.uvs6AttrDesc && binaryInfo.uvs6AttrDesc.count > 0) {
  82970. var uvs6Data = new Float32Array(parsedGeometry, binaryInfo.uvs6AttrDesc.offset, binaryInfo.uvs6AttrDesc.count);
  82971. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, uvs6Data, false);
  82972. }
  82973. if (binaryInfo.colorsAttrDesc && binaryInfo.colorsAttrDesc.count > 0) {
  82974. var colorsData = new Float32Array(parsedGeometry, binaryInfo.colorsAttrDesc.offset, binaryInfo.colorsAttrDesc.count);
  82975. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, colorsData, false, binaryInfo.colorsAttrDesc.stride);
  82976. }
  82977. if (binaryInfo.matricesIndicesAttrDesc && binaryInfo.matricesIndicesAttrDesc.count > 0) {
  82978. var matricesIndicesData = new Int32Array(parsedGeometry, binaryInfo.matricesIndicesAttrDesc.offset, binaryInfo.matricesIndicesAttrDesc.count);
  82979. var floatIndices = [];
  82980. for (var i = 0; i < matricesIndicesData.length; i++) {
  82981. var index = matricesIndicesData[i];
  82982. floatIndices.push(index & 0x000000FF);
  82983. floatIndices.push((index & 0x0000FF00) >> 8);
  82984. floatIndices.push((index & 0x00FF0000) >> 16);
  82985. floatIndices.push(index >> 24);
  82986. }
  82987. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, false);
  82988. }
  82989. if (binaryInfo.matricesWeightsAttrDesc && binaryInfo.matricesWeightsAttrDesc.count > 0) {
  82990. var matricesWeightsData = new Float32Array(parsedGeometry, binaryInfo.matricesWeightsAttrDesc.offset, binaryInfo.matricesWeightsAttrDesc.count);
  82991. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, matricesWeightsData, false);
  82992. }
  82993. if (binaryInfo.indicesAttrDesc && binaryInfo.indicesAttrDesc.count > 0) {
  82994. var indicesData = new Int32Array(parsedGeometry, binaryInfo.indicesAttrDesc.offset, binaryInfo.indicesAttrDesc.count);
  82995. mesh.setIndices(indicesData, null);
  82996. }
  82997. if (binaryInfo.subMeshesAttrDesc && binaryInfo.subMeshesAttrDesc.count > 0) {
  82998. var subMeshesData = new Int32Array(parsedGeometry, binaryInfo.subMeshesAttrDesc.offset, binaryInfo.subMeshesAttrDesc.count * 5);
  82999. mesh.subMeshes = [];
  83000. for (var i = 0; i < binaryInfo.subMeshesAttrDesc.count; i++) {
  83001. var materialIndex = subMeshesData[(i * 5) + 0];
  83002. var verticesStart = subMeshesData[(i * 5) + 1];
  83003. var verticesCount = subMeshesData[(i * 5) + 2];
  83004. var indexStart = subMeshesData[(i * 5) + 3];
  83005. var indexCount = subMeshesData[(i * 5) + 4];
  83006. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh);
  83007. }
  83008. }
  83009. }
  83010. else if (parsedGeometry.positions && parsedGeometry.normals && parsedGeometry.indices) {
  83011. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, parsedGeometry.positions, parsedGeometry.positions._updatable);
  83012. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].NormalKind, parsedGeometry.normals, parsedGeometry.normals._updatable);
  83013. if (parsedGeometry.tangents) {
  83014. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].TangentKind, parsedGeometry.tangents, parsedGeometry.tangents._updatable);
  83015. }
  83016. if (parsedGeometry.uvs) {
  83017. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind, parsedGeometry.uvs, parsedGeometry.uvs._updatable);
  83018. }
  83019. if (parsedGeometry.uvs2) {
  83020. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind, parsedGeometry.uvs2, parsedGeometry.uvs2._updatable);
  83021. }
  83022. if (parsedGeometry.uvs3) {
  83023. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind, parsedGeometry.uvs3, parsedGeometry.uvs3._updatable);
  83024. }
  83025. if (parsedGeometry.uvs4) {
  83026. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind, parsedGeometry.uvs4, parsedGeometry.uvs4._updatable);
  83027. }
  83028. if (parsedGeometry.uvs5) {
  83029. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind, parsedGeometry.uvs5, parsedGeometry.uvs5._updatable);
  83030. }
  83031. if (parsedGeometry.uvs6) {
  83032. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind, parsedGeometry.uvs6, parsedGeometry.uvs6._updatable);
  83033. }
  83034. if (parsedGeometry.colors) {
  83035. 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);
  83036. }
  83037. if (parsedGeometry.matricesIndices) {
  83038. if (!parsedGeometry.matricesIndices._isExpanded) {
  83039. var floatIndices = [];
  83040. for (var i = 0; i < parsedGeometry.matricesIndices.length; i++) {
  83041. var matricesIndex = parsedGeometry.matricesIndices[i];
  83042. floatIndices.push(matricesIndex & 0x000000FF);
  83043. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  83044. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  83045. floatIndices.push(matricesIndex >> 24);
  83046. }
  83047. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, floatIndices, parsedGeometry.matricesIndices._updatable);
  83048. }
  83049. else {
  83050. delete parsedGeometry.matricesIndices._isExpanded;
  83051. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, parsedGeometry.matricesIndices, parsedGeometry.matricesIndices._updatable);
  83052. }
  83053. }
  83054. if (parsedGeometry.matricesIndicesExtra) {
  83055. if (!parsedGeometry.matricesIndicesExtra._isExpanded) {
  83056. var floatIndices = [];
  83057. for (var i = 0; i < parsedGeometry.matricesIndicesExtra.length; i++) {
  83058. var matricesIndex = parsedGeometry.matricesIndicesExtra[i];
  83059. floatIndices.push(matricesIndex & 0x000000FF);
  83060. floatIndices.push((matricesIndex & 0x0000FF00) >> 8);
  83061. floatIndices.push((matricesIndex & 0x00FF0000) >> 16);
  83062. floatIndices.push(matricesIndex >> 24);
  83063. }
  83064. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, floatIndices, parsedGeometry.matricesIndicesExtra._updatable);
  83065. }
  83066. else {
  83067. delete parsedGeometry.matricesIndices._isExpanded;
  83068. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, parsedGeometry.matricesIndicesExtra, parsedGeometry.matricesIndicesExtra._updatable);
  83069. }
  83070. }
  83071. if (parsedGeometry.matricesWeights) {
  83072. Geometry._CleanMatricesWeights(parsedGeometry, mesh);
  83073. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind, parsedGeometry.matricesWeights, parsedGeometry.matricesWeights._updatable);
  83074. }
  83075. if (parsedGeometry.matricesWeightsExtra) {
  83076. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsExtraKind, parsedGeometry.matricesWeightsExtra, parsedGeometry.matricesWeights._updatable);
  83077. }
  83078. mesh.setIndices(parsedGeometry.indices, null);
  83079. }
  83080. // SubMeshes
  83081. if (parsedGeometry.subMeshes) {
  83082. mesh.subMeshes = [];
  83083. for (var subIndex = 0; subIndex < parsedGeometry.subMeshes.length; subIndex++) {
  83084. var parsedSubMesh = parsedGeometry.subMeshes[subIndex];
  83085. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_3__["SubMesh"].AddToMesh(parsedSubMesh.materialIndex, parsedSubMesh.verticesStart, parsedSubMesh.verticesCount, parsedSubMesh.indexStart, parsedSubMesh.indexCount, mesh);
  83086. }
  83087. }
  83088. // Flat shading
  83089. if (mesh._shouldGenerateFlatShading) {
  83090. mesh.convertToFlatShadedMesh();
  83091. delete mesh._shouldGenerateFlatShading;
  83092. }
  83093. // Update
  83094. mesh.computeWorldMatrix(true);
  83095. scene.onMeshImportedObservable.notifyObservers(mesh);
  83096. };
  83097. Geometry._CleanMatricesWeights = function (parsedGeometry, mesh) {
  83098. var epsilon = 1e-3;
  83099. if (!_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_4__["SceneLoaderFlags"].CleanBoneMatrixWeights) {
  83100. return;
  83101. }
  83102. var noInfluenceBoneIndex = 0.0;
  83103. if (parsedGeometry.skeletonId > -1) {
  83104. var skeleton = mesh.getScene().getLastSkeletonByID(parsedGeometry.skeletonId);
  83105. if (!skeleton) {
  83106. return;
  83107. }
  83108. noInfluenceBoneIndex = skeleton.bones.length;
  83109. }
  83110. else {
  83111. return;
  83112. }
  83113. var matricesIndices = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  83114. var matricesIndicesExtra = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind);
  83115. var matricesWeights = parsedGeometry.matricesWeights;
  83116. var matricesWeightsExtra = parsedGeometry.matricesWeightsExtra;
  83117. var influencers = parsedGeometry.numBoneInfluencer;
  83118. var size = matricesWeights.length;
  83119. for (var i = 0; i < size; i += 4) {
  83120. var weight = 0.0;
  83121. var firstZeroWeight = -1;
  83122. for (var j = 0; j < 4; j++) {
  83123. var w = matricesWeights[i + j];
  83124. weight += w;
  83125. if (w < epsilon && firstZeroWeight < 0) {
  83126. firstZeroWeight = j;
  83127. }
  83128. }
  83129. if (matricesWeightsExtra) {
  83130. for (var j = 0; j < 4; j++) {
  83131. var w = matricesWeightsExtra[i + j];
  83132. weight += w;
  83133. if (w < epsilon && firstZeroWeight < 0) {
  83134. firstZeroWeight = j + 4;
  83135. }
  83136. }
  83137. }
  83138. if (firstZeroWeight < 0 || firstZeroWeight > (influencers - 1)) {
  83139. firstZeroWeight = influencers - 1;
  83140. }
  83141. if (weight > epsilon) {
  83142. var mweight = 1.0 / weight;
  83143. for (var j = 0; j < 4; j++) {
  83144. matricesWeights[i + j] *= mweight;
  83145. }
  83146. if (matricesWeightsExtra) {
  83147. for (var j = 0; j < 4; j++) {
  83148. matricesWeightsExtra[i + j] *= mweight;
  83149. }
  83150. }
  83151. }
  83152. else {
  83153. if (firstZeroWeight >= 4) {
  83154. matricesWeightsExtra[i + firstZeroWeight - 4] = 1.0 - weight;
  83155. matricesIndicesExtra[i + firstZeroWeight - 4] = noInfluenceBoneIndex;
  83156. }
  83157. else {
  83158. matricesWeights[i + firstZeroWeight] = 1.0 - weight;
  83159. matricesIndices[i + firstZeroWeight] = noInfluenceBoneIndex;
  83160. }
  83161. }
  83162. }
  83163. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind, matricesIndices);
  83164. if (parsedGeometry.matricesWeightsExtra) {
  83165. mesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesExtraKind, matricesIndicesExtra);
  83166. }
  83167. };
  83168. /**
  83169. * Create a new geometry from persisted data (Using .babylon file format)
  83170. * @param parsedVertexData defines the persisted data
  83171. * @param scene defines the hosting scene
  83172. * @param rootUrl defines the root url to use to load assets (like delayed data)
  83173. * @returns the new geometry object
  83174. */
  83175. Geometry.Parse = function (parsedVertexData, scene, rootUrl) {
  83176. if (scene.getGeometryByID(parsedVertexData.id)) {
  83177. return null; // null since geometry could be something else than a box...
  83178. }
  83179. var geometry = new Geometry(parsedVertexData.id, scene, undefined, parsedVertexData.updatable);
  83180. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"]) {
  83181. _Misc_tags__WEBPACK_IMPORTED_MODULE_8__["Tags"].AddTagsTo(geometry, parsedVertexData.tags);
  83182. }
  83183. if (parsedVertexData.delayLoadingFile) {
  83184. geometry.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].DELAYLOADSTATE_NOTLOADED;
  83185. geometry.delayLoadingFile = rootUrl + parsedVertexData.delayLoadingFile;
  83186. 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));
  83187. geometry._delayInfo = [];
  83188. if (parsedVertexData.hasUVs) {
  83189. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UVKind);
  83190. }
  83191. if (parsedVertexData.hasUVs2) {
  83192. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV2Kind);
  83193. }
  83194. if (parsedVertexData.hasUVs3) {
  83195. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV3Kind);
  83196. }
  83197. if (parsedVertexData.hasUVs4) {
  83198. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV4Kind);
  83199. }
  83200. if (parsedVertexData.hasUVs5) {
  83201. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV5Kind);
  83202. }
  83203. if (parsedVertexData.hasUVs6) {
  83204. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].UV6Kind);
  83205. }
  83206. if (parsedVertexData.hasColors) {
  83207. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  83208. }
  83209. if (parsedVertexData.hasMatricesIndices) {
  83210. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesIndicesKind);
  83211. }
  83212. if (parsedVertexData.hasMatricesWeights) {
  83213. geometry._delayInfo.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].MatricesWeightsKind);
  83214. }
  83215. geometry._delayLoadingFunction = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData;
  83216. }
  83217. else {
  83218. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_1__["VertexData"].ImportVertexData(parsedVertexData, geometry);
  83219. }
  83220. scene.pushGeometry(geometry, true);
  83221. return geometry;
  83222. };
  83223. return Geometry;
  83224. }());
  83225. /***/ }),
  83226. /***/ "./Meshes/groundMesh.ts":
  83227. /*!******************************!*\
  83228. !*** ./Meshes/groundMesh.ts ***!
  83229. \******************************/
  83230. /*! exports provided: GroundMesh */
  83231. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83232. "use strict";
  83233. __webpack_require__.r(__webpack_exports__);
  83234. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return GroundMesh; });
  83235. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83236. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83237. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83238. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83239. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._GroundMeshParser = function (parsedMesh, scene) {
  83240. return GroundMesh.Parse(parsedMesh, scene);
  83241. };
  83242. /**
  83243. * Mesh representing the gorund
  83244. */
  83245. var GroundMesh = /** @class */ (function (_super) {
  83246. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GroundMesh, _super);
  83247. function GroundMesh(name, scene) {
  83248. var _this = _super.call(this, name, scene) || this;
  83249. /** If octree should be generated */
  83250. _this.generateOctree = false;
  83251. return _this;
  83252. }
  83253. /**
  83254. * "GroundMesh"
  83255. * @returns "GroundMesh"
  83256. */
  83257. GroundMesh.prototype.getClassName = function () {
  83258. return "GroundMesh";
  83259. };
  83260. Object.defineProperty(GroundMesh.prototype, "subdivisions", {
  83261. /**
  83262. * The minimum of x and y subdivisions
  83263. */
  83264. get: function () {
  83265. return Math.min(this._subdivisionsX, this._subdivisionsY);
  83266. },
  83267. enumerable: true,
  83268. configurable: true
  83269. });
  83270. Object.defineProperty(GroundMesh.prototype, "subdivisionsX", {
  83271. /**
  83272. * X subdivisions
  83273. */
  83274. get: function () {
  83275. return this._subdivisionsX;
  83276. },
  83277. enumerable: true,
  83278. configurable: true
  83279. });
  83280. Object.defineProperty(GroundMesh.prototype, "subdivisionsY", {
  83281. /**
  83282. * Y subdivisions
  83283. */
  83284. get: function () {
  83285. return this._subdivisionsY;
  83286. },
  83287. enumerable: true,
  83288. configurable: true
  83289. });
  83290. /**
  83291. * This function will update an octree to help to select the right submeshes for rendering, picking and collision computations.
  83292. * Please note that you must have a decent number of submeshes to get performance improvements when using an octree
  83293. * @param chunksCount the number of subdivisions for x and y
  83294. * @param octreeBlocksSize (Default: 32)
  83295. */
  83296. GroundMesh.prototype.optimize = function (chunksCount, octreeBlocksSize) {
  83297. if (octreeBlocksSize === void 0) { octreeBlocksSize = 32; }
  83298. this._subdivisionsX = chunksCount;
  83299. this._subdivisionsY = chunksCount;
  83300. this.subdivide(chunksCount);
  83301. // Call the octree system optimization if it is defined.
  83302. var thisAsAny = this;
  83303. if (thisAsAny.createOrUpdateSubmeshesOctree) {
  83304. thisAsAny.createOrUpdateSubmeshesOctree(octreeBlocksSize);
  83305. }
  83306. };
  83307. /**
  83308. * Returns a height (y) value in the Worl system :
  83309. * the ground altitude at the coordinates (x, z) expressed in the World system.
  83310. * @param x x coordinate
  83311. * @param z z coordinate
  83312. * @returns the ground y position if (x, z) are outside the ground surface.
  83313. */
  83314. GroundMesh.prototype.getHeightAtCoordinates = function (x, z) {
  83315. var world = this.getWorldMatrix();
  83316. var invMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  83317. world.invertToRef(invMat);
  83318. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  83319. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, invMat, tmpVect); // transform x,z in the mesh local space
  83320. x = tmpVect.x;
  83321. z = tmpVect.z;
  83322. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  83323. return this.position.y;
  83324. }
  83325. if (!this._heightQuads || this._heightQuads.length == 0) {
  83326. this._initHeightQuads();
  83327. this._computeHeightQuads();
  83328. }
  83329. var facet = this._getFacetAt(x, z);
  83330. var y = -(facet.x * x + facet.z * z + facet.w) / facet.y;
  83331. // return y in the World system
  83332. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0.0, y, 0.0, world, tmpVect);
  83333. return tmpVect.y;
  83334. };
  83335. /**
  83336. * Returns a normalized vector (Vector3) orthogonal to the ground
  83337. * at the ground coordinates (x, z) expressed in the World system.
  83338. * @param x x coordinate
  83339. * @param z z coordinate
  83340. * @returns Vector3(0.0, 1.0, 0.0) if (x, z) are outside the ground surface.
  83341. */
  83342. GroundMesh.prototype.getNormalAtCoordinates = function (x, z) {
  83343. var normal = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.0, 1.0, 0.0);
  83344. this.getNormalAtCoordinatesToRef(x, z, normal);
  83345. return normal;
  83346. };
  83347. /**
  83348. * Updates the Vector3 passed a reference with a normalized vector orthogonal to the ground
  83349. * at the ground coordinates (x, z) expressed in the World system.
  83350. * Doesn't uptade the reference Vector3 if (x, z) are outside the ground surface.
  83351. * @param x x coordinate
  83352. * @param z z coordinate
  83353. * @param ref vector to store the result
  83354. * @returns the GroundMesh.
  83355. */
  83356. GroundMesh.prototype.getNormalAtCoordinatesToRef = function (x, z, ref) {
  83357. var world = this.getWorldMatrix();
  83358. var tmpMat = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Matrix[5];
  83359. world.invertToRef(tmpMat);
  83360. var tmpVect = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  83361. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(x, 0.0, z, tmpMat, tmpVect); // transform x,z in the mesh local space
  83362. x = tmpVect.x;
  83363. z = tmpVect.z;
  83364. if (x < this._minX || x > this._maxX || z < this._minZ || z > this._maxZ) {
  83365. return this;
  83366. }
  83367. if (!this._heightQuads || this._heightQuads.length == 0) {
  83368. this._initHeightQuads();
  83369. this._computeHeightQuads();
  83370. }
  83371. var facet = this._getFacetAt(x, z);
  83372. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(facet.x, facet.y, facet.z, world, ref);
  83373. return this;
  83374. };
  83375. /**
  83376. * Force the heights to be recomputed for getHeightAtCoordinates() or getNormalAtCoordinates()
  83377. * if the ground has been updated.
  83378. * This can be used in the render loop.
  83379. * @returns the GroundMesh.
  83380. */
  83381. GroundMesh.prototype.updateCoordinateHeights = function () {
  83382. if (!this._heightQuads || this._heightQuads.length == 0) {
  83383. this._initHeightQuads();
  83384. }
  83385. this._computeHeightQuads();
  83386. return this;
  83387. };
  83388. // Returns the element "facet" from the heightQuads array relative to (x, z) local coordinates
  83389. GroundMesh.prototype._getFacetAt = function (x, z) {
  83390. // retrieve col and row from x, z coordinates in the ground local system
  83391. var col = Math.floor((x + this._maxX) * this._subdivisionsX / this._width);
  83392. var row = Math.floor(-(z + this._maxZ) * this._subdivisionsY / this._height + this._subdivisionsY);
  83393. var quad = this._heightQuads[row * this._subdivisionsX + col];
  83394. var facet;
  83395. if (z < quad.slope.x * x + quad.slope.y) {
  83396. facet = quad.facet1;
  83397. }
  83398. else {
  83399. facet = quad.facet2;
  83400. }
  83401. return facet;
  83402. };
  83403. // Creates and populates the heightMap array with "facet" elements :
  83404. // a quad is two triangular facets separated by a slope, so a "facet" element is 1 slope + 2 facets
  83405. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  83406. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  83407. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  83408. // Returns the GroundMesh.
  83409. GroundMesh.prototype._initHeightQuads = function () {
  83410. var subdivisionsX = this._subdivisionsX;
  83411. var subdivisionsY = this._subdivisionsY;
  83412. this._heightQuads = new Array();
  83413. for (var row = 0; row < subdivisionsY; row++) {
  83414. for (var col = 0; col < subdivisionsX; col++) {
  83415. 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) };
  83416. this._heightQuads[row * subdivisionsX + col] = quad;
  83417. }
  83418. }
  83419. return this;
  83420. };
  83421. // Compute each quad element values and update the the heightMap array :
  83422. // slope : Vector2(c, h) = 2D diagonal line equation setting appart two triangular facets in a quad : z = cx + h
  83423. // facet1 : Vector4(a, b, c, d) = first facet 3D plane equation : ax + by + cz + d = 0
  83424. // facet2 : Vector4(a, b, c, d) = second facet 3D plane equation : ax + by + cz + d = 0
  83425. // Returns the GroundMesh.
  83426. GroundMesh.prototype._computeHeightQuads = function () {
  83427. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  83428. if (!positions) {
  83429. return this;
  83430. }
  83431. var v1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[3];
  83432. var v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[2];
  83433. var v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[1];
  83434. var v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[0];
  83435. var v1v2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[4];
  83436. var v1v3 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[5];
  83437. var v1v4 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[6];
  83438. var norm1 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[7];
  83439. var norm2 = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector3[8];
  83440. var i = 0;
  83441. var j = 0;
  83442. var k = 0;
  83443. var cd = 0; // 2D slope coefficient : z = cd * x + h
  83444. var h = 0;
  83445. var d1 = 0; // facet plane equation : ax + by + cz + d = 0
  83446. var d2 = 0;
  83447. var subdivisionsX = this._subdivisionsX;
  83448. var subdivisionsY = this._subdivisionsY;
  83449. for (var row = 0; row < subdivisionsY; row++) {
  83450. for (var col = 0; col < subdivisionsX; col++) {
  83451. i = col * 3;
  83452. j = row * (subdivisionsX + 1) * 3;
  83453. k = (row + 1) * (subdivisionsX + 1) * 3;
  83454. v1.x = positions[j + i];
  83455. v1.y = positions[j + i + 1];
  83456. v1.z = positions[j + i + 2];
  83457. v2.x = positions[j + i + 3];
  83458. v2.y = positions[j + i + 4];
  83459. v2.z = positions[j + i + 5];
  83460. v3.x = positions[k + i];
  83461. v3.y = positions[k + i + 1];
  83462. v3.z = positions[k + i + 2];
  83463. v4.x = positions[k + i + 3];
  83464. v4.y = positions[k + i + 4];
  83465. v4.z = positions[k + i + 5];
  83466. // 2D slope V1V4
  83467. cd = (v4.z - v1.z) / (v4.x - v1.x);
  83468. h = v1.z - cd * v1.x; // v1 belongs to the slope
  83469. // facet equations :
  83470. // we compute each facet normal vector
  83471. // the equation of the facet plane is : norm.x * x + norm.y * y + norm.z * z + d = 0
  83472. // we compute the value d by applying the equation to v1 which belongs to the plane
  83473. // then we store the facet equation in a Vector4
  83474. v2.subtractToRef(v1, v1v2);
  83475. v3.subtractToRef(v1, v1v3);
  83476. v4.subtractToRef(v1, v1v4);
  83477. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v4, v1v3, norm1); // caution : CrossToRef uses the Tmp class
  83478. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].CrossToRef(v1v2, v1v4, norm2);
  83479. norm1.normalize();
  83480. norm2.normalize();
  83481. d1 = -(norm1.x * v1.x + norm1.y * v1.y + norm1.z * v1.z);
  83482. d2 = -(norm2.x * v2.x + norm2.y * v2.y + norm2.z * v2.z);
  83483. var quad = this._heightQuads[row * subdivisionsX + col];
  83484. quad.slope.copyFromFloats(cd, h);
  83485. quad.facet1.copyFromFloats(norm1.x, norm1.y, norm1.z, d1);
  83486. quad.facet2.copyFromFloats(norm2.x, norm2.y, norm2.z, d2);
  83487. }
  83488. }
  83489. return this;
  83490. };
  83491. /**
  83492. * Serializes this ground mesh
  83493. * @param serializationObject object to write serialization to
  83494. */
  83495. GroundMesh.prototype.serialize = function (serializationObject) {
  83496. _super.prototype.serialize.call(this, serializationObject);
  83497. serializationObject.subdivisionsX = this._subdivisionsX;
  83498. serializationObject.subdivisionsY = this._subdivisionsY;
  83499. serializationObject.minX = this._minX;
  83500. serializationObject.maxX = this._maxX;
  83501. serializationObject.minZ = this._minZ;
  83502. serializationObject.maxZ = this._maxZ;
  83503. serializationObject.width = this._width;
  83504. serializationObject.height = this._height;
  83505. };
  83506. /**
  83507. * Parses a serialized ground mesh
  83508. * @param parsedMesh the serialized mesh
  83509. * @param scene the scene to create the ground mesh in
  83510. * @returns the created ground mesh
  83511. */
  83512. GroundMesh.Parse = function (parsedMesh, scene) {
  83513. var result = new GroundMesh(parsedMesh.name, scene);
  83514. result._subdivisionsX = parsedMesh.subdivisionsX || 1;
  83515. result._subdivisionsY = parsedMesh.subdivisionsY || 1;
  83516. result._minX = parsedMesh.minX;
  83517. result._maxX = parsedMesh.maxX;
  83518. result._minZ = parsedMesh.minZ;
  83519. result._maxZ = parsedMesh.maxZ;
  83520. result._width = parsedMesh.width;
  83521. result._height = parsedMesh.height;
  83522. return result;
  83523. };
  83524. return GroundMesh;
  83525. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  83526. /***/ }),
  83527. /***/ "./Meshes/index.ts":
  83528. /*!*************************!*\
  83529. !*** ./Meshes/index.ts ***!
  83530. \*************************/
  83531. /*! 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, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder */
  83532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83533. "use strict";
  83534. __webpack_require__.r(__webpack_exports__);
  83535. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  83536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _abstractMesh__WEBPACK_IMPORTED_MODULE_0__["AbstractMesh"]; });
  83537. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  83538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["Buffer"]; });
  83539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"]; });
  83540. /* harmony import */ var _Compression_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Compression/index */ "./Meshes/Compression/index.ts");
  83541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Compression_index__WEBPACK_IMPORTED_MODULE_2__["DracoCompression"]; });
  83542. /* harmony import */ var _csg__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./csg */ "./Meshes/csg.ts");
  83543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _csg__WEBPACK_IMPORTED_MODULE_3__["CSG"]; });
  83544. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  83545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _geometry__WEBPACK_IMPORTED_MODULE_4__["Geometry"]; });
  83546. /* harmony import */ var _groundMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./groundMesh */ "./Meshes/groundMesh.ts");
  83547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _groundMesh__WEBPACK_IMPORTED_MODULE_5__["GroundMesh"]; });
  83548. /* harmony import */ var _trailMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./trailMesh */ "./Meshes/trailMesh.ts");
  83549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _trailMesh__WEBPACK_IMPORTED_MODULE_6__["TrailMesh"]; });
  83550. /* harmony import */ var _instancedMesh__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./instancedMesh */ "./Meshes/instancedMesh.ts");
  83551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _instancedMesh__WEBPACK_IMPORTED_MODULE_7__["InstancedMesh"]; });
  83552. /* harmony import */ var _linesMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./linesMesh */ "./Meshes/linesMesh.ts");
  83553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["LinesMesh"]; });
  83554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _linesMesh__WEBPACK_IMPORTED_MODULE_8__["InstancedLinesMesh"]; });
  83555. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  83556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["MeshLODLevel"]; });
  83557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_CreationDataStorage"]; });
  83558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["_InstancesBatch"]; });
  83559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _mesh__WEBPACK_IMPORTED_MODULE_9__["Mesh"]; });
  83560. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  83561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _mesh_vertexData__WEBPACK_IMPORTED_MODULE_10__["VertexData"]; });
  83562. /* harmony import */ var _meshBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./meshBuilder */ "./Meshes/meshBuilder.ts");
  83563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _meshBuilder__WEBPACK_IMPORTED_MODULE_11__["MeshBuilder"]; });
  83564. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  83565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationSettings"]; });
  83566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationQueue"]; });
  83567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _meshSimplification__WEBPACK_IMPORTED_MODULE_12__["SimplificationType"]; });
  83568. /* harmony import */ var _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./meshSimplificationSceneComponent */ "./Meshes/meshSimplificationSceneComponent.ts");
  83569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _meshSimplificationSceneComponent__WEBPACK_IMPORTED_MODULE_13__["SimplicationQueueSceneComponent"]; });
  83570. /* harmony import */ var _polygonMesh__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./polygonMesh */ "./Meshes/polygonMesh.ts");
  83571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["Polygon"]; });
  83572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _polygonMesh__WEBPACK_IMPORTED_MODULE_14__["PolygonMeshBuilder"]; });
  83573. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  83574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["BaseSubMesh"]; });
  83575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _subMesh__WEBPACK_IMPORTED_MODULE_15__["SubMesh"]; });
  83576. /* harmony import */ var _transformNode__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./transformNode */ "./Meshes/transformNode.ts");
  83577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _transformNode__WEBPACK_IMPORTED_MODULE_16__["TransformNode"]; });
  83578. /* harmony import */ var _Builders_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Builders/index */ "./Meshes/Builders/index.ts");
  83579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["BoxBuilder"]; });
  83580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["SphereBuilder"]; });
  83581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["CylinderBuilder"]; });
  83582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LinesBuilder"]; });
  83583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PlaneBuilder"]; });
  83584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DiscBuilder"]; });
  83585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["RibbonBuilder"]; });
  83586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusBuilder"]; });
  83587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TorusKnotBuilder"]; });
  83588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolygonBuilder"]; });
  83589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["ShapeBuilder"]; });
  83590. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["LatheBuilder"]; });
  83591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["GroundBuilder"]; });
  83592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["TubeBuilder"]; });
  83593. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["PolyhedronBuilder"]; });
  83594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["IcoSphereBuilder"]; });
  83595. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Builders_index__WEBPACK_IMPORTED_MODULE_17__["DecalBuilder"]; });
  83596. /***/ }),
  83597. /***/ "./Meshes/instancedMesh.ts":
  83598. /*!*********************************!*\
  83599. !*** ./Meshes/instancedMesh.ts ***!
  83600. \*********************************/
  83601. /*! exports provided: InstancedMesh */
  83602. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83603. "use strict";
  83604. __webpack_require__.r(__webpack_exports__);
  83605. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return InstancedMesh; });
  83606. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83607. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  83608. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  83609. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83610. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  83611. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]._instancedMeshFactory = function (name, mesh) {
  83612. return new InstancedMesh(name, mesh);
  83613. };
  83614. /**
  83615. * Creates an instance based on a source mesh.
  83616. */
  83617. var InstancedMesh = /** @class */ (function (_super) {
  83618. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedMesh, _super);
  83619. function InstancedMesh(name, source) {
  83620. var _this = _super.call(this, name, source.getScene()) || this;
  83621. /** @hidden */
  83622. _this._indexInSourceMeshInstanceArray = -1;
  83623. source.addInstance(_this);
  83624. _this._sourceMesh = source;
  83625. _this.position.copyFrom(source.position);
  83626. _this.rotation.copyFrom(source.rotation);
  83627. _this.scaling.copyFrom(source.scaling);
  83628. if (source.rotationQuaternion) {
  83629. _this.rotationQuaternion = source.rotationQuaternion.clone();
  83630. }
  83631. _this.infiniteDistance = source.infiniteDistance;
  83632. _this.setPivotMatrix(source.getPivotMatrix());
  83633. _this.refreshBoundingInfo();
  83634. _this._syncSubMeshes();
  83635. return _this;
  83636. }
  83637. /**
  83638. * Returns the string "InstancedMesh".
  83639. */
  83640. InstancedMesh.prototype.getClassName = function () {
  83641. return "InstancedMesh";
  83642. };
  83643. Object.defineProperty(InstancedMesh.prototype, "receiveShadows", {
  83644. // Methods
  83645. /**
  83646. * If the source mesh receives shadows
  83647. */
  83648. get: function () {
  83649. return this._sourceMesh.receiveShadows;
  83650. },
  83651. enumerable: true,
  83652. configurable: true
  83653. });
  83654. Object.defineProperty(InstancedMesh.prototype, "material", {
  83655. /**
  83656. * The material of the source mesh
  83657. */
  83658. get: function () {
  83659. return this._sourceMesh.material;
  83660. },
  83661. enumerable: true,
  83662. configurable: true
  83663. });
  83664. Object.defineProperty(InstancedMesh.prototype, "visibility", {
  83665. /**
  83666. * Visibility of the source mesh
  83667. */
  83668. get: function () {
  83669. return this._sourceMesh.visibility;
  83670. },
  83671. enumerable: true,
  83672. configurable: true
  83673. });
  83674. Object.defineProperty(InstancedMesh.prototype, "skeleton", {
  83675. /**
  83676. * Skeleton of the source mesh
  83677. */
  83678. get: function () {
  83679. return this._sourceMesh.skeleton;
  83680. },
  83681. enumerable: true,
  83682. configurable: true
  83683. });
  83684. Object.defineProperty(InstancedMesh.prototype, "renderingGroupId", {
  83685. /**
  83686. * Rendering ground id of the source mesh
  83687. */
  83688. get: function () {
  83689. return this._sourceMesh.renderingGroupId;
  83690. },
  83691. set: function (value) {
  83692. if (!this._sourceMesh || value === this._sourceMesh.renderingGroupId) {
  83693. return;
  83694. }
  83695. //no-op with warning
  83696. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Note - setting renderingGroupId of an instanced mesh has no effect on the scene");
  83697. },
  83698. enumerable: true,
  83699. configurable: true
  83700. });
  83701. /**
  83702. * Returns the total number of vertices (integer).
  83703. */
  83704. InstancedMesh.prototype.getTotalVertices = function () {
  83705. return this._sourceMesh.getTotalVertices();
  83706. };
  83707. /**
  83708. * Returns a positive integer : the total number of indices in this mesh geometry.
  83709. * @returns the numner of indices or zero if the mesh has no geometry.
  83710. */
  83711. InstancedMesh.prototype.getTotalIndices = function () {
  83712. return this._sourceMesh.getTotalIndices();
  83713. };
  83714. Object.defineProperty(InstancedMesh.prototype, "sourceMesh", {
  83715. /**
  83716. * The source mesh of the instance
  83717. */
  83718. get: function () {
  83719. return this._sourceMesh;
  83720. },
  83721. enumerable: true,
  83722. configurable: true
  83723. });
  83724. /**
  83725. * Is this node ready to be used/rendered
  83726. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  83727. * @return {boolean} is it ready
  83728. */
  83729. InstancedMesh.prototype.isReady = function (completeCheck) {
  83730. if (completeCheck === void 0) { completeCheck = false; }
  83731. return this._sourceMesh.isReady(completeCheck, true);
  83732. };
  83733. /**
  83734. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  83735. * @param kind kind of verticies to retreive (eg. positons, normals, uvs, etc.)
  83736. * @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.
  83737. * @returns a float array or a Float32Array of the requested kind of data : positons, normals, uvs, etc.
  83738. */
  83739. InstancedMesh.prototype.getVerticesData = function (kind, copyWhenShared) {
  83740. return this._sourceMesh.getVerticesData(kind, copyWhenShared);
  83741. };
  83742. /**
  83743. * Sets the vertex data of the mesh geometry for the requested `kind`.
  83744. * If the mesh has no geometry, a new Geometry object is set to the mesh and then passed this vertex data.
  83745. * The `data` are either a numeric array either a Float32Array.
  83746. * The parameter `updatable` is passed as is to the underlying Geometry object constructor (if initianilly none) or updater.
  83747. * 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).
  83748. * Note that a new underlying VertexBuffer object is created each call.
  83749. * If the `kind` is the `PositionKind`, the mesh BoundingInfo is renewed, so the bounding box and sphere, and the mesh World Matrix is recomputed.
  83750. *
  83751. * Possible `kind` values :
  83752. * - VertexBuffer.PositionKind
  83753. * - VertexBuffer.UVKind
  83754. * - VertexBuffer.UV2Kind
  83755. * - VertexBuffer.UV3Kind
  83756. * - VertexBuffer.UV4Kind
  83757. * - VertexBuffer.UV5Kind
  83758. * - VertexBuffer.UV6Kind
  83759. * - VertexBuffer.ColorKind
  83760. * - VertexBuffer.MatricesIndicesKind
  83761. * - VertexBuffer.MatricesIndicesExtraKind
  83762. * - VertexBuffer.MatricesWeightsKind
  83763. * - VertexBuffer.MatricesWeightsExtraKind
  83764. *
  83765. * Returns the Mesh.
  83766. */
  83767. InstancedMesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  83768. if (this.sourceMesh) {
  83769. this.sourceMesh.setVerticesData(kind, data, updatable, stride);
  83770. }
  83771. return this.sourceMesh;
  83772. };
  83773. /**
  83774. * Updates the existing vertex data of the mesh geometry for the requested `kind`.
  83775. * If the mesh has no geometry, it is simply returned as it is.
  83776. * The `data` are either a numeric array either a Float32Array.
  83777. * No new underlying VertexBuffer object is created.
  83778. * 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.
  83779. * If the parameter `makeItUnique` is true, a new global geometry is created from this positions and is set to the mesh.
  83780. *
  83781. * Possible `kind` values :
  83782. * - VertexBuffer.PositionKind
  83783. * - VertexBuffer.UVKind
  83784. * - VertexBuffer.UV2Kind
  83785. * - VertexBuffer.UV3Kind
  83786. * - VertexBuffer.UV4Kind
  83787. * - VertexBuffer.UV5Kind
  83788. * - VertexBuffer.UV6Kind
  83789. * - VertexBuffer.ColorKind
  83790. * - VertexBuffer.MatricesIndicesKind
  83791. * - VertexBuffer.MatricesIndicesExtraKind
  83792. * - VertexBuffer.MatricesWeightsKind
  83793. * - VertexBuffer.MatricesWeightsExtraKind
  83794. *
  83795. * Returns the Mesh.
  83796. */
  83797. InstancedMesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  83798. if (this.sourceMesh) {
  83799. this.sourceMesh.updateVerticesData(kind, data, updateExtends, makeItUnique);
  83800. }
  83801. return this.sourceMesh;
  83802. };
  83803. /**
  83804. * Sets the mesh indices.
  83805. * Expects an array populated with integers or a typed array (Int32Array, Uint32Array, Uint16Array).
  83806. * If the mesh has no geometry, a new Geometry object is created and set to the mesh.
  83807. * This method creates a new index buffer each call.
  83808. * Returns the Mesh.
  83809. */
  83810. InstancedMesh.prototype.setIndices = function (indices, totalVertices) {
  83811. if (totalVertices === void 0) { totalVertices = null; }
  83812. if (this.sourceMesh) {
  83813. this.sourceMesh.setIndices(indices, totalVertices);
  83814. }
  83815. return this.sourceMesh;
  83816. };
  83817. /**
  83818. * Boolean : True if the mesh owns the requested kind of data.
  83819. */
  83820. InstancedMesh.prototype.isVerticesDataPresent = function (kind) {
  83821. return this._sourceMesh.isVerticesDataPresent(kind);
  83822. };
  83823. /**
  83824. * Returns an array of indices (IndicesArray).
  83825. */
  83826. InstancedMesh.prototype.getIndices = function () {
  83827. return this._sourceMesh.getIndices();
  83828. };
  83829. Object.defineProperty(InstancedMesh.prototype, "_positions", {
  83830. get: function () {
  83831. return this._sourceMesh._positions;
  83832. },
  83833. enumerable: true,
  83834. configurable: true
  83835. });
  83836. /**
  83837. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  83838. * This means the mesh underlying bounding box and sphere are recomputed.
  83839. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  83840. * @returns the current mesh
  83841. */
  83842. InstancedMesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  83843. if (applySkeleton === void 0) { applySkeleton = false; }
  83844. if (this._boundingInfo && this._boundingInfo.isLocked) {
  83845. return this;
  83846. }
  83847. var bias = this._sourceMesh.geometry ? this._sourceMesh.geometry.boundingBias : null;
  83848. this._refreshBoundingInfo(this._sourceMesh._getPositionData(applySkeleton), bias);
  83849. return this;
  83850. };
  83851. /** @hidden */
  83852. InstancedMesh.prototype._preActivate = function () {
  83853. if (this._currentLOD) {
  83854. this._currentLOD._preActivate();
  83855. }
  83856. return this;
  83857. };
  83858. /** @hidden */
  83859. InstancedMesh.prototype._activate = function (renderId) {
  83860. if (this._currentLOD) {
  83861. this._currentLOD._registerInstanceForRenderId(this, renderId);
  83862. }
  83863. return this;
  83864. };
  83865. /**
  83866. * Returns the current associated LOD AbstractMesh.
  83867. */
  83868. InstancedMesh.prototype.getLOD = function (camera) {
  83869. if (!camera) {
  83870. return this;
  83871. }
  83872. var boundingInfo = this.getBoundingInfo();
  83873. this._currentLOD = this.sourceMesh.getLOD(camera, boundingInfo.boundingSphere);
  83874. if (this._currentLOD === this.sourceMesh) {
  83875. return this;
  83876. }
  83877. return this._currentLOD;
  83878. };
  83879. /** @hidden */
  83880. InstancedMesh.prototype._syncSubMeshes = function () {
  83881. this.releaseSubMeshes();
  83882. if (this._sourceMesh.subMeshes) {
  83883. for (var index = 0; index < this._sourceMesh.subMeshes.length; index++) {
  83884. this._sourceMesh.subMeshes[index].clone(this, this._sourceMesh);
  83885. }
  83886. }
  83887. return this;
  83888. };
  83889. /** @hidden */
  83890. InstancedMesh.prototype._generatePointsArray = function () {
  83891. return this._sourceMesh._generatePointsArray();
  83892. };
  83893. /**
  83894. * Creates a new InstancedMesh from the current mesh.
  83895. * - name (string) : the cloned mesh name
  83896. * - newParent (optional Node) : the optional Node to parent the clone to.
  83897. * - doNotCloneChildren (optional boolean, default `false`) : if `true` the model children aren't cloned.
  83898. *
  83899. * Returns the clone.
  83900. */
  83901. InstancedMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  83902. var result = this._sourceMesh.createInstance(name);
  83903. // Deep copy
  83904. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_4__["DeepCopier"].DeepCopy(this, result, ["name", "subMeshes", "uniqueId"], []);
  83905. // Bounding info
  83906. this.refreshBoundingInfo();
  83907. // Parent
  83908. if (newParent) {
  83909. result.parent = newParent;
  83910. }
  83911. if (!doNotCloneChildren) {
  83912. // Children
  83913. for (var index = 0; index < this.getScene().meshes.length; index++) {
  83914. var mesh = this.getScene().meshes[index];
  83915. if (mesh.parent === this) {
  83916. mesh.clone(mesh.name, result);
  83917. }
  83918. }
  83919. }
  83920. result.computeWorldMatrix(true);
  83921. return result;
  83922. };
  83923. /**
  83924. * Disposes the InstancedMesh.
  83925. * Returns nothing.
  83926. */
  83927. InstancedMesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  83928. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  83929. // Remove from mesh
  83930. this._sourceMesh.removeInstance(this);
  83931. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  83932. };
  83933. return InstancedMesh;
  83934. }(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"]));
  83935. /***/ }),
  83936. /***/ "./Meshes/linesMesh.ts":
  83937. /*!*****************************!*\
  83938. !*** ./Meshes/linesMesh.ts ***!
  83939. \*****************************/
  83940. /*! exports provided: LinesMesh, InstancedLinesMesh */
  83941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  83942. "use strict";
  83943. __webpack_require__.r(__webpack_exports__);
  83944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return LinesMesh; });
  83945. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return InstancedLinesMesh; });
  83946. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  83947. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  83948. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  83949. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  83950. /* harmony import */ var _Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/instancedMesh */ "./Meshes/instancedMesh.ts");
  83951. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  83952. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  83953. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  83954. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  83955. /**
  83956. * Line mesh
  83957. * @see https://doc.babylonjs.com/babylon101/parametric_shapes
  83958. */
  83959. var LinesMesh = /** @class */ (function (_super) {
  83960. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LinesMesh, _super);
  83961. /**
  83962. * Creates a new LinesMesh
  83963. * @param name defines the name
  83964. * @param scene defines the hosting scene
  83965. * @param parent defines the parent mesh if any
  83966. * @param source defines the optional source LinesMesh used to clone data from
  83967. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  83968. * When false, achieved by calling a clone(), also passing False.
  83969. * This will make creation of children, recursive.
  83970. * @param useVertexColor defines if this LinesMesh supports vertex color
  83971. * @param useVertexAlpha defines if this LinesMesh supports vertex alpha
  83972. */
  83973. function LinesMesh(name, scene, parent, source, doNotCloneChildren,
  83974. /**
  83975. * If vertex color should be applied to the mesh
  83976. */
  83977. useVertexColor,
  83978. /**
  83979. * If vertex alpha should be applied to the mesh
  83980. */
  83981. useVertexAlpha) {
  83982. if (scene === void 0) { scene = null; }
  83983. if (parent === void 0) { parent = null; }
  83984. var _this = _super.call(this, name, scene, parent, source, doNotCloneChildren) || this;
  83985. _this.useVertexColor = useVertexColor;
  83986. _this.useVertexAlpha = useVertexAlpha;
  83987. /**
  83988. * Color of the line (Default: White)
  83989. */
  83990. _this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"](1, 1, 1);
  83991. /**
  83992. * Alpha of the line (Default: 1)
  83993. */
  83994. _this.alpha = 1;
  83995. if (source) {
  83996. _this.color = source.color.clone();
  83997. _this.alpha = source.alpha;
  83998. _this.useVertexColor = source.useVertexColor;
  83999. _this.useVertexAlpha = source.useVertexAlpha;
  84000. }
  84001. _this.intersectionThreshold = 0.1;
  84002. var defines = [];
  84003. var options = {
  84004. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, "world0", "world1", "world2", "world3"],
  84005. uniforms: ["world", "viewProjection"],
  84006. needAlphaBlending: true,
  84007. defines: defines
  84008. };
  84009. if (useVertexAlpha === false) {
  84010. options.needAlphaBlending = false;
  84011. }
  84012. if (!useVertexColor) {
  84013. options.uniforms.push("color");
  84014. }
  84015. else {
  84016. options.defines.push("#define VERTEXCOLOR");
  84017. options.attributes.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind);
  84018. }
  84019. _this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("colorShader", _this.getScene(), "color", options);
  84020. return _this;
  84021. }
  84022. /**
  84023. * Returns the string "LineMesh"
  84024. */
  84025. LinesMesh.prototype.getClassName = function () {
  84026. return "LinesMesh";
  84027. };
  84028. Object.defineProperty(LinesMesh.prototype, "material", {
  84029. /**
  84030. * @hidden
  84031. */
  84032. get: function () {
  84033. return this._colorShader;
  84034. },
  84035. /**
  84036. * @hidden
  84037. */
  84038. set: function (value) {
  84039. // Do nothing
  84040. },
  84041. enumerable: true,
  84042. configurable: true
  84043. });
  84044. Object.defineProperty(LinesMesh.prototype, "checkCollisions", {
  84045. /**
  84046. * @hidden
  84047. */
  84048. get: function () {
  84049. return false;
  84050. },
  84051. enumerable: true,
  84052. configurable: true
  84053. });
  84054. /** @hidden */
  84055. LinesMesh.prototype._bind = function (subMesh, effect, fillMode) {
  84056. if (!this._geometry) {
  84057. return this;
  84058. }
  84059. // VBOs
  84060. this._geometry._bind(this._colorShader.getEffect());
  84061. // Color
  84062. if (!this.useVertexColor) {
  84063. this._colorShader.setColor4("color", this.color.toColor4(this.alpha));
  84064. }
  84065. return this;
  84066. };
  84067. /** @hidden */
  84068. LinesMesh.prototype._draw = function (subMesh, fillMode, instancesCount) {
  84069. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  84070. return this;
  84071. }
  84072. var engine = this.getScene().getEngine();
  84073. // Draw order
  84074. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].LineListDrawMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  84075. return this;
  84076. };
  84077. /**
  84078. * Disposes of the line mesh
  84079. * @param doNotRecurse If children should be disposed
  84080. */
  84081. LinesMesh.prototype.dispose = function (doNotRecurse) {
  84082. this._colorShader.dispose(false, false, true);
  84083. _super.prototype.dispose.call(this, doNotRecurse);
  84084. };
  84085. /**
  84086. * Returns a new LineMesh object cloned from the current one.
  84087. */
  84088. LinesMesh.prototype.clone = function (name, newParent, doNotCloneChildren) {
  84089. return new LinesMesh(name, this.getScene(), newParent, this, doNotCloneChildren);
  84090. };
  84091. /**
  84092. * Creates a new InstancedLinesMesh object from the mesh model.
  84093. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84094. * @param name defines the name of the new instance
  84095. * @returns a new InstancedLinesMesh
  84096. */
  84097. LinesMesh.prototype.createInstance = function (name) {
  84098. return new InstancedLinesMesh(name, this);
  84099. };
  84100. return LinesMesh;
  84101. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"]));
  84102. /**
  84103. * Creates an instance based on a source LinesMesh
  84104. */
  84105. var InstancedLinesMesh = /** @class */ (function (_super) {
  84106. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](InstancedLinesMesh, _super);
  84107. function InstancedLinesMesh(name, source) {
  84108. var _this = _super.call(this, name, source) || this;
  84109. _this.intersectionThreshold = source.intersectionThreshold;
  84110. return _this;
  84111. }
  84112. /**
  84113. * Returns the string "InstancedLinesMesh".
  84114. */
  84115. InstancedLinesMesh.prototype.getClassName = function () {
  84116. return "InstancedLinesMesh";
  84117. };
  84118. return InstancedLinesMesh;
  84119. }(_Meshes_instancedMesh__WEBPACK_IMPORTED_MODULE_4__["InstancedMesh"]));
  84120. /***/ }),
  84121. /***/ "./Meshes/mesh.ts":
  84122. /*!************************!*\
  84123. !*** ./Meshes/mesh.ts ***!
  84124. \************************/
  84125. /*! exports provided: MeshLODLevel, _CreationDataStorage, _InstancesBatch, Mesh */
  84126. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  84127. "use strict";
  84128. __webpack_require__.r(__webpack_exports__);
  84129. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return MeshLODLevel; });
  84130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _CreationDataStorage; });
  84131. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _InstancesBatch; });
  84132. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return Mesh; });
  84133. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  84134. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  84135. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  84136. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  84137. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  84138. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  84139. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../node */ "./node.ts");
  84140. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  84141. /* harmony import */ var _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  84142. /* harmony import */ var _geometry__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./geometry */ "./Meshes/geometry.ts");
  84143. /* harmony import */ var _abstractMesh__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractMesh */ "./Meshes/abstractMesh.ts");
  84144. /* harmony import */ var _subMesh__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./subMesh */ "./Meshes/subMesh.ts");
  84145. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  84146. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  84147. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  84148. /* harmony import */ var _Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Loading/sceneLoaderFlags */ "./Loading/sceneLoaderFlags.ts");
  84149. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  84150. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  84151. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  84152. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  84153. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  84154. /**
  84155. * Class used to represent a specific level of detail of a mesh
  84156. * @see http://doc.babylonjs.com/how_to/how_to_use_lod
  84157. */
  84158. var MeshLODLevel = /** @class */ (function () {
  84159. /**
  84160. * Creates a new LOD level
  84161. * @param distance defines the distance where this level should star being displayed
  84162. * @param mesh defines the mesh to use to render this level
  84163. */
  84164. function MeshLODLevel(
  84165. /** Defines the distance where this level should star being displayed */
  84166. distance,
  84167. /** Defines the mesh to use to render this level */
  84168. mesh) {
  84169. this.distance = distance;
  84170. this.mesh = mesh;
  84171. }
  84172. return MeshLODLevel;
  84173. }());
  84174. /**
  84175. * @hidden
  84176. **/
  84177. var _CreationDataStorage = /** @class */ (function () {
  84178. function _CreationDataStorage() {
  84179. }
  84180. return _CreationDataStorage;
  84181. }());
  84182. /**
  84183. * @hidden
  84184. **/
  84185. var _InstanceDataStorage = /** @class */ (function () {
  84186. function _InstanceDataStorage() {
  84187. this.visibleInstances = {};
  84188. this.renderIdForInstances = new Array();
  84189. this.batchCache = new _InstancesBatch();
  84190. this.instancesBufferSize = 32 * 16 * 4; // let's start with a maximum of 32 instances
  84191. }
  84192. return _InstanceDataStorage;
  84193. }());
  84194. /**
  84195. * @hidden
  84196. **/
  84197. var _InstancesBatch = /** @class */ (function () {
  84198. function _InstancesBatch() {
  84199. this.mustReturn = false;
  84200. this.visibleInstances = new Array();
  84201. this.renderSelf = new Array();
  84202. }
  84203. return _InstancesBatch;
  84204. }());
  84205. /**
  84206. * Class used to represent renderable models
  84207. */
  84208. var Mesh = /** @class */ (function (_super) {
  84209. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Mesh, _super);
  84210. /**
  84211. * @constructor
  84212. * @param name The value used by scene.getMeshByName() to do a lookup.
  84213. * @param scene The scene to add this mesh to.
  84214. * @param parent The parent of this mesh, if it has one
  84215. * @param source An optional Mesh from which geometry is shared, cloned.
  84216. * @param doNotCloneChildren When cloning, skip cloning child meshes of source, default False.
  84217. * When false, achieved by calling a clone(), also passing False.
  84218. * This will make creation of children, recursive.
  84219. * @param clonePhysicsImpostor When cloning, include cloning mesh physics impostor, default True.
  84220. */
  84221. function Mesh(name, scene, parent, source, doNotCloneChildren, clonePhysicsImpostor) {
  84222. if (scene === void 0) { scene = null; }
  84223. if (parent === void 0) { parent = null; }
  84224. if (source === void 0) { source = null; }
  84225. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  84226. var _this = _super.call(this, name, scene) || this;
  84227. // Members
  84228. /**
  84229. * Gets the delay loading state of the mesh (when delay loading is turned on)
  84230. * @see http://doc.babylonjs.com/how_to/using_the_incremental_loading_system
  84231. */
  84232. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NONE;
  84233. /**
  84234. * Gets the list of instances created from this mesh
  84235. * it is not supposed to be modified manually.
  84236. * Note also that the order of the InstancedMesh wihin the array is not significant and might change.
  84237. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  84238. */
  84239. _this.instances = new Array();
  84240. _this._LODLevels = new Array();
  84241. /** @hidden */
  84242. _this._instanceDataStorage = new _InstanceDataStorage();
  84243. // Use by builder only to know what orientation were the mesh build in.
  84244. /** @hidden */
  84245. _this._originalBuilderSideOrientation = Mesh.DEFAULTSIDE;
  84246. /**
  84247. * Use this property to change the original side orientation defined at construction time
  84248. */
  84249. _this.overrideMaterialSideOrientation = null;
  84250. _this._areNormalsFrozen = false; // Will be used by ribbons mainly
  84251. // Will be used to save a source mesh reference, If any
  84252. _this._source = null;
  84253. /** @hidden */
  84254. _this._isMesh = true;
  84255. scene = _this.getScene();
  84256. if (source) {
  84257. // Geometry
  84258. if (source._geometry) {
  84259. source._geometry.applyToMesh(_this);
  84260. }
  84261. // Deep copy
  84262. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(source, _this, ["name", "material", "skeleton", "instances", "parent", "uniqueId",
  84263. "source", "metadata", "hasLODLevels", "geometry", "isBlocked", "areNormalsFrozen",
  84264. "onBeforeDrawObservable", "onBeforeRenderObservable", "onAfterRenderObservable", "onBeforeDraw",
  84265. "onAfterWorldMatrixUpdateObservable", "onCollideObservable", "onCollisionPositionChangeObservable", "onRebuildObservable",
  84266. "onDisposeObservable"
  84267. ], ["_poseMatrix"]);
  84268. // Source mesh
  84269. _this._source = source;
  84270. if (scene.useClonedMeshhMap) {
  84271. if (!source.meshMap) {
  84272. source.meshMap = {};
  84273. }
  84274. source.meshMap[_this.uniqueId] = _this;
  84275. }
  84276. // Construction Params
  84277. // Clone parameters allowing mesh to be updated in case of parametric shapes.
  84278. _this._originalBuilderSideOrientation = source._originalBuilderSideOrientation;
  84279. _this._creationDataStorage = source._creationDataStorage;
  84280. // Animation ranges
  84281. if (_this._source._ranges) {
  84282. var ranges = _this._source._ranges;
  84283. for (var name in ranges) {
  84284. if (!ranges.hasOwnProperty(name)) {
  84285. continue;
  84286. }
  84287. if (!ranges[name]) {
  84288. continue;
  84289. }
  84290. _this.createAnimationRange(name, ranges[name].from, ranges[name].to);
  84291. }
  84292. }
  84293. // Metadata
  84294. if (source.metadata && source.metadata.clone) {
  84295. _this.metadata = source.metadata.clone();
  84296. }
  84297. else {
  84298. _this.metadata = source.metadata;
  84299. }
  84300. // Tags
  84301. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(source)) {
  84302. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(_this, _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(source, true));
  84303. }
  84304. // Parent
  84305. _this.parent = source.parent;
  84306. // Pivot
  84307. _this.setPivotMatrix(source.getPivotMatrix());
  84308. _this.id = name + "." + source.id;
  84309. // Material
  84310. _this.material = source.material;
  84311. var index;
  84312. if (!doNotCloneChildren) {
  84313. // Children
  84314. var directDescendants = source.getDescendants(true);
  84315. for (var index_1 = 0; index_1 < directDescendants.length; index_1++) {
  84316. var child = directDescendants[index_1];
  84317. if (child.clone) {
  84318. child.clone(name + "." + child.name, _this);
  84319. }
  84320. }
  84321. }
  84322. // Physics clone
  84323. var physicsEngine = _this.getScene().getPhysicsEngine();
  84324. if (clonePhysicsImpostor && physicsEngine) {
  84325. var impostor = physicsEngine.getImpostorForPhysicsObject(source);
  84326. if (impostor) {
  84327. _this.physicsImpostor = impostor.clone(_this);
  84328. }
  84329. }
  84330. // Particles
  84331. for (index = 0; index < scene.particleSystems.length; index++) {
  84332. var system = scene.particleSystems[index];
  84333. if (system.emitter === source) {
  84334. system.clone(system.name, _this);
  84335. }
  84336. }
  84337. _this.refreshBoundingInfo();
  84338. _this.computeWorldMatrix(true);
  84339. }
  84340. // Parent
  84341. if (parent !== null) {
  84342. _this.parent = parent;
  84343. }
  84344. return _this;
  84345. }
  84346. /**
  84347. * Gets the default side orientation.
  84348. * @param orientation the orientation to value to attempt to get
  84349. * @returns the default orientation
  84350. * @hidden
  84351. */
  84352. Mesh._GetDefaultSideOrientation = function (orientation) {
  84353. if (orientation == Mesh.DOUBLESIDE) {
  84354. return Mesh.DOUBLESIDE;
  84355. }
  84356. if (orientation === undefined || orientation === null) {
  84357. return Mesh.FRONTSIDE;
  84358. }
  84359. return orientation;
  84360. };
  84361. Object.defineProperty(Mesh.prototype, "onBeforeRenderObservable", {
  84362. /**
  84363. * An event triggered before rendering the mesh
  84364. */
  84365. get: function () {
  84366. if (!this._onBeforeRenderObservable) {
  84367. this._onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  84368. }
  84369. return this._onBeforeRenderObservable;
  84370. },
  84371. enumerable: true,
  84372. configurable: true
  84373. });
  84374. Object.defineProperty(Mesh.prototype, "onBeforeBindObservable", {
  84375. /**
  84376. * An event triggered before binding the mesh
  84377. */
  84378. get: function () {
  84379. if (!this._onBeforeBindObservable) {
  84380. this._onBeforeBindObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  84381. }
  84382. return this._onBeforeBindObservable;
  84383. },
  84384. enumerable: true,
  84385. configurable: true
  84386. });
  84387. Object.defineProperty(Mesh.prototype, "onAfterRenderObservable", {
  84388. /**
  84389. * An event triggered after rendering the mesh
  84390. */
  84391. get: function () {
  84392. if (!this._onAfterRenderObservable) {
  84393. this._onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  84394. }
  84395. return this._onAfterRenderObservable;
  84396. },
  84397. enumerable: true,
  84398. configurable: true
  84399. });
  84400. Object.defineProperty(Mesh.prototype, "onBeforeDrawObservable", {
  84401. /**
  84402. * An event triggered before drawing the mesh
  84403. */
  84404. get: function () {
  84405. if (!this._onBeforeDrawObservable) {
  84406. this._onBeforeDrawObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  84407. }
  84408. return this._onBeforeDrawObservable;
  84409. },
  84410. enumerable: true,
  84411. configurable: true
  84412. });
  84413. Object.defineProperty(Mesh.prototype, "onBeforeDraw", {
  84414. /**
  84415. * Sets a callback to call before drawing the mesh. It is recommended to use onBeforeDrawObservable instead
  84416. */
  84417. set: function (callback) {
  84418. if (this._onBeforeDrawObserver) {
  84419. this.onBeforeDrawObservable.remove(this._onBeforeDrawObserver);
  84420. }
  84421. this._onBeforeDrawObserver = this.onBeforeDrawObservable.add(callback);
  84422. },
  84423. enumerable: true,
  84424. configurable: true
  84425. });
  84426. Object.defineProperty(Mesh.prototype, "morphTargetManager", {
  84427. /**
  84428. * Gets or sets the morph target manager
  84429. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  84430. */
  84431. get: function () {
  84432. return this._morphTargetManager;
  84433. },
  84434. set: function (value) {
  84435. if (this._morphTargetManager === value) {
  84436. return;
  84437. }
  84438. this._morphTargetManager = value;
  84439. this._syncGeometryWithMorphTargetManager();
  84440. },
  84441. enumerable: true,
  84442. configurable: true
  84443. });
  84444. Object.defineProperty(Mesh.prototype, "source", {
  84445. /**
  84446. * Gets the source mesh (the one used to clone this one from)
  84447. */
  84448. get: function () {
  84449. return this._source;
  84450. },
  84451. enumerable: true,
  84452. configurable: true
  84453. });
  84454. Object.defineProperty(Mesh.prototype, "isUnIndexed", {
  84455. /**
  84456. * Gets or sets a boolean indicating that this mesh does not use index buffer
  84457. */
  84458. get: function () {
  84459. return this._unIndexed;
  84460. },
  84461. set: function (value) {
  84462. if (this._unIndexed !== value) {
  84463. this._unIndexed = value;
  84464. this._markSubMeshesAsAttributesDirty();
  84465. }
  84466. },
  84467. enumerable: true,
  84468. configurable: true
  84469. });
  84470. // Methods
  84471. /**
  84472. * Gets the class name
  84473. * @returns the string "Mesh".
  84474. */
  84475. Mesh.prototype.getClassName = function () {
  84476. return "Mesh";
  84477. };
  84478. /**
  84479. * Returns a description of this mesh
  84480. * @param fullDetails define if full details about this mesh must be used
  84481. * @returns a descriptive string representing this mesh
  84482. */
  84483. Mesh.prototype.toString = function (fullDetails) {
  84484. var ret = _super.prototype.toString.call(this, fullDetails);
  84485. ret += ", n vertices: " + this.getTotalVertices();
  84486. ret += ", parent: " + (this._waitingParentId ? this._waitingParentId : (this.parent ? this.parent.name : "NONE"));
  84487. if (this.animations) {
  84488. for (var i = 0; i < this.animations.length; i++) {
  84489. ret += ", animation[0]: " + this.animations[i].toString(fullDetails);
  84490. }
  84491. }
  84492. if (fullDetails) {
  84493. if (this._geometry) {
  84494. var ib = this.getIndices();
  84495. var vb = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  84496. if (vb && ib) {
  84497. ret += ", flat shading: " + (vb.length / 3 === ib.length ? "YES" : "NO");
  84498. }
  84499. }
  84500. else {
  84501. ret += ", flat shading: UNKNOWN";
  84502. }
  84503. }
  84504. return ret;
  84505. };
  84506. /** @hidden */
  84507. Mesh.prototype._unBindEffect = function () {
  84508. _super.prototype._unBindEffect.call(this);
  84509. for (var _i = 0, _a = this.instances; _i < _a.length; _i++) {
  84510. var instance = _a[_i];
  84511. instance._unBindEffect();
  84512. }
  84513. };
  84514. Object.defineProperty(Mesh.prototype, "hasLODLevels", {
  84515. /**
  84516. * Gets a boolean indicating if this mesh has LOD
  84517. */
  84518. get: function () {
  84519. return this._LODLevels.length > 0;
  84520. },
  84521. enumerable: true,
  84522. configurable: true
  84523. });
  84524. /**
  84525. * Gets the list of MeshLODLevel associated with the current mesh
  84526. * @returns an array of MeshLODLevel
  84527. */
  84528. Mesh.prototype.getLODLevels = function () {
  84529. return this._LODLevels;
  84530. };
  84531. Mesh.prototype._sortLODLevels = function () {
  84532. this._LODLevels.sort(function (a, b) {
  84533. if (a.distance < b.distance) {
  84534. return 1;
  84535. }
  84536. if (a.distance > b.distance) {
  84537. return -1;
  84538. }
  84539. return 0;
  84540. });
  84541. };
  84542. /**
  84543. * Add a mesh as LOD level triggered at the given distance.
  84544. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84545. * @param distance The distance from the center of the object to show this level
  84546. * @param mesh The mesh to be added as LOD level (can be null)
  84547. * @return This mesh (for chaining)
  84548. */
  84549. Mesh.prototype.addLODLevel = function (distance, mesh) {
  84550. if (mesh && mesh._masterMesh) {
  84551. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("You cannot use a mesh as LOD level twice");
  84552. return this;
  84553. }
  84554. var level = new MeshLODLevel(distance, mesh);
  84555. this._LODLevels.push(level);
  84556. if (mesh) {
  84557. mesh._masterMesh = this;
  84558. }
  84559. this._sortLODLevels();
  84560. return this;
  84561. };
  84562. /**
  84563. * Returns the LOD level mesh at the passed distance or null if not found.
  84564. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84565. * @param distance The distance from the center of the object to show this level
  84566. * @returns a Mesh or `null`
  84567. */
  84568. Mesh.prototype.getLODLevelAtDistance = function (distance) {
  84569. for (var index = 0; index < this._LODLevels.length; index++) {
  84570. var level = this._LODLevels[index];
  84571. if (level.distance === distance) {
  84572. return level.mesh;
  84573. }
  84574. }
  84575. return null;
  84576. };
  84577. /**
  84578. * Remove a mesh from the LOD array
  84579. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84580. * @param mesh defines the mesh to be removed
  84581. * @return This mesh (for chaining)
  84582. */
  84583. Mesh.prototype.removeLODLevel = function (mesh) {
  84584. for (var index = 0; index < this._LODLevels.length; index++) {
  84585. if (this._LODLevels[index].mesh === mesh) {
  84586. this._LODLevels.splice(index, 1);
  84587. if (mesh) {
  84588. mesh._masterMesh = null;
  84589. }
  84590. }
  84591. }
  84592. this._sortLODLevels();
  84593. return this;
  84594. };
  84595. /**
  84596. * Returns the registered LOD mesh distant from the parameter `camera` position if any, else returns the current mesh.
  84597. * @see https://doc.babylonjs.com/how_to/how_to_use_lod
  84598. * @param camera defines the camera to use to compute distance
  84599. * @param boundingSphere defines a custom bounding sphere to use instead of the one from this mesh
  84600. * @return This mesh (for chaining)
  84601. */
  84602. Mesh.prototype.getLOD = function (camera, boundingSphere) {
  84603. if (!this._LODLevels || this._LODLevels.length === 0) {
  84604. return this;
  84605. }
  84606. var bSphere;
  84607. if (boundingSphere) {
  84608. bSphere = boundingSphere;
  84609. }
  84610. else {
  84611. var boundingInfo = this.getBoundingInfo();
  84612. bSphere = boundingInfo.boundingSphere;
  84613. }
  84614. var distanceToCamera = bSphere.centerWorld.subtract(camera.globalPosition).length();
  84615. if (this._LODLevels[this._LODLevels.length - 1].distance > distanceToCamera) {
  84616. if (this.onLODLevelSelection) {
  84617. this.onLODLevelSelection(distanceToCamera, this, this._LODLevels[this._LODLevels.length - 1].mesh);
  84618. }
  84619. return this;
  84620. }
  84621. for (var index = 0; index < this._LODLevels.length; index++) {
  84622. var level = this._LODLevels[index];
  84623. if (level.distance < distanceToCamera) {
  84624. if (level.mesh) {
  84625. level.mesh._preActivate();
  84626. level.mesh._updateSubMeshesBoundingInfo(this.worldMatrixFromCache);
  84627. }
  84628. if (this.onLODLevelSelection) {
  84629. this.onLODLevelSelection(distanceToCamera, this, level.mesh);
  84630. }
  84631. return level.mesh;
  84632. }
  84633. }
  84634. if (this.onLODLevelSelection) {
  84635. this.onLODLevelSelection(distanceToCamera, this, this);
  84636. }
  84637. return this;
  84638. };
  84639. Object.defineProperty(Mesh.prototype, "geometry", {
  84640. /**
  84641. * Gets the mesh internal Geometry object
  84642. */
  84643. get: function () {
  84644. return this._geometry;
  84645. },
  84646. enumerable: true,
  84647. configurable: true
  84648. });
  84649. /**
  84650. * Returns the total number of vertices within the mesh geometry or zero if the mesh has no geometry.
  84651. * @returns the total number of vertices
  84652. */
  84653. Mesh.prototype.getTotalVertices = function () {
  84654. if (this._geometry === null || this._geometry === undefined) {
  84655. return 0;
  84656. }
  84657. return this._geometry.getTotalVertices();
  84658. };
  84659. /**
  84660. * Returns the content of an associated vertex buffer
  84661. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84662. * - VertexBuffer.PositionKind
  84663. * - VertexBuffer.UVKind
  84664. * - VertexBuffer.UV2Kind
  84665. * - VertexBuffer.UV3Kind
  84666. * - VertexBuffer.UV4Kind
  84667. * - VertexBuffer.UV5Kind
  84668. * - VertexBuffer.UV6Kind
  84669. * - VertexBuffer.ColorKind
  84670. * - VertexBuffer.MatricesIndicesKind
  84671. * - VertexBuffer.MatricesIndicesExtraKind
  84672. * - VertexBuffer.MatricesWeightsKind
  84673. * - VertexBuffer.MatricesWeightsExtraKind
  84674. * @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
  84675. * @param forceCopy defines a boolean forcing the copy of the buffer no matter what the value of copyWhenShared is
  84676. * @returns a FloatArray or null if the mesh has no geometry or no vertex buffer for this kind.
  84677. */
  84678. Mesh.prototype.getVerticesData = function (kind, copyWhenShared, forceCopy) {
  84679. if (!this._geometry) {
  84680. return null;
  84681. }
  84682. return this._geometry.getVerticesData(kind, copyWhenShared, forceCopy);
  84683. };
  84684. /**
  84685. * Returns the mesh VertexBuffer object from the requested `kind`
  84686. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84687. * - VertexBuffer.PositionKind
  84688. * - VertexBuffer.UVKind
  84689. * - VertexBuffer.UV2Kind
  84690. * - VertexBuffer.UV3Kind
  84691. * - VertexBuffer.UV4Kind
  84692. * - VertexBuffer.UV5Kind
  84693. * - VertexBuffer.UV6Kind
  84694. * - VertexBuffer.ColorKind
  84695. * - VertexBuffer.MatricesIndicesKind
  84696. * - VertexBuffer.MatricesIndicesExtraKind
  84697. * - VertexBuffer.MatricesWeightsKind
  84698. * - VertexBuffer.MatricesWeightsExtraKind
  84699. * @returns a FloatArray or null if the mesh has no vertex buffer for this kind.
  84700. */
  84701. Mesh.prototype.getVertexBuffer = function (kind) {
  84702. if (!this._geometry) {
  84703. return null;
  84704. }
  84705. return this._geometry.getVertexBuffer(kind);
  84706. };
  84707. /**
  84708. * Tests if a specific vertex buffer is associated with this mesh
  84709. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84710. * - VertexBuffer.PositionKind
  84711. * - VertexBuffer.UVKind
  84712. * - VertexBuffer.UV2Kind
  84713. * - VertexBuffer.UV3Kind
  84714. * - VertexBuffer.UV4Kind
  84715. * - VertexBuffer.UV5Kind
  84716. * - VertexBuffer.UV6Kind
  84717. * - VertexBuffer.ColorKind
  84718. * - VertexBuffer.MatricesIndicesKind
  84719. * - VertexBuffer.MatricesIndicesExtraKind
  84720. * - VertexBuffer.MatricesWeightsKind
  84721. * - VertexBuffer.MatricesWeightsExtraKind
  84722. * @returns a boolean
  84723. */
  84724. Mesh.prototype.isVerticesDataPresent = function (kind) {
  84725. if (!this._geometry) {
  84726. if (this._delayInfo) {
  84727. return this._delayInfo.indexOf(kind) !== -1;
  84728. }
  84729. return false;
  84730. }
  84731. return this._geometry.isVerticesDataPresent(kind);
  84732. };
  84733. /**
  84734. * Returns a boolean defining if the vertex data for the requested `kind` is updatable.
  84735. * @param kind defines which buffer to check (positions, indices, normals, etc). Possible `kind` values :
  84736. * - VertexBuffer.PositionKind
  84737. * - VertexBuffer.UVKind
  84738. * - VertexBuffer.UV2Kind
  84739. * - VertexBuffer.UV3Kind
  84740. * - VertexBuffer.UV4Kind
  84741. * - VertexBuffer.UV5Kind
  84742. * - VertexBuffer.UV6Kind
  84743. * - VertexBuffer.ColorKind
  84744. * - VertexBuffer.MatricesIndicesKind
  84745. * - VertexBuffer.MatricesIndicesExtraKind
  84746. * - VertexBuffer.MatricesWeightsKind
  84747. * - VertexBuffer.MatricesWeightsExtraKind
  84748. * @returns a boolean
  84749. */
  84750. Mesh.prototype.isVertexBufferUpdatable = function (kind) {
  84751. if (!this._geometry) {
  84752. if (this._delayInfo) {
  84753. return this._delayInfo.indexOf(kind) !== -1;
  84754. }
  84755. return false;
  84756. }
  84757. return this._geometry.isVertexBufferUpdatable(kind);
  84758. };
  84759. /**
  84760. * Returns a string which contains the list of existing `kinds` of Vertex Data associated with this mesh.
  84761. * @param kind defines which buffer to read from (positions, indices, normals, etc). Possible `kind` values :
  84762. * - VertexBuffer.PositionKind
  84763. * - VertexBuffer.UVKind
  84764. * - VertexBuffer.UV2Kind
  84765. * - VertexBuffer.UV3Kind
  84766. * - VertexBuffer.UV4Kind
  84767. * - VertexBuffer.UV5Kind
  84768. * - VertexBuffer.UV6Kind
  84769. * - VertexBuffer.ColorKind
  84770. * - VertexBuffer.MatricesIndicesKind
  84771. * - VertexBuffer.MatricesIndicesExtraKind
  84772. * - VertexBuffer.MatricesWeightsKind
  84773. * - VertexBuffer.MatricesWeightsExtraKind
  84774. * @returns an array of strings
  84775. */
  84776. Mesh.prototype.getVerticesDataKinds = function () {
  84777. if (!this._geometry) {
  84778. var result = new Array();
  84779. if (this._delayInfo) {
  84780. this._delayInfo.forEach(function (kind) {
  84781. result.push(kind);
  84782. });
  84783. }
  84784. return result;
  84785. }
  84786. return this._geometry.getVerticesDataKinds();
  84787. };
  84788. /**
  84789. * Returns a positive integer : the total number of indices in this mesh geometry.
  84790. * @returns the numner of indices or zero if the mesh has no geometry.
  84791. */
  84792. Mesh.prototype.getTotalIndices = function () {
  84793. if (!this._geometry) {
  84794. return 0;
  84795. }
  84796. return this._geometry.getTotalIndices();
  84797. };
  84798. /**
  84799. * Returns an array of integers or a typed array (Int32Array, Uint32Array, Uint16Array) populated with the mesh indices.
  84800. * @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.
  84801. * @param forceCopy defines a boolean indicating that the returned array must be cloned upon returning it
  84802. * @returns the indices array or an empty array if the mesh has no geometry
  84803. */
  84804. Mesh.prototype.getIndices = function (copyWhenShared, forceCopy) {
  84805. if (!this._geometry) {
  84806. return [];
  84807. }
  84808. return this._geometry.getIndices(copyWhenShared, forceCopy);
  84809. };
  84810. Object.defineProperty(Mesh.prototype, "isBlocked", {
  84811. get: function () {
  84812. return this._masterMesh !== null && this._masterMesh !== undefined;
  84813. },
  84814. enumerable: true,
  84815. configurable: true
  84816. });
  84817. /**
  84818. * Determine if the current mesh is ready to be rendered
  84819. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  84820. * @param forceInstanceSupport will check if the mesh will be ready when used with instances (false by default)
  84821. * @returns true if all associated assets are ready (material, textures, shaders)
  84822. */
  84823. Mesh.prototype.isReady = function (completeCheck, forceInstanceSupport) {
  84824. if (completeCheck === void 0) { completeCheck = false; }
  84825. if (forceInstanceSupport === void 0) { forceInstanceSupport = false; }
  84826. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  84827. return false;
  84828. }
  84829. if (!_super.prototype.isReady.call(this, completeCheck)) {
  84830. return false;
  84831. }
  84832. if (!this.subMeshes || this.subMeshes.length === 0) {
  84833. return true;
  84834. }
  84835. if (!completeCheck) {
  84836. return true;
  84837. }
  84838. var engine = this.getEngine();
  84839. var scene = this.getScene();
  84840. var hardwareInstancedRendering = forceInstanceSupport || engine.getCaps().instancedArrays && this.instances.length > 0;
  84841. this.computeWorldMatrix();
  84842. var mat = this.material || scene.defaultMaterial;
  84843. if (mat) {
  84844. if (mat._storeEffectOnSubMeshes) {
  84845. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84846. var subMesh = _a[_i];
  84847. var effectiveMaterial = subMesh.getMaterial();
  84848. if (effectiveMaterial) {
  84849. if (effectiveMaterial._storeEffectOnSubMeshes) {
  84850. if (!effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  84851. return false;
  84852. }
  84853. }
  84854. else {
  84855. if (!effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  84856. return false;
  84857. }
  84858. }
  84859. }
  84860. }
  84861. }
  84862. else {
  84863. if (!mat.isReady(this, hardwareInstancedRendering)) {
  84864. return false;
  84865. }
  84866. }
  84867. }
  84868. // Shadows
  84869. for (var _b = 0, _c = this._lightSources; _b < _c.length; _b++) {
  84870. var light = _c[_b];
  84871. var generator = light.getShadowGenerator();
  84872. if (generator) {
  84873. for (var _d = 0, _e = this.subMeshes; _d < _e.length; _d++) {
  84874. var subMesh = _e[_d];
  84875. if (!generator.isReady(subMesh, hardwareInstancedRendering)) {
  84876. return false;
  84877. }
  84878. }
  84879. }
  84880. }
  84881. // LOD
  84882. for (var _f = 0, _g = this._LODLevels; _f < _g.length; _f++) {
  84883. var lod = _g[_f];
  84884. if (lod.mesh && !lod.mesh.isReady(hardwareInstancedRendering)) {
  84885. return false;
  84886. }
  84887. }
  84888. return true;
  84889. };
  84890. Object.defineProperty(Mesh.prototype, "areNormalsFrozen", {
  84891. /**
  84892. * 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.
  84893. */
  84894. get: function () {
  84895. return this._areNormalsFrozen;
  84896. },
  84897. enumerable: true,
  84898. configurable: true
  84899. });
  84900. /**
  84901. * 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.
  84902. * @returns the current mesh
  84903. */
  84904. Mesh.prototype.freezeNormals = function () {
  84905. this._areNormalsFrozen = true;
  84906. return this;
  84907. };
  84908. /**
  84909. * 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
  84910. * @returns the current mesh
  84911. */
  84912. Mesh.prototype.unfreezeNormals = function () {
  84913. this._areNormalsFrozen = false;
  84914. return this;
  84915. };
  84916. Object.defineProperty(Mesh.prototype, "overridenInstanceCount", {
  84917. /**
  84918. * Sets a value overriding the instance count. Only applicable when custom instanced InterleavedVertexBuffer are used rather than InstancedMeshs
  84919. */
  84920. set: function (count) {
  84921. this._instanceDataStorage.overridenInstanceCount = count;
  84922. },
  84923. enumerable: true,
  84924. configurable: true
  84925. });
  84926. // Methods
  84927. /** @hidden */
  84928. Mesh.prototype._preActivate = function () {
  84929. var sceneRenderId = this.getScene().getRenderId();
  84930. if (this._preActivateId === sceneRenderId) {
  84931. return this;
  84932. }
  84933. this._preActivateId = sceneRenderId;
  84934. this._instanceDataStorage.visibleInstances = null;
  84935. return this;
  84936. };
  84937. /** @hidden */
  84938. Mesh.prototype._preActivateForIntermediateRendering = function (renderId) {
  84939. if (this._instanceDataStorage.visibleInstances) {
  84940. this._instanceDataStorage.visibleInstances.intermediateDefaultRenderId = renderId;
  84941. }
  84942. return this;
  84943. };
  84944. /** @hidden */
  84945. Mesh.prototype._registerInstanceForRenderId = function (instance, renderId) {
  84946. if (!this._instanceDataStorage.visibleInstances) {
  84947. this._instanceDataStorage.visibleInstances = {
  84948. defaultRenderId: renderId,
  84949. selfDefaultRenderId: this._renderId
  84950. };
  84951. }
  84952. if (!this._instanceDataStorage.visibleInstances[renderId]) {
  84953. this._instanceDataStorage.visibleInstances[renderId] = new Array();
  84954. }
  84955. this._instanceDataStorage.visibleInstances[renderId].push(instance);
  84956. return this;
  84957. };
  84958. /**
  84959. * This method recomputes and sets a new BoundingInfo to the mesh unless it is locked.
  84960. * This means the mesh underlying bounding box and sphere are recomputed.
  84961. * @param applySkeleton defines whether to apply the skeleton before computing the bounding info
  84962. * @returns the current mesh
  84963. */
  84964. Mesh.prototype.refreshBoundingInfo = function (applySkeleton) {
  84965. if (applySkeleton === void 0) { applySkeleton = false; }
  84966. if (this._boundingInfo && this._boundingInfo.isLocked) {
  84967. return this;
  84968. }
  84969. var bias = this.geometry ? this.geometry.boundingBias : null;
  84970. this._refreshBoundingInfo(this._getPositionData(applySkeleton), bias);
  84971. return this;
  84972. };
  84973. /** @hidden */
  84974. Mesh.prototype._createGlobalSubMesh = function (force) {
  84975. var totalVertices = this.getTotalVertices();
  84976. if (!totalVertices || !this.getIndices()) {
  84977. return null;
  84978. }
  84979. // Check if we need to recreate the submeshes
  84980. if (this.subMeshes && this.subMeshes.length > 0) {
  84981. var ib = this.getIndices();
  84982. if (!ib) {
  84983. return null;
  84984. }
  84985. var totalIndices = ib.length;
  84986. var needToRecreate = false;
  84987. if (force) {
  84988. needToRecreate = true;
  84989. }
  84990. else {
  84991. for (var _i = 0, _a = this.subMeshes; _i < _a.length; _i++) {
  84992. var submesh = _a[_i];
  84993. if (submesh.indexStart + submesh.indexCount >= totalIndices) {
  84994. needToRecreate = true;
  84995. break;
  84996. }
  84997. if (submesh.verticesStart + submesh.verticesCount >= totalVertices) {
  84998. needToRecreate = true;
  84999. break;
  85000. }
  85001. }
  85002. }
  85003. if (!needToRecreate) {
  85004. return this.subMeshes[0];
  85005. }
  85006. }
  85007. this.releaseSubMeshes();
  85008. return new _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"](0, 0, totalVertices, 0, this.getTotalIndices(), this);
  85009. };
  85010. /**
  85011. * This function will subdivide the mesh into multiple submeshes
  85012. * @param count defines the expected number of submeshes
  85013. */
  85014. Mesh.prototype.subdivide = function (count) {
  85015. if (count < 1) {
  85016. return;
  85017. }
  85018. var totalIndices = this.getTotalIndices();
  85019. var subdivisionSize = (totalIndices / count) | 0;
  85020. var offset = 0;
  85021. // Ensure that subdivisionSize is a multiple of 3
  85022. while (subdivisionSize % 3 !== 0) {
  85023. subdivisionSize++;
  85024. }
  85025. this.releaseSubMeshes();
  85026. for (var index = 0; index < count; index++) {
  85027. if (offset >= totalIndices) {
  85028. break;
  85029. }
  85030. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, Math.min(subdivisionSize, totalIndices - offset), this);
  85031. offset += subdivisionSize;
  85032. }
  85033. this.synchronizeInstances();
  85034. };
  85035. /**
  85036. * Copy a FloatArray into a specific associated vertex buffer
  85037. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85038. * - VertexBuffer.PositionKind
  85039. * - VertexBuffer.UVKind
  85040. * - VertexBuffer.UV2Kind
  85041. * - VertexBuffer.UV3Kind
  85042. * - VertexBuffer.UV4Kind
  85043. * - VertexBuffer.UV5Kind
  85044. * - VertexBuffer.UV6Kind
  85045. * - VertexBuffer.ColorKind
  85046. * - VertexBuffer.MatricesIndicesKind
  85047. * - VertexBuffer.MatricesIndicesExtraKind
  85048. * - VertexBuffer.MatricesWeightsKind
  85049. * - VertexBuffer.MatricesWeightsExtraKind
  85050. * @param data defines the data source
  85051. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  85052. * @param stride defines the data stride size (can be null)
  85053. * @returns the current mesh
  85054. */
  85055. Mesh.prototype.setVerticesData = function (kind, data, updatable, stride) {
  85056. if (updatable === void 0) { updatable = false; }
  85057. if (!this._geometry) {
  85058. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  85059. vertexData.set(data, kind);
  85060. var scene = this.getScene();
  85061. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  85062. }
  85063. else {
  85064. this._geometry.setVerticesData(kind, data, updatable, stride);
  85065. }
  85066. return this;
  85067. };
  85068. /**
  85069. * Flags an associated vertex buffer as updatable
  85070. * @param kind defines which buffer to use (positions, indices, normals, etc). Possible `kind` values :
  85071. * - VertexBuffer.PositionKind
  85072. * - VertexBuffer.UVKind
  85073. * - VertexBuffer.UV2Kind
  85074. * - VertexBuffer.UV3Kind
  85075. * - VertexBuffer.UV4Kind
  85076. * - VertexBuffer.UV5Kind
  85077. * - VertexBuffer.UV6Kind
  85078. * - VertexBuffer.ColorKind
  85079. * - VertexBuffer.MatricesIndicesKind
  85080. * - VertexBuffer.MatricesIndicesExtraKind
  85081. * - VertexBuffer.MatricesWeightsKind
  85082. * - VertexBuffer.MatricesWeightsExtraKind
  85083. * @param updatable defines if the updated vertex buffer must be flagged as updatable
  85084. */
  85085. Mesh.prototype.markVerticesDataAsUpdatable = function (kind, updatable) {
  85086. if (updatable === void 0) { updatable = true; }
  85087. var vb = this.getVertexBuffer(kind);
  85088. if (!vb || vb.isUpdatable() === updatable) {
  85089. return;
  85090. }
  85091. this.setVerticesData(kind, this.getVerticesData(kind), updatable);
  85092. };
  85093. /**
  85094. * Sets the mesh global Vertex Buffer
  85095. * @param buffer defines the buffer to use
  85096. * @returns the current mesh
  85097. */
  85098. Mesh.prototype.setVerticesBuffer = function (buffer) {
  85099. if (!this._geometry) {
  85100. this._geometry = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].CreateGeometryForMesh(this);
  85101. }
  85102. this._geometry.setVerticesBuffer(buffer);
  85103. return this;
  85104. };
  85105. /**
  85106. * Update a specific associated vertex buffer
  85107. * @param kind defines which buffer to write to (positions, indices, normals, etc). Possible `kind` values :
  85108. * - VertexBuffer.PositionKind
  85109. * - VertexBuffer.UVKind
  85110. * - VertexBuffer.UV2Kind
  85111. * - VertexBuffer.UV3Kind
  85112. * - VertexBuffer.UV4Kind
  85113. * - VertexBuffer.UV5Kind
  85114. * - VertexBuffer.UV6Kind
  85115. * - VertexBuffer.ColorKind
  85116. * - VertexBuffer.MatricesIndicesKind
  85117. * - VertexBuffer.MatricesIndicesExtraKind
  85118. * - VertexBuffer.MatricesWeightsKind
  85119. * - VertexBuffer.MatricesWeightsExtraKind
  85120. * @param data defines the data source
  85121. * @param updateExtends defines if extends info of the mesh must be updated (can be null). This is mostly useful for "position" kind
  85122. * @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)
  85123. * @returns the current mesh
  85124. */
  85125. Mesh.prototype.updateVerticesData = function (kind, data, updateExtends, makeItUnique) {
  85126. if (!this._geometry) {
  85127. return this;
  85128. }
  85129. if (!makeItUnique) {
  85130. this._geometry.updateVerticesData(kind, data, updateExtends);
  85131. }
  85132. else {
  85133. this.makeGeometryUnique();
  85134. this.updateVerticesData(kind, data, updateExtends, false);
  85135. }
  85136. return this;
  85137. };
  85138. /**
  85139. * This method updates the vertex positions of an updatable mesh according to the `positionFunction` returned values.
  85140. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh#other-shapes-updatemeshpositions
  85141. * @param positionFunction is a simple JS function what is passed the mesh `positions` array. It doesn't need to return anything
  85142. * @param computeNormals is a boolean (default true) to enable/disable the mesh normal recomputation after the vertex position update
  85143. * @returns the current mesh
  85144. */
  85145. Mesh.prototype.updateMeshPositions = function (positionFunction, computeNormals) {
  85146. if (computeNormals === void 0) { computeNormals = true; }
  85147. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85148. if (!positions) {
  85149. return this;
  85150. }
  85151. positionFunction(positions);
  85152. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions, false, false);
  85153. if (computeNormals) {
  85154. var indices = this.getIndices();
  85155. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85156. if (!normals) {
  85157. return this;
  85158. }
  85159. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, indices, normals);
  85160. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, false, false);
  85161. }
  85162. return this;
  85163. };
  85164. /**
  85165. * Creates a un-shared specific occurence of the geometry for the mesh.
  85166. * @returns the current mesh
  85167. */
  85168. Mesh.prototype.makeGeometryUnique = function () {
  85169. if (!this._geometry) {
  85170. return this;
  85171. }
  85172. var oldGeometry = this._geometry;
  85173. var geometry = this._geometry.copy(_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId());
  85174. oldGeometry.releaseForMesh(this, true);
  85175. geometry.applyToMesh(this);
  85176. return this;
  85177. };
  85178. /**
  85179. * Set the index buffer of this mesh
  85180. * @param indices defines the source data
  85181. * @param totalVertices defines the total number of vertices referenced by this index data (can be null)
  85182. * @param updatable defines if the updated index buffer must be flagged as updatable (default is false)
  85183. * @returns the current mesh
  85184. */
  85185. Mesh.prototype.setIndices = function (indices, totalVertices, updatable) {
  85186. if (totalVertices === void 0) { totalVertices = null; }
  85187. if (updatable === void 0) { updatable = false; }
  85188. if (!this._geometry) {
  85189. var vertexData = new _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"]();
  85190. vertexData.indices = indices;
  85191. var scene = this.getScene();
  85192. new _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"](_geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"].RandomId(), scene, vertexData, updatable, this);
  85193. }
  85194. else {
  85195. this._geometry.setIndices(indices, totalVertices, updatable);
  85196. }
  85197. return this;
  85198. };
  85199. /**
  85200. * Update the current index buffer
  85201. * @param indices defines the source data
  85202. * @param offset defines the offset in the index buffer where to store the new data (can be null)
  85203. * @returns the current mesh
  85204. */
  85205. Mesh.prototype.updateIndices = function (indices, offset) {
  85206. if (!this._geometry) {
  85207. return this;
  85208. }
  85209. this._geometry.updateIndices(indices, offset);
  85210. return this;
  85211. };
  85212. /**
  85213. * Invert the geometry to move from a right handed system to a left handed one.
  85214. * @returns the current mesh
  85215. */
  85216. Mesh.prototype.toLeftHanded = function () {
  85217. if (!this._geometry) {
  85218. return this;
  85219. }
  85220. this._geometry.toLeftHanded();
  85221. return this;
  85222. };
  85223. /** @hidden */
  85224. Mesh.prototype._bind = function (subMesh, effect, fillMode) {
  85225. if (!this._geometry) {
  85226. return this;
  85227. }
  85228. var engine = this.getScene().getEngine();
  85229. // Wireframe
  85230. var indexToBind;
  85231. if (this._unIndexed) {
  85232. indexToBind = null;
  85233. }
  85234. else {
  85235. switch (fillMode) {
  85236. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode:
  85237. indexToBind = null;
  85238. break;
  85239. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode:
  85240. indexToBind = subMesh._getLinesIndexBuffer(this.getIndices(), engine);
  85241. break;
  85242. default:
  85243. case _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].TriangleFillMode:
  85244. indexToBind = this._unIndexed ? null : this._geometry.getIndexBuffer();
  85245. break;
  85246. }
  85247. }
  85248. // VBOs
  85249. this._geometry._bind(effect, indexToBind);
  85250. return this;
  85251. };
  85252. /** @hidden */
  85253. Mesh.prototype._draw = function (subMesh, fillMode, instancesCount, alternate) {
  85254. if (alternate === void 0) { alternate = false; }
  85255. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  85256. return this;
  85257. }
  85258. if (this._onBeforeDrawObservable) {
  85259. this._onBeforeDrawObservable.notifyObservers(this);
  85260. }
  85261. var scene = this.getScene();
  85262. var engine = scene.getEngine();
  85263. if (this._unIndexed || fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].PointFillMode) {
  85264. // or triangles as points
  85265. engine.drawArraysType(fillMode, subMesh.verticesStart, subMesh.verticesCount, instancesCount);
  85266. }
  85267. else if (fillMode == _Materials_material__WEBPACK_IMPORTED_MODULE_13__["Material"].WireFrameFillMode) {
  85268. // Triangles as wireframe
  85269. engine.drawElementsType(fillMode, 0, subMesh._linesIndexCount, instancesCount);
  85270. }
  85271. else {
  85272. engine.drawElementsType(fillMode, subMesh.indexStart, subMesh.indexCount, instancesCount);
  85273. }
  85274. if (scene._isAlternateRenderingEnabled && !alternate) {
  85275. var effect = subMesh.effect || this._effectiveMaterial.getEffect();
  85276. if (!effect || !scene.activeCamera) {
  85277. return this;
  85278. }
  85279. scene._switchToAlternateCameraConfiguration(true);
  85280. this._effectiveMaterial.bindView(effect);
  85281. this._effectiveMaterial.bindViewProjection(effect);
  85282. engine.setViewport(scene.activeCamera._alternateCamera.viewport);
  85283. this._draw(subMesh, fillMode, instancesCount, true);
  85284. engine.setViewport(scene.activeCamera.viewport);
  85285. scene._switchToAlternateCameraConfiguration(false);
  85286. this._effectiveMaterial.bindView(effect);
  85287. this._effectiveMaterial.bindViewProjection(effect);
  85288. }
  85289. return this;
  85290. };
  85291. /**
  85292. * Registers for this mesh a javascript function called just before the rendering process
  85293. * @param func defines the function to call before rendering this mesh
  85294. * @returns the current mesh
  85295. */
  85296. Mesh.prototype.registerBeforeRender = function (func) {
  85297. this.onBeforeRenderObservable.add(func);
  85298. return this;
  85299. };
  85300. /**
  85301. * Disposes a previously registered javascript function called before the rendering
  85302. * @param func defines the function to remove
  85303. * @returns the current mesh
  85304. */
  85305. Mesh.prototype.unregisterBeforeRender = function (func) {
  85306. this.onBeforeRenderObservable.removeCallback(func);
  85307. return this;
  85308. };
  85309. /**
  85310. * Registers for this mesh a javascript function called just after the rendering is complete
  85311. * @param func defines the function to call after rendering this mesh
  85312. * @returns the current mesh
  85313. */
  85314. Mesh.prototype.registerAfterRender = function (func) {
  85315. this.onAfterRenderObservable.add(func);
  85316. return this;
  85317. };
  85318. /**
  85319. * Disposes a previously registered javascript function called after the rendering.
  85320. * @param func defines the function to remove
  85321. * @returns the current mesh
  85322. */
  85323. Mesh.prototype.unregisterAfterRender = function (func) {
  85324. this.onAfterRenderObservable.removeCallback(func);
  85325. return this;
  85326. };
  85327. /** @hidden */
  85328. Mesh.prototype._getInstancesRenderList = function (subMeshId) {
  85329. var scene = this.getScene();
  85330. var batchCache = this._instanceDataStorage.batchCache;
  85331. batchCache.mustReturn = false;
  85332. batchCache.renderSelf[subMeshId] = this.isEnabled() && this.isVisible;
  85333. batchCache.visibleInstances[subMeshId] = null;
  85334. if (this._instanceDataStorage.visibleInstances) {
  85335. var visibleInstances = this._instanceDataStorage.visibleInstances;
  85336. var currentRenderId = scene.getRenderId();
  85337. var defaultRenderId = (scene._isInIntermediateRendering() ? visibleInstances.intermediateDefaultRenderId : visibleInstances.defaultRenderId);
  85338. batchCache.visibleInstances[subMeshId] = visibleInstances[currentRenderId];
  85339. var selfRenderId = this._renderId;
  85340. if (!batchCache.visibleInstances[subMeshId] && defaultRenderId) {
  85341. batchCache.visibleInstances[subMeshId] = visibleInstances[defaultRenderId];
  85342. currentRenderId = Math.max(defaultRenderId, currentRenderId);
  85343. selfRenderId = Math.max(visibleInstances.selfDefaultRenderId, currentRenderId);
  85344. }
  85345. var visibleInstancesForSubMesh = batchCache.visibleInstances[subMeshId];
  85346. if (visibleInstancesForSubMesh && visibleInstancesForSubMesh.length) {
  85347. if (this._instanceDataStorage.renderIdForInstances[subMeshId] === currentRenderId) {
  85348. batchCache.mustReturn = true;
  85349. return batchCache;
  85350. }
  85351. if (currentRenderId !== selfRenderId) {
  85352. batchCache.renderSelf[subMeshId] = false;
  85353. }
  85354. }
  85355. this._instanceDataStorage.renderIdForInstances[subMeshId] = currentRenderId;
  85356. }
  85357. return batchCache;
  85358. };
  85359. /** @hidden */
  85360. Mesh.prototype._renderWithInstances = function (subMesh, fillMode, batch, effect, engine) {
  85361. var visibleInstances = batch.visibleInstances[subMesh._id];
  85362. if (!visibleInstances) {
  85363. return this;
  85364. }
  85365. var matricesCount = visibleInstances.length + 1;
  85366. var bufferSize = matricesCount * 16 * 4;
  85367. var instanceStorage = this._instanceDataStorage;
  85368. var currentInstancesBufferSize = instanceStorage.instancesBufferSize;
  85369. var instancesBuffer = instanceStorage.instancesBuffer;
  85370. while (instanceStorage.instancesBufferSize < bufferSize) {
  85371. instanceStorage.instancesBufferSize *= 2;
  85372. }
  85373. if (!instanceStorage.instancesData || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  85374. instanceStorage.instancesData = new Float32Array(instanceStorage.instancesBufferSize / 4);
  85375. }
  85376. var offset = 0;
  85377. var instancesCount = 0;
  85378. var world = this.getWorldMatrix();
  85379. if (batch.renderSelf[subMesh._id]) {
  85380. world.copyToArray(instanceStorage.instancesData, offset);
  85381. offset += 16;
  85382. instancesCount++;
  85383. }
  85384. if (visibleInstances) {
  85385. for (var instanceIndex = 0; instanceIndex < visibleInstances.length; instanceIndex++) {
  85386. var instance = visibleInstances[instanceIndex];
  85387. instance.getWorldMatrix().copyToArray(instanceStorage.instancesData, offset);
  85388. offset += 16;
  85389. instancesCount++;
  85390. }
  85391. }
  85392. if (!instancesBuffer || currentInstancesBufferSize != instanceStorage.instancesBufferSize) {
  85393. if (instancesBuffer) {
  85394. instancesBuffer.dispose();
  85395. }
  85396. instancesBuffer = new _buffer__WEBPACK_IMPORTED_MODULE_7__["Buffer"](engine, instanceStorage.instancesData, true, 16, false, true);
  85397. instanceStorage.instancesBuffer = instancesBuffer;
  85398. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world0", 0, 4));
  85399. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world1", 4, 4));
  85400. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world2", 8, 4));
  85401. this.setVerticesBuffer(instancesBuffer.createVertexBuffer("world3", 12, 4));
  85402. }
  85403. else {
  85404. instancesBuffer.updateDirectly(instanceStorage.instancesData, 0, instancesCount);
  85405. }
  85406. this._bind(subMesh, effect, fillMode);
  85407. this._draw(subMesh, fillMode, instancesCount);
  85408. engine.unbindInstanceAttributes();
  85409. return this;
  85410. };
  85411. /** @hidden */
  85412. Mesh.prototype._processRendering = function (subMesh, effect, fillMode, batch, hardwareInstancedRendering, onBeforeDraw, effectiveMaterial) {
  85413. var scene = this.getScene();
  85414. var engine = scene.getEngine();
  85415. if (hardwareInstancedRendering) {
  85416. this._renderWithInstances(subMesh, fillMode, batch, effect, engine);
  85417. }
  85418. else {
  85419. if (batch.renderSelf[subMesh._id]) {
  85420. // Draw
  85421. if (onBeforeDraw) {
  85422. onBeforeDraw(false, this.getWorldMatrix(), effectiveMaterial);
  85423. }
  85424. this._draw(subMesh, fillMode, this._instanceDataStorage.overridenInstanceCount);
  85425. }
  85426. var visibleInstancesForSubMesh = batch.visibleInstances[subMesh._id];
  85427. if (visibleInstancesForSubMesh) {
  85428. for (var instanceIndex = 0; instanceIndex < visibleInstancesForSubMesh.length; instanceIndex++) {
  85429. var instance = visibleInstancesForSubMesh[instanceIndex];
  85430. // World
  85431. var world = instance.getWorldMatrix();
  85432. if (onBeforeDraw) {
  85433. onBeforeDraw(true, world, effectiveMaterial);
  85434. }
  85435. // Draw
  85436. this._draw(subMesh, fillMode);
  85437. }
  85438. }
  85439. }
  85440. return this;
  85441. };
  85442. /**
  85443. * 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
  85444. * @param subMesh defines the subMesh to render
  85445. * @param enableAlphaMode defines if alpha mode can be changed
  85446. * @returns the current mesh
  85447. */
  85448. Mesh.prototype.render = function (subMesh, enableAlphaMode) {
  85449. if (this._checkOcclusionQuery()) {
  85450. return this;
  85451. }
  85452. var scene = this.getScene();
  85453. // Managing instances
  85454. var batch = this._getInstancesRenderList(subMesh._id);
  85455. if (batch.mustReturn) {
  85456. return this;
  85457. }
  85458. // Checking geometry state
  85459. if (!this._geometry || !this._geometry.getVertexBuffers() || (!this._unIndexed && !this._geometry.getIndexBuffer())) {
  85460. return this;
  85461. }
  85462. if (this._onBeforeRenderObservable) {
  85463. this._onBeforeRenderObservable.notifyObservers(this);
  85464. }
  85465. var engine = scene.getEngine();
  85466. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  85467. // Material
  85468. var material = subMesh.getMaterial();
  85469. if (!material) {
  85470. return this;
  85471. }
  85472. this._effectiveMaterial = material;
  85473. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85474. if (!this._effectiveMaterial.isReadyForSubMesh(this, subMesh, hardwareInstancedRendering)) {
  85475. return this;
  85476. }
  85477. }
  85478. else if (!this._effectiveMaterial.isReady(this, hardwareInstancedRendering)) {
  85479. return this;
  85480. }
  85481. // Alpha mode
  85482. if (enableAlphaMode) {
  85483. engine.setAlphaMode(this._effectiveMaterial.alphaMode);
  85484. }
  85485. for (var _i = 0, _a = scene._beforeRenderingMeshStage; _i < _a.length; _i++) {
  85486. var step = _a[_i];
  85487. step.action(this, subMesh, batch);
  85488. }
  85489. var effect;
  85490. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85491. effect = subMesh.effect;
  85492. }
  85493. else {
  85494. effect = this._effectiveMaterial.getEffect();
  85495. }
  85496. if (!effect) {
  85497. return this;
  85498. }
  85499. var effectiveMesh = (this.skeleton && this.skeleton.overrideMesh) || this;
  85500. var sideOrientation = this.overrideMaterialSideOrientation;
  85501. if (sideOrientation == null) {
  85502. sideOrientation = this._effectiveMaterial.sideOrientation;
  85503. if (effectiveMesh._getWorldMatrixDeterminant() < 0) {
  85504. 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);
  85505. }
  85506. }
  85507. var reverse = this._effectiveMaterial._preBind(effect, sideOrientation);
  85508. if (this._effectiveMaterial.forceDepthWrite) {
  85509. engine.setDepthWrite(true);
  85510. }
  85511. // Bind
  85512. 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);
  85513. if (this._onBeforeBindObservable) {
  85514. this._onBeforeBindObservable.notifyObservers(this);
  85515. }
  85516. if (!hardwareInstancedRendering) { // Binding will be done later because we need to add more info to the VB
  85517. this._bind(subMesh, effect, fillMode);
  85518. }
  85519. var world = effectiveMesh.getWorldMatrix();
  85520. if (this._effectiveMaterial._storeEffectOnSubMeshes) {
  85521. this._effectiveMaterial.bindForSubMesh(world, this, subMesh);
  85522. }
  85523. else {
  85524. this._effectiveMaterial.bind(world, this);
  85525. }
  85526. if (!this._effectiveMaterial.backFaceCulling && this._effectiveMaterial.separateCullingPass) {
  85527. engine.setState(true, this._effectiveMaterial.zOffset, false, !reverse);
  85528. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85529. engine.setState(true, this._effectiveMaterial.zOffset, false, reverse);
  85530. }
  85531. // Draw
  85532. this._processRendering(subMesh, effect, fillMode, batch, hardwareInstancedRendering, this._onBeforeDraw, this._effectiveMaterial);
  85533. // Unbind
  85534. this._effectiveMaterial.unbind();
  85535. for (var _b = 0, _c = scene._afterRenderingMeshStage; _b < _c.length; _b++) {
  85536. var step = _c[_b];
  85537. step.action(this, subMesh, batch);
  85538. }
  85539. if (this._onAfterRenderObservable) {
  85540. this._onAfterRenderObservable.notifyObservers(this);
  85541. }
  85542. return this;
  85543. };
  85544. Mesh.prototype._onBeforeDraw = function (isInstance, world, effectiveMaterial) {
  85545. if (isInstance && effectiveMaterial) {
  85546. effectiveMaterial.bindOnlyWorldMatrix(world);
  85547. }
  85548. };
  85549. /**
  85550. * Renormalize the mesh and patch it up if there are no weights
  85551. * Similar to normalization by adding the weights compute the reciprocal and multiply all elements, this wil ensure that everything adds to 1.
  85552. * However in the case of zero weights then we set just a single influence to 1.
  85553. * We check in the function for extra's present and if so we use the normalizeSkinWeightsWithExtras rather than the FourWeights version.
  85554. */
  85555. Mesh.prototype.cleanMatrixWeights = function () {
  85556. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  85557. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind)) {
  85558. this.normalizeSkinWeightsAndExtra();
  85559. }
  85560. else {
  85561. this.normalizeSkinFourWeights();
  85562. }
  85563. }
  85564. };
  85565. // faster 4 weight version.
  85566. Mesh.prototype.normalizeSkinFourWeights = function () {
  85567. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85568. var numWeights = matricesWeights.length;
  85569. for (var a = 0; a < numWeights; a += 4) {
  85570. // accumulate weights
  85571. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85572. // check for invalid weight and just set it to 1.
  85573. if (t === 0) {
  85574. matricesWeights[a] = 1;
  85575. }
  85576. else {
  85577. // renormalize so everything adds to 1 use reciprical
  85578. var recip = 1 / t;
  85579. matricesWeights[a] *= recip;
  85580. matricesWeights[a + 1] *= recip;
  85581. matricesWeights[a + 2] *= recip;
  85582. matricesWeights[a + 3] *= recip;
  85583. }
  85584. }
  85585. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85586. };
  85587. // handle special case of extra verts. (in theory gltf can handle 12 influences)
  85588. Mesh.prototype.normalizeSkinWeightsAndExtra = function () {
  85589. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85590. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85591. var numWeights = matricesWeights.length;
  85592. for (var a = 0; a < numWeights; a += 4) {
  85593. // accumulate weights
  85594. var t = matricesWeights[a] + matricesWeights[a + 1] + matricesWeights[a + 2] + matricesWeights[a + 3];
  85595. t += matricesWeightsExtra[a] + matricesWeightsExtra[a + 1] + matricesWeightsExtra[a + 2] + matricesWeightsExtra[a + 3];
  85596. // check for invalid weight and just set it to 1.
  85597. if (t === 0) {
  85598. matricesWeights[a] = 1;
  85599. }
  85600. else {
  85601. // renormalize so everything adds to 1 use reciprical
  85602. var recip = 1 / t;
  85603. matricesWeights[a] *= recip;
  85604. matricesWeights[a + 1] *= recip;
  85605. matricesWeights[a + 2] *= recip;
  85606. matricesWeights[a + 3] *= recip;
  85607. // same goes for extras
  85608. matricesWeightsExtra[a] *= recip;
  85609. matricesWeightsExtra[a + 1] *= recip;
  85610. matricesWeightsExtra[a + 2] *= recip;
  85611. matricesWeightsExtra[a + 3] *= recip;
  85612. }
  85613. }
  85614. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeights);
  85615. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind, matricesWeightsExtra);
  85616. };
  85617. /**
  85618. * ValidateSkinning is used to determine that a mesh has valid skinning data along with skin metrics, if missing weights,
  85619. * or not normalized it is returned as invalid mesh the string can be used for console logs, or on screen messages to let
  85620. * the user know there was an issue with importing the mesh
  85621. * @returns a validation object with skinned, valid and report string
  85622. */
  85623. Mesh.prototype.validateSkinning = function () {
  85624. var matricesWeightsExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind);
  85625. var matricesWeights = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  85626. if (matricesWeights === null || this.skeleton == null) {
  85627. return { skinned: false, valid: true, report: "not skinned" };
  85628. }
  85629. var numWeights = matricesWeights.length;
  85630. var numberNotSorted = 0;
  85631. var missingWeights = 0;
  85632. var maxUsedWeights = 0;
  85633. var numberNotNormalized = 0;
  85634. var numInfluences = matricesWeightsExtra === null ? 4 : 8;
  85635. var usedWeightCounts = new Array();
  85636. for (var a = 0; a <= numInfluences; a++) {
  85637. usedWeightCounts[a] = 0;
  85638. }
  85639. var toleranceEpsilon = 0.001;
  85640. for (var a = 0; a < numWeights; a += 4) {
  85641. var lastWeight = matricesWeights[a];
  85642. var t = lastWeight;
  85643. var usedWeights = t === 0 ? 0 : 1;
  85644. for (var b = 1; b < numInfluences; b++) {
  85645. var d = b < 4 ? matricesWeights[a + b] : matricesWeightsExtra[a + b - 4];
  85646. if (d > lastWeight) {
  85647. numberNotSorted++;
  85648. }
  85649. if (d !== 0) {
  85650. usedWeights++;
  85651. }
  85652. t += d;
  85653. lastWeight = d;
  85654. }
  85655. // count the buffer weights usage
  85656. usedWeightCounts[usedWeights]++;
  85657. // max influences
  85658. if (usedWeights > maxUsedWeights) {
  85659. maxUsedWeights = usedWeights;
  85660. }
  85661. // check for invalid weight and just set it to 1.
  85662. if (t === 0) {
  85663. missingWeights++;
  85664. }
  85665. else {
  85666. // renormalize so everything adds to 1 use reciprical
  85667. var recip = 1 / t;
  85668. var tolerance = 0;
  85669. for (b = 0; b < numInfluences; b++) {
  85670. if (b < 4) {
  85671. tolerance += Math.abs(matricesWeights[a + b] - (matricesWeights[a + b] * recip));
  85672. }
  85673. else {
  85674. tolerance += Math.abs(matricesWeightsExtra[a + b - 4] - (matricesWeightsExtra[a + b - 4] * recip));
  85675. }
  85676. }
  85677. // arbitary epsilon value for dicdating not normalized
  85678. if (tolerance > toleranceEpsilon) {
  85679. numberNotNormalized++;
  85680. }
  85681. }
  85682. }
  85683. // validate bone indices are in range of the skeleton
  85684. var numBones = this.skeleton.bones.length;
  85685. var matricesIndices = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  85686. var matricesIndicesExtra = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind);
  85687. var numBadBoneIndices = 0;
  85688. for (var a = 0; a < numWeights; a++) {
  85689. for (var b = 0; b < numInfluences; b++) {
  85690. var index = b < 4 ? matricesIndices[b] : matricesIndicesExtra[b - 4];
  85691. if (index >= numBones || index < 0) {
  85692. numBadBoneIndices++;
  85693. }
  85694. }
  85695. }
  85696. // log mesh stats
  85697. var output = "Number of Weights = " + numWeights / 4 + "\nMaximum influences = " + maxUsedWeights +
  85698. "\nMissing Weights = " + missingWeights + "\nNot Sorted = " + numberNotSorted +
  85699. "\nNot Normalized = " + numberNotNormalized + "\nWeightCounts = [" + usedWeightCounts + "]" +
  85700. "\nNumber of bones = " + numBones + "\nBad Bone Indices = " + numBadBoneIndices;
  85701. return { skinned: true, valid: missingWeights === 0 && numberNotNormalized === 0 && numBadBoneIndices === 0, report: output };
  85702. };
  85703. /** @hidden */
  85704. Mesh.prototype._checkDelayState = function () {
  85705. var scene = this.getScene();
  85706. if (this._geometry) {
  85707. this._geometry.load(scene);
  85708. }
  85709. else if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED) {
  85710. this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING;
  85711. this._queueLoad(scene);
  85712. }
  85713. return this;
  85714. };
  85715. Mesh.prototype._queueLoad = function (scene) {
  85716. var _this = this;
  85717. scene._addPendingData(this);
  85718. var getBinaryData = (this.delayLoadingFile.indexOf(".babylonbinarymeshdata") !== -1);
  85719. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadFile(this.delayLoadingFile, function (data) {
  85720. if (data instanceof ArrayBuffer) {
  85721. _this._delayLoadingFunction(data, _this);
  85722. }
  85723. else {
  85724. _this._delayLoadingFunction(JSON.parse(data), _this);
  85725. }
  85726. _this.instances.forEach(function (instance) {
  85727. instance._syncSubMeshes();
  85728. });
  85729. _this.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADED;
  85730. scene._removePendingData(_this);
  85731. }, function () { }, scene.offlineProvider, getBinaryData);
  85732. return this;
  85733. };
  85734. /**
  85735. * Returns `true` if the mesh is within the frustum defined by the passed array of planes.
  85736. * A mesh is in the frustum if its bounding box intersects the frustum
  85737. * @param frustumPlanes defines the frustum to test
  85738. * @returns true if the mesh is in the frustum planes
  85739. */
  85740. Mesh.prototype.isInFrustum = function (frustumPlanes) {
  85741. if (this.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_LOADING) {
  85742. return false;
  85743. }
  85744. if (!_super.prototype.isInFrustum.call(this, frustumPlanes)) {
  85745. return false;
  85746. }
  85747. this._checkDelayState();
  85748. return true;
  85749. };
  85750. /**
  85751. * Sets the mesh material by the material or multiMaterial `id` property
  85752. * @param id is a string identifying the material or the multiMaterial
  85753. * @returns the current mesh
  85754. */
  85755. Mesh.prototype.setMaterialByID = function (id) {
  85756. var materials = this.getScene().materials;
  85757. var index;
  85758. for (index = materials.length - 1; index > -1; index--) {
  85759. if (materials[index].id === id) {
  85760. this.material = materials[index];
  85761. return this;
  85762. }
  85763. }
  85764. // Multi
  85765. var multiMaterials = this.getScene().multiMaterials;
  85766. for (index = multiMaterials.length - 1; index > -1; index--) {
  85767. if (multiMaterials[index].id === id) {
  85768. this.material = multiMaterials[index];
  85769. return this;
  85770. }
  85771. }
  85772. return this;
  85773. };
  85774. /**
  85775. * Returns as a new array populated with the mesh material and/or skeleton, if any.
  85776. * @returns an array of IAnimatable
  85777. */
  85778. Mesh.prototype.getAnimatables = function () {
  85779. var results = new Array();
  85780. if (this.material) {
  85781. results.push(this.material);
  85782. }
  85783. if (this.skeleton) {
  85784. results.push(this.skeleton);
  85785. }
  85786. return results;
  85787. };
  85788. /**
  85789. * Modifies the mesh geometry according to the passed transformation matrix.
  85790. * This method returns nothing but it really modifies the mesh even if it's originally not set as updatable.
  85791. * The mesh normals are modified using the same transformation.
  85792. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85793. * @param transform defines the transform matrix to use
  85794. * @see http://doc.babylonjs.com/resources/baking_transformations
  85795. * @returns the current mesh
  85796. */
  85797. Mesh.prototype.bakeTransformIntoVertices = function (transform) {
  85798. // Position
  85799. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  85800. return this;
  85801. }
  85802. var submeshes = this.subMeshes.splice(0);
  85803. this._resetPointsArrayCache();
  85804. var data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  85805. var temp = new Array();
  85806. var index;
  85807. for (index = 0; index < data.length; index += 3) {
  85808. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).toArray(temp, index);
  85809. }
  85810. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind).isUpdatable());
  85811. // Normals
  85812. if (this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  85813. data = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  85814. temp = [];
  85815. for (index = 0; index < data.length; index += 3) {
  85816. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormal(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(data, index), transform).normalize().toArray(temp, index);
  85817. }
  85818. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, temp, this.getVertexBuffer(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind).isUpdatable());
  85819. }
  85820. // flip faces?
  85821. if (transform.m[0] * transform.m[5] * transform.m[10] < 0) {
  85822. this.flipFaces();
  85823. }
  85824. // Restore submeshes
  85825. this.releaseSubMeshes();
  85826. this.subMeshes = submeshes;
  85827. return this;
  85828. };
  85829. /**
  85830. * Modifies the mesh geometry according to its own current World Matrix.
  85831. * The mesh World Matrix is then reset.
  85832. * This method returns nothing but really modifies the mesh even if it's originally not set as updatable.
  85833. * Note that, under the hood, this method sets a new VertexBuffer each call.
  85834. * @see http://doc.babylonjs.com/resources/baking_transformations
  85835. * @returns the current mesh
  85836. */
  85837. Mesh.prototype.bakeCurrentTransformIntoVertices = function () {
  85838. this.bakeTransformIntoVertices(this.computeWorldMatrix(true));
  85839. this.scaling.copyFromFloats(1, 1, 1);
  85840. this.position.copyFromFloats(0, 0, 0);
  85841. this.rotation.copyFromFloats(0, 0, 0);
  85842. //only if quaternion is already set
  85843. if (this.rotationQuaternion) {
  85844. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].Identity();
  85845. }
  85846. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].Identity();
  85847. return this;
  85848. };
  85849. Object.defineProperty(Mesh.prototype, "_positions", {
  85850. // Cache
  85851. /** @hidden */
  85852. get: function () {
  85853. if (this._geometry) {
  85854. return this._geometry._positions;
  85855. }
  85856. return null;
  85857. },
  85858. enumerable: true,
  85859. configurable: true
  85860. });
  85861. /** @hidden */
  85862. Mesh.prototype._resetPointsArrayCache = function () {
  85863. if (this._geometry) {
  85864. this._geometry._resetPointsArrayCache();
  85865. }
  85866. return this;
  85867. };
  85868. /** @hidden */
  85869. Mesh.prototype._generatePointsArray = function () {
  85870. if (this._geometry) {
  85871. return this._geometry._generatePointsArray();
  85872. }
  85873. return false;
  85874. };
  85875. /**
  85876. * Returns a new Mesh object generated from the current mesh properties.
  85877. * This method must not get confused with createInstance()
  85878. * @param name is a string, the name given to the new mesh
  85879. * @param newParent can be any Node object (default `null`)
  85880. * @param doNotCloneChildren allows/denies the recursive cloning of the original mesh children if any (default `false`)
  85881. * @param clonePhysicsImpostor allows/denies the cloning in the same time of the original mesh `body` used by the physics engine, if any (default `true`)
  85882. * @returns a new mesh
  85883. */
  85884. Mesh.prototype.clone = function (name, newParent, doNotCloneChildren, clonePhysicsImpostor) {
  85885. if (name === void 0) { name = ""; }
  85886. if (clonePhysicsImpostor === void 0) { clonePhysicsImpostor = true; }
  85887. return new Mesh(name, this.getScene(), newParent, this, doNotCloneChildren, clonePhysicsImpostor);
  85888. };
  85889. /**
  85890. * Releases resources associated with this mesh.
  85891. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  85892. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  85893. */
  85894. Mesh.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  85895. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  85896. this.morphTargetManager = null;
  85897. if (this._geometry) {
  85898. this._geometry.releaseForMesh(this, true);
  85899. }
  85900. if (this._onBeforeDrawObservable) {
  85901. this._onBeforeDrawObservable.clear();
  85902. }
  85903. if (this._onBeforeBindObservable) {
  85904. this._onBeforeBindObservable.clear();
  85905. }
  85906. if (this._onBeforeRenderObservable) {
  85907. this._onBeforeRenderObservable.clear();
  85908. }
  85909. if (this._onAfterRenderObservable) {
  85910. this._onAfterRenderObservable.clear();
  85911. }
  85912. // Sources
  85913. if (this._scene.useClonedMeshhMap) {
  85914. if (this.meshMap) {
  85915. for (var uniqueId in this.meshMap) {
  85916. var mesh = this.meshMap[uniqueId];
  85917. if (mesh) {
  85918. mesh._source = null;
  85919. this.meshMap[uniqueId] = undefined;
  85920. }
  85921. }
  85922. }
  85923. if (this._source && this._source.meshMap) {
  85924. this._source.meshMap[this.uniqueId] = undefined;
  85925. }
  85926. }
  85927. else {
  85928. var meshes = this.getScene().meshes;
  85929. for (var _i = 0, meshes_1 = meshes; _i < meshes_1.length; _i++) {
  85930. var abstractMesh = meshes_1[_i];
  85931. var mesh = abstractMesh;
  85932. if (mesh._source && mesh._source === this) {
  85933. mesh._source = null;
  85934. }
  85935. }
  85936. }
  85937. this._source = null;
  85938. // Instances
  85939. if (this._instanceDataStorage.instancesBuffer) {
  85940. this._instanceDataStorage.instancesBuffer.dispose();
  85941. this._instanceDataStorage.instancesBuffer = null;
  85942. }
  85943. while (this.instances.length) {
  85944. this.instances[0].dispose();
  85945. }
  85946. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  85947. };
  85948. /**
  85949. * Modifies the mesh geometry according to a displacement map.
  85950. * 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.
  85951. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85952. * @param url is a string, the URL from the image file is to be downloaded.
  85953. * @param minHeight is the lower limit of the displacement.
  85954. * @param maxHeight is the upper limit of the displacement.
  85955. * @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.
  85956. * @param uvOffset is an optional vector2 used to offset UV.
  85957. * @param uvScale is an optional vector2 used to scale UV.
  85958. * @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.
  85959. * @returns the Mesh.
  85960. */
  85961. Mesh.prototype.applyDisplacementMap = function (url, minHeight, maxHeight, onSuccess, uvOffset, uvScale, forceUpdate) {
  85962. var _this = this;
  85963. if (forceUpdate === void 0) { forceUpdate = false; }
  85964. var scene = this.getScene();
  85965. var onload = function (img) {
  85966. // Getting height map data
  85967. var canvas = document.createElement("canvas");
  85968. var context = canvas.getContext("2d");
  85969. var heightMapWidth = img.width;
  85970. var heightMapHeight = img.height;
  85971. canvas.width = heightMapWidth;
  85972. canvas.height = heightMapHeight;
  85973. context.drawImage(img, 0, 0);
  85974. // Create VertexData from map data
  85975. //Cast is due to wrong definition in lib.d.ts from ts 1.3 - https://github.com/Microsoft/TypeScript/issues/949
  85976. var buffer = context.getImageData(0, 0, heightMapWidth, heightMapHeight).data;
  85977. _this.applyDisplacementMapFromBuffer(buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate);
  85978. //execute success callback, if set
  85979. if (onSuccess) {
  85980. onSuccess(_this);
  85981. }
  85982. };
  85983. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].LoadImage(url, onload, function () { }, scene.offlineProvider);
  85984. return this;
  85985. };
  85986. /**
  85987. * Modifies the mesh geometry according to a displacementMap buffer.
  85988. * 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.
  85989. * The mesh must be set as updatable. Its internal geometry is directly modified, no new buffer are allocated.
  85990. * @param buffer is a `Uint8Array` buffer containing series of `Uint8` lower than 255, the red, green, blue and alpha values of each successive pixel.
  85991. * @param heightMapWidth is the width of the buffer image.
  85992. * @param heightMapHeight is the height of the buffer image.
  85993. * @param minHeight is the lower limit of the displacement.
  85994. * @param maxHeight is the upper limit of the displacement.
  85995. * @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.
  85996. * @param uvOffset is an optional vector2 used to offset UV.
  85997. * @param uvScale is an optional vector2 used to scale UV.
  85998. * @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.
  85999. * @returns the Mesh.
  86000. */
  86001. Mesh.prototype.applyDisplacementMapFromBuffer = function (buffer, heightMapWidth, heightMapHeight, minHeight, maxHeight, uvOffset, uvScale, forceUpdate) {
  86002. if (forceUpdate === void 0) { forceUpdate = false; }
  86003. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)
  86004. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)
  86005. || !this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind)) {
  86006. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Warn("Cannot call applyDisplacementMap: Given mesh is not complete. Position, Normal or UV are missing");
  86007. return this;
  86008. }
  86009. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, true, true);
  86010. var normals = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  86011. var uvs = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86012. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86013. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  86014. var uv = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  86015. uvOffset = uvOffset || _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].Zero();
  86016. uvScale = uvScale || new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"](1, 1);
  86017. for (var index = 0; index < positions.length; index += 3) {
  86018. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(positions, index, position);
  86019. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArrayToRef(normals, index, normal);
  86020. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector2"].FromArrayToRef(uvs, (index / 3) * 2, uv);
  86021. // Compute height
  86022. var u = ((Math.abs(uv.x * uvScale.x + uvOffset.x) * heightMapWidth) % heightMapWidth) | 0;
  86023. var v = ((Math.abs(uv.y * uvScale.y + uvOffset.y) * heightMapHeight) % heightMapHeight) | 0;
  86024. var pos = (u + v * heightMapWidth) * 4;
  86025. var r = buffer[pos] / 255.0;
  86026. var g = buffer[pos + 1] / 255.0;
  86027. var b = buffer[pos + 2] / 255.0;
  86028. var gradient = r * 0.3 + g * 0.59 + b * 0.11;
  86029. normal.normalize();
  86030. normal.scaleInPlace(minHeight + (maxHeight - minHeight) * gradient);
  86031. position = position.add(normal);
  86032. position.toArray(positions, index);
  86033. }
  86034. _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ComputeNormals(positions, this.getIndices(), normals);
  86035. if (forceUpdate) {
  86036. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  86037. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  86038. }
  86039. else {
  86040. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positions);
  86041. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals);
  86042. }
  86043. return this;
  86044. };
  86045. /**
  86046. * Modify the mesh to get a flat shading rendering.
  86047. * This means each mesh facet will then have its own normals. Usually new vertices are added in the mesh geometry to get this result.
  86048. * Warning : the mesh is really modified even if not set originally as updatable and, under the hood, a new VertexBuffer is allocated.
  86049. * @returns current mesh
  86050. */
  86051. Mesh.prototype.convertToFlatShadedMesh = function () {
  86052. var kinds = this.getVerticesDataKinds();
  86053. var vbs = {};
  86054. var data = {};
  86055. var newdata = {};
  86056. var updatableNormals = false;
  86057. var kindIndex;
  86058. var kind;
  86059. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86060. kind = kinds[kindIndex];
  86061. var vertexBuffer = this.getVertexBuffer(kind);
  86062. if (kind === _buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) {
  86063. updatableNormals = vertexBuffer.isUpdatable();
  86064. kinds.splice(kindIndex, 1);
  86065. kindIndex--;
  86066. continue;
  86067. }
  86068. vbs[kind] = vertexBuffer;
  86069. data[kind] = vbs[kind].getData();
  86070. newdata[kind] = [];
  86071. }
  86072. // Save previous submeshes
  86073. var previousSubmeshes = this.subMeshes.slice(0);
  86074. var indices = this.getIndices();
  86075. var totalIndices = this.getTotalIndices();
  86076. // Generating unique vertices per face
  86077. var index;
  86078. for (index = 0; index < totalIndices; index++) {
  86079. var vertexIndex = indices[index];
  86080. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86081. kind = kinds[kindIndex];
  86082. var stride = vbs[kind].getStrideSize();
  86083. for (var offset = 0; offset < stride; offset++) {
  86084. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  86085. }
  86086. }
  86087. }
  86088. // Updating faces & normal
  86089. var normals = [];
  86090. var positions = newdata[_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind];
  86091. for (index = 0; index < totalIndices; index += 3) {
  86092. indices[index] = index;
  86093. indices[index + 1] = index + 1;
  86094. indices[index + 2] = index + 2;
  86095. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, index * 3);
  86096. var p2 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 1) * 3);
  86097. var p3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, (index + 2) * 3);
  86098. var p1p2 = p1.subtract(p2);
  86099. var p3p2 = p3.subtract(p2);
  86100. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Cross(p1p2, p3p2));
  86101. // Store same normals for every vertex
  86102. for (var localIndex = 0; localIndex < 3; localIndex++) {
  86103. normals.push(normal.x);
  86104. normals.push(normal.y);
  86105. normals.push(normal.z);
  86106. }
  86107. }
  86108. this.setIndices(indices);
  86109. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normals, updatableNormals);
  86110. // Updating vertex buffers
  86111. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86112. kind = kinds[kindIndex];
  86113. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  86114. }
  86115. // Updating submeshes
  86116. this.releaseSubMeshes();
  86117. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  86118. var previousOne = previousSubmeshes[submeshIndex];
  86119. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  86120. }
  86121. this.synchronizeInstances();
  86122. return this;
  86123. };
  86124. /**
  86125. * This method removes all the mesh indices and add new vertices (duplication) in order to unfold facets into buffers.
  86126. * In other words, more vertices, no more indices and a single bigger VBO.
  86127. * The mesh is really modified even if not set originally as updatable. Under the hood, a new VertexBuffer is allocated.
  86128. * @returns current mesh
  86129. */
  86130. Mesh.prototype.convertToUnIndexedMesh = function () {
  86131. var kinds = this.getVerticesDataKinds();
  86132. var vbs = {};
  86133. var data = {};
  86134. var newdata = {};
  86135. var kindIndex;
  86136. var kind;
  86137. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86138. kind = kinds[kindIndex];
  86139. var vertexBuffer = this.getVertexBuffer(kind);
  86140. vbs[kind] = vertexBuffer;
  86141. data[kind] = vbs[kind].getData();
  86142. newdata[kind] = [];
  86143. }
  86144. // Save previous submeshes
  86145. var previousSubmeshes = this.subMeshes.slice(0);
  86146. var indices = this.getIndices();
  86147. var totalIndices = this.getTotalIndices();
  86148. // Generating unique vertices per face
  86149. var index;
  86150. for (index = 0; index < totalIndices; index++) {
  86151. var vertexIndex = indices[index];
  86152. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86153. kind = kinds[kindIndex];
  86154. var stride = vbs[kind].getStrideSize();
  86155. for (var offset = 0; offset < stride; offset++) {
  86156. newdata[kind].push(data[kind][vertexIndex * stride + offset]);
  86157. }
  86158. }
  86159. }
  86160. // Updating indices
  86161. for (index = 0; index < totalIndices; index += 3) {
  86162. indices[index] = index;
  86163. indices[index + 1] = index + 1;
  86164. indices[index + 2] = index + 2;
  86165. }
  86166. this.setIndices(indices);
  86167. // Updating vertex buffers
  86168. for (kindIndex = 0; kindIndex < kinds.length; kindIndex++) {
  86169. kind = kinds[kindIndex];
  86170. this.setVerticesData(kind, newdata[kind], vbs[kind].isUpdatable());
  86171. }
  86172. // Updating submeshes
  86173. this.releaseSubMeshes();
  86174. for (var submeshIndex = 0; submeshIndex < previousSubmeshes.length; submeshIndex++) {
  86175. var previousOne = previousSubmeshes[submeshIndex];
  86176. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].AddToMesh(previousOne.materialIndex, previousOne.indexStart, previousOne.indexCount, previousOne.indexStart, previousOne.indexCount, this);
  86177. }
  86178. this._unIndexed = true;
  86179. this.synchronizeInstances();
  86180. return this;
  86181. };
  86182. /**
  86183. * Inverses facet orientations.
  86184. * Warning : the mesh is really modified even if not set originally as updatable. A new VertexBuffer is created under the hood each call.
  86185. * @param flipNormals will also inverts the normals
  86186. * @returns current mesh
  86187. */
  86188. Mesh.prototype.flipFaces = function (flipNormals) {
  86189. if (flipNormals === void 0) { flipNormals = false; }
  86190. var vertex_data = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(this);
  86191. var i;
  86192. if (flipNormals && this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind) && vertex_data.normals) {
  86193. for (i = 0; i < vertex_data.normals.length; i++) {
  86194. vertex_data.normals[i] *= -1;
  86195. }
  86196. }
  86197. if (vertex_data.indices) {
  86198. var temp;
  86199. for (i = 0; i < vertex_data.indices.length; i += 3) {
  86200. // reassign indices
  86201. temp = vertex_data.indices[i + 1];
  86202. vertex_data.indices[i + 1] = vertex_data.indices[i + 2];
  86203. vertex_data.indices[i + 2] = temp;
  86204. }
  86205. }
  86206. vertex_data.applyToMesh(this);
  86207. return this;
  86208. };
  86209. // Instances
  86210. /** @hidden */
  86211. Mesh._instancedMeshFactory = function (name, mesh) {
  86212. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("InstancedMesh");
  86213. };
  86214. /** @hidden */
  86215. Mesh._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  86216. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("PhysicsImpostor");
  86217. };
  86218. /**
  86219. * Creates a new InstancedMesh object from the mesh model.
  86220. * @see http://doc.babylonjs.com/how_to/how_to_use_instances
  86221. * @param name defines the name of the new instance
  86222. * @returns a new InstancedMesh
  86223. */
  86224. Mesh.prototype.createInstance = function (name) {
  86225. return Mesh._instancedMeshFactory(name, this);
  86226. };
  86227. /**
  86228. * Synchronises all the mesh instance submeshes to the current mesh submeshes, if any.
  86229. * After this call, all the mesh instances have the same submeshes than the current mesh.
  86230. * @returns the current mesh
  86231. */
  86232. Mesh.prototype.synchronizeInstances = function () {
  86233. for (var instanceIndex = 0; instanceIndex < this.instances.length; instanceIndex++) {
  86234. var instance = this.instances[instanceIndex];
  86235. instance._syncSubMeshes();
  86236. }
  86237. return this;
  86238. };
  86239. /**
  86240. * Optimization of the mesh's indices, in case a mesh has duplicated vertices.
  86241. * The function will only reorder the indices and will not remove unused vertices to avoid problems with submeshes.
  86242. * This should be used together with the simplification to avoid disappearing triangles.
  86243. * @param successCallback an optional success callback to be called after the optimization finished.
  86244. * @returns the current mesh
  86245. */
  86246. Mesh.prototype.optimizeIndices = function (successCallback) {
  86247. var _this = this;
  86248. var indices = this.getIndices();
  86249. var positions = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  86250. if (!positions || !indices) {
  86251. return this;
  86252. }
  86253. var vectorPositions = new Array();
  86254. for (var pos = 0; pos < positions.length; pos = pos + 3) {
  86255. vectorPositions.push(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(positions, pos));
  86256. }
  86257. var dupes = new Array();
  86258. _Misc_tools__WEBPACK_IMPORTED_MODULE_2__["AsyncLoop"].SyncAsyncForLoop(vectorPositions.length, 40, function (iteration) {
  86259. var realPos = vectorPositions.length - 1 - iteration;
  86260. var testedPosition = vectorPositions[realPos];
  86261. for (var j = 0; j < realPos; ++j) {
  86262. var againstPosition = vectorPositions[j];
  86263. if (testedPosition.equals(againstPosition)) {
  86264. dupes[realPos] = j;
  86265. break;
  86266. }
  86267. }
  86268. }, function () {
  86269. for (var i = 0; i < indices.length; ++i) {
  86270. indices[i] = dupes[indices[i]] || indices[i];
  86271. }
  86272. //indices are now reordered
  86273. var originalSubMeshes = _this.subMeshes.slice(0);
  86274. _this.setIndices(indices);
  86275. _this.subMeshes = originalSubMeshes;
  86276. if (successCallback) {
  86277. successCallback(_this);
  86278. }
  86279. });
  86280. return this;
  86281. };
  86282. /**
  86283. * Serialize current mesh
  86284. * @param serializationObject defines the object which will receive the serialization data
  86285. */
  86286. Mesh.prototype.serialize = function (serializationObject) {
  86287. serializationObject.name = this.name;
  86288. serializationObject.id = this.id;
  86289. serializationObject.type = this.getClassName();
  86290. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].HasTags(this)) {
  86291. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].GetTags(this);
  86292. }
  86293. serializationObject.position = this.position.asArray();
  86294. if (this.rotationQuaternion) {
  86295. serializationObject.rotationQuaternion = this.rotationQuaternion.asArray();
  86296. }
  86297. else if (this.rotation) {
  86298. serializationObject.rotation = this.rotation.asArray();
  86299. }
  86300. serializationObject.scaling = this.scaling.asArray();
  86301. if (this._postMultiplyPivotMatrix) {
  86302. serializationObject.pivotMatrix = this.getPivotMatrix().asArray();
  86303. }
  86304. else {
  86305. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  86306. }
  86307. serializationObject.isEnabled = this.isEnabled(false);
  86308. serializationObject.isVisible = this.isVisible;
  86309. serializationObject.infiniteDistance = this.infiniteDistance;
  86310. serializationObject.pickable = this.isPickable;
  86311. serializationObject.receiveShadows = this.receiveShadows;
  86312. serializationObject.billboardMode = this.billboardMode;
  86313. serializationObject.visibility = this.visibility;
  86314. serializationObject.checkCollisions = this.checkCollisions;
  86315. serializationObject.isBlocker = this.isBlocker;
  86316. // Parent
  86317. if (this.parent) {
  86318. serializationObject.parentId = this.parent.id;
  86319. }
  86320. // Geometry
  86321. serializationObject.isUnIndexed = this.isUnIndexed;
  86322. var geometry = this._geometry;
  86323. if (geometry) {
  86324. var geometryId = geometry.id;
  86325. serializationObject.geometryId = geometryId;
  86326. // SubMeshes
  86327. serializationObject.subMeshes = [];
  86328. for (var subIndex = 0; subIndex < this.subMeshes.length; subIndex++) {
  86329. var subMesh = this.subMeshes[subIndex];
  86330. serializationObject.subMeshes.push({
  86331. materialIndex: subMesh.materialIndex,
  86332. verticesStart: subMesh.verticesStart,
  86333. verticesCount: subMesh.verticesCount,
  86334. indexStart: subMesh.indexStart,
  86335. indexCount: subMesh.indexCount
  86336. });
  86337. }
  86338. }
  86339. // Material
  86340. if (this.material) {
  86341. serializationObject.materialId = this.material.id;
  86342. }
  86343. else {
  86344. this.material = null;
  86345. }
  86346. // Morph targets
  86347. if (this.morphTargetManager) {
  86348. serializationObject.morphTargetManagerId = this.morphTargetManager.uniqueId;
  86349. }
  86350. // Skeleton
  86351. if (this.skeleton) {
  86352. serializationObject.skeletonId = this.skeleton.id;
  86353. }
  86354. // Physics
  86355. //TODO implement correct serialization for physics impostors.
  86356. var impostor = this.getPhysicsImpostor();
  86357. if (impostor) {
  86358. serializationObject.physicsMass = impostor.getParam("mass");
  86359. serializationObject.physicsFriction = impostor.getParam("friction");
  86360. serializationObject.physicsRestitution = impostor.getParam("mass");
  86361. serializationObject.physicsImpostor = impostor.type;
  86362. }
  86363. // Metadata
  86364. if (this.metadata) {
  86365. serializationObject.metadata = this.metadata;
  86366. }
  86367. // Instances
  86368. serializationObject.instances = [];
  86369. for (var index = 0; index < this.instances.length; index++) {
  86370. var instance = this.instances[index];
  86371. if (instance.doNotSerialize) {
  86372. continue;
  86373. }
  86374. var serializationInstance = {
  86375. name: instance.name,
  86376. id: instance.id,
  86377. position: instance.position.asArray(),
  86378. scaling: instance.scaling.asArray()
  86379. };
  86380. if (instance.parent) {
  86381. serializationInstance.parentId = instance.parent.id;
  86382. }
  86383. if (instance.rotationQuaternion) {
  86384. serializationInstance.rotationQuaternion = instance.rotationQuaternion.asArray();
  86385. }
  86386. else if (instance.rotation) {
  86387. serializationInstance.rotation = instance.rotation.asArray();
  86388. }
  86389. serializationObject.instances.push(serializationInstance);
  86390. // Animations
  86391. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(instance, serializationInstance);
  86392. serializationInstance.ranges = instance.serializeAnimationRanges();
  86393. }
  86394. //
  86395. // Animations
  86396. _Misc_decorators__WEBPACK_IMPORTED_MODULE_17__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  86397. serializationObject.ranges = this.serializeAnimationRanges();
  86398. // Layer mask
  86399. serializationObject.layerMask = this.layerMask;
  86400. // Alpha
  86401. serializationObject.alphaIndex = this.alphaIndex;
  86402. serializationObject.hasVertexAlpha = this.hasVertexAlpha;
  86403. // Overlay
  86404. serializationObject.overlayAlpha = this.overlayAlpha;
  86405. serializationObject.overlayColor = this.overlayColor.asArray();
  86406. serializationObject.renderOverlay = this.renderOverlay;
  86407. // Fog
  86408. serializationObject.applyFog = this.applyFog;
  86409. // Action Manager
  86410. if (this.actionManager) {
  86411. serializationObject.actions = this.actionManager.serialize(this.name);
  86412. }
  86413. };
  86414. /** @hidden */
  86415. Mesh.prototype._syncGeometryWithMorphTargetManager = function () {
  86416. if (!this.geometry) {
  86417. return;
  86418. }
  86419. this._markSubMeshesAsAttributesDirty();
  86420. var morphTargetManager = this._morphTargetManager;
  86421. if (morphTargetManager && morphTargetManager.vertexCount) {
  86422. if (morphTargetManager.vertexCount !== this.getTotalVertices()) {
  86423. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Mesh is incompatible with morph targets. Targets and mesh must all have the same vertices count.");
  86424. this.morphTargetManager = null;
  86425. return;
  86426. }
  86427. for (var index = 0; index < morphTargetManager.numInfluencers; index++) {
  86428. var morphTarget = morphTargetManager.getActiveTarget(index);
  86429. var positions = morphTarget.getPositions();
  86430. if (!positions) {
  86431. _Misc_logger__WEBPACK_IMPORTED_MODULE_18__["Logger"].Error("Invalid morph target. Target must have positions.");
  86432. return;
  86433. }
  86434. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index, positions, false, 3);
  86435. var normals = morphTarget.getNormals();
  86436. if (normals) {
  86437. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index, normals, false, 3);
  86438. }
  86439. var tangents = morphTarget.getTangents();
  86440. if (tangents) {
  86441. this.geometry.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index, tangents, false, 3);
  86442. }
  86443. }
  86444. }
  86445. else {
  86446. var index = 0;
  86447. // Positions
  86448. while (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index)) {
  86449. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind + index);
  86450. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index)) {
  86451. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind + index);
  86452. }
  86453. if (this.geometry.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index)) {
  86454. this.geometry.removeVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].TangentKind + index);
  86455. }
  86456. index++;
  86457. }
  86458. }
  86459. };
  86460. /**
  86461. * Returns a new Mesh object parsed from the source provided.
  86462. * @param parsedMesh is the source
  86463. * @param scene defines the hosting scene
  86464. * @param rootUrl is the root URL to prefix the `delayLoadingFile` property with
  86465. * @returns a new Mesh
  86466. */
  86467. Mesh.Parse = function (parsedMesh, scene, rootUrl) {
  86468. var mesh;
  86469. if (parsedMesh.type && parsedMesh.type === "GroundMesh") {
  86470. mesh = Mesh._GroundMeshParser(parsedMesh, scene);
  86471. }
  86472. else {
  86473. mesh = new Mesh(parsedMesh.name, scene);
  86474. }
  86475. mesh.id = parsedMesh.id;
  86476. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86477. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(mesh, parsedMesh.tags);
  86478. }
  86479. mesh.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.position);
  86480. if (parsedMesh.metadata !== undefined) {
  86481. mesh.metadata = parsedMesh.metadata;
  86482. }
  86483. if (parsedMesh.rotationQuaternion) {
  86484. mesh.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedMesh.rotationQuaternion);
  86485. }
  86486. else if (parsedMesh.rotation) {
  86487. mesh.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.rotation);
  86488. }
  86489. mesh.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedMesh.scaling);
  86490. if (parsedMesh.localMatrix) {
  86491. mesh.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.localMatrix));
  86492. }
  86493. else if (parsedMesh.pivotMatrix) {
  86494. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromArray(parsedMesh.pivotMatrix));
  86495. }
  86496. mesh.setEnabled(parsedMesh.isEnabled);
  86497. mesh.isVisible = parsedMesh.isVisible;
  86498. mesh.infiniteDistance = parsedMesh.infiniteDistance;
  86499. mesh.showBoundingBox = parsedMesh.showBoundingBox;
  86500. mesh.showSubMeshesBoundingBox = parsedMesh.showSubMeshesBoundingBox;
  86501. if (parsedMesh.applyFog !== undefined) {
  86502. mesh.applyFog = parsedMesh.applyFog;
  86503. }
  86504. if (parsedMesh.pickable !== undefined) {
  86505. mesh.isPickable = parsedMesh.pickable;
  86506. }
  86507. if (parsedMesh.alphaIndex !== undefined) {
  86508. mesh.alphaIndex = parsedMesh.alphaIndex;
  86509. }
  86510. mesh.receiveShadows = parsedMesh.receiveShadows;
  86511. mesh.billboardMode = parsedMesh.billboardMode;
  86512. if (parsedMesh.visibility !== undefined) {
  86513. mesh.visibility = parsedMesh.visibility;
  86514. }
  86515. mesh.checkCollisions = parsedMesh.checkCollisions;
  86516. if (parsedMesh.isBlocker !== undefined) {
  86517. mesh.isBlocker = parsedMesh.isBlocker;
  86518. }
  86519. mesh._shouldGenerateFlatShading = parsedMesh.useFlatShading;
  86520. // freezeWorldMatrix
  86521. if (parsedMesh.freezeWorldMatrix) {
  86522. mesh._waitingFreezeWorldMatrix = parsedMesh.freezeWorldMatrix;
  86523. }
  86524. // Parent
  86525. if (parsedMesh.parentId) {
  86526. mesh._waitingParentId = parsedMesh.parentId;
  86527. }
  86528. // Actions
  86529. if (parsedMesh.actions !== undefined) {
  86530. mesh._waitingActions = parsedMesh.actions;
  86531. }
  86532. // Overlay
  86533. if (parsedMesh.overlayAlpha !== undefined) {
  86534. mesh.overlayAlpha = parsedMesh.overlayAlpha;
  86535. }
  86536. if (parsedMesh.overlayColor !== undefined) {
  86537. mesh.overlayColor = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Color3"].FromArray(parsedMesh.overlayColor);
  86538. }
  86539. if (parsedMesh.renderOverlay !== undefined) {
  86540. mesh.renderOverlay = parsedMesh.renderOverlay;
  86541. }
  86542. // Geometry
  86543. mesh.isUnIndexed = !!parsedMesh.isUnIndexed;
  86544. mesh.hasVertexAlpha = parsedMesh.hasVertexAlpha;
  86545. if (parsedMesh.delayLoadingFile) {
  86546. mesh.delayLoadState = _Engines_constants__WEBPACK_IMPORTED_MODULE_16__["Constants"].DELAYLOADSTATE_NOTLOADED;
  86547. mesh.delayLoadingFile = rootUrl + parsedMesh.delayLoadingFile;
  86548. 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));
  86549. if (parsedMesh._binaryInfo) {
  86550. mesh._binaryInfo = parsedMesh._binaryInfo;
  86551. }
  86552. mesh._delayInfo = [];
  86553. if (parsedMesh.hasUVs) {
  86554. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UVKind);
  86555. }
  86556. if (parsedMesh.hasUVs2) {
  86557. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV2Kind);
  86558. }
  86559. if (parsedMesh.hasUVs3) {
  86560. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV3Kind);
  86561. }
  86562. if (parsedMesh.hasUVs4) {
  86563. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV4Kind);
  86564. }
  86565. if (parsedMesh.hasUVs5) {
  86566. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV5Kind);
  86567. }
  86568. if (parsedMesh.hasUVs6) {
  86569. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].UV6Kind);
  86570. }
  86571. if (parsedMesh.hasColors) {
  86572. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].ColorKind);
  86573. }
  86574. if (parsedMesh.hasMatricesIndices) {
  86575. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  86576. }
  86577. if (parsedMesh.hasMatricesWeights) {
  86578. mesh._delayInfo.push(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  86579. }
  86580. mesh._delayLoadingFunction = _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry;
  86581. if (_Loading_sceneLoaderFlags__WEBPACK_IMPORTED_MODULE_15__["SceneLoaderFlags"].ForceFullSceneLoadingForIncremental) {
  86582. mesh._checkDelayState();
  86583. }
  86584. }
  86585. else {
  86586. _geometry__WEBPACK_IMPORTED_MODULE_9__["Geometry"]._ImportGeometry(parsedMesh, mesh);
  86587. }
  86588. // Material
  86589. if (parsedMesh.materialId) {
  86590. mesh.setMaterialByID(parsedMesh.materialId);
  86591. }
  86592. else {
  86593. mesh.material = null;
  86594. }
  86595. // Morph targets
  86596. if (parsedMesh.morphTargetManagerId > -1) {
  86597. mesh.morphTargetManager = scene.getMorphTargetManagerById(parsedMesh.morphTargetManagerId);
  86598. }
  86599. // Skeleton
  86600. if (parsedMesh.skeletonId > -1) {
  86601. mesh.skeleton = scene.getLastSkeletonByID(parsedMesh.skeletonId);
  86602. if (parsedMesh.numBoneInfluencers) {
  86603. mesh.numBoneInfluencers = parsedMesh.numBoneInfluencers;
  86604. }
  86605. }
  86606. // Animations
  86607. if (parsedMesh.animations) {
  86608. for (var animationIndex = 0; animationIndex < parsedMesh.animations.length; animationIndex++) {
  86609. var parsedAnimation = parsedMesh.animations[animationIndex];
  86610. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86611. if (internalClass) {
  86612. mesh.animations.push(internalClass.Parse(parsedAnimation));
  86613. }
  86614. }
  86615. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(mesh, parsedMesh, scene);
  86616. }
  86617. if (parsedMesh.autoAnimate) {
  86618. scene.beginAnimation(mesh, parsedMesh.autoAnimateFrom, parsedMesh.autoAnimateTo, parsedMesh.autoAnimateLoop, parsedMesh.autoAnimateSpeed || 1.0);
  86619. }
  86620. // Layer Mask
  86621. if (parsedMesh.layerMask && (!isNaN(parsedMesh.layerMask))) {
  86622. mesh.layerMask = Math.abs(parseInt(parsedMesh.layerMask));
  86623. }
  86624. else {
  86625. mesh.layerMask = 0x0FFFFFFF;
  86626. }
  86627. // Physics
  86628. if (parsedMesh.physicsImpostor) {
  86629. Mesh._PhysicsImpostorParser(scene, mesh, parsedMesh);
  86630. }
  86631. // Instances
  86632. if (parsedMesh.instances) {
  86633. for (var index = 0; index < parsedMesh.instances.length; index++) {
  86634. var parsedInstance = parsedMesh.instances[index];
  86635. var instance = mesh.createInstance(parsedInstance.name);
  86636. if (parsedInstance.id) {
  86637. instance.id = parsedInstance.id;
  86638. }
  86639. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"]) {
  86640. if (parsedInstance.tags) {
  86641. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedInstance.tags);
  86642. }
  86643. else {
  86644. _Misc_tags__WEBPACK_IMPORTED_MODULE_4__["Tags"].AddTagsTo(instance, parsedMesh.tags);
  86645. }
  86646. }
  86647. instance.position = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.position);
  86648. if (parsedInstance.parentId) {
  86649. instance._waitingParentId = parsedInstance.parentId;
  86650. }
  86651. if (parsedInstance.rotationQuaternion) {
  86652. instance.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Quaternion"].FromArray(parsedInstance.rotationQuaternion);
  86653. }
  86654. else if (parsedInstance.rotation) {
  86655. instance.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.rotation);
  86656. }
  86657. instance.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].FromArray(parsedInstance.scaling);
  86658. if (parsedInstance.checkCollisions != undefined && parsedInstance.checkCollisions != null) {
  86659. instance.checkCollisions = parsedInstance.checkCollisions;
  86660. }
  86661. if (parsedInstance.pickable != undefined && parsedInstance.pickable != null) {
  86662. instance.isPickable = parsedInstance.pickable;
  86663. }
  86664. if (parsedInstance.showBoundingBox != undefined && parsedInstance.showBoundingBox != null) {
  86665. instance.showBoundingBox = parsedInstance.showBoundingBox;
  86666. }
  86667. if (parsedInstance.showSubMeshesBoundingBox != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86668. instance.showSubMeshesBoundingBox = parsedInstance.showSubMeshesBoundingBox;
  86669. }
  86670. if (parsedInstance.alphaIndex != undefined && parsedInstance.showSubMeshesBoundingBox != null) {
  86671. instance.alphaIndex = parsedInstance.alphaIndex;
  86672. }
  86673. // Physics
  86674. if (parsedInstance.physicsImpostor) {
  86675. Mesh._PhysicsImpostorParser(scene, instance, parsedInstance);
  86676. }
  86677. // Animation
  86678. if (parsedInstance.animations) {
  86679. for (animationIndex = 0; animationIndex < parsedInstance.animations.length; animationIndex++) {
  86680. parsedAnimation = parsedInstance.animations[animationIndex];
  86681. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_19__["_TypeStore"].GetClass("BABYLON.Animation");
  86682. if (internalClass) {
  86683. instance.animations.push(internalClass.Parse(parsedAnimation));
  86684. }
  86685. }
  86686. _node__WEBPACK_IMPORTED_MODULE_6__["Node"].ParseAnimationRanges(instance, parsedInstance, scene);
  86687. if (parsedInstance.autoAnimate) {
  86688. scene.beginAnimation(instance, parsedInstance.autoAnimateFrom, parsedInstance.autoAnimateTo, parsedInstance.autoAnimateLoop, parsedInstance.autoAnimateSpeed || 1.0);
  86689. }
  86690. }
  86691. }
  86692. }
  86693. return mesh;
  86694. };
  86695. /**
  86696. * Creates a ribbon mesh. Please consider using the same method from the MeshBuilder class instead
  86697. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86698. * @param name defines the name of the mesh to create
  86699. * @param pathArray is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry.
  86700. * @param closeArray creates a seam between the first and the last paths of the path array (default is false)
  86701. * @param closePath creates a seam between the first and the last points of each path of the path array
  86702. * @param offset is taken in account only if the `pathArray` is containing a single path
  86703. * @param scene defines the hosting scene
  86704. * @param updatable defines if the mesh must be flagged as updatable
  86705. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86706. * @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)
  86707. * @returns a new Mesh
  86708. */
  86709. Mesh.CreateRibbon = function (name, pathArray, closeArray, closePath, offset, scene, updatable, sideOrientation, instance) {
  86710. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86711. };
  86712. /**
  86713. * Creates a plane polygonal mesh. By default, this is a disc. Please consider using the same method from the MeshBuilder class instead
  86714. * @param name defines the name of the mesh to create
  86715. * @param radius sets the radius size (float) of the polygon (default 0.5)
  86716. * @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
  86717. * @param scene defines the hosting scene
  86718. * @param updatable defines if the mesh must be flagged as updatable
  86719. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86720. * @returns a new Mesh
  86721. */
  86722. Mesh.CreateDisc = function (name, radius, tessellation, scene, updatable, sideOrientation) {
  86723. if (scene === void 0) { scene = null; }
  86724. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86725. };
  86726. /**
  86727. * Creates a box mesh. Please consider using the same method from the MeshBuilder class instead
  86728. * @param name defines the name of the mesh to create
  86729. * @param size sets the size (float) of each box side (default 1)
  86730. * @param scene defines the hosting scene
  86731. * @param updatable defines if the mesh must be flagged as updatable
  86732. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86733. * @returns a new Mesh
  86734. */
  86735. Mesh.CreateBox = function (name, size, scene, updatable, sideOrientation) {
  86736. if (scene === void 0) { scene = null; }
  86737. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86738. };
  86739. /**
  86740. * Creates a sphere mesh. Please consider using the same method from the MeshBuilder class instead
  86741. * @param name defines the name of the mesh to create
  86742. * @param segments sets the sphere number of horizontal stripes (positive integer, default 32)
  86743. * @param diameter sets the diameter size (float) of the sphere (default 1)
  86744. * @param scene defines the hosting scene
  86745. * @param updatable defines if the mesh must be flagged as updatable
  86746. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86747. * @returns a new Mesh
  86748. */
  86749. Mesh.CreateSphere = function (name, segments, diameter, scene, updatable, sideOrientation) {
  86750. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86751. };
  86752. /**
  86753. * Creates a cylinder or a cone mesh. Please consider using the same method from the MeshBuilder class instead
  86754. * @param name defines the name of the mesh to create
  86755. * @param height sets the height size (float) of the cylinder/cone (float, default 2)
  86756. * @param diameterTop set the top cap diameter (floats, default 1)
  86757. * @param diameterBottom set the bottom cap diameter (floats, default 1). This value can't be zero
  86758. * @param tessellation sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance
  86759. * @param subdivisions sets the number of rings along the cylinder height (positive integer, default 1)
  86760. * @param scene defines the hosting scene
  86761. * @param updatable defines if the mesh must be flagged as updatable
  86762. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86763. * @returns a new Mesh
  86764. */
  86765. Mesh.CreateCylinder = function (name, height, diameterTop, diameterBottom, tessellation, subdivisions, scene, updatable, sideOrientation) {
  86766. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86767. };
  86768. // Torus (Code from SharpDX.org)
  86769. /**
  86770. * Creates a torus mesh. Please consider using the same method from the MeshBuilder class instead
  86771. * @param name defines the name of the mesh to create
  86772. * @param diameter sets the diameter size (float) of the torus (default 1)
  86773. * @param thickness sets the diameter size of the tube of the torus (float, default 0.5)
  86774. * @param tessellation sets the number of torus sides (postive integer, default 16)
  86775. * @param scene defines the hosting scene
  86776. * @param updatable defines if the mesh must be flagged as updatable
  86777. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86778. * @returns a new Mesh
  86779. */
  86780. Mesh.CreateTorus = function (name, diameter, thickness, tessellation, scene, updatable, sideOrientation) {
  86781. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86782. };
  86783. /**
  86784. * Creates a torus knot mesh. Please consider using the same method from the MeshBuilder class instead
  86785. * @param name defines the name of the mesh to create
  86786. * @param radius sets the global radius size (float) of the torus knot (default 2)
  86787. * @param tube sets the diameter size of the tube of the torus (float, default 0.5)
  86788. * @param radialSegments sets the number of sides on each tube segments (positive integer, default 32)
  86789. * @param tubularSegments sets the number of tubes to decompose the knot into (positive integer, default 32)
  86790. * @param p the number of windings on X axis (positive integers, default 2)
  86791. * @param q the number of windings on Y axis (positive integers, default 3)
  86792. * @param scene defines the hosting scene
  86793. * @param updatable defines if the mesh must be flagged as updatable
  86794. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86795. * @returns a new Mesh
  86796. */
  86797. Mesh.CreateTorusKnot = function (name, radius, tube, radialSegments, tubularSegments, p, q, scene, updatable, sideOrientation) {
  86798. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86799. };
  86800. /**
  86801. * Creates a line mesh. Please consider using the same method from the MeshBuilder class instead.
  86802. * @param name defines the name of the mesh to create
  86803. * @param points is an array successive Vector3
  86804. * @param scene defines the hosting scene
  86805. * @param updatable defines if the mesh must be flagged as updatable
  86806. * @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).
  86807. * @returns a new Mesh
  86808. */
  86809. Mesh.CreateLines = function (name, points, scene, updatable, instance) {
  86810. if (scene === void 0) { scene = null; }
  86811. if (updatable === void 0) { updatable = false; }
  86812. if (instance === void 0) { instance = null; }
  86813. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86814. };
  86815. /**
  86816. * Creates a dashed line mesh. Please consider using the same method from the MeshBuilder class instead
  86817. * @param name defines the name of the mesh to create
  86818. * @param points is an array successive Vector3
  86819. * @param dashSize is the size of the dashes relatively the dash number (positive float, default 3)
  86820. * @param gapSize is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  86821. * @param dashNb is the intended total number of dashes (positive integer, default 200)
  86822. * @param scene defines the hosting scene
  86823. * @param updatable defines if the mesh must be flagged as updatable
  86824. * @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)
  86825. * @returns a new Mesh
  86826. */
  86827. Mesh.CreateDashedLines = function (name, points, dashSize, gapSize, dashNb, scene, updatable, instance) {
  86828. if (scene === void 0) { scene = null; }
  86829. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86830. };
  86831. /**
  86832. * Creates a polygon mesh.Please consider using the same method from the MeshBuilder class instead
  86833. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh.
  86834. * 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.
  86835. * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  86836. * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  86837. * Remember you can only change the shape positions, not their number when updating a polygon.
  86838. * @see http://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  86839. * @param name defines the name of the mesh to create
  86840. * @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
  86841. * @param scene defines the hosting scene
  86842. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86843. * @param updatable defines if the mesh must be flagged as updatable
  86844. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86845. * @param earcutInjection can be used to inject your own earcut reference
  86846. * @returns a new Mesh
  86847. */
  86848. Mesh.CreatePolygon = function (name, shape, scene, holes, updatable, sideOrientation, earcutInjection) {
  86849. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86850. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86851. };
  86852. /**
  86853. * Creates an extruded polygon mesh, with depth in the Y direction. Please consider using the same method from the MeshBuilder class instead.
  86854. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-non-regular-polygon
  86855. * @param name defines the name of the mesh to create
  86856. * @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
  86857. * @param depth defines the height of extrusion
  86858. * @param scene defines the hosting scene
  86859. * @param holes is a required array of arrays of successive Vector3 used to defines holes in the polygon
  86860. * @param updatable defines if the mesh must be flagged as updatable
  86861. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86862. * @param earcutInjection can be used to inject your own earcut reference
  86863. * @returns a new Mesh
  86864. */
  86865. Mesh.ExtrudePolygon = function (name, shape, depth, scene, holes, updatable, sideOrientation, earcutInjection) {
  86866. if (earcutInjection === void 0) { earcutInjection = earcut; }
  86867. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86868. };
  86869. /**
  86870. * Creates an extruded shape mesh.
  86871. * 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
  86872. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86873. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86874. * @param name defines the name of the mesh to create
  86875. * @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
  86876. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86877. * @param scale is the value to scale the shape
  86878. * @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
  86879. * @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
  86880. * @param scene defines the hosting scene
  86881. * @param updatable defines if the mesh must be flagged as updatable
  86882. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86883. * @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)
  86884. * @returns a new Mesh
  86885. */
  86886. Mesh.ExtrudeShape = function (name, shape, path, scale, rotation, cap, scene, updatable, sideOrientation, instance) {
  86887. if (scene === void 0) { scene = null; }
  86888. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86889. };
  86890. /**
  86891. * Creates an custom extruded shape mesh.
  86892. * The custom extrusion is a parametric shape.
  86893. * It has no predefined shape. Its final shape will depend on the input parameters.
  86894. * Please consider using the same method from the MeshBuilder class instead
  86895. * @see http://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  86896. * @param name defines the name of the mesh to create
  86897. * @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
  86898. * @param path is a required array of successive Vector3. This is the axis curve the shape is extruded along
  86899. * @param scaleFunction is a custom Javascript function called on each path point
  86900. * @param rotationFunction is a custom Javascript function called on each path point
  86901. * @param ribbonCloseArray forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  86902. * @param ribbonClosePath forces the extrusion underlying ribbon to close its `pathArray`
  86903. * @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
  86904. * @param scene defines the hosting scene
  86905. * @param updatable defines if the mesh must be flagged as updatable
  86906. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86907. * @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)
  86908. * @returns a new Mesh
  86909. */
  86910. Mesh.ExtrudeShapeCustom = function (name, shape, path, scaleFunction, rotationFunction, ribbonCloseArray, ribbonClosePath, cap, scene, updatable, sideOrientation, instance) {
  86911. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86912. };
  86913. /**
  86914. * Creates lathe mesh.
  86915. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe.
  86916. * Please consider using the same method from the MeshBuilder class instead
  86917. * @param name defines the name of the mesh to create
  86918. * @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
  86919. * @param radius is the radius value of the lathe
  86920. * @param tessellation is the side number of the lathe.
  86921. * @param scene defines the hosting scene
  86922. * @param updatable defines if the mesh must be flagged as updatable
  86923. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86924. * @returns a new Mesh
  86925. */
  86926. Mesh.CreateLathe = function (name, shape, radius, tessellation, scene, updatable, sideOrientation) {
  86927. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86928. };
  86929. /**
  86930. * Creates a plane mesh. Please consider using the same method from the MeshBuilder class instead
  86931. * @param name defines the name of the mesh to create
  86932. * @param size sets the size (float) of both sides of the plane at once (default 1)
  86933. * @param scene defines the hosting scene
  86934. * @param updatable defines if the mesh must be flagged as updatable
  86935. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  86936. * @returns a new Mesh
  86937. */
  86938. Mesh.CreatePlane = function (name, size, scene, updatable, sideOrientation) {
  86939. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86940. };
  86941. /**
  86942. * Creates a ground mesh.
  86943. * Please consider using the same method from the MeshBuilder class instead
  86944. * @param name defines the name of the mesh to create
  86945. * @param width set the width of the ground
  86946. * @param height set the height of the ground
  86947. * @param subdivisions sets the number of subdivisions per side
  86948. * @param scene defines the hosting scene
  86949. * @param updatable defines if the mesh must be flagged as updatable
  86950. * @returns a new Mesh
  86951. */
  86952. Mesh.CreateGround = function (name, width, height, subdivisions, scene, updatable) {
  86953. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86954. };
  86955. /**
  86956. * Creates a tiled ground mesh.
  86957. * Please consider using the same method from the MeshBuilder class instead
  86958. * @param name defines the name of the mesh to create
  86959. * @param xmin set the ground minimum X coordinate
  86960. * @param zmin set the ground minimum Y coordinate
  86961. * @param xmax set the ground maximum X coordinate
  86962. * @param zmax set the ground maximum Z coordinate
  86963. * @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
  86964. * @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
  86965. * @param scene defines the hosting scene
  86966. * @param updatable defines if the mesh must be flagged as updatable
  86967. * @returns a new Mesh
  86968. */
  86969. Mesh.CreateTiledGround = function (name, xmin, zmin, xmax, zmax, subdivisions, precision, scene, updatable) {
  86970. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86971. };
  86972. /**
  86973. * Creates a ground mesh from a height map.
  86974. * Please consider using the same method from the MeshBuilder class instead
  86975. * @see http://doc.babylonjs.com/babylon101/height_map
  86976. * @param name defines the name of the mesh to create
  86977. * @param url sets the URL of the height map image resource
  86978. * @param width set the ground width size
  86979. * @param height set the ground height size
  86980. * @param subdivisions sets the number of subdivision per side
  86981. * @param minHeight is the minimum altitude on the ground
  86982. * @param maxHeight is the maximum altitude on the ground
  86983. * @param scene defines the hosting scene
  86984. * @param updatable defines if the mesh must be flagged as updatable
  86985. * @param onReady is a callback function that will be called once the mesh is built (the height map download can last some time)
  86986. * @param alphaFilter will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  86987. * @returns a new Mesh
  86988. */
  86989. Mesh.CreateGroundFromHeightMap = function (name, url, width, height, subdivisions, minHeight, maxHeight, scene, updatable, onReady, alphaFilter) {
  86990. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  86991. };
  86992. /**
  86993. * Creates a tube mesh.
  86994. * The tube is a parametric shape.
  86995. * It has no predefined shape. Its final shape will depend on the input parameters.
  86996. * Please consider using the same method from the MeshBuilder class instead
  86997. * @see http://doc.babylonjs.com/how_to/parametric_shapes
  86998. * @param name defines the name of the mesh to create
  86999. * @param path is a required array of successive Vector3. It is the curve used as the axis of the tube
  87000. * @param radius sets the tube radius size
  87001. * @param tessellation is the number of sides on the tubular surface
  87002. * @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
  87003. * @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
  87004. * @param scene defines the hosting scene
  87005. * @param updatable defines if the mesh must be flagged as updatable
  87006. * @param sideOrientation defines the mesh side orientation (http://doc.babylonjs.com/babylon101/discover_basic_elements#side-orientation)
  87007. * @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)
  87008. * @returns a new Mesh
  87009. */
  87010. Mesh.CreateTube = function (name, path, radius, tessellation, radiusFunction, cap, scene, updatable, sideOrientation, instance) {
  87011. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87012. };
  87013. /**
  87014. * Creates a polyhedron mesh.
  87015. * Please consider using the same method from the MeshBuilder class instead.
  87016. * * 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
  87017. * * The parameter `size` (positive float, default 1) sets the polygon size
  87018. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  87019. * * 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`
  87020. * * 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
  87021. * * 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)`)
  87022. * * 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
  87023. * * 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
  87024. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87025. * * 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
  87026. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87027. * @param name defines the name of the mesh to create
  87028. * @param options defines the options used to create the mesh
  87029. * @param scene defines the hosting scene
  87030. * @returns a new Mesh
  87031. */
  87032. Mesh.CreatePolyhedron = function (name, options, scene) {
  87033. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87034. };
  87035. /**
  87036. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  87037. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  87038. * * 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`)
  87039. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  87040. * * 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
  87041. * * You can also set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87042. * * 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
  87043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  87044. * @param name defines the name of the mesh
  87045. * @param options defines the options used to create the mesh
  87046. * @param scene defines the hosting scene
  87047. * @returns a new Mesh
  87048. * @see http://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  87049. */
  87050. Mesh.CreateIcoSphere = function (name, options, scene) {
  87051. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87052. };
  87053. /**
  87054. * Creates a decal mesh.
  87055. * Please consider using the same method from the MeshBuilder class instead.
  87056. * A decal is a mesh usually applied as a model onto the surface of another mesh
  87057. * @param name defines the name of the mesh
  87058. * @param sourceMesh defines the mesh receiving the decal
  87059. * @param position sets the position of the decal in world coordinates
  87060. * @param normal sets the normal of the mesh where the decal is applied onto in world coordinates
  87061. * @param size sets the decal scaling
  87062. * @param angle sets the angle to rotate the decal
  87063. * @returns a new Mesh
  87064. */
  87065. Mesh.CreateDecal = function (name, sourceMesh, position, normal, size, angle) {
  87066. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("MeshBuilder");
  87067. };
  87068. // Skeletons
  87069. /**
  87070. * Prepare internal position array for software CPU skinning
  87071. * @returns original positions used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh
  87072. */
  87073. Mesh.prototype.setPositionsForCPUSkinning = function () {
  87074. if (!this._sourcePositions) {
  87075. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87076. if (!source) {
  87077. return this._sourcePositions;
  87078. }
  87079. this._sourcePositions = new Float32Array(source);
  87080. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87081. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, source, true);
  87082. }
  87083. }
  87084. return this._sourcePositions;
  87085. };
  87086. /**
  87087. * Prepare internal normal array for software CPU skinning
  87088. * @returns original normals used for CPU skinning. Useful for integrating Morphing with skeletons in same mesh.
  87089. */
  87090. Mesh.prototype.setNormalsForCPUSkinning = function () {
  87091. if (!this._sourceNormals) {
  87092. var source = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87093. if (!source) {
  87094. return this._sourceNormals;
  87095. }
  87096. this._sourceNormals = new Float32Array(source);
  87097. if (!this.isVertexBufferUpdatable(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87098. this.setVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, source, true);
  87099. }
  87100. }
  87101. return this._sourceNormals;
  87102. };
  87103. /**
  87104. * Updates the vertex buffer by applying transformation from the bones
  87105. * @param skeleton defines the skeleton to apply to current mesh
  87106. * @returns the current mesh
  87107. */
  87108. Mesh.prototype.applySkeleton = function (skeleton) {
  87109. if (!this.geometry) {
  87110. return this;
  87111. }
  87112. if (this.geometry._softwareSkinningFrameId == this.getScene().getFrameId()) {
  87113. return this;
  87114. }
  87115. this.geometry._softwareSkinningFrameId = this.getScene().getFrameId();
  87116. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind)) {
  87117. return this;
  87118. }
  87119. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind)) {
  87120. return this;
  87121. }
  87122. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind)) {
  87123. return this;
  87124. }
  87125. if (!this.isVerticesDataPresent(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind)) {
  87126. return this;
  87127. }
  87128. if (!this._sourcePositions) {
  87129. var submeshes = this.subMeshes.slice();
  87130. this.setPositionsForCPUSkinning();
  87131. this.subMeshes = submeshes;
  87132. }
  87133. if (!this._sourceNormals) {
  87134. this.setNormalsForCPUSkinning();
  87135. }
  87136. // positionsData checks for not being Float32Array will only pass at most once
  87137. var positionsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind);
  87138. if (!positionsData) {
  87139. return this;
  87140. }
  87141. if (!(positionsData instanceof Float32Array)) {
  87142. positionsData = new Float32Array(positionsData);
  87143. }
  87144. // normalsData checks for not being Float32Array will only pass at most once
  87145. var normalsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind);
  87146. if (!normalsData) {
  87147. return this;
  87148. }
  87149. if (!(normalsData instanceof Float32Array)) {
  87150. normalsData = new Float32Array(normalsData);
  87151. }
  87152. var matricesIndicesData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesKind);
  87153. var matricesWeightsData = this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsKind);
  87154. if (!matricesWeightsData || !matricesIndicesData) {
  87155. return this;
  87156. }
  87157. var needExtras = this.numBoneInfluencers > 4;
  87158. var matricesIndicesExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesIndicesExtraKind) : null;
  87159. var matricesWeightsExtraData = needExtras ? this.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].MatricesWeightsExtraKind) : null;
  87160. var skeletonMatrices = skeleton.getTransformMatrices(this);
  87161. var tempVector3 = _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero();
  87162. var finalMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  87163. var tempMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"]();
  87164. var matWeightIdx = 0;
  87165. var inf;
  87166. for (var index = 0; index < positionsData.length; index += 3, matWeightIdx += 4) {
  87167. var weight;
  87168. for (inf = 0; inf < 4; inf++) {
  87169. weight = matricesWeightsData[matWeightIdx + inf];
  87170. if (weight > 0) {
  87171. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesData[matWeightIdx + inf] * 16), weight, tempMatrix);
  87172. finalMatrix.addToSelf(tempMatrix);
  87173. }
  87174. }
  87175. if (needExtras) {
  87176. for (inf = 0; inf < 4; inf++) {
  87177. weight = matricesWeightsExtraData[matWeightIdx + inf];
  87178. if (weight > 0) {
  87179. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Matrix"].FromFloat32ArrayToRefScaled(skeletonMatrices, Math.floor(matricesIndicesExtraData[matWeightIdx + inf] * 16), weight, tempMatrix);
  87180. finalMatrix.addToSelf(tempMatrix);
  87181. }
  87182. }
  87183. }
  87184. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformCoordinatesFromFloatsToRef(this._sourcePositions[index], this._sourcePositions[index + 1], this._sourcePositions[index + 2], finalMatrix, tempVector3);
  87185. tempVector3.toArray(positionsData, index);
  87186. _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].TransformNormalFromFloatsToRef(this._sourceNormals[index], this._sourceNormals[index + 1], this._sourceNormals[index + 2], finalMatrix, tempVector3);
  87187. tempVector3.toArray(normalsData, index);
  87188. finalMatrix.reset();
  87189. }
  87190. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].PositionKind, positionsData);
  87191. this.updateVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_7__["VertexBuffer"].NormalKind, normalsData);
  87192. return this;
  87193. };
  87194. // Tools
  87195. /**
  87196. * 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
  87197. * @param meshes defines the list of meshes to scan
  87198. * @returns an object `{min:` Vector3`, max:` Vector3`}`
  87199. */
  87200. Mesh.MinMax = function (meshes) {
  87201. var minVector = null;
  87202. var maxVector = null;
  87203. meshes.forEach(function (mesh) {
  87204. var boundingInfo = mesh.getBoundingInfo();
  87205. var boundingBox = boundingInfo.boundingBox;
  87206. if (!minVector || !maxVector) {
  87207. minVector = boundingBox.minimumWorld;
  87208. maxVector = boundingBox.maximumWorld;
  87209. }
  87210. else {
  87211. minVector.minimizeInPlace(boundingBox.minimumWorld);
  87212. maxVector.maximizeInPlace(boundingBox.maximumWorld);
  87213. }
  87214. });
  87215. if (!minVector || !maxVector) {
  87216. return {
  87217. min: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero(),
  87218. max: _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Zero()
  87219. };
  87220. }
  87221. return {
  87222. min: minVector,
  87223. max: maxVector
  87224. };
  87225. };
  87226. /**
  87227. * Returns the center of the `{min:` Vector3`, max:` Vector3`}` or the center of MinMax vector3 computed from a mesh array
  87228. * @param meshesOrMinMaxVector could be an array of meshes or a `{min:` Vector3`, max:` Vector3`}` object
  87229. * @returns a vector3
  87230. */
  87231. Mesh.Center = function (meshesOrMinMaxVector) {
  87232. var minMaxVector = (meshesOrMinMaxVector instanceof Array) ? Mesh.MinMax(meshesOrMinMaxVector) : meshesOrMinMaxVector;
  87233. return _Maths_math__WEBPACK_IMPORTED_MODULE_5__["Vector3"].Center(minMaxVector.min, minMaxVector.max);
  87234. };
  87235. /**
  87236. * Merge the array of meshes into a single mesh for performance reasons.
  87237. * @param meshes defines he vertices source. They should all be of the same material. Entries can empty
  87238. * @param disposeSource when true (default), dispose of the vertices from the source meshes
  87239. * @param allow32BitsIndices when the sum of the vertices > 64k, this must be set to true
  87240. * @param meshSubclass when set, vertices inserted into this Mesh. Meshes can then be merged into a Mesh sub-class.
  87241. * @param subdivideWithSubMeshes when true (false default), subdivide mesh to his subMesh array with meshes source.
  87242. * @param multiMultiMaterials when true (false default), subdivide mesh and accept multiple multi materials, ignores subdivideWithSubMeshes.
  87243. * @returns a new mesh
  87244. */
  87245. Mesh.MergeMeshes = function (meshes, disposeSource, allow32BitsIndices, meshSubclass, subdivideWithSubMeshes, multiMultiMaterials) {
  87246. if (disposeSource === void 0) { disposeSource = true; }
  87247. var index;
  87248. if (!allow32BitsIndices) {
  87249. var totalVertices = 0;
  87250. // Counting vertices
  87251. for (index = 0; index < meshes.length; index++) {
  87252. if (meshes[index]) {
  87253. totalVertices += meshes[index].getTotalVertices();
  87254. if (totalVertices > 65536) {
  87255. _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");
  87256. return null;
  87257. }
  87258. }
  87259. }
  87260. }
  87261. if (multiMultiMaterials) {
  87262. var newMultiMaterial = null;
  87263. var subIndex;
  87264. var matIndex;
  87265. subdivideWithSubMeshes = false;
  87266. }
  87267. var materialArray = new Array();
  87268. var materialIndexArray = new Array();
  87269. // Merge
  87270. var vertexData = null;
  87271. var otherVertexData;
  87272. var indiceArray = new Array();
  87273. var source = null;
  87274. for (index = 0; index < meshes.length; index++) {
  87275. if (meshes[index]) {
  87276. var mesh = meshes[index];
  87277. var wm = mesh.computeWorldMatrix(true);
  87278. otherVertexData = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].ExtractFromMesh(mesh, true, true);
  87279. otherVertexData.transform(wm);
  87280. if (vertexData) {
  87281. vertexData.merge(otherVertexData, allow32BitsIndices);
  87282. }
  87283. else {
  87284. vertexData = otherVertexData;
  87285. source = mesh;
  87286. }
  87287. if (subdivideWithSubMeshes) {
  87288. indiceArray.push(mesh.getTotalIndices());
  87289. }
  87290. if (multiMultiMaterials) {
  87291. if (mesh.material) {
  87292. var material = mesh.material;
  87293. if (material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"]) {
  87294. for (matIndex = 0; matIndex < material.subMaterials.length; matIndex++) {
  87295. if (materialArray.indexOf(material.subMaterials[matIndex]) < 0) {
  87296. materialArray.push(material.subMaterials[matIndex]);
  87297. }
  87298. }
  87299. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  87300. materialIndexArray.push(materialArray.indexOf(material.subMaterials[mesh.subMeshes[subIndex].materialIndex]));
  87301. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  87302. }
  87303. }
  87304. else {
  87305. if (materialArray.indexOf(material) < 0) {
  87306. materialArray.push(material);
  87307. }
  87308. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  87309. materialIndexArray.push(materialArray.indexOf(material));
  87310. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  87311. }
  87312. }
  87313. }
  87314. else {
  87315. for (subIndex = 0; subIndex < mesh.subMeshes.length; subIndex++) {
  87316. materialIndexArray.push(0);
  87317. indiceArray.push(mesh.subMeshes[subIndex].indexCount);
  87318. }
  87319. }
  87320. }
  87321. }
  87322. }
  87323. source = source;
  87324. if (!meshSubclass) {
  87325. meshSubclass = new Mesh(source.name + "_merged", source.getScene());
  87326. }
  87327. vertexData.applyToMesh(meshSubclass);
  87328. // Setting properties
  87329. meshSubclass.checkCollisions = source.checkCollisions;
  87330. // Cleaning
  87331. if (disposeSource) {
  87332. for (index = 0; index < meshes.length; index++) {
  87333. if (meshes[index]) {
  87334. meshes[index].dispose();
  87335. }
  87336. }
  87337. }
  87338. // Subdivide
  87339. if (subdivideWithSubMeshes || multiMultiMaterials) {
  87340. //-- removal of global submesh
  87341. meshSubclass.releaseSubMeshes();
  87342. index = 0;
  87343. var offset = 0;
  87344. //-- apply subdivision according to index table
  87345. while (index < indiceArray.length) {
  87346. _subMesh__WEBPACK_IMPORTED_MODULE_11__["SubMesh"].CreateFromIndices(0, offset, indiceArray[index], meshSubclass);
  87347. offset += indiceArray[index];
  87348. index++;
  87349. }
  87350. }
  87351. if (multiMultiMaterials) {
  87352. newMultiMaterial = new _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_14__["MultiMaterial"](source.name + "_merged", source.getScene());
  87353. newMultiMaterial.subMaterials = materialArray;
  87354. for (subIndex = 0; subIndex < meshSubclass.subMeshes.length; subIndex++) {
  87355. meshSubclass.subMeshes[subIndex].materialIndex = materialIndexArray[subIndex];
  87356. }
  87357. meshSubclass.material = newMultiMaterial;
  87358. }
  87359. else {
  87360. meshSubclass.material = source.material;
  87361. }
  87362. return meshSubclass;
  87363. };
  87364. /** @hidden */
  87365. Mesh.prototype.addInstance = function (instance) {
  87366. instance._indexInSourceMeshInstanceArray = this.instances.length;
  87367. this.instances.push(instance);
  87368. };
  87369. /** @hidden */
  87370. Mesh.prototype.removeInstance = function (instance) {
  87371. // Remove from mesh
  87372. var index = instance._indexInSourceMeshInstanceArray;
  87373. if (index != -1) {
  87374. if (index !== this.instances.length - 1) {
  87375. var last = this.instances[this.instances.length - 1];
  87376. this.instances[index] = last;
  87377. last._indexInSourceMeshInstanceArray = index;
  87378. }
  87379. instance._indexInSourceMeshInstanceArray = -1;
  87380. this.instances.pop();
  87381. }
  87382. };
  87383. // Consts
  87384. /**
  87385. * Mesh side orientation : usually the external or front surface
  87386. */
  87387. Mesh.FRONTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].FRONTSIDE;
  87388. /**
  87389. * Mesh side orientation : usually the internal or back surface
  87390. */
  87391. Mesh.BACKSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].BACKSIDE;
  87392. /**
  87393. * Mesh side orientation : both internal and external or front and back surfaces
  87394. */
  87395. Mesh.DOUBLESIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DOUBLESIDE;
  87396. /**
  87397. * Mesh side orientation : by default, `FRONTSIDE`
  87398. */
  87399. Mesh.DEFAULTSIDE = _mesh_vertexData__WEBPACK_IMPORTED_MODULE_8__["VertexData"].DEFAULTSIDE;
  87400. /**
  87401. * Mesh cap setting : no cap
  87402. */
  87403. Mesh.NO_CAP = 0;
  87404. /**
  87405. * Mesh cap setting : one cap at the beginning of the mesh
  87406. */
  87407. Mesh.CAP_START = 1;
  87408. /**
  87409. * Mesh cap setting : one cap at the end of the mesh
  87410. */
  87411. Mesh.CAP_END = 2;
  87412. /**
  87413. * Mesh cap setting : two caps, one at the beginning and one at the end of the mesh
  87414. */
  87415. Mesh.CAP_ALL = 3;
  87416. // Statics
  87417. /** @hidden */
  87418. Mesh._GroundMeshParser = function (parsedMesh, scene) {
  87419. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_20__["_DevTools"].WarnImport("GroundMesh");
  87420. };
  87421. return Mesh;
  87422. }(_abstractMesh__WEBPACK_IMPORTED_MODULE_10__["AbstractMesh"]));
  87423. /***/ }),
  87424. /***/ "./Meshes/mesh.vertexData.ts":
  87425. /*!***********************************!*\
  87426. !*** ./Meshes/mesh.vertexData.ts ***!
  87427. \***********************************/
  87428. /*! exports provided: VertexData */
  87429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  87430. "use strict";
  87431. __webpack_require__.r(__webpack_exports__);
  87432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return VertexData; });
  87433. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  87434. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  87435. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  87436. /**
  87437. * This class contains the various kinds of data on every vertex of a mesh used in determining its shape and appearance
  87438. */
  87439. var VertexData = /** @class */ (function () {
  87440. function VertexData() {
  87441. }
  87442. /**
  87443. * Uses the passed data array to set the set the values for the specified kind of data
  87444. * @param data a linear array of floating numbers
  87445. * @param kind the type of data that is being set, eg positions, colors etc
  87446. */
  87447. VertexData.prototype.set = function (data, kind) {
  87448. switch (kind) {
  87449. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind:
  87450. this.positions = data;
  87451. break;
  87452. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind:
  87453. this.normals = data;
  87454. break;
  87455. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind:
  87456. this.tangents = data;
  87457. break;
  87458. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind:
  87459. this.uvs = data;
  87460. break;
  87461. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind:
  87462. this.uvs2 = data;
  87463. break;
  87464. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind:
  87465. this.uvs3 = data;
  87466. break;
  87467. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind:
  87468. this.uvs4 = data;
  87469. break;
  87470. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind:
  87471. this.uvs5 = data;
  87472. break;
  87473. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind:
  87474. this.uvs6 = data;
  87475. break;
  87476. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind:
  87477. this.colors = data;
  87478. break;
  87479. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind:
  87480. this.matricesIndices = data;
  87481. break;
  87482. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind:
  87483. this.matricesWeights = data;
  87484. break;
  87485. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind:
  87486. this.matricesIndicesExtra = data;
  87487. break;
  87488. case _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind:
  87489. this.matricesWeightsExtra = data;
  87490. break;
  87491. }
  87492. };
  87493. /**
  87494. * Associates the vertexData to the passed Mesh.
  87495. * Sets it as updatable or not (default `false`)
  87496. * @param mesh the mesh the vertexData is applied to
  87497. * @param updatable when used and having the value true allows new data to update the vertexData
  87498. * @returns the VertexData
  87499. */
  87500. VertexData.prototype.applyToMesh = function (mesh, updatable) {
  87501. this._applyTo(mesh, updatable);
  87502. return this;
  87503. };
  87504. /**
  87505. * Associates the vertexData to the passed Geometry.
  87506. * Sets it as updatable or not (default `false`)
  87507. * @param geometry the geometry the vertexData is applied to
  87508. * @param updatable when used and having the value true allows new data to update the vertexData
  87509. * @returns VertexData
  87510. */
  87511. VertexData.prototype.applyToGeometry = function (geometry, updatable) {
  87512. this._applyTo(geometry, updatable);
  87513. return this;
  87514. };
  87515. /**
  87516. * Updates the associated mesh
  87517. * @param mesh the mesh to be updated
  87518. * @param updateExtends when true the mesh BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87519. * @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
  87520. * @returns VertexData
  87521. */
  87522. VertexData.prototype.updateMesh = function (mesh) {
  87523. this._update(mesh);
  87524. return this;
  87525. };
  87526. /**
  87527. * Updates the associated geometry
  87528. * @param geometry the geometry to be updated
  87529. * @param updateExtends when true BoundingInfo will be renewed when and if position kind is updated, optional with default false
  87530. * @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
  87531. * @returns VertexData.
  87532. */
  87533. VertexData.prototype.updateGeometry = function (geometry) {
  87534. this._update(geometry);
  87535. return this;
  87536. };
  87537. VertexData.prototype._applyTo = function (meshOrGeometry, updatable) {
  87538. if (updatable === void 0) { updatable = false; }
  87539. if (this.positions) {
  87540. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updatable);
  87541. }
  87542. if (this.normals) {
  87543. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updatable);
  87544. }
  87545. if (this.tangents) {
  87546. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updatable);
  87547. }
  87548. if (this.uvs) {
  87549. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updatable);
  87550. }
  87551. if (this.uvs2) {
  87552. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updatable);
  87553. }
  87554. if (this.uvs3) {
  87555. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updatable);
  87556. }
  87557. if (this.uvs4) {
  87558. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updatable);
  87559. }
  87560. if (this.uvs5) {
  87561. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updatable);
  87562. }
  87563. if (this.uvs6) {
  87564. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updatable);
  87565. }
  87566. if (this.colors) {
  87567. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updatable);
  87568. }
  87569. if (this.matricesIndices) {
  87570. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updatable);
  87571. }
  87572. if (this.matricesWeights) {
  87573. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updatable);
  87574. }
  87575. if (this.matricesIndicesExtra) {
  87576. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updatable);
  87577. }
  87578. if (this.matricesWeightsExtra) {
  87579. meshOrGeometry.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updatable);
  87580. }
  87581. if (this.indices) {
  87582. meshOrGeometry.setIndices(this.indices, null, updatable);
  87583. }
  87584. else {
  87585. meshOrGeometry.setIndices([], null);
  87586. }
  87587. return this;
  87588. };
  87589. VertexData.prototype._update = function (meshOrGeometry, updateExtends, makeItUnique) {
  87590. if (this.positions) {
  87591. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions, updateExtends, makeItUnique);
  87592. }
  87593. if (this.normals) {
  87594. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals, updateExtends, makeItUnique);
  87595. }
  87596. if (this.tangents) {
  87597. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents, updateExtends, makeItUnique);
  87598. }
  87599. if (this.uvs) {
  87600. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs, updateExtends, makeItUnique);
  87601. }
  87602. if (this.uvs2) {
  87603. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2, updateExtends, makeItUnique);
  87604. }
  87605. if (this.uvs3) {
  87606. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3, updateExtends, makeItUnique);
  87607. }
  87608. if (this.uvs4) {
  87609. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4, updateExtends, makeItUnique);
  87610. }
  87611. if (this.uvs5) {
  87612. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5, updateExtends, makeItUnique);
  87613. }
  87614. if (this.uvs6) {
  87615. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6, updateExtends, makeItUnique);
  87616. }
  87617. if (this.colors) {
  87618. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors, updateExtends, makeItUnique);
  87619. }
  87620. if (this.matricesIndices) {
  87621. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices, updateExtends, makeItUnique);
  87622. }
  87623. if (this.matricesWeights) {
  87624. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights, updateExtends, makeItUnique);
  87625. }
  87626. if (this.matricesIndicesExtra) {
  87627. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra, updateExtends, makeItUnique);
  87628. }
  87629. if (this.matricesWeightsExtra) {
  87630. meshOrGeometry.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra, updateExtends, makeItUnique);
  87631. }
  87632. if (this.indices) {
  87633. meshOrGeometry.setIndices(this.indices, null);
  87634. }
  87635. return this;
  87636. };
  87637. /**
  87638. * Transforms each position and each normal of the vertexData according to the passed Matrix
  87639. * @param matrix the transforming matrix
  87640. * @returns the VertexData
  87641. */
  87642. VertexData.prototype.transform = function (matrix) {
  87643. var flip = matrix.m[0] * matrix.m[5] * matrix.m[10] < 0;
  87644. var transformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87645. var index;
  87646. if (this.positions) {
  87647. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87648. for (index = 0; index < this.positions.length; index += 3) {
  87649. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.positions, index, position);
  87650. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(position, matrix, transformed);
  87651. this.positions[index] = transformed.x;
  87652. this.positions[index + 1] = transformed.y;
  87653. this.positions[index + 2] = transformed.z;
  87654. }
  87655. }
  87656. if (this.normals) {
  87657. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  87658. for (index = 0; index < this.normals.length; index += 3) {
  87659. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArrayToRef(this.normals, index, normal);
  87660. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(normal, matrix, transformed);
  87661. this.normals[index] = transformed.x;
  87662. this.normals[index + 1] = transformed.y;
  87663. this.normals[index + 2] = transformed.z;
  87664. }
  87665. }
  87666. if (this.tangents) {
  87667. var tangent = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87668. var tangentTransformed = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].Zero();
  87669. for (index = 0; index < this.tangents.length; index += 4) {
  87670. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].FromArrayToRef(this.tangents, index, tangent);
  87671. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"].TransformNormalToRef(tangent, matrix, tangentTransformed);
  87672. this.tangents[index] = tangentTransformed.x;
  87673. this.tangents[index + 1] = tangentTransformed.y;
  87674. this.tangents[index + 2] = tangentTransformed.z;
  87675. this.tangents[index + 3] = tangentTransformed.w;
  87676. }
  87677. }
  87678. if (flip && this.indices) {
  87679. for (index = 0; index < this.indices.length; index += 3) {
  87680. var tmp = this.indices[index + 1];
  87681. this.indices[index + 1] = this.indices[index + 2];
  87682. this.indices[index + 2] = tmp;
  87683. }
  87684. }
  87685. return this;
  87686. };
  87687. /**
  87688. * Merges the passed VertexData into the current one
  87689. * @param other the VertexData to be merged into the current one
  87690. * @param use32BitsIndices defines a boolean indicating if indices must be store in a 32 bits array
  87691. * @returns the modified VertexData
  87692. */
  87693. VertexData.prototype.merge = function (other, use32BitsIndices) {
  87694. if (use32BitsIndices === void 0) { use32BitsIndices = false; }
  87695. this._validate();
  87696. other._validate();
  87697. if (!this.normals !== !other.normals ||
  87698. !this.tangents !== !other.tangents ||
  87699. !this.uvs !== !other.uvs ||
  87700. !this.uvs2 !== !other.uvs2 ||
  87701. !this.uvs3 !== !other.uvs3 ||
  87702. !this.uvs4 !== !other.uvs4 ||
  87703. !this.uvs5 !== !other.uvs5 ||
  87704. !this.uvs6 !== !other.uvs6 ||
  87705. !this.colors !== !other.colors ||
  87706. !this.matricesIndices !== !other.matricesIndices ||
  87707. !this.matricesWeights !== !other.matricesWeights ||
  87708. !this.matricesIndicesExtra !== !other.matricesIndicesExtra ||
  87709. !this.matricesWeightsExtra !== !other.matricesWeightsExtra) {
  87710. throw new Error("Cannot merge vertex data that do not have the same set of attributes");
  87711. }
  87712. if (other.indices) {
  87713. if (!this.indices) {
  87714. this.indices = [];
  87715. }
  87716. var offset = this.positions ? this.positions.length / 3 : 0;
  87717. var isSrcTypedArray = this.indices.BYTES_PER_ELEMENT !== undefined;
  87718. if (isSrcTypedArray) {
  87719. var len = this.indices.length + other.indices.length;
  87720. var temp = use32BitsIndices || this.indices instanceof Uint32Array ? new Uint32Array(len) : new Uint16Array(len);
  87721. temp.set(this.indices);
  87722. var decal = this.indices.length;
  87723. for (var index = 0; index < other.indices.length; index++) {
  87724. temp[decal + index] = other.indices[index] + offset;
  87725. }
  87726. this.indices = temp;
  87727. }
  87728. else {
  87729. for (var index = 0; index < other.indices.length; index++) {
  87730. this.indices.push(other.indices[index] + offset);
  87731. }
  87732. }
  87733. }
  87734. this.positions = this._mergeElement(this.positions, other.positions);
  87735. this.normals = this._mergeElement(this.normals, other.normals);
  87736. this.tangents = this._mergeElement(this.tangents, other.tangents);
  87737. this.uvs = this._mergeElement(this.uvs, other.uvs);
  87738. this.uvs2 = this._mergeElement(this.uvs2, other.uvs2);
  87739. this.uvs3 = this._mergeElement(this.uvs3, other.uvs3);
  87740. this.uvs4 = this._mergeElement(this.uvs4, other.uvs4);
  87741. this.uvs5 = this._mergeElement(this.uvs5, other.uvs5);
  87742. this.uvs6 = this._mergeElement(this.uvs6, other.uvs6);
  87743. this.colors = this._mergeElement(this.colors, other.colors);
  87744. this.matricesIndices = this._mergeElement(this.matricesIndices, other.matricesIndices);
  87745. this.matricesWeights = this._mergeElement(this.matricesWeights, other.matricesWeights);
  87746. this.matricesIndicesExtra = this._mergeElement(this.matricesIndicesExtra, other.matricesIndicesExtra);
  87747. this.matricesWeightsExtra = this._mergeElement(this.matricesWeightsExtra, other.matricesWeightsExtra);
  87748. return this;
  87749. };
  87750. VertexData.prototype._mergeElement = function (source, other) {
  87751. if (!source) {
  87752. return other;
  87753. }
  87754. if (!other) {
  87755. return source;
  87756. }
  87757. var len = other.length + source.length;
  87758. var isSrcTypedArray = source instanceof Float32Array;
  87759. var isOthTypedArray = other instanceof Float32Array;
  87760. // use non-loop method when the source is Float32Array
  87761. if (isSrcTypedArray) {
  87762. var ret32 = new Float32Array(len);
  87763. ret32.set(source);
  87764. ret32.set(other, source.length);
  87765. return ret32;
  87766. // source is number[], when other is also use concat
  87767. }
  87768. else if (!isOthTypedArray) {
  87769. return source.concat(other);
  87770. // source is a number[], but other is a Float32Array, loop required
  87771. }
  87772. else {
  87773. var ret = source.slice(0); // copy source to a separate array
  87774. for (var i = 0, len = other.length; i < len; i++) {
  87775. ret.push(other[i]);
  87776. }
  87777. return ret;
  87778. }
  87779. };
  87780. VertexData.prototype._validate = function () {
  87781. if (!this.positions) {
  87782. throw new Error("Positions are required");
  87783. }
  87784. var getElementCount = function (kind, values) {
  87785. var stride = _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].DeduceStride(kind);
  87786. if ((values.length % stride) !== 0) {
  87787. throw new Error("The " + kind + "s array count must be a multiple of " + stride);
  87788. }
  87789. return values.length / stride;
  87790. };
  87791. var positionsElementCount = getElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this.positions);
  87792. var validateElementCount = function (kind, values) {
  87793. var elementCount = getElementCount(kind, values);
  87794. if (elementCount !== positionsElementCount) {
  87795. throw new Error("The " + kind + "s element count (" + elementCount + ") does not match the positions count (" + positionsElementCount + ")");
  87796. }
  87797. };
  87798. if (this.normals) {
  87799. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, this.normals);
  87800. }
  87801. if (this.tangents) {
  87802. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, this.tangents);
  87803. }
  87804. if (this.uvs) {
  87805. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, this.uvs);
  87806. }
  87807. if (this.uvs2) {
  87808. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, this.uvs2);
  87809. }
  87810. if (this.uvs3) {
  87811. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, this.uvs3);
  87812. }
  87813. if (this.uvs4) {
  87814. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, this.uvs4);
  87815. }
  87816. if (this.uvs5) {
  87817. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, this.uvs5);
  87818. }
  87819. if (this.uvs6) {
  87820. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, this.uvs6);
  87821. }
  87822. if (this.colors) {
  87823. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, this.colors);
  87824. }
  87825. if (this.matricesIndices) {
  87826. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, this.matricesIndices);
  87827. }
  87828. if (this.matricesWeights) {
  87829. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, this.matricesWeights);
  87830. }
  87831. if (this.matricesIndicesExtra) {
  87832. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, this.matricesIndicesExtra);
  87833. }
  87834. if (this.matricesWeightsExtra) {
  87835. validateElementCount(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, this.matricesWeightsExtra);
  87836. }
  87837. };
  87838. /**
  87839. * Serializes the VertexData
  87840. * @returns a serialized object
  87841. */
  87842. VertexData.prototype.serialize = function () {
  87843. var serializationObject = this.serialize();
  87844. if (this.positions) {
  87845. serializationObject.positions = this.positions;
  87846. }
  87847. if (this.normals) {
  87848. serializationObject.normals = this.normals;
  87849. }
  87850. if (this.tangents) {
  87851. serializationObject.tangents = this.tangents;
  87852. }
  87853. if (this.uvs) {
  87854. serializationObject.uvs = this.uvs;
  87855. }
  87856. if (this.uvs2) {
  87857. serializationObject.uvs2 = this.uvs2;
  87858. }
  87859. if (this.uvs3) {
  87860. serializationObject.uvs3 = this.uvs3;
  87861. }
  87862. if (this.uvs4) {
  87863. serializationObject.uvs4 = this.uvs4;
  87864. }
  87865. if (this.uvs5) {
  87866. serializationObject.uvs5 = this.uvs5;
  87867. }
  87868. if (this.uvs6) {
  87869. serializationObject.uvs6 = this.uvs6;
  87870. }
  87871. if (this.colors) {
  87872. serializationObject.colors = this.colors;
  87873. }
  87874. if (this.matricesIndices) {
  87875. serializationObject.matricesIndices = this.matricesIndices;
  87876. serializationObject.matricesIndices._isExpanded = true;
  87877. }
  87878. if (this.matricesWeights) {
  87879. serializationObject.matricesWeights = this.matricesWeights;
  87880. }
  87881. if (this.matricesIndicesExtra) {
  87882. serializationObject.matricesIndicesExtra = this.matricesIndicesExtra;
  87883. serializationObject.matricesIndicesExtra._isExpanded = true;
  87884. }
  87885. if (this.matricesWeightsExtra) {
  87886. serializationObject.matricesWeightsExtra = this.matricesWeightsExtra;
  87887. }
  87888. serializationObject.indices = this.indices;
  87889. return serializationObject;
  87890. };
  87891. // Statics
  87892. /**
  87893. * Extracts the vertexData from a mesh
  87894. * @param mesh the mesh from which to extract the VertexData
  87895. * @param copyWhenShared defines if the VertexData must be cloned when shared between multiple meshes, optional, default false
  87896. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87897. * @returns the object VertexData associated to the passed mesh
  87898. */
  87899. VertexData.ExtractFromMesh = function (mesh, copyWhenShared, forceCopy) {
  87900. return VertexData._ExtractFrom(mesh, copyWhenShared, forceCopy);
  87901. };
  87902. /**
  87903. * Extracts the vertexData from the geometry
  87904. * @param geometry the geometry from which to extract the VertexData
  87905. * @param copyWhenShared defines if the VertexData must be cloned when the geometrty is shared between multiple meshes, optional, default false
  87906. * @param forceCopy indicating that the VertexData must be cloned, optional, default false
  87907. * @returns the object VertexData associated to the passed mesh
  87908. */
  87909. VertexData.ExtractFromGeometry = function (geometry, copyWhenShared, forceCopy) {
  87910. return VertexData._ExtractFrom(geometry, copyWhenShared, forceCopy);
  87911. };
  87912. VertexData._ExtractFrom = function (meshOrGeometry, copyWhenShared, forceCopy) {
  87913. var result = new VertexData();
  87914. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind)) {
  87915. result.positions = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, copyWhenShared, forceCopy);
  87916. }
  87917. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind)) {
  87918. result.normals = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, copyWhenShared, forceCopy);
  87919. }
  87920. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind)) {
  87921. result.tangents = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind, copyWhenShared, forceCopy);
  87922. }
  87923. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  87924. result.uvs = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, copyWhenShared, forceCopy);
  87925. }
  87926. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  87927. result.uvs2 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind, copyWhenShared, forceCopy);
  87928. }
  87929. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind)) {
  87930. result.uvs3 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind, copyWhenShared, forceCopy);
  87931. }
  87932. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind)) {
  87933. result.uvs4 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind, copyWhenShared, forceCopy);
  87934. }
  87935. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind)) {
  87936. result.uvs5 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind, copyWhenShared, forceCopy);
  87937. }
  87938. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind)) {
  87939. result.uvs6 = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind, copyWhenShared, forceCopy);
  87940. }
  87941. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind)) {
  87942. result.colors = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, copyWhenShared, forceCopy);
  87943. }
  87944. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind)) {
  87945. result.matricesIndices = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind, copyWhenShared, forceCopy);
  87946. }
  87947. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind)) {
  87948. result.matricesWeights = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind, copyWhenShared, forceCopy);
  87949. }
  87950. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind)) {
  87951. result.matricesIndicesExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind, copyWhenShared, forceCopy);
  87952. }
  87953. if (meshOrGeometry.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind)) {
  87954. result.matricesWeightsExtra = meshOrGeometry.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind, copyWhenShared, forceCopy);
  87955. }
  87956. result.indices = meshOrGeometry.getIndices(copyWhenShared, forceCopy);
  87957. return result;
  87958. };
  87959. /**
  87960. * Creates the VertexData for a Ribbon
  87961. * @param options an object used to set the following optional parameters for the ribbon, required but can be empty
  87962. * * pathArray array of paths, each of which an array of successive Vector3
  87963. * * closeArray creates a seam between the first and the last paths of the pathArray, optional, default false
  87964. * * closePath creates a seam between the first and the last points of each path of the path array, optional, default false
  87965. * * 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
  87966. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87967. * * 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)
  87968. * * 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)
  87969. * * invertUV swaps in the U and V coordinates when applying a texture, optional, default false
  87970. * * uvs a linear array, of length 2 * number of vertices, of custom UV values, optional
  87971. * * colors a linear array, of length 4 * number of vertices, of custom color values, optional
  87972. * @returns the VertexData of the ribbon
  87973. */
  87974. VertexData.CreateRibbon = function (options) {
  87975. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ribbonBuilder");
  87976. };
  87977. /**
  87978. * Creates the VertexData for a box
  87979. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87980. * * size sets the width, height and depth of the box to the value of size, optional default 1
  87981. * * width sets the width (x direction) of the box, overwrites the width set by size, optional, default size
  87982. * * height sets the height (y direction) of the box, overwrites the height set by size, optional, default size
  87983. * * depth sets the depth (z direction) of the box, overwrites the depth set by size, optional, default size
  87984. * * faceUV an array of 6 Vector4 elements used to set different images to each box side
  87985. * * faceColors an array of 6 Color3 elements used to set different colors to each box side
  87986. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  87987. * * 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)
  87988. * * 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)
  87989. * @returns the VertexData of the box
  87990. */
  87991. VertexData.CreateBox = function (options) {
  87992. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("boxBuilder");
  87993. };
  87994. /**
  87995. * Creates the VertexData for an ellipsoid, defaults to a sphere
  87996. * @param options an object used to set the following optional parameters for the box, required but can be empty
  87997. * * segments sets the number of horizontal strips optional, default 32
  87998. * * diameter sets the axes dimensions, diameterX, diameterY and diameterZ to the value of diameter, optional default 1
  87999. * * diameterX sets the diameterX (x direction) of the ellipsoid, overwrites the diameterX set by diameter, optional, default diameter
  88000. * * diameterY sets the diameterY (y direction) of the ellipsoid, overwrites the diameterY set by diameter, optional, default diameter
  88001. * * diameterZ sets the diameterZ (z direction) of the ellipsoid, overwrites the diameterZ set by diameter, optional, default diameter
  88002. * * 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
  88003. * * 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
  88004. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88005. * * 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)
  88006. * * 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)
  88007. * @returns the VertexData of the ellipsoid
  88008. */
  88009. VertexData.CreateSphere = function (options) {
  88010. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("sphereBuilder");
  88011. };
  88012. /**
  88013. * Creates the VertexData for a cylinder, cone or prism
  88014. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88015. * * height sets the height (y direction) of the cylinder, optional, default 2
  88016. * * diameterTop sets the diameter of the top of the cone, overwrites diameter, optional, default diameter
  88017. * * diameterBottom sets the diameter of the bottom of the cone, overwrites diameter, optional, default diameter
  88018. * * diameter sets the diameter of the top and bottom of the cone, optional default 1
  88019. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88020. * * subdivisions` the number of rings along the cylinder height, optional, default 1
  88021. * * 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
  88022. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88023. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88024. * * hasRings when true makes each subdivision independantly treated as a face for faceUV and faceColors, optional, default false
  88025. * * enclose when true closes an open cylinder by adding extra flat faces between the height axis and vertical edges, think cut cake
  88026. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88027. * * 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)
  88028. * * 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)
  88029. * @returns the VertexData of the cylinder, cone or prism
  88030. */
  88031. VertexData.CreateCylinder = function (options) {
  88032. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("cylinderBuilder");
  88033. };
  88034. /**
  88035. * Creates the VertexData for a torus
  88036. * @param options an object used to set the following optional parameters for the box, required but can be empty
  88037. * * diameter the diameter of the torus, optional default 1
  88038. * * thickness the diameter of the tube forming the torus, optional default 0.5
  88039. * * tessellation the number of prism sides, 3 for a triangular prism, optional, default 24
  88040. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88041. * * 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)
  88042. * * 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)
  88043. * @returns the VertexData of the torus
  88044. */
  88045. VertexData.CreateTorus = function (options) {
  88046. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusBuilder");
  88047. };
  88048. /**
  88049. * Creates the VertexData of the LineSystem
  88050. * @param options an object used to set the following optional parameters for the LineSystem, required but can be empty
  88051. * - lines an array of lines, each line being an array of successive Vector3
  88052. * - colors an array of line colors, each of the line colors being an array of successive Color4, one per line point
  88053. * @returns the VertexData of the LineSystem
  88054. */
  88055. VertexData.CreateLineSystem = function (options) {
  88056. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  88057. };
  88058. /**
  88059. * Create the VertexData for a DashedLines
  88060. * @param options an object used to set the following optional parameters for the DashedLines, required but can be empty
  88061. * - points an array successive Vector3
  88062. * - dashSize the size of the dashes relative to the dash number, optional, default 3
  88063. * - gapSize the size of the gap between two successive dashes relative to the dash number, optional, default 1
  88064. * - dashNb the intended total number of dashes, optional, default 200
  88065. * @returns the VertexData for the DashedLines
  88066. */
  88067. VertexData.CreateDashedLines = function (options) {
  88068. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("linesBuilder");
  88069. };
  88070. /**
  88071. * Creates the VertexData for a Ground
  88072. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88073. * - width the width (x direction) of the ground, optional, default 1
  88074. * - height the height (z direction) of the ground, optional, default 1
  88075. * - subdivisions the number of subdivisions per side, optional, default 1
  88076. * @returns the VertexData of the Ground
  88077. */
  88078. VertexData.CreateGround = function (options) {
  88079. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  88080. };
  88081. /**
  88082. * Creates the VertexData for a TiledGround by subdividing the ground into tiles
  88083. * @param options an object used to set the following optional parameters for the Ground, required but can be empty
  88084. * * xmin the ground minimum X coordinate, optional, default -1
  88085. * * zmin the ground minimum Z coordinate, optional, default -1
  88086. * * xmax the ground maximum X coordinate, optional, default 1
  88087. * * zmax the ground maximum Z coordinate, optional, default 1
  88088. * * 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}
  88089. * * 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}
  88090. * @returns the VertexData of the TiledGround
  88091. */
  88092. VertexData.CreateTiledGround = function (options) {
  88093. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  88094. };
  88095. /**
  88096. * Creates the VertexData of the Ground designed from a heightmap
  88097. * @param options an object used to set the following parameters for the Ground, required and provided by MeshBuilder.CreateGroundFromHeightMap
  88098. * * width the width (x direction) of the ground
  88099. * * height the height (z direction) of the ground
  88100. * * subdivisions the number of subdivisions per side
  88101. * * minHeight the minimum altitude on the ground, optional, default 0
  88102. * * maxHeight the maximum altitude on the ground, optional default 1
  88103. * * colorFilter the filter to apply to the image pixel colors to compute the height, optional Color3, default (0.3, 0.59, 0.11)
  88104. * * buffer the array holding the image color data
  88105. * * bufferWidth the width of image
  88106. * * bufferHeight the height of image
  88107. * * alphaFilter Remove any data where the alpha channel is below this value, defaults 0 (all data visible)
  88108. * @returns the VertexData of the Ground designed from a heightmap
  88109. */
  88110. VertexData.CreateGroundFromHeightMap = function (options) {
  88111. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("groundBuilder");
  88112. };
  88113. /**
  88114. * Creates the VertexData for a Plane
  88115. * @param options an object used to set the following optional parameters for the plane, required but can be empty
  88116. * * size sets the width and height of the plane to the value of size, optional default 1
  88117. * * width sets the width (x direction) of the plane, overwrites the width set by size, optional, default size
  88118. * * height sets the height (y direction) of the plane, overwrites the height set by size, optional, default size
  88119. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88120. * * 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)
  88121. * * 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)
  88122. * @returns the VertexData of the box
  88123. */
  88124. VertexData.CreatePlane = function (options) {
  88125. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("planeBuilder");
  88126. };
  88127. /**
  88128. * Creates the VertexData of the Disc or regular Polygon
  88129. * @param options an object used to set the following optional parameters for the disc, required but can be empty
  88130. * * radius the radius of the disc, optional default 0.5
  88131. * * tessellation the number of polygon sides, optional, default 64
  88132. * * 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
  88133. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88134. * * 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)
  88135. * * 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)
  88136. * @returns the VertexData of the box
  88137. */
  88138. VertexData.CreateDisc = function (options) {
  88139. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("discBuilder");
  88140. };
  88141. /**
  88142. * Creates the VertexData for an irregular Polygon in the XoZ plane using a mesh built by polygonTriangulation.build()
  88143. * All parameters are provided by MeshBuilder.CreatePolygon as needed
  88144. * @param polygon a mesh built from polygonTriangulation.build()
  88145. * @param sideOrientation takes the values Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88146. * @param fUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88147. * @param fColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88148. * @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)
  88149. * @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)
  88150. * @returns the VertexData of the Polygon
  88151. */
  88152. VertexData.CreatePolygon = function (polygon, sideOrientation, fUV, fColors, frontUVs, backUVs) {
  88153. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polygonBuilder");
  88154. };
  88155. /**
  88156. * Creates the VertexData of the IcoSphere
  88157. * @param options an object used to set the following optional parameters for the IcoSphere, required but can be empty
  88158. * * radius the radius of the IcoSphere, optional default 1
  88159. * * radiusX allows stretching in the x direction, optional, default radius
  88160. * * radiusY allows stretching in the y direction, optional, default radius
  88161. * * radiusZ allows stretching in the z direction, optional, default radius
  88162. * * flat when true creates a flat shaded mesh, optional, default true
  88163. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88164. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88165. * * 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)
  88166. * * 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)
  88167. * @returns the VertexData of the IcoSphere
  88168. */
  88169. VertexData.CreateIcoSphere = function (options) {
  88170. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("icoSphereBuilder");
  88171. };
  88172. // inspired from // http://stemkoski.github.io/Three.js/Polyhedra.html
  88173. /**
  88174. * Creates the VertexData for a Polyhedron
  88175. * @param options an object used to set the following optional parameters for the polyhedron, required but can be empty
  88176. * * type provided types are:
  88177. * * 0 : Tetrahedron, 1 : Octahedron, 2 : Dodecahedron, 3 : Icosahedron, 4 : Rhombicuboctahedron, 5 : Triangular Prism, 6 : Pentagonal Prism, 7 : Hexagonal Prism, 8 : Square Pyramid (J1)
  88178. * * 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)
  88179. * * size the size of the IcoSphere, optional default 1
  88180. * * sizeX allows stretching in the x direction, optional, default size
  88181. * * sizeY allows stretching in the y direction, optional, default size
  88182. * * sizeZ allows stretching in the z direction, optional, default size
  88183. * * 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
  88184. * * faceUV an array of Vector4 elements used to set different images to the top, rings and bottom respectively
  88185. * * faceColors an array of Color3 elements used to set different colors to the top, rings and bottom respectively
  88186. * * flat when true creates a flat shaded mesh, optional, default true
  88187. * * subdivisions increasing the subdivisions increases the number of faces, optional, default 4
  88188. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88189. * * 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)
  88190. * * 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)
  88191. * @returns the VertexData of the Polyhedron
  88192. */
  88193. VertexData.CreatePolyhedron = function (options) {
  88194. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("polyhedronBuilder");
  88195. };
  88196. // based on http://code.google.com/p/away3d/source/browse/trunk/fp10/Away3D/src/away3d/primitives/TorusKnot.as?spec=svn2473&r=2473
  88197. /**
  88198. * Creates the VertexData for a TorusKnot
  88199. * @param options an object used to set the following optional parameters for the TorusKnot, required but can be empty
  88200. * * radius the radius of the torus knot, optional, default 2
  88201. * * tube the thickness of the tube, optional, default 0.5
  88202. * * radialSegments the number of sides on each tube segments, optional, default 32
  88203. * * tubularSegments the number of tubes to decompose the knot into, optional, default 32
  88204. * * p the number of windings around the z axis, optional, default 2
  88205. * * q the number of windings around the x axis, optional, default 3
  88206. * * sideOrientation optional and takes the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88207. * * 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)
  88208. * * 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)
  88209. * @returns the VertexData of the Torus Knot
  88210. */
  88211. VertexData.CreateTorusKnot = function (options) {
  88212. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("torusKnotBuilder");
  88213. };
  88214. // Tools
  88215. /**
  88216. * Compute normals for given positions and indices
  88217. * @param positions an array of vertex positions, [...., x, y, z, ......]
  88218. * @param indices an array of indices in groups of three for each triangular facet, [...., i, j, k, ......]
  88219. * @param normals an array of vertex normals, [...., x, y, z, ......]
  88220. * @param options an object used to set the following optional parameters for the TorusKnot, optional
  88221. * * facetNormals : optional array of facet normals (vector3)
  88222. * * facetPositions : optional array of facet positions (vector3)
  88223. * * facetPartitioning : optional partitioning array. facetPositions is required for facetPartitioning computation
  88224. * * ratio : optional partitioning ratio / bounding box, required for facetPartitioning computation
  88225. * * bInfo : optional bounding info, required for facetPartitioning computation
  88226. * * bbSize : optional bounding box size data, required for facetPartitioning computation
  88227. * * subDiv : optional partitioning data about subdivsions on each axis (int), required for facetPartitioning computation
  88228. * * useRightHandedSystem: optional boolean to for right handed system computation
  88229. * * depthSort : optional boolean to enable the facet depth sort computation
  88230. * * distanceTo : optional Vector3 to compute the facet depth from this location
  88231. * * depthSortedFacets : optional array of depthSortedFacets to store the facet distances from the reference location
  88232. */
  88233. VertexData.ComputeNormals = function (positions, indices, normals, options) {
  88234. // temporary scalar variables
  88235. var index = 0; // facet index
  88236. var p1p2x = 0.0; // p1p2 vector x coordinate
  88237. var p1p2y = 0.0; // p1p2 vector y coordinate
  88238. var p1p2z = 0.0; // p1p2 vector z coordinate
  88239. var p3p2x = 0.0; // p3p2 vector x coordinate
  88240. var p3p2y = 0.0; // p3p2 vector y coordinate
  88241. var p3p2z = 0.0; // p3p2 vector z coordinate
  88242. var faceNormalx = 0.0; // facet normal x coordinate
  88243. var faceNormaly = 0.0; // facet normal y coordinate
  88244. var faceNormalz = 0.0; // facet normal z coordinate
  88245. var length = 0.0; // facet normal length before normalization
  88246. var v1x = 0; // vector1 x index in the positions array
  88247. var v1y = 0; // vector1 y index in the positions array
  88248. var v1z = 0; // vector1 z index in the positions array
  88249. var v2x = 0; // vector2 x index in the positions array
  88250. var v2y = 0; // vector2 y index in the positions array
  88251. var v2z = 0; // vector2 z index in the positions array
  88252. var v3x = 0; // vector3 x index in the positions array
  88253. var v3y = 0; // vector3 y index in the positions array
  88254. var v3z = 0; // vector3 z index in the positions array
  88255. var computeFacetNormals = false;
  88256. var computeFacetPositions = false;
  88257. var computeFacetPartitioning = false;
  88258. var computeDepthSort = false;
  88259. var faceNormalSign = 1;
  88260. var ratio = 0;
  88261. var distanceTo = null;
  88262. if (options) {
  88263. computeFacetNormals = (options.facetNormals) ? true : false;
  88264. computeFacetPositions = (options.facetPositions) ? true : false;
  88265. computeFacetPartitioning = (options.facetPartitioning) ? true : false;
  88266. faceNormalSign = (options.useRightHandedSystem === true) ? -1 : 1;
  88267. ratio = options.ratio || 0;
  88268. computeDepthSort = (options.depthSort) ? true : false;
  88269. distanceTo = (options.distanceTo);
  88270. if (computeDepthSort) {
  88271. if (distanceTo === undefined) {
  88272. distanceTo = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  88273. }
  88274. var depthSortedFacets = options.depthSortedFacets;
  88275. }
  88276. }
  88277. // facetPartitioning reinit if needed
  88278. var xSubRatio = 0;
  88279. var ySubRatio = 0;
  88280. var zSubRatio = 0;
  88281. var subSq = 0;
  88282. if (computeFacetPartitioning && options && options.bbSize) {
  88283. var ox = 0; // X partitioning index for facet position
  88284. var oy = 0; // Y partinioning index for facet position
  88285. var oz = 0; // Z partinioning index for facet position
  88286. var b1x = 0; // X partitioning index for facet v1 vertex
  88287. var b1y = 0; // Y partitioning index for facet v1 vertex
  88288. var b1z = 0; // z partitioning index for facet v1 vertex
  88289. var b2x = 0; // X partitioning index for facet v2 vertex
  88290. var b2y = 0; // Y partitioning index for facet v2 vertex
  88291. var b2z = 0; // Z partitioning index for facet v2 vertex
  88292. var b3x = 0; // X partitioning index for facet v3 vertex
  88293. var b3y = 0; // Y partitioning index for facet v3 vertex
  88294. var b3z = 0; // Z partitioning index for facet v3 vertex
  88295. var block_idx_o = 0; // facet barycenter block index
  88296. var block_idx_v1 = 0; // v1 vertex block index
  88297. var block_idx_v2 = 0; // v2 vertex block index
  88298. var block_idx_v3 = 0; // v3 vertex block index
  88299. var bbSizeMax = (options.bbSize.x > options.bbSize.y) ? options.bbSize.x : options.bbSize.y;
  88300. bbSizeMax = (bbSizeMax > options.bbSize.z) ? bbSizeMax : options.bbSize.z;
  88301. xSubRatio = options.subDiv.X * ratio / options.bbSize.x;
  88302. ySubRatio = options.subDiv.Y * ratio / options.bbSize.y;
  88303. zSubRatio = options.subDiv.Z * ratio / options.bbSize.z;
  88304. subSq = options.subDiv.max * options.subDiv.max;
  88305. options.facetPartitioning.length = 0;
  88306. }
  88307. // reset the normals
  88308. for (index = 0; index < positions.length; index++) {
  88309. normals[index] = 0.0;
  88310. }
  88311. // Loop : 1 indice triplet = 1 facet
  88312. var nbFaces = (indices.length / 3) | 0;
  88313. for (index = 0; index < nbFaces; index++) {
  88314. // get the indexes of the coordinates of each vertex of the facet
  88315. v1x = indices[index * 3] * 3;
  88316. v1y = v1x + 1;
  88317. v1z = v1x + 2;
  88318. v2x = indices[index * 3 + 1] * 3;
  88319. v2y = v2x + 1;
  88320. v2z = v2x + 2;
  88321. v3x = indices[index * 3 + 2] * 3;
  88322. v3y = v3x + 1;
  88323. v3z = v3x + 2;
  88324. p1p2x = positions[v1x] - positions[v2x]; // compute two vectors per facet : p1p2 and p3p2
  88325. p1p2y = positions[v1y] - positions[v2y];
  88326. p1p2z = positions[v1z] - positions[v2z];
  88327. p3p2x = positions[v3x] - positions[v2x];
  88328. p3p2y = positions[v3y] - positions[v2y];
  88329. p3p2z = positions[v3z] - positions[v2z];
  88330. // compute the face normal with the cross product
  88331. faceNormalx = faceNormalSign * (p1p2y * p3p2z - p1p2z * p3p2y);
  88332. faceNormaly = faceNormalSign * (p1p2z * p3p2x - p1p2x * p3p2z);
  88333. faceNormalz = faceNormalSign * (p1p2x * p3p2y - p1p2y * p3p2x);
  88334. // normalize this normal and store it in the array facetData
  88335. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  88336. length = (length === 0) ? 1.0 : length;
  88337. faceNormalx /= length;
  88338. faceNormaly /= length;
  88339. faceNormalz /= length;
  88340. if (computeFacetNormals && options) {
  88341. options.facetNormals[index].x = faceNormalx;
  88342. options.facetNormals[index].y = faceNormaly;
  88343. options.facetNormals[index].z = faceNormalz;
  88344. }
  88345. if (computeFacetPositions && options) {
  88346. // compute and the facet barycenter coordinates in the array facetPositions
  88347. options.facetPositions[index].x = (positions[v1x] + positions[v2x] + positions[v3x]) / 3.0;
  88348. options.facetPositions[index].y = (positions[v1y] + positions[v2y] + positions[v3y]) / 3.0;
  88349. options.facetPositions[index].z = (positions[v1z] + positions[v2z] + positions[v3z]) / 3.0;
  88350. }
  88351. if (computeFacetPartitioning && options) {
  88352. // store the facet indexes in arrays in the main facetPartitioning array :
  88353. // compute each facet vertex (+ facet barycenter) index in the partiniong array
  88354. ox = Math.floor((options.facetPositions[index].x - options.bInfo.minimum.x * ratio) * xSubRatio);
  88355. oy = Math.floor((options.facetPositions[index].y - options.bInfo.minimum.y * ratio) * ySubRatio);
  88356. oz = Math.floor((options.facetPositions[index].z - options.bInfo.minimum.z * ratio) * zSubRatio);
  88357. b1x = Math.floor((positions[v1x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  88358. b1y = Math.floor((positions[v1y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  88359. b1z = Math.floor((positions[v1z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  88360. b2x = Math.floor((positions[v2x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  88361. b2y = Math.floor((positions[v2y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  88362. b2z = Math.floor((positions[v2z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  88363. b3x = Math.floor((positions[v3x] - options.bInfo.minimum.x * ratio) * xSubRatio);
  88364. b3y = Math.floor((positions[v3y] - options.bInfo.minimum.y * ratio) * ySubRatio);
  88365. b3z = Math.floor((positions[v3z] - options.bInfo.minimum.z * ratio) * zSubRatio);
  88366. block_idx_v1 = b1x + options.subDiv.max * b1y + subSq * b1z;
  88367. block_idx_v2 = b2x + options.subDiv.max * b2y + subSq * b2z;
  88368. block_idx_v3 = b3x + options.subDiv.max * b3y + subSq * b3z;
  88369. block_idx_o = ox + options.subDiv.max * oy + subSq * oz;
  88370. options.facetPartitioning[block_idx_o] = options.facetPartitioning[block_idx_o] ? options.facetPartitioning[block_idx_o] : new Array();
  88371. options.facetPartitioning[block_idx_v1] = options.facetPartitioning[block_idx_v1] ? options.facetPartitioning[block_idx_v1] : new Array();
  88372. options.facetPartitioning[block_idx_v2] = options.facetPartitioning[block_idx_v2] ? options.facetPartitioning[block_idx_v2] : new Array();
  88373. options.facetPartitioning[block_idx_v3] = options.facetPartitioning[block_idx_v3] ? options.facetPartitioning[block_idx_v3] : new Array();
  88374. // push each facet index in each block containing the vertex
  88375. options.facetPartitioning[block_idx_v1].push(index);
  88376. if (block_idx_v2 != block_idx_v1) {
  88377. options.facetPartitioning[block_idx_v2].push(index);
  88378. }
  88379. if (!(block_idx_v3 == block_idx_v2 || block_idx_v3 == block_idx_v1)) {
  88380. options.facetPartitioning[block_idx_v3].push(index);
  88381. }
  88382. if (!(block_idx_o == block_idx_v1 || block_idx_o == block_idx_v2 || block_idx_o == block_idx_v3)) {
  88383. options.facetPartitioning[block_idx_o].push(index);
  88384. }
  88385. }
  88386. if (computeDepthSort && options && options.facetPositions) {
  88387. var dsf = depthSortedFacets[index];
  88388. dsf.ind = index * 3;
  88389. dsf.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(options.facetPositions[index], distanceTo);
  88390. }
  88391. // compute the normals anyway
  88392. normals[v1x] += faceNormalx; // accumulate all the normals per face
  88393. normals[v1y] += faceNormaly;
  88394. normals[v1z] += faceNormalz;
  88395. normals[v2x] += faceNormalx;
  88396. normals[v2y] += faceNormaly;
  88397. normals[v2z] += faceNormalz;
  88398. normals[v3x] += faceNormalx;
  88399. normals[v3y] += faceNormaly;
  88400. normals[v3z] += faceNormalz;
  88401. }
  88402. // last normalization of each normal
  88403. for (index = 0; index < normals.length / 3; index++) {
  88404. faceNormalx = normals[index * 3];
  88405. faceNormaly = normals[index * 3 + 1];
  88406. faceNormalz = normals[index * 3 + 2];
  88407. length = Math.sqrt(faceNormalx * faceNormalx + faceNormaly * faceNormaly + faceNormalz * faceNormalz);
  88408. length = (length === 0) ? 1.0 : length;
  88409. faceNormalx /= length;
  88410. faceNormaly /= length;
  88411. faceNormalz /= length;
  88412. normals[index * 3] = faceNormalx;
  88413. normals[index * 3 + 1] = faceNormaly;
  88414. normals[index * 3 + 2] = faceNormalz;
  88415. }
  88416. };
  88417. /** @hidden */
  88418. VertexData._ComputeSides = function (sideOrientation, positions, indices, normals, uvs, frontUVs, backUVs) {
  88419. var li = indices.length;
  88420. var ln = normals.length;
  88421. var i;
  88422. var n;
  88423. sideOrientation = sideOrientation || VertexData.DEFAULTSIDE;
  88424. switch (sideOrientation) {
  88425. case VertexData.FRONTSIDE:
  88426. // nothing changed
  88427. break;
  88428. case VertexData.BACKSIDE:
  88429. var tmp;
  88430. // indices
  88431. for (i = 0; i < li; i += 3) {
  88432. tmp = indices[i];
  88433. indices[i] = indices[i + 2];
  88434. indices[i + 2] = tmp;
  88435. }
  88436. // normals
  88437. for (n = 0; n < ln; n++) {
  88438. normals[n] = -normals[n];
  88439. }
  88440. break;
  88441. case VertexData.DOUBLESIDE:
  88442. // positions
  88443. var lp = positions.length;
  88444. var l = lp / 3;
  88445. for (var p = 0; p < lp; p++) {
  88446. positions[lp + p] = positions[p];
  88447. }
  88448. // indices
  88449. for (i = 0; i < li; i += 3) {
  88450. indices[i + li] = indices[i + 2] + l;
  88451. indices[i + 1 + li] = indices[i + 1] + l;
  88452. indices[i + 2 + li] = indices[i] + l;
  88453. }
  88454. // normals
  88455. for (n = 0; n < ln; n++) {
  88456. normals[ln + n] = -normals[n];
  88457. }
  88458. // uvs
  88459. var lu = uvs.length;
  88460. var u = 0;
  88461. for (u = 0; u < lu; u++) {
  88462. uvs[u + lu] = uvs[u];
  88463. }
  88464. frontUVs = frontUVs ? frontUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  88465. backUVs = backUVs ? backUVs : new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  88466. u = 0;
  88467. for (i = 0; i < lu / 2; i++) {
  88468. uvs[u] = frontUVs.x + (frontUVs.z - frontUVs.x) * uvs[u];
  88469. uvs[u + 1] = frontUVs.y + (frontUVs.w - frontUVs.y) * uvs[u + 1];
  88470. uvs[u + lu] = backUVs.x + (backUVs.z - backUVs.x) * uvs[u + lu];
  88471. uvs[u + lu + 1] = backUVs.y + (backUVs.w - backUVs.y) * uvs[u + lu + 1];
  88472. u += 2;
  88473. }
  88474. break;
  88475. }
  88476. };
  88477. /**
  88478. * Applies VertexData created from the imported parameters to the geometry
  88479. * @param parsedVertexData the parsed data from an imported file
  88480. * @param geometry the geometry to apply the VertexData to
  88481. */
  88482. VertexData.ImportVertexData = function (parsedVertexData, geometry) {
  88483. var vertexData = new VertexData();
  88484. // positions
  88485. var positions = parsedVertexData.positions;
  88486. if (positions) {
  88487. vertexData.set(positions, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  88488. }
  88489. // normals
  88490. var normals = parsedVertexData.normals;
  88491. if (normals) {
  88492. vertexData.set(normals, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  88493. }
  88494. // tangents
  88495. var tangents = parsedVertexData.tangents;
  88496. if (tangents) {
  88497. vertexData.set(tangents, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].TangentKind);
  88498. }
  88499. // uvs
  88500. var uvs = parsedVertexData.uvs;
  88501. if (uvs) {
  88502. vertexData.set(uvs, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  88503. }
  88504. // uv2s
  88505. var uv2s = parsedVertexData.uv2s;
  88506. if (uv2s) {
  88507. vertexData.set(uv2s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  88508. }
  88509. // uv3s
  88510. var uv3s = parsedVertexData.uv3s;
  88511. if (uv3s) {
  88512. vertexData.set(uv3s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV3Kind);
  88513. }
  88514. // uv4s
  88515. var uv4s = parsedVertexData.uv4s;
  88516. if (uv4s) {
  88517. vertexData.set(uv4s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV4Kind);
  88518. }
  88519. // uv5s
  88520. var uv5s = parsedVertexData.uv5s;
  88521. if (uv5s) {
  88522. vertexData.set(uv5s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV5Kind);
  88523. }
  88524. // uv6s
  88525. var uv6s = parsedVertexData.uv6s;
  88526. if (uv6s) {
  88527. vertexData.set(uv6s, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV6Kind);
  88528. }
  88529. // colors
  88530. var colors = parsedVertexData.colors;
  88531. if (colors) {
  88532. vertexData.set(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"].CheckColors4(colors, positions.length / 3), _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  88533. }
  88534. // matricesIndices
  88535. var matricesIndices = parsedVertexData.matricesIndices;
  88536. if (matricesIndices) {
  88537. vertexData.set(matricesIndices, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  88538. }
  88539. // matricesWeights
  88540. var matricesWeights = parsedVertexData.matricesWeights;
  88541. if (matricesWeights) {
  88542. vertexData.set(matricesWeights, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  88543. }
  88544. // indices
  88545. var indices = parsedVertexData.indices;
  88546. if (indices) {
  88547. vertexData.indices = indices;
  88548. }
  88549. geometry.setAllVerticesData(vertexData, parsedVertexData.updatable);
  88550. };
  88551. /**
  88552. * Mesh side orientation : usually the external or front surface
  88553. */
  88554. VertexData.FRONTSIDE = 0;
  88555. /**
  88556. * Mesh side orientation : usually the internal or back surface
  88557. */
  88558. VertexData.BACKSIDE = 1;
  88559. /**
  88560. * Mesh side orientation : both internal and external or front and back surfaces
  88561. */
  88562. VertexData.DOUBLESIDE = 2;
  88563. /**
  88564. * Mesh side orientation : by default, `FRONTSIDE`
  88565. */
  88566. VertexData.DEFAULTSIDE = 0;
  88567. return VertexData;
  88568. }());
  88569. /***/ }),
  88570. /***/ "./Meshes/meshBuilder.ts":
  88571. /*!*******************************!*\
  88572. !*** ./Meshes/meshBuilder.ts ***!
  88573. \*******************************/
  88574. /*! exports provided: MeshBuilder */
  88575. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  88576. "use strict";
  88577. __webpack_require__.r(__webpack_exports__);
  88578. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return MeshBuilder; });
  88579. /* harmony import */ var _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Builders/ribbonBuilder */ "./Meshes/Builders/ribbonBuilder.ts");
  88580. /* harmony import */ var _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  88581. /* harmony import */ var _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  88582. /* harmony import */ var _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  88583. /* harmony import */ var _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  88584. /* harmony import */ var _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Builders/torusBuilder */ "./Meshes/Builders/torusBuilder.ts");
  88585. /* harmony import */ var _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Builders/torusKnotBuilder */ "./Meshes/Builders/torusKnotBuilder.ts");
  88586. /* harmony import */ var _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Builders/linesBuilder */ "./Meshes/Builders/linesBuilder.ts");
  88587. /* harmony import */ var _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Builders/polygonBuilder */ "./Meshes/Builders/polygonBuilder.ts");
  88588. /* harmony import */ var _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Builders/shapeBuilder */ "./Meshes/Builders/shapeBuilder.ts");
  88589. /* harmony import */ var _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Builders/latheBuilder */ "./Meshes/Builders/latheBuilder.ts");
  88590. /* harmony import */ var _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  88591. /* harmony import */ var _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Builders/groundBuilder */ "./Meshes/Builders/groundBuilder.ts");
  88592. /* harmony import */ var _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Builders/tubeBuilder */ "./Meshes/Builders/tubeBuilder.ts");
  88593. /* harmony import */ var _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Builders/polyhedronBuilder */ "./Meshes/Builders/polyhedronBuilder.ts");
  88594. /* harmony import */ var _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Builders/icoSphereBuilder */ "./Meshes/Builders/icoSphereBuilder.ts");
  88595. /* harmony import */ var _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Builders/decalBuilder */ "./Meshes/Builders/decalBuilder.ts");
  88596. /**
  88597. * Class containing static functions to help procedurally build meshes
  88598. */
  88599. var MeshBuilder = /** @class */ (function () {
  88600. function MeshBuilder() {
  88601. }
  88602. /**
  88603. * Creates a box mesh
  88604. * * The parameter `size` sets the size (float) of each box side (default 1)
  88605. * * You can set some different box dimensions by using the parameters `width`, `height` and `depth` (all by default have the same value of `size`)
  88606. * * 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)
  88607. * * Please read this tutorial : https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88608. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88609. * * 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
  88610. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88611. * @see https://doc.babylonjs.com/how_to/set_shapes#box
  88612. * @param name defines the name of the mesh
  88613. * @param options defines the options used to create the mesh
  88614. * @param scene defines the hosting scene
  88615. * @returns the box mesh
  88616. */
  88617. MeshBuilder.CreateBox = function (name, options, scene) {
  88618. if (scene === void 0) { scene = null; }
  88619. return _Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_2__["BoxBuilder"].CreateBox(name, options, scene);
  88620. };
  88621. /**
  88622. * Creates a sphere mesh
  88623. * * The parameter `diameter` sets the diameter size (float) of the sphere (default 1)
  88624. * * 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`)
  88625. * * The parameter `segments` sets the sphere number of horizontal stripes (positive integer, default 32)
  88626. * * 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
  88627. * * 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)
  88628. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88629. * * 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
  88630. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88631. * @param name defines the name of the mesh
  88632. * @param options defines the options used to create the mesh
  88633. * @param scene defines the hosting scene
  88634. * @returns the sphere mesh
  88635. * @see https://doc.babylonjs.com/how_to/set_shapes#sphere
  88636. */
  88637. MeshBuilder.CreateSphere = function (name, options, scene) {
  88638. return _Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_3__["SphereBuilder"].CreateSphere(name, options, scene);
  88639. };
  88640. /**
  88641. * Creates a plane polygonal mesh. By default, this is a disc
  88642. * * The parameter `radius` sets the radius size (float) of the polygon (default 0.5)
  88643. * * 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
  88644. * * 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
  88645. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88646. * * 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
  88647. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88648. * @param name defines the name of the mesh
  88649. * @param options defines the options used to create the mesh
  88650. * @param scene defines the hosting scene
  88651. * @returns the plane polygonal mesh
  88652. * @see https://doc.babylonjs.com/how_to/set_shapes#disc-or-regular-polygon
  88653. */
  88654. MeshBuilder.CreateDisc = function (name, options, scene) {
  88655. if (scene === void 0) { scene = null; }
  88656. return _Builders_discBuilder__WEBPACK_IMPORTED_MODULE_1__["DiscBuilder"].CreateDisc(name, options, scene);
  88657. };
  88658. /**
  88659. * Creates a sphere based upon an icosahedron with 20 triangular faces which can be subdivided
  88660. * * The parameter `radius` sets the radius size (float) of the icosphere (default 1)
  88661. * * 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`)
  88662. * * The parameter `subdivisions` sets the number of subdivisions (postive integer, default 4). The more subdivisions, the more faces on the icosphere whatever its size
  88663. * * 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
  88664. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88665. * * 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
  88666. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88667. * @param name defines the name of the mesh
  88668. * @param options defines the options used to create the mesh
  88669. * @param scene defines the hosting scene
  88670. * @returns the icosahedron mesh
  88671. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes#icosphere
  88672. */
  88673. MeshBuilder.CreateIcoSphere = function (name, options, scene) {
  88674. return _Builders_icoSphereBuilder__WEBPACK_IMPORTED_MODULE_15__["IcoSphereBuilder"].CreateIcoSphere(name, options, scene);
  88675. };
  88676. /**
  88677. * Creates a ribbon mesh. The ribbon is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  88678. * * The parameter `pathArray` is a required array of paths, what are each an array of successive Vector3. The pathArray parameter depicts the ribbon geometry
  88679. * * The parameter `closeArray` (boolean, default false) creates a seam between the first and the last paths of the path array
  88680. * * The parameter `closePath` (boolean, default false) creates a seam between the first and the last points of each path of the path array
  88681. * * 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
  88682. * * 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
  88683. * * 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
  88684. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88685. * * 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
  88686. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88687. * * 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
  88688. * * The parameters `colors` is an optional flat array of `Color4` to set/update each ribbon vertex with its own custom color values
  88689. * * 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
  88690. * * Moreover, you can use the parameter `color` with `instance` (to update the ribbon), only if you previously used it at creation time
  88691. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88692. * @param name defines the name of the mesh
  88693. * @param options defines the options used to create the mesh
  88694. * @param scene defines the hosting scene
  88695. * @returns the ribbon mesh
  88696. * @see https://doc.babylonjs.com/how_to/ribbon_tutorial
  88697. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88698. */
  88699. MeshBuilder.CreateRibbon = function (name, options, scene) {
  88700. if (scene === void 0) { scene = null; }
  88701. return _Builders_ribbonBuilder__WEBPACK_IMPORTED_MODULE_0__["RibbonBuilder"].CreateRibbon(name, options, scene);
  88702. };
  88703. /**
  88704. * Creates a cylinder or a cone mesh
  88705. * * The parameter `height` sets the height size (float) of the cylinder/cone (float, default 2).
  88706. * * The parameter `diameter` sets the diameter of the top and bottom cap at once (float, default 1).
  88707. * * 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.
  88708. * * The parameter `tessellation` sets the number of cylinder sides (positive integer, default 24). Set it to 3 to get a prism for instance.
  88709. * * The parameter `subdivisions` sets the number of rings along the cylinder height (positive integer, default 1).
  88710. * * The parameter `hasRings` (boolean, default false) makes the subdivisions independent from each other, so they become different faces.
  88711. * * The parameter `enclose` (boolean, default false) adds two extra faces per subdivision to a sliced cylinder to close it around its height axis.
  88712. * * The parameter `arc` (float, default 1) is the ratio (max 1) to apply to the circumference to slice the cylinder.
  88713. * * 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).
  88714. * * 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
  88715. * * Now, if the cylinder has 5 independent subdivisions (hasRings = true), n equals : top face + 5 stripe surfaces + bottom face = 2 + 5 = 7
  88716. * * 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
  88717. * * 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.
  88718. * * If `enclose` is false, a ring surface is one element.
  88719. * * If `enclose` is true, a ring surface is 3 successive elements in the array : the tubular surface, then the two closing faces.
  88720. * * 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
  88721. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88722. * * 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
  88723. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88724. * @param name defines the name of the mesh
  88725. * @param options defines the options used to create the mesh
  88726. * @param scene defines the hosting scene
  88727. * @returns the cylinder mesh
  88728. * @see https://doc.babylonjs.com/how_to/set_shapes#cylinder-or-cone
  88729. */
  88730. MeshBuilder.CreateCylinder = function (name, options, scene) {
  88731. return _Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_4__["CylinderBuilder"].CreateCylinder(name, options, scene);
  88732. };
  88733. /**
  88734. * Creates a torus mesh
  88735. * * The parameter `diameter` sets the diameter size (float) of the torus (default 1)
  88736. * * The parameter `thickness` sets the diameter size of the tube of the torus (float, default 0.5)
  88737. * * The parameter `tessellation` sets the number of torus sides (postive integer, default 16)
  88738. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88739. * * 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
  88740. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88741. * @param name defines the name of the mesh
  88742. * @param options defines the options used to create the mesh
  88743. * @param scene defines the hosting scene
  88744. * @returns the torus mesh
  88745. * @see https://doc.babylonjs.com/how_to/set_shapes#torus
  88746. */
  88747. MeshBuilder.CreateTorus = function (name, options, scene) {
  88748. return _Builders_torusBuilder__WEBPACK_IMPORTED_MODULE_5__["TorusBuilder"].CreateTorus(name, options, scene);
  88749. };
  88750. /**
  88751. * Creates a torus knot mesh
  88752. * * The parameter `radius` sets the global radius size (float) of the torus knot (default 2)
  88753. * * The parameter `radialSegments` sets the number of sides on each tube segments (positive integer, default 32)
  88754. * * The parameter `tubularSegments` sets the number of tubes to decompose the knot into (positive integer, default 32)
  88755. * * The parameters `p` and `q` are the number of windings on each axis (positive integers, default 2 and 3)
  88756. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88757. * * 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
  88758. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88759. * @param name defines the name of the mesh
  88760. * @param options defines the options used to create the mesh
  88761. * @param scene defines the hosting scene
  88762. * @returns the torus knot mesh
  88763. * @see https://doc.babylonjs.com/how_to/set_shapes#torus-knot
  88764. */
  88765. MeshBuilder.CreateTorusKnot = function (name, options, scene) {
  88766. return _Builders_torusKnotBuilder__WEBPACK_IMPORTED_MODULE_6__["TorusKnotBuilder"].CreateTorusKnot(name, options, scene);
  88767. };
  88768. /**
  88769. * Creates a line system mesh. A line system is a pool of many lines gathered in a single mesh
  88770. * * 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
  88771. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineSystem to this static function
  88772. * * The parameter `lines` is an array of lines, each line being an array of successive Vector3
  88773. * * The optional parameter `instance` is an instance of an existing LineSystem object to be updated with the passed `lines` parameter
  88774. * * The optional parameter `colors` is an array of line colors, each line colors being an array of successive Color4, one per line point
  88775. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need the alpha blending (faster)
  88776. * * 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
  88777. * * When updating an instance, remember that only line point positions can change, not the number of points, neither the number of lines
  88778. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88779. * @see https://doc.babylonjs.com/how_to/parametric_shapes#line-system
  88780. * @param name defines the name of the new line system
  88781. * @param options defines the options used to create the line system
  88782. * @param scene defines the hosting scene
  88783. * @returns a new line system mesh
  88784. */
  88785. MeshBuilder.CreateLineSystem = function (name, options, scene) {
  88786. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLineSystem(name, options, scene);
  88787. };
  88788. /**
  88789. * Creates a line mesh
  88790. * 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
  88791. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88792. * * The parameter `points` is an array successive Vector3
  88793. * * 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
  88794. * * The optional parameter `colors` is an array of successive Color4, one per line point
  88795. * * The optional parameter `useVertexAlpha` is to be set to `false` (default `true`) when you don't need alpha blending (faster)
  88796. * * When updating an instance, remember that only point positions can change, not the number of points
  88797. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88798. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lines
  88799. * @param name defines the name of the new line system
  88800. * @param options defines the options used to create the line system
  88801. * @param scene defines the hosting scene
  88802. * @returns a new line mesh
  88803. */
  88804. MeshBuilder.CreateLines = function (name, options, scene) {
  88805. if (scene === void 0) { scene = null; }
  88806. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateLines(name, options, scene);
  88807. };
  88808. /**
  88809. * Creates a dashed line mesh
  88810. * * 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
  88811. * * Like every other parametric shape, it is dynamically updatable by passing an existing instance of LineMesh to this static function
  88812. * * The parameter `points` is an array successive Vector3
  88813. * * The parameter `dashNb` is the intended total number of dashes (positive integer, default 200)
  88814. * * The parameter `dashSize` is the size of the dashes relatively the dash number (positive float, default 3)
  88815. * * The parameter `gapSize` is the size of the gap between two successive dashes relatively the dash number (positive float, default 1)
  88816. * * 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
  88817. * * When updating an instance, remember that only point positions can change, not the number of points
  88818. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88819. * @param name defines the name of the mesh
  88820. * @param options defines the options used to create the mesh
  88821. * @param scene defines the hosting scene
  88822. * @returns the dashed line mesh
  88823. * @see https://doc.babylonjs.com/how_to/parametric_shapes#dashed-lines
  88824. */
  88825. MeshBuilder.CreateDashedLines = function (name, options, scene) {
  88826. if (scene === void 0) { scene = null; }
  88827. return _Builders_linesBuilder__WEBPACK_IMPORTED_MODULE_7__["LinesBuilder"].CreateDashedLines(name, options, scene);
  88828. };
  88829. /**
  88830. * 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.
  88831. * * 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.
  88832. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88833. * * 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.
  88834. * * The parameter `scale` (float, default 1) is the value to scale the shape.
  88835. * * 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
  88836. * * 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
  88837. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape.
  88838. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88839. * * 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
  88840. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture.
  88841. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88842. * @param name defines the name of the mesh
  88843. * @param options defines the options used to create the mesh
  88844. * @param scene defines the hosting scene
  88845. * @returns the extruded shape mesh
  88846. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88847. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88848. */
  88849. MeshBuilder.ExtrudeShape = function (name, options, scene) {
  88850. if (scene === void 0) { scene = null; }
  88851. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShape(name, options, scene);
  88852. };
  88853. /**
  88854. * Creates an custom extruded shape mesh.
  88855. * The custom extrusion is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters.
  88856. * * 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.
  88857. * * The parameter `path` is a required array of successive Vector3. This is the axis curve the shape is extruded along.
  88858. * * 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
  88859. * * It must returns a float value that will be the rotation in radians applied to the shape on each path point.
  88860. * * 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
  88861. * * It must returns a float value that will be the scale value applied to the shape on each path point
  88862. * * The parameter `ribbonClosePath` (boolean, default false) forces the extrusion underlying ribbon to close all the paths in its `pathArray`
  88863. * * The parameter `ribbonCloseArray` (boolean, default false) forces the extrusion underlying ribbon to close its `pathArray`
  88864. * * 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
  88865. * * 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
  88866. * * Remember you can only change the shape or path point positions, not their number when updating an extruded shape
  88867. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88868. * * 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
  88869. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88870. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88871. * @param name defines the name of the mesh
  88872. * @param options defines the options used to create the mesh
  88873. * @param scene defines the hosting scene
  88874. * @returns the custom extruded shape mesh
  88875. * @see https://doc.babylonjs.com/how_to/parametric_shapes#custom-extruded-shapes
  88876. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  88877. * @see https://doc.babylonjs.com/how_to/parametric_shapes#extruded-shapes
  88878. */
  88879. MeshBuilder.ExtrudeShapeCustom = function (name, options, scene) {
  88880. return _Builders_shapeBuilder__WEBPACK_IMPORTED_MODULE_9__["ShapeBuilder"].ExtrudeShapeCustom(name, options, scene);
  88881. };
  88882. /**
  88883. * Creates lathe mesh.
  88884. * The lathe is a shape with a symetry axis : a 2D model shape is rotated around this axis to design the lathe
  88885. * * 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
  88886. * * The parameter `radius` (positive float, default 1) is the radius value of the lathe
  88887. * * The parameter `tessellation` (positive integer, default 64) is the side number of the lathe
  88888. * * The parameter `clip` (positive integer, default 0) is the number of sides to not create without effecting the general shape of the sides
  88889. * * 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
  88890. * * The parameter `closed` (boolean, default true) opens/closes the lathe circumference. This should be set to false when used with the parameter "arc"
  88891. * * 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
  88892. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88893. * * 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
  88894. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  88895. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88896. * @param name defines the name of the mesh
  88897. * @param options defines the options used to create the mesh
  88898. * @param scene defines the hosting scene
  88899. * @returns the lathe mesh
  88900. * @see https://doc.babylonjs.com/how_to/parametric_shapes#lathe
  88901. */
  88902. MeshBuilder.CreateLathe = function (name, options, scene) {
  88903. return _Builders_latheBuilder__WEBPACK_IMPORTED_MODULE_10__["LatheBuilder"].CreateLathe(name, options, scene);
  88904. };
  88905. /**
  88906. * Creates a plane mesh
  88907. * * The parameter `size` sets the size (float) of both sides of the plane at once (default 1)
  88908. * * You can set some different plane dimensions by using the parameters `width` and `height` (both by default have the same value of `size`)
  88909. * * The parameter `sourcePlane` is a Plane instance. It builds a mesh plane from a Math plane
  88910. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  88911. * * 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
  88912. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88913. * @param name defines the name of the mesh
  88914. * @param options defines the options used to create the mesh
  88915. * @param scene defines the hosting scene
  88916. * @returns the plane mesh
  88917. * @see https://doc.babylonjs.com/how_to/set_shapes#plane
  88918. */
  88919. MeshBuilder.CreatePlane = function (name, options, scene) {
  88920. return _Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_11__["PlaneBuilder"].CreatePlane(name, options, scene);
  88921. };
  88922. /**
  88923. * Creates a ground mesh
  88924. * * The parameters `width` and `height` (floats, default 1) set the width and height sizes of the ground
  88925. * * The parameter `subdivisions` (positive integer) sets the number of subdivisions per side
  88926. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88927. * @param name defines the name of the mesh
  88928. * @param options defines the options used to create the mesh
  88929. * @param scene defines the hosting scene
  88930. * @returns the ground mesh
  88931. * @see https://doc.babylonjs.com/how_to/set_shapes#ground
  88932. */
  88933. MeshBuilder.CreateGround = function (name, options, scene) {
  88934. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGround(name, options, scene);
  88935. };
  88936. /**
  88937. * Creates a tiled ground mesh
  88938. * * The parameters `xmin` and `xmax` (floats, default -1 and 1) set the ground minimum and maximum X coordinates
  88939. * * The parameters `zmin` and `zmax` (floats, default -1 and 1) set the ground minimum and maximum Z coordinates
  88940. * * 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
  88941. * * 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
  88942. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88943. * @param name defines the name of the mesh
  88944. * @param options defines the options used to create the mesh
  88945. * @param scene defines the hosting scene
  88946. * @returns the tiled ground mesh
  88947. * @see https://doc.babylonjs.com/how_to/set_shapes#tiled-ground
  88948. */
  88949. MeshBuilder.CreateTiledGround = function (name, options, scene) {
  88950. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateTiledGround(name, options, scene);
  88951. };
  88952. /**
  88953. * Creates a ground mesh from a height map
  88954. * * The parameter `url` sets the URL of the height map image resource.
  88955. * * The parameters `width` and `height` (positive floats, default 10) set the ground width and height sizes.
  88956. * * The parameter `subdivisions` (positive integer, default 1) sets the number of subdivision per side.
  88957. * * The parameter `minHeight` (float, default 0) is the minimum altitude on the ground.
  88958. * * The parameter `maxHeight` (float, default 1) is the maximum altitude on the ground.
  88959. * * 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.
  88960. * * 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).
  88961. * * The parameter `alphaFilter` will filter any data where the alpha channel is below this value, defaults 0 (all data visible)
  88962. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created.
  88963. * @param name defines the name of the mesh
  88964. * @param url defines the url to the height map
  88965. * @param options defines the options used to create the mesh
  88966. * @param scene defines the hosting scene
  88967. * @returns the ground mesh
  88968. * @see https://doc.babylonjs.com/babylon101/height_map
  88969. * @see https://doc.babylonjs.com/how_to/set_shapes#ground-from-a-height-map
  88970. */
  88971. MeshBuilder.CreateGroundFromHeightMap = function (name, url, options, scene) {
  88972. return _Builders_groundBuilder__WEBPACK_IMPORTED_MODULE_12__["GroundBuilder"].CreateGroundFromHeightMap(name, url, options, scene);
  88973. };
  88974. /**
  88975. * Creates a polygon mesh
  88976. * The polygon's shape will depend on the input parameters and is constructed parallel to a ground mesh
  88977. * * 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
  88978. * * You can set the mesh side orientation with the values : Mesh.FRONTSIDE (default), Mesh.BACKSIDE or Mesh.DOUBLESIDE
  88979. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  88980. * * 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)
  88981. * * Remember you can only change the shape positions, not their number when updating a polygon
  88982. * @param name defines the name of the mesh
  88983. * @param options defines the options used to create the mesh
  88984. * @param scene defines the hosting scene
  88985. * @param earcutInjection can be used to inject your own earcut reference
  88986. * @returns the polygon mesh
  88987. */
  88988. MeshBuilder.CreatePolygon = function (name, options, scene, earcutInjection) {
  88989. if (earcutInjection === void 0) { earcutInjection = earcut; }
  88990. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].CreatePolygon(name, options, scene, earcutInjection);
  88991. };
  88992. /**
  88993. * Creates an extruded polygon mesh, with depth in the Y direction.
  88994. * * 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)
  88995. * @see https://doc.babylonjs.com/how_to/createbox_per_face_textures_and_colors
  88996. * @param name defines the name of the mesh
  88997. * @param options defines the options used to create the mesh
  88998. * @param scene defines the hosting scene
  88999. * @param earcutInjection can be used to inject your own earcut reference
  89000. * @returns the polygon mesh
  89001. */
  89002. MeshBuilder.ExtrudePolygon = function (name, options, scene, earcutInjection) {
  89003. if (earcutInjection === void 0) { earcutInjection = earcut; }
  89004. return _Builders_polygonBuilder__WEBPACK_IMPORTED_MODULE_8__["PolygonBuilder"].ExtrudePolygon(name, options, scene, earcutInjection);
  89005. };
  89006. /**
  89007. * Creates a tube mesh.
  89008. * The tube is a parametric shape. It has no predefined shape. Its final shape will depend on the input parameters
  89009. * * The parameter `path` is a required array of successive Vector3. It is the curve used as the axis of the tube
  89010. * * The parameter `radius` (positive float, default 1) sets the tube radius size
  89011. * * The parameter `tessellation` (positive float, default 64) is the number of sides on the tubular surface
  89012. * * The parameter `radiusFunction` (javascript function, default null) is a vanilla javascript function. If it is not null, it overwrittes the parameter `radius`
  89013. * * 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)
  89014. * * The parameter `arc` (positive float, maximum 1, default 1) is the ratio to apply to the tube circumference : 2 x PI x arc
  89015. * * 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
  89016. * * 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
  89017. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89018. * * 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
  89019. * * The optional parameter `invertUV` (boolean, default false) swaps in the geometry the U and V coordinates to apply a texture
  89020. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89021. * @param name defines the name of the mesh
  89022. * @param options defines the options used to create the mesh
  89023. * @param scene defines the hosting scene
  89024. * @returns the tube mesh
  89025. * @see https://doc.babylonjs.com/how_to/parametric_shapes
  89026. * @see https://doc.babylonjs.com/how_to/set_shapes#tube
  89027. */
  89028. MeshBuilder.CreateTube = function (name, options, scene) {
  89029. return _Builders_tubeBuilder__WEBPACK_IMPORTED_MODULE_13__["TubeBuilder"].CreateTube(name, options, scene);
  89030. };
  89031. /**
  89032. * Creates a polyhedron mesh
  89033. * * 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
  89034. * * The parameter `size` (positive float, default 1) sets the polygon size
  89035. * * You can overwrite the `size` on each dimension bu using the parameters `sizeX`, `sizeY` or `sizeZ` (positive floats, default to `size` value)
  89036. * * 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`
  89037. * * 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
  89038. * * 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)`)
  89039. * * 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
  89040. * * 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
  89041. * * You can also set the mesh side orientation with the values : BABYLON.Mesh.FRONTSIDE (default), BABYLON.Mesh.BACKSIDE or BABYLON.Mesh.DOUBLESIDE
  89042. * * 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
  89043. * * The mesh can be set to updatable with the boolean parameter `updatable` (default false) if its internal geometry is supposed to change once created
  89044. * @param name defines the name of the mesh
  89045. * @param options defines the options used to create the mesh
  89046. * @param scene defines the hosting scene
  89047. * @returns the polyhedron mesh
  89048. * @see https://doc.babylonjs.com/how_to/polyhedra_shapes
  89049. */
  89050. MeshBuilder.CreatePolyhedron = function (name, options, scene) {
  89051. return _Builders_polyhedronBuilder__WEBPACK_IMPORTED_MODULE_14__["PolyhedronBuilder"].CreatePolyhedron(name, options, scene);
  89052. };
  89053. /**
  89054. * Creates a decal mesh.
  89055. * 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
  89056. * * The parameter `position` (Vector3, default `(0, 0, 0)`) sets the position of the decal in World coordinates
  89057. * * The parameter `normal` (Vector3, default `Vector3.Up`) sets the normal of the mesh where the decal is applied onto in World coordinates
  89058. * * The parameter `size` (Vector3, default `(1, 1, 1)`) sets the decal scaling
  89059. * * The parameter `angle` (float in radian, default 0) sets the angle to rotate the decal
  89060. * @param name defines the name of the mesh
  89061. * @param sourceMesh defines the mesh where the decal must be applied
  89062. * @param options defines the options used to create the mesh
  89063. * @param scene defines the hosting scene
  89064. * @returns the decal mesh
  89065. * @see https://doc.babylonjs.com/how_to/decals
  89066. */
  89067. MeshBuilder.CreateDecal = function (name, sourceMesh, options) {
  89068. return _Builders_decalBuilder__WEBPACK_IMPORTED_MODULE_16__["DecalBuilder"].CreateDecal(name, sourceMesh, options);
  89069. };
  89070. return MeshBuilder;
  89071. }());
  89072. /***/ }),
  89073. /***/ "./Meshes/meshSimplification.ts":
  89074. /*!**************************************!*\
  89075. !*** ./Meshes/meshSimplification.ts ***!
  89076. \**************************************/
  89077. /*! exports provided: SimplificationSettings, SimplificationQueue, SimplificationType */
  89078. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89079. "use strict";
  89080. __webpack_require__.r(__webpack_exports__);
  89081. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return SimplificationSettings; });
  89082. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return SimplificationQueue; });
  89083. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return SimplificationType; });
  89084. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89085. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89086. /* harmony import */ var _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/subMesh */ "./Meshes/subMesh.ts");
  89087. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89088. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  89089. /**
  89090. * Class used to specify simplification options
  89091. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  89092. */
  89093. var SimplificationSettings = /** @class */ (function () {
  89094. /**
  89095. * Creates a SimplificationSettings
  89096. * @param quality expected quality
  89097. * @param distance distance when this optimized version should be used
  89098. * @param optimizeMesh already optimized mesh
  89099. */
  89100. function SimplificationSettings(
  89101. /** expected quality */
  89102. quality,
  89103. /** distance when this optimized version should be used */
  89104. distance,
  89105. /** already optimized mesh */
  89106. optimizeMesh) {
  89107. this.quality = quality;
  89108. this.distance = distance;
  89109. this.optimizeMesh = optimizeMesh;
  89110. }
  89111. return SimplificationSettings;
  89112. }());
  89113. /**
  89114. * Queue used to order the simplification tasks
  89115. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  89116. */
  89117. var SimplificationQueue = /** @class */ (function () {
  89118. /**
  89119. * Creates a new queue
  89120. */
  89121. function SimplificationQueue() {
  89122. this.running = false;
  89123. this._simplificationArray = [];
  89124. }
  89125. /**
  89126. * Adds a new simplification task
  89127. * @param task defines a task to add
  89128. */
  89129. SimplificationQueue.prototype.addTask = function (task) {
  89130. this._simplificationArray.push(task);
  89131. };
  89132. /**
  89133. * Execute next task
  89134. */
  89135. SimplificationQueue.prototype.executeNext = function () {
  89136. var task = this._simplificationArray.pop();
  89137. if (task) {
  89138. this.running = true;
  89139. this.runSimplification(task);
  89140. }
  89141. else {
  89142. this.running = false;
  89143. }
  89144. };
  89145. /**
  89146. * Execute a simplification task
  89147. * @param task defines the task to run
  89148. */
  89149. SimplificationQueue.prototype.runSimplification = function (task) {
  89150. var _this = this;
  89151. if (task.parallelProcessing) {
  89152. //parallel simplifier
  89153. task.settings.forEach(function (setting) {
  89154. var simplifier = _this.getSimplifier(task);
  89155. simplifier.simplify(setting, function (newMesh) {
  89156. task.mesh.addLODLevel(setting.distance, newMesh);
  89157. newMesh.isVisible = true;
  89158. //check if it is the last
  89159. if (setting.quality === task.settings[task.settings.length - 1].quality && task.successCallback) {
  89160. //all done, run the success callback.
  89161. task.successCallback();
  89162. }
  89163. _this.executeNext();
  89164. });
  89165. });
  89166. }
  89167. else {
  89168. //single simplifier.
  89169. var simplifier = this.getSimplifier(task);
  89170. var runDecimation = function (setting, callback) {
  89171. simplifier.simplify(setting, function (newMesh) {
  89172. task.mesh.addLODLevel(setting.distance, newMesh);
  89173. newMesh.isVisible = true;
  89174. //run the next quality level
  89175. callback();
  89176. });
  89177. };
  89178. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(task.settings.length, function (loop) {
  89179. runDecimation(task.settings[loop.index], function () {
  89180. loop.executeNext();
  89181. });
  89182. }, function () {
  89183. //execution ended, run the success callback.
  89184. if (task.successCallback) {
  89185. task.successCallback();
  89186. }
  89187. _this.executeNext();
  89188. });
  89189. }
  89190. };
  89191. SimplificationQueue.prototype.getSimplifier = function (task) {
  89192. switch (task.simplificationType) {
  89193. case SimplificationType.QUADRATIC:
  89194. default:
  89195. return new QuadraticErrorSimplification(task.mesh);
  89196. }
  89197. };
  89198. return SimplificationQueue;
  89199. }());
  89200. /**
  89201. * The implemented types of simplification
  89202. * At the moment only Quadratic Error Decimation is implemented
  89203. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  89204. */
  89205. var SimplificationType;
  89206. (function (SimplificationType) {
  89207. /** Quadratic error decimation */
  89208. SimplificationType[SimplificationType["QUADRATIC"] = 0] = "QUADRATIC";
  89209. })(SimplificationType || (SimplificationType = {}));
  89210. var DecimationTriangle = /** @class */ (function () {
  89211. function DecimationTriangle(vertices) {
  89212. this.vertices = vertices;
  89213. this.error = new Array(4);
  89214. this.deleted = false;
  89215. this.isDirty = false;
  89216. this.deletePending = false;
  89217. this.borderFactor = 0;
  89218. }
  89219. return DecimationTriangle;
  89220. }());
  89221. var DecimationVertex = /** @class */ (function () {
  89222. function DecimationVertex(position, id) {
  89223. this.position = position;
  89224. this.id = id;
  89225. this.isBorder = true;
  89226. this.q = new QuadraticMatrix();
  89227. this.triangleCount = 0;
  89228. this.triangleStart = 0;
  89229. this.originalOffsets = [];
  89230. }
  89231. DecimationVertex.prototype.updatePosition = function (newPosition) {
  89232. this.position.copyFrom(newPosition);
  89233. };
  89234. return DecimationVertex;
  89235. }());
  89236. var QuadraticMatrix = /** @class */ (function () {
  89237. function QuadraticMatrix(data) {
  89238. this.data = new Array(10);
  89239. for (var i = 0; i < 10; ++i) {
  89240. if (data && data[i]) {
  89241. this.data[i] = data[i];
  89242. }
  89243. else {
  89244. this.data[i] = 0;
  89245. }
  89246. }
  89247. }
  89248. QuadraticMatrix.prototype.det = function (a11, a12, a13, a21, a22, a23, a31, a32, a33) {
  89249. var det = this.data[a11] * this.data[a22] * this.data[a33] + this.data[a13] * this.data[a21] * this.data[a32] +
  89250. this.data[a12] * this.data[a23] * this.data[a31] - this.data[a13] * this.data[a22] * this.data[a31] -
  89251. this.data[a11] * this.data[a23] * this.data[a32] - this.data[a12] * this.data[a21] * this.data[a33];
  89252. return det;
  89253. };
  89254. QuadraticMatrix.prototype.addInPlace = function (matrix) {
  89255. for (var i = 0; i < 10; ++i) {
  89256. this.data[i] += matrix.data[i];
  89257. }
  89258. };
  89259. QuadraticMatrix.prototype.addArrayInPlace = function (data) {
  89260. for (var i = 0; i < 10; ++i) {
  89261. this.data[i] += data[i];
  89262. }
  89263. };
  89264. QuadraticMatrix.prototype.add = function (matrix) {
  89265. var m = new QuadraticMatrix();
  89266. for (var i = 0; i < 10; ++i) {
  89267. m.data[i] = this.data[i] + matrix.data[i];
  89268. }
  89269. return m;
  89270. };
  89271. QuadraticMatrix.FromData = function (a, b, c, d) {
  89272. return new QuadraticMatrix(QuadraticMatrix.DataFromNumbers(a, b, c, d));
  89273. };
  89274. //returning an array to avoid garbage collection
  89275. QuadraticMatrix.DataFromNumbers = function (a, b, c, d) {
  89276. return [a * a, a * b, a * c, a * d, b * b, b * c, b * d, c * c, c * d, d * d];
  89277. };
  89278. return QuadraticMatrix;
  89279. }());
  89280. var Reference = /** @class */ (function () {
  89281. function Reference(vertexId, triangleId) {
  89282. this.vertexId = vertexId;
  89283. this.triangleId = triangleId;
  89284. }
  89285. return Reference;
  89286. }());
  89287. /**
  89288. * An implementation of the Quadratic Error simplification algorithm.
  89289. * Original paper : http://www1.cs.columbia.edu/~cs4162/html05s/garland97.pdf
  89290. * Ported mostly from QSlim and http://voxels.blogspot.de/2014/05/quadric-mesh-simplification-with-source.html to babylon JS
  89291. * @author RaananW
  89292. * @see http://doc.babylonjs.com/how_to/in-browser_mesh_simplification
  89293. */
  89294. var QuadraticErrorSimplification = /** @class */ (function () {
  89295. function QuadraticErrorSimplification(_mesh) {
  89296. this._mesh = _mesh;
  89297. this.syncIterations = 5000;
  89298. this.aggressiveness = 7;
  89299. this.decimationIterations = 100;
  89300. this.boundingBoxEpsilon = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Epsilon"];
  89301. }
  89302. QuadraticErrorSimplification.prototype.simplify = function (settings, successCallback) {
  89303. var _this = this;
  89304. this.initDecimatedMesh();
  89305. //iterating through the submeshes array, one after the other.
  89306. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this._mesh.subMeshes.length, function (loop) {
  89307. _this.initWithMesh(loop.index, function () {
  89308. _this.runDecimation(settings, loop.index, function () {
  89309. loop.executeNext();
  89310. });
  89311. }, settings.optimizeMesh);
  89312. }, function () {
  89313. setTimeout(function () {
  89314. successCallback(_this._reconstructedMesh);
  89315. }, 0);
  89316. });
  89317. };
  89318. QuadraticErrorSimplification.prototype.runDecimation = function (settings, submeshIndex, successCallback) {
  89319. var _this = this;
  89320. var targetCount = ~~(this.triangles.length * settings.quality);
  89321. var deletedTriangles = 0;
  89322. var triangleCount = this.triangles.length;
  89323. var iterationFunction = function (iteration, callback) {
  89324. setTimeout(function () {
  89325. if (iteration % 5 === 0) {
  89326. _this.updateMesh(iteration === 0);
  89327. }
  89328. for (var i = 0; i < _this.triangles.length; ++i) {
  89329. _this.triangles[i].isDirty = false;
  89330. }
  89331. var threshold = 0.000000001 * Math.pow((iteration + 3), _this.aggressiveness);
  89332. var trianglesIterator = function (i) {
  89333. var tIdx = ~~(((_this.triangles.length / 2) + i) % _this.triangles.length);
  89334. var t = _this.triangles[tIdx];
  89335. if (!t) {
  89336. return;
  89337. }
  89338. if (t.error[3] > threshold || t.deleted || t.isDirty) {
  89339. return;
  89340. }
  89341. for (var j = 0; j < 3; ++j) {
  89342. if (t.error[j] < threshold) {
  89343. var deleted0 = [];
  89344. var deleted1 = [];
  89345. var v0 = t.vertices[j];
  89346. var v1 = t.vertices[(j + 1) % 3];
  89347. if (v0.isBorder || v1.isBorder) {
  89348. continue;
  89349. }
  89350. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89351. // var n = Vector3.Zero();
  89352. // var uv = Vector2.Zero();
  89353. // var color = new Color4(0, 0, 0, 1);
  89354. _this.calculateError(v0, v1, p);
  89355. var delTr = new Array();
  89356. if (_this.isFlipped(v0, v1, p, deleted0, delTr)) {
  89357. continue;
  89358. }
  89359. if (_this.isFlipped(v1, v0, p, deleted1, delTr)) {
  89360. continue;
  89361. }
  89362. if (deleted0.indexOf(true) < 0 || deleted1.indexOf(true) < 0) {
  89363. continue;
  89364. }
  89365. var uniqueArray = new Array();
  89366. delTr.forEach(function (deletedT) {
  89367. if (uniqueArray.indexOf(deletedT) === -1) {
  89368. deletedT.deletePending = true;
  89369. uniqueArray.push(deletedT);
  89370. }
  89371. });
  89372. if (uniqueArray.length % 2 !== 0) {
  89373. continue;
  89374. }
  89375. v0.q = v1.q.add(v0.q);
  89376. v0.updatePosition(p);
  89377. var tStart = _this.references.length;
  89378. deletedTriangles = _this.updateTriangles(v0, v0, deleted0, deletedTriangles);
  89379. deletedTriangles = _this.updateTriangles(v0, v1, deleted1, deletedTriangles);
  89380. var tCount = _this.references.length - tStart;
  89381. if (tCount <= v0.triangleCount) {
  89382. if (tCount) {
  89383. for (var c = 0; c < tCount; c++) {
  89384. _this.references[v0.triangleStart + c] = _this.references[tStart + c];
  89385. }
  89386. }
  89387. }
  89388. else {
  89389. v0.triangleStart = tStart;
  89390. }
  89391. v0.triangleCount = tCount;
  89392. break;
  89393. }
  89394. }
  89395. };
  89396. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, trianglesIterator, callback, function () { return (triangleCount - deletedTriangles <= targetCount); });
  89397. }, 0);
  89398. };
  89399. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].Run(this.decimationIterations, function (loop) {
  89400. if (triangleCount - deletedTriangles <= targetCount) {
  89401. loop.breakLoop();
  89402. }
  89403. else {
  89404. iterationFunction(loop.index, function () {
  89405. loop.executeNext();
  89406. });
  89407. }
  89408. }, function () {
  89409. setTimeout(function () {
  89410. //reconstruct this part of the mesh
  89411. _this.reconstructMesh(submeshIndex);
  89412. successCallback();
  89413. }, 0);
  89414. });
  89415. };
  89416. QuadraticErrorSimplification.prototype.initWithMesh = function (submeshIndex, callback, optimizeMesh) {
  89417. var _this = this;
  89418. this.vertices = [];
  89419. this.triangles = [];
  89420. var positionData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  89421. var indices = this._mesh.getIndices();
  89422. var submesh = this._mesh.subMeshes[submeshIndex];
  89423. var findInVertices = function (positionToSearch) {
  89424. if (optimizeMesh) {
  89425. for (var ii = 0; ii < _this.vertices.length; ++ii) {
  89426. if (_this.vertices[ii].position.equals(positionToSearch)) {
  89427. return _this.vertices[ii];
  89428. }
  89429. }
  89430. }
  89431. return null;
  89432. };
  89433. var vertexReferences = [];
  89434. var vertexInit = function (i) {
  89435. if (!positionData) {
  89436. return;
  89437. }
  89438. var offset = i + submesh.verticesStart;
  89439. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positionData, offset * 3);
  89440. var vertex = findInVertices(position) || new DecimationVertex(position, _this.vertices.length);
  89441. vertex.originalOffsets.push(offset);
  89442. if (vertex.id === _this.vertices.length) {
  89443. _this.vertices.push(vertex);
  89444. }
  89445. vertexReferences.push(vertex.id);
  89446. };
  89447. //var totalVertices = mesh.getTotalVertices();
  89448. var totalVertices = submesh.verticesCount;
  89449. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(totalVertices, (this.syncIterations / 4) >> 0, vertexInit, function () {
  89450. var indicesInit = function (i) {
  89451. if (!indices) {
  89452. return;
  89453. }
  89454. var offset = (submesh.indexStart / 3) + i;
  89455. var pos = (offset * 3);
  89456. var i0 = indices[pos + 0];
  89457. var i1 = indices[pos + 1];
  89458. var i2 = indices[pos + 2];
  89459. var v0 = _this.vertices[vertexReferences[i0 - submesh.verticesStart]];
  89460. var v1 = _this.vertices[vertexReferences[i1 - submesh.verticesStart]];
  89461. var v2 = _this.vertices[vertexReferences[i2 - submesh.verticesStart]];
  89462. var triangle = new DecimationTriangle([v0, v1, v2]);
  89463. triangle.originalOffset = pos;
  89464. _this.triangles.push(triangle);
  89465. };
  89466. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(submesh.indexCount / 3, _this.syncIterations, indicesInit, function () {
  89467. _this.init(callback);
  89468. });
  89469. });
  89470. };
  89471. QuadraticErrorSimplification.prototype.init = function (callback) {
  89472. var _this = this;
  89473. var triangleInit1 = function (i) {
  89474. var t = _this.triangles[i];
  89475. 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();
  89476. for (var j = 0; j < 3; j++) {
  89477. 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))));
  89478. }
  89479. };
  89480. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(this.triangles.length, this.syncIterations, triangleInit1, function () {
  89481. var triangleInit2 = function (i) {
  89482. var t = _this.triangles[i];
  89483. for (var j = 0; j < 3; ++j) {
  89484. t.error[j] = _this.calculateError(t.vertices[j], t.vertices[(j + 1) % 3]);
  89485. }
  89486. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89487. };
  89488. _Misc_tools__WEBPACK_IMPORTED_MODULE_4__["AsyncLoop"].SyncAsyncForLoop(_this.triangles.length, _this.syncIterations, triangleInit2, function () {
  89489. callback();
  89490. });
  89491. });
  89492. };
  89493. QuadraticErrorSimplification.prototype.reconstructMesh = function (submeshIndex) {
  89494. var newTriangles = [];
  89495. var i;
  89496. for (i = 0; i < this.vertices.length; ++i) {
  89497. this.vertices[i].triangleCount = 0;
  89498. }
  89499. var t;
  89500. var j;
  89501. for (i = 0; i < this.triangles.length; ++i) {
  89502. if (!this.triangles[i].deleted) {
  89503. t = this.triangles[i];
  89504. for (j = 0; j < 3; ++j) {
  89505. t.vertices[j].triangleCount = 1;
  89506. }
  89507. newTriangles.push(t);
  89508. }
  89509. }
  89510. var newPositionData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind) || []);
  89511. var newNormalData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind) || []);
  89512. var newUVsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind) || []);
  89513. var newColorsData = (this._reconstructedMesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind) || []);
  89514. var normalData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  89515. var uvs = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  89516. var colorsData = this._mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  89517. var vertexCount = 0;
  89518. for (i = 0; i < this.vertices.length; ++i) {
  89519. var vertex = this.vertices[i];
  89520. vertex.id = vertexCount;
  89521. if (vertex.triangleCount) {
  89522. vertex.originalOffsets.forEach(function (originalOffset) {
  89523. if (!normalData) {
  89524. return;
  89525. }
  89526. newPositionData.push(vertex.position.x);
  89527. newPositionData.push(vertex.position.y);
  89528. newPositionData.push(vertex.position.z);
  89529. newNormalData.push(normalData[originalOffset * 3]);
  89530. newNormalData.push(normalData[(originalOffset * 3) + 1]);
  89531. newNormalData.push(normalData[(originalOffset * 3) + 2]);
  89532. if (uvs && uvs.length) {
  89533. newUVsData.push(uvs[(originalOffset * 2)]);
  89534. newUVsData.push(uvs[(originalOffset * 2) + 1]);
  89535. }
  89536. else if (colorsData && colorsData.length) {
  89537. newColorsData.push(colorsData[(originalOffset * 4)]);
  89538. newColorsData.push(colorsData[(originalOffset * 4) + 1]);
  89539. newColorsData.push(colorsData[(originalOffset * 4) + 2]);
  89540. newColorsData.push(colorsData[(originalOffset * 4) + 3]);
  89541. }
  89542. ++vertexCount;
  89543. });
  89544. }
  89545. }
  89546. var startingIndex = this._reconstructedMesh.getTotalIndices();
  89547. var startingVertex = this._reconstructedMesh.getTotalVertices();
  89548. var submeshesArray = this._reconstructedMesh.subMeshes;
  89549. this._reconstructedMesh.subMeshes = [];
  89550. var newIndicesArray = this._reconstructedMesh.getIndices(); //[];
  89551. var originalIndices = this._mesh.getIndices();
  89552. for (i = 0; i < newTriangles.length; ++i) {
  89553. t = newTriangles[i]; //now get the new referencing point for each vertex
  89554. [0, 1, 2].forEach(function (idx) {
  89555. var id = originalIndices[t.originalOffset + idx];
  89556. var offset = t.vertices[idx].originalOffsets.indexOf(id);
  89557. if (offset < 0) {
  89558. offset = 0;
  89559. }
  89560. newIndicesArray.push(t.vertices[idx].id + offset + startingVertex);
  89561. });
  89562. }
  89563. //overwriting the old vertex buffers and indices.
  89564. this._reconstructedMesh.setIndices(newIndicesArray);
  89565. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, newPositionData);
  89566. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, newNormalData);
  89567. if (newUVsData.length > 0) {
  89568. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, newUVsData);
  89569. }
  89570. if (newColorsData.length > 0) {
  89571. this._reconstructedMesh.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, newColorsData);
  89572. }
  89573. //create submesh
  89574. var originalSubmesh = this._mesh.subMeshes[submeshIndex];
  89575. if (submeshIndex > 0) {
  89576. this._reconstructedMesh.subMeshes = [];
  89577. submeshesArray.forEach(function (submesh) {
  89578. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(submesh.materialIndex, submesh.verticesStart, submesh.verticesCount, /* 0, newPositionData.length/3, */ submesh.indexStart, submesh.indexCount, submesh.getMesh());
  89579. });
  89580. _Meshes_subMesh__WEBPACK_IMPORTED_MODULE_2__["SubMesh"].AddToMesh(originalSubmesh.materialIndex, startingVertex, vertexCount, /* 0, newPositionData.length / 3, */ startingIndex, newTriangles.length * 3, this._reconstructedMesh);
  89581. }
  89582. };
  89583. QuadraticErrorSimplification.prototype.initDecimatedMesh = function () {
  89584. this._reconstructedMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this._mesh.name + "Decimated", this._mesh.getScene());
  89585. this._reconstructedMesh.material = this._mesh.material;
  89586. this._reconstructedMesh.parent = this._mesh.parent;
  89587. this._reconstructedMesh.isVisible = false;
  89588. this._reconstructedMesh.renderingGroupId = this._mesh.renderingGroupId;
  89589. };
  89590. QuadraticErrorSimplification.prototype.isFlipped = function (vertex1, vertex2, point, deletedArray, delTr) {
  89591. for (var i = 0; i < vertex1.triangleCount; ++i) {
  89592. var t = this.triangles[this.references[vertex1.triangleStart + i].triangleId];
  89593. if (t.deleted) {
  89594. continue;
  89595. }
  89596. var s = this.references[vertex1.triangleStart + i].vertexId;
  89597. var v1 = t.vertices[(s + 1) % 3];
  89598. var v2 = t.vertices[(s + 2) % 3];
  89599. if ((v1 === vertex2 || v2 === vertex2)) {
  89600. deletedArray[i] = true;
  89601. delTr.push(t);
  89602. continue;
  89603. }
  89604. var d1 = v1.position.subtract(point);
  89605. d1 = d1.normalize();
  89606. var d2 = v2.position.subtract(point);
  89607. d2 = d2.normalize();
  89608. if (Math.abs(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(d1, d2)) > 0.999) {
  89609. return true;
  89610. }
  89611. var normal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Cross(d1, d2).normalize();
  89612. deletedArray[i] = false;
  89613. if (_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Dot(normal, t.normal) < 0.2) {
  89614. return true;
  89615. }
  89616. }
  89617. return false;
  89618. };
  89619. QuadraticErrorSimplification.prototype.updateTriangles = function (origVertex, vertex, deletedArray, deletedTriangles) {
  89620. var newDeleted = deletedTriangles;
  89621. for (var i = 0; i < vertex.triangleCount; ++i) {
  89622. var ref = this.references[vertex.triangleStart + i];
  89623. var t = this.triangles[ref.triangleId];
  89624. if (t.deleted) {
  89625. continue;
  89626. }
  89627. if (deletedArray[i] && t.deletePending) {
  89628. t.deleted = true;
  89629. newDeleted++;
  89630. continue;
  89631. }
  89632. t.vertices[ref.vertexId] = origVertex;
  89633. t.isDirty = true;
  89634. t.error[0] = this.calculateError(t.vertices[0], t.vertices[1]) + (t.borderFactor / 2);
  89635. t.error[1] = this.calculateError(t.vertices[1], t.vertices[2]) + (t.borderFactor / 2);
  89636. t.error[2] = this.calculateError(t.vertices[2], t.vertices[0]) + (t.borderFactor / 2);
  89637. t.error[3] = Math.min(t.error[0], t.error[1], t.error[2]);
  89638. this.references.push(ref);
  89639. }
  89640. return newDeleted;
  89641. };
  89642. QuadraticErrorSimplification.prototype.identifyBorder = function () {
  89643. for (var i = 0; i < this.vertices.length; ++i) {
  89644. var vCount = [];
  89645. var vId = [];
  89646. var v = this.vertices[i];
  89647. var j;
  89648. for (j = 0; j < v.triangleCount; ++j) {
  89649. var triangle = this.triangles[this.references[v.triangleStart + j].triangleId];
  89650. for (var ii = 0; ii < 3; ii++) {
  89651. var ofs = 0;
  89652. var vv = triangle.vertices[ii];
  89653. while (ofs < vCount.length) {
  89654. if (vId[ofs] === vv.id) {
  89655. break;
  89656. }
  89657. ++ofs;
  89658. }
  89659. if (ofs === vCount.length) {
  89660. vCount.push(1);
  89661. vId.push(vv.id);
  89662. }
  89663. else {
  89664. vCount[ofs]++;
  89665. }
  89666. }
  89667. }
  89668. for (j = 0; j < vCount.length; ++j) {
  89669. if (vCount[j] === 1) {
  89670. this.vertices[vId[j]].isBorder = true;
  89671. }
  89672. else {
  89673. this.vertices[vId[j]].isBorder = false;
  89674. }
  89675. }
  89676. }
  89677. };
  89678. QuadraticErrorSimplification.prototype.updateMesh = function (identifyBorders) {
  89679. if (identifyBorders === void 0) { identifyBorders = false; }
  89680. var i;
  89681. if (!identifyBorders) {
  89682. var newTrianglesVector = [];
  89683. for (i = 0; i < this.triangles.length; ++i) {
  89684. if (!this.triangles[i].deleted) {
  89685. newTrianglesVector.push(this.triangles[i]);
  89686. }
  89687. }
  89688. this.triangles = newTrianglesVector;
  89689. }
  89690. for (i = 0; i < this.vertices.length; ++i) {
  89691. this.vertices[i].triangleCount = 0;
  89692. this.vertices[i].triangleStart = 0;
  89693. }
  89694. var t;
  89695. var j;
  89696. var v;
  89697. for (i = 0; i < this.triangles.length; ++i) {
  89698. t = this.triangles[i];
  89699. for (j = 0; j < 3; ++j) {
  89700. v = t.vertices[j];
  89701. v.triangleCount++;
  89702. }
  89703. }
  89704. var tStart = 0;
  89705. for (i = 0; i < this.vertices.length; ++i) {
  89706. this.vertices[i].triangleStart = tStart;
  89707. tStart += this.vertices[i].triangleCount;
  89708. this.vertices[i].triangleCount = 0;
  89709. }
  89710. var newReferences = new Array(this.triangles.length * 3);
  89711. for (i = 0; i < this.triangles.length; ++i) {
  89712. t = this.triangles[i];
  89713. for (j = 0; j < 3; ++j) {
  89714. v = t.vertices[j];
  89715. newReferences[v.triangleStart + v.triangleCount] = new Reference(j, i);
  89716. v.triangleCount++;
  89717. }
  89718. }
  89719. this.references = newReferences;
  89720. if (identifyBorders) {
  89721. this.identifyBorder();
  89722. }
  89723. };
  89724. QuadraticErrorSimplification.prototype.vertexError = function (q, point) {
  89725. var x = point.x;
  89726. var y = point.y;
  89727. var z = point.z;
  89728. 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
  89729. + 2 * q.data[5] * y * z + 2 * q.data[6] * y + q.data[7] * z * z + 2 * q.data[8] * z + q.data[9];
  89730. };
  89731. QuadraticErrorSimplification.prototype.calculateError = function (vertex1, vertex2, pointResult) {
  89732. var q = vertex1.q.add(vertex2.q);
  89733. var border = vertex1.isBorder && vertex2.isBorder;
  89734. var error = 0;
  89735. var qDet = q.det(0, 1, 2, 1, 4, 5, 2, 5, 7);
  89736. if (qDet !== 0 && !border) {
  89737. if (!pointResult) {
  89738. pointResult = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  89739. }
  89740. pointResult.x = -1 / qDet * (q.det(1, 2, 3, 4, 5, 6, 5, 7, 8));
  89741. pointResult.y = 1 / qDet * (q.det(0, 2, 3, 1, 5, 6, 2, 7, 8));
  89742. pointResult.z = -1 / qDet * (q.det(0, 1, 3, 1, 4, 6, 2, 5, 8));
  89743. error = this.vertexError(q, pointResult);
  89744. }
  89745. else {
  89746. var p3 = (vertex1.position.add(vertex2.position)).divide(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](2, 2, 2));
  89747. //var norm3 = (vertex1.normal.add(vertex2.normal)).divide(new Vector3(2, 2, 2)).normalize();
  89748. var error1 = this.vertexError(q, vertex1.position);
  89749. var error2 = this.vertexError(q, vertex2.position);
  89750. var error3 = this.vertexError(q, p3);
  89751. error = Math.min(error1, error2, error3);
  89752. if (error === error1) {
  89753. if (pointResult) {
  89754. pointResult.copyFrom(vertex1.position);
  89755. }
  89756. }
  89757. else if (error === error2) {
  89758. if (pointResult) {
  89759. pointResult.copyFrom(vertex2.position);
  89760. }
  89761. }
  89762. else {
  89763. if (pointResult) {
  89764. pointResult.copyFrom(p3);
  89765. }
  89766. }
  89767. }
  89768. return error;
  89769. };
  89770. return QuadraticErrorSimplification;
  89771. }());
  89772. /***/ }),
  89773. /***/ "./Meshes/meshSimplificationSceneComponent.ts":
  89774. /*!****************************************************!*\
  89775. !*** ./Meshes/meshSimplificationSceneComponent.ts ***!
  89776. \****************************************************/
  89777. /*! exports provided: SimplicationQueueSceneComponent */
  89778. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89779. "use strict";
  89780. __webpack_require__.r(__webpack_exports__);
  89781. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return SimplicationQueueSceneComponent; });
  89782. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  89783. /* harmony import */ var _mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./mesh */ "./Meshes/mesh.ts");
  89784. /* harmony import */ var _meshSimplification__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./meshSimplification */ "./Meshes/meshSimplification.ts");
  89785. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  89786. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "simplificationQueue", {
  89787. get: function () {
  89788. if (!this._simplificationQueue) {
  89789. this._simplificationQueue = new _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationQueue"]();
  89790. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE);
  89791. if (!component) {
  89792. component = new SimplicationQueueSceneComponent(this);
  89793. this._addComponent(component);
  89794. }
  89795. }
  89796. return this._simplificationQueue;
  89797. },
  89798. set: function (value) {
  89799. this._simplificationQueue = value;
  89800. },
  89801. enumerable: true,
  89802. configurable: true
  89803. });
  89804. _mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"].prototype.simplify = function (settings, parallelProcessing, simplificationType, successCallback) {
  89805. if (parallelProcessing === void 0) { parallelProcessing = true; }
  89806. if (simplificationType === void 0) { simplificationType = _meshSimplification__WEBPACK_IMPORTED_MODULE_2__["SimplificationType"].QUADRATIC; }
  89807. this.getScene().simplificationQueue.addTask({
  89808. settings: settings,
  89809. parallelProcessing: parallelProcessing,
  89810. mesh: this,
  89811. simplificationType: simplificationType,
  89812. successCallback: successCallback
  89813. });
  89814. return this;
  89815. };
  89816. /**
  89817. * Defines the simplification queue scene component responsible to help scheduling the various simplification task
  89818. * created in a scene
  89819. */
  89820. var SimplicationQueueSceneComponent = /** @class */ (function () {
  89821. /**
  89822. * Creates a new instance of the component for the given scene
  89823. * @param scene Defines the scene to register the component in
  89824. */
  89825. function SimplicationQueueSceneComponent(scene) {
  89826. /**
  89827. * The component name helpfull to identify the component in the list of scene components.
  89828. */
  89829. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_SIMPLIFICATIONQUEUE;
  89830. this.scene = scene;
  89831. }
  89832. /**
  89833. * Registers the component in a given scene
  89834. */
  89835. SimplicationQueueSceneComponent.prototype.register = function () {
  89836. this.scene._beforeCameraUpdateStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE, this, this._beforeCameraUpdate);
  89837. };
  89838. /**
  89839. * Rebuilds the elements related to this component in case of
  89840. * context lost for instance.
  89841. */
  89842. SimplicationQueueSceneComponent.prototype.rebuild = function () {
  89843. // Nothing to do for this component
  89844. };
  89845. /**
  89846. * Disposes the component and the associated ressources
  89847. */
  89848. SimplicationQueueSceneComponent.prototype.dispose = function () {
  89849. // Nothing to do for this component
  89850. };
  89851. SimplicationQueueSceneComponent.prototype._beforeCameraUpdate = function () {
  89852. if (this.scene._simplificationQueue && !this.scene._simplificationQueue.running) {
  89853. this.scene._simplificationQueue.executeNext();
  89854. }
  89855. };
  89856. return SimplicationQueueSceneComponent;
  89857. }());
  89858. /***/ }),
  89859. /***/ "./Meshes/polygonMesh.ts":
  89860. /*!*******************************!*\
  89861. !*** ./Meshes/polygonMesh.ts ***!
  89862. \*******************************/
  89863. /*! exports provided: Polygon, PolygonMeshBuilder */
  89864. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  89865. "use strict";
  89866. __webpack_require__.r(__webpack_exports__);
  89867. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return Polygon; });
  89868. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return PolygonMeshBuilder; });
  89869. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  89870. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  89871. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  89872. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  89873. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  89874. /**
  89875. * Vector2 wth index property
  89876. */
  89877. var IndexedVector2 = /** @class */ (function (_super) {
  89878. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](IndexedVector2, _super);
  89879. function IndexedVector2(original,
  89880. /** Index of the vector2 */
  89881. index) {
  89882. var _this = _super.call(this, original.x, original.y) || this;
  89883. _this.index = index;
  89884. return _this;
  89885. }
  89886. return IndexedVector2;
  89887. }(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"]));
  89888. /**
  89889. * Defines points to create a polygon
  89890. */
  89891. var PolygonPoints = /** @class */ (function () {
  89892. function PolygonPoints() {
  89893. this.elements = new Array();
  89894. }
  89895. PolygonPoints.prototype.add = function (originalPoints) {
  89896. var _this = this;
  89897. var result = new Array();
  89898. originalPoints.forEach(function (point) {
  89899. if (result.length === 0 || !point.equalsWithEpsilon(result[0])) {
  89900. var newPoint = new IndexedVector2(point, _this.elements.length);
  89901. result.push(newPoint);
  89902. _this.elements.push(newPoint);
  89903. }
  89904. });
  89905. return result;
  89906. };
  89907. PolygonPoints.prototype.computeBounds = function () {
  89908. var lmin = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89909. var lmax = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](this.elements[0].x, this.elements[0].y);
  89910. this.elements.forEach(function (point) {
  89911. // x
  89912. if (point.x < lmin.x) {
  89913. lmin.x = point.x;
  89914. }
  89915. else if (point.x > lmax.x) {
  89916. lmax.x = point.x;
  89917. }
  89918. // y
  89919. if (point.y < lmin.y) {
  89920. lmin.y = point.y;
  89921. }
  89922. else if (point.y > lmax.y) {
  89923. lmax.y = point.y;
  89924. }
  89925. });
  89926. return {
  89927. min: lmin,
  89928. max: lmax,
  89929. width: lmax.x - lmin.x,
  89930. height: lmax.y - lmin.y
  89931. };
  89932. };
  89933. return PolygonPoints;
  89934. }());
  89935. /**
  89936. * Polygon
  89937. * @see https://doc.babylonjs.com/how_to/parametric_shapes#non-regular-polygon
  89938. */
  89939. var Polygon = /** @class */ (function () {
  89940. function Polygon() {
  89941. }
  89942. /**
  89943. * Creates a rectangle
  89944. * @param xmin bottom X coord
  89945. * @param ymin bottom Y coord
  89946. * @param xmax top X coord
  89947. * @param ymax top Y coord
  89948. * @returns points that make the resulting rectation
  89949. */
  89950. Polygon.Rectangle = function (xmin, ymin, xmax, ymax) {
  89951. return [
  89952. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymin),
  89953. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymin),
  89954. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmax, ymax),
  89955. new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](xmin, ymax)
  89956. ];
  89957. };
  89958. /**
  89959. * Creates a circle
  89960. * @param radius radius of circle
  89961. * @param cx scale in x
  89962. * @param cy scale in y
  89963. * @param numberOfSides number of sides that make up the circle
  89964. * @returns points that make the resulting circle
  89965. */
  89966. Polygon.Circle = function (radius, cx, cy, numberOfSides) {
  89967. if (cx === void 0) { cx = 0; }
  89968. if (cy === void 0) { cy = 0; }
  89969. if (numberOfSides === void 0) { numberOfSides = 32; }
  89970. var result = new Array();
  89971. var angle = 0;
  89972. var increment = (Math.PI * 2) / numberOfSides;
  89973. for (var i = 0; i < numberOfSides; i++) {
  89974. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](cx + Math.cos(angle) * radius, cy + Math.sin(angle) * radius));
  89975. angle -= increment;
  89976. }
  89977. return result;
  89978. };
  89979. /**
  89980. * Creates a polygon from input string
  89981. * @param input Input polygon data
  89982. * @returns the parsed points
  89983. */
  89984. Polygon.Parse = function (input) {
  89985. var floats = input.split(/[^-+eE\.\d]+/).map(parseFloat).filter(function (val) { return (!isNaN(val)); });
  89986. var i, result = [];
  89987. for (i = 0; i < (floats.length & 0x7FFFFFFE); i += 2) {
  89988. result.push(new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](floats[i], floats[i + 1]));
  89989. }
  89990. return result;
  89991. };
  89992. /**
  89993. * Starts building a polygon from x and y coordinates
  89994. * @param x x coordinate
  89995. * @param y y coordinate
  89996. * @returns the started path2
  89997. */
  89998. Polygon.StartingAt = function (x, y) {
  89999. return _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"].StartingAt(x, y);
  90000. };
  90001. return Polygon;
  90002. }());
  90003. /**
  90004. * Builds a polygon
  90005. * @see https://doc.babylonjs.com/how_to/polygonmeshbuilder
  90006. */
  90007. var PolygonMeshBuilder = /** @class */ (function () {
  90008. /**
  90009. * Creates a PolygonMeshBuilder
  90010. * @param name name of the builder
  90011. * @param contours Path of the polygon
  90012. * @param scene scene to add to
  90013. * @param earcutInjection can be used to inject your own earcut reference
  90014. */
  90015. function PolygonMeshBuilder(name, contours, scene, earcutInjection) {
  90016. if (earcutInjection === void 0) { earcutInjection = earcut; }
  90017. this._points = new PolygonPoints();
  90018. this._outlinepoints = new PolygonPoints();
  90019. this._holes = new Array();
  90020. this._epoints = new Array();
  90021. this._eholes = new Array();
  90022. this.bjsEarcut = earcutInjection;
  90023. this._name = name;
  90024. this._scene = scene;
  90025. var points;
  90026. if (contours instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Path2"]) {
  90027. points = contours.getPoints();
  90028. }
  90029. else {
  90030. points = contours;
  90031. }
  90032. this._addToepoint(points);
  90033. this._points.add(points);
  90034. this._outlinepoints.add(points);
  90035. if (typeof this.bjsEarcut === 'undefined') {
  90036. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Earcut was not found, the polygon will not be built.");
  90037. }
  90038. }
  90039. PolygonMeshBuilder.prototype._addToepoint = function (points) {
  90040. for (var _i = 0, points_1 = points; _i < points_1.length; _i++) {
  90041. var p = points_1[_i];
  90042. this._epoints.push(p.x, p.y);
  90043. }
  90044. };
  90045. /**
  90046. * Adds a whole within the polygon
  90047. * @param hole Array of points defining the hole
  90048. * @returns this
  90049. */
  90050. PolygonMeshBuilder.prototype.addHole = function (hole) {
  90051. this._points.add(hole);
  90052. var holepoints = new PolygonPoints();
  90053. holepoints.add(hole);
  90054. this._holes.push(holepoints);
  90055. this._eholes.push(this._epoints.length / 2);
  90056. this._addToepoint(hole);
  90057. return this;
  90058. };
  90059. /**
  90060. * Creates the polygon
  90061. * @param updatable If the mesh should be updatable
  90062. * @param depth The depth of the mesh created
  90063. * @returns the created mesh
  90064. */
  90065. PolygonMeshBuilder.prototype.build = function (updatable, depth) {
  90066. var _this = this;
  90067. if (updatable === void 0) { updatable = false; }
  90068. if (depth === void 0) { depth = 0; }
  90069. var result = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"](this._name, this._scene);
  90070. var normals = new Array();
  90071. var positions = new Array();
  90072. var uvs = new Array();
  90073. var bounds = this._points.computeBounds();
  90074. this._points.elements.forEach(function (p) {
  90075. normals.push(0, 1.0, 0);
  90076. positions.push(p.x, 0, p.y);
  90077. uvs.push((p.x - bounds.min.x) / bounds.width, (p.y - bounds.min.y) / bounds.height);
  90078. });
  90079. var indices = new Array();
  90080. var res = this.bjsEarcut(this._epoints, this._eholes, 2);
  90081. for (var i = 0; i < res.length; i++) {
  90082. indices.push(res[i]);
  90083. }
  90084. if (depth > 0) {
  90085. var positionscount = (positions.length / 3); //get the current pointcount
  90086. this._points.elements.forEach(function (p) {
  90087. normals.push(0, -1.0, 0);
  90088. positions.push(p.x, -depth, p.y);
  90089. uvs.push(1 - (p.x - bounds.min.x) / bounds.width, 1 - (p.y - bounds.min.y) / bounds.height);
  90090. });
  90091. var totalCount = indices.length;
  90092. for (var i = 0; i < totalCount; i += 3) {
  90093. var i0 = indices[i + 0];
  90094. var i1 = indices[i + 1];
  90095. var i2 = indices[i + 2];
  90096. indices.push(i2 + positionscount);
  90097. indices.push(i1 + positionscount);
  90098. indices.push(i0 + positionscount);
  90099. }
  90100. //Add the sides
  90101. this.addSide(positions, normals, uvs, indices, bounds, this._outlinepoints, depth, false);
  90102. this._holes.forEach(function (hole) {
  90103. _this.addSide(positions, normals, uvs, indices, bounds, hole, depth, true);
  90104. });
  90105. }
  90106. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, updatable);
  90107. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, updatable);
  90108. result.setVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].UVKind, uvs, updatable);
  90109. result.setIndices(indices);
  90110. return result;
  90111. };
  90112. /**
  90113. * Adds a side to the polygon
  90114. * @param positions points that make the polygon
  90115. * @param normals normals of the polygon
  90116. * @param uvs uvs of the polygon
  90117. * @param indices indices of the polygon
  90118. * @param bounds bounds of the polygon
  90119. * @param points points of the polygon
  90120. * @param depth depth of the polygon
  90121. * @param flip flip of the polygon
  90122. */
  90123. PolygonMeshBuilder.prototype.addSide = function (positions, normals, uvs, indices, bounds, points, depth, flip) {
  90124. var StartIndex = positions.length / 3;
  90125. var ulength = 0;
  90126. for (var i = 0; i < points.elements.length; i++) {
  90127. var p = points.elements[i];
  90128. var p1;
  90129. if ((i + 1) > points.elements.length - 1) {
  90130. p1 = points.elements[0];
  90131. }
  90132. else {
  90133. p1 = points.elements[i + 1];
  90134. }
  90135. positions.push(p.x, 0, p.y);
  90136. positions.push(p.x, -depth, p.y);
  90137. positions.push(p1.x, 0, p1.y);
  90138. positions.push(p1.x, -depth, p1.y);
  90139. var v1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p.x, 0, p.y);
  90140. var v2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](p1.x, 0, p1.y);
  90141. var v3 = v2.subtract(v1);
  90142. var v4 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](0, 1, 0);
  90143. var vn = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Cross(v3, v4);
  90144. vn = vn.normalize();
  90145. uvs.push(ulength / bounds.width, 0);
  90146. uvs.push(ulength / bounds.width, 1);
  90147. ulength += v3.length();
  90148. uvs.push((ulength / bounds.width), 0);
  90149. uvs.push((ulength / bounds.width), 1);
  90150. if (!flip) {
  90151. normals.push(-vn.x, -vn.y, -vn.z);
  90152. normals.push(-vn.x, -vn.y, -vn.z);
  90153. normals.push(-vn.x, -vn.y, -vn.z);
  90154. normals.push(-vn.x, -vn.y, -vn.z);
  90155. indices.push(StartIndex);
  90156. indices.push(StartIndex + 1);
  90157. indices.push(StartIndex + 2);
  90158. indices.push(StartIndex + 1);
  90159. indices.push(StartIndex + 3);
  90160. indices.push(StartIndex + 2);
  90161. }
  90162. else {
  90163. normals.push(vn.x, vn.y, vn.z);
  90164. normals.push(vn.x, vn.y, vn.z);
  90165. normals.push(vn.x, vn.y, vn.z);
  90166. normals.push(vn.x, vn.y, vn.z);
  90167. indices.push(StartIndex);
  90168. indices.push(StartIndex + 2);
  90169. indices.push(StartIndex + 1);
  90170. indices.push(StartIndex + 1);
  90171. indices.push(StartIndex + 2);
  90172. indices.push(StartIndex + 3);
  90173. }
  90174. StartIndex += 4;
  90175. }
  90176. };
  90177. return PolygonMeshBuilder;
  90178. }());
  90179. /***/ }),
  90180. /***/ "./Meshes/subMesh.ts":
  90181. /*!***************************!*\
  90182. !*** ./Meshes/subMesh.ts ***!
  90183. \***************************/
  90184. /*! exports provided: BaseSubMesh, SubMesh */
  90185. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90186. "use strict";
  90187. __webpack_require__.r(__webpack_exports__);
  90188. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return BaseSubMesh; });
  90189. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return SubMesh; });
  90190. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90191. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  90192. /* harmony import */ var _buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./buffer */ "./Meshes/buffer.ts");
  90193. /* harmony import */ var _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/intersectionInfo */ "./Collisions/intersectionInfo.ts");
  90194. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  90195. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  90196. /**
  90197. * Base class for submeshes
  90198. */
  90199. var BaseSubMesh = /** @class */ (function () {
  90200. function BaseSubMesh() {
  90201. }
  90202. Object.defineProperty(BaseSubMesh.prototype, "effect", {
  90203. /**
  90204. * Gets associated effect
  90205. */
  90206. get: function () {
  90207. return this._materialEffect;
  90208. },
  90209. enumerable: true,
  90210. configurable: true
  90211. });
  90212. /**
  90213. * Sets associated effect (effect used to render this submesh)
  90214. * @param effect defines the effect to associate with
  90215. * @param defines defines the set of defines used to compile this effect
  90216. */
  90217. BaseSubMesh.prototype.setEffect = function (effect, defines) {
  90218. if (defines === void 0) { defines = null; }
  90219. if (this._materialEffect === effect) {
  90220. if (!effect) {
  90221. this._materialDefines = null;
  90222. }
  90223. return;
  90224. }
  90225. this._materialDefines = defines;
  90226. this._materialEffect = effect;
  90227. };
  90228. return BaseSubMesh;
  90229. }());
  90230. /**
  90231. * Defines a subdivision inside a mesh
  90232. */
  90233. var SubMesh = /** @class */ (function (_super) {
  90234. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SubMesh, _super);
  90235. /**
  90236. * Creates a new submesh
  90237. * @param materialIndex defines the material index to use
  90238. * @param verticesStart defines vertex index start
  90239. * @param verticesCount defines vertices count
  90240. * @param indexStart defines index start
  90241. * @param indexCount defines indices count
  90242. * @param mesh defines the parent mesh
  90243. * @param renderingMesh defines an optional rendering mesh
  90244. * @param createBoundingBox defines if bounding box should be created for this submesh
  90245. */
  90246. function SubMesh(
  90247. /** the material index to use */
  90248. materialIndex,
  90249. /** vertex index start */
  90250. verticesStart,
  90251. /** vertices count */
  90252. verticesCount,
  90253. /** index start */
  90254. indexStart,
  90255. /** indices count */
  90256. indexCount, mesh, renderingMesh, createBoundingBox) {
  90257. if (createBoundingBox === void 0) { createBoundingBox = true; }
  90258. var _this = _super.call(this) || this;
  90259. _this.materialIndex = materialIndex;
  90260. _this.verticesStart = verticesStart;
  90261. _this.verticesCount = verticesCount;
  90262. _this.indexStart = indexStart;
  90263. _this.indexCount = indexCount;
  90264. /** @hidden */
  90265. _this._renderId = 0;
  90266. _this._mesh = mesh;
  90267. _this._renderingMesh = renderingMesh || mesh;
  90268. mesh.subMeshes.push(_this);
  90269. _this._trianglePlanes = [];
  90270. _this._id = mesh.subMeshes.length - 1;
  90271. if (createBoundingBox) {
  90272. _this.refreshBoundingInfo();
  90273. mesh.computeWorldMatrix(true);
  90274. }
  90275. return _this;
  90276. }
  90277. /**
  90278. * Add a new submesh to a mesh
  90279. * @param materialIndex defines the material index to use
  90280. * @param verticesStart defines vertex index start
  90281. * @param verticesCount defines vertices count
  90282. * @param indexStart defines index start
  90283. * @param indexCount defines indices count
  90284. * @param mesh defines the parent mesh
  90285. * @param renderingMesh defines an optional rendering mesh
  90286. * @param createBoundingBox defines if bounding box should be created for this submesh
  90287. * @returns the new submesh
  90288. */
  90289. SubMesh.AddToMesh = function (materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox) {
  90290. if (createBoundingBox === void 0) { createBoundingBox = true; }
  90291. return new SubMesh(materialIndex, verticesStart, verticesCount, indexStart, indexCount, mesh, renderingMesh, createBoundingBox);
  90292. };
  90293. Object.defineProperty(SubMesh.prototype, "IsGlobal", {
  90294. /**
  90295. * Returns true if this submesh covers the entire parent mesh
  90296. * @ignorenaming
  90297. */
  90298. get: function () {
  90299. return (this.verticesStart === 0 && this.verticesCount === this._mesh.getTotalVertices());
  90300. },
  90301. enumerable: true,
  90302. configurable: true
  90303. });
  90304. /**
  90305. * Returns the submesh BoudingInfo object
  90306. * @returns current bounding info (or mesh's one if the submesh is global)
  90307. */
  90308. SubMesh.prototype.getBoundingInfo = function () {
  90309. if (this.IsGlobal) {
  90310. return this._mesh.getBoundingInfo();
  90311. }
  90312. return this._boundingInfo;
  90313. };
  90314. /**
  90315. * Sets the submesh BoundingInfo
  90316. * @param boundingInfo defines the new bounding info to use
  90317. * @returns the SubMesh
  90318. */
  90319. SubMesh.prototype.setBoundingInfo = function (boundingInfo) {
  90320. this._boundingInfo = boundingInfo;
  90321. return this;
  90322. };
  90323. /**
  90324. * Returns the mesh of the current submesh
  90325. * @return the parent mesh
  90326. */
  90327. SubMesh.prototype.getMesh = function () {
  90328. return this._mesh;
  90329. };
  90330. /**
  90331. * Returns the rendering mesh of the submesh
  90332. * @returns the rendering mesh (could be different from parent mesh)
  90333. */
  90334. SubMesh.prototype.getRenderingMesh = function () {
  90335. return this._renderingMesh;
  90336. };
  90337. /**
  90338. * Returns the submesh material
  90339. * @returns null or the current material
  90340. */
  90341. SubMesh.prototype.getMaterial = function () {
  90342. var rootMaterial = this._renderingMesh.material;
  90343. if (rootMaterial === null || rootMaterial === undefined) {
  90344. return this._mesh.getScene().defaultMaterial;
  90345. }
  90346. else if (rootMaterial.getSubMaterial) {
  90347. var multiMaterial = rootMaterial;
  90348. var effectiveMaterial = multiMaterial.getSubMaterial(this.materialIndex);
  90349. if (this._currentMaterial !== effectiveMaterial) {
  90350. this._currentMaterial = effectiveMaterial;
  90351. this._materialDefines = null;
  90352. }
  90353. return effectiveMaterial;
  90354. }
  90355. return rootMaterial;
  90356. };
  90357. // Methods
  90358. /**
  90359. * Sets a new updated BoundingInfo object to the submesh
  90360. * @returns the SubMesh
  90361. */
  90362. SubMesh.prototype.refreshBoundingInfo = function () {
  90363. this._lastColliderWorldVertices = null;
  90364. if (this.IsGlobal || !this._renderingMesh || !this._renderingMesh.geometry) {
  90365. return this;
  90366. }
  90367. var data = this._renderingMesh.getVerticesData(_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind);
  90368. if (!data) {
  90369. this._boundingInfo = this._mesh.getBoundingInfo();
  90370. return this;
  90371. }
  90372. var indices = this._renderingMesh.getIndices();
  90373. var extend;
  90374. //is this the only submesh?
  90375. if (this.indexStart === 0 && this.indexCount === indices.length) {
  90376. var boundingInfo = this._renderingMesh.getBoundingInfo();
  90377. //the rendering mesh's bounding info can be used, it is the standard submesh for all indices.
  90378. extend = { minimum: boundingInfo.minimum.clone(), maximum: boundingInfo.maximum.clone() };
  90379. }
  90380. else {
  90381. extend = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].ExtractMinAndMaxIndexed(data, indices, this.indexStart, this.indexCount, this._renderingMesh.geometry.boundingBias);
  90382. }
  90383. if (this._boundingInfo) {
  90384. this._boundingInfo.reConstruct(extend.minimum, extend.maximum);
  90385. }
  90386. else {
  90387. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](extend.minimum, extend.maximum);
  90388. }
  90389. return this;
  90390. };
  90391. /** @hidden */
  90392. SubMesh.prototype._checkCollision = function (collider) {
  90393. var boundingInfo = this.getBoundingInfo();
  90394. return boundingInfo._checkCollision(collider);
  90395. };
  90396. /**
  90397. * Updates the submesh BoundingInfo
  90398. * @param world defines the world matrix to use to update the bounding info
  90399. * @returns the submesh
  90400. */
  90401. SubMesh.prototype.updateBoundingInfo = function (world) {
  90402. var boundingInfo = this.getBoundingInfo();
  90403. if (!boundingInfo) {
  90404. this.refreshBoundingInfo();
  90405. boundingInfo = this.getBoundingInfo();
  90406. }
  90407. boundingInfo.update(world);
  90408. return this;
  90409. };
  90410. /**
  90411. * True is the submesh bounding box intersects the frustum defined by the passed array of planes.
  90412. * @param frustumPlanes defines the frustum planes
  90413. * @returns true if the submesh is intersecting with the frustum
  90414. */
  90415. SubMesh.prototype.isInFrustum = function (frustumPlanes) {
  90416. var boundingInfo = this.getBoundingInfo();
  90417. if (!boundingInfo) {
  90418. return false;
  90419. }
  90420. return boundingInfo.isInFrustum(frustumPlanes, this._mesh.cullingStrategy);
  90421. };
  90422. /**
  90423. * True is the submesh bounding box is completely inside the frustum defined by the passed array of planes
  90424. * @param frustumPlanes defines the frustum planes
  90425. * @returns true if the submesh is inside the frustum
  90426. */
  90427. SubMesh.prototype.isCompletelyInFrustum = function (frustumPlanes) {
  90428. var boundingInfo = this.getBoundingInfo();
  90429. if (!boundingInfo) {
  90430. return false;
  90431. }
  90432. return boundingInfo.isCompletelyInFrustum(frustumPlanes);
  90433. };
  90434. /**
  90435. * Renders the submesh
  90436. * @param enableAlphaMode defines if alpha needs to be used
  90437. * @returns the submesh
  90438. */
  90439. SubMesh.prototype.render = function (enableAlphaMode) {
  90440. this._renderingMesh.render(this, enableAlphaMode);
  90441. return this;
  90442. };
  90443. /**
  90444. * @hidden
  90445. */
  90446. SubMesh.prototype._getLinesIndexBuffer = function (indices, engine) {
  90447. if (!this._linesIndexBuffer) {
  90448. var linesIndices = [];
  90449. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  90450. linesIndices.push(indices[index], indices[index + 1], indices[index + 1], indices[index + 2], indices[index + 2], indices[index]);
  90451. }
  90452. this._linesIndexBuffer = engine.createIndexBuffer(linesIndices);
  90453. this._linesIndexCount = linesIndices.length;
  90454. }
  90455. return this._linesIndexBuffer;
  90456. };
  90457. /**
  90458. * Checks if the submesh intersects with a ray
  90459. * @param ray defines the ray to test
  90460. * @returns true is the passed ray intersects the submesh bounding box
  90461. */
  90462. SubMesh.prototype.canIntersects = function (ray) {
  90463. var boundingInfo = this.getBoundingInfo();
  90464. if (!boundingInfo) {
  90465. return false;
  90466. }
  90467. return ray.intersectsBox(boundingInfo.boundingBox);
  90468. };
  90469. /**
  90470. * Intersects current submesh with a ray
  90471. * @param ray defines the ray to test
  90472. * @param positions defines mesh's positions array
  90473. * @param indices defines mesh's indices array
  90474. * @param fastCheck defines if only bounding info should be used
  90475. * @returns intersection info or null if no intersection
  90476. */
  90477. SubMesh.prototype.intersects = function (ray, positions, indices, fastCheck) {
  90478. var material = this.getMaterial();
  90479. if (!material) {
  90480. return null;
  90481. }
  90482. switch (material.fillMode) {
  90483. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_PointListDrawMode:
  90484. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineListDrawMode:
  90485. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineLoopDrawMode:
  90486. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_LineStripDrawMode:
  90487. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleFanDrawMode:
  90488. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].MATERIAL_TriangleStripDrawMode:
  90489. return null;
  90490. }
  90491. // LineMesh first as it's also a Mesh...
  90492. if (this._mesh.getClassName() === "InstancedLinesMesh" || this._mesh.getClassName() === "LinesMesh") {
  90493. return this._intersectLines(ray, positions, indices, this._mesh.intersectionThreshold, fastCheck);
  90494. }
  90495. return this._intersectTriangles(ray, positions, indices, fastCheck);
  90496. };
  90497. /** @hidden */
  90498. SubMesh.prototype._intersectLines = function (ray, positions, indices, intersectionThreshold, fastCheck) {
  90499. var intersectInfo = null;
  90500. // Line test
  90501. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 2) {
  90502. var p0 = positions[indices[index]];
  90503. var p1 = positions[indices[index + 1]];
  90504. var length = ray.intersectionSegment(p0, p1, intersectionThreshold);
  90505. if (length < 0) {
  90506. continue;
  90507. }
  90508. if (fastCheck || !intersectInfo || length < intersectInfo.distance) {
  90509. intersectInfo = new _Collisions_intersectionInfo__WEBPACK_IMPORTED_MODULE_3__["IntersectionInfo"](null, null, length);
  90510. intersectInfo.faceId = index / 2;
  90511. if (fastCheck) {
  90512. break;
  90513. }
  90514. }
  90515. }
  90516. return intersectInfo;
  90517. };
  90518. /** @hidden */
  90519. SubMesh.prototype._intersectTriangles = function (ray, positions, indices, fastCheck) {
  90520. var intersectInfo = null;
  90521. // Triangles test
  90522. for (var index = this.indexStart; index < this.indexStart + this.indexCount; index += 3) {
  90523. var p0 = positions[indices[index]];
  90524. var p1 = positions[indices[index + 1]];
  90525. var p2 = positions[indices[index + 2]];
  90526. var currentIntersectInfo = ray.intersectsTriangle(p0, p1, p2);
  90527. if (currentIntersectInfo) {
  90528. if (currentIntersectInfo.distance < 0) {
  90529. continue;
  90530. }
  90531. if (fastCheck || !intersectInfo || currentIntersectInfo.distance < intersectInfo.distance) {
  90532. intersectInfo = currentIntersectInfo;
  90533. intersectInfo.faceId = index / 3;
  90534. if (fastCheck) {
  90535. break;
  90536. }
  90537. }
  90538. }
  90539. }
  90540. return intersectInfo;
  90541. };
  90542. /** @hidden */
  90543. SubMesh.prototype._rebuild = function () {
  90544. if (this._linesIndexBuffer) {
  90545. this._linesIndexBuffer = null;
  90546. }
  90547. };
  90548. // Clone
  90549. /**
  90550. * Creates a new submesh from the passed mesh
  90551. * @param newMesh defines the new hosting mesh
  90552. * @param newRenderingMesh defines an optional rendering mesh
  90553. * @returns the new submesh
  90554. */
  90555. SubMesh.prototype.clone = function (newMesh, newRenderingMesh) {
  90556. var result = new SubMesh(this.materialIndex, this.verticesStart, this.verticesCount, this.indexStart, this.indexCount, newMesh, newRenderingMesh, false);
  90557. if (!this.IsGlobal) {
  90558. var boundingInfo = this.getBoundingInfo();
  90559. if (!boundingInfo) {
  90560. return result;
  90561. }
  90562. result._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_4__["BoundingInfo"](boundingInfo.minimum, boundingInfo.maximum);
  90563. }
  90564. return result;
  90565. };
  90566. // Dispose
  90567. /**
  90568. * Release associated resources
  90569. */
  90570. SubMesh.prototype.dispose = function () {
  90571. if (this._linesIndexBuffer) {
  90572. this._mesh.getScene().getEngine()._releaseBuffer(this._linesIndexBuffer);
  90573. this._linesIndexBuffer = null;
  90574. }
  90575. // Remove from mesh
  90576. var index = this._mesh.subMeshes.indexOf(this);
  90577. this._mesh.subMeshes.splice(index, 1);
  90578. };
  90579. /**
  90580. * Gets the class name
  90581. * @returns the string "SubMesh".
  90582. */
  90583. SubMesh.prototype.getClassName = function () {
  90584. return "SubMesh";
  90585. };
  90586. // Statics
  90587. /**
  90588. * Creates a new submesh from indices data
  90589. * @param materialIndex the index of the main mesh material
  90590. * @param startIndex the index where to start the copy in the mesh indices array
  90591. * @param indexCount the number of indices to copy then from the startIndex
  90592. * @param mesh the main mesh to create the submesh from
  90593. * @param renderingMesh the optional rendering mesh
  90594. * @returns a new submesh
  90595. */
  90596. SubMesh.CreateFromIndices = function (materialIndex, startIndex, indexCount, mesh, renderingMesh) {
  90597. var minVertexIndex = Number.MAX_VALUE;
  90598. var maxVertexIndex = -Number.MAX_VALUE;
  90599. var whatWillRender = (renderingMesh || mesh);
  90600. var indices = whatWillRender.getIndices();
  90601. for (var index = startIndex; index < startIndex + indexCount; index++) {
  90602. var vertexIndex = indices[index];
  90603. if (vertexIndex < minVertexIndex) {
  90604. minVertexIndex = vertexIndex;
  90605. }
  90606. if (vertexIndex > maxVertexIndex) {
  90607. maxVertexIndex = vertexIndex;
  90608. }
  90609. }
  90610. return new SubMesh(materialIndex, minVertexIndex, maxVertexIndex - minVertexIndex + 1, startIndex, indexCount, mesh, renderingMesh);
  90611. };
  90612. return SubMesh;
  90613. }(BaseSubMesh));
  90614. /***/ }),
  90615. /***/ "./Meshes/trailMesh.ts":
  90616. /*!*****************************!*\
  90617. !*** ./Meshes/trailMesh.ts ***!
  90618. \*****************************/
  90619. /*! exports provided: TrailMesh */
  90620. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90621. "use strict";
  90622. __webpack_require__.r(__webpack_exports__);
  90623. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return TrailMesh; });
  90624. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90625. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  90626. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90627. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  90628. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  90629. /**
  90630. * Class used to create a trail following a mesh
  90631. */
  90632. var TrailMesh = /** @class */ (function (_super) {
  90633. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TrailMesh, _super);
  90634. /**
  90635. * @constructor
  90636. * @param name The value used by scene.getMeshByName() to do a lookup.
  90637. * @param generator The mesh to generate a trail.
  90638. * @param scene The scene to add this mesh to.
  90639. * @param diameter Diameter of trailing mesh. Default is 1.
  90640. * @param length Length of trailing mesh. Default is 60.
  90641. * @param autoStart Automatically start trailing mesh. Default true.
  90642. */
  90643. function TrailMesh(name, generator, scene, diameter, length, autoStart) {
  90644. if (diameter === void 0) { diameter = 1; }
  90645. if (length === void 0) { length = 60; }
  90646. if (autoStart === void 0) { autoStart = true; }
  90647. var _this = _super.call(this, name, scene) || this;
  90648. _this._sectionPolygonPointsCount = 4;
  90649. _this._running = false;
  90650. _this._autoStart = autoStart;
  90651. _this._generator = generator;
  90652. _this._diameter = diameter;
  90653. _this._length = length;
  90654. _this._sectionVectors = [];
  90655. _this._sectionNormalVectors = [];
  90656. for (var i = 0; i < _this._sectionPolygonPointsCount; i++) {
  90657. _this._sectionVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  90658. _this._sectionNormalVectors[i] = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  90659. }
  90660. _this._createMesh();
  90661. return _this;
  90662. }
  90663. /**
  90664. * "TrailMesh"
  90665. * @returns "TrailMesh"
  90666. */
  90667. TrailMesh.prototype.getClassName = function () {
  90668. return "TrailMesh";
  90669. };
  90670. TrailMesh.prototype._createMesh = function () {
  90671. var data = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"]();
  90672. var positions = [];
  90673. var normals = [];
  90674. var indices = [];
  90675. var meshCenter = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  90676. if (this._generator._boundingInfo) {
  90677. meshCenter = this._generator._boundingInfo.boundingBox.centerWorld;
  90678. }
  90679. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  90680. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  90681. positions.push(meshCenter.x + Math.cos(i * alpha) * this._diameter, meshCenter.y + Math.sin(i * alpha) * this._diameter, meshCenter.z);
  90682. }
  90683. for (var i = 1; i <= this._length; i++) {
  90684. for (var j = 0; j < this._sectionPolygonPointsCount; j++) {
  90685. positions.push(meshCenter.x + Math.cos(j * alpha) * this._diameter, meshCenter.y + Math.sin(j * alpha) * this._diameter, meshCenter.z);
  90686. }
  90687. var l = positions.length / 3 - 2 * this._sectionPolygonPointsCount;
  90688. for (var j = 0; j < this._sectionPolygonPointsCount - 1; j++) {
  90689. indices.push(l + j, l + j + this._sectionPolygonPointsCount, l + j + this._sectionPolygonPointsCount + 1);
  90690. indices.push(l + j, l + j + this._sectionPolygonPointsCount + 1, l + j + 1);
  90691. }
  90692. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount - 1 + this._sectionPolygonPointsCount, l + this._sectionPolygonPointsCount);
  90693. indices.push(l + this._sectionPolygonPointsCount - 1, l + this._sectionPolygonPointsCount, l);
  90694. }
  90695. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_4__["VertexData"].ComputeNormals(positions, indices, normals);
  90696. data.positions = positions;
  90697. data.normals = normals;
  90698. data.indices = indices;
  90699. data.applyToMesh(this, true);
  90700. if (this._autoStart) {
  90701. this.start();
  90702. }
  90703. };
  90704. /**
  90705. * Start trailing mesh.
  90706. */
  90707. TrailMesh.prototype.start = function () {
  90708. var _this = this;
  90709. if (!this._running) {
  90710. this._running = true;
  90711. this._beforeRenderObserver = this.getScene().onBeforeRenderObservable.add(function () {
  90712. _this.update();
  90713. });
  90714. }
  90715. };
  90716. /**
  90717. * Stop trailing mesh.
  90718. */
  90719. TrailMesh.prototype.stop = function () {
  90720. if (this._beforeRenderObserver && this._running) {
  90721. this._running = false;
  90722. this.getScene().onBeforeRenderObservable.remove(this._beforeRenderObserver);
  90723. }
  90724. };
  90725. /**
  90726. * Update trailing mesh geometry.
  90727. */
  90728. TrailMesh.prototype.update = function () {
  90729. var positions = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind);
  90730. var normals = this.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind);
  90731. var wm = this._generator.getWorldMatrix();
  90732. if (positions && normals) {
  90733. for (var i = 3 * this._sectionPolygonPointsCount; i < positions.length; i++) {
  90734. positions[i - 3 * this._sectionPolygonPointsCount] = positions[i] - normals[i] / this._length * this._diameter;
  90735. }
  90736. for (var i = 3 * this._sectionPolygonPointsCount; i < normals.length; i++) {
  90737. normals[i - 3 * this._sectionPolygonPointsCount] = normals[i];
  90738. }
  90739. var l = positions.length - 3 * this._sectionPolygonPointsCount;
  90740. var alpha = 2 * Math.PI / this._sectionPolygonPointsCount;
  90741. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  90742. this._sectionVectors[i].copyFromFloats(Math.cos(i * alpha) * this._diameter, Math.sin(i * alpha) * this._diameter, 0);
  90743. this._sectionNormalVectors[i].copyFromFloats(Math.cos(i * alpha), Math.sin(i * alpha), 0);
  90744. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformCoordinatesToRef(this._sectionVectors[i], wm, this._sectionVectors[i]);
  90745. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].TransformNormalToRef(this._sectionNormalVectors[i], wm, this._sectionNormalVectors[i]);
  90746. }
  90747. for (var i = 0; i < this._sectionPolygonPointsCount; i++) {
  90748. positions[l + 3 * i] = this._sectionVectors[i].x;
  90749. positions[l + 3 * i + 1] = this._sectionVectors[i].y;
  90750. positions[l + 3 * i + 2] = this._sectionVectors[i].z;
  90751. normals[l + 3 * i] = this._sectionNormalVectors[i].x;
  90752. normals[l + 3 * i + 1] = this._sectionNormalVectors[i].y;
  90753. normals[l + 3 * i + 2] = this._sectionNormalVectors[i].z;
  90754. }
  90755. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind, positions, true, false);
  90756. this.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind, normals, true, false);
  90757. }
  90758. };
  90759. /**
  90760. * Returns a new TrailMesh object.
  90761. * @param name is a string, the name given to the new mesh
  90762. * @param newGenerator use new generator object for cloned trail mesh
  90763. * @returns a new mesh
  90764. */
  90765. TrailMesh.prototype.clone = function (name, newGenerator) {
  90766. if (name === void 0) { name = ""; }
  90767. return new TrailMesh(name, (newGenerator === undefined ? this._generator : newGenerator), this.getScene(), this._diameter, this._length, this._autoStart);
  90768. };
  90769. /**
  90770. * Serializes this trail mesh
  90771. * @param serializationObject object to write serialization to
  90772. */
  90773. TrailMesh.prototype.serialize = function (serializationObject) {
  90774. _super.prototype.serialize.call(this, serializationObject);
  90775. };
  90776. /**
  90777. * Parses a serialized trail mesh
  90778. * @param parsedMesh the serialized mesh
  90779. * @param scene the scene to create the trail mesh in
  90780. * @returns the created trail mesh
  90781. */
  90782. TrailMesh.Parse = function (parsedMesh, scene) {
  90783. return new TrailMesh(parsedMesh.name, parsedMesh._generator, scene, parsedMesh._diameter, parsedMesh._length, parsedMesh._autoStart);
  90784. };
  90785. return TrailMesh;
  90786. }(_Meshes_mesh__WEBPACK_IMPORTED_MODULE_1__["Mesh"]));
  90787. /***/ }),
  90788. /***/ "./Meshes/transformNode.ts":
  90789. /*!*********************************!*\
  90790. !*** ./Meshes/transformNode.ts ***!
  90791. \*********************************/
  90792. /*! exports provided: TransformNode */
  90793. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  90794. "use strict";
  90795. __webpack_require__.r(__webpack_exports__);
  90796. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return TransformNode; });
  90797. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  90798. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  90799. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  90800. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  90801. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../node */ "./node.ts");
  90802. /**
  90803. * 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.
  90804. * @see https://doc.babylonjs.com/how_to/transformnode
  90805. */
  90806. var TransformNode = /** @class */ (function (_super) {
  90807. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TransformNode, _super);
  90808. function TransformNode(name, scene, isPure) {
  90809. if (scene === void 0) { scene = null; }
  90810. if (isPure === void 0) { isPure = true; }
  90811. var _this = _super.call(this, name, scene) || this;
  90812. _this._forward = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 1);
  90813. _this._forwardInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, -1);
  90814. _this._up = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 1, 0);
  90815. _this._right = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](1, 0, 0);
  90816. _this._rightInverted = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](-1, 0, 0);
  90817. // Properties
  90818. _this._position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90819. _this._rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90820. _this._scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].One();
  90821. _this._isDirty = false;
  90822. /**
  90823. * Set the billboard mode. Default is 0.
  90824. *
  90825. * | Value | Type | Description |
  90826. * | --- | --- | --- |
  90827. * | 0 | BILLBOARDMODE_NONE | |
  90828. * | 1 | BILLBOARDMODE_X | |
  90829. * | 2 | BILLBOARDMODE_Y | |
  90830. * | 4 | BILLBOARDMODE_Z | |
  90831. * | 7 | BILLBOARDMODE_ALL | |
  90832. *
  90833. */
  90834. _this.billboardMode = TransformNode.BILLBOARDMODE_NONE;
  90835. /**
  90836. * 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
  90837. */
  90838. _this.scalingDeterminant = 1;
  90839. /**
  90840. * Sets the distance of the object to max, often used by skybox
  90841. */
  90842. _this.infiniteDistance = false;
  90843. /**
  90844. * Gets or sets a boolean indicating that non uniform scaling (when at least one component is different from others) should be ignored.
  90845. * By default the system will update normals to compensate
  90846. */
  90847. _this.ignoreNonUniformScaling = false;
  90848. /** @hidden */
  90849. _this._localMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Zero();
  90850. _this._absolutePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  90851. _this._pivotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  90852. _this._postMultiplyPivotMatrix = false;
  90853. _this._isWorldMatrixFrozen = false;
  90854. /** @hidden */
  90855. _this._indexInSceneTransformNodesArray = -1;
  90856. /**
  90857. * An event triggered after the world matrix is updated
  90858. */
  90859. _this.onAfterWorldMatrixUpdateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  90860. _this._nonUniformScaling = false;
  90861. if (isPure) {
  90862. _this.getScene().addTransformNode(_this);
  90863. }
  90864. return _this;
  90865. }
  90866. /**
  90867. * Gets a string identifying the name of the class
  90868. * @returns "TransformNode" string
  90869. */
  90870. TransformNode.prototype.getClassName = function () {
  90871. return "TransformNode";
  90872. };
  90873. Object.defineProperty(TransformNode.prototype, "position", {
  90874. /**
  90875. * Gets or set the node position (default is (0.0, 0.0, 0.0))
  90876. */
  90877. get: function () {
  90878. return this._position;
  90879. },
  90880. set: function (newPosition) {
  90881. this._position = newPosition;
  90882. this._isDirty = true;
  90883. },
  90884. enumerable: true,
  90885. configurable: true
  90886. });
  90887. Object.defineProperty(TransformNode.prototype, "rotation", {
  90888. /**
  90889. * 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)).
  90890. * If rotation quaternion is set, this Vector3 will be ignored and copy from the quaternion
  90891. */
  90892. get: function () {
  90893. return this._rotation;
  90894. },
  90895. set: function (newRotation) {
  90896. this._rotation = newRotation;
  90897. this._isDirty = true;
  90898. },
  90899. enumerable: true,
  90900. configurable: true
  90901. });
  90902. Object.defineProperty(TransformNode.prototype, "scaling", {
  90903. /**
  90904. * 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)).
  90905. */
  90906. get: function () {
  90907. return this._scaling;
  90908. },
  90909. set: function (newScaling) {
  90910. this._scaling = newScaling;
  90911. this._isDirty = true;
  90912. },
  90913. enumerable: true,
  90914. configurable: true
  90915. });
  90916. Object.defineProperty(TransformNode.prototype, "rotationQuaternion", {
  90917. /**
  90918. * 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).
  90919. * If set, only the rotationQuaternion is then used to compute the node rotation (ie. node.rotation will be ignored)
  90920. */
  90921. get: function () {
  90922. return this._rotationQuaternion;
  90923. },
  90924. set: function (quaternion) {
  90925. this._rotationQuaternion = quaternion;
  90926. //reset the rotation vector.
  90927. if (quaternion) {
  90928. this.rotation.setAll(0.0);
  90929. }
  90930. },
  90931. enumerable: true,
  90932. configurable: true
  90933. });
  90934. Object.defineProperty(TransformNode.prototype, "forward", {
  90935. /**
  90936. * The forward direction of that transform in world space.
  90937. */
  90938. get: function () {
  90939. 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()));
  90940. },
  90941. enumerable: true,
  90942. configurable: true
  90943. });
  90944. Object.defineProperty(TransformNode.prototype, "up", {
  90945. /**
  90946. * The up direction of that transform in world space.
  90947. */
  90948. get: function () {
  90949. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Normalize(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this._up, this.getWorldMatrix()));
  90950. },
  90951. enumerable: true,
  90952. configurable: true
  90953. });
  90954. Object.defineProperty(TransformNode.prototype, "right", {
  90955. /**
  90956. * The right direction of that transform in world space.
  90957. */
  90958. get: function () {
  90959. 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()));
  90960. },
  90961. enumerable: true,
  90962. configurable: true
  90963. });
  90964. /**
  90965. * Copies the parameter passed Matrix into the mesh Pose matrix.
  90966. * @param matrix the matrix to copy the pose from
  90967. * @returns this TransformNode.
  90968. */
  90969. TransformNode.prototype.updatePoseMatrix = function (matrix) {
  90970. this._poseMatrix.copyFrom(matrix);
  90971. return this;
  90972. };
  90973. /**
  90974. * Returns the mesh Pose matrix.
  90975. * @returns the pose matrix
  90976. */
  90977. TransformNode.prototype.getPoseMatrix = function () {
  90978. return this._poseMatrix;
  90979. };
  90980. /** @hidden */
  90981. TransformNode.prototype._isSynchronized = function () {
  90982. if (this._isDirty) {
  90983. return false;
  90984. }
  90985. if (this.billboardMode !== this._cache.billboardMode || this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  90986. return false;
  90987. }
  90988. if (this._cache.pivotMatrixUpdated) {
  90989. return false;
  90990. }
  90991. if (this.infiniteDistance) {
  90992. return false;
  90993. }
  90994. if (!this._cache.position.equals(this._position)) {
  90995. return false;
  90996. }
  90997. if (this._rotationQuaternion) {
  90998. if (!this._cache.rotationQuaternion.equals(this._rotationQuaternion)) {
  90999. return false;
  91000. }
  91001. }
  91002. if (!this._cache.rotation.equals(this._rotation)) {
  91003. return false;
  91004. }
  91005. if (!this._cache.scaling.equals(this._scaling)) {
  91006. return false;
  91007. }
  91008. return true;
  91009. };
  91010. /** @hidden */
  91011. TransformNode.prototype._initCache = function () {
  91012. _super.prototype._initCache.call(this);
  91013. this._cache.localMatrixUpdated = false;
  91014. this._cache.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91015. this._cache.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91016. this._cache.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91017. this._cache.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"](0, 0, 0, 0);
  91018. this._cache.billboardMode = -1;
  91019. this._cache.infiniteDistance = false;
  91020. };
  91021. /**
  91022. * Flag the transform node as dirty (Forcing it to update everything)
  91023. * @param property if set to "rotation" the objects rotationQuaternion will be set to null
  91024. * @returns this transform node
  91025. */
  91026. TransformNode.prototype.markAsDirty = function (property) {
  91027. if (property === "rotation") {
  91028. this.rotationQuaternion = null;
  91029. }
  91030. this._currentRenderId = Number.MAX_VALUE;
  91031. this._isDirty = true;
  91032. return this;
  91033. };
  91034. Object.defineProperty(TransformNode.prototype, "absolutePosition", {
  91035. /**
  91036. * Returns the current mesh absolute position.
  91037. * Returns a Vector3.
  91038. */
  91039. get: function () {
  91040. return this._absolutePosition;
  91041. },
  91042. enumerable: true,
  91043. configurable: true
  91044. });
  91045. /**
  91046. * Sets a new matrix to apply before all other transformation
  91047. * @param matrix defines the transform matrix
  91048. * @returns the current TransformNode
  91049. */
  91050. TransformNode.prototype.setPreTransformMatrix = function (matrix) {
  91051. return this.setPivotMatrix(matrix, false);
  91052. };
  91053. /**
  91054. * Sets a new pivot matrix to the current node
  91055. * @param matrix defines the new pivot matrix to use
  91056. * @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
  91057. * @returns the current TransformNode
  91058. */
  91059. TransformNode.prototype.setPivotMatrix = function (matrix, postMultiplyPivotMatrix) {
  91060. if (postMultiplyPivotMatrix === void 0) { postMultiplyPivotMatrix = true; }
  91061. this._pivotMatrix.copyFrom(matrix);
  91062. this._cache.pivotMatrixUpdated = true;
  91063. this._postMultiplyPivotMatrix = postMultiplyPivotMatrix;
  91064. if (this._postMultiplyPivotMatrix) {
  91065. if (!this._pivotMatrixInverse) {
  91066. this._pivotMatrixInverse = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._pivotMatrix);
  91067. }
  91068. else {
  91069. this._pivotMatrix.invertToRef(this._pivotMatrixInverse);
  91070. }
  91071. }
  91072. return this;
  91073. };
  91074. /**
  91075. * Returns the mesh pivot matrix.
  91076. * Default : Identity.
  91077. * @returns the matrix
  91078. */
  91079. TransformNode.prototype.getPivotMatrix = function () {
  91080. return this._pivotMatrix;
  91081. };
  91082. /**
  91083. * Prevents the World matrix to be computed any longer.
  91084. * @returns the TransformNode.
  91085. */
  91086. TransformNode.prototype.freezeWorldMatrix = function () {
  91087. this._isWorldMatrixFrozen = false; // no guarantee world is not already frozen, switch off temporarily
  91088. this.computeWorldMatrix(true);
  91089. this._isWorldMatrixFrozen = true;
  91090. return this;
  91091. };
  91092. /**
  91093. * Allows back the World matrix computation.
  91094. * @returns the TransformNode.
  91095. */
  91096. TransformNode.prototype.unfreezeWorldMatrix = function () {
  91097. this._isWorldMatrixFrozen = false;
  91098. this.computeWorldMatrix(true);
  91099. return this;
  91100. };
  91101. Object.defineProperty(TransformNode.prototype, "isWorldMatrixFrozen", {
  91102. /**
  91103. * True if the World matrix has been frozen.
  91104. */
  91105. get: function () {
  91106. return this._isWorldMatrixFrozen;
  91107. },
  91108. enumerable: true,
  91109. configurable: true
  91110. });
  91111. /**
  91112. * Retuns the mesh absolute position in the World.
  91113. * @returns a Vector3.
  91114. */
  91115. TransformNode.prototype.getAbsolutePosition = function () {
  91116. this.computeWorldMatrix();
  91117. return this._absolutePosition;
  91118. };
  91119. /**
  91120. * Sets the mesh absolute position in the World from a Vector3 or an Array(3).
  91121. * @param absolutePosition the absolute position to set
  91122. * @returns the TransformNode.
  91123. */
  91124. TransformNode.prototype.setAbsolutePosition = function (absolutePosition) {
  91125. if (!absolutePosition) {
  91126. return this;
  91127. }
  91128. var absolutePositionX;
  91129. var absolutePositionY;
  91130. var absolutePositionZ;
  91131. if (absolutePosition.x === undefined) {
  91132. if (arguments.length < 3) {
  91133. return this;
  91134. }
  91135. absolutePositionX = arguments[0];
  91136. absolutePositionY = arguments[1];
  91137. absolutePositionZ = arguments[2];
  91138. }
  91139. else {
  91140. absolutePositionX = absolutePosition.x;
  91141. absolutePositionY = absolutePosition.y;
  91142. absolutePositionZ = absolutePosition.z;
  91143. }
  91144. if (this.parent) {
  91145. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91146. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  91147. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesFromFloatsToRef(absolutePositionX, absolutePositionY, absolutePositionZ, invertParentWorldMatrix, this.position);
  91148. }
  91149. else {
  91150. this.position.x = absolutePositionX;
  91151. this.position.y = absolutePositionY;
  91152. this.position.z = absolutePositionZ;
  91153. }
  91154. return this;
  91155. };
  91156. /**
  91157. * Sets the mesh position in its local space.
  91158. * @param vector3 the position to set in localspace
  91159. * @returns the TransformNode.
  91160. */
  91161. TransformNode.prototype.setPositionWithLocalVector = function (vector3) {
  91162. this.computeWorldMatrix();
  91163. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(vector3, this._localMatrix);
  91164. return this;
  91165. };
  91166. /**
  91167. * Returns the mesh position in the local space from the current World matrix values.
  91168. * @returns a new Vector3.
  91169. */
  91170. TransformNode.prototype.getPositionExpressedInLocalSpace = function () {
  91171. this.computeWorldMatrix();
  91172. var invLocalWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91173. this._localMatrix.invertToRef(invLocalWorldMatrix);
  91174. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(this.position, invLocalWorldMatrix);
  91175. };
  91176. /**
  91177. * Translates the mesh along the passed Vector3 in its local space.
  91178. * @param vector3 the distance to translate in localspace
  91179. * @returns the TransformNode.
  91180. */
  91181. TransformNode.prototype.locallyTranslate = function (vector3) {
  91182. this.computeWorldMatrix(true);
  91183. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(vector3, this._localMatrix);
  91184. return this;
  91185. };
  91186. /**
  91187. * Orients a mesh towards a target point. Mesh must be drawn facing user.
  91188. * @param targetPoint the position (must be in same space as current mesh) to look at
  91189. * @param yawCor optional yaw (y-axis) correction in radians
  91190. * @param pitchCor optional pitch (x-axis) correction in radians
  91191. * @param rollCor optional roll (z-axis) correction in radians
  91192. * @param space the choosen space of the target
  91193. * @returns the TransformNode.
  91194. */
  91195. TransformNode.prototype.lookAt = function (targetPoint, yawCor, pitchCor, rollCor, space) {
  91196. if (yawCor === void 0) { yawCor = 0; }
  91197. if (pitchCor === void 0) { pitchCor = 0; }
  91198. if (rollCor === void 0) { rollCor = 0; }
  91199. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  91200. var dv = TransformNode._lookAtVectorCache;
  91201. var pos = space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL ? this.position : this.getAbsolutePosition();
  91202. targetPoint.subtractToRef(pos, dv);
  91203. this.setDirection(dv, yawCor, pitchCor, rollCor);
  91204. // Correct for parent's rotation offset
  91205. if (space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD && this.parent) {
  91206. if (this.rotationQuaternion) {
  91207. // Get local rotation matrix of the looking object
  91208. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91209. this.rotationQuaternion.toRotationMatrix(rotationMatrix);
  91210. // Offset rotation by parent's inverted rotation matrix to correct in world space
  91211. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  91212. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  91213. parentRotationMatrix.invert();
  91214. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  91215. this.rotationQuaternion.fromRotationMatrix(rotationMatrix);
  91216. }
  91217. else {
  91218. // Get local rotation matrix of the looking object
  91219. var quaternionRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  91220. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].FromEulerVectorToRef(this.rotation, quaternionRotation);
  91221. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91222. quaternionRotation.toRotationMatrix(rotationMatrix);
  91223. // Offset rotation by parent's inverted rotation matrix to correct in world space
  91224. var parentRotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  91225. this.parent.getWorldMatrix().getRotationMatrixToRef(parentRotationMatrix);
  91226. parentRotationMatrix.invert();
  91227. rotationMatrix.multiplyToRef(parentRotationMatrix, rotationMatrix);
  91228. quaternionRotation.fromRotationMatrix(rotationMatrix);
  91229. quaternionRotation.toEulerAnglesToRef(this.rotation);
  91230. }
  91231. }
  91232. return this;
  91233. };
  91234. /**
  91235. * Returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91236. * This Vector3 is expressed in the World space.
  91237. * @param localAxis axis to rotate
  91238. * @returns a new Vector3 that is the localAxis, expressed in the mesh local space, rotated like the mesh.
  91239. */
  91240. TransformNode.prototype.getDirection = function (localAxis) {
  91241. var result = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91242. this.getDirectionToRef(localAxis, result);
  91243. return result;
  91244. };
  91245. /**
  91246. * Sets the Vector3 "result" as the rotated Vector3 "localAxis" in the same rotation than the mesh.
  91247. * localAxis is expressed in the mesh local space.
  91248. * result is computed in the Wordl space from the mesh World matrix.
  91249. * @param localAxis axis to rotate
  91250. * @param result the resulting transformnode
  91251. * @returns this TransformNode.
  91252. */
  91253. TransformNode.prototype.getDirectionToRef = function (localAxis, result) {
  91254. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormalToRef(localAxis, this.getWorldMatrix(), result);
  91255. return this;
  91256. };
  91257. /**
  91258. * Sets this transform node rotation to the given local axis.
  91259. * @param localAxis the axis in local space
  91260. * @param yawCor optional yaw (y-axis) correction in radians
  91261. * @param pitchCor optional pitch (x-axis) correction in radians
  91262. * @param rollCor optional roll (z-axis) correction in radians
  91263. * @returns this TransformNode
  91264. */
  91265. TransformNode.prototype.setDirection = function (localAxis, yawCor, pitchCor, rollCor) {
  91266. if (yawCor === void 0) { yawCor = 0; }
  91267. if (pitchCor === void 0) { pitchCor = 0; }
  91268. if (rollCor === void 0) { rollCor = 0; }
  91269. var yaw = -Math.atan2(localAxis.z, localAxis.x) + Math.PI / 2;
  91270. var len = Math.sqrt(localAxis.x * localAxis.x + localAxis.z * localAxis.z);
  91271. var pitch = -Math.atan2(localAxis.y, len);
  91272. if (this.rotationQuaternion) {
  91273. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(yaw + yawCor, pitch + pitchCor, rollCor, this.rotationQuaternion);
  91274. }
  91275. else {
  91276. this.rotation.x = pitch + pitchCor;
  91277. this.rotation.y = yaw + yawCor;
  91278. this.rotation.z = rollCor;
  91279. }
  91280. return this;
  91281. };
  91282. /**
  91283. * Sets a new pivot point to the current node
  91284. * @param point defines the new pivot point to use
  91285. * @param space defines if the point is in world or local space (local by default)
  91286. * @returns the current TransformNode
  91287. */
  91288. TransformNode.prototype.setPivotPoint = function (point, space) {
  91289. if (space === void 0) { space = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL; }
  91290. if (this.getScene().getRenderId() == 0) {
  91291. this.computeWorldMatrix(true);
  91292. }
  91293. var wm = this.getWorldMatrix();
  91294. if (space == _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].WORLD) {
  91295. var tmat = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91296. wm.invertToRef(tmat);
  91297. point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(point, tmat);
  91298. }
  91299. return this.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(-point.x, -point.y, -point.z), true);
  91300. };
  91301. /**
  91302. * Returns a new Vector3 set with the mesh pivot point coordinates in the local space.
  91303. * @returns the pivot point
  91304. */
  91305. TransformNode.prototype.getPivotPoint = function () {
  91306. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91307. this.getPivotPointToRef(point);
  91308. return point;
  91309. };
  91310. /**
  91311. * Sets the passed Vector3 "result" with the coordinates of the mesh pivot point in the local space.
  91312. * @param result the vector3 to store the result
  91313. * @returns this TransformNode.
  91314. */
  91315. TransformNode.prototype.getPivotPointToRef = function (result) {
  91316. result.x = -this._pivotMatrix.m[12];
  91317. result.y = -this._pivotMatrix.m[13];
  91318. result.z = -this._pivotMatrix.m[14];
  91319. return this;
  91320. };
  91321. /**
  91322. * Returns a new Vector3 set with the mesh pivot point World coordinates.
  91323. * @returns a new Vector3 set with the mesh pivot point World coordinates.
  91324. */
  91325. TransformNode.prototype.getAbsolutePivotPoint = function () {
  91326. var point = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  91327. this.getAbsolutePivotPointToRef(point);
  91328. return point;
  91329. };
  91330. /**
  91331. * Sets the Vector3 "result" coordinates with the mesh pivot point World coordinates.
  91332. * @param result vector3 to store the result
  91333. * @returns this TransformNode.
  91334. */
  91335. TransformNode.prototype.getAbsolutePivotPointToRef = function (result) {
  91336. result.x = this._pivotMatrix.m[12];
  91337. result.y = this._pivotMatrix.m[13];
  91338. result.z = this._pivotMatrix.m[14];
  91339. this.getPivotPointToRef(result);
  91340. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(result, this.getWorldMatrix(), result);
  91341. return this;
  91342. };
  91343. /**
  91344. * Defines the passed node as the parent of the current node.
  91345. * The node will remain exactly where it is and its position / rotation will be updated accordingly
  91346. * @param node the node ot set as the parent
  91347. * @returns this TransformNode.
  91348. */
  91349. TransformNode.prototype.setParent = function (node) {
  91350. if (!node && !this.parent) {
  91351. return this;
  91352. }
  91353. var quatRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  91354. var position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  91355. var scale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  91356. if (!node) {
  91357. if (this.parent && this.parent.computeWorldMatrix) {
  91358. this.parent.computeWorldMatrix(true);
  91359. }
  91360. this.computeWorldMatrix(true);
  91361. this.getWorldMatrix().decompose(scale, quatRotation, position);
  91362. }
  91363. else {
  91364. var diffMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91365. var invParentMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1];
  91366. this.computeWorldMatrix(true);
  91367. node.computeWorldMatrix(true);
  91368. node.getWorldMatrix().invertToRef(invParentMatrix);
  91369. this.getWorldMatrix().multiplyToRef(invParentMatrix, diffMatrix);
  91370. diffMatrix.decompose(scale, quatRotation, position);
  91371. }
  91372. if (this.rotationQuaternion) {
  91373. this.rotationQuaternion.copyFrom(quatRotation);
  91374. }
  91375. else {
  91376. quatRotation.toEulerAnglesToRef(this.rotation);
  91377. }
  91378. this.scaling.copyFrom(scale);
  91379. this.position.copyFrom(position);
  91380. this.parent = node;
  91381. return this;
  91382. };
  91383. Object.defineProperty(TransformNode.prototype, "nonUniformScaling", {
  91384. /**
  91385. * True if the scaling property of this object is non uniform eg. (1,2,1)
  91386. */
  91387. get: function () {
  91388. return this._nonUniformScaling;
  91389. },
  91390. enumerable: true,
  91391. configurable: true
  91392. });
  91393. /** @hidden */
  91394. TransformNode.prototype._updateNonUniformScalingState = function (value) {
  91395. if (this._nonUniformScaling === value) {
  91396. return false;
  91397. }
  91398. this._nonUniformScaling = value;
  91399. return true;
  91400. };
  91401. /**
  91402. * Attach the current TransformNode to another TransformNode associated with a bone
  91403. * @param bone Bone affecting the TransformNode
  91404. * @param affectedTransformNode TransformNode associated with the bone
  91405. * @returns this object
  91406. */
  91407. TransformNode.prototype.attachToBone = function (bone, affectedTransformNode) {
  91408. this._transformToBoneReferal = affectedTransformNode;
  91409. this.parent = bone;
  91410. if (bone.getWorldMatrix().determinant() < 0) {
  91411. this.scalingDeterminant *= -1;
  91412. }
  91413. return this;
  91414. };
  91415. /**
  91416. * Detach the transform node if its associated with a bone
  91417. * @returns this object
  91418. */
  91419. TransformNode.prototype.detachFromBone = function () {
  91420. if (!this.parent) {
  91421. return this;
  91422. }
  91423. if (this.parent.getWorldMatrix().determinant() < 0) {
  91424. this.scalingDeterminant *= -1;
  91425. }
  91426. this._transformToBoneReferal = null;
  91427. this.parent = null;
  91428. return this;
  91429. };
  91430. /**
  91431. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in the given space.
  91432. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91433. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91434. * The passed axis is also normalized.
  91435. * @param axis the axis to rotate around
  91436. * @param amount the amount to rotate in radians
  91437. * @param space Space to rotate in (Default: local)
  91438. * @returns the TransformNode.
  91439. */
  91440. TransformNode.prototype.rotate = function (axis, amount, space) {
  91441. axis.normalize();
  91442. if (!this.rotationQuaternion) {
  91443. this.rotationQuaternion = this.rotation.toQuaternion();
  91444. this.rotation.setAll(0);
  91445. }
  91446. var rotationQuaternion;
  91447. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  91448. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  91449. this.rotationQuaternion.multiplyToRef(rotationQuaternion, this.rotationQuaternion);
  91450. }
  91451. else {
  91452. if (this.parent) {
  91453. var invertParentWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0];
  91454. this.parent.getWorldMatrix().invertToRef(invertParentWorldMatrix);
  91455. axis = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformNormal(axis, invertParentWorldMatrix);
  91456. }
  91457. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationAxisToRef(axis, amount, TransformNode._rotationAxisCache);
  91458. rotationQuaternion.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  91459. }
  91460. return this;
  91461. };
  91462. /**
  91463. * Rotates the mesh around the axis vector for the passed angle (amount) expressed in radians, in world space.
  91464. * Note that the property `rotationQuaternion` is then automatically updated and the property `rotation` is set to (0,0,0) and no longer used.
  91465. * The passed axis is also normalized. .
  91466. * Method is based on http://www.euclideanspace.com/maths/geometry/affine/aroundPoint/index.htm
  91467. * @param point the point to rotate around
  91468. * @param axis the axis to rotate around
  91469. * @param amount the amount to rotate in radians
  91470. * @returns the TransformNode
  91471. */
  91472. TransformNode.prototype.rotateAround = function (point, axis, amount) {
  91473. axis.normalize();
  91474. if (!this.rotationQuaternion) {
  91475. this.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z);
  91476. this.rotation.setAll(0);
  91477. }
  91478. var tmpVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  91479. var finalScale = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  91480. var finalTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[2];
  91481. var finalRotation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  91482. var translationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]; // T
  91483. var translationMatrixInv = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]; // T'
  91484. var rotationMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]; // R
  91485. var finalMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[3]; // T' x R x T
  91486. point.subtractToRef(this.position, tmpVector);
  91487. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(tmpVector.x, tmpVector.y, tmpVector.z, translationMatrix); // T
  91488. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(-tmpVector.x, -tmpVector.y, -tmpVector.z, translationMatrixInv); // T'
  91489. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationAxisToRef(axis, amount, rotationMatrix); // R
  91490. translationMatrixInv.multiplyToRef(rotationMatrix, finalMatrix); // T' x R
  91491. finalMatrix.multiplyToRef(translationMatrix, finalMatrix); // T' x R x T
  91492. finalMatrix.decompose(finalScale, finalRotation, finalTranslation);
  91493. this.position.addInPlace(finalTranslation);
  91494. finalRotation.multiplyToRef(this.rotationQuaternion, this.rotationQuaternion);
  91495. return this;
  91496. };
  91497. /**
  91498. * Translates the mesh along the axis vector for the passed distance in the given space.
  91499. * space (default LOCAL) can be either Space.LOCAL, either Space.WORLD.
  91500. * @param axis the axis to translate in
  91501. * @param distance the distance to translate
  91502. * @param space Space to rotate in (Default: local)
  91503. * @returns the TransformNode.
  91504. */
  91505. TransformNode.prototype.translate = function (axis, distance, space) {
  91506. var displacementVector = axis.scale(distance);
  91507. if (!space || space === _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Space"].LOCAL) {
  91508. var tempV3 = this.getPositionExpressedInLocalSpace().add(displacementVector);
  91509. this.setPositionWithLocalVector(tempV3);
  91510. }
  91511. else {
  91512. this.setAbsolutePosition(this.getAbsolutePosition().add(displacementVector));
  91513. }
  91514. return this;
  91515. };
  91516. /**
  91517. * Adds a rotation step to the mesh current rotation.
  91518. * x, y, z are Euler angles expressed in radians.
  91519. * This methods updates the current mesh rotation, either mesh.rotation, either mesh.rotationQuaternion if it's set.
  91520. * This means this rotation is made in the mesh local space only.
  91521. * It's useful to set a custom rotation order different from the BJS standard one YXZ.
  91522. * Example : this rotates the mesh first around its local X axis, then around its local Z axis, finally around its local Y axis.
  91523. * ```javascript
  91524. * mesh.addRotation(x1, 0, 0).addRotation(0, 0, z2).addRotation(0, 0, y3);
  91525. * ```
  91526. * Note that `addRotation()` accumulates the passed rotation values to the current ones and computes the .rotation or .rotationQuaternion updated values.
  91527. * 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.
  91528. * @param x Rotation to add
  91529. * @param y Rotation to add
  91530. * @param z Rotation to add
  91531. * @returns the TransformNode.
  91532. */
  91533. TransformNode.prototype.addRotation = function (x, y, z) {
  91534. var rotationQuaternion;
  91535. if (this.rotationQuaternion) {
  91536. rotationQuaternion = this.rotationQuaternion;
  91537. }
  91538. else {
  91539. rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[1];
  91540. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, rotationQuaternion);
  91541. }
  91542. var accumulation = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Quaternion[0];
  91543. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRollToRef(y, x, z, accumulation);
  91544. rotationQuaternion.multiplyInPlace(accumulation);
  91545. if (!this.rotationQuaternion) {
  91546. rotationQuaternion.toEulerAnglesToRef(this.rotation);
  91547. }
  91548. return this;
  91549. };
  91550. /**
  91551. * Computes the world matrix of the node
  91552. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  91553. * @returns the world matrix
  91554. */
  91555. TransformNode.prototype.computeWorldMatrix = function (force) {
  91556. if (this._isWorldMatrixFrozen) {
  91557. return this._worldMatrix;
  91558. }
  91559. if (!force && this.isSynchronized()) {
  91560. this._currentRenderId = this.getScene().getRenderId();
  91561. return this._worldMatrix;
  91562. }
  91563. this._updateCache();
  91564. this._cache.position.copyFrom(this.position);
  91565. this._cache.scaling.copyFrom(this.scaling);
  91566. this._cache.pivotMatrixUpdated = false;
  91567. this._cache.billboardMode = this.billboardMode;
  91568. this._cache.infiniteDistance = this.infiniteDistance;
  91569. this._currentRenderId = this.getScene().getRenderId();
  91570. this._childRenderId = this.getScene().getRenderId();
  91571. this._isDirty = false;
  91572. // Scaling
  91573. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].ScalingToRef(this.scaling.x * this.scalingDeterminant, this.scaling.y * this.scalingDeterminant, this.scaling.z * this.scalingDeterminant, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1]);
  91574. // Rotation
  91575. //rotate, if quaternion is set and rotation was used
  91576. if (this.rotationQuaternion) {
  91577. var len = this.rotation.length();
  91578. if (len) {
  91579. this.rotationQuaternion.multiplyInPlace(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"].RotationYawPitchRoll(this.rotation.y, this.rotation.x, this.rotation.z));
  91580. this.rotation.copyFromFloats(0, 0, 0);
  91581. }
  91582. }
  91583. if (this.rotationQuaternion) {
  91584. this.rotationQuaternion.toRotationMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  91585. this._cache.rotationQuaternion.copyFrom(this.rotationQuaternion);
  91586. }
  91587. else {
  91588. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(this.rotation.y, this.rotation.x, this.rotation.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  91589. this._cache.rotation.copyFrom(this.rotation);
  91590. }
  91591. // Translation
  91592. var camera = this.getScene().activeCamera;
  91593. if (this.infiniteDistance && !this.parent && camera) {
  91594. var cameraWorldMatrix = camera.getWorldMatrix();
  91595. var cameraGlobalPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](cameraWorldMatrix.m[12], cameraWorldMatrix.m[13], cameraWorldMatrix.m[14]);
  91596. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x + cameraGlobalPosition.x, this.position.y + cameraGlobalPosition.y, this.position.z + cameraGlobalPosition.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  91597. }
  91598. else {
  91599. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].TranslationToRef(this.position.x, this.position.y, this.position.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2]);
  91600. }
  91601. // Composing transformations
  91602. this._pivotMatrix.multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4]);
  91603. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[4].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  91604. // Billboarding (testing PG:http://www.babylonjs-playground.com/#UJEIL#13)
  91605. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE && camera) {
  91606. if ((this.billboardMode & TransformNode.BILLBOARDMODE_ALL) !== TransformNode.BILLBOARDMODE_ALL) {
  91607. // Need to decompose each rotation here
  91608. var currentPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[3];
  91609. if (this.parent && this.parent.getWorldMatrix) {
  91610. if (this._transformToBoneReferal) {
  91611. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91612. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6], currentPosition);
  91613. }
  91614. else {
  91615. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(this.position, this.parent.getWorldMatrix(), currentPosition);
  91616. }
  91617. }
  91618. else {
  91619. currentPosition.copyFrom(this.position);
  91620. }
  91621. currentPosition.subtractInPlace(camera.globalPosition);
  91622. var finalEuler = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[4].copyFromFloats(0, 0, 0);
  91623. if ((this.billboardMode & TransformNode.BILLBOARDMODE_X) === TransformNode.BILLBOARDMODE_X) {
  91624. finalEuler.x = Math.atan2(-currentPosition.y, currentPosition.z);
  91625. }
  91626. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Y) === TransformNode.BILLBOARDMODE_Y) {
  91627. finalEuler.y = Math.atan2(currentPosition.x, currentPosition.z);
  91628. }
  91629. if ((this.billboardMode & TransformNode.BILLBOARDMODE_Z) === TransformNode.BILLBOARDMODE_Z) {
  91630. finalEuler.z = Math.atan2(currentPosition.y, currentPosition.x);
  91631. }
  91632. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].RotationYawPitchRollToRef(finalEuler.y, finalEuler.x, finalEuler.z, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  91633. }
  91634. else {
  91635. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(camera.getViewMatrix());
  91636. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].setTranslationFromFloats(0, 0, 0);
  91637. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].invertToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0]);
  91638. }
  91639. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  91640. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[1].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[0], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  91641. }
  91642. // Post multiply inverse of pivotMatrix
  91643. if (this._postMultiplyPivotMatrix) {
  91644. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(this._pivotMatrixInverse, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5]);
  91645. }
  91646. // Local world
  91647. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].multiplyToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[2], this._localMatrix);
  91648. // Parent
  91649. if (this.parent && this.parent.getWorldMatrix) {
  91650. if (this.billboardMode !== TransformNode.BILLBOARDMODE_NONE) {
  91651. if (this._transformToBoneReferal) {
  91652. this.parent.getWorldMatrix().multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91653. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91654. }
  91655. else {
  91656. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5].copyFrom(this.parent.getWorldMatrix());
  91657. }
  91658. this._localMatrix.getTranslationToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91659. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[5], _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91660. this._worldMatrix.copyFrom(this._localMatrix);
  91661. this._worldMatrix.setTranslation(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[5]);
  91662. }
  91663. else {
  91664. if (this._transformToBoneReferal) {
  91665. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6]);
  91666. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Matrix[6].multiplyToRef(this._transformToBoneReferal.getWorldMatrix(), this._worldMatrix);
  91667. }
  91668. else {
  91669. this._localMatrix.multiplyToRef(this.parent.getWorldMatrix(), this._worldMatrix);
  91670. }
  91671. }
  91672. this._markSyncedWithParent();
  91673. }
  91674. else {
  91675. this._worldMatrix.copyFrom(this._localMatrix);
  91676. }
  91677. // Normal matrix
  91678. if (!this.ignoreNonUniformScaling) {
  91679. if (this.scaling.isNonUniform) {
  91680. this._updateNonUniformScalingState(true);
  91681. }
  91682. else if (this.parent && this.parent._nonUniformScaling) {
  91683. this._updateNonUniformScalingState(this.parent._nonUniformScaling);
  91684. }
  91685. else {
  91686. this._updateNonUniformScalingState(false);
  91687. }
  91688. }
  91689. else {
  91690. this._updateNonUniformScalingState(false);
  91691. }
  91692. this._afterComputeWorldMatrix();
  91693. // Absolute position
  91694. this._absolutePosition.copyFromFloats(this._worldMatrix.m[12], this._worldMatrix.m[13], this._worldMatrix.m[14]);
  91695. // Callbacks
  91696. this.onAfterWorldMatrixUpdateObservable.notifyObservers(this);
  91697. if (!this._poseMatrix) {
  91698. this._poseMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Invert(this._worldMatrix);
  91699. }
  91700. // Cache the determinant
  91701. this._worldMatrixDeterminant = this._worldMatrix.determinant();
  91702. return this._worldMatrix;
  91703. };
  91704. TransformNode.prototype._afterComputeWorldMatrix = function () {
  91705. };
  91706. /**
  91707. * If you'd like to be called back after the mesh position, rotation or scaling has been updated.
  91708. * @param func callback function to add
  91709. *
  91710. * @returns the TransformNode.
  91711. */
  91712. TransformNode.prototype.registerAfterWorldMatrixUpdate = function (func) {
  91713. this.onAfterWorldMatrixUpdateObservable.add(func);
  91714. return this;
  91715. };
  91716. /**
  91717. * Removes a registered callback function.
  91718. * @param func callback function to remove
  91719. * @returns the TransformNode.
  91720. */
  91721. TransformNode.prototype.unregisterAfterWorldMatrixUpdate = function (func) {
  91722. this.onAfterWorldMatrixUpdateObservable.removeCallback(func);
  91723. return this;
  91724. };
  91725. /**
  91726. * Gets the position of the current mesh in camera space
  91727. * @param camera defines the camera to use
  91728. * @returns a position
  91729. */
  91730. TransformNode.prototype.getPositionInCameraSpace = function (camera) {
  91731. if (camera === void 0) { camera = null; }
  91732. if (!camera) {
  91733. camera = this.getScene().activeCamera;
  91734. }
  91735. return _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinates(this.absolutePosition, camera.getViewMatrix());
  91736. };
  91737. /**
  91738. * Returns the distance from the mesh to the active camera
  91739. * @param camera defines the camera to use
  91740. * @returns the distance
  91741. */
  91742. TransformNode.prototype.getDistanceToCamera = function (camera) {
  91743. if (camera === void 0) { camera = null; }
  91744. if (!camera) {
  91745. camera = this.getScene().activeCamera;
  91746. }
  91747. return this.absolutePosition.subtract(camera.position).length();
  91748. };
  91749. /**
  91750. * Clone the current transform node
  91751. * @param name Name of the new clone
  91752. * @param newParent New parent for the clone
  91753. * @param doNotCloneChildren Do not clone children hierarchy
  91754. * @returns the new transform node
  91755. */
  91756. TransformNode.prototype.clone = function (name, newParent, doNotCloneChildren) {
  91757. var _this = this;
  91758. var result = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Clone(function () { return new TransformNode(name, _this.getScene()); }, this);
  91759. result.name = name;
  91760. result.id = name;
  91761. if (newParent) {
  91762. result.parent = newParent;
  91763. }
  91764. if (!doNotCloneChildren) {
  91765. // Children
  91766. var directDescendants = this.getDescendants(true);
  91767. for (var index = 0; index < directDescendants.length; index++) {
  91768. var child = directDescendants[index];
  91769. if (child.clone) {
  91770. child.clone(name + "." + child.name, result);
  91771. }
  91772. }
  91773. }
  91774. return result;
  91775. };
  91776. /**
  91777. * Serializes the objects information.
  91778. * @param currentSerializationObject defines the object to serialize in
  91779. * @returns the serialized object
  91780. */
  91781. TransformNode.prototype.serialize = function (currentSerializationObject) {
  91782. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, currentSerializationObject);
  91783. serializationObject.type = this.getClassName();
  91784. // Parent
  91785. if (this.parent) {
  91786. serializationObject.parentId = this.parent.id;
  91787. }
  91788. serializationObject.localMatrix = this.getPivotMatrix().asArray();
  91789. serializationObject.isEnabled = this.isEnabled();
  91790. // Parent
  91791. if (this.parent) {
  91792. serializationObject.parentId = this.parent.id;
  91793. }
  91794. return serializationObject;
  91795. };
  91796. // Statics
  91797. /**
  91798. * Returns a new TransformNode object parsed from the source provided.
  91799. * @param parsedTransformNode is the source.
  91800. * @param scene the scne the object belongs to
  91801. * @param rootUrl is a string, it's the root URL to prefix the `delayLoadingFile` property with
  91802. * @returns a new TransformNode object parsed from the source provided.
  91803. */
  91804. TransformNode.Parse = function (parsedTransformNode, scene, rootUrl) {
  91805. var transformNode = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new TransformNode(parsedTransformNode.name, scene); }, parsedTransformNode, scene, rootUrl);
  91806. if (parsedTransformNode.localMatrix) {
  91807. transformNode.setPreTransformMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.localMatrix));
  91808. }
  91809. else if (parsedTransformNode.pivotMatrix) {
  91810. transformNode.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].FromArray(parsedTransformNode.pivotMatrix));
  91811. }
  91812. transformNode.setEnabled(parsedTransformNode.isEnabled);
  91813. // Parent
  91814. if (parsedTransformNode.parentId) {
  91815. transformNode._waitingParentId = parsedTransformNode.parentId;
  91816. }
  91817. return transformNode;
  91818. };
  91819. /**
  91820. * Get all child-transformNodes of this node
  91821. * @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
  91822. * @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
  91823. * @returns an array of TransformNode
  91824. */
  91825. TransformNode.prototype.getChildTransformNodes = function (directDescendantsOnly, predicate) {
  91826. var results = [];
  91827. this._getDescendants(results, directDescendantsOnly, function (node) {
  91828. return ((!predicate || predicate(node)) && (node instanceof TransformNode));
  91829. });
  91830. return results;
  91831. };
  91832. /**
  91833. * Releases resources associated with this transform node.
  91834. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  91835. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  91836. */
  91837. TransformNode.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  91838. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  91839. // Animations
  91840. this.getScene().stopAnimation(this);
  91841. // Remove from scene
  91842. this.getScene().removeTransformNode(this);
  91843. this.onAfterWorldMatrixUpdateObservable.clear();
  91844. if (doNotRecurse) {
  91845. var transformNodes = this.getChildTransformNodes(true);
  91846. for (var _i = 0, transformNodes_1 = transformNodes; _i < transformNodes_1.length; _i++) {
  91847. var transformNode = transformNodes_1[_i];
  91848. transformNode.parent = null;
  91849. transformNode.computeWorldMatrix(true);
  91850. }
  91851. }
  91852. _super.prototype.dispose.call(this, doNotRecurse, disposeMaterialAndTextures);
  91853. };
  91854. // Statics
  91855. /**
  91856. * Object will not rotate to face the camera
  91857. */
  91858. TransformNode.BILLBOARDMODE_NONE = 0;
  91859. /**
  91860. * Object will rotate to face the camera but only on the x axis
  91861. */
  91862. TransformNode.BILLBOARDMODE_X = 1;
  91863. /**
  91864. * Object will rotate to face the camera but only on the y axis
  91865. */
  91866. TransformNode.BILLBOARDMODE_Y = 2;
  91867. /**
  91868. * Object will rotate to face the camera but only on the z axis
  91869. */
  91870. TransformNode.BILLBOARDMODE_Z = 4;
  91871. /**
  91872. * Object will rotate to face the camera
  91873. */
  91874. TransformNode.BILLBOARDMODE_ALL = 7;
  91875. TransformNode._lookAtVectorCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](0, 0, 0);
  91876. TransformNode._rotationAxisCache = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  91877. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91878. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("position")
  91879. ], TransformNode.prototype, "_position", void 0);
  91880. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91881. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("rotation")
  91882. ], TransformNode.prototype, "_rotation", void 0);
  91883. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91884. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsQuaternion"])("rotationQuaternion")
  91885. ], TransformNode.prototype, "_rotationQuaternion", void 0);
  91886. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91887. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])("scaling")
  91888. ], TransformNode.prototype, "_scaling", void 0);
  91889. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91890. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91891. ], TransformNode.prototype, "billboardMode", void 0);
  91892. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91893. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91894. ], TransformNode.prototype, "scalingDeterminant", void 0);
  91895. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91896. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91897. ], TransformNode.prototype, "infiniteDistance", void 0);
  91898. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  91899. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  91900. ], TransformNode.prototype, "ignoreNonUniformScaling", void 0);
  91901. return TransformNode;
  91902. }(_node__WEBPACK_IMPORTED_MODULE_4__["Node"]));
  91903. /***/ }),
  91904. /***/ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts":
  91905. /*!***************************************************************!*\
  91906. !*** ./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts ***!
  91907. \***************************************************************/
  91908. /*! exports provided: CubeMapToSphericalPolynomialTools */
  91909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  91910. "use strict";
  91911. __webpack_require__.r(__webpack_exports__);
  91912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return CubeMapToSphericalPolynomialTools; });
  91913. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  91914. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  91915. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  91916. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  91917. var FileFaceOrientation = /** @class */ (function () {
  91918. function FileFaceOrientation(name, worldAxisForNormal, worldAxisForFileX, worldAxisForFileY) {
  91919. this.name = name;
  91920. this.worldAxisForNormal = worldAxisForNormal;
  91921. this.worldAxisForFileX = worldAxisForFileX;
  91922. this.worldAxisForFileY = worldAxisForFileY;
  91923. }
  91924. return FileFaceOrientation;
  91925. }());
  91926. /**
  91927. * Helper class dealing with the extraction of spherical polynomial dataArray
  91928. * from a cube map.
  91929. */
  91930. var CubeMapToSphericalPolynomialTools = /** @class */ (function () {
  91931. function CubeMapToSphericalPolynomialTools() {
  91932. }
  91933. /**
  91934. * Converts a texture to the according Spherical Polynomial data.
  91935. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91936. *
  91937. * @param texture The texture to extract the information from.
  91938. * @return The Spherical Polynomial data.
  91939. */
  91940. CubeMapToSphericalPolynomialTools.ConvertCubeMapTextureToSphericalPolynomial = function (texture) {
  91941. if (!texture.isCube) {
  91942. // Only supports cube Textures currently.
  91943. return null;
  91944. }
  91945. var size = texture.getSize().width;
  91946. var right = texture.readPixels(0);
  91947. var left = texture.readPixels(1);
  91948. var up;
  91949. var down;
  91950. if (texture.isRenderTarget) {
  91951. up = texture.readPixels(3);
  91952. down = texture.readPixels(2);
  91953. }
  91954. else {
  91955. up = texture.readPixels(2);
  91956. down = texture.readPixels(3);
  91957. }
  91958. var front = texture.readPixels(4);
  91959. var back = texture.readPixels(5);
  91960. var gammaSpace = texture.gammaSpace;
  91961. // Always read as RGBA.
  91962. var format = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA;
  91963. var type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  91964. if (texture.textureType && texture.textureType !== _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  91965. type = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_FLOAT;
  91966. }
  91967. var cubeInfo = {
  91968. size: size,
  91969. right: right,
  91970. left: left,
  91971. up: up,
  91972. down: down,
  91973. front: front,
  91974. back: back,
  91975. format: format,
  91976. type: type,
  91977. gammaSpace: gammaSpace,
  91978. };
  91979. return this.ConvertCubeMapToSphericalPolynomial(cubeInfo);
  91980. };
  91981. /**
  91982. * Converts a cubemap to the according Spherical Polynomial data.
  91983. * This extracts the first 3 orders only as they are the only one used in the lighting.
  91984. *
  91985. * @param cubeInfo The Cube map to extract the information from.
  91986. * @return The Spherical Polynomial data.
  91987. */
  91988. CubeMapToSphericalPolynomialTools.ConvertCubeMapToSphericalPolynomial = function (cubeInfo) {
  91989. var sphericalHarmonics = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalHarmonics"]();
  91990. var totalSolidAngle = 0.0;
  91991. // The (u,v) range is [-1,+1], so the distance between each texel is 2/Size.
  91992. var du = 2.0 / cubeInfo.size;
  91993. var dv = du;
  91994. // The (u,v) of the first texel is half a texel from the corner (-1,-1).
  91995. var minUV = du * 0.5 - 1.0;
  91996. for (var faceIndex = 0; faceIndex < 6; faceIndex++) {
  91997. var fileFace = this.FileFaces[faceIndex];
  91998. var dataArray = cubeInfo[fileFace.name];
  91999. var v = minUV;
  92000. // TODO: we could perform the summation directly into a SphericalPolynomial (SP), which is more efficient than SphericalHarmonic (SH).
  92001. // This is possible because during the summation we do not need the SH-specific properties, e.g. orthogonality.
  92002. // Because SP is still linear, so summation is fine in that basis.
  92003. var stride = cubeInfo.format === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTUREFORMAT_RGBA ? 4 : 3;
  92004. for (var y = 0; y < cubeInfo.size; y++) {
  92005. var u = minUV;
  92006. for (var x = 0; x < cubeInfo.size; x++) {
  92007. // World direction (not normalised)
  92008. var worldDirection = fileFace.worldAxisForFileX.scale(u).add(fileFace.worldAxisForFileY.scale(v)).add(fileFace.worldAxisForNormal);
  92009. worldDirection.normalize();
  92010. var deltaSolidAngle = Math.pow(1.0 + u * u + v * v, -3.0 / 2.0);
  92011. var r = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 0];
  92012. var g = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 1];
  92013. var b = dataArray[(y * cubeInfo.size * stride) + (x * stride) + 2];
  92014. // Handle Integer types.
  92015. if (cubeInfo.type === _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  92016. r /= 255;
  92017. g /= 255;
  92018. b /= 255;
  92019. }
  92020. // Handle Gamma space textures.
  92021. if (cubeInfo.gammaSpace) {
  92022. r = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(r), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92023. g = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(g), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92024. b = Math.pow(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(b), _Maths_math__WEBPACK_IMPORTED_MODULE_0__["ToLinearSpace"]);
  92025. }
  92026. var color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"](r, g, b);
  92027. sphericalHarmonics.addLight(worldDirection, color, deltaSolidAngle);
  92028. totalSolidAngle += deltaSolidAngle;
  92029. u += du;
  92030. }
  92031. v += dv;
  92032. }
  92033. }
  92034. // Solid angle for entire sphere is 4*pi
  92035. var sphereSolidAngle = 4.0 * Math.PI;
  92036. // Adjust the solid angle to allow for how many faces we processed.
  92037. var facesProcessed = 6.0;
  92038. var expectedSolidAngle = sphereSolidAngle * facesProcessed / 6.0;
  92039. // Adjust the harmonics so that the accumulated solid angle matches the expected solid angle.
  92040. // This is needed because the numerical integration over the cube uses a
  92041. // small angle approximation of solid angle for each texel (see deltaSolidAngle),
  92042. // and also to compensate for accumulative error due to float precision in the summation.
  92043. var correctionFactor = expectedSolidAngle / totalSolidAngle;
  92044. sphericalHarmonics.scale(correctionFactor);
  92045. sphericalHarmonics.convertIncidentRadianceToIrradiance();
  92046. sphericalHarmonics.convertIrradianceToLambertianRadiance();
  92047. return _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_2__["SphericalPolynomial"].FromHarmonics(sphericalHarmonics);
  92048. };
  92049. CubeMapToSphericalPolynomialTools.FileFaces = [
  92050. 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)),
  92051. 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)),
  92052. 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)),
  92053. 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)),
  92054. 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)),
  92055. 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
  92056. ];
  92057. return CubeMapToSphericalPolynomialTools;
  92058. }());
  92059. /***/ }),
  92060. /***/ "./Misc/HighDynamicRange/hdr.ts":
  92061. /*!**************************************!*\
  92062. !*** ./Misc/HighDynamicRange/hdr.ts ***!
  92063. \**************************************/
  92064. /*! exports provided: HDRTools */
  92065. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92066. "use strict";
  92067. __webpack_require__.r(__webpack_exports__);
  92068. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return HDRTools; });
  92069. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  92070. /**
  92071. * This groups tools to convert HDR texture to native colors array.
  92072. */
  92073. var HDRTools = /** @class */ (function () {
  92074. function HDRTools() {
  92075. }
  92076. HDRTools.Ldexp = function (mantissa, exponent) {
  92077. if (exponent > 1023) {
  92078. return mantissa * Math.pow(2, 1023) * Math.pow(2, exponent - 1023);
  92079. }
  92080. if (exponent < -1074) {
  92081. return mantissa * Math.pow(2, -1074) * Math.pow(2, exponent + 1074);
  92082. }
  92083. return mantissa * Math.pow(2, exponent);
  92084. };
  92085. HDRTools.Rgbe2float = function (float32array, red, green, blue, exponent, index) {
  92086. if (exponent > 0) { /*nonzero pixel*/
  92087. exponent = this.Ldexp(1.0, exponent - (128 + 8));
  92088. float32array[index + 0] = red * exponent;
  92089. float32array[index + 1] = green * exponent;
  92090. float32array[index + 2] = blue * exponent;
  92091. }
  92092. else {
  92093. float32array[index + 0] = 0;
  92094. float32array[index + 1] = 0;
  92095. float32array[index + 2] = 0;
  92096. }
  92097. };
  92098. HDRTools.readStringLine = function (uint8array, startIndex) {
  92099. var line = "";
  92100. var character = "";
  92101. for (var i = startIndex; i < uint8array.length - startIndex; i++) {
  92102. character = String.fromCharCode(uint8array[i]);
  92103. if (character == "\n") {
  92104. break;
  92105. }
  92106. line += character;
  92107. }
  92108. return line;
  92109. };
  92110. /**
  92111. * Reads header information from an RGBE texture stored in a native array.
  92112. * More information on this format are available here:
  92113. * https://en.wikipedia.org/wiki/RGBE_image_format
  92114. *
  92115. * @param uint8array The binary file stored in native array.
  92116. * @return The header information.
  92117. */
  92118. HDRTools.RGBE_ReadHeader = function (uint8array) {
  92119. var height = 0;
  92120. var width = 0;
  92121. var line = this.readStringLine(uint8array, 0);
  92122. if (line[0] != '#' || line[1] != '?') {
  92123. throw "Bad HDR Format.";
  92124. }
  92125. var endOfHeader = false;
  92126. var findFormat = false;
  92127. var lineIndex = 0;
  92128. do {
  92129. lineIndex += (line.length + 1);
  92130. line = this.readStringLine(uint8array, lineIndex);
  92131. if (line == "FORMAT=32-bit_rle_rgbe") {
  92132. findFormat = true;
  92133. }
  92134. else if (line.length == 0) {
  92135. endOfHeader = true;
  92136. }
  92137. } while (!endOfHeader);
  92138. if (!findFormat) {
  92139. throw "HDR Bad header format, unsupported FORMAT";
  92140. }
  92141. lineIndex += (line.length + 1);
  92142. line = this.readStringLine(uint8array, lineIndex);
  92143. var sizeRegexp = /^\-Y (.*) \+X (.*)$/g;
  92144. var match = sizeRegexp.exec(line);
  92145. // TODO. Support +Y and -X if needed.
  92146. if (!match || match.length < 3) {
  92147. throw "HDR Bad header format, no size";
  92148. }
  92149. width = parseInt(match[2]);
  92150. height = parseInt(match[1]);
  92151. if (width < 8 || width > 0x7fff) {
  92152. throw "HDR Bad header format, unsupported size";
  92153. }
  92154. lineIndex += (line.length + 1);
  92155. return {
  92156. height: height,
  92157. width: width,
  92158. dataPosition: lineIndex
  92159. };
  92160. };
  92161. /**
  92162. * Returns the cubemap information (each faces texture data) extracted from an RGBE texture.
  92163. * This RGBE texture needs to store the information as a panorama.
  92164. *
  92165. * More information on this format are available here:
  92166. * https://en.wikipedia.org/wiki/RGBE_image_format
  92167. *
  92168. * @param buffer The binary file stored in an array buffer.
  92169. * @param size The expected size of the extracted cubemap.
  92170. * @return The Cube Map information.
  92171. */
  92172. HDRTools.GetCubeMapTextureData = function (buffer, size) {
  92173. var uint8array = new Uint8Array(buffer);
  92174. var hdrInfo = this.RGBE_ReadHeader(uint8array);
  92175. var data = this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  92176. var cubeMapData = _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_0__["PanoramaToCubeMapTools"].ConvertPanoramaToCubemap(data, hdrInfo.width, hdrInfo.height, size);
  92177. return cubeMapData;
  92178. };
  92179. /**
  92180. * Returns the pixels data extracted from an RGBE texture.
  92181. * This pixels will be stored left to right up to down in the R G B order in one array.
  92182. *
  92183. * More information on this format are available here:
  92184. * https://en.wikipedia.org/wiki/RGBE_image_format
  92185. *
  92186. * @param uint8array The binary file stored in an array buffer.
  92187. * @param hdrInfo The header information of the file.
  92188. * @return The pixels data in RGB right to left up to down order.
  92189. */
  92190. HDRTools.RGBE_ReadPixels = function (uint8array, hdrInfo) {
  92191. // Keep for multi format supports.
  92192. return this.RGBE_ReadPixels_RLE(uint8array, hdrInfo);
  92193. };
  92194. HDRTools.RGBE_ReadPixels_RLE = function (uint8array, hdrInfo) {
  92195. var num_scanlines = hdrInfo.height;
  92196. var scanline_width = hdrInfo.width;
  92197. var a, b, c, d, count;
  92198. var dataIndex = hdrInfo.dataPosition;
  92199. var index = 0, endIndex = 0, i = 0;
  92200. var scanLineArrayBuffer = new ArrayBuffer(scanline_width * 4); // four channel R G B E
  92201. var scanLineArray = new Uint8Array(scanLineArrayBuffer);
  92202. // 3 channels of 4 bytes per pixel in float.
  92203. var resultBuffer = new ArrayBuffer(hdrInfo.width * hdrInfo.height * 4 * 3);
  92204. var resultArray = new Float32Array(resultBuffer);
  92205. // read in each successive scanline
  92206. while (num_scanlines > 0) {
  92207. a = uint8array[dataIndex++];
  92208. b = uint8array[dataIndex++];
  92209. c = uint8array[dataIndex++];
  92210. d = uint8array[dataIndex++];
  92211. if (a != 2 || b != 2 || (c & 0x80)) {
  92212. // this file is not run length encoded
  92213. throw "HDR Bad header format, not RLE";
  92214. }
  92215. if (((c << 8) | d) != scanline_width) {
  92216. throw "HDR Bad header format, wrong scan line width";
  92217. }
  92218. index = 0;
  92219. // read each of the four channels for the scanline into the buffer
  92220. for (i = 0; i < 4; i++) {
  92221. endIndex = (i + 1) * scanline_width;
  92222. while (index < endIndex) {
  92223. a = uint8array[dataIndex++];
  92224. b = uint8array[dataIndex++];
  92225. if (a > 128) {
  92226. // a run of the same value
  92227. count = a - 128;
  92228. if ((count == 0) || (count > endIndex - index)) {
  92229. throw "HDR Bad Format, bad scanline data (run)";
  92230. }
  92231. while (count-- > 0) {
  92232. scanLineArray[index++] = b;
  92233. }
  92234. }
  92235. else {
  92236. // a non-run
  92237. count = a;
  92238. if ((count == 0) || (count > endIndex - index)) {
  92239. throw "HDR Bad Format, bad scanline data (non-run)";
  92240. }
  92241. scanLineArray[index++] = b;
  92242. if (--count > 0) {
  92243. for (var j = 0; j < count; j++) {
  92244. scanLineArray[index++] = uint8array[dataIndex++];
  92245. }
  92246. }
  92247. }
  92248. }
  92249. }
  92250. // now convert data from buffer into floats
  92251. for (i = 0; i < scanline_width; i++) {
  92252. a = scanLineArray[i];
  92253. b = scanLineArray[i + scanline_width];
  92254. c = scanLineArray[i + 2 * scanline_width];
  92255. d = scanLineArray[i + 3 * scanline_width];
  92256. this.Rgbe2float(resultArray, a, b, c, d, (hdrInfo.height - num_scanlines) * scanline_width * 3 + i * 3);
  92257. }
  92258. num_scanlines--;
  92259. }
  92260. return resultArray;
  92261. };
  92262. return HDRTools;
  92263. }());
  92264. /***/ }),
  92265. /***/ "./Misc/HighDynamicRange/index.ts":
  92266. /*!****************************************!*\
  92267. !*** ./Misc/HighDynamicRange/index.ts ***!
  92268. \****************************************/
  92269. /*! exports provided: CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  92270. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92271. "use strict";
  92272. __webpack_require__.r(__webpack_exports__);
  92273. /* harmony import */ var _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  92274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_0__["CubeMapToSphericalPolynomialTools"]; });
  92275. /* harmony import */ var _hdr__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./hdr */ "./Misc/HighDynamicRange/hdr.ts");
  92276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _hdr__WEBPACK_IMPORTED_MODULE_1__["HDRTools"]; });
  92277. /* harmony import */ var _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./panoramaToCubemap */ "./Misc/HighDynamicRange/panoramaToCubemap.ts");
  92278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _panoramaToCubemap__WEBPACK_IMPORTED_MODULE_2__["PanoramaToCubeMapTools"]; });
  92279. /***/ }),
  92280. /***/ "./Misc/HighDynamicRange/panoramaToCubemap.ts":
  92281. /*!****************************************************!*\
  92282. !*** ./Misc/HighDynamicRange/panoramaToCubemap.ts ***!
  92283. \****************************************************/
  92284. /*! exports provided: PanoramaToCubeMapTools */
  92285. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92286. "use strict";
  92287. __webpack_require__.r(__webpack_exports__);
  92288. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return PanoramaToCubeMapTools; });
  92289. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  92290. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Engines/constants */ "./Engines/constants.ts");
  92291. /**
  92292. * Helper class useful to convert panorama picture to their cubemap representation in 6 faces.
  92293. */
  92294. var PanoramaToCubeMapTools = /** @class */ (function () {
  92295. function PanoramaToCubeMapTools() {
  92296. }
  92297. /**
  92298. * Converts a panorma stored in RGB right to left up to down format into a cubemap (6 faces).
  92299. *
  92300. * @param float32Array The source data.
  92301. * @param inputWidth The width of the input panorama.
  92302. * @param inputHeight The height of the input panorama.
  92303. * @param size The willing size of the generated cubemap (each faces will be size * size pixels)
  92304. * @return The cubemap data
  92305. */
  92306. PanoramaToCubeMapTools.ConvertPanoramaToCubemap = function (float32Array, inputWidth, inputHeight, size) {
  92307. if (!float32Array) {
  92308. throw "ConvertPanoramaToCubemap: input cannot be null";
  92309. }
  92310. if (float32Array.length != inputWidth * inputHeight * 3) {
  92311. throw "ConvertPanoramaToCubemap: input size is wrong";
  92312. }
  92313. var textureFront = this.CreateCubemapTexture(size, this.FACE_FRONT, float32Array, inputWidth, inputHeight);
  92314. var textureBack = this.CreateCubemapTexture(size, this.FACE_BACK, float32Array, inputWidth, inputHeight);
  92315. var textureLeft = this.CreateCubemapTexture(size, this.FACE_LEFT, float32Array, inputWidth, inputHeight);
  92316. var textureRight = this.CreateCubemapTexture(size, this.FACE_RIGHT, float32Array, inputWidth, inputHeight);
  92317. var textureUp = this.CreateCubemapTexture(size, this.FACE_UP, float32Array, inputWidth, inputHeight);
  92318. var textureDown = this.CreateCubemapTexture(size, this.FACE_DOWN, float32Array, inputWidth, inputHeight);
  92319. return {
  92320. front: textureFront,
  92321. back: textureBack,
  92322. left: textureLeft,
  92323. right: textureRight,
  92324. up: textureUp,
  92325. down: textureDown,
  92326. size: size,
  92327. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_FLOAT,
  92328. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTUREFORMAT_RGB,
  92329. gammaSpace: false,
  92330. };
  92331. };
  92332. PanoramaToCubeMapTools.CreateCubemapTexture = function (texSize, faceData, float32Array, inputWidth, inputHeight) {
  92333. var buffer = new ArrayBuffer(texSize * texSize * 4 * 3);
  92334. var textureArray = new Float32Array(buffer);
  92335. var rotDX1 = faceData[1].subtract(faceData[0]).scale(1 / texSize);
  92336. var rotDX2 = faceData[3].subtract(faceData[2]).scale(1 / texSize);
  92337. var dy = 1 / texSize;
  92338. var fy = 0;
  92339. for (var y = 0; y < texSize; y++) {
  92340. var xv1 = faceData[0];
  92341. var xv2 = faceData[2];
  92342. for (var x = 0; x < texSize; x++) {
  92343. var v = xv2.subtract(xv1).scale(fy).add(xv1);
  92344. v.normalize();
  92345. var color = this.CalcProjectionSpherical(v, float32Array, inputWidth, inputHeight);
  92346. // 3 channels per pixels
  92347. textureArray[y * texSize * 3 + (x * 3) + 0] = color.r;
  92348. textureArray[y * texSize * 3 + (x * 3) + 1] = color.g;
  92349. textureArray[y * texSize * 3 + (x * 3) + 2] = color.b;
  92350. xv1 = xv1.add(rotDX1);
  92351. xv2 = xv2.add(rotDX2);
  92352. }
  92353. fy += dy;
  92354. }
  92355. return textureArray;
  92356. };
  92357. PanoramaToCubeMapTools.CalcProjectionSpherical = function (vDir, float32Array, inputWidth, inputHeight) {
  92358. var theta = Math.atan2(vDir.z, vDir.x);
  92359. var phi = Math.acos(vDir.y);
  92360. while (theta < -Math.PI) {
  92361. theta += 2 * Math.PI;
  92362. }
  92363. while (theta > Math.PI) {
  92364. theta -= 2 * Math.PI;
  92365. }
  92366. var dx = theta / Math.PI;
  92367. var dy = phi / Math.PI;
  92368. // recenter.
  92369. dx = dx * 0.5 + 0.5;
  92370. var px = Math.round(dx * inputWidth);
  92371. if (px < 0) {
  92372. px = 0;
  92373. }
  92374. else if (px >= inputWidth) {
  92375. px = inputWidth - 1;
  92376. }
  92377. var py = Math.round(dy * inputHeight);
  92378. if (py < 0) {
  92379. py = 0;
  92380. }
  92381. else if (py >= inputHeight) {
  92382. py = inputHeight - 1;
  92383. }
  92384. var inputY = (inputHeight - py - 1);
  92385. var r = float32Array[inputY * inputWidth * 3 + (px * 3) + 0];
  92386. var g = float32Array[inputY * inputWidth * 3 + (px * 3) + 1];
  92387. var b = float32Array[inputY * inputWidth * 3 + (px * 3) + 2];
  92388. return {
  92389. r: r,
  92390. g: g,
  92391. b: b
  92392. };
  92393. };
  92394. PanoramaToCubeMapTools.FACE_FRONT = [
  92395. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  92396. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  92397. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  92398. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0)
  92399. ];
  92400. PanoramaToCubeMapTools.FACE_BACK = [
  92401. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  92402. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  92403. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0),
  92404. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0)
  92405. ];
  92406. PanoramaToCubeMapTools.FACE_RIGHT = [
  92407. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0),
  92408. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  92409. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  92410. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  92411. ];
  92412. PanoramaToCubeMapTools.FACE_LEFT = [
  92413. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  92414. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  92415. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  92416. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0)
  92417. ];
  92418. PanoramaToCubeMapTools.FACE_DOWN = [
  92419. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, -1.0),
  92420. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, -1.0),
  92421. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, 1.0, 1.0),
  92422. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, 1.0, 1.0)
  92423. ];
  92424. PanoramaToCubeMapTools.FACE_UP = [
  92425. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, 1.0),
  92426. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, 1.0),
  92427. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](-1.0, -1.0, -1.0),
  92428. new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](1.0, -1.0, -1.0)
  92429. ];
  92430. return PanoramaToCubeMapTools;
  92431. }());
  92432. /***/ }),
  92433. /***/ "./Misc/andOrNotEvaluator.ts":
  92434. /*!***********************************!*\
  92435. !*** ./Misc/andOrNotEvaluator.ts ***!
  92436. \***********************************/
  92437. /*! exports provided: AndOrNotEvaluator */
  92438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92439. "use strict";
  92440. __webpack_require__.r(__webpack_exports__);
  92441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return AndOrNotEvaluator; });
  92442. /**
  92443. * Class used to evalaute queries containing `and` and `or` operators
  92444. */
  92445. var AndOrNotEvaluator = /** @class */ (function () {
  92446. function AndOrNotEvaluator() {
  92447. }
  92448. /**
  92449. * Evaluate a query
  92450. * @param query defines the query to evaluate
  92451. * @param evaluateCallback defines the callback used to filter result
  92452. * @returns true if the query matches
  92453. */
  92454. AndOrNotEvaluator.Eval = function (query, evaluateCallback) {
  92455. if (!query.match(/\([^\(\)]*\)/g)) {
  92456. query = AndOrNotEvaluator._HandleParenthesisContent(query, evaluateCallback);
  92457. }
  92458. else {
  92459. query = query.replace(/\([^\(\)]*\)/g, function (r) {
  92460. // remove parenthesis
  92461. r = r.slice(1, r.length - 1);
  92462. return AndOrNotEvaluator._HandleParenthesisContent(r, evaluateCallback);
  92463. });
  92464. }
  92465. if (query === "true") {
  92466. return true;
  92467. }
  92468. if (query === "false") {
  92469. return false;
  92470. }
  92471. return AndOrNotEvaluator.Eval(query, evaluateCallback);
  92472. };
  92473. AndOrNotEvaluator._HandleParenthesisContent = function (parenthesisContent, evaluateCallback) {
  92474. evaluateCallback = evaluateCallback || (function (r) {
  92475. return r === "true" ? true : false;
  92476. });
  92477. var result;
  92478. var or = parenthesisContent.split("||");
  92479. for (var i in or) {
  92480. if (or.hasOwnProperty(i)) {
  92481. var ori = AndOrNotEvaluator._SimplifyNegation(or[i].trim());
  92482. var and = ori.split("&&");
  92483. if (and.length > 1) {
  92484. for (var j = 0; j < and.length; ++j) {
  92485. var andj = AndOrNotEvaluator._SimplifyNegation(and[j].trim());
  92486. if (andj !== "true" && andj !== "false") {
  92487. if (andj[0] === "!") {
  92488. result = !evaluateCallback(andj.substring(1));
  92489. }
  92490. else {
  92491. result = evaluateCallback(andj);
  92492. }
  92493. }
  92494. else {
  92495. result = andj === "true" ? true : false;
  92496. }
  92497. if (!result) { // no need to continue since 'false && ... && ...' will always return false
  92498. ori = "false";
  92499. break;
  92500. }
  92501. }
  92502. }
  92503. if (result || ori === "true") { // no need to continue since 'true || ... || ...' will always return true
  92504. result = true;
  92505. break;
  92506. }
  92507. // result equals false (or undefined)
  92508. if (ori !== "true" && ori !== "false") {
  92509. if (ori[0] === "!") {
  92510. result = !evaluateCallback(ori.substring(1));
  92511. }
  92512. else {
  92513. result = evaluateCallback(ori);
  92514. }
  92515. }
  92516. else {
  92517. result = ori === "true" ? true : false;
  92518. }
  92519. }
  92520. }
  92521. // the whole parenthesis scope is replaced by 'true' or 'false'
  92522. return result ? "true" : "false";
  92523. };
  92524. AndOrNotEvaluator._SimplifyNegation = function (booleanString) {
  92525. booleanString = booleanString.replace(/^[\s!]+/, function (r) {
  92526. // remove whitespaces
  92527. r = r.replace(/[\s]/g, function () { return ""; });
  92528. return r.length % 2 ? "!" : "";
  92529. });
  92530. booleanString = booleanString.trim();
  92531. if (booleanString === "!true") {
  92532. booleanString = "false";
  92533. }
  92534. else if (booleanString === "!false") {
  92535. booleanString = "true";
  92536. }
  92537. return booleanString;
  92538. };
  92539. return AndOrNotEvaluator;
  92540. }());
  92541. /***/ }),
  92542. /***/ "./Misc/arrayTools.ts":
  92543. /*!****************************!*\
  92544. !*** ./Misc/arrayTools.ts ***!
  92545. \****************************/
  92546. /*! exports provided: ArrayTools */
  92547. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92548. "use strict";
  92549. __webpack_require__.r(__webpack_exports__);
  92550. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ArrayTools", function() { return ArrayTools; });
  92551. /**
  92552. * Class containing a set of static utilities functions for arrays.
  92553. */
  92554. var ArrayTools = /** @class */ (function () {
  92555. function ArrayTools() {
  92556. }
  92557. /**
  92558. * Returns an array of the given size filled with element built from the given constructor and the paramters
  92559. * @param size the number of element to construct and put in the array
  92560. * @param itemBuilder a callback responsible for creating new instance of item. Called once per array entry.
  92561. * @returns a new array filled with new objects
  92562. */
  92563. ArrayTools.BuildArray = function (size, itemBuilder) {
  92564. var a = [];
  92565. for (var i = 0; i < size; ++i) {
  92566. a.push(itemBuilder());
  92567. }
  92568. return a;
  92569. };
  92570. return ArrayTools;
  92571. }());
  92572. /***/ }),
  92573. /***/ "./Misc/assetsManager.ts":
  92574. /*!*******************************!*\
  92575. !*** ./Misc/assetsManager.ts ***!
  92576. \*******************************/
  92577. /*! exports provided: AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager */
  92578. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  92579. "use strict";
  92580. __webpack_require__.r(__webpack_exports__);
  92581. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return AssetTaskState; });
  92582. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return AbstractAssetTask; });
  92583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return AssetsProgressEvent; });
  92584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return MeshAssetTask; });
  92585. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return TextFileAssetTask; });
  92586. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return BinaryFileAssetTask; });
  92587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return ImageAssetTask; });
  92588. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return TextureAssetTask; });
  92589. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return CubeTextureAssetTask; });
  92590. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return HDRCubeTextureAssetTask; });
  92591. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return AssetsManager; });
  92592. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  92593. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  92594. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  92595. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  92596. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  92597. /* harmony import */ var _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/cubeTexture */ "./Materials/Textures/cubeTexture.ts");
  92598. /* harmony import */ var _Materials_Textures_hdrCubeTexture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/hdrCubeTexture */ "./Materials/Textures/hdrCubeTexture.ts");
  92599. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  92600. /**
  92601. * Defines the list of states available for a task inside a AssetsManager
  92602. */
  92603. var AssetTaskState;
  92604. (function (AssetTaskState) {
  92605. /**
  92606. * Initialization
  92607. */
  92608. AssetTaskState[AssetTaskState["INIT"] = 0] = "INIT";
  92609. /**
  92610. * Running
  92611. */
  92612. AssetTaskState[AssetTaskState["RUNNING"] = 1] = "RUNNING";
  92613. /**
  92614. * Done
  92615. */
  92616. AssetTaskState[AssetTaskState["DONE"] = 2] = "DONE";
  92617. /**
  92618. * Error
  92619. */
  92620. AssetTaskState[AssetTaskState["ERROR"] = 3] = "ERROR";
  92621. })(AssetTaskState || (AssetTaskState = {}));
  92622. /**
  92623. * Define an abstract asset task used with a AssetsManager class to load assets into a scene
  92624. */
  92625. var AbstractAssetTask = /** @class */ (function () {
  92626. /**
  92627. * Creates a new AssetsManager
  92628. * @param name defines the name of the task
  92629. */
  92630. function AbstractAssetTask(
  92631. /**
  92632. * Task name
  92633. */ name) {
  92634. this.name = name;
  92635. this._isCompleted = false;
  92636. this._taskState = AssetTaskState.INIT;
  92637. }
  92638. Object.defineProperty(AbstractAssetTask.prototype, "isCompleted", {
  92639. /**
  92640. * Get if the task is completed
  92641. */
  92642. get: function () {
  92643. return this._isCompleted;
  92644. },
  92645. enumerable: true,
  92646. configurable: true
  92647. });
  92648. Object.defineProperty(AbstractAssetTask.prototype, "taskState", {
  92649. /**
  92650. * Gets the current state of the task
  92651. */
  92652. get: function () {
  92653. return this._taskState;
  92654. },
  92655. enumerable: true,
  92656. configurable: true
  92657. });
  92658. Object.defineProperty(AbstractAssetTask.prototype, "errorObject", {
  92659. /**
  92660. * Gets the current error object (if task is in error)
  92661. */
  92662. get: function () {
  92663. return this._errorObject;
  92664. },
  92665. enumerable: true,
  92666. configurable: true
  92667. });
  92668. /**
  92669. * Internal only
  92670. * @hidden
  92671. */
  92672. AbstractAssetTask.prototype._setErrorObject = function (message, exception) {
  92673. if (this._errorObject) {
  92674. return;
  92675. }
  92676. this._errorObject = {
  92677. message: message,
  92678. exception: exception
  92679. };
  92680. };
  92681. /**
  92682. * Execute the current task
  92683. * @param scene defines the scene where you want your assets to be loaded
  92684. * @param onSuccess is a callback called when the task is successfully executed
  92685. * @param onError is a callback called if an error occurs
  92686. */
  92687. AbstractAssetTask.prototype.run = function (scene, onSuccess, onError) {
  92688. var _this = this;
  92689. this._taskState = AssetTaskState.RUNNING;
  92690. this.runTask(scene, function () {
  92691. _this.onDoneCallback(onSuccess, onError);
  92692. }, function (msg, exception) {
  92693. _this.onErrorCallback(onError, msg, exception);
  92694. });
  92695. };
  92696. /**
  92697. * Execute the current task
  92698. * @param scene defines the scene where you want your assets to be loaded
  92699. * @param onSuccess is a callback called when the task is successfully executed
  92700. * @param onError is a callback called if an error occurs
  92701. */
  92702. AbstractAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92703. throw new Error("runTask is not implemented");
  92704. };
  92705. /**
  92706. * Reset will set the task state back to INIT, so the next load call of the assets manager will execute this task again.
  92707. * This can be used with failed tasks that have the reason for failure fixed.
  92708. */
  92709. AbstractAssetTask.prototype.reset = function () {
  92710. this._taskState = AssetTaskState.INIT;
  92711. };
  92712. AbstractAssetTask.prototype.onErrorCallback = function (onError, message, exception) {
  92713. this._taskState = AssetTaskState.ERROR;
  92714. this._errorObject = {
  92715. message: message,
  92716. exception: exception
  92717. };
  92718. if (this.onError) {
  92719. this.onError(this, message, exception);
  92720. }
  92721. onError();
  92722. };
  92723. AbstractAssetTask.prototype.onDoneCallback = function (onSuccess, onError) {
  92724. try {
  92725. this._taskState = AssetTaskState.DONE;
  92726. this._isCompleted = true;
  92727. if (this.onSuccess) {
  92728. this.onSuccess(this);
  92729. }
  92730. onSuccess();
  92731. }
  92732. catch (e) {
  92733. this.onErrorCallback(onError, "Task is done, error executing success callback(s)", e);
  92734. }
  92735. };
  92736. return AbstractAssetTask;
  92737. }());
  92738. /**
  92739. * Class used to share progress information about assets loading
  92740. */
  92741. var AssetsProgressEvent = /** @class */ (function () {
  92742. /**
  92743. * Creates a AssetsProgressEvent
  92744. * @param remainingCount defines the number of remaining tasks to process
  92745. * @param totalCount defines the total number of tasks
  92746. * @param task defines the task that was just processed
  92747. */
  92748. function AssetsProgressEvent(remainingCount, totalCount, task) {
  92749. this.remainingCount = remainingCount;
  92750. this.totalCount = totalCount;
  92751. this.task = task;
  92752. }
  92753. return AssetsProgressEvent;
  92754. }());
  92755. /**
  92756. * Define a task used by AssetsManager to load meshes
  92757. */
  92758. var MeshAssetTask = /** @class */ (function (_super) {
  92759. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MeshAssetTask, _super);
  92760. /**
  92761. * Creates a new MeshAssetTask
  92762. * @param name defines the name of the task
  92763. * @param meshesNames defines the list of mesh's names you want to load
  92764. * @param rootUrl defines the root url to use as a base to load your meshes and associated resources
  92765. * @param sceneFilename defines the filename of the scene to load from
  92766. */
  92767. function MeshAssetTask(
  92768. /**
  92769. * Defines the name of the task
  92770. */
  92771. name,
  92772. /**
  92773. * Defines the list of mesh's names you want to load
  92774. */
  92775. meshesNames,
  92776. /**
  92777. * Defines the root url to use as a base to load your meshes and associated resources
  92778. */
  92779. rootUrl,
  92780. /**
  92781. * Defines the filename of the scene to load from
  92782. */
  92783. sceneFilename) {
  92784. var _this = _super.call(this, name) || this;
  92785. _this.name = name;
  92786. _this.meshesNames = meshesNames;
  92787. _this.rootUrl = rootUrl;
  92788. _this.sceneFilename = sceneFilename;
  92789. return _this;
  92790. }
  92791. /**
  92792. * Execute the current task
  92793. * @param scene defines the scene where you want your assets to be loaded
  92794. * @param onSuccess is a callback called when the task is successfully executed
  92795. * @param onError is a callback called if an error occurs
  92796. */
  92797. MeshAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92798. var _this = this;
  92799. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_1__["SceneLoader"].ImportMesh(this.meshesNames, this.rootUrl, this.sceneFilename, scene, function (meshes, particleSystems, skeletons, animationGroups) {
  92800. _this.loadedMeshes = meshes;
  92801. _this.loadedParticleSystems = particleSystems;
  92802. _this.loadedSkeletons = skeletons;
  92803. _this.loadedAnimationGroups = animationGroups;
  92804. onSuccess();
  92805. }, null, function (scene, message, exception) {
  92806. onError(message, exception);
  92807. });
  92808. };
  92809. return MeshAssetTask;
  92810. }(AbstractAssetTask));
  92811. /**
  92812. * Define a task used by AssetsManager to load text content
  92813. */
  92814. var TextFileAssetTask = /** @class */ (function (_super) {
  92815. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextFileAssetTask, _super);
  92816. /**
  92817. * Creates a new TextFileAssetTask object
  92818. * @param name defines the name of the task
  92819. * @param url defines the location of the file to load
  92820. */
  92821. function TextFileAssetTask(
  92822. /**
  92823. * Defines the name of the task
  92824. */
  92825. name,
  92826. /**
  92827. * Defines the location of the file to load
  92828. */
  92829. url) {
  92830. var _this = _super.call(this, name) || this;
  92831. _this.name = name;
  92832. _this.url = url;
  92833. return _this;
  92834. }
  92835. /**
  92836. * Execute the current task
  92837. * @param scene defines the scene where you want your assets to be loaded
  92838. * @param onSuccess is a callback called when the task is successfully executed
  92839. * @param onError is a callback called if an error occurs
  92840. */
  92841. TextFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92842. var _this = this;
  92843. scene._loadFile(this.url, function (data) {
  92844. _this.text = data;
  92845. onSuccess();
  92846. }, undefined, false, false, function (request, exception) {
  92847. if (request) {
  92848. onError(request.status + " " + request.statusText, exception);
  92849. }
  92850. });
  92851. };
  92852. return TextFileAssetTask;
  92853. }(AbstractAssetTask));
  92854. /**
  92855. * Define a task used by AssetsManager to load binary data
  92856. */
  92857. var BinaryFileAssetTask = /** @class */ (function (_super) {
  92858. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BinaryFileAssetTask, _super);
  92859. /**
  92860. * Creates a new BinaryFileAssetTask object
  92861. * @param name defines the name of the new task
  92862. * @param url defines the location of the file to load
  92863. */
  92864. function BinaryFileAssetTask(
  92865. /**
  92866. * Defines the name of the task
  92867. */
  92868. name,
  92869. /**
  92870. * Defines the location of the file to load
  92871. */
  92872. url) {
  92873. var _this = _super.call(this, name) || this;
  92874. _this.name = name;
  92875. _this.url = url;
  92876. return _this;
  92877. }
  92878. /**
  92879. * Execute the current task
  92880. * @param scene defines the scene where you want your assets to be loaded
  92881. * @param onSuccess is a callback called when the task is successfully executed
  92882. * @param onError is a callback called if an error occurs
  92883. */
  92884. BinaryFileAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92885. var _this = this;
  92886. scene._loadFile(this.url, function (data) {
  92887. _this.data = data;
  92888. onSuccess();
  92889. }, undefined, true, true, function (request, exception) {
  92890. if (request) {
  92891. onError(request.status + " " + request.statusText, exception);
  92892. }
  92893. });
  92894. };
  92895. return BinaryFileAssetTask;
  92896. }(AbstractAssetTask));
  92897. /**
  92898. * Define a task used by AssetsManager to load images
  92899. */
  92900. var ImageAssetTask = /** @class */ (function (_super) {
  92901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageAssetTask, _super);
  92902. /**
  92903. * Creates a new ImageAssetTask
  92904. * @param name defines the name of the task
  92905. * @param url defines the location of the image to load
  92906. */
  92907. function ImageAssetTask(
  92908. /**
  92909. * Defines the name of the task
  92910. */
  92911. name,
  92912. /**
  92913. * Defines the location of the image to load
  92914. */
  92915. url) {
  92916. var _this = _super.call(this, name) || this;
  92917. _this.name = name;
  92918. _this.url = url;
  92919. return _this;
  92920. }
  92921. /**
  92922. * Execute the current task
  92923. * @param scene defines the scene where you want your assets to be loaded
  92924. * @param onSuccess is a callback called when the task is successfully executed
  92925. * @param onError is a callback called if an error occurs
  92926. */
  92927. ImageAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92928. var _this = this;
  92929. var img = new Image();
  92930. _tools__WEBPACK_IMPORTED_MODULE_2__["Tools"].SetCorsBehavior(this.url, img);
  92931. img.onload = function () {
  92932. _this.image = img;
  92933. onSuccess();
  92934. };
  92935. img.onerror = function (err) {
  92936. onError("Error loading image", err);
  92937. };
  92938. img.src = this.url;
  92939. };
  92940. return ImageAssetTask;
  92941. }(AbstractAssetTask));
  92942. /**
  92943. * Define a task used by AssetsManager to load 2D textures
  92944. */
  92945. var TextureAssetTask = /** @class */ (function (_super) {
  92946. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureAssetTask, _super);
  92947. /**
  92948. * Creates a new TextureAssetTask object
  92949. * @param name defines the name of the task
  92950. * @param url defines the location of the file to load
  92951. * @param noMipmap defines if mipmap should not be generated (default is false)
  92952. * @param invertY defines if texture must be inverted on Y axis (default is false)
  92953. * @param samplingMode defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92954. */
  92955. function TextureAssetTask(
  92956. /**
  92957. * Defines the name of the task
  92958. */
  92959. name,
  92960. /**
  92961. * Defines the location of the file to load
  92962. */
  92963. url,
  92964. /**
  92965. * Defines if mipmap should not be generated (default is false)
  92966. */
  92967. noMipmap,
  92968. /**
  92969. * Defines if texture must be inverted on Y axis (default is false)
  92970. */
  92971. invertY,
  92972. /**
  92973. * Defines the sampling mode to use (default is Texture.TRILINEAR_SAMPLINGMODE)
  92974. */
  92975. samplingMode) {
  92976. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  92977. var _this = _super.call(this, name) || this;
  92978. _this.name = name;
  92979. _this.url = url;
  92980. _this.noMipmap = noMipmap;
  92981. _this.invertY = invertY;
  92982. _this.samplingMode = samplingMode;
  92983. return _this;
  92984. }
  92985. /**
  92986. * Execute the current task
  92987. * @param scene defines the scene where you want your assets to be loaded
  92988. * @param onSuccess is a callback called when the task is successfully executed
  92989. * @param onError is a callback called if an error occurs
  92990. */
  92991. TextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  92992. var onload = function () {
  92993. onSuccess();
  92994. };
  92995. var onerror = function (message, exception) {
  92996. onError(message, exception);
  92997. };
  92998. this.texture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"](this.url, scene, this.noMipmap, this.invertY, this.samplingMode, onload, onerror);
  92999. };
  93000. return TextureAssetTask;
  93001. }(AbstractAssetTask));
  93002. /**
  93003. * Define a task used by AssetsManager to load cube textures
  93004. */
  93005. var CubeTextureAssetTask = /** @class */ (function (_super) {
  93006. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CubeTextureAssetTask, _super);
  93007. /**
  93008. * Creates a new CubeTextureAssetTask
  93009. * @param name defines the name of the task
  93010. * @param url defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  93011. * @param extensions defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  93012. * @param noMipmap defines if mipmaps should not be generated (default is false)
  93013. * @param files defines the explicit list of files (undefined by default)
  93014. */
  93015. function CubeTextureAssetTask(
  93016. /**
  93017. * Defines the name of the task
  93018. */
  93019. name,
  93020. /**
  93021. * Defines the location of the files to load (You have to specify the folder where the files are + filename with no extension)
  93022. */
  93023. url,
  93024. /**
  93025. * Defines the extensions to use to load files (["_px", "_py", "_pz", "_nx", "_ny", "_nz"] by default)
  93026. */
  93027. extensions,
  93028. /**
  93029. * Defines if mipmaps should not be generated (default is false)
  93030. */
  93031. noMipmap,
  93032. /**
  93033. * Defines the explicit list of files (undefined by default)
  93034. */
  93035. files) {
  93036. var _this = _super.call(this, name) || this;
  93037. _this.name = name;
  93038. _this.url = url;
  93039. _this.extensions = extensions;
  93040. _this.noMipmap = noMipmap;
  93041. _this.files = files;
  93042. return _this;
  93043. }
  93044. /**
  93045. * Execute the current task
  93046. * @param scene defines the scene where you want your assets to be loaded
  93047. * @param onSuccess is a callback called when the task is successfully executed
  93048. * @param onError is a callback called if an error occurs
  93049. */
  93050. CubeTextureAssetTask.prototype.runTask = function (scene, onSuccess, onError) {
  93051. var onload = function () {
  93052. onSuccess();
  93053. };
  93054. var onerror = function (message, exception) {
  93055. onError(message, exception);
  93056. };
  93057. this.texture = new _Materials_Textures_cubeTexture__WEBPACK_IMPORTED_MODULE_5__["CubeTexture"](this.url, scene, this.extensions, this.noMipmap, this.files, onload, onerror);
  93058. };
  93059. return CubeTextureAssetTask;
  93060. }(AbstractAssetTask));
  93061. /**
  93062. * Define a task used by AssetsManager to load HDR cube textures
  93063. */
  93064. var HDRCubeTextureAssetTask = /** @class */ (function (_super) {
  93065. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HDRCubeTextureAssetTask, _super);
  93066. /**
  93067. * Creates a new HDRCubeTextureAssetTask object
  93068. * @param name defines the name of the task
  93069. * @param url defines the location of the file to load
  93070. * @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.
  93071. * @param noMipmap defines if mipmaps should not be generated (default is false)
  93072. * @param generateHarmonics specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  93073. * @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)
  93074. * @param reserved Internal use only
  93075. */
  93076. function HDRCubeTextureAssetTask(
  93077. /**
  93078. * Defines the name of the task
  93079. */
  93080. name,
  93081. /**
  93082. * Defines the location of the file to load
  93083. */
  93084. url,
  93085. /**
  93086. * Defines the desired size (the more it increases the longer the generation will be)
  93087. */
  93088. size,
  93089. /**
  93090. * Defines if mipmaps should not be generated (default is false)
  93091. */
  93092. noMipmap,
  93093. /**
  93094. * Specifies whether you want to extract the polynomial harmonics during the generation process (default is true)
  93095. */
  93096. generateHarmonics,
  93097. /**
  93098. * 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)
  93099. */
  93100. gammaSpace,
  93101. /**
  93102. * Internal Use Only
  93103. */
  93104. reserved) {
  93105. if (noMipmap === void 0) { noMipmap = false; }
  93106. if (generateHarmonics === void 0) { generateHarmonics = true; }
  93107. if (gammaSpace === void 0) { gammaSpace = false; }
  93108. if (reserved === void 0) { reserved = false; }
  93109. var _this = _super.call(this, name) || this;
  93110. _this.name = name;
  93111. _this.url = url;
  93112. _this.size = size;
  93113. _this.noMipmap = noMipmap;
  93114. _this.generateHarmonics = generateHarmonics;
  93115. _this.gammaSpace = gammaSpace;
  93116. _this.reserved = reserved;
  93117. return _this;
  93118. }
  93119. /**
  93120. * Execute the current task
  93121. * @param scene defines the scene where you want your assets to be loaded
  93122. * @param onSuccess is a callback called when the task is successfully executed
  93123. * @param onError is a callback called if an error occurs
  93124. */
  93125. HDRCubeTextureAssetTask.prototype.run = function (scene, onSuccess, onError) {
  93126. var onload = function () {
  93127. onSuccess();
  93128. };
  93129. var onerror = function (message, exception) {
  93130. onError(message, exception);
  93131. };
  93132. 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);
  93133. };
  93134. return HDRCubeTextureAssetTask;
  93135. }(AbstractAssetTask));
  93136. /**
  93137. * This class can be used to easily import assets into a scene
  93138. * @see http://doc.babylonjs.com/how_to/how_to_use_assetsmanager
  93139. */
  93140. var AssetsManager = /** @class */ (function () {
  93141. /**
  93142. * Creates a new AssetsManager
  93143. * @param scene defines the scene to work on
  93144. */
  93145. function AssetsManager(scene) {
  93146. this._isLoading = false;
  93147. this._tasks = new Array();
  93148. this._waitingTasksCount = 0;
  93149. this._totalTasksCount = 0;
  93150. /**
  93151. * Observable called when all tasks are processed
  93152. */
  93153. this.onTaskSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  93154. /**
  93155. * Observable called when a task had an error
  93156. */
  93157. this.onTaskErrorObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  93158. /**
  93159. * Observable called when a task is successful
  93160. */
  93161. this.onTasksDoneObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  93162. /**
  93163. * Observable called when a task is done (whatever the result is)
  93164. */
  93165. this.onProgressObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  93166. /**
  93167. * Gets or sets a boolean defining if the AssetsManager should use the default loading screen
  93168. * @see http://doc.babylonjs.com/how_to/creating_a_custom_loading_screen
  93169. */
  93170. this.useDefaultLoadingScreen = true;
  93171. this._scene = scene;
  93172. }
  93173. /**
  93174. * Add a MeshAssetTask to the list of active tasks
  93175. * @param taskName defines the name of the new task
  93176. * @param meshesNames defines the name of meshes to load
  93177. * @param rootUrl defines the root url to use to locate files
  93178. * @param sceneFilename defines the filename of the scene file
  93179. * @returns a new MeshAssetTask object
  93180. */
  93181. AssetsManager.prototype.addMeshTask = function (taskName, meshesNames, rootUrl, sceneFilename) {
  93182. var task = new MeshAssetTask(taskName, meshesNames, rootUrl, sceneFilename);
  93183. this._tasks.push(task);
  93184. return task;
  93185. };
  93186. /**
  93187. * Add a TextFileAssetTask to the list of active tasks
  93188. * @param taskName defines the name of the new task
  93189. * @param url defines the url of the file to load
  93190. * @returns a new TextFileAssetTask object
  93191. */
  93192. AssetsManager.prototype.addTextFileTask = function (taskName, url) {
  93193. var task = new TextFileAssetTask(taskName, url);
  93194. this._tasks.push(task);
  93195. return task;
  93196. };
  93197. /**
  93198. * Add a BinaryFileAssetTask to the list of active tasks
  93199. * @param taskName defines the name of the new task
  93200. * @param url defines the url of the file to load
  93201. * @returns a new BinaryFileAssetTask object
  93202. */
  93203. AssetsManager.prototype.addBinaryFileTask = function (taskName, url) {
  93204. var task = new BinaryFileAssetTask(taskName, url);
  93205. this._tasks.push(task);
  93206. return task;
  93207. };
  93208. /**
  93209. * Add a ImageAssetTask to the list of active tasks
  93210. * @param taskName defines the name of the new task
  93211. * @param url defines the url of the file to load
  93212. * @returns a new ImageAssetTask object
  93213. */
  93214. AssetsManager.prototype.addImageTask = function (taskName, url) {
  93215. var task = new ImageAssetTask(taskName, url);
  93216. this._tasks.push(task);
  93217. return task;
  93218. };
  93219. /**
  93220. * Add a TextureAssetTask to the list of active tasks
  93221. * @param taskName defines the name of the new task
  93222. * @param url defines the url of the file to load
  93223. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  93224. * @param invertY defines if you want to invert Y axis of the loaded texture (false by default)
  93225. * @param samplingMode defines the sampling mode to use (Texture.TRILINEAR_SAMPLINGMODE by default)
  93226. * @returns a new TextureAssetTask object
  93227. */
  93228. AssetsManager.prototype.addTextureTask = function (taskName, url, noMipmap, invertY, samplingMode) {
  93229. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].TRILINEAR_SAMPLINGMODE; }
  93230. var task = new TextureAssetTask(taskName, url, noMipmap, invertY, samplingMode);
  93231. this._tasks.push(task);
  93232. return task;
  93233. };
  93234. /**
  93235. * Add a CubeTextureAssetTask to the list of active tasks
  93236. * @param taskName defines the name of the new task
  93237. * @param url defines the url of the file to load
  93238. * @param extensions defines the extension to use to load the cube map (can be null)
  93239. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  93240. * @param files defines the list of files to load (can be null)
  93241. * @returns a new CubeTextureAssetTask object
  93242. */
  93243. AssetsManager.prototype.addCubeTextureTask = function (taskName, url, extensions, noMipmap, files) {
  93244. var task = new CubeTextureAssetTask(taskName, url, extensions, noMipmap, files);
  93245. this._tasks.push(task);
  93246. return task;
  93247. };
  93248. /**
  93249. *
  93250. * Add a HDRCubeTextureAssetTask to the list of active tasks
  93251. * @param taskName defines the name of the new task
  93252. * @param url defines the url of the file to load
  93253. * @param size defines the size you want for the cubemap (can be null)
  93254. * @param noMipmap defines if the texture must not receive mipmaps (false by default)
  93255. * @param generateHarmonics defines if you want to automatically generate (true by default)
  93256. * @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)
  93257. * @param reserved Internal use only
  93258. * @returns a new HDRCubeTextureAssetTask object
  93259. */
  93260. AssetsManager.prototype.addHDRCubeTextureTask = function (taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved) {
  93261. if (noMipmap === void 0) { noMipmap = false; }
  93262. if (generateHarmonics === void 0) { generateHarmonics = true; }
  93263. if (gammaSpace === void 0) { gammaSpace = false; }
  93264. if (reserved === void 0) { reserved = false; }
  93265. var task = new HDRCubeTextureAssetTask(taskName, url, size, noMipmap, generateHarmonics, gammaSpace, reserved);
  93266. this._tasks.push(task);
  93267. return task;
  93268. };
  93269. /**
  93270. * Remove a task from the assets manager.
  93271. * @param task the task to remove
  93272. */
  93273. AssetsManager.prototype.removeTask = function (task) {
  93274. var index = this._tasks.indexOf(task);
  93275. if (index > -1) {
  93276. this._tasks.splice(index, 1);
  93277. }
  93278. };
  93279. AssetsManager.prototype._decreaseWaitingTasksCount = function (task) {
  93280. this._waitingTasksCount--;
  93281. try {
  93282. if (this.onProgress) {
  93283. this.onProgress(this._waitingTasksCount, this._totalTasksCount, task);
  93284. }
  93285. this.onProgressObservable.notifyObservers(new AssetsProgressEvent(this._waitingTasksCount, this._totalTasksCount, task));
  93286. }
  93287. catch (e) {
  93288. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running progress callbacks.");
  93289. console.log(e);
  93290. }
  93291. if (this._waitingTasksCount === 0) {
  93292. try {
  93293. if (this.onFinish) {
  93294. this.onFinish(this._tasks);
  93295. }
  93296. // Let's remove successfull tasks
  93297. var currentTasks = this._tasks.slice();
  93298. for (var _i = 0, currentTasks_1 = currentTasks; _i < currentTasks_1.length; _i++) {
  93299. var task = currentTasks_1[_i];
  93300. if (task.taskState === AssetTaskState.DONE) {
  93301. var index = this._tasks.indexOf(task);
  93302. if (index > -1) {
  93303. this._tasks.splice(index, 1);
  93304. }
  93305. }
  93306. }
  93307. this.onTasksDoneObservable.notifyObservers(this._tasks);
  93308. }
  93309. catch (e) {
  93310. _Misc_logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error running tasks-done callbacks.");
  93311. console.log(e);
  93312. }
  93313. this._isLoading = false;
  93314. this._scene.getEngine().hideLoadingUI();
  93315. }
  93316. };
  93317. AssetsManager.prototype._runTask = function (task) {
  93318. var _this = this;
  93319. var done = function () {
  93320. try {
  93321. if (_this.onTaskSuccess) {
  93322. _this.onTaskSuccess(task);
  93323. }
  93324. _this.onTaskSuccessObservable.notifyObservers(task);
  93325. _this._decreaseWaitingTasksCount(task);
  93326. }
  93327. catch (e) {
  93328. error("Error executing task success callbacks", e);
  93329. }
  93330. };
  93331. var error = function (message, exception) {
  93332. task._setErrorObject(message, exception);
  93333. if (_this.onTaskError) {
  93334. _this.onTaskError(task);
  93335. }
  93336. _this.onTaskErrorObservable.notifyObservers(task);
  93337. _this._decreaseWaitingTasksCount(task);
  93338. };
  93339. task.run(this._scene, done, error);
  93340. };
  93341. /**
  93342. * Reset the AssetsManager and remove all tasks
  93343. * @return the current instance of the AssetsManager
  93344. */
  93345. AssetsManager.prototype.reset = function () {
  93346. this._isLoading = false;
  93347. this._tasks = new Array();
  93348. return this;
  93349. };
  93350. /**
  93351. * Start the loading process
  93352. * @return the current instance of the AssetsManager
  93353. */
  93354. AssetsManager.prototype.load = function () {
  93355. if (this._isLoading) {
  93356. return this;
  93357. }
  93358. this._isLoading = true;
  93359. this._waitingTasksCount = this._tasks.length;
  93360. this._totalTasksCount = this._tasks.length;
  93361. if (this._waitingTasksCount === 0) {
  93362. this._isLoading = false;
  93363. if (this.onFinish) {
  93364. this.onFinish(this._tasks);
  93365. }
  93366. this.onTasksDoneObservable.notifyObservers(this._tasks);
  93367. return this;
  93368. }
  93369. if (this.useDefaultLoadingScreen) {
  93370. this._scene.getEngine().displayLoadingUI();
  93371. }
  93372. for (var index = 0; index < this._tasks.length; index++) {
  93373. var task = this._tasks[index];
  93374. if (task.taskState === AssetTaskState.INIT) {
  93375. this._runTask(task);
  93376. }
  93377. }
  93378. return this;
  93379. };
  93380. return AssetsManager;
  93381. }());
  93382. /***/ }),
  93383. /***/ "./Misc/dds.ts":
  93384. /*!*********************!*\
  93385. !*** ./Misc/dds.ts ***!
  93386. \*********************/
  93387. /*! exports provided: DDSTools */
  93388. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  93389. "use strict";
  93390. __webpack_require__.r(__webpack_exports__);
  93391. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return DDSTools; });
  93392. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  93393. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  93394. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  93395. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  93396. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  93397. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  93398. /* harmony import */ var _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Misc/HighDynamicRange/cubemapToSphericalPolynomial */ "./Misc/HighDynamicRange/cubemapToSphericalPolynomial.ts");
  93399. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  93400. // Based on demo done by Brandon Jones - http://media.tojicode.com/webgl-samples/dds.html
  93401. // All values and structures referenced from:
  93402. // http://msdn.microsoft.com/en-us/library/bb943991.aspx/
  93403. var DDS_MAGIC = 0x20534444;
  93404. var
  93405. //DDSD_CAPS = 0x1,
  93406. //DDSD_HEIGHT = 0x2,
  93407. //DDSD_WIDTH = 0x4,
  93408. //DDSD_PITCH = 0x8,
  93409. //DDSD_PIXELFORMAT = 0x1000,
  93410. DDSD_MIPMAPCOUNT = 0x20000;
  93411. //DDSD_LINEARSIZE = 0x80000,
  93412. //DDSD_DEPTH = 0x800000;
  93413. // var DDSCAPS_COMPLEX = 0x8,
  93414. // DDSCAPS_MIPMAP = 0x400000,
  93415. // DDSCAPS_TEXTURE = 0x1000;
  93416. var DDSCAPS2_CUBEMAP = 0x200;
  93417. // DDSCAPS2_CUBEMAP_POSITIVEX = 0x400,
  93418. // DDSCAPS2_CUBEMAP_NEGATIVEX = 0x800,
  93419. // DDSCAPS2_CUBEMAP_POSITIVEY = 0x1000,
  93420. // DDSCAPS2_CUBEMAP_NEGATIVEY = 0x2000,
  93421. // DDSCAPS2_CUBEMAP_POSITIVEZ = 0x4000,
  93422. // DDSCAPS2_CUBEMAP_NEGATIVEZ = 0x8000,
  93423. // DDSCAPS2_VOLUME = 0x200000;
  93424. var
  93425. //DDPF_ALPHAPIXELS = 0x1,
  93426. //DDPF_ALPHA = 0x2,
  93427. DDPF_FOURCC = 0x4, DDPF_RGB = 0x40,
  93428. //DDPF_YUV = 0x200,
  93429. DDPF_LUMINANCE = 0x20000;
  93430. function FourCCToInt32(value) {
  93431. return value.charCodeAt(0) +
  93432. (value.charCodeAt(1) << 8) +
  93433. (value.charCodeAt(2) << 16) +
  93434. (value.charCodeAt(3) << 24);
  93435. }
  93436. function Int32ToFourCC(value) {
  93437. return String.fromCharCode(value & 0xff, (value >> 8) & 0xff, (value >> 16) & 0xff, (value >> 24) & 0xff);
  93438. }
  93439. var FOURCC_DXT1 = FourCCToInt32("DXT1");
  93440. var FOURCC_DXT3 = FourCCToInt32("DXT3");
  93441. var FOURCC_DXT5 = FourCCToInt32("DXT5");
  93442. var FOURCC_DX10 = FourCCToInt32("DX10");
  93443. var FOURCC_D3DFMT_R16G16B16A16F = 113;
  93444. var FOURCC_D3DFMT_R32G32B32A32F = 116;
  93445. var DXGI_FORMAT_R16G16B16A16_FLOAT = 10;
  93446. var DXGI_FORMAT_B8G8R8X8_UNORM = 88;
  93447. var headerLengthInt = 31; // The header length in 32 bit ints
  93448. // Offsets into the header array
  93449. var off_magic = 0;
  93450. var off_size = 1;
  93451. var off_flags = 2;
  93452. var off_height = 3;
  93453. var off_width = 4;
  93454. var off_mipmapCount = 7;
  93455. var off_pfFlags = 20;
  93456. var off_pfFourCC = 21;
  93457. var off_RGBbpp = 22;
  93458. var off_RMask = 23;
  93459. var off_GMask = 24;
  93460. var off_BMask = 25;
  93461. var off_AMask = 26;
  93462. // var off_caps1 = 27;
  93463. var off_caps2 = 28;
  93464. // var off_caps3 = 29;
  93465. // var off_caps4 = 30;
  93466. var off_dxgiFormat = 32;
  93467. /**
  93468. * Class used to provide DDS decompression tools
  93469. */
  93470. var DDSTools = /** @class */ (function () {
  93471. function DDSTools() {
  93472. }
  93473. /**
  93474. * Gets DDS information from an array buffer
  93475. * @param arrayBuffer defines the array buffer to read data from
  93476. * @returns the DDS information
  93477. */
  93478. DDSTools.GetDDSInfo = function (arrayBuffer) {
  93479. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  93480. var extendedHeader = new Int32Array(arrayBuffer, 0, headerLengthInt + 4);
  93481. var mipmapCount = 1;
  93482. if (header[off_flags] & DDSD_MIPMAPCOUNT) {
  93483. mipmapCount = Math.max(1, header[off_mipmapCount]);
  93484. }
  93485. var fourCC = header[off_pfFourCC];
  93486. var dxgiFormat = (fourCC === FOURCC_DX10) ? extendedHeader[off_dxgiFormat] : 0;
  93487. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93488. switch (fourCC) {
  93489. case FOURCC_D3DFMT_R16G16B16A16F:
  93490. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93491. break;
  93492. case FOURCC_D3DFMT_R32G32B32A32F:
  93493. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93494. break;
  93495. case FOURCC_DX10:
  93496. if (dxgiFormat === DXGI_FORMAT_R16G16B16A16_FLOAT) {
  93497. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93498. break;
  93499. }
  93500. }
  93501. return {
  93502. width: header[off_width],
  93503. height: header[off_height],
  93504. mipmapCount: mipmapCount,
  93505. isFourCC: (header[off_pfFlags] & DDPF_FOURCC) === DDPF_FOURCC,
  93506. isRGB: (header[off_pfFlags] & DDPF_RGB) === DDPF_RGB,
  93507. isLuminance: (header[off_pfFlags] & DDPF_LUMINANCE) === DDPF_LUMINANCE,
  93508. isCube: (header[off_caps2] & DDSCAPS2_CUBEMAP) === DDSCAPS2_CUBEMAP,
  93509. isCompressed: (fourCC === FOURCC_DXT1 || fourCC === FOURCC_DXT3 || fourCC === FOURCC_DXT5),
  93510. dxgiFormat: dxgiFormat,
  93511. textureType: textureType
  93512. };
  93513. };
  93514. DDSTools._ToHalfFloat = function (value) {
  93515. if (!DDSTools._FloatView) {
  93516. DDSTools._FloatView = new Float32Array(1);
  93517. DDSTools._Int32View = new Int32Array(DDSTools._FloatView.buffer);
  93518. }
  93519. DDSTools._FloatView[0] = value;
  93520. var x = DDSTools._Int32View[0];
  93521. var bits = (x >> 16) & 0x8000; /* Get the sign */
  93522. var m = (x >> 12) & 0x07ff; /* Keep one extra bit for rounding */
  93523. var e = (x >> 23) & 0xff; /* Using int is faster here */
  93524. /* If zero, or denormal, or exponent underflows too much for a denormal
  93525. * half, return signed zero. */
  93526. if (e < 103) {
  93527. return bits;
  93528. }
  93529. /* If NaN, return NaN. If Inf or exponent overflow, return Inf. */
  93530. if (e > 142) {
  93531. bits |= 0x7c00;
  93532. /* If exponent was 0xff and one mantissa bit was set, it means NaN,
  93533. * not Inf, so make sure we set one mantissa bit too. */
  93534. bits |= ((e == 255) ? 0 : 1) && (x & 0x007fffff);
  93535. return bits;
  93536. }
  93537. /* If exponent underflows but not too much, return a denormal */
  93538. if (e < 113) {
  93539. m |= 0x0800;
  93540. /* Extra rounding may overflow and set mantissa to 0 and exponent
  93541. * to 1, which is OK. */
  93542. bits |= (m >> (114 - e)) + ((m >> (113 - e)) & 1);
  93543. return bits;
  93544. }
  93545. bits |= ((e - 112) << 10) | (m >> 1);
  93546. bits += m & 1;
  93547. return bits;
  93548. };
  93549. DDSTools._FromHalfFloat = function (value) {
  93550. var s = (value & 0x8000) >> 15;
  93551. var e = (value & 0x7C00) >> 10;
  93552. var f = value & 0x03FF;
  93553. if (e === 0) {
  93554. return (s ? -1 : 1) * Math.pow(2, -14) * (f / Math.pow(2, 10));
  93555. }
  93556. else if (e == 0x1F) {
  93557. return f ? NaN : ((s ? -1 : 1) * Infinity);
  93558. }
  93559. return (s ? -1 : 1) * Math.pow(2, e - 15) * (1 + (f / Math.pow(2, 10)));
  93560. };
  93561. DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  93562. var destArray = new Float32Array(dataLength);
  93563. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  93564. var index = 0;
  93565. for (var y = 0; y < height; y++) {
  93566. for (var x = 0; x < width; x++) {
  93567. var srcPos = (x + y * width) * 4;
  93568. destArray[index] = DDSTools._FromHalfFloat(srcData[srcPos]);
  93569. destArray[index + 1] = DDSTools._FromHalfFloat(srcData[srcPos + 1]);
  93570. destArray[index + 2] = DDSTools._FromHalfFloat(srcData[srcPos + 2]);
  93571. if (DDSTools.StoreLODInAlphaChannel) {
  93572. destArray[index + 3] = lod;
  93573. }
  93574. else {
  93575. destArray[index + 3] = DDSTools._FromHalfFloat(srcData[srcPos + 3]);
  93576. }
  93577. index += 4;
  93578. }
  93579. }
  93580. return destArray;
  93581. };
  93582. DDSTools._GetHalfFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  93583. if (DDSTools.StoreLODInAlphaChannel) {
  93584. var destArray = new Uint16Array(dataLength);
  93585. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  93586. var index = 0;
  93587. for (var y = 0; y < height; y++) {
  93588. for (var x = 0; x < width; x++) {
  93589. var srcPos = (x + y * width) * 4;
  93590. destArray[index] = srcData[srcPos];
  93591. destArray[index + 1] = srcData[srcPos + 1];
  93592. destArray[index + 2] = srcData[srcPos + 2];
  93593. destArray[index + 3] = DDSTools._ToHalfFloat(lod);
  93594. index += 4;
  93595. }
  93596. }
  93597. return destArray;
  93598. }
  93599. return new Uint16Array(arrayBuffer, dataOffset, dataLength);
  93600. };
  93601. DDSTools._GetFloatRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  93602. if (DDSTools.StoreLODInAlphaChannel) {
  93603. var destArray = new Float32Array(dataLength);
  93604. var srcData = new Float32Array(arrayBuffer, dataOffset);
  93605. var index = 0;
  93606. for (var y = 0; y < height; y++) {
  93607. for (var x = 0; x < width; x++) {
  93608. var srcPos = (x + y * width) * 4;
  93609. destArray[index] = srcData[srcPos];
  93610. destArray[index + 1] = srcData[srcPos + 1];
  93611. destArray[index + 2] = srcData[srcPos + 2];
  93612. destArray[index + 3] = lod;
  93613. index += 4;
  93614. }
  93615. }
  93616. return destArray;
  93617. }
  93618. return new Float32Array(arrayBuffer, dataOffset, dataLength);
  93619. };
  93620. DDSTools._GetFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  93621. var destArray = new Uint8Array(dataLength);
  93622. var srcData = new Float32Array(arrayBuffer, dataOffset);
  93623. var index = 0;
  93624. for (var y = 0; y < height; y++) {
  93625. for (var x = 0; x < width; x++) {
  93626. var srcPos = (x + y * width) * 4;
  93627. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos]) * 255;
  93628. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 1]) * 255;
  93629. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 2]) * 255;
  93630. if (DDSTools.StoreLODInAlphaChannel) {
  93631. destArray[index + 3] = lod;
  93632. }
  93633. else {
  93634. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(srcData[srcPos + 3]) * 255;
  93635. }
  93636. index += 4;
  93637. }
  93638. }
  93639. return destArray;
  93640. };
  93641. DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, lod) {
  93642. var destArray = new Uint8Array(dataLength);
  93643. var srcData = new Uint16Array(arrayBuffer, dataOffset);
  93644. var index = 0;
  93645. for (var y = 0; y < height; y++) {
  93646. for (var x = 0; x < width; x++) {
  93647. var srcPos = (x + y * width) * 4;
  93648. destArray[index] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos])) * 255;
  93649. destArray[index + 1] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 1])) * 255;
  93650. destArray[index + 2] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 2])) * 255;
  93651. if (DDSTools.StoreLODInAlphaChannel) {
  93652. destArray[index + 3] = lod;
  93653. }
  93654. else {
  93655. destArray[index + 3] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Clamp(DDSTools._FromHalfFloat(srcData[srcPos + 3])) * 255;
  93656. }
  93657. index += 4;
  93658. }
  93659. }
  93660. return destArray;
  93661. };
  93662. DDSTools._GetRGBAArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset) {
  93663. var byteArray = new Uint8Array(dataLength);
  93664. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93665. var index = 0;
  93666. for (var y = 0; y < height; y++) {
  93667. for (var x = 0; x < width; x++) {
  93668. var srcPos = (x + y * width) * 4;
  93669. byteArray[index] = srcData[srcPos + rOffset];
  93670. byteArray[index + 1] = srcData[srcPos + gOffset];
  93671. byteArray[index + 2] = srcData[srcPos + bOffset];
  93672. byteArray[index + 3] = srcData[srcPos + aOffset];
  93673. index += 4;
  93674. }
  93675. }
  93676. return byteArray;
  93677. };
  93678. DDSTools._ExtractLongWordOrder = function (value) {
  93679. if (value === 0 || value === 255 || value === -16777216) {
  93680. return 0;
  93681. }
  93682. return 1 + DDSTools._ExtractLongWordOrder(value >> 8);
  93683. };
  93684. DDSTools._GetRGBArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset) {
  93685. var byteArray = new Uint8Array(dataLength);
  93686. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93687. var index = 0;
  93688. for (var y = 0; y < height; y++) {
  93689. for (var x = 0; x < width; x++) {
  93690. var srcPos = (x + y * width) * 3;
  93691. byteArray[index] = srcData[srcPos + rOffset];
  93692. byteArray[index + 1] = srcData[srcPos + gOffset];
  93693. byteArray[index + 2] = srcData[srcPos + bOffset];
  93694. index += 3;
  93695. }
  93696. }
  93697. return byteArray;
  93698. };
  93699. DDSTools._GetLuminanceArrayBuffer = function (width, height, dataOffset, dataLength, arrayBuffer) {
  93700. var byteArray = new Uint8Array(dataLength);
  93701. var srcData = new Uint8Array(arrayBuffer, dataOffset);
  93702. var index = 0;
  93703. for (var y = 0; y < height; y++) {
  93704. for (var x = 0; x < width; x++) {
  93705. var srcPos = (x + y * width);
  93706. byteArray[index] = srcData[srcPos];
  93707. index++;
  93708. }
  93709. }
  93710. return byteArray;
  93711. };
  93712. /**
  93713. * Uploads DDS Levels to a Babylon Texture
  93714. * @hidden
  93715. */
  93716. DDSTools.UploadDDSLevels = function (engine, texture, arrayBuffer, info, loadMipmaps, faces, lodIndex, currentFace) {
  93717. if (lodIndex === void 0) { lodIndex = -1; }
  93718. var sphericalPolynomialFaces = null;
  93719. if (info.sphericalPolynomial) {
  93720. sphericalPolynomialFaces = new Array();
  93721. }
  93722. var ext = engine.getCaps().s3tc;
  93723. var header = new Int32Array(arrayBuffer, 0, headerLengthInt);
  93724. var fourCC, width, height, dataLength = 0, dataOffset;
  93725. var byteArray, mipmapCount, mip;
  93726. var internalCompressedFormat = 0;
  93727. var blockBytes = 1;
  93728. if (header[off_magic] !== DDS_MAGIC) {
  93729. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Invalid magic number in DDS header");
  93730. return;
  93731. }
  93732. if (!info.isFourCC && !info.isRGB && !info.isLuminance) {
  93733. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Unsupported format, must contain a FourCC, RGB or LUMINANCE code");
  93734. return;
  93735. }
  93736. if (info.isCompressed && !ext) {
  93737. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Error("Compressed textures are not supported on this platform.");
  93738. return;
  93739. }
  93740. var bpp = header[off_RGBbpp];
  93741. dataOffset = header[off_size] + 4;
  93742. var computeFormats = false;
  93743. if (info.isFourCC) {
  93744. fourCC = header[off_pfFourCC];
  93745. switch (fourCC) {
  93746. case FOURCC_DXT1:
  93747. blockBytes = 8;
  93748. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT1_EXT;
  93749. break;
  93750. case FOURCC_DXT3:
  93751. blockBytes = 16;
  93752. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT3_EXT;
  93753. break;
  93754. case FOURCC_DXT5:
  93755. blockBytes = 16;
  93756. internalCompressedFormat = ext.COMPRESSED_RGBA_S3TC_DXT5_EXT;
  93757. break;
  93758. case FOURCC_D3DFMT_R16G16B16A16F:
  93759. computeFormats = true;
  93760. break;
  93761. case FOURCC_D3DFMT_R32G32B32A32F:
  93762. computeFormats = true;
  93763. break;
  93764. case FOURCC_DX10:
  93765. // There is an additionnal header so dataOffset need to be changed
  93766. dataOffset += 5 * 4; // 5 uints
  93767. var supported = false;
  93768. switch (info.dxgiFormat) {
  93769. case DXGI_FORMAT_R16G16B16A16_FLOAT:
  93770. computeFormats = true;
  93771. supported = true;
  93772. break;
  93773. case DXGI_FORMAT_B8G8R8X8_UNORM:
  93774. info.isRGB = true;
  93775. info.isFourCC = false;
  93776. bpp = 32;
  93777. supported = true;
  93778. break;
  93779. }
  93780. if (supported) {
  93781. break;
  93782. }
  93783. default:
  93784. console.error("Unsupported FourCC code:", Int32ToFourCC(fourCC));
  93785. return;
  93786. }
  93787. }
  93788. var rOffset = DDSTools._ExtractLongWordOrder(header[off_RMask]);
  93789. var gOffset = DDSTools._ExtractLongWordOrder(header[off_GMask]);
  93790. var bOffset = DDSTools._ExtractLongWordOrder(header[off_BMask]);
  93791. var aOffset = DDSTools._ExtractLongWordOrder(header[off_AMask]);
  93792. if (computeFormats) {
  93793. internalCompressedFormat = engine._getRGBABufferInternalSizedFormat(info.textureType);
  93794. }
  93795. mipmapCount = 1;
  93796. if (header[off_flags] & DDSD_MIPMAPCOUNT && loadMipmaps !== false) {
  93797. mipmapCount = Math.max(1, header[off_mipmapCount]);
  93798. }
  93799. for (var face = 0; face < faces; face++) {
  93800. width = header[off_width];
  93801. height = header[off_height];
  93802. for (mip = 0; mip < mipmapCount; ++mip) {
  93803. if (lodIndex === -1 || lodIndex === mip) {
  93804. // In case of fixed LOD, if the lod has just been uploaded, early exit.
  93805. var i = (lodIndex === -1) ? mip : 0;
  93806. if (!info.isCompressed && info.isFourCC) {
  93807. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93808. dataLength = width * height * 4;
  93809. var floatArray = null;
  93810. if (engine._badOS || engine._badDesktopOS || (!engine.getCaps().textureHalfFloat && !engine.getCaps().textureFloat)) { // Required because iOS has many issues with float and half float generation
  93811. if (bpp === 128) {
  93812. floatArray = DDSTools._GetFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93813. if (sphericalPolynomialFaces && i == 0) {
  93814. sphericalPolynomialFaces.push(DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93815. }
  93816. }
  93817. else if (bpp === 64) {
  93818. floatArray = DDSTools._GetHalfFloatAsUIntRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93819. if (sphericalPolynomialFaces && i == 0) {
  93820. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93821. }
  93822. }
  93823. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93824. }
  93825. else {
  93826. if (bpp === 128) {
  93827. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93828. floatArray = DDSTools._GetFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93829. if (sphericalPolynomialFaces && i == 0) {
  93830. sphericalPolynomialFaces.push(floatArray);
  93831. }
  93832. }
  93833. else if (bpp === 64 && !engine.getCaps().textureHalfFloat) {
  93834. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  93835. floatArray = DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93836. if (sphericalPolynomialFaces && i == 0) {
  93837. sphericalPolynomialFaces.push(floatArray);
  93838. }
  93839. }
  93840. else { // 64
  93841. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  93842. floatArray = DDSTools._GetHalfFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i);
  93843. if (sphericalPolynomialFaces && i == 0) {
  93844. sphericalPolynomialFaces.push(DDSTools._GetHalfFloatAsFloatRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, i));
  93845. }
  93846. }
  93847. }
  93848. if (floatArray) {
  93849. engine._uploadDataToTextureDirectly(texture, floatArray, face, i);
  93850. }
  93851. }
  93852. else if (info.isRGB) {
  93853. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93854. if (bpp === 24) {
  93855. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGB;
  93856. dataLength = width * height * 3;
  93857. byteArray = DDSTools._GetRGBArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset);
  93858. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93859. }
  93860. else { // 32
  93861. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA;
  93862. dataLength = width * height * 4;
  93863. byteArray = DDSTools._GetRGBAArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer, rOffset, gOffset, bOffset, aOffset);
  93864. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93865. }
  93866. }
  93867. else if (info.isLuminance) {
  93868. var unpackAlignment = engine._getUnpackAlignement();
  93869. var unpaddedRowSize = width;
  93870. var paddedRowSize = Math.floor((width + unpackAlignment - 1) / unpackAlignment) * unpackAlignment;
  93871. dataLength = paddedRowSize * (height - 1) + unpaddedRowSize;
  93872. byteArray = DDSTools._GetLuminanceArrayBuffer(width, height, dataOffset, dataLength, arrayBuffer);
  93873. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_LUMINANCE;
  93874. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93875. engine._uploadDataToTextureDirectly(texture, byteArray, face, i);
  93876. }
  93877. else {
  93878. dataLength = Math.max(4, width) / 4 * Math.max(4, height) / 4 * blockBytes;
  93879. byteArray = new Uint8Array(arrayBuffer, dataOffset, dataLength);
  93880. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  93881. engine._uploadCompressedDataToTextureDirectly(texture, internalCompressedFormat, width, height, byteArray, face, i);
  93882. }
  93883. }
  93884. dataOffset += bpp ? (width * height * (bpp / 8)) : dataLength;
  93885. width *= 0.5;
  93886. height *= 0.5;
  93887. width = Math.max(1.0, width);
  93888. height = Math.max(1.0, height);
  93889. }
  93890. if (currentFace !== undefined) {
  93891. // Loading a single face
  93892. break;
  93893. }
  93894. }
  93895. if (sphericalPolynomialFaces && sphericalPolynomialFaces.length > 0) {
  93896. info.sphericalPolynomial = _Misc_HighDynamicRange_cubemapToSphericalPolynomial__WEBPACK_IMPORTED_MODULE_6__["CubeMapToSphericalPolynomialTools"].ConvertCubeMapToSphericalPolynomial({
  93897. size: header[off_width],
  93898. right: sphericalPolynomialFaces[0],
  93899. left: sphericalPolynomialFaces[1],
  93900. up: sphericalPolynomialFaces[2],
  93901. down: sphericalPolynomialFaces[3],
  93902. front: sphericalPolynomialFaces[4],
  93903. back: sphericalPolynomialFaces[5],
  93904. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTUREFORMAT_RGBA,
  93905. type: _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT,
  93906. gammaSpace: false,
  93907. });
  93908. }
  93909. else {
  93910. info.sphericalPolynomial = undefined;
  93911. }
  93912. };
  93913. /**
  93914. * Gets or sets a boolean indicating that LOD info is stored in alpha channel (false by default)
  93915. */
  93916. DDSTools.StoreLODInAlphaChannel = false;
  93917. return DDSTools;
  93918. }());
  93919. /**
  93920. * Create a cube texture from prefiltered data (ie. the mipmaps contain ready to use data for PBR reflection)
  93921. * @param rootUrl defines the url where the file to load is located
  93922. * @param scene defines the current scene
  93923. * @param lodScale defines scale to apply to the mip map selection
  93924. * @param lodOffset defines offset to apply to the mip map selection
  93925. * @param onLoad defines an optional callback raised when the texture is loaded
  93926. * @param onError defines an optional callback raised if there is an issue to load the texture
  93927. * @param format defines the format of the data
  93928. * @param forcedExtension defines the extension to use to pick the right loader
  93929. * @param createPolynomials defines wheter or not to create polynomails harmonics for the texture
  93930. * @returns the cube texture as an InternalTexture
  93931. */
  93932. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createPrefilteredCubeTexture = function (rootUrl, scene, lodScale, lodOffset, onLoad, onError, format, forcedExtension, createPolynomials) {
  93933. var _this = this;
  93934. if (onLoad === void 0) { onLoad = null; }
  93935. if (onError === void 0) { onError = null; }
  93936. if (forcedExtension === void 0) { forcedExtension = null; }
  93937. if (createPolynomials === void 0) { createPolynomials = true; }
  93938. var callback = function (loadData) {
  93939. if (!loadData) {
  93940. if (onLoad) {
  93941. onLoad(null);
  93942. }
  93943. return;
  93944. }
  93945. var texture = loadData.texture;
  93946. if (!createPolynomials) {
  93947. texture._sphericalPolynomial = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_1__["SphericalPolynomial"]();
  93948. }
  93949. else if (loadData.info.sphericalPolynomial) {
  93950. texture._sphericalPolynomial = loadData.info.sphericalPolynomial;
  93951. }
  93952. texture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBEPREFILTERED;
  93953. if (_this.getCaps().textureLOD) {
  93954. // Do not add extra process if texture lod is supported.
  93955. if (onLoad) {
  93956. onLoad(texture);
  93957. }
  93958. return;
  93959. }
  93960. var mipSlices = 3;
  93961. var gl = _this._gl;
  93962. var width = loadData.width;
  93963. if (!width) {
  93964. return;
  93965. }
  93966. var textures = [];
  93967. for (var i = 0; i < mipSlices; i++) {
  93968. //compute LOD from even spacing in smoothness (matching shader calculation)
  93969. var smoothness = i / (mipSlices - 1);
  93970. var roughness = 1 - smoothness;
  93971. var minLODIndex = lodOffset; // roughness = 0
  93972. var maxLODIndex = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) * lodScale + lodOffset; // roughness = 1
  93973. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  93974. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  93975. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](_this, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  93976. glTextureFromLod.type = texture.type;
  93977. glTextureFromLod.format = texture.format;
  93978. glTextureFromLod.width = Math.pow(2, Math.max(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_0__["Scalar"].Log2(width) - mipmapIndex, 0));
  93979. glTextureFromLod.height = glTextureFromLod.width;
  93980. glTextureFromLod.isCube = true;
  93981. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, glTextureFromLod, true);
  93982. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MAG_FILTER, gl.LINEAR);
  93983. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_MIN_FILTER, gl.LINEAR);
  93984. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_S, gl.CLAMP_TO_EDGE);
  93985. gl.texParameteri(gl.TEXTURE_CUBE_MAP, gl.TEXTURE_WRAP_T, gl.CLAMP_TO_EDGE);
  93986. if (loadData.isDDS) {
  93987. var info = loadData.info;
  93988. var data = loadData.data;
  93989. _this._unpackFlipY(info.isCompressed);
  93990. DDSTools.UploadDDSLevels(_this, glTextureFromLod, data, info, true, 6, mipmapIndex);
  93991. }
  93992. else {
  93993. _Misc_logger__WEBPACK_IMPORTED_MODULE_5__["Logger"].Warn("DDS is the only prefiltered cube map supported so far.");
  93994. }
  93995. _this._bindTextureDirectly(gl.TEXTURE_CUBE_MAP, null);
  93996. // Wrap in a base texture for easy binding.
  93997. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_7__["BaseTexture"](scene);
  93998. lodTexture.isCube = true;
  93999. lodTexture._texture = glTextureFromLod;
  94000. glTextureFromLod.isReady = true;
  94001. textures.push(lodTexture);
  94002. }
  94003. texture._lodTextureHigh = textures[2];
  94004. texture._lodTextureMid = textures[1];
  94005. texture._lodTextureLow = textures[0];
  94006. if (onLoad) {
  94007. onLoad(texture);
  94008. }
  94009. };
  94010. return this.createCubeTexture(rootUrl, scene, null, false, callback, onError, format, forcedExtension, createPolynomials, lodScale, lodOffset);
  94011. };
  94012. /***/ }),
  94013. /***/ "./Misc/decorators.ts":
  94014. /*!****************************!*\
  94015. !*** ./Misc/decorators.ts ***!
  94016. \****************************/
  94017. /*! exports provided: expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper */
  94018. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94019. "use strict";
  94020. __webpack_require__.r(__webpack_exports__);
  94021. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return expandToProperty; });
  94022. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return serialize; });
  94023. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return serializeAsTexture; });
  94024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return serializeAsColor3; });
  94025. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return serializeAsFresnelParameters; });
  94026. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return serializeAsVector2; });
  94027. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return serializeAsVector3; });
  94028. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return serializeAsMeshReference; });
  94029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return serializeAsColorCurves; });
  94030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return serializeAsColor4; });
  94031. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return serializeAsImageProcessingConfiguration; });
  94032. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return serializeAsQuaternion; });
  94033. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return serializeAsCameraReference; });
  94034. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return SerializationHelper; });
  94035. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tags */ "./Misc/tags.ts");
  94036. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94037. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  94038. var __decoratorInitialStore = {};
  94039. var __mergedStore = {};
  94040. var _copySource = function (creationFunction, source, instanciate) {
  94041. var destination = creationFunction();
  94042. // Tags
  94043. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  94044. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  94045. }
  94046. var classStore = getMergedStore(destination);
  94047. // Properties
  94048. for (var property in classStore) {
  94049. var propertyDescriptor = classStore[property];
  94050. var sourceProperty = source[property];
  94051. var propertyType = propertyDescriptor.type;
  94052. if (sourceProperty !== undefined && sourceProperty !== null && property !== "uniqueId") {
  94053. switch (propertyType) {
  94054. case 0: // Value
  94055. case 6: // Mesh reference
  94056. case 11: // Camera reference
  94057. destination[property] = sourceProperty;
  94058. break;
  94059. case 1: // Texture
  94060. destination[property] = (instanciate || sourceProperty.isRenderTarget) ? sourceProperty : sourceProperty.clone();
  94061. break;
  94062. case 2: // Color3
  94063. case 3: // FresnelParameters
  94064. case 4: // Vector2
  94065. case 5: // Vector3
  94066. case 7: // Color Curves
  94067. case 10: // Quaternion
  94068. destination[property] = instanciate ? sourceProperty : sourceProperty.clone();
  94069. break;
  94070. }
  94071. }
  94072. }
  94073. return destination;
  94074. };
  94075. function getDirectStore(target) {
  94076. var classKey = target.getClassName();
  94077. if (!__decoratorInitialStore[classKey]) {
  94078. __decoratorInitialStore[classKey] = {};
  94079. }
  94080. return __decoratorInitialStore[classKey];
  94081. }
  94082. /**
  94083. * Return the list of properties flagged as serializable
  94084. * @param target: host object
  94085. */
  94086. function getMergedStore(target) {
  94087. var classKey = target.getClassName();
  94088. if (__mergedStore[classKey]) {
  94089. return __mergedStore[classKey];
  94090. }
  94091. __mergedStore[classKey] = {};
  94092. var store = __mergedStore[classKey];
  94093. var currentTarget = target;
  94094. var currentKey = classKey;
  94095. while (currentKey) {
  94096. var initialStore = __decoratorInitialStore[currentKey];
  94097. for (var property in initialStore) {
  94098. store[property] = initialStore[property];
  94099. }
  94100. var parent_1 = void 0;
  94101. var done = false;
  94102. do {
  94103. parent_1 = Object.getPrototypeOf(currentTarget);
  94104. if (!parent_1.getClassName) {
  94105. done = true;
  94106. break;
  94107. }
  94108. if (parent_1.getClassName() !== currentKey) {
  94109. break;
  94110. }
  94111. currentTarget = parent_1;
  94112. } while (parent_1);
  94113. if (done) {
  94114. break;
  94115. }
  94116. currentKey = parent_1.getClassName();
  94117. currentTarget = parent_1;
  94118. }
  94119. return store;
  94120. }
  94121. function generateSerializableMember(type, sourceName) {
  94122. return function (target, propertyKey) {
  94123. var classStore = getDirectStore(target);
  94124. if (!classStore[propertyKey]) {
  94125. classStore[propertyKey] = { type: type, sourceName: sourceName };
  94126. }
  94127. };
  94128. }
  94129. function generateExpandMember(setCallback, targetKey) {
  94130. if (targetKey === void 0) { targetKey = null; }
  94131. return function (target, propertyKey) {
  94132. var key = targetKey || ("_" + propertyKey);
  94133. Object.defineProperty(target, propertyKey, {
  94134. get: function () {
  94135. return this[key];
  94136. },
  94137. set: function (value) {
  94138. if (this[key] === value) {
  94139. return;
  94140. }
  94141. this[key] = value;
  94142. target[setCallback].apply(this);
  94143. },
  94144. enumerable: true,
  94145. configurable: true
  94146. });
  94147. };
  94148. }
  94149. function expandToProperty(callback, targetKey) {
  94150. if (targetKey === void 0) { targetKey = null; }
  94151. return generateExpandMember(callback, targetKey);
  94152. }
  94153. function serialize(sourceName) {
  94154. return generateSerializableMember(0, sourceName); // value member
  94155. }
  94156. function serializeAsTexture(sourceName) {
  94157. return generateSerializableMember(1, sourceName); // texture member
  94158. }
  94159. function serializeAsColor3(sourceName) {
  94160. return generateSerializableMember(2, sourceName); // color3 member
  94161. }
  94162. function serializeAsFresnelParameters(sourceName) {
  94163. return generateSerializableMember(3, sourceName); // fresnel parameters member
  94164. }
  94165. function serializeAsVector2(sourceName) {
  94166. return generateSerializableMember(4, sourceName); // vector2 member
  94167. }
  94168. function serializeAsVector3(sourceName) {
  94169. return generateSerializableMember(5, sourceName); // vector3 member
  94170. }
  94171. function serializeAsMeshReference(sourceName) {
  94172. return generateSerializableMember(6, sourceName); // mesh reference member
  94173. }
  94174. function serializeAsColorCurves(sourceName) {
  94175. return generateSerializableMember(7, sourceName); // color curves
  94176. }
  94177. function serializeAsColor4(sourceName) {
  94178. return generateSerializableMember(8, sourceName); // color 4
  94179. }
  94180. function serializeAsImageProcessingConfiguration(sourceName) {
  94181. return generateSerializableMember(9, sourceName); // image processing
  94182. }
  94183. function serializeAsQuaternion(sourceName) {
  94184. return generateSerializableMember(10, sourceName); // quaternion member
  94185. }
  94186. /**
  94187. * Decorator used to define property that can be serialized as reference to a camera
  94188. * @param sourceName defines the name of the property to decorate
  94189. */
  94190. function serializeAsCameraReference(sourceName) {
  94191. return generateSerializableMember(11, sourceName); // camera reference member
  94192. }
  94193. /**
  94194. * Class used to help serialization objects
  94195. */
  94196. var SerializationHelper = /** @class */ (function () {
  94197. function SerializationHelper() {
  94198. }
  94199. /**
  94200. * Appends the serialized animations from the source animations
  94201. * @param source Source containing the animations
  94202. * @param destination Target to store the animations
  94203. */
  94204. SerializationHelper.AppendSerializedAnimations = function (source, destination) {
  94205. if (source.animations) {
  94206. destination.animations = [];
  94207. for (var animationIndex = 0; animationIndex < source.animations.length; animationIndex++) {
  94208. var animation = source.animations[animationIndex];
  94209. destination.animations.push(animation.serialize());
  94210. }
  94211. }
  94212. };
  94213. /**
  94214. * Static function used to serialized a specific entity
  94215. * @param entity defines the entity to serialize
  94216. * @param serializationObject defines the optional target obecjt where serialization data will be stored
  94217. * @returns a JSON compatible object representing the serialization of the entity
  94218. */
  94219. SerializationHelper.Serialize = function (entity, serializationObject) {
  94220. if (!serializationObject) {
  94221. serializationObject = {};
  94222. }
  94223. // Tags
  94224. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  94225. serializationObject.tags = _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].GetTags(entity);
  94226. }
  94227. var serializedProperties = getMergedStore(entity);
  94228. // Properties
  94229. for (var property in serializedProperties) {
  94230. var propertyDescriptor = serializedProperties[property];
  94231. var targetPropertyName = propertyDescriptor.sourceName || property;
  94232. var propertyType = propertyDescriptor.type;
  94233. var sourceProperty = entity[property];
  94234. if (sourceProperty !== undefined && sourceProperty !== null) {
  94235. switch (propertyType) {
  94236. case 0: // Value
  94237. serializationObject[targetPropertyName] = sourceProperty;
  94238. break;
  94239. case 1: // Texture
  94240. serializationObject[targetPropertyName] = sourceProperty.serialize();
  94241. break;
  94242. case 2: // Color3
  94243. serializationObject[targetPropertyName] = sourceProperty.asArray();
  94244. break;
  94245. case 3: // FresnelParameters
  94246. serializationObject[targetPropertyName] = sourceProperty.serialize();
  94247. break;
  94248. case 4: // Vector2
  94249. serializationObject[targetPropertyName] = sourceProperty.asArray();
  94250. break;
  94251. case 5: // Vector3
  94252. serializationObject[targetPropertyName] = sourceProperty.asArray();
  94253. break;
  94254. case 6: // Mesh reference
  94255. serializationObject[targetPropertyName] = sourceProperty.id;
  94256. break;
  94257. case 7: // Color Curves
  94258. serializationObject[targetPropertyName] = sourceProperty.serialize();
  94259. break;
  94260. case 8: // Color 4
  94261. serializationObject[targetPropertyName] = sourceProperty.asArray();
  94262. break;
  94263. case 9: // Image Processing
  94264. serializationObject[targetPropertyName] = sourceProperty.serialize();
  94265. break;
  94266. case 10: // Quaternion
  94267. serializationObject[targetPropertyName] = sourceProperty.asArray();
  94268. break;
  94269. case 11: // Camera reference
  94270. serializationObject[targetPropertyName] = sourceProperty.id;
  94271. break;
  94272. }
  94273. }
  94274. }
  94275. return serializationObject;
  94276. };
  94277. /**
  94278. * Creates a new entity from a serialization data object
  94279. * @param creationFunction defines a function used to instanciated the new entity
  94280. * @param source defines the source serialization data
  94281. * @param scene defines the hosting scene
  94282. * @param rootUrl defines the root url for resources
  94283. * @returns a new entity
  94284. */
  94285. SerializationHelper.Parse = function (creationFunction, source, scene, rootUrl) {
  94286. if (rootUrl === void 0) { rootUrl = null; }
  94287. var destination = creationFunction();
  94288. if (!rootUrl) {
  94289. rootUrl = "";
  94290. }
  94291. // Tags
  94292. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"]) {
  94293. _Misc_tags__WEBPACK_IMPORTED_MODULE_0__["Tags"].AddTagsTo(destination, source.tags);
  94294. }
  94295. var classStore = getMergedStore(destination);
  94296. // Properties
  94297. for (var property in classStore) {
  94298. var propertyDescriptor = classStore[property];
  94299. var sourceProperty = source[propertyDescriptor.sourceName || property];
  94300. var propertyType = propertyDescriptor.type;
  94301. if (sourceProperty !== undefined && sourceProperty !== null) {
  94302. var dest = destination;
  94303. switch (propertyType) {
  94304. case 0: // Value
  94305. dest[property] = sourceProperty;
  94306. break;
  94307. case 1: // Texture
  94308. if (scene) {
  94309. dest[property] = SerializationHelper._TextureParser(sourceProperty, scene, rootUrl);
  94310. }
  94311. break;
  94312. case 2: // Color3
  94313. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color3"].FromArray(sourceProperty);
  94314. break;
  94315. case 3: // FresnelParameters
  94316. dest[property] = SerializationHelper._FresnelParametersParser(sourceProperty);
  94317. break;
  94318. case 4: // Vector2
  94319. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"].FromArray(sourceProperty);
  94320. break;
  94321. case 5: // Vector3
  94322. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(sourceProperty);
  94323. break;
  94324. case 6: // Mesh reference
  94325. if (scene) {
  94326. dest[property] = scene.getLastMeshByID(sourceProperty);
  94327. }
  94328. break;
  94329. case 7: // Color Curves
  94330. dest[property] = SerializationHelper._ColorCurvesParser(sourceProperty);
  94331. break;
  94332. case 8: // Color 4
  94333. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].FromArray(sourceProperty);
  94334. break;
  94335. case 9: // Image Processing
  94336. dest[property] = SerializationHelper._ImageProcessingConfigurationParser(sourceProperty);
  94337. break;
  94338. case 10: // Quaternion
  94339. dest[property] = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].FromArray(sourceProperty);
  94340. break;
  94341. case 11: // Camera reference
  94342. if (scene) {
  94343. dest[property] = scene.getCameraByID(sourceProperty);
  94344. }
  94345. break;
  94346. }
  94347. }
  94348. }
  94349. return destination;
  94350. };
  94351. /**
  94352. * Clones an object
  94353. * @param creationFunction defines the function used to instanciate the new object
  94354. * @param source defines the source object
  94355. * @returns the cloned object
  94356. */
  94357. SerializationHelper.Clone = function (creationFunction, source) {
  94358. return _copySource(creationFunction, source, false);
  94359. };
  94360. /**
  94361. * Instanciates a new object based on a source one (some data will be shared between both object)
  94362. * @param creationFunction defines the function used to instanciate the new object
  94363. * @param source defines the source object
  94364. * @returns the new object
  94365. */
  94366. SerializationHelper.Instanciate = function (creationFunction, source) {
  94367. return _copySource(creationFunction, source, true);
  94368. };
  94369. /** hidden */
  94370. SerializationHelper._ImageProcessingConfigurationParser = function (sourceProperty) {
  94371. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ImageProcessingConfiguration");
  94372. };
  94373. /** hidden */
  94374. SerializationHelper._FresnelParametersParser = function (sourceProperty) {
  94375. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("FresnelParameters");
  94376. };
  94377. /** hidden */
  94378. SerializationHelper._ColorCurvesParser = function (sourceProperty) {
  94379. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("ColorCurves");
  94380. };
  94381. /** hidden */
  94382. SerializationHelper._TextureParser = function (sourceProperty, scene, rootUrl) {
  94383. throw _devTools__WEBPACK_IMPORTED_MODULE_2__["_DevTools"].WarnImport("Texture");
  94384. };
  94385. return SerializationHelper;
  94386. }());
  94387. /***/ }),
  94388. /***/ "./Misc/deepCopier.ts":
  94389. /*!****************************!*\
  94390. !*** ./Misc/deepCopier.ts ***!
  94391. \****************************/
  94392. /*! exports provided: DeepCopier */
  94393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94394. "use strict";
  94395. __webpack_require__.r(__webpack_exports__);
  94396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return DeepCopier; });
  94397. var cloneValue = function (source, destinationObject) {
  94398. if (!source) {
  94399. return null;
  94400. }
  94401. if (source.getClassName && source.getClassName() === "Mesh") {
  94402. return null;
  94403. }
  94404. if (source.getClassName && source.getClassName() === "SubMesh") {
  94405. return source.clone(destinationObject);
  94406. }
  94407. else if (source.clone) {
  94408. return source.clone();
  94409. }
  94410. return null;
  94411. };
  94412. /**
  94413. * Class containing a set of static utilities functions for deep copy.
  94414. */
  94415. var DeepCopier = /** @class */ (function () {
  94416. function DeepCopier() {
  94417. }
  94418. /**
  94419. * Tries to copy an object by duplicating every property
  94420. * @param source defines the source object
  94421. * @param destination defines the target object
  94422. * @param doNotCopyList defines a list of properties to avoid
  94423. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  94424. */
  94425. DeepCopier.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  94426. for (var prop in source) {
  94427. if (prop[0] === "_" && (!mustCopyList || mustCopyList.indexOf(prop) === -1)) {
  94428. continue;
  94429. }
  94430. if (doNotCopyList && doNotCopyList.indexOf(prop) !== -1) {
  94431. continue;
  94432. }
  94433. var sourceValue = source[prop];
  94434. var typeOfSourceValue = typeof sourceValue;
  94435. if (typeOfSourceValue === "function") {
  94436. continue;
  94437. }
  94438. try {
  94439. if (typeOfSourceValue === "object") {
  94440. if (sourceValue instanceof Array) {
  94441. destination[prop] = [];
  94442. if (sourceValue.length > 0) {
  94443. if (typeof sourceValue[0] == "object") {
  94444. for (var index = 0; index < sourceValue.length; index++) {
  94445. var clonedValue = cloneValue(sourceValue[index], destination);
  94446. if (destination[prop].indexOf(clonedValue) === -1) { // Test if auto inject was not done
  94447. destination[prop].push(clonedValue);
  94448. }
  94449. }
  94450. }
  94451. else {
  94452. destination[prop] = sourceValue.slice(0);
  94453. }
  94454. }
  94455. }
  94456. else {
  94457. destination[prop] = cloneValue(sourceValue, destination);
  94458. }
  94459. }
  94460. else {
  94461. destination[prop] = sourceValue;
  94462. }
  94463. }
  94464. catch (e) {
  94465. // Just ignore error (it could be because of a read-only property)
  94466. }
  94467. }
  94468. };
  94469. return DeepCopier;
  94470. }());
  94471. /***/ }),
  94472. /***/ "./Misc/deferred.ts":
  94473. /*!**************************!*\
  94474. !*** ./Misc/deferred.ts ***!
  94475. \**************************/
  94476. /*! exports provided: Deferred */
  94477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94478. "use strict";
  94479. __webpack_require__.r(__webpack_exports__);
  94480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return Deferred; });
  94481. /**
  94482. * Wrapper class for promise with external resolve and reject.
  94483. */
  94484. var Deferred = /** @class */ (function () {
  94485. /**
  94486. * Constructor for this deferred object.
  94487. */
  94488. function Deferred() {
  94489. var _this = this;
  94490. this.promise = new Promise(function (resolve, reject) {
  94491. _this._resolve = resolve;
  94492. _this._reject = reject;
  94493. });
  94494. }
  94495. Object.defineProperty(Deferred.prototype, "resolve", {
  94496. /**
  94497. * The resolve method of the promise associated with this deferred object.
  94498. */
  94499. get: function () {
  94500. return this._resolve;
  94501. },
  94502. enumerable: true,
  94503. configurable: true
  94504. });
  94505. Object.defineProperty(Deferred.prototype, "reject", {
  94506. /**
  94507. * The reject method of the promise associated with this deferred object.
  94508. */
  94509. get: function () {
  94510. return this._reject;
  94511. },
  94512. enumerable: true,
  94513. configurable: true
  94514. });
  94515. return Deferred;
  94516. }());
  94517. /***/ }),
  94518. /***/ "./Misc/devTools.ts":
  94519. /*!**************************!*\
  94520. !*** ./Misc/devTools.ts ***!
  94521. \**************************/
  94522. /*! exports provided: _DevTools */
  94523. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94524. "use strict";
  94525. __webpack_require__.r(__webpack_exports__);
  94526. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DevTools", function() { return _DevTools; });
  94527. /** @hidden */
  94528. var _DevTools = /** @class */ (function () {
  94529. function _DevTools() {
  94530. }
  94531. _DevTools.WarnImport = function (name) {
  94532. return name + " needs to be imported before as it contains a side-effect required by your code.";
  94533. };
  94534. return _DevTools;
  94535. }());
  94536. /***/ }),
  94537. /***/ "./Misc/domManagement.ts":
  94538. /*!*******************************!*\
  94539. !*** ./Misc/domManagement.ts ***!
  94540. \*******************************/
  94541. /*! exports provided: DomManagement */
  94542. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94543. "use strict";
  94544. __webpack_require__.r(__webpack_exports__);
  94545. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DomManagement", function() { return DomManagement; });
  94546. /**
  94547. * Sets of helpers dealing with the DOM and some of the recurrent functions needed in
  94548. * Babylon.js
  94549. */
  94550. var DomManagement = /** @class */ (function () {
  94551. function DomManagement() {
  94552. }
  94553. /**
  94554. * Checks if the window object exists
  94555. * @returns true if the window object exists
  94556. */
  94557. DomManagement.IsWindowObjectExist = function () {
  94558. return (typeof window) !== "undefined";
  94559. };
  94560. /**
  94561. * Extracts text content from a DOM element hierarchy
  94562. * @param element defines the root element
  94563. * @returns a string
  94564. */
  94565. DomManagement.GetDOMTextContent = function (element) {
  94566. var result = "";
  94567. var child = element.firstChild;
  94568. while (child) {
  94569. if (child.nodeType === 3) {
  94570. result += child.textContent;
  94571. }
  94572. child = (child.nextSibling);
  94573. }
  94574. return result;
  94575. };
  94576. return DomManagement;
  94577. }());
  94578. /***/ }),
  94579. /***/ "./Misc/environmentTextureTools.ts":
  94580. /*!*****************************************!*\
  94581. !*** ./Misc/environmentTextureTools.ts ***!
  94582. \*****************************************/
  94583. /*! exports provided: EnvironmentTextureTools */
  94584. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  94585. "use strict";
  94586. __webpack_require__.r(__webpack_exports__);
  94587. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return EnvironmentTextureTools; });
  94588. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  94589. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  94590. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  94591. /* harmony import */ var _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/sphericalPolynomial */ "./Maths/sphericalPolynomial.ts");
  94592. /* harmony import */ var _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/internalTexture */ "./Materials/Textures/internalTexture.ts");
  94593. /* harmony import */ var _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/Textures/baseTexture */ "./Materials/Textures/baseTexture.ts");
  94594. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  94595. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  94596. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  94597. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  94598. /* harmony import */ var _Shaders_rgbdEncode_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/rgbdEncode.fragment */ "./Shaders/rgbdEncode.fragment.ts");
  94599. /* harmony import */ var _Shaders_rgbdDecode_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/rgbdDecode.fragment */ "./Shaders/rgbdDecode.fragment.ts");
  94600. /**
  94601. * Sets of helpers addressing the serialization and deserialization of environment texture
  94602. * stored in a BabylonJS env file.
  94603. * Those files are usually stored as .env files.
  94604. */
  94605. var EnvironmentTextureTools = /** @class */ (function () {
  94606. function EnvironmentTextureTools() {
  94607. }
  94608. /**
  94609. * Gets the environment info from an env file.
  94610. * @param data The array buffer containing the .env bytes.
  94611. * @returns the environment file info (the json header) if successfully parsed.
  94612. */
  94613. EnvironmentTextureTools.GetEnvInfo = function (data) {
  94614. var dataView = new DataView(data);
  94615. var pos = 0;
  94616. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  94617. if (dataView.getUint8(pos++) !== EnvironmentTextureTools._MagicBytes[i]) {
  94618. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Error('Not a babylon environment map');
  94619. return null;
  94620. }
  94621. }
  94622. // Read json manifest - collect characters up to null terminator
  94623. var manifestString = '';
  94624. var charCode = 0x00;
  94625. while ((charCode = dataView.getUint8(pos++))) {
  94626. manifestString += String.fromCharCode(charCode);
  94627. }
  94628. var manifest = JSON.parse(manifestString);
  94629. if (manifest.specular) {
  94630. // Extend the header with the position of the payload.
  94631. manifest.specular.specularDataPosition = pos;
  94632. // Fallback to 0.8 exactly if lodGenerationScale is not defined for backward compatibility.
  94633. manifest.specular.lodGenerationScale = manifest.specular.lodGenerationScale || 0.8;
  94634. }
  94635. return manifest;
  94636. };
  94637. /**
  94638. * Creates an environment texture from a loaded cube texture.
  94639. * @param texture defines the cube texture to convert in env file
  94640. * @return a promise containing the environment data if succesfull.
  94641. */
  94642. EnvironmentTextureTools.CreateEnvTextureAsync = function (texture) {
  94643. var _this = this;
  94644. var internalTexture = texture.getInternalTexture();
  94645. if (!internalTexture) {
  94646. return Promise.reject("The cube texture is invalid.");
  94647. }
  94648. if (!texture._prefiltered) {
  94649. return Promise.reject("The cube texture is invalid (not prefiltered).");
  94650. }
  94651. var engine = internalTexture.getEngine();
  94652. if (engine && engine.premultipliedAlpha) {
  94653. return Promise.reject("Env texture can only be created when the engine is created with the premultipliedAlpha option set to false.");
  94654. }
  94655. if (texture.textureType === _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT) {
  94656. return Promise.reject("The cube texture should allow HDR (Full Float or Half Float).");
  94657. }
  94658. var canvas = engine.getRenderingCanvas();
  94659. if (!canvas) {
  94660. return Promise.reject("Env texture can only be created when the engine is associated to a canvas.");
  94661. }
  94662. var textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94663. if (!engine.getCaps().textureFloatRender) {
  94664. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94665. if (!engine.getCaps().textureHalfFloatRender) {
  94666. return Promise.reject("Env texture can only be created when the browser supports half float or full float rendering.");
  94667. }
  94668. }
  94669. var cubeWidth = internalTexture.width;
  94670. var hostingScene = new _scene__WEBPACK_IMPORTED_MODULE_7__["Scene"](engine);
  94671. var specularTextures = {};
  94672. var promises = [];
  94673. // Read and collect all mipmaps data from the cube.
  94674. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(internalTexture.width);
  94675. mipmapsCount = Math.round(mipmapsCount);
  94676. var _loop_1 = function (i) {
  94677. var faceWidth = Math.pow(2, mipmapsCount - i);
  94678. var _loop_2 = function (face) {
  94679. var data = texture.readPixels(face, i);
  94680. // Creates a temp texture with the face data.
  94681. 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);
  94682. // And rgbdEncode them.
  94683. var promise = new Promise(function (resolve, reject) {
  94684. 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);
  94685. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94686. rgbdPostProcess.onApply = function (effect) {
  94687. effect._bindTexture("textureSampler", tempTexture);
  94688. };
  94689. // As the process needs to happen on the main canvas, keep track of the current size
  94690. var currentW = engine.getRenderWidth();
  94691. var currentH = engine.getRenderHeight();
  94692. // Set the desired size for the texture
  94693. engine.setSize(faceWidth, faceWidth);
  94694. hostingScene.postProcessManager.directRender([rgbdPostProcess], null);
  94695. // Reading datas from WebGL
  94696. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].ToBlob(canvas, function (blob) {
  94697. var fileReader = new FileReader();
  94698. fileReader.onload = function (event) {
  94699. var arrayBuffer = event.target.result;
  94700. specularTextures[i * 6 + face] = arrayBuffer;
  94701. resolve();
  94702. };
  94703. fileReader.readAsArrayBuffer(blob);
  94704. });
  94705. // Reapply the previous canvas size
  94706. engine.setSize(currentW, currentH);
  94707. });
  94708. });
  94709. promises.push(promise);
  94710. };
  94711. // All faces of the cube.
  94712. for (var face = 0; face < 6; face++) {
  94713. _loop_2(face);
  94714. }
  94715. };
  94716. for (var i = 0; i <= mipmapsCount; i++) {
  94717. _loop_1(i);
  94718. }
  94719. // Once all the textures haves been collected as RGBD stored in PNGs
  94720. return Promise.all(promises).then(function () {
  94721. // We can delete the hosting scene keeping track of all the creation objects
  94722. hostingScene.dispose();
  94723. // Creates the json header for the env texture
  94724. var info = {
  94725. version: 1,
  94726. width: cubeWidth,
  94727. irradiance: _this._CreateEnvTextureIrradiance(texture),
  94728. specular: {
  94729. mipmaps: [],
  94730. lodGenerationScale: texture.lodGenerationScale
  94731. }
  94732. };
  94733. // Sets the specular image data information
  94734. var position = 0;
  94735. for (var i = 0; i <= mipmapsCount; i++) {
  94736. for (var face = 0; face < 6; face++) {
  94737. var byteLength = specularTextures[i * 6 + face].byteLength;
  94738. info.specular.mipmaps.push({
  94739. length: byteLength,
  94740. position: position
  94741. });
  94742. position += byteLength;
  94743. }
  94744. }
  94745. // Encode the JSON as an array buffer
  94746. var infoString = JSON.stringify(info);
  94747. var infoBuffer = new ArrayBuffer(infoString.length + 1);
  94748. var infoView = new Uint8Array(infoBuffer); // Limited to ascii subset matching unicode.
  94749. for (var i = 0, strLen = infoString.length; i < strLen; i++) {
  94750. infoView[i] = infoString.charCodeAt(i);
  94751. }
  94752. // Ends up with a null terminator for easier parsing
  94753. infoView[infoString.length] = 0x00;
  94754. // Computes the final required size and creates the storage
  94755. var totalSize = EnvironmentTextureTools._MagicBytes.length + position + infoBuffer.byteLength;
  94756. var finalBuffer = new ArrayBuffer(totalSize);
  94757. var finalBufferView = new Uint8Array(finalBuffer);
  94758. var dataView = new DataView(finalBuffer);
  94759. // Copy the magic bytes identifying the file in
  94760. var pos = 0;
  94761. for (var i = 0; i < EnvironmentTextureTools._MagicBytes.length; i++) {
  94762. dataView.setUint8(pos++, EnvironmentTextureTools._MagicBytes[i]);
  94763. }
  94764. // Add the json info
  94765. finalBufferView.set(new Uint8Array(infoBuffer), pos);
  94766. pos += infoBuffer.byteLength;
  94767. // Finally inserts the texture data
  94768. for (var i = 0; i <= mipmapsCount; i++) {
  94769. for (var face = 0; face < 6; face++) {
  94770. var dataBuffer = specularTextures[i * 6 + face];
  94771. finalBufferView.set(new Uint8Array(dataBuffer), pos);
  94772. pos += dataBuffer.byteLength;
  94773. }
  94774. }
  94775. // Voila
  94776. return finalBuffer;
  94777. });
  94778. };
  94779. /**
  94780. * Creates a JSON representation of the spherical data.
  94781. * @param texture defines the texture containing the polynomials
  94782. * @return the JSON representation of the spherical info
  94783. */
  94784. EnvironmentTextureTools._CreateEnvTextureIrradiance = function (texture) {
  94785. var polynmials = texture.sphericalPolynomial;
  94786. if (polynmials == null) {
  94787. return null;
  94788. }
  94789. return {
  94790. x: [polynmials.x.x, polynmials.x.y, polynmials.x.z],
  94791. y: [polynmials.y.x, polynmials.y.y, polynmials.y.z],
  94792. z: [polynmials.z.x, polynmials.z.y, polynmials.z.z],
  94793. xx: [polynmials.xx.x, polynmials.xx.y, polynmials.xx.z],
  94794. yy: [polynmials.yy.x, polynmials.yy.y, polynmials.yy.z],
  94795. zz: [polynmials.zz.x, polynmials.zz.y, polynmials.zz.z],
  94796. yz: [polynmials.yz.x, polynmials.yz.y, polynmials.yz.z],
  94797. zx: [polynmials.zx.x, polynmials.zx.y, polynmials.zx.z],
  94798. xy: [polynmials.xy.x, polynmials.xy.y, polynmials.xy.z]
  94799. };
  94800. };
  94801. /**
  94802. * Uploads the texture info contained in the env file to the GPU.
  94803. * @param texture defines the internal texture to upload to
  94804. * @param arrayBuffer defines the buffer cotaining the data to load
  94805. * @param info defines the texture info retrieved through the GetEnvInfo method
  94806. * @returns a promise
  94807. */
  94808. EnvironmentTextureTools.UploadEnvLevelsAsync = function (texture, arrayBuffer, info) {
  94809. if (info.version !== 1) {
  94810. throw new Error("Unsupported babylon environment map version \"" + info.version + "\"");
  94811. }
  94812. var specularInfo = info.specular;
  94813. if (!specularInfo) {
  94814. // Nothing else parsed so far
  94815. return Promise.resolve();
  94816. }
  94817. // Double checks the enclosed info
  94818. var mipmapsCount = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(info.width);
  94819. mipmapsCount = Math.round(mipmapsCount) + 1;
  94820. if (specularInfo.mipmaps.length !== 6 * mipmapsCount) {
  94821. throw new Error("Unsupported specular mipmaps number \"" + specularInfo.mipmaps.length + "\"");
  94822. }
  94823. texture._lodGenerationScale = specularInfo.lodGenerationScale;
  94824. var imageData = new Array(mipmapsCount);
  94825. for (var i = 0; i < mipmapsCount; i++) {
  94826. imageData[i] = new Array(6);
  94827. for (var face = 0; face < 6; face++) {
  94828. var imageInfo = specularInfo.mipmaps[i * 6 + face];
  94829. imageData[i][face] = new Uint8Array(arrayBuffer, specularInfo.specularDataPosition + imageInfo.position, imageInfo.length);
  94830. }
  94831. }
  94832. return EnvironmentTextureTools.UploadLevelsAsync(texture, imageData);
  94833. };
  94834. /**
  94835. * Uploads the levels of image data to the GPU.
  94836. * @param texture defines the internal texture to upload to
  94837. * @param imageData defines the array buffer views of image data [mipmap][face]
  94838. * @returns a promise
  94839. */
  94840. EnvironmentTextureTools.UploadLevelsAsync = function (texture, imageData) {
  94841. if (!_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsExponentOfTwo(texture.width)) {
  94842. throw new Error("Texture size must be a power of two");
  94843. }
  94844. var mipmapsCount = Math.round(_Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Log2(texture.width)) + 1;
  94845. // Gets everything ready.
  94846. var engine = texture.getEngine();
  94847. var expandTexture = false;
  94848. var generateNonLODTextures = false;
  94849. var rgbdPostProcess = null;
  94850. var cubeRtt = null;
  94851. var lodTextures = null;
  94852. var caps = engine.getCaps();
  94853. texture.format = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA;
  94854. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  94855. texture.generateMipMaps = true;
  94856. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE, texture);
  94857. // Add extra process if texture lod is not supported
  94858. if (!caps.textureLOD) {
  94859. expandTexture = false;
  94860. generateNonLODTextures = true;
  94861. lodTextures = {};
  94862. }
  94863. // in webgl 1 there are no ways to either render or copy lod level information for float textures.
  94864. else if (engine.webGLVersion < 2) {
  94865. expandTexture = false;
  94866. }
  94867. // If half float available we can uncompress the texture
  94868. else if (caps.textureHalfFloatRender && caps.textureHalfFloatLinearFiltering) {
  94869. expandTexture = true;
  94870. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT;
  94871. }
  94872. // If full float available we can uncompress the texture
  94873. else if (caps.textureFloatRender && caps.textureFloatLinearFiltering) {
  94874. expandTexture = true;
  94875. texture.type = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT;
  94876. }
  94877. // Expand the texture if possible
  94878. if (expandTexture) {
  94879. // Simply run through the decode PP
  94880. 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);
  94881. texture._isRGBD = false;
  94882. texture.invertY = false;
  94883. cubeRtt = engine.createRenderTargetCubeTexture(texture.width, {
  94884. generateDepthBuffer: false,
  94885. generateMipMaps: true,
  94886. generateStencilBuffer: false,
  94887. samplingMode: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE,
  94888. type: texture.type,
  94889. format: _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTUREFORMAT_RGBA
  94890. });
  94891. }
  94892. else {
  94893. texture._isRGBD = true;
  94894. texture.invertY = true;
  94895. // In case of missing support, applies the same patch than DDS files.
  94896. if (generateNonLODTextures) {
  94897. var mipSlices = 3;
  94898. var scale = texture._lodGenerationScale;
  94899. var offset = texture._lodGenerationOffset;
  94900. for (var i = 0; i < mipSlices; i++) {
  94901. //compute LOD from even spacing in smoothness (matching shader calculation)
  94902. var smoothness = i / (mipSlices - 1);
  94903. var roughness = 1 - smoothness;
  94904. var minLODIndex = offset; // roughness = 0
  94905. var maxLODIndex = (mipmapsCount - 1) * scale + offset; // roughness = 1 (mipmaps start from 0)
  94906. var lodIndex = minLODIndex + (maxLODIndex - minLODIndex) * roughness;
  94907. var mipmapIndex = Math.round(Math.min(Math.max(lodIndex, 0), maxLODIndex));
  94908. var glTextureFromLod = new _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"](engine, _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_TEMP);
  94909. glTextureFromLod.isCube = true;
  94910. glTextureFromLod.invertY = true;
  94911. glTextureFromLod.generateMipMaps = false;
  94912. engine.updateTextureSamplingMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_LINEAR_LINEAR, glTextureFromLod);
  94913. // Wrap in a base texture for easy binding.
  94914. var lodTexture = new _Materials_Textures_baseTexture__WEBPACK_IMPORTED_MODULE_5__["BaseTexture"](null);
  94915. lodTexture.isCube = true;
  94916. lodTexture._texture = glTextureFromLod;
  94917. lodTextures[mipmapIndex] = lodTexture;
  94918. switch (i) {
  94919. case 0:
  94920. texture._lodTextureLow = lodTexture;
  94921. break;
  94922. case 1:
  94923. texture._lodTextureMid = lodTexture;
  94924. break;
  94925. case 2:
  94926. texture._lodTextureHigh = lodTexture;
  94927. break;
  94928. }
  94929. }
  94930. }
  94931. }
  94932. var promises = [];
  94933. var _loop_3 = function (i) {
  94934. var _loop_4 = function (face) {
  94935. // Constructs an image element from image data
  94936. var bytes = imageData[i][face];
  94937. var blob = new Blob([bytes], { type: 'image/png' });
  94938. var url = URL.createObjectURL(blob);
  94939. var image = new Image();
  94940. image.src = url;
  94941. // Enqueue promise to upload to the texture.
  94942. var promise = new Promise(function (resolve, reject) {
  94943. image.onload = function () {
  94944. if (expandTexture) {
  94945. var tempTexture_1 = engine.createTexture(null, true, true, null, _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE, null, function (message) {
  94946. reject(message);
  94947. }, image);
  94948. rgbdPostProcess.getEffect().executeWhenCompiled(function () {
  94949. // Uncompress the data to a RTT
  94950. rgbdPostProcess.onApply = function (effect) {
  94951. effect._bindTexture("textureSampler", tempTexture_1);
  94952. effect.setFloat2("scale", 1, 1);
  94953. };
  94954. engine.scenes[0].postProcessManager.directRender([rgbdPostProcess], cubeRtt, true, face, i);
  94955. // Cleanup
  94956. engine.restoreDefaultFramebuffer();
  94957. tempTexture_1.dispose();
  94958. window.URL.revokeObjectURL(url);
  94959. resolve();
  94960. });
  94961. }
  94962. else {
  94963. engine._uploadImageToTexture(texture, image, face, i);
  94964. // Upload the face to the non lod texture support
  94965. if (generateNonLODTextures) {
  94966. var lodTexture = lodTextures[i];
  94967. if (lodTexture) {
  94968. engine._uploadImageToTexture(lodTexture._texture, image, face, 0);
  94969. }
  94970. }
  94971. resolve();
  94972. }
  94973. };
  94974. image.onerror = function (error) {
  94975. reject(error);
  94976. };
  94977. });
  94978. promises.push(promise);
  94979. };
  94980. // All faces
  94981. for (var face = 0; face < 6; face++) {
  94982. _loop_4(face);
  94983. }
  94984. };
  94985. // All mipmaps up to provided number of images
  94986. for (var i = 0; i < imageData.length; i++) {
  94987. _loop_3(i);
  94988. }
  94989. // Fill remaining mipmaps with black textures.
  94990. if (imageData.length < mipmapsCount) {
  94991. var data = void 0;
  94992. var size = Math.pow(2, mipmapsCount - 1 - imageData.length);
  94993. var dataLength = size * size * 4;
  94994. switch (texture.type) {
  94995. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_UNSIGNED_INT: {
  94996. data = new Uint8Array(dataLength);
  94997. break;
  94998. }
  94999. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_HALF_FLOAT: {
  95000. data = new Uint16Array(dataLength);
  95001. break;
  95002. }
  95003. case _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].TEXTURETYPE_FLOAT: {
  95004. data = new Float32Array(dataLength);
  95005. break;
  95006. }
  95007. }
  95008. for (var i = imageData.length; i < mipmapsCount; i++) {
  95009. for (var face = 0; face < 6; face++) {
  95010. engine._uploadArrayBufferViewToTexture(texture, data, face, i);
  95011. }
  95012. }
  95013. }
  95014. // Once all done, finishes the cleanup and return
  95015. return Promise.all(promises).then(function () {
  95016. // Release temp RTT.
  95017. if (cubeRtt) {
  95018. engine._releaseFramebufferObjects(cubeRtt);
  95019. cubeRtt._swapAndDie(texture);
  95020. }
  95021. // Release temp Post Process.
  95022. if (rgbdPostProcess) {
  95023. rgbdPostProcess.dispose();
  95024. }
  95025. // Flag internal texture as ready in case they are in use.
  95026. if (generateNonLODTextures) {
  95027. if (texture._lodTextureHigh && texture._lodTextureHigh._texture) {
  95028. texture._lodTextureHigh._texture.isReady = true;
  95029. }
  95030. if (texture._lodTextureMid && texture._lodTextureMid._texture) {
  95031. texture._lodTextureMid._texture.isReady = true;
  95032. }
  95033. if (texture._lodTextureLow && texture._lodTextureLow._texture) {
  95034. texture._lodTextureLow._texture.isReady = true;
  95035. }
  95036. }
  95037. });
  95038. };
  95039. /**
  95040. * Uploads spherical polynomials information to the texture.
  95041. * @param texture defines the texture we are trying to upload the information to
  95042. * @param info defines the environment texture info retrieved through the GetEnvInfo method
  95043. */
  95044. EnvironmentTextureTools.UploadEnvSpherical = function (texture, info) {
  95045. if (info.version !== 1) {
  95046. _Misc_logger__WEBPACK_IMPORTED_MODULE_9__["Logger"].Warn('Unsupported babylon environment map version "' + info.version + '"');
  95047. }
  95048. var irradianceInfo = info.irradiance;
  95049. if (!irradianceInfo) {
  95050. return;
  95051. }
  95052. var sp = new _Maths_sphericalPolynomial__WEBPACK_IMPORTED_MODULE_3__["SphericalPolynomial"]();
  95053. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.x, 0, sp.x);
  95054. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.y, 0, sp.y);
  95055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.z, 0, sp.z);
  95056. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xx, 0, sp.xx);
  95057. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yy, 0, sp.yy);
  95058. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zz, 0, sp.zz);
  95059. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.yz, 0, sp.yz);
  95060. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.zx, 0, sp.zx);
  95061. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(irradianceInfo.xy, 0, sp.xy);
  95062. texture._sphericalPolynomial = sp;
  95063. };
  95064. /** @hidden */
  95065. EnvironmentTextureTools._UpdateRGBDAsync = function (internalTexture, data, sphericalPolynomial, lodScale, lodOffset) {
  95066. internalTexture._dataSource = _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"].DATASOURCE_CUBERAW_RGBD;
  95067. internalTexture._bufferViewArrayArray = data;
  95068. internalTexture._lodGenerationScale = lodScale;
  95069. internalTexture._lodGenerationOffset = lodOffset;
  95070. internalTexture._sphericalPolynomial = sphericalPolynomial;
  95071. return EnvironmentTextureTools.UploadLevelsAsync(internalTexture, data).then(function () {
  95072. internalTexture.isReady = true;
  95073. });
  95074. };
  95075. /**
  95076. * Magic number identifying the env file.
  95077. */
  95078. EnvironmentTextureTools._MagicBytes = [0x86, 0x16, 0x87, 0x96, 0xf6, 0xd6, 0x96, 0x36];
  95079. return EnvironmentTextureTools;
  95080. }());
  95081. // References the dependencies.
  95082. _Materials_Textures_internalTexture__WEBPACK_IMPORTED_MODULE_4__["InternalTexture"]._UpdateRGBDAsync = EnvironmentTextureTools._UpdateRGBDAsync;
  95083. /***/ }),
  95084. /***/ "./Misc/filesInput.ts":
  95085. /*!****************************!*\
  95086. !*** ./Misc/filesInput.ts ***!
  95087. \****************************/
  95088. /*! exports provided: FilesInput */
  95089. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95090. "use strict";
  95091. __webpack_require__.r(__webpack_exports__);
  95092. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return FilesInput; });
  95093. /* harmony import */ var _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Loading/sceneLoader */ "./Loading/sceneLoader.ts");
  95094. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95095. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  95096. /**
  95097. * Class used to help managing file picking and drag'n'drop
  95098. */
  95099. var FilesInput = /** @class */ (function () {
  95100. /**
  95101. * Creates a new FilesInput
  95102. * @param engine defines the rendering engine
  95103. * @param scene defines the hosting scene
  95104. * @param sceneLoadedCallback callback called when scene is loaded
  95105. * @param progressCallback callback called to track progress
  95106. * @param additionalRenderLoopLogicCallback callback called to add user logic to the rendering loop
  95107. * @param textureLoadingCallback callback called when a texture is loading
  95108. * @param startingProcessingFilesCallback callback called when the system is about to process all files
  95109. * @param onReloadCallback callback called when a reload is requested
  95110. * @param errorCallback callback call if an error occurs
  95111. */
  95112. function FilesInput(engine, scene, sceneLoadedCallback, progressCallback, additionalRenderLoopLogicCallback, textureLoadingCallback, startingProcessingFilesCallback, onReloadCallback, errorCallback) {
  95113. /**
  95114. * Callback called when a file is processed
  95115. */
  95116. this.onProcessFileCallback = function () { return true; };
  95117. this._engine = engine;
  95118. this._currentScene = scene;
  95119. this._sceneLoadedCallback = sceneLoadedCallback;
  95120. this._progressCallback = progressCallback;
  95121. this._additionalRenderLoopLogicCallback = additionalRenderLoopLogicCallback;
  95122. this._textureLoadingCallback = textureLoadingCallback;
  95123. this._startingProcessingFilesCallback = startingProcessingFilesCallback;
  95124. this._onReloadCallback = onReloadCallback;
  95125. this._errorCallback = errorCallback;
  95126. }
  95127. Object.defineProperty(FilesInput, "FilesToLoad", {
  95128. /**
  95129. * List of files ready to be loaded
  95130. */
  95131. get: function () {
  95132. return _filesInputStore__WEBPACK_IMPORTED_MODULE_2__["FilesInputStore"].FilesToLoad;
  95133. },
  95134. enumerable: true,
  95135. configurable: true
  95136. });
  95137. /**
  95138. * Calls this function to listen to drag'n'drop events on a specific DOM element
  95139. * @param elementToMonitor defines the DOM element to track
  95140. */
  95141. FilesInput.prototype.monitorElementForDragNDrop = function (elementToMonitor) {
  95142. var _this = this;
  95143. if (elementToMonitor) {
  95144. this._elementToMonitor = elementToMonitor;
  95145. this._dragEnterHandler = function (e) { _this.drag(e); };
  95146. this._dragOverHandler = function (e) { _this.drag(e); };
  95147. this._dropHandler = function (e) { _this.drop(e); };
  95148. this._elementToMonitor.addEventListener("dragenter", this._dragEnterHandler, false);
  95149. this._elementToMonitor.addEventListener("dragover", this._dragOverHandler, false);
  95150. this._elementToMonitor.addEventListener("drop", this._dropHandler, false);
  95151. }
  95152. };
  95153. /**
  95154. * Release all associated resources
  95155. */
  95156. FilesInput.prototype.dispose = function () {
  95157. if (!this._elementToMonitor) {
  95158. return;
  95159. }
  95160. this._elementToMonitor.removeEventListener("dragenter", this._dragEnterHandler);
  95161. this._elementToMonitor.removeEventListener("dragover", this._dragOverHandler);
  95162. this._elementToMonitor.removeEventListener("drop", this._dropHandler);
  95163. };
  95164. FilesInput.prototype.renderFunction = function () {
  95165. if (this._additionalRenderLoopLogicCallback) {
  95166. this._additionalRenderLoopLogicCallback();
  95167. }
  95168. if (this._currentScene) {
  95169. if (this._textureLoadingCallback) {
  95170. var remaining = this._currentScene.getWaitingItemsCount();
  95171. if (remaining > 0) {
  95172. this._textureLoadingCallback(remaining);
  95173. }
  95174. }
  95175. this._currentScene.render();
  95176. }
  95177. };
  95178. FilesInput.prototype.drag = function (e) {
  95179. e.stopPropagation();
  95180. e.preventDefault();
  95181. };
  95182. FilesInput.prototype.drop = function (eventDrop) {
  95183. eventDrop.stopPropagation();
  95184. eventDrop.preventDefault();
  95185. this.loadFiles(eventDrop);
  95186. };
  95187. FilesInput.prototype._traverseFolder = function (folder, files, remaining, callback) {
  95188. var _this = this;
  95189. var reader = folder.createReader();
  95190. var relativePath = folder.fullPath.replace(/^\//, "").replace(/(.+?)\/?$/, "$1/");
  95191. reader.readEntries(function (entries) {
  95192. remaining.count += entries.length;
  95193. for (var _i = 0, entries_1 = entries; _i < entries_1.length; _i++) {
  95194. var entry = entries_1[_i];
  95195. if (entry.isFile) {
  95196. entry.file(function (file) {
  95197. file.correctName = relativePath + file.name;
  95198. files.push(file);
  95199. if (--remaining.count === 0) {
  95200. callback();
  95201. }
  95202. });
  95203. }
  95204. else if (entry.isDirectory) {
  95205. _this._traverseFolder(entry, files, remaining, callback);
  95206. }
  95207. }
  95208. if (--remaining.count) {
  95209. callback();
  95210. }
  95211. });
  95212. };
  95213. FilesInput.prototype._processFiles = function (files) {
  95214. for (var i = 0; i < files.length; i++) {
  95215. var name = files[i].correctName.toLowerCase();
  95216. var extension = name.split('.').pop();
  95217. if (!this.onProcessFileCallback(files[i], name, extension)) {
  95218. continue;
  95219. }
  95220. if ((extension === "babylon" || extension === "stl" || extension === "obj" || extension === "gltf" || extension === "glb")
  95221. && name.indexOf(".binary.babylon") === -1 && name.indexOf(".incremental.babylon") === -1) {
  95222. this._sceneFileToLoad = files[i];
  95223. }
  95224. FilesInput.FilesToLoad[name] = files[i];
  95225. }
  95226. };
  95227. /**
  95228. * Load files from a drop event
  95229. * @param event defines the drop event to use as source
  95230. */
  95231. FilesInput.prototype.loadFiles = function (event) {
  95232. var _this = this;
  95233. // Handling data transfer via drag'n'drop
  95234. if (event && event.dataTransfer && event.dataTransfer.files) {
  95235. this._filesToLoad = event.dataTransfer.files;
  95236. }
  95237. // Handling files from input files
  95238. if (event && event.target && event.target.files) {
  95239. this._filesToLoad = event.target.files;
  95240. }
  95241. if (!this._filesToLoad || this._filesToLoad.length === 0) {
  95242. return;
  95243. }
  95244. if (this._startingProcessingFilesCallback) {
  95245. this._startingProcessingFilesCallback(this._filesToLoad);
  95246. }
  95247. if (this._filesToLoad && this._filesToLoad.length > 0) {
  95248. var files_1 = new Array();
  95249. var folders = [];
  95250. var items = event.dataTransfer ? event.dataTransfer.items : null;
  95251. for (var i = 0; i < this._filesToLoad.length; i++) {
  95252. var fileToLoad = this._filesToLoad[i];
  95253. var name_1 = fileToLoad.name.toLowerCase();
  95254. var entry = void 0;
  95255. fileToLoad.correctName = name_1;
  95256. if (items) {
  95257. var item = items[i];
  95258. if (item.getAsEntry) {
  95259. entry = item.getAsEntry();
  95260. }
  95261. else if (item.webkitGetAsEntry) {
  95262. entry = item.webkitGetAsEntry();
  95263. }
  95264. }
  95265. if (!entry) {
  95266. files_1.push(fileToLoad);
  95267. }
  95268. else {
  95269. if (entry.isDirectory) {
  95270. folders.push(entry);
  95271. }
  95272. else {
  95273. files_1.push(fileToLoad);
  95274. }
  95275. }
  95276. }
  95277. if (folders.length === 0) {
  95278. this._processFiles(files_1);
  95279. this._processReload();
  95280. }
  95281. else {
  95282. var remaining = { count: folders.length };
  95283. for (var _i = 0, folders_1 = folders; _i < folders_1.length; _i++) {
  95284. var folder = folders_1[_i];
  95285. this._traverseFolder(folder, files_1, remaining, function () {
  95286. _this._processFiles(files_1);
  95287. if (remaining.count === 0) {
  95288. _this._processReload();
  95289. }
  95290. });
  95291. }
  95292. }
  95293. }
  95294. };
  95295. FilesInput.prototype._processReload = function () {
  95296. if (this._onReloadCallback) {
  95297. this._onReloadCallback(this._sceneFileToLoad);
  95298. }
  95299. else {
  95300. this.reload();
  95301. }
  95302. };
  95303. /**
  95304. * Reload the current scene from the loaded files
  95305. */
  95306. FilesInput.prototype.reload = function () {
  95307. var _this = this;
  95308. // If a scene file has been provided
  95309. if (this._sceneFileToLoad) {
  95310. if (this._currentScene) {
  95311. if (_Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].errorsCount > 0) {
  95312. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].ClearLogCache();
  95313. }
  95314. this._engine.stopRenderLoop();
  95315. }
  95316. _Loading_sceneLoader__WEBPACK_IMPORTED_MODULE_0__["SceneLoader"].LoadAsync("file:", this._sceneFileToLoad, this._engine, function (progress) {
  95317. if (_this._progressCallback) {
  95318. _this._progressCallback(progress);
  95319. }
  95320. }).then(function (scene) {
  95321. if (_this._currentScene) {
  95322. _this._currentScene.dispose();
  95323. }
  95324. _this._currentScene = scene;
  95325. if (_this._sceneLoadedCallback) {
  95326. _this._sceneLoadedCallback(_this._sceneFileToLoad, _this._currentScene);
  95327. }
  95328. // Wait for textures and shaders to be ready
  95329. _this._currentScene.executeWhenReady(function () {
  95330. _this._engine.runRenderLoop(function () {
  95331. _this.renderFunction();
  95332. });
  95333. });
  95334. }).catch(function (error) {
  95335. if (_this._errorCallback) {
  95336. _this._errorCallback(_this._sceneFileToLoad, _this._currentScene, error.message);
  95337. }
  95338. });
  95339. }
  95340. else {
  95341. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Please provide a valid .babylon file.");
  95342. }
  95343. };
  95344. return FilesInput;
  95345. }());
  95346. /***/ }),
  95347. /***/ "./Misc/filesInputStore.ts":
  95348. /*!*********************************!*\
  95349. !*** ./Misc/filesInputStore.ts ***!
  95350. \*********************************/
  95351. /*! exports provided: FilesInputStore */
  95352. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95353. "use strict";
  95354. __webpack_require__.r(__webpack_exports__);
  95355. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return FilesInputStore; });
  95356. /**
  95357. * Class used to help managing file picking and drag'n'drop
  95358. * File Storage
  95359. */
  95360. var FilesInputStore = /** @class */ (function () {
  95361. function FilesInputStore() {
  95362. }
  95363. /**
  95364. * List of files ready to be loaded
  95365. */
  95366. FilesInputStore.FilesToLoad = {};
  95367. return FilesInputStore;
  95368. }());
  95369. /***/ }),
  95370. /***/ "./Misc/index.ts":
  95371. /*!***********************!*\
  95372. !*** ./Misc/index.ts ***!
  95373. \***********************/
  95374. /*! exports provided: AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools */
  95375. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95376. "use strict";
  95377. __webpack_require__.r(__webpack_exports__);
  95378. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  95379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_0__["AndOrNotEvaluator"]; });
  95380. /* harmony import */ var _assetsManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./assetsManager */ "./Misc/assetsManager.ts");
  95381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetTaskState"]; });
  95382. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AbstractAssetTask"]; });
  95383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsProgressEvent"]; });
  95384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["MeshAssetTask"]; });
  95385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextFileAssetTask"]; });
  95386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["BinaryFileAssetTask"]; });
  95387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["ImageAssetTask"]; });
  95388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["TextureAssetTask"]; });
  95389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["CubeTextureAssetTask"]; });
  95390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["HDRCubeTextureAssetTask"]; });
  95391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _assetsManager__WEBPACK_IMPORTED_MODULE_1__["AssetsManager"]; });
  95392. /* harmony import */ var _dds__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./dds */ "./Misc/dds.ts");
  95393. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _dds__WEBPACK_IMPORTED_MODULE_2__["DDSTools"]; });
  95394. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  95395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["expandToProperty"]; });
  95396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serialize"]; });
  95397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsTexture"]; });
  95398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor3"]; });
  95399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsFresnelParameters"]; });
  95400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector2"]; });
  95401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsVector3"]; });
  95402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsMeshReference"]; });
  95403. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColorCurves"]; });
  95404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsColor4"]; });
  95405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsImageProcessingConfiguration"]; });
  95406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsQuaternion"]; });
  95407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["serializeAsCameraReference"]; });
  95408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"]; });
  95409. /* harmony import */ var _deferred__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./deferred */ "./Misc/deferred.ts");
  95410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _deferred__WEBPACK_IMPORTED_MODULE_4__["Deferred"]; });
  95411. /* harmony import */ var _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./environmentTextureTools */ "./Misc/environmentTextureTools.ts");
  95412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _environmentTextureTools__WEBPACK_IMPORTED_MODULE_5__["EnvironmentTextureTools"]; });
  95413. /* harmony import */ var _filesInput__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./filesInput */ "./Misc/filesInput.ts");
  95414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _filesInput__WEBPACK_IMPORTED_MODULE_6__["FilesInput"]; });
  95415. /* harmony import */ var _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HighDynamicRange/index */ "./Misc/HighDynamicRange/index.ts");
  95416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["CubeMapToSphericalPolynomialTools"]; });
  95417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["HDRTools"]; });
  95418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _HighDynamicRange_index__WEBPACK_IMPORTED_MODULE_7__["PanoramaToCubeMapTools"]; });
  95419. /* harmony import */ var _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./khronosTextureContainer */ "./Misc/khronosTextureContainer.ts");
  95420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _khronosTextureContainer__WEBPACK_IMPORTED_MODULE_8__["KhronosTextureContainer"]; });
  95421. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  95422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["EventState"]; });
  95423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observer"]; });
  95424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["MultiObserver"]; });
  95425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _observable__WEBPACK_IMPORTED_MODULE_9__["Observable"]; });
  95426. /* harmony import */ var _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./performanceMonitor */ "./Misc/performanceMonitor.ts");
  95427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["PerformanceMonitor"]; });
  95428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _performanceMonitor__WEBPACK_IMPORTED_MODULE_10__["RollingAverage"]; });
  95429. /* harmony import */ var _promise__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./promise */ "./Misc/promise.ts");
  95430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _promise__WEBPACK_IMPORTED_MODULE_11__["PromisePolyfill"]; });
  95431. /* harmony import */ var _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./sceneOptimizer */ "./Misc/sceneOptimizer.ts");
  95432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimization"]; });
  95433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["TextureOptimization"]; });
  95434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["HardwareScalingOptimization"]; });
  95435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ShadowsOptimization"]; });
  95436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["PostProcessesOptimization"]; });
  95437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["LensFlaresOptimization"]; });
  95438. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["CustomOptimization"]; });
  95439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["ParticlesOptimization"]; });
  95440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["RenderTargetsOptimization"]; });
  95441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["MergeMeshesOptimization"]; });
  95442. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizerOptions"]; });
  95443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _sceneOptimizer__WEBPACK_IMPORTED_MODULE_12__["SceneOptimizer"]; });
  95444. /* harmony import */ var _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./sceneSerializer */ "./Misc/sceneSerializer.ts");
  95445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _sceneSerializer__WEBPACK_IMPORTED_MODULE_13__["SceneSerializer"]; });
  95446. /* harmony import */ var _smartArray__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./smartArray */ "./Misc/smartArray.ts");
  95447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArray"]; });
  95448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _smartArray__WEBPACK_IMPORTED_MODULE_14__["SmartArrayNoDuplicate"]; });
  95449. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  95450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _stringDictionary__WEBPACK_IMPORTED_MODULE_15__["StringDictionary"]; });
  95451. /* harmony import */ var _tags__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./tags */ "./Misc/tags.ts");
  95452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _tags__WEBPACK_IMPORTED_MODULE_16__["Tags"]; });
  95453. /* harmony import */ var _textureTools__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./textureTools */ "./Misc/textureTools.ts");
  95454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _textureTools__WEBPACK_IMPORTED_MODULE_17__["TextureTools"]; });
  95455. /* harmony import */ var _tga__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./tga */ "./Misc/tga.ts");
  95456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _tga__WEBPACK_IMPORTED_MODULE_18__["TGATools"]; });
  95457. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  95458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["ColorGradient"]; });
  95459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Color3Gradient"]; });
  95460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["FactorGradient"]; });
  95461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["LoadFileError"]; });
  95462. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["RetryStrategy"]; });
  95463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["Tools"]; });
  95464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["PerfCounter"]; });
  95465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["className"]; });
  95466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _tools__WEBPACK_IMPORTED_MODULE_19__["AsyncLoop"]; });
  95467. /* harmony import */ var _videoRecorder__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./videoRecorder */ "./Misc/videoRecorder.ts");
  95468. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _videoRecorder__WEBPACK_IMPORTED_MODULE_20__["VideoRecorder"]; });
  95469. /* harmony import */ var _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./virtualJoystick */ "./Misc/virtualJoystick.ts");
  95470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["JoystickAxis"]; });
  95471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _virtualJoystick__WEBPACK_IMPORTED_MODULE_21__["VirtualJoystick"]; });
  95472. /* harmony import */ var _workerPool__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./workerPool */ "./Misc/workerPool.ts");
  95473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _workerPool__WEBPACK_IMPORTED_MODULE_22__["WorkerPool"]; });
  95474. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  95475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _logger__WEBPACK_IMPORTED_MODULE_23__["Logger"]; });
  95476. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  95477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _typeStore__WEBPACK_IMPORTED_MODULE_24__["_TypeStore"]; });
  95478. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  95479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _filesInputStore__WEBPACK_IMPORTED_MODULE_25__["FilesInputStore"]; });
  95480. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  95481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _deepCopier__WEBPACK_IMPORTED_MODULE_26__["DeepCopier"]; });
  95482. /* harmony import */ var _pivotTools__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./pivotTools */ "./Misc/pivotTools.ts");
  95483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _pivotTools__WEBPACK_IMPORTED_MODULE_27__["PivotTools"]; });
  95484. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  95485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _precisionDate__WEBPACK_IMPORTED_MODULE_28__["PrecisionDate"]; });
  95486. /* harmony import */ var _screenshotTools__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./screenshotTools */ "./Misc/screenshotTools.ts");
  95487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _screenshotTools__WEBPACK_IMPORTED_MODULE_29__["ScreenshotTools"]; });
  95488. /* empty/unused harmony star reexport */
  95489. /***/ }),
  95490. /***/ "./Misc/khronosTextureContainer.ts":
  95491. /*!*****************************************!*\
  95492. !*** ./Misc/khronosTextureContainer.ts ***!
  95493. \*****************************************/
  95494. /*! exports provided: KhronosTextureContainer */
  95495. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95496. "use strict";
  95497. __webpack_require__.r(__webpack_exports__);
  95498. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return KhronosTextureContainer; });
  95499. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  95500. /**
  95501. * for description see https://www.khronos.org/opengles/sdk/tools/KTX/
  95502. * for file layout see https://www.khronos.org/opengles/sdk/tools/KTX/file_format_spec/
  95503. */
  95504. var KhronosTextureContainer = /** @class */ (function () {
  95505. /**
  95506. * Creates a new KhronosTextureContainer
  95507. * @param arrayBuffer contents of the KTX container file
  95508. * @param facesExpected should be either 1 or 6, based whether a cube texture or or
  95509. * @param threeDExpected provision for indicating that data should be a 3D texture, not implemented
  95510. * @param textureArrayExpected provision for indicating that data should be a texture array, not implemented
  95511. */
  95512. function KhronosTextureContainer(
  95513. /** contents of the KTX container file */
  95514. arrayBuffer, facesExpected, threeDExpected, textureArrayExpected) {
  95515. this.arrayBuffer = arrayBuffer;
  95516. /**
  95517. * If the container has been made invalid (eg. constructor failed to correctly load array buffer)
  95518. */
  95519. this.isInvalid = false;
  95520. // Test that it is a ktx formatted file, based on the first 12 bytes, character representation is:
  95521. // '�', 'K', 'T', 'X', ' ', '1', '1', '�', '\r', '\n', '\x1A', '\n'
  95522. // 0xAB, 0x4B, 0x54, 0x58, 0x20, 0x31, 0x31, 0xBB, 0x0D, 0x0A, 0x1A, 0x0A
  95523. var identifier = new Uint8Array(this.arrayBuffer, 0, 12);
  95524. if (identifier[0] !== 0xAB || identifier[1] !== 0x4B || identifier[2] !== 0x54 || identifier[3] !== 0x58 || identifier[4] !== 0x20 || identifier[5] !== 0x31 ||
  95525. identifier[6] !== 0x31 || identifier[7] !== 0xBB || identifier[8] !== 0x0D || identifier[9] !== 0x0A || identifier[10] !== 0x1A || identifier[11] !== 0x0A) {
  95526. this.isInvalid = true;
  95527. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture missing KTX identifier");
  95528. return;
  95529. }
  95530. // load the reset of the header in native 32 bit uint
  95531. var dataSize = Uint32Array.BYTES_PER_ELEMENT;
  95532. var headerDataView = new DataView(this.arrayBuffer, 12, 13 * dataSize);
  95533. var endianness = headerDataView.getUint32(0, true);
  95534. var littleEndian = endianness === 0x04030201;
  95535. this.glType = headerDataView.getUint32(1 * dataSize, littleEndian); // must be 0 for compressed textures
  95536. this.glTypeSize = headerDataView.getUint32(2 * dataSize, littleEndian); // must be 1 for compressed textures
  95537. this.glFormat = headerDataView.getUint32(3 * dataSize, littleEndian); // must be 0 for compressed textures
  95538. this.glInternalFormat = headerDataView.getUint32(4 * dataSize, littleEndian); // the value of arg passed to gl.compressedTexImage2D(,,x,,,,)
  95539. this.glBaseInternalFormat = headerDataView.getUint32(5 * dataSize, littleEndian); // specify GL_RGB, GL_RGBA, GL_ALPHA, etc (un-compressed only)
  95540. this.pixelWidth = headerDataView.getUint32(6 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,x,,,)
  95541. this.pixelHeight = headerDataView.getUint32(7 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage2D(,,,,x,,)
  95542. this.pixelDepth = headerDataView.getUint32(8 * dataSize, littleEndian); // level 0 value of arg passed to gl.compressedTexImage3D(,,,,,x,,)
  95543. this.numberOfArrayElements = headerDataView.getUint32(9 * dataSize, littleEndian); // used for texture arrays
  95544. this.numberOfFaces = headerDataView.getUint32(10 * dataSize, littleEndian); // used for cubemap textures, should either be 1 or 6
  95545. this.numberOfMipmapLevels = headerDataView.getUint32(11 * dataSize, littleEndian); // number of levels; disregard possibility of 0 for compressed textures
  95546. this.bytesOfKeyValueData = headerDataView.getUint32(12 * dataSize, littleEndian); // the amount of space after the header for meta-data
  95547. // Make sure we have a compressed type. Not only reduces work, but probably better to let dev know they are not compressing.
  95548. if (this.glType !== 0) {
  95549. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only compressed formats currently supported");
  95550. return;
  95551. }
  95552. else {
  95553. // value of zero is an indication to generate mipmaps @ runtime. Not usually allowed for compressed, so disregard.
  95554. this.numberOfMipmapLevels = Math.max(1, this.numberOfMipmapLevels);
  95555. }
  95556. if (this.pixelHeight === 0 || this.pixelDepth !== 0) {
  95557. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("only 2D textures currently supported");
  95558. return;
  95559. }
  95560. if (this.numberOfArrayElements !== 0) {
  95561. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("texture arrays not currently supported");
  95562. return;
  95563. }
  95564. if (this.numberOfFaces !== facesExpected) {
  95565. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("number of faces expected" + facesExpected + ", but found " + this.numberOfFaces);
  95566. return;
  95567. }
  95568. // we now have a completely validated file, so could use existence of loadType as success
  95569. // would need to make this more elaborate & adjust checks above to support more than one load type
  95570. this.loadType = KhronosTextureContainer.COMPRESSED_2D;
  95571. }
  95572. /**
  95573. * Uploads KTX content to a Babylon Texture.
  95574. * It is assumed that the texture has already been created & is currently bound
  95575. * @hidden
  95576. */
  95577. KhronosTextureContainer.prototype.uploadLevels = function (texture, loadMipmaps) {
  95578. switch (this.loadType) {
  95579. case KhronosTextureContainer.COMPRESSED_2D:
  95580. this._upload2DCompressedLevels(texture, loadMipmaps);
  95581. break;
  95582. case KhronosTextureContainer.TEX_2D:
  95583. case KhronosTextureContainer.COMPRESSED_3D:
  95584. case KhronosTextureContainer.TEX_3D:
  95585. }
  95586. };
  95587. KhronosTextureContainer.prototype._upload2DCompressedLevels = function (texture, loadMipmaps) {
  95588. // initialize width & height for level 1
  95589. var dataOffset = KhronosTextureContainer.HEADER_LEN + this.bytesOfKeyValueData;
  95590. var width = this.pixelWidth;
  95591. var height = this.pixelHeight;
  95592. var mipmapCount = loadMipmaps ? this.numberOfMipmapLevels : 1;
  95593. for (var level = 0; level < mipmapCount; level++) {
  95594. var imageSize = new Int32Array(this.arrayBuffer, dataOffset, 1)[0]; // size per face, since not supporting array cubemaps
  95595. dataOffset += 4; //image data starts from next multiple of 4 offset. Each face refers to same imagesize field above.
  95596. for (var face = 0; face < this.numberOfFaces; face++) {
  95597. var byteArray = new Uint8Array(this.arrayBuffer, dataOffset, imageSize);
  95598. var engine = texture.getEngine();
  95599. engine._uploadCompressedDataToTextureDirectly(texture, this.glInternalFormat, width, height, byteArray, face, level);
  95600. dataOffset += imageSize; // add size of the image for the next face/mipmap
  95601. dataOffset += 3 - ((imageSize + 3) % 4); // add padding for odd sized image
  95602. }
  95603. width = Math.max(1.0, width * 0.5);
  95604. height = Math.max(1.0, height * 0.5);
  95605. }
  95606. };
  95607. KhronosTextureContainer.HEADER_LEN = 12 + (13 * 4); // identifier + header elements (not including key value meta-data pairs)
  95608. // load types
  95609. KhronosTextureContainer.COMPRESSED_2D = 0; // uses a gl.compressedTexImage2D()
  95610. KhronosTextureContainer.COMPRESSED_3D = 1; // uses a gl.compressedTexImage3D()
  95611. KhronosTextureContainer.TEX_2D = 2; // uses a gl.texImage2D()
  95612. KhronosTextureContainer.TEX_3D = 3; // uses a gl.texImage3D()
  95613. return KhronosTextureContainer;
  95614. }());
  95615. /***/ }),
  95616. /***/ "./Misc/logger.ts":
  95617. /*!************************!*\
  95618. !*** ./Misc/logger.ts ***!
  95619. \************************/
  95620. /*! exports provided: Logger */
  95621. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95622. "use strict";
  95623. __webpack_require__.r(__webpack_exports__);
  95624. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return Logger; });
  95625. /**
  95626. * Logger used througouht the application to allow configuration of
  95627. * the log level required for the messages.
  95628. */
  95629. var Logger = /** @class */ (function () {
  95630. function Logger() {
  95631. }
  95632. Logger._AddLogEntry = function (entry) {
  95633. Logger._LogCache = entry + Logger._LogCache;
  95634. if (Logger.OnNewCacheEntry) {
  95635. Logger.OnNewCacheEntry(entry);
  95636. }
  95637. };
  95638. Logger._FormatMessage = function (message) {
  95639. var padStr = function (i) { return (i < 10) ? "0" + i : "" + i; };
  95640. var date = new Date();
  95641. return "[" + padStr(date.getHours()) + ":" + padStr(date.getMinutes()) + ":" + padStr(date.getSeconds()) + "]: " + message;
  95642. };
  95643. Logger._LogDisabled = function (message) {
  95644. // nothing to do
  95645. };
  95646. Logger._LogEnabled = function (message) {
  95647. var formattedMessage = Logger._FormatMessage(message);
  95648. console.log("BJS - " + formattedMessage);
  95649. var entry = "<div style='color:white'>" + formattedMessage + "</div><br>";
  95650. Logger._AddLogEntry(entry);
  95651. };
  95652. Logger._WarnDisabled = function (message) {
  95653. // nothing to do
  95654. };
  95655. Logger._WarnEnabled = function (message) {
  95656. var formattedMessage = Logger._FormatMessage(message);
  95657. console.warn("BJS - " + formattedMessage);
  95658. var entry = "<div style='color:orange'>" + formattedMessage + "</div><br>";
  95659. Logger._AddLogEntry(entry);
  95660. };
  95661. Logger._ErrorDisabled = function (message) {
  95662. // nothing to do
  95663. };
  95664. Logger._ErrorEnabled = function (message) {
  95665. Logger.errorsCount++;
  95666. var formattedMessage = Logger._FormatMessage(message);
  95667. console.error("BJS - " + formattedMessage);
  95668. var entry = "<div style='color:red'>" + formattedMessage + "</div><br>";
  95669. Logger._AddLogEntry(entry);
  95670. };
  95671. Object.defineProperty(Logger, "LogCache", {
  95672. /**
  95673. * Gets current log cache (list of logs)
  95674. */
  95675. get: function () {
  95676. return Logger._LogCache;
  95677. },
  95678. enumerable: true,
  95679. configurable: true
  95680. });
  95681. /**
  95682. * Clears the log cache
  95683. */
  95684. Logger.ClearLogCache = function () {
  95685. Logger._LogCache = "";
  95686. Logger.errorsCount = 0;
  95687. };
  95688. Object.defineProperty(Logger, "LogLevels", {
  95689. /**
  95690. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  95691. */
  95692. set: function (level) {
  95693. if ((level & Logger.MessageLogLevel) === Logger.MessageLogLevel) {
  95694. Logger.Log = Logger._LogEnabled;
  95695. }
  95696. else {
  95697. Logger.Log = Logger._LogDisabled;
  95698. }
  95699. if ((level & Logger.WarningLogLevel) === Logger.WarningLogLevel) {
  95700. Logger.Warn = Logger._WarnEnabled;
  95701. }
  95702. else {
  95703. Logger.Warn = Logger._WarnDisabled;
  95704. }
  95705. if ((level & Logger.ErrorLogLevel) === Logger.ErrorLogLevel) {
  95706. Logger.Error = Logger._ErrorEnabled;
  95707. }
  95708. else {
  95709. Logger.Error = Logger._ErrorDisabled;
  95710. }
  95711. },
  95712. enumerable: true,
  95713. configurable: true
  95714. });
  95715. /**
  95716. * No log
  95717. */
  95718. Logger.NoneLogLevel = 0;
  95719. /**
  95720. * Only message logs
  95721. */
  95722. Logger.MessageLogLevel = 1;
  95723. /**
  95724. * Only warning logs
  95725. */
  95726. Logger.WarningLogLevel = 2;
  95727. /**
  95728. * Only error logs
  95729. */
  95730. Logger.ErrorLogLevel = 4;
  95731. /**
  95732. * All logs
  95733. */
  95734. Logger.AllLogLevel = 7;
  95735. Logger._LogCache = "";
  95736. /**
  95737. * Gets a value indicating the number of loading errors
  95738. * @ignorenaming
  95739. */
  95740. Logger.errorsCount = 0;
  95741. /**
  95742. * Log a message to the console
  95743. */
  95744. Logger.Log = Logger._LogEnabled;
  95745. /**
  95746. * Write a warning message to the console
  95747. */
  95748. Logger.Warn = Logger._WarnEnabled;
  95749. /**
  95750. * Write an error message to the console
  95751. */
  95752. Logger.Error = Logger._ErrorEnabled;
  95753. return Logger;
  95754. }());
  95755. /***/ }),
  95756. /***/ "./Misc/observable.ts":
  95757. /*!****************************!*\
  95758. !*** ./Misc/observable.ts ***!
  95759. \****************************/
  95760. /*! exports provided: EventState, Observer, MultiObserver, Observable */
  95761. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  95762. "use strict";
  95763. __webpack_require__.r(__webpack_exports__);
  95764. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return EventState; });
  95765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return Observer; });
  95766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return MultiObserver; });
  95767. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return Observable; });
  95768. /**
  95769. * A class serves as a medium between the observable and its observers
  95770. */
  95771. var EventState = /** @class */ (function () {
  95772. /**
  95773. * Create a new EventState
  95774. * @param mask defines the mask associated with this state
  95775. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95776. * @param target defines the original target of the state
  95777. * @param currentTarget defines the current target of the state
  95778. */
  95779. function EventState(mask, skipNextObservers, target, currentTarget) {
  95780. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95781. this.initalize(mask, skipNextObservers, target, currentTarget);
  95782. }
  95783. /**
  95784. * Initialize the current event state
  95785. * @param mask defines the mask associated with this state
  95786. * @param skipNextObservers defines a flag which will instruct the observable to skip following observers when set to true
  95787. * @param target defines the original target of the state
  95788. * @param currentTarget defines the current target of the state
  95789. * @returns the current event state
  95790. */
  95791. EventState.prototype.initalize = function (mask, skipNextObservers, target, currentTarget) {
  95792. if (skipNextObservers === void 0) { skipNextObservers = false; }
  95793. this.mask = mask;
  95794. this.skipNextObservers = skipNextObservers;
  95795. this.target = target;
  95796. this.currentTarget = currentTarget;
  95797. return this;
  95798. };
  95799. return EventState;
  95800. }());
  95801. /**
  95802. * Represent an Observer registered to a given Observable object.
  95803. */
  95804. var Observer = /** @class */ (function () {
  95805. /**
  95806. * Creates a new observer
  95807. * @param callback defines the callback to call when the observer is notified
  95808. * @param mask defines the mask of the observer (used to filter notifications)
  95809. * @param scope defines the current scope used to restore the JS context
  95810. */
  95811. function Observer(
  95812. /**
  95813. * Defines the callback to call when the observer is notified
  95814. */
  95815. callback,
  95816. /**
  95817. * Defines the mask of the observer (used to filter notifications)
  95818. */
  95819. mask,
  95820. /**
  95821. * Defines the current scope used to restore the JS context
  95822. */
  95823. scope) {
  95824. if (scope === void 0) { scope = null; }
  95825. this.callback = callback;
  95826. this.mask = mask;
  95827. this.scope = scope;
  95828. /** @hidden */
  95829. this._willBeUnregistered = false;
  95830. /**
  95831. * Gets or sets a property defining that the observer as to be unregistered after the next notification
  95832. */
  95833. this.unregisterOnNextCall = false;
  95834. }
  95835. return Observer;
  95836. }());
  95837. /**
  95838. * Represent a list of observers registered to multiple Observables object.
  95839. */
  95840. var MultiObserver = /** @class */ (function () {
  95841. function MultiObserver() {
  95842. }
  95843. /**
  95844. * Release associated resources
  95845. */
  95846. MultiObserver.prototype.dispose = function () {
  95847. if (this._observers && this._observables) {
  95848. for (var index = 0; index < this._observers.length; index++) {
  95849. this._observables[index].remove(this._observers[index]);
  95850. }
  95851. }
  95852. this._observers = null;
  95853. this._observables = null;
  95854. };
  95855. /**
  95856. * Raise a callback when one of the observable will notify
  95857. * @param observables defines a list of observables to watch
  95858. * @param callback defines the callback to call on notification
  95859. * @param mask defines the mask used to filter notifications
  95860. * @param scope defines the current scope used to restore the JS context
  95861. * @returns the new MultiObserver
  95862. */
  95863. MultiObserver.Watch = function (observables, callback, mask, scope) {
  95864. if (mask === void 0) { mask = -1; }
  95865. if (scope === void 0) { scope = null; }
  95866. var result = new MultiObserver();
  95867. result._observers = new Array();
  95868. result._observables = observables;
  95869. for (var _i = 0, observables_1 = observables; _i < observables_1.length; _i++) {
  95870. var observable = observables_1[_i];
  95871. var observer = observable.add(callback, mask, false, scope);
  95872. if (observer) {
  95873. result._observers.push(observer);
  95874. }
  95875. }
  95876. return result;
  95877. };
  95878. return MultiObserver;
  95879. }());
  95880. /**
  95881. * The Observable class is a simple implementation of the Observable pattern.
  95882. *
  95883. * 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.
  95884. * This enable a more fine grained execution without having to rely on multiple different Observable objects.
  95885. * 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).
  95886. * 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.
  95887. */
  95888. var Observable = /** @class */ (function () {
  95889. /**
  95890. * Creates a new observable
  95891. * @param onObserverAdded defines a callback to call when a new observer is added
  95892. */
  95893. function Observable(onObserverAdded) {
  95894. this._observers = new Array();
  95895. this._eventState = new EventState(0);
  95896. if (onObserverAdded) {
  95897. this._onObserverAdded = onObserverAdded;
  95898. }
  95899. }
  95900. /**
  95901. * Create a new Observer with the specified callback
  95902. * @param callback the callback that will be executed for that Observer
  95903. * @param mask the mask used to filter observers
  95904. * @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.
  95905. * @param scope optional scope for the callback to be called from
  95906. * @param unregisterOnFirstCall defines if the observer as to be unregistered after the next notification
  95907. * @returns the new observer created for the callback
  95908. */
  95909. Observable.prototype.add = function (callback, mask, insertFirst, scope, unregisterOnFirstCall) {
  95910. if (mask === void 0) { mask = -1; }
  95911. if (insertFirst === void 0) { insertFirst = false; }
  95912. if (scope === void 0) { scope = null; }
  95913. if (unregisterOnFirstCall === void 0) { unregisterOnFirstCall = false; }
  95914. if (!callback) {
  95915. return null;
  95916. }
  95917. var observer = new Observer(callback, mask, scope);
  95918. observer.unregisterOnNextCall = unregisterOnFirstCall;
  95919. if (insertFirst) {
  95920. this._observers.unshift(observer);
  95921. }
  95922. else {
  95923. this._observers.push(observer);
  95924. }
  95925. if (this._onObserverAdded) {
  95926. this._onObserverAdded(observer);
  95927. }
  95928. return observer;
  95929. };
  95930. /**
  95931. * Create a new Observer with the specified callback and unregisters after the next notification
  95932. * @param callback the callback that will be executed for that Observer
  95933. * @returns the new observer created for the callback
  95934. */
  95935. Observable.prototype.addOnce = function (callback) {
  95936. return this.add(callback, undefined, undefined, undefined, true);
  95937. };
  95938. /**
  95939. * Remove an Observer from the Observable object
  95940. * @param observer the instance of the Observer to remove
  95941. * @returns false if it doesn't belong to this Observable
  95942. */
  95943. Observable.prototype.remove = function (observer) {
  95944. if (!observer) {
  95945. return false;
  95946. }
  95947. var index = this._observers.indexOf(observer);
  95948. if (index !== -1) {
  95949. this._deferUnregister(observer);
  95950. return true;
  95951. }
  95952. return false;
  95953. };
  95954. /**
  95955. * Remove a callback from the Observable object
  95956. * @param callback the callback to remove
  95957. * @param scope optional scope. If used only the callbacks with this scope will be removed
  95958. * @returns false if it doesn't belong to this Observable
  95959. */
  95960. Observable.prototype.removeCallback = function (callback, scope) {
  95961. for (var index = 0; index < this._observers.length; index++) {
  95962. if (this._observers[index].callback === callback && (!scope || scope === this._observers[index].scope)) {
  95963. this._deferUnregister(this._observers[index]);
  95964. return true;
  95965. }
  95966. }
  95967. return false;
  95968. };
  95969. Observable.prototype._deferUnregister = function (observer) {
  95970. var _this = this;
  95971. observer.unregisterOnNextCall = false;
  95972. observer._willBeUnregistered = true;
  95973. setTimeout(function () {
  95974. _this._remove(observer);
  95975. }, 0);
  95976. };
  95977. // This should only be called when not iterating over _observers to avoid callback skipping.
  95978. // Removes an observer from the _observer Array.
  95979. Observable.prototype._remove = function (observer) {
  95980. if (!observer) {
  95981. return false;
  95982. }
  95983. var index = this._observers.indexOf(observer);
  95984. if (index !== -1) {
  95985. this._observers.splice(index, 1);
  95986. return true;
  95987. }
  95988. return false;
  95989. };
  95990. /**
  95991. * Notify all Observers by calling their respective callback with the given data
  95992. * Will return true if all observers were executed, false if an observer set skipNextObservers to true, then prevent the subsequent ones to execute
  95993. * @param eventData defines the data to send to all observers
  95994. * @param mask defines the mask of the current notification (observers with incompatible mask (ie mask & observer.mask === 0) will not be notified)
  95995. * @param target defines the original target of the state
  95996. * @param currentTarget defines the current target of the state
  95997. * @returns false if the complete observer chain was not processed (because one observer set the skipNextObservers to true)
  95998. */
  95999. Observable.prototype.notifyObservers = function (eventData, mask, target, currentTarget) {
  96000. if (mask === void 0) { mask = -1; }
  96001. if (!this._observers.length) {
  96002. return true;
  96003. }
  96004. var state = this._eventState;
  96005. state.mask = mask;
  96006. state.target = target;
  96007. state.currentTarget = currentTarget;
  96008. state.skipNextObservers = false;
  96009. state.lastReturnValue = eventData;
  96010. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  96011. var obs = _a[_i];
  96012. if (obs._willBeUnregistered) {
  96013. continue;
  96014. }
  96015. if (obs.mask & mask) {
  96016. if (obs.scope) {
  96017. state.lastReturnValue = obs.callback.apply(obs.scope, [eventData, state]);
  96018. }
  96019. else {
  96020. state.lastReturnValue = obs.callback(eventData, state);
  96021. }
  96022. if (obs.unregisterOnNextCall) {
  96023. this._deferUnregister(obs);
  96024. }
  96025. }
  96026. if (state.skipNextObservers) {
  96027. return false;
  96028. }
  96029. }
  96030. return true;
  96031. };
  96032. /**
  96033. * Calling this will execute each callback, expecting it to be a promise or return a value.
  96034. * If at any point in the chain one function fails, the promise will fail and the execution will not continue.
  96035. * This is useful when a chain of events (sometimes async events) is needed to initialize a certain object
  96036. * and it is crucial that all callbacks will be executed.
  96037. * The order of the callbacks is kept, callbacks are not executed parallel.
  96038. *
  96039. * @param eventData The data to be sent to each callback
  96040. * @param mask is used to filter observers defaults to -1
  96041. * @param target defines the callback target (see EventState)
  96042. * @param currentTarget defines he current object in the bubbling phase
  96043. * @returns {Promise<T>} will return a Promise than resolves when all callbacks executed successfully.
  96044. */
  96045. Observable.prototype.notifyObserversWithPromise = function (eventData, mask, target, currentTarget) {
  96046. var _this = this;
  96047. if (mask === void 0) { mask = -1; }
  96048. // create an empty promise
  96049. var p = Promise.resolve(eventData);
  96050. // no observers? return this promise.
  96051. if (!this._observers.length) {
  96052. return p;
  96053. }
  96054. var state = this._eventState;
  96055. state.mask = mask;
  96056. state.target = target;
  96057. state.currentTarget = currentTarget;
  96058. state.skipNextObservers = false;
  96059. // execute one callback after another (not using Promise.all, the order is important)
  96060. this._observers.forEach(function (obs) {
  96061. if (state.skipNextObservers) {
  96062. return;
  96063. }
  96064. if (obs._willBeUnregistered) {
  96065. return;
  96066. }
  96067. if (obs.mask & mask) {
  96068. if (obs.scope) {
  96069. p = p.then(function (lastReturnedValue) {
  96070. state.lastReturnValue = lastReturnedValue;
  96071. return obs.callback.apply(obs.scope, [eventData, state]);
  96072. });
  96073. }
  96074. else {
  96075. p = p.then(function (lastReturnedValue) {
  96076. state.lastReturnValue = lastReturnedValue;
  96077. return obs.callback(eventData, state);
  96078. });
  96079. }
  96080. if (obs.unregisterOnNextCall) {
  96081. _this._deferUnregister(obs);
  96082. }
  96083. }
  96084. });
  96085. // return the eventData
  96086. return p.then(function () { return eventData; });
  96087. };
  96088. /**
  96089. * Notify a specific observer
  96090. * @param observer defines the observer to notify
  96091. * @param eventData defines the data to be sent to each callback
  96092. * @param mask is used to filter observers defaults to -1
  96093. */
  96094. Observable.prototype.notifyObserver = function (observer, eventData, mask) {
  96095. if (mask === void 0) { mask = -1; }
  96096. var state = this._eventState;
  96097. state.mask = mask;
  96098. state.skipNextObservers = false;
  96099. observer.callback(eventData, state);
  96100. };
  96101. /**
  96102. * Gets a boolean indicating if the observable has at least one observer
  96103. * @returns true is the Observable has at least one Observer registered
  96104. */
  96105. Observable.prototype.hasObservers = function () {
  96106. return this._observers.length > 0;
  96107. };
  96108. /**
  96109. * Clear the list of observers
  96110. */
  96111. Observable.prototype.clear = function () {
  96112. this._observers = new Array();
  96113. this._onObserverAdded = null;
  96114. };
  96115. /**
  96116. * Clone the current observable
  96117. * @returns a new observable
  96118. */
  96119. Observable.prototype.clone = function () {
  96120. var result = new Observable();
  96121. result._observers = this._observers.slice(0);
  96122. return result;
  96123. };
  96124. /**
  96125. * Does this observable handles observer registered with a given mask
  96126. * @param mask defines the mask to be tested
  96127. * @return whether or not one observer registered with the given mask is handeled
  96128. **/
  96129. Observable.prototype.hasSpecificMask = function (mask) {
  96130. if (mask === void 0) { mask = -1; }
  96131. for (var _i = 0, _a = this._observers; _i < _a.length; _i++) {
  96132. var obs = _a[_i];
  96133. if (obs.mask & mask || obs.mask === mask) {
  96134. return true;
  96135. }
  96136. }
  96137. return false;
  96138. };
  96139. return Observable;
  96140. }());
  96141. /***/ }),
  96142. /***/ "./Misc/performanceMonitor.ts":
  96143. /*!************************************!*\
  96144. !*** ./Misc/performanceMonitor.ts ***!
  96145. \************************************/
  96146. /*! exports provided: PerformanceMonitor, RollingAverage */
  96147. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96148. "use strict";
  96149. __webpack_require__.r(__webpack_exports__);
  96150. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return PerformanceMonitor; });
  96151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return RollingAverage; });
  96152. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  96153. /**
  96154. * Performance monitor tracks rolling average frame-time and frame-time variance over a user defined sliding-window
  96155. */
  96156. var PerformanceMonitor = /** @class */ (function () {
  96157. /**
  96158. * constructor
  96159. * @param frameSampleSize The number of samples required to saturate the sliding window
  96160. */
  96161. function PerformanceMonitor(frameSampleSize) {
  96162. if (frameSampleSize === void 0) { frameSampleSize = 30; }
  96163. this._enabled = true;
  96164. this._rollingFrameTime = new RollingAverage(frameSampleSize);
  96165. }
  96166. /**
  96167. * Samples current frame
  96168. * @param timeMs A timestamp in milliseconds of the current frame to compare with other frames
  96169. */
  96170. PerformanceMonitor.prototype.sampleFrame = function (timeMs) {
  96171. if (timeMs === void 0) { timeMs = _precisionDate__WEBPACK_IMPORTED_MODULE_0__["PrecisionDate"].Now; }
  96172. if (!this._enabled) {
  96173. return;
  96174. }
  96175. if (this._lastFrameTimeMs != null) {
  96176. var dt = timeMs - this._lastFrameTimeMs;
  96177. this._rollingFrameTime.add(dt);
  96178. }
  96179. this._lastFrameTimeMs = timeMs;
  96180. };
  96181. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTime", {
  96182. /**
  96183. * Returns the average frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  96184. */
  96185. get: function () {
  96186. return this._rollingFrameTime.average;
  96187. },
  96188. enumerable: true,
  96189. configurable: true
  96190. });
  96191. Object.defineProperty(PerformanceMonitor.prototype, "averageFrameTimeVariance", {
  96192. /**
  96193. * Returns the variance frame time in milliseconds over the sliding window (or the subset of frames sampled so far)
  96194. */
  96195. get: function () {
  96196. return this._rollingFrameTime.variance;
  96197. },
  96198. enumerable: true,
  96199. configurable: true
  96200. });
  96201. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFrameTime", {
  96202. /**
  96203. * Returns the frame time of the most recent frame
  96204. */
  96205. get: function () {
  96206. return this._rollingFrameTime.history(0);
  96207. },
  96208. enumerable: true,
  96209. configurable: true
  96210. });
  96211. Object.defineProperty(PerformanceMonitor.prototype, "averageFPS", {
  96212. /**
  96213. * Returns the average framerate in frames per second over the sliding window (or the subset of frames sampled so far)
  96214. */
  96215. get: function () {
  96216. return 1000.0 / this._rollingFrameTime.average;
  96217. },
  96218. enumerable: true,
  96219. configurable: true
  96220. });
  96221. Object.defineProperty(PerformanceMonitor.prototype, "instantaneousFPS", {
  96222. /**
  96223. * Returns the average framerate in frames per second using the most recent frame time
  96224. */
  96225. get: function () {
  96226. var history = this._rollingFrameTime.history(0);
  96227. if (history === 0) {
  96228. return 0;
  96229. }
  96230. return 1000.0 / history;
  96231. },
  96232. enumerable: true,
  96233. configurable: true
  96234. });
  96235. Object.defineProperty(PerformanceMonitor.prototype, "isSaturated", {
  96236. /**
  96237. * Returns true if enough samples have been taken to completely fill the sliding window
  96238. */
  96239. get: function () {
  96240. return this._rollingFrameTime.isSaturated();
  96241. },
  96242. enumerable: true,
  96243. configurable: true
  96244. });
  96245. /**
  96246. * Enables contributions to the sliding window sample set
  96247. */
  96248. PerformanceMonitor.prototype.enable = function () {
  96249. this._enabled = true;
  96250. };
  96251. /**
  96252. * Disables contributions to the sliding window sample set
  96253. * Samples will not be interpolated over the disabled period
  96254. */
  96255. PerformanceMonitor.prototype.disable = function () {
  96256. this._enabled = false;
  96257. //clear last sample to avoid interpolating over the disabled period when next enabled
  96258. this._lastFrameTimeMs = null;
  96259. };
  96260. Object.defineProperty(PerformanceMonitor.prototype, "isEnabled", {
  96261. /**
  96262. * Returns true if sampling is enabled
  96263. */
  96264. get: function () {
  96265. return this._enabled;
  96266. },
  96267. enumerable: true,
  96268. configurable: true
  96269. });
  96270. /**
  96271. * Resets performance monitor
  96272. */
  96273. PerformanceMonitor.prototype.reset = function () {
  96274. //clear last sample to avoid interpolating over the disabled period when next enabled
  96275. this._lastFrameTimeMs = null;
  96276. //wipe record
  96277. this._rollingFrameTime.reset();
  96278. };
  96279. return PerformanceMonitor;
  96280. }());
  96281. /**
  96282. * RollingAverage
  96283. *
  96284. * Utility to efficiently compute the rolling average and variance over a sliding window of samples
  96285. */
  96286. var RollingAverage = /** @class */ (function () {
  96287. /**
  96288. * constructor
  96289. * @param length The number of samples required to saturate the sliding window
  96290. */
  96291. function RollingAverage(length) {
  96292. this._samples = new Array(length);
  96293. this.reset();
  96294. }
  96295. /**
  96296. * Adds a sample to the sample set
  96297. * @param v The sample value
  96298. */
  96299. RollingAverage.prototype.add = function (v) {
  96300. //http://en.wikipedia.org/wiki/Algorithms_for_calculating_variance
  96301. var delta;
  96302. //we need to check if we've already wrapped round
  96303. if (this.isSaturated()) {
  96304. //remove bottom of stack from mean
  96305. var bottomValue = this._samples[this._pos];
  96306. delta = bottomValue - this.average;
  96307. this.average -= delta / (this._sampleCount - 1);
  96308. this._m2 -= delta * (bottomValue - this.average);
  96309. }
  96310. else {
  96311. this._sampleCount++;
  96312. }
  96313. //add new value to mean
  96314. delta = v - this.average;
  96315. this.average += delta / (this._sampleCount);
  96316. this._m2 += delta * (v - this.average);
  96317. //set the new variance
  96318. this.variance = this._m2 / (this._sampleCount - 1);
  96319. this._samples[this._pos] = v;
  96320. this._pos++;
  96321. this._pos %= this._samples.length; //positive wrap around
  96322. };
  96323. /**
  96324. * Returns previously added values or null if outside of history or outside the sliding window domain
  96325. * @param i Index in history. For example, pass 0 for the most recent value and 1 for the value before that
  96326. * @return Value previously recorded with add() or null if outside of range
  96327. */
  96328. RollingAverage.prototype.history = function (i) {
  96329. if ((i >= this._sampleCount) || (i >= this._samples.length)) {
  96330. return 0;
  96331. }
  96332. var i0 = this._wrapPosition(this._pos - 1.0);
  96333. return this._samples[this._wrapPosition(i0 - i)];
  96334. };
  96335. /**
  96336. * Returns true if enough samples have been taken to completely fill the sliding window
  96337. * @return true if sample-set saturated
  96338. */
  96339. RollingAverage.prototype.isSaturated = function () {
  96340. return this._sampleCount >= this._samples.length;
  96341. };
  96342. /**
  96343. * Resets the rolling average (equivalent to 0 samples taken so far)
  96344. */
  96345. RollingAverage.prototype.reset = function () {
  96346. this.average = 0;
  96347. this.variance = 0;
  96348. this._sampleCount = 0;
  96349. this._pos = 0;
  96350. this._m2 = 0;
  96351. };
  96352. /**
  96353. * Wraps a value around the sample range boundaries
  96354. * @param i Position in sample range, for example if the sample length is 5, and i is -3, then 2 will be returned.
  96355. * @return Wrapped position in sample range
  96356. */
  96357. RollingAverage.prototype._wrapPosition = function (i) {
  96358. var max = this._samples.length;
  96359. return ((i % max) + max) % max;
  96360. };
  96361. return RollingAverage;
  96362. }());
  96363. /***/ }),
  96364. /***/ "./Misc/pivotTools.ts":
  96365. /*!****************************!*\
  96366. !*** ./Misc/pivotTools.ts ***!
  96367. \****************************/
  96368. /*! exports provided: PivotTools */
  96369. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96370. "use strict";
  96371. __webpack_require__.r(__webpack_exports__);
  96372. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return PivotTools; });
  96373. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  96374. /**
  96375. * Class containing a set of static utilities functions for managing Pivots
  96376. * @hidden
  96377. */
  96378. var PivotTools = /** @class */ (function () {
  96379. function PivotTools() {
  96380. }
  96381. /** @hidden */
  96382. PivotTools._RemoveAndStorePivotPoint = function (mesh) {
  96383. if (mesh && PivotTools._PivotCached === 0) {
  96384. // Save old pivot and set pivot to 0,0,0
  96385. mesh.getPivotPointToRef(PivotTools._OldPivotPoint);
  96386. if (!PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0)) {
  96387. mesh.setPivotMatrix(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityReadOnly);
  96388. PivotTools._OldPivotPoint.subtractToRef(mesh.getPivotPoint(), PivotTools._PivotTranslation);
  96389. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  96390. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  96391. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  96392. mesh.position.addInPlace(PivotTools._PivotTmpVector);
  96393. }
  96394. }
  96395. PivotTools._PivotCached++;
  96396. };
  96397. /** @hidden */
  96398. PivotTools._RestorePivotPoint = function (mesh) {
  96399. if (mesh && !PivotTools._OldPivotPoint.equalsToFloats(0, 0, 0) && PivotTools._PivotCached === 1) {
  96400. mesh.setPivotPoint(PivotTools._OldPivotPoint);
  96401. PivotTools._PivotTmpVector.copyFromFloats(1, 1, 1);
  96402. PivotTools._PivotTmpVector.subtractInPlace(mesh.scaling);
  96403. PivotTools._PivotTmpVector.multiplyInPlace(PivotTools._PivotTranslation);
  96404. mesh.position.subtractInPlace(PivotTools._PivotTmpVector);
  96405. }
  96406. this._PivotCached--;
  96407. };
  96408. // Stores the state of the pivot cache (_oldPivotPoint, _pivotTranslation)
  96409. // store/remove pivot point should only be applied during their outermost calls
  96410. PivotTools._PivotCached = 0;
  96411. PivotTools._OldPivotPoint = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  96412. PivotTools._PivotTranslation = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  96413. PivotTools._PivotTmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  96414. return PivotTools;
  96415. }());
  96416. /***/ }),
  96417. /***/ "./Misc/precisionDate.ts":
  96418. /*!*******************************!*\
  96419. !*** ./Misc/precisionDate.ts ***!
  96420. \*******************************/
  96421. /*! exports provided: PrecisionDate */
  96422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96423. "use strict";
  96424. __webpack_require__.r(__webpack_exports__);
  96425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return PrecisionDate; });
  96426. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  96427. /**
  96428. * Class containing a set of static utilities functions for precision date
  96429. */
  96430. var PrecisionDate = /** @class */ (function () {
  96431. function PrecisionDate() {
  96432. }
  96433. Object.defineProperty(PrecisionDate, "Now", {
  96434. /**
  96435. * Gets either window.performance.now() if supported or Date.now() else
  96436. */
  96437. get: function () {
  96438. if (_domManagement__WEBPACK_IMPORTED_MODULE_0__["DomManagement"].IsWindowObjectExist() && window.performance && window.performance.now) {
  96439. return window.performance.now();
  96440. }
  96441. return Date.now();
  96442. },
  96443. enumerable: true,
  96444. configurable: true
  96445. });
  96446. return PrecisionDate;
  96447. }());
  96448. /***/ }),
  96449. /***/ "./Misc/promise.ts":
  96450. /*!*************************!*\
  96451. !*** ./Misc/promise.ts ***!
  96452. \*************************/
  96453. /*! exports provided: PromisePolyfill */
  96454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96455. "use strict";
  96456. __webpack_require__.r(__webpack_exports__);
  96457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return PromisePolyfill; });
  96458. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  96459. var PromiseStates;
  96460. (function (PromiseStates) {
  96461. PromiseStates[PromiseStates["Pending"] = 0] = "Pending";
  96462. PromiseStates[PromiseStates["Fulfilled"] = 1] = "Fulfilled";
  96463. PromiseStates[PromiseStates["Rejected"] = 2] = "Rejected";
  96464. })(PromiseStates || (PromiseStates = {}));
  96465. var FulFillmentAgregator = /** @class */ (function () {
  96466. function FulFillmentAgregator() {
  96467. this.count = 0;
  96468. this.target = 0;
  96469. this.results = [];
  96470. }
  96471. return FulFillmentAgregator;
  96472. }());
  96473. var InternalPromise = /** @class */ (function () {
  96474. function InternalPromise(resolver) {
  96475. var _this = this;
  96476. this._state = PromiseStates.Pending;
  96477. this._children = new Array();
  96478. this._rejectWasConsumed = false;
  96479. if (!resolver) {
  96480. return;
  96481. }
  96482. try {
  96483. resolver(function (value) {
  96484. _this._resolve(value);
  96485. }, function (reason) {
  96486. _this._reject(reason);
  96487. });
  96488. }
  96489. catch (e) {
  96490. this._reject(e);
  96491. }
  96492. }
  96493. Object.defineProperty(InternalPromise.prototype, "_result", {
  96494. get: function () {
  96495. return this._resultValue;
  96496. },
  96497. set: function (value) {
  96498. this._resultValue = value;
  96499. if (this._parent && this._parent._result === undefined) {
  96500. this._parent._result = value;
  96501. }
  96502. },
  96503. enumerable: true,
  96504. configurable: true
  96505. });
  96506. InternalPromise.prototype.catch = function (onRejected) {
  96507. return this.then(undefined, onRejected);
  96508. };
  96509. InternalPromise.prototype.then = function (onFulfilled, onRejected) {
  96510. var _this = this;
  96511. var newPromise = new InternalPromise();
  96512. newPromise._onFulfilled = onFulfilled;
  96513. newPromise._onRejected = onRejected;
  96514. // Composition
  96515. this._children.push(newPromise);
  96516. newPromise._parent = this;
  96517. if (this._state !== PromiseStates.Pending) {
  96518. _tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  96519. if (_this._state === PromiseStates.Fulfilled || _this._rejectWasConsumed) {
  96520. var returnedValue = newPromise._resolve(_this._result);
  96521. if (returnedValue !== undefined && returnedValue !== null) {
  96522. if (returnedValue._state !== undefined) {
  96523. var returnedPromise = returnedValue;
  96524. newPromise._children.push(returnedPromise);
  96525. returnedPromise._parent = newPromise;
  96526. newPromise = returnedPromise;
  96527. }
  96528. else {
  96529. newPromise._result = returnedValue;
  96530. }
  96531. }
  96532. }
  96533. else {
  96534. newPromise._reject(_this._reason);
  96535. }
  96536. });
  96537. }
  96538. return newPromise;
  96539. };
  96540. InternalPromise.prototype._moveChildren = function (children) {
  96541. var _this = this;
  96542. var _a;
  96543. (_a = this._children).push.apply(_a, children.splice(0, children.length));
  96544. this._children.forEach(function (child) {
  96545. child._parent = _this;
  96546. });
  96547. if (this._state === PromiseStates.Fulfilled) {
  96548. for (var _i = 0, _b = this._children; _i < _b.length; _i++) {
  96549. var child = _b[_i];
  96550. child._resolve(this._result);
  96551. }
  96552. }
  96553. else if (this._state === PromiseStates.Rejected) {
  96554. for (var _c = 0, _d = this._children; _c < _d.length; _c++) {
  96555. var child = _d[_c];
  96556. child._reject(this._reason);
  96557. }
  96558. }
  96559. };
  96560. InternalPromise.prototype._resolve = function (value) {
  96561. try {
  96562. this._state = PromiseStates.Fulfilled;
  96563. var returnedValue = null;
  96564. if (this._onFulfilled) {
  96565. returnedValue = this._onFulfilled(value);
  96566. }
  96567. if (returnedValue !== undefined && returnedValue !== null) {
  96568. if (returnedValue._state !== undefined) {
  96569. // Transmit children
  96570. var returnedPromise = returnedValue;
  96571. returnedPromise._parent = this;
  96572. returnedPromise._moveChildren(this._children);
  96573. value = returnedPromise._result;
  96574. }
  96575. else {
  96576. value = returnedValue;
  96577. }
  96578. }
  96579. this._result = value;
  96580. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  96581. var child = _a[_i];
  96582. child._resolve(value);
  96583. }
  96584. this._children.length = 0;
  96585. delete this._onFulfilled;
  96586. delete this._onRejected;
  96587. }
  96588. catch (e) {
  96589. this._reject(e, true);
  96590. }
  96591. };
  96592. InternalPromise.prototype._reject = function (reason, onLocalThrow) {
  96593. if (onLocalThrow === void 0) { onLocalThrow = false; }
  96594. this._state = PromiseStates.Rejected;
  96595. this._reason = reason;
  96596. if (this._onRejected && !onLocalThrow) {
  96597. try {
  96598. this._onRejected(reason);
  96599. this._rejectWasConsumed = true;
  96600. }
  96601. catch (e) {
  96602. reason = e;
  96603. }
  96604. }
  96605. for (var _i = 0, _a = this._children; _i < _a.length; _i++) {
  96606. var child = _a[_i];
  96607. if (this._rejectWasConsumed) {
  96608. child._resolve(null);
  96609. }
  96610. else {
  96611. child._reject(reason);
  96612. }
  96613. }
  96614. this._children.length = 0;
  96615. delete this._onFulfilled;
  96616. delete this._onRejected;
  96617. };
  96618. InternalPromise.resolve = function (value) {
  96619. var newPromise = new InternalPromise();
  96620. newPromise._resolve(value);
  96621. return newPromise;
  96622. };
  96623. InternalPromise._RegisterForFulfillment = function (promise, agregator, index) {
  96624. promise.then(function (value) {
  96625. agregator.results[index] = value;
  96626. agregator.count++;
  96627. if (agregator.count === agregator.target) {
  96628. agregator.rootPromise._resolve(agregator.results);
  96629. }
  96630. return null;
  96631. }, function (reason) {
  96632. if (agregator.rootPromise._state !== PromiseStates.Rejected) {
  96633. agregator.rootPromise._reject(reason);
  96634. }
  96635. });
  96636. };
  96637. InternalPromise.all = function (promises) {
  96638. var newPromise = new InternalPromise();
  96639. var agregator = new FulFillmentAgregator();
  96640. agregator.target = promises.length;
  96641. agregator.rootPromise = newPromise;
  96642. if (promises.length) {
  96643. for (var index = 0; index < promises.length; index++) {
  96644. InternalPromise._RegisterForFulfillment(promises[index], agregator, index);
  96645. }
  96646. }
  96647. else {
  96648. newPromise._resolve([]);
  96649. }
  96650. return newPromise;
  96651. };
  96652. InternalPromise.race = function (promises) {
  96653. var newPromise = new InternalPromise();
  96654. if (promises.length) {
  96655. for (var _i = 0, promises_1 = promises; _i < promises_1.length; _i++) {
  96656. var promise = promises_1[_i];
  96657. promise.then(function (value) {
  96658. if (newPromise) {
  96659. newPromise._resolve(value);
  96660. newPromise = null;
  96661. }
  96662. return null;
  96663. }, function (reason) {
  96664. if (newPromise) {
  96665. newPromise._reject(reason);
  96666. newPromise = null;
  96667. }
  96668. });
  96669. }
  96670. }
  96671. return newPromise;
  96672. };
  96673. return InternalPromise;
  96674. }());
  96675. /**
  96676. * Helper class that provides a small promise polyfill
  96677. */
  96678. var PromisePolyfill = /** @class */ (function () {
  96679. function PromisePolyfill() {
  96680. }
  96681. /**
  96682. * Static function used to check if the polyfill is required
  96683. * If this is the case then the function will inject the polyfill to window.Promise
  96684. * @param force defines a boolean used to force the injection (mostly for testing purposes)
  96685. */
  96686. PromisePolyfill.Apply = function (force) {
  96687. if (force === void 0) { force = false; }
  96688. if (force || typeof Promise === 'undefined') {
  96689. var root = window;
  96690. root.Promise = InternalPromise;
  96691. }
  96692. };
  96693. return PromisePolyfill;
  96694. }());
  96695. /***/ }),
  96696. /***/ "./Misc/sceneOptimizer.ts":
  96697. /*!********************************!*\
  96698. !*** ./Misc/sceneOptimizer.ts ***!
  96699. \********************************/
  96700. /*! exports provided: SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer */
  96701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  96702. "use strict";
  96703. __webpack_require__.r(__webpack_exports__);
  96704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return SceneOptimization; });
  96705. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return TextureOptimization; });
  96706. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return HardwareScalingOptimization; });
  96707. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return ShadowsOptimization; });
  96708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return PostProcessesOptimization; });
  96709. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return LensFlaresOptimization; });
  96710. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return CustomOptimization; });
  96711. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return ParticlesOptimization; });
  96712. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return RenderTargetsOptimization; });
  96713. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return MergeMeshesOptimization; });
  96714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return SceneOptimizerOptions; });
  96715. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return SceneOptimizer; });
  96716. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  96717. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  96718. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  96719. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  96720. /**
  96721. * Defines the root class used to create scene optimization to use with SceneOptimizer
  96722. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96723. */
  96724. var SceneOptimization = /** @class */ (function () {
  96725. /**
  96726. * Creates the SceneOptimization object
  96727. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96728. * @param desc defines the description associated with the optimization
  96729. */
  96730. function SceneOptimization(
  96731. /**
  96732. * Defines the priority of this optimization (0 by default which means first in the list)
  96733. */
  96734. priority) {
  96735. if (priority === void 0) { priority = 0; }
  96736. this.priority = priority;
  96737. }
  96738. /**
  96739. * Gets a string describing the action executed by the current optimization
  96740. * @returns description string
  96741. */
  96742. SceneOptimization.prototype.getDescription = function () {
  96743. return "";
  96744. };
  96745. /**
  96746. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96747. * @param scene defines the current scene where to apply this optimization
  96748. * @param optimizer defines the current optimizer
  96749. * @returns true if everything that can be done was applied
  96750. */
  96751. SceneOptimization.prototype.apply = function (scene, optimizer) {
  96752. return true;
  96753. };
  96754. return SceneOptimization;
  96755. }());
  96756. /**
  96757. * Defines an optimization used to reduce the size of render target textures
  96758. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96759. */
  96760. var TextureOptimization = /** @class */ (function (_super) {
  96761. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TextureOptimization, _super);
  96762. /**
  96763. * Creates the TextureOptimization object
  96764. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96765. * @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
  96766. * @param step defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96767. */
  96768. function TextureOptimization(
  96769. /**
  96770. * Defines the priority of this optimization (0 by default which means first in the list)
  96771. */
  96772. priority,
  96773. /**
  96774. * 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
  96775. */
  96776. maximumSize,
  96777. /**
  96778. * Defines the factor (0.5 by default) used to scale down textures bigger than maximum sized allowed.
  96779. */
  96780. step) {
  96781. if (priority === void 0) { priority = 0; }
  96782. if (maximumSize === void 0) { maximumSize = 1024; }
  96783. if (step === void 0) { step = 0.5; }
  96784. var _this = _super.call(this, priority) || this;
  96785. _this.priority = priority;
  96786. _this.maximumSize = maximumSize;
  96787. _this.step = step;
  96788. return _this;
  96789. }
  96790. /**
  96791. * Gets a string describing the action executed by the current optimization
  96792. * @returns description string
  96793. */
  96794. TextureOptimization.prototype.getDescription = function () {
  96795. return "Reducing render target texture size to " + this.maximumSize;
  96796. };
  96797. /**
  96798. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96799. * @param scene defines the current scene where to apply this optimization
  96800. * @param optimizer defines the current optimizer
  96801. * @returns true if everything that can be done was applied
  96802. */
  96803. TextureOptimization.prototype.apply = function (scene, optimizer) {
  96804. var allDone = true;
  96805. for (var index = 0; index < scene.textures.length; index++) {
  96806. var texture = scene.textures[index];
  96807. if (!texture.canRescale || texture.getContext) {
  96808. continue;
  96809. }
  96810. var currentSize = texture.getSize();
  96811. var maxDimension = Math.max(currentSize.width, currentSize.height);
  96812. if (maxDimension > this.maximumSize) {
  96813. texture.scale(this.step);
  96814. allDone = false;
  96815. }
  96816. }
  96817. return allDone;
  96818. };
  96819. return TextureOptimization;
  96820. }(SceneOptimization));
  96821. /**
  96822. * Defines an optimization used to increase or decrease the rendering resolution
  96823. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96824. */
  96825. var HardwareScalingOptimization = /** @class */ (function (_super) {
  96826. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HardwareScalingOptimization, _super);
  96827. /**
  96828. * Creates the HardwareScalingOptimization object
  96829. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  96830. * @param maximumScale defines the maximum scale to use (2 by default)
  96831. * @param step defines the step to use between two passes (0.5 by default)
  96832. */
  96833. function HardwareScalingOptimization(
  96834. /**
  96835. * Defines the priority of this optimization (0 by default which means first in the list)
  96836. */
  96837. priority,
  96838. /**
  96839. * Defines the maximum scale to use (2 by default)
  96840. */
  96841. maximumScale,
  96842. /**
  96843. * Defines the step to use between two passes (0.5 by default)
  96844. */
  96845. step) {
  96846. if (priority === void 0) { priority = 0; }
  96847. if (maximumScale === void 0) { maximumScale = 2; }
  96848. if (step === void 0) { step = 0.25; }
  96849. var _this = _super.call(this, priority) || this;
  96850. _this.priority = priority;
  96851. _this.maximumScale = maximumScale;
  96852. _this.step = step;
  96853. _this._currentScale = -1;
  96854. _this._directionOffset = 1;
  96855. return _this;
  96856. }
  96857. /**
  96858. * Gets a string describing the action executed by the current optimization
  96859. * @return description string
  96860. */
  96861. HardwareScalingOptimization.prototype.getDescription = function () {
  96862. return "Setting hardware scaling level to " + this._currentScale;
  96863. };
  96864. /**
  96865. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96866. * @param scene defines the current scene where to apply this optimization
  96867. * @param optimizer defines the current optimizer
  96868. * @returns true if everything that can be done was applied
  96869. */
  96870. HardwareScalingOptimization.prototype.apply = function (scene, optimizer) {
  96871. if (this._currentScale === -1) {
  96872. this._currentScale = scene.getEngine().getHardwareScalingLevel();
  96873. if (this._currentScale > this.maximumScale) {
  96874. this._directionOffset = -1;
  96875. }
  96876. }
  96877. this._currentScale += this._directionOffset * this.step;
  96878. scene.getEngine().setHardwareScalingLevel(this._currentScale);
  96879. return this._directionOffset === 1 ? this._currentScale >= this.maximumScale : this._currentScale <= this.maximumScale;
  96880. };
  96881. return HardwareScalingOptimization;
  96882. }(SceneOptimization));
  96883. /**
  96884. * Defines an optimization used to remove shadows
  96885. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96886. */
  96887. var ShadowsOptimization = /** @class */ (function (_super) {
  96888. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ShadowsOptimization, _super);
  96889. function ShadowsOptimization() {
  96890. return _super !== null && _super.apply(this, arguments) || this;
  96891. }
  96892. /**
  96893. * Gets a string describing the action executed by the current optimization
  96894. * @return description string
  96895. */
  96896. ShadowsOptimization.prototype.getDescription = function () {
  96897. return "Turning shadows on/off";
  96898. };
  96899. /**
  96900. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96901. * @param scene defines the current scene where to apply this optimization
  96902. * @param optimizer defines the current optimizer
  96903. * @returns true if everything that can be done was applied
  96904. */
  96905. ShadowsOptimization.prototype.apply = function (scene, optimizer) {
  96906. scene.shadowsEnabled = optimizer.isInImprovementMode;
  96907. return true;
  96908. };
  96909. return ShadowsOptimization;
  96910. }(SceneOptimization));
  96911. /**
  96912. * Defines an optimization used to turn post-processes off
  96913. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96914. */
  96915. var PostProcessesOptimization = /** @class */ (function (_super) {
  96916. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PostProcessesOptimization, _super);
  96917. function PostProcessesOptimization() {
  96918. return _super !== null && _super.apply(this, arguments) || this;
  96919. }
  96920. /**
  96921. * Gets a string describing the action executed by the current optimization
  96922. * @return description string
  96923. */
  96924. PostProcessesOptimization.prototype.getDescription = function () {
  96925. return "Turning post-processes on/off";
  96926. };
  96927. /**
  96928. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96929. * @param scene defines the current scene where to apply this optimization
  96930. * @param optimizer defines the current optimizer
  96931. * @returns true if everything that can be done was applied
  96932. */
  96933. PostProcessesOptimization.prototype.apply = function (scene, optimizer) {
  96934. scene.postProcessesEnabled = optimizer.isInImprovementMode;
  96935. return true;
  96936. };
  96937. return PostProcessesOptimization;
  96938. }(SceneOptimization));
  96939. /**
  96940. * Defines an optimization used to turn lens flares off
  96941. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96942. */
  96943. var LensFlaresOptimization = /** @class */ (function (_super) {
  96944. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensFlaresOptimization, _super);
  96945. function LensFlaresOptimization() {
  96946. return _super !== null && _super.apply(this, arguments) || this;
  96947. }
  96948. /**
  96949. * Gets a string describing the action executed by the current optimization
  96950. * @return description string
  96951. */
  96952. LensFlaresOptimization.prototype.getDescription = function () {
  96953. return "Turning lens flares on/off";
  96954. };
  96955. /**
  96956. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96957. * @param scene defines the current scene where to apply this optimization
  96958. * @param optimizer defines the current optimizer
  96959. * @returns true if everything that can be done was applied
  96960. */
  96961. LensFlaresOptimization.prototype.apply = function (scene, optimizer) {
  96962. scene.lensFlaresEnabled = optimizer.isInImprovementMode;
  96963. return true;
  96964. };
  96965. return LensFlaresOptimization;
  96966. }(SceneOptimization));
  96967. /**
  96968. * Defines an optimization based on user defined callback.
  96969. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  96970. */
  96971. var CustomOptimization = /** @class */ (function (_super) {
  96972. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CustomOptimization, _super);
  96973. function CustomOptimization() {
  96974. return _super !== null && _super.apply(this, arguments) || this;
  96975. }
  96976. /**
  96977. * Gets a string describing the action executed by the current optimization
  96978. * @returns description string
  96979. */
  96980. CustomOptimization.prototype.getDescription = function () {
  96981. if (this.onGetDescription) {
  96982. return this.onGetDescription();
  96983. }
  96984. return "Running user defined callback";
  96985. };
  96986. /**
  96987. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  96988. * @param scene defines the current scene where to apply this optimization
  96989. * @param optimizer defines the current optimizer
  96990. * @returns true if everything that can be done was applied
  96991. */
  96992. CustomOptimization.prototype.apply = function (scene, optimizer) {
  96993. if (this.onApply) {
  96994. return this.onApply(scene, optimizer);
  96995. }
  96996. return true;
  96997. };
  96998. return CustomOptimization;
  96999. }(SceneOptimization));
  97000. /**
  97001. * Defines an optimization used to turn particles off
  97002. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97003. */
  97004. var ParticlesOptimization = /** @class */ (function (_super) {
  97005. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticlesOptimization, _super);
  97006. function ParticlesOptimization() {
  97007. return _super !== null && _super.apply(this, arguments) || this;
  97008. }
  97009. /**
  97010. * Gets a string describing the action executed by the current optimization
  97011. * @return description string
  97012. */
  97013. ParticlesOptimization.prototype.getDescription = function () {
  97014. return "Turning particles on/off";
  97015. };
  97016. /**
  97017. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97018. * @param scene defines the current scene where to apply this optimization
  97019. * @param optimizer defines the current optimizer
  97020. * @returns true if everything that can be done was applied
  97021. */
  97022. ParticlesOptimization.prototype.apply = function (scene, optimizer) {
  97023. scene.particlesEnabled = optimizer.isInImprovementMode;
  97024. return true;
  97025. };
  97026. return ParticlesOptimization;
  97027. }(SceneOptimization));
  97028. /**
  97029. * Defines an optimization used to turn render targets off
  97030. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97031. */
  97032. var RenderTargetsOptimization = /** @class */ (function (_super) {
  97033. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RenderTargetsOptimization, _super);
  97034. function RenderTargetsOptimization() {
  97035. return _super !== null && _super.apply(this, arguments) || this;
  97036. }
  97037. /**
  97038. * Gets a string describing the action executed by the current optimization
  97039. * @return description string
  97040. */
  97041. RenderTargetsOptimization.prototype.getDescription = function () {
  97042. return "Turning render targets off";
  97043. };
  97044. /**
  97045. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97046. * @param scene defines the current scene where to apply this optimization
  97047. * @param optimizer defines the current optimizer
  97048. * @returns true if everything that can be done was applied
  97049. */
  97050. RenderTargetsOptimization.prototype.apply = function (scene, optimizer) {
  97051. scene.renderTargetsEnabled = optimizer.isInImprovementMode;
  97052. return true;
  97053. };
  97054. return RenderTargetsOptimization;
  97055. }(SceneOptimization));
  97056. /**
  97057. * Defines an optimization used to merge meshes with compatible materials
  97058. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97059. */
  97060. var MergeMeshesOptimization = /** @class */ (function (_super) {
  97061. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MergeMeshesOptimization, _super);
  97062. function MergeMeshesOptimization() {
  97063. var _this = _super !== null && _super.apply(this, arguments) || this;
  97064. _this._canBeMerged = function (abstractMesh) {
  97065. if (!(abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"])) {
  97066. return false;
  97067. }
  97068. var mesh = abstractMesh;
  97069. if (mesh.isDisposed()) {
  97070. return false;
  97071. }
  97072. if (!mesh.isVisible || !mesh.isEnabled()) {
  97073. return false;
  97074. }
  97075. if (mesh.instances.length > 0) {
  97076. return false;
  97077. }
  97078. if (mesh.skeleton || mesh.hasLODLevels) {
  97079. return false;
  97080. }
  97081. return true;
  97082. };
  97083. return _this;
  97084. }
  97085. Object.defineProperty(MergeMeshesOptimization, "UpdateSelectionTree", {
  97086. /**
  97087. * Gets or sets a boolean which defines if optimization octree has to be updated
  97088. */
  97089. get: function () {
  97090. return MergeMeshesOptimization._UpdateSelectionTree;
  97091. },
  97092. /**
  97093. * Gets or sets a boolean which defines if optimization octree has to be updated
  97094. */
  97095. set: function (value) {
  97096. MergeMeshesOptimization._UpdateSelectionTree = value;
  97097. },
  97098. enumerable: true,
  97099. configurable: true
  97100. });
  97101. /**
  97102. * Gets a string describing the action executed by the current optimization
  97103. * @return description string
  97104. */
  97105. MergeMeshesOptimization.prototype.getDescription = function () {
  97106. return "Merging similar meshes together";
  97107. };
  97108. /**
  97109. * This function will be called by the SceneOptimizer when its priority is reached in order to apply the change required by the current optimization
  97110. * @param scene defines the current scene where to apply this optimization
  97111. * @param optimizer defines the current optimizer
  97112. * @param updateSelectionTree defines that the selection octree has to be updated (false by default)
  97113. * @returns true if everything that can be done was applied
  97114. */
  97115. MergeMeshesOptimization.prototype.apply = function (scene, optimizer, updateSelectionTree) {
  97116. var globalPool = scene.meshes.slice(0);
  97117. var globalLength = globalPool.length;
  97118. for (var index = 0; index < globalLength; index++) {
  97119. var currentPool = new Array();
  97120. var current = globalPool[index];
  97121. // Checks
  97122. if (!this._canBeMerged(current)) {
  97123. continue;
  97124. }
  97125. currentPool.push(current);
  97126. // Find compatible meshes
  97127. for (var subIndex = index + 1; subIndex < globalLength; subIndex++) {
  97128. var otherMesh = globalPool[subIndex];
  97129. if (!this._canBeMerged(otherMesh)) {
  97130. continue;
  97131. }
  97132. if (otherMesh.material !== current.material) {
  97133. continue;
  97134. }
  97135. if (otherMesh.checkCollisions !== current.checkCollisions) {
  97136. continue;
  97137. }
  97138. currentPool.push(otherMesh);
  97139. globalLength--;
  97140. globalPool.splice(subIndex, 1);
  97141. subIndex--;
  97142. }
  97143. if (currentPool.length < 2) {
  97144. continue;
  97145. }
  97146. // Merge meshes
  97147. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"].MergeMeshes(currentPool, undefined, true);
  97148. }
  97149. // Call the octree system optimization if it is defined.
  97150. var sceneAsAny = scene;
  97151. if (sceneAsAny.createOrUpdateSelectionOctree) {
  97152. if (updateSelectionTree != undefined) {
  97153. if (updateSelectionTree) {
  97154. sceneAsAny.createOrUpdateSelectionOctree();
  97155. }
  97156. }
  97157. else if (MergeMeshesOptimization.UpdateSelectionTree) {
  97158. sceneAsAny.createOrUpdateSelectionOctree();
  97159. }
  97160. }
  97161. return true;
  97162. };
  97163. MergeMeshesOptimization._UpdateSelectionTree = false;
  97164. return MergeMeshesOptimization;
  97165. }(SceneOptimization));
  97166. /**
  97167. * Defines a list of options used by SceneOptimizer
  97168. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97169. */
  97170. var SceneOptimizerOptions = /** @class */ (function () {
  97171. /**
  97172. * Creates a new list of options used by SceneOptimizer
  97173. * @param targetFrameRate defines the target frame rate to reach (60 by default)
  97174. * @param trackerDuration defines the interval between two checkes (2000ms by default)
  97175. */
  97176. function SceneOptimizerOptions(
  97177. /**
  97178. * Defines the target frame rate to reach (60 by default)
  97179. */
  97180. targetFrameRate,
  97181. /**
  97182. * Defines the interval between two checkes (2000ms by default)
  97183. */
  97184. trackerDuration) {
  97185. if (targetFrameRate === void 0) { targetFrameRate = 60; }
  97186. if (trackerDuration === void 0) { trackerDuration = 2000; }
  97187. this.targetFrameRate = targetFrameRate;
  97188. this.trackerDuration = trackerDuration;
  97189. /**
  97190. * Gets the list of optimizations to apply
  97191. */
  97192. this.optimizations = new Array();
  97193. }
  97194. /**
  97195. * Add a new optimization
  97196. * @param optimization defines the SceneOptimization to add to the list of active optimizations
  97197. * @returns the current SceneOptimizerOptions
  97198. */
  97199. SceneOptimizerOptions.prototype.addOptimization = function (optimization) {
  97200. this.optimizations.push(optimization);
  97201. return this;
  97202. };
  97203. /**
  97204. * Add a new custom optimization
  97205. * @param onApply defines the callback called to apply the custom optimization (true if everything that can be done was applied)
  97206. * @param onGetDescription defines the callback called to get the description attached with the optimization.
  97207. * @param priority defines the priority of this optimization (0 by default which means first in the list)
  97208. * @returns the current SceneOptimizerOptions
  97209. */
  97210. SceneOptimizerOptions.prototype.addCustomOptimization = function (onApply, onGetDescription, priority) {
  97211. if (priority === void 0) { priority = 0; }
  97212. var optimization = new CustomOptimization(priority);
  97213. optimization.onApply = onApply;
  97214. optimization.onGetDescription = onGetDescription;
  97215. this.optimizations.push(optimization);
  97216. return this;
  97217. };
  97218. /**
  97219. * Creates a list of pre-defined optimizations aimed to reduce the visual impact on the scene
  97220. * @param targetFrameRate defines the target frame rate (60 by default)
  97221. * @returns a SceneOptimizerOptions object
  97222. */
  97223. SceneOptimizerOptions.LowDegradationAllowed = function (targetFrameRate) {
  97224. var result = new SceneOptimizerOptions(targetFrameRate);
  97225. var priority = 0;
  97226. result.addOptimization(new MergeMeshesOptimization(priority));
  97227. result.addOptimization(new ShadowsOptimization(priority));
  97228. result.addOptimization(new LensFlaresOptimization(priority));
  97229. // Next priority
  97230. priority++;
  97231. result.addOptimization(new PostProcessesOptimization(priority));
  97232. result.addOptimization(new ParticlesOptimization(priority));
  97233. // Next priority
  97234. priority++;
  97235. result.addOptimization(new TextureOptimization(priority, 1024));
  97236. return result;
  97237. };
  97238. /**
  97239. * Creates a list of pre-defined optimizations aimed to have a moderate impact on the scene visual
  97240. * @param targetFrameRate defines the target frame rate (60 by default)
  97241. * @returns a SceneOptimizerOptions object
  97242. */
  97243. SceneOptimizerOptions.ModerateDegradationAllowed = function (targetFrameRate) {
  97244. var result = new SceneOptimizerOptions(targetFrameRate);
  97245. var priority = 0;
  97246. result.addOptimization(new MergeMeshesOptimization(priority));
  97247. result.addOptimization(new ShadowsOptimization(priority));
  97248. result.addOptimization(new LensFlaresOptimization(priority));
  97249. // Next priority
  97250. priority++;
  97251. result.addOptimization(new PostProcessesOptimization(priority));
  97252. result.addOptimization(new ParticlesOptimization(priority));
  97253. // Next priority
  97254. priority++;
  97255. result.addOptimization(new TextureOptimization(priority, 512));
  97256. // Next priority
  97257. priority++;
  97258. result.addOptimization(new RenderTargetsOptimization(priority));
  97259. // Next priority
  97260. priority++;
  97261. result.addOptimization(new HardwareScalingOptimization(priority, 2));
  97262. return result;
  97263. };
  97264. /**
  97265. * Creates a list of pre-defined optimizations aimed to have a big impact on the scene visual
  97266. * @param targetFrameRate defines the target frame rate (60 by default)
  97267. * @returns a SceneOptimizerOptions object
  97268. */
  97269. SceneOptimizerOptions.HighDegradationAllowed = function (targetFrameRate) {
  97270. var result = new SceneOptimizerOptions(targetFrameRate);
  97271. var priority = 0;
  97272. result.addOptimization(new MergeMeshesOptimization(priority));
  97273. result.addOptimization(new ShadowsOptimization(priority));
  97274. result.addOptimization(new LensFlaresOptimization(priority));
  97275. // Next priority
  97276. priority++;
  97277. result.addOptimization(new PostProcessesOptimization(priority));
  97278. result.addOptimization(new ParticlesOptimization(priority));
  97279. // Next priority
  97280. priority++;
  97281. result.addOptimization(new TextureOptimization(priority, 256));
  97282. // Next priority
  97283. priority++;
  97284. result.addOptimization(new RenderTargetsOptimization(priority));
  97285. // Next priority
  97286. priority++;
  97287. result.addOptimization(new HardwareScalingOptimization(priority, 4));
  97288. return result;
  97289. };
  97290. return SceneOptimizerOptions;
  97291. }());
  97292. /**
  97293. * Class used to run optimizations in order to reach a target frame rate
  97294. * @description More details at http://doc.babylonjs.com/how_to/how_to_use_sceneoptimizer
  97295. */
  97296. var SceneOptimizer = /** @class */ (function () {
  97297. /**
  97298. * Creates a new SceneOptimizer
  97299. * @param scene defines the scene to work on
  97300. * @param options defines the options to use with the SceneOptimizer
  97301. * @param autoGeneratePriorities defines if priorities must be generated and not read from SceneOptimization property (true by default)
  97302. * @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)
  97303. */
  97304. function SceneOptimizer(scene, options, autoGeneratePriorities, improvementMode) {
  97305. if (autoGeneratePriorities === void 0) { autoGeneratePriorities = true; }
  97306. if (improvementMode === void 0) { improvementMode = false; }
  97307. var _this = this;
  97308. this._isRunning = false;
  97309. this._currentPriorityLevel = 0;
  97310. this._targetFrameRate = 60;
  97311. this._trackerDuration = 2000;
  97312. this._currentFrameRate = 0;
  97313. this._improvementMode = false;
  97314. /**
  97315. * Defines an observable called when the optimizer reaches the target frame rate
  97316. */
  97317. this.onSuccessObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97318. /**
  97319. * Defines an observable called when the optimizer enables an optimization
  97320. */
  97321. this.onNewOptimizationAppliedObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97322. /**
  97323. * Defines an observable called when the optimizer is not able to reach the target frame rate
  97324. */
  97325. this.onFailureObservable = new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  97326. if (!options) {
  97327. this._options = new SceneOptimizerOptions();
  97328. }
  97329. else {
  97330. this._options = options;
  97331. }
  97332. if (this._options.targetFrameRate) {
  97333. this._targetFrameRate = this._options.targetFrameRate;
  97334. }
  97335. if (this._options.trackerDuration) {
  97336. this._trackerDuration = this._options.trackerDuration;
  97337. }
  97338. if (autoGeneratePriorities) {
  97339. var priority = 0;
  97340. for (var _i = 0, _a = this._options.optimizations; _i < _a.length; _i++) {
  97341. var optim = _a[_i];
  97342. optim.priority = priority++;
  97343. }
  97344. }
  97345. this._improvementMode = improvementMode;
  97346. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_1__["EngineStore"].LastCreatedScene;
  97347. this._sceneDisposeObserver = this._scene.onDisposeObservable.add(function () {
  97348. _this._sceneDisposeObserver = null;
  97349. _this.dispose();
  97350. });
  97351. }
  97352. Object.defineProperty(SceneOptimizer.prototype, "isInImprovementMode", {
  97353. /**
  97354. * Gets a boolean indicating if the optimizer is in improvement mode
  97355. */
  97356. get: function () {
  97357. return this._improvementMode;
  97358. },
  97359. enumerable: true,
  97360. configurable: true
  97361. });
  97362. Object.defineProperty(SceneOptimizer.prototype, "currentPriorityLevel", {
  97363. /**
  97364. * Gets the current priority level (0 at start)
  97365. */
  97366. get: function () {
  97367. return this._currentPriorityLevel;
  97368. },
  97369. enumerable: true,
  97370. configurable: true
  97371. });
  97372. Object.defineProperty(SceneOptimizer.prototype, "currentFrameRate", {
  97373. /**
  97374. * Gets the current frame rate checked by the SceneOptimizer
  97375. */
  97376. get: function () {
  97377. return this._currentFrameRate;
  97378. },
  97379. enumerable: true,
  97380. configurable: true
  97381. });
  97382. Object.defineProperty(SceneOptimizer.prototype, "targetFrameRate", {
  97383. /**
  97384. * Gets or sets the current target frame rate (60 by default)
  97385. */
  97386. get: function () {
  97387. return this._targetFrameRate;
  97388. },
  97389. /**
  97390. * Gets or sets the current target frame rate (60 by default)
  97391. */
  97392. set: function (value) {
  97393. this._targetFrameRate = value;
  97394. },
  97395. enumerable: true,
  97396. configurable: true
  97397. });
  97398. Object.defineProperty(SceneOptimizer.prototype, "trackerDuration", {
  97399. /**
  97400. * Gets or sets the current interval between two checks (every 2000ms by default)
  97401. */
  97402. get: function () {
  97403. return this._trackerDuration;
  97404. },
  97405. /**
  97406. * Gets or sets the current interval between two checks (every 2000ms by default)
  97407. */
  97408. set: function (value) {
  97409. this._trackerDuration = value;
  97410. },
  97411. enumerable: true,
  97412. configurable: true
  97413. });
  97414. Object.defineProperty(SceneOptimizer.prototype, "optimizations", {
  97415. /**
  97416. * Gets the list of active optimizations
  97417. */
  97418. get: function () {
  97419. return this._options.optimizations;
  97420. },
  97421. enumerable: true,
  97422. configurable: true
  97423. });
  97424. /**
  97425. * Stops the current optimizer
  97426. */
  97427. SceneOptimizer.prototype.stop = function () {
  97428. this._isRunning = false;
  97429. };
  97430. /**
  97431. * Reset the optimizer to initial step (current priority level = 0)
  97432. */
  97433. SceneOptimizer.prototype.reset = function () {
  97434. this._currentPriorityLevel = 0;
  97435. };
  97436. /**
  97437. * Start the optimizer. By default it will try to reach a specific framerate
  97438. * but if the optimizer is set with improvementMode === true then it will run all optimiatiation while frame rate is above the target frame rate
  97439. */
  97440. SceneOptimizer.prototype.start = function () {
  97441. var _this = this;
  97442. if (this._isRunning) {
  97443. return;
  97444. }
  97445. this._isRunning = true;
  97446. // Let's wait for the scene to be ready before running our check
  97447. this._scene.executeWhenReady(function () {
  97448. setTimeout(function () {
  97449. _this._checkCurrentState();
  97450. }, _this._trackerDuration);
  97451. });
  97452. };
  97453. SceneOptimizer.prototype._checkCurrentState = function () {
  97454. var _this = this;
  97455. if (!this._isRunning) {
  97456. return;
  97457. }
  97458. var scene = this._scene;
  97459. var options = this._options;
  97460. this._currentFrameRate = Math.round(scene.getEngine().getFps());
  97461. if (this._improvementMode && this._currentFrameRate <= this._targetFrameRate ||
  97462. !this._improvementMode && this._currentFrameRate >= this._targetFrameRate) {
  97463. this._isRunning = false;
  97464. this.onSuccessObservable.notifyObservers(this);
  97465. return;
  97466. }
  97467. // Apply current level of optimizations
  97468. var allDone = true;
  97469. var noOptimizationApplied = true;
  97470. for (var index = 0; index < options.optimizations.length; index++) {
  97471. var optimization = options.optimizations[index];
  97472. if (optimization.priority === this._currentPriorityLevel) {
  97473. noOptimizationApplied = false;
  97474. allDone = allDone && optimization.apply(scene, this);
  97475. this.onNewOptimizationAppliedObservable.notifyObservers(optimization);
  97476. }
  97477. }
  97478. // If no optimization was applied, this is a failure :(
  97479. if (noOptimizationApplied) {
  97480. this._isRunning = false;
  97481. this.onFailureObservable.notifyObservers(this);
  97482. return;
  97483. }
  97484. // If all optimizations were done, move to next level
  97485. if (allDone) {
  97486. this._currentPriorityLevel++;
  97487. }
  97488. // Let's the system running for a specific amount of time before checking FPS
  97489. scene.executeWhenReady(function () {
  97490. setTimeout(function () {
  97491. _this._checkCurrentState();
  97492. }, _this._trackerDuration);
  97493. });
  97494. };
  97495. /**
  97496. * Release all resources
  97497. */
  97498. SceneOptimizer.prototype.dispose = function () {
  97499. this.stop();
  97500. this.onSuccessObservable.clear();
  97501. this.onFailureObservable.clear();
  97502. this.onNewOptimizationAppliedObservable.clear();
  97503. if (this._sceneDisposeObserver) {
  97504. this._scene.onDisposeObservable.remove(this._sceneDisposeObserver);
  97505. }
  97506. };
  97507. /**
  97508. * Helper function to create a SceneOptimizer with one single line of code
  97509. * @param scene defines the scene to work on
  97510. * @param options defines the options to use with the SceneOptimizer
  97511. * @param onSuccess defines a callback to call on success
  97512. * @param onFailure defines a callback to call on failure
  97513. * @returns the new SceneOptimizer object
  97514. */
  97515. SceneOptimizer.OptimizeAsync = function (scene, options, onSuccess, onFailure) {
  97516. var optimizer = new SceneOptimizer(scene, options || SceneOptimizerOptions.ModerateDegradationAllowed(), false);
  97517. if (onSuccess) {
  97518. optimizer.onSuccessObservable.add(function () {
  97519. onSuccess();
  97520. });
  97521. }
  97522. if (onFailure) {
  97523. optimizer.onFailureObservable.add(function () {
  97524. onFailure();
  97525. });
  97526. }
  97527. optimizer.start();
  97528. return optimizer;
  97529. };
  97530. return SceneOptimizer;
  97531. }());
  97532. /***/ }),
  97533. /***/ "./Misc/sceneSerializer.ts":
  97534. /*!*********************************!*\
  97535. !*** ./Misc/sceneSerializer.ts ***!
  97536. \*********************************/
  97537. /*! exports provided: SceneSerializer */
  97538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97539. "use strict";
  97540. __webpack_require__.r(__webpack_exports__);
  97541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return SceneSerializer; });
  97542. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  97543. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97544. /* harmony import */ var _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/multiMaterial */ "./Materials/multiMaterial.ts");
  97545. /* harmony import */ var _decorators__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./decorators */ "./Misc/decorators.ts");
  97546. var serializedGeometries = [];
  97547. var serializeGeometry = function (geometry, serializationGeometries) {
  97548. if (serializedGeometries[geometry.id]) {
  97549. return;
  97550. }
  97551. if (geometry.doNotSerialize) {
  97552. return;
  97553. }
  97554. serializationGeometries.vertexData.push(geometry.serializeVerticeData());
  97555. serializedGeometries[geometry.id] = true;
  97556. };
  97557. var serializeMesh = function (mesh, serializationScene) {
  97558. var serializationObject = {};
  97559. // Geometry
  97560. var geometry = mesh._geometry;
  97561. if (geometry) {
  97562. if (!mesh.getScene().getGeometryByID(geometry.id)) {
  97563. // 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
  97564. serializeGeometry(geometry, serializationScene.geometries);
  97565. }
  97566. }
  97567. // Custom
  97568. if (mesh.serialize) {
  97569. mesh.serialize(serializationObject);
  97570. }
  97571. return serializationObject;
  97572. };
  97573. var finalizeSingleMesh = function (mesh, serializationObject) {
  97574. //only works if the mesh is already loaded
  97575. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  97576. //serialize material
  97577. if (mesh.material) {
  97578. if (mesh.material instanceof _Materials_multiMaterial__WEBPACK_IMPORTED_MODULE_2__["MultiMaterial"]) {
  97579. serializationObject.multiMaterials = serializationObject.multiMaterials || [];
  97580. serializationObject.materials = serializationObject.materials || [];
  97581. if (!serializationObject.multiMaterials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  97582. serializationObject.multiMaterials.push(mesh.material.serialize());
  97583. var _loop_1 = function (submaterial) {
  97584. if (submaterial) {
  97585. if (!serializationObject.materials.some(function (mat) { return (mat.id === submaterial.id); })) {
  97586. serializationObject.materials.push(submaterial.serialize());
  97587. }
  97588. }
  97589. };
  97590. for (var _i = 0, _a = mesh.material.subMaterials; _i < _a.length; _i++) {
  97591. var submaterial = _a[_i];
  97592. _loop_1(submaterial);
  97593. }
  97594. }
  97595. }
  97596. else {
  97597. serializationObject.materials = serializationObject.materials || [];
  97598. if (!serializationObject.materials.some(function (mat) { return (mat.id === mesh.material.id); })) {
  97599. serializationObject.materials.push(mesh.material.serialize());
  97600. }
  97601. }
  97602. }
  97603. //serialize geometry
  97604. var geometry = mesh._geometry;
  97605. if (geometry) {
  97606. if (!serializationObject.geometries) {
  97607. serializationObject.geometries = {};
  97608. serializationObject.geometries.boxes = [];
  97609. serializationObject.geometries.spheres = [];
  97610. serializationObject.geometries.cylinders = [];
  97611. serializationObject.geometries.toruses = [];
  97612. serializationObject.geometries.grounds = [];
  97613. serializationObject.geometries.planes = [];
  97614. serializationObject.geometries.torusKnots = [];
  97615. serializationObject.geometries.vertexData = [];
  97616. }
  97617. serializeGeometry(geometry, serializationObject.geometries);
  97618. }
  97619. // Skeletons
  97620. if (mesh.skeleton) {
  97621. serializationObject.skeletons = serializationObject.skeletons || [];
  97622. serializationObject.skeletons.push(mesh.skeleton.serialize());
  97623. }
  97624. //serialize the actual mesh
  97625. serializationObject.meshes = serializationObject.meshes || [];
  97626. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  97627. }
  97628. };
  97629. /**
  97630. * Class used to serialize a scene into a string
  97631. */
  97632. var SceneSerializer = /** @class */ (function () {
  97633. function SceneSerializer() {
  97634. }
  97635. /**
  97636. * Clear cache used by a previous serialization
  97637. */
  97638. SceneSerializer.ClearCache = function () {
  97639. serializedGeometries = [];
  97640. };
  97641. /**
  97642. * Serialize a scene into a JSON compatible object
  97643. * @param scene defines the scene to serialize
  97644. * @returns a JSON compatible object
  97645. */
  97646. SceneSerializer.Serialize = function (scene) {
  97647. var serializationObject = {};
  97648. SceneSerializer.ClearCache();
  97649. // Scene
  97650. serializationObject.useDelayedTextureLoading = scene.useDelayedTextureLoading;
  97651. serializationObject.autoClear = scene.autoClear;
  97652. serializationObject.clearColor = scene.clearColor.asArray();
  97653. serializationObject.ambientColor = scene.ambientColor.asArray();
  97654. serializationObject.gravity = scene.gravity.asArray();
  97655. serializationObject.collisionsEnabled = scene.collisionsEnabled;
  97656. // Fog
  97657. if (scene.fogMode && scene.fogMode !== 0) {
  97658. serializationObject.fogMode = scene.fogMode;
  97659. serializationObject.fogColor = scene.fogColor.asArray();
  97660. serializationObject.fogStart = scene.fogStart;
  97661. serializationObject.fogEnd = scene.fogEnd;
  97662. serializationObject.fogDensity = scene.fogDensity;
  97663. }
  97664. //Physics
  97665. if (scene.isPhysicsEnabled()) {
  97666. var physicEngine = scene.getPhysicsEngine();
  97667. if (physicEngine) {
  97668. serializationObject.physicsEnabled = true;
  97669. serializationObject.physicsGravity = physicEngine.gravity.asArray();
  97670. serializationObject.physicsEngine = physicEngine.getPhysicsPluginName();
  97671. }
  97672. }
  97673. // Metadata
  97674. if (scene.metadata) {
  97675. serializationObject.metadata = scene.metadata;
  97676. }
  97677. // Morph targets
  97678. serializationObject.morphTargetManagers = [];
  97679. for (var _i = 0, _a = scene.meshes; _i < _a.length; _i++) {
  97680. var abstractMesh = _a[_i];
  97681. var manager = abstractMesh.morphTargetManager;
  97682. if (manager) {
  97683. serializationObject.morphTargetManagers.push(manager.serialize());
  97684. }
  97685. }
  97686. // Lights
  97687. serializationObject.lights = [];
  97688. var index;
  97689. var light;
  97690. for (index = 0; index < scene.lights.length; index++) {
  97691. light = scene.lights[index];
  97692. if (!light.doNotSerialize) {
  97693. serializationObject.lights.push(light.serialize());
  97694. }
  97695. }
  97696. // Cameras
  97697. serializationObject.cameras = [];
  97698. for (index = 0; index < scene.cameras.length; index++) {
  97699. var camera = scene.cameras[index];
  97700. if (!camera.doNotSerialize) {
  97701. serializationObject.cameras.push(camera.serialize());
  97702. }
  97703. }
  97704. if (scene.activeCamera) {
  97705. serializationObject.activeCameraID = scene.activeCamera.id;
  97706. }
  97707. // Animations
  97708. _decorators__WEBPACK_IMPORTED_MODULE_3__["SerializationHelper"].AppendSerializedAnimations(scene, serializationObject);
  97709. // Reflection probes
  97710. if (scene.reflectionProbes && scene.reflectionProbes.length > 0) {
  97711. serializationObject.reflectionProbes = [];
  97712. for (index = 0; index < scene.reflectionProbes.length; index++) {
  97713. var reflectionProbe = scene.reflectionProbes[index];
  97714. serializationObject.reflectionProbes.push(reflectionProbe.serialize());
  97715. }
  97716. }
  97717. // Materials
  97718. serializationObject.materials = [];
  97719. serializationObject.multiMaterials = [];
  97720. var material;
  97721. for (index = 0; index < scene.materials.length; index++) {
  97722. material = scene.materials[index];
  97723. if (!material.doNotSerialize) {
  97724. serializationObject.materials.push(material.serialize());
  97725. }
  97726. }
  97727. // MultiMaterials
  97728. serializationObject.multiMaterials = [];
  97729. for (index = 0; index < scene.multiMaterials.length; index++) {
  97730. var multiMaterial = scene.multiMaterials[index];
  97731. serializationObject.multiMaterials.push(multiMaterial.serialize());
  97732. }
  97733. // Environment texture
  97734. if (scene.environmentTexture) {
  97735. serializationObject.environmentTexture = scene.environmentTexture.name;
  97736. }
  97737. // Skeletons
  97738. serializationObject.skeletons = [];
  97739. for (index = 0; index < scene.skeletons.length; index++) {
  97740. var skeleton = scene.skeletons[index];
  97741. if (!skeleton.doNotSerialize) {
  97742. serializationObject.skeletons.push(skeleton.serialize());
  97743. }
  97744. }
  97745. // Transform nodes
  97746. serializationObject.transformNodes = [];
  97747. for (index = 0; index < scene.transformNodes.length; index++) {
  97748. serializationObject.transformNodes.push(scene.transformNodes[index].serialize());
  97749. }
  97750. // Geometries
  97751. serializationObject.geometries = {};
  97752. serializationObject.geometries.boxes = [];
  97753. serializationObject.geometries.spheres = [];
  97754. serializationObject.geometries.cylinders = [];
  97755. serializationObject.geometries.toruses = [];
  97756. serializationObject.geometries.grounds = [];
  97757. serializationObject.geometries.planes = [];
  97758. serializationObject.geometries.torusKnots = [];
  97759. serializationObject.geometries.vertexData = [];
  97760. serializedGeometries = [];
  97761. var geometries = scene.getGeometries();
  97762. for (index = 0; index < geometries.length; index++) {
  97763. var geometry = geometries[index];
  97764. if (geometry.isReady()) {
  97765. serializeGeometry(geometry, serializationObject.geometries);
  97766. }
  97767. }
  97768. // Meshes
  97769. serializationObject.meshes = [];
  97770. for (index = 0; index < scene.meshes.length; index++) {
  97771. var abstractMesh = scene.meshes[index];
  97772. if (abstractMesh instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"]) {
  97773. var mesh = abstractMesh;
  97774. if (!mesh.doNotSerialize) {
  97775. if (mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_LOADED || mesh.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].DELAYLOADSTATE_NONE) {
  97776. serializationObject.meshes.push(serializeMesh(mesh, serializationObject));
  97777. }
  97778. }
  97779. }
  97780. }
  97781. // Particles Systems
  97782. serializationObject.particleSystems = [];
  97783. for (index = 0; index < scene.particleSystems.length; index++) {
  97784. serializationObject.particleSystems.push(scene.particleSystems[index].serialize());
  97785. }
  97786. // Action Manager
  97787. if (scene.actionManager) {
  97788. serializationObject.actions = scene.actionManager.serialize("scene");
  97789. }
  97790. // Components
  97791. for (var _b = 0, _c = scene._serializableComponents; _b < _c.length; _b++) {
  97792. var component = _c[_b];
  97793. component.serialize(serializationObject);
  97794. }
  97795. return serializationObject;
  97796. };
  97797. /**
  97798. * Serialize a mesh into a JSON compatible object
  97799. * @param toSerialize defines the mesh to serialize
  97800. * @param withParents defines if parents must be serialized as well
  97801. * @param withChildren defines if children must be serialized as well
  97802. * @returns a JSON compatible object
  97803. */
  97804. SceneSerializer.SerializeMesh = function (toSerialize /* Mesh || Mesh[] */, withParents, withChildren) {
  97805. if (withParents === void 0) { withParents = false; }
  97806. if (withChildren === void 0) { withChildren = false; }
  97807. var serializationObject = {};
  97808. SceneSerializer.ClearCache();
  97809. toSerialize = (toSerialize instanceof Array) ? toSerialize : [toSerialize];
  97810. if (withParents || withChildren) {
  97811. //deliberate for loop! not for each, appended should be processed as well.
  97812. for (var i = 0; i < toSerialize.length; ++i) {
  97813. if (withChildren) {
  97814. toSerialize[i].getDescendants().forEach(function (node) {
  97815. if (node instanceof _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"] && (toSerialize.indexOf(node) < 0)) {
  97816. toSerialize.push(node);
  97817. }
  97818. });
  97819. }
  97820. //make sure the array doesn't contain the object already
  97821. if (withParents && toSerialize[i].parent && (toSerialize.indexOf(toSerialize[i].parent) < 0)) {
  97822. toSerialize.push(toSerialize[i].parent);
  97823. }
  97824. }
  97825. }
  97826. toSerialize.forEach(function (mesh) {
  97827. finalizeSingleMesh(mesh, serializationObject);
  97828. });
  97829. return serializationObject;
  97830. };
  97831. return SceneSerializer;
  97832. }());
  97833. /***/ }),
  97834. /***/ "./Misc/screenshotTools.ts":
  97835. /*!*********************************!*\
  97836. !*** ./Misc/screenshotTools.ts ***!
  97837. \*********************************/
  97838. /*! exports provided: ScreenshotTools */
  97839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  97840. "use strict";
  97841. __webpack_require__.r(__webpack_exports__);
  97842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return ScreenshotTools; });
  97843. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  97844. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  97845. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  97846. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  97847. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  97848. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  97849. // Screenshots
  97850. var screenshotCanvas;
  97851. /**
  97852. * Class containing a set of static utilities functions for screenshots
  97853. */
  97854. var ScreenshotTools = /** @class */ (function () {
  97855. function ScreenshotTools() {
  97856. }
  97857. /**
  97858. * Captures a screenshot of the current rendering
  97859. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97860. * @param engine defines the rendering engine
  97861. * @param camera defines the source camera
  97862. * @param size This parameter can be set to a single number or to an object with the
  97863. * following (optional) properties: precision, width, height. If a single number is passed,
  97864. * it will be used for both width and height. If an object is passed, the screenshot size
  97865. * will be derived from the parameters. The precision property is a multiplier allowing
  97866. * rendering at a higher or lower resolution
  97867. * @param successCallback defines the callback receives a single parameter which contains the
  97868. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97869. * src parameter of an <img> to display it
  97870. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  97871. * Check your browser for supported MIME types
  97872. */
  97873. ScreenshotTools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  97874. if (mimeType === void 0) { mimeType = "image/png"; }
  97875. var width;
  97876. var height;
  97877. // If a precision value is specified
  97878. if (size.precision) {
  97879. width = Math.round(engine.getRenderWidth() * size.precision);
  97880. height = Math.round(width / engine.getAspectRatio(camera));
  97881. }
  97882. else if (size.width && size.height) {
  97883. width = size.width;
  97884. height = size.height;
  97885. }
  97886. //If passing only width, computing height to keep display canvas ratio.
  97887. else if (size.width && !size.height) {
  97888. width = size.width;
  97889. height = Math.round(width / engine.getAspectRatio(camera));
  97890. }
  97891. //If passing only height, computing width to keep display canvas ratio.
  97892. else if (size.height && !size.width) {
  97893. height = size.height;
  97894. width = Math.round(height * engine.getAspectRatio(camera));
  97895. }
  97896. //Assuming here that "size" parameter is a number
  97897. else if (!isNaN(size)) {
  97898. height = size;
  97899. width = size;
  97900. }
  97901. else {
  97902. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97903. return;
  97904. }
  97905. if (!screenshotCanvas) {
  97906. screenshotCanvas = document.createElement('canvas');
  97907. }
  97908. screenshotCanvas.width = width;
  97909. screenshotCanvas.height = height;
  97910. var renderContext = screenshotCanvas.getContext("2d");
  97911. var ratio = engine.getRenderWidth() / engine.getRenderHeight();
  97912. var newWidth = width;
  97913. var newHeight = newWidth / ratio;
  97914. if (newHeight > height) {
  97915. newHeight = height;
  97916. newWidth = newHeight * ratio;
  97917. }
  97918. var offsetX = Math.max(0, width - newWidth) / 2;
  97919. var offsetY = Math.max(0, height - newHeight) / 2;
  97920. var renderingCanvas = engine.getRenderingCanvas();
  97921. if (renderContext && renderingCanvas) {
  97922. renderContext.drawImage(renderingCanvas, offsetX, offsetY, newWidth, newHeight);
  97923. }
  97924. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].EncodeScreenshotCanvasData(successCallback, mimeType);
  97925. };
  97926. /**
  97927. * Generates an image screenshot from the specified camera.
  97928. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  97929. * @param engine The engine to use for rendering
  97930. * @param camera The camera to use for rendering
  97931. * @param size This parameter can be set to a single number or to an object with the
  97932. * following (optional) properties: precision, width, height. If a single number is passed,
  97933. * it will be used for both width and height. If an object is passed, the screenshot size
  97934. * will be derived from the parameters. The precision property is a multiplier allowing
  97935. * rendering at a higher or lower resolution
  97936. * @param successCallback The callback receives a single parameter which contains the
  97937. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  97938. * src parameter of an <img> to display it
  97939. * @param mimeType The MIME type of the screenshot image (default: image/png).
  97940. * Check your browser for supported MIME types
  97941. * @param samples Texture samples (default: 1)
  97942. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  97943. * @param fileName A name for for the downloaded file.
  97944. */
  97945. ScreenshotTools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  97946. if (mimeType === void 0) { mimeType = "image/png"; }
  97947. if (samples === void 0) { samples = 1; }
  97948. if (antialiasing === void 0) { antialiasing = false; }
  97949. var width;
  97950. var height;
  97951. //If a precision value is specified
  97952. if (size.precision) {
  97953. width = Math.round(engine.getRenderWidth() * size.precision);
  97954. height = Math.round(width / engine.getAspectRatio(camera));
  97955. size = { width: width, height: height };
  97956. }
  97957. else if (size.width && size.height) {
  97958. width = size.width;
  97959. height = size.height;
  97960. }
  97961. //If passing only width, computing height to keep display canvas ratio.
  97962. else if (size.width && !size.height) {
  97963. width = size.width;
  97964. height = Math.round(width / engine.getAspectRatio(camera));
  97965. size = { width: width, height: height };
  97966. }
  97967. //If passing only height, computing width to keep display canvas ratio.
  97968. else if (size.height && !size.width) {
  97969. height = size.height;
  97970. width = Math.round(height * engine.getAspectRatio(camera));
  97971. size = { width: width, height: height };
  97972. }
  97973. //Assuming here that "size" parameter is a number
  97974. else if (!isNaN(size)) {
  97975. height = size;
  97976. width = size;
  97977. }
  97978. else {
  97979. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("Invalid 'size' parameter !");
  97980. return;
  97981. }
  97982. var scene = camera.getScene();
  97983. var previousCamera = null;
  97984. if (scene.activeCamera !== camera) {
  97985. previousCamera = scene.activeCamera;
  97986. scene.activeCamera = camera;
  97987. }
  97988. var renderCanvas = engine.getRenderingCanvas();
  97989. if (!renderCanvas) {
  97990. _logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Error("No rendering canvas found !");
  97991. return;
  97992. }
  97993. var originalSize = { width: renderCanvas.width, height: renderCanvas.height };
  97994. engine.setSize(width, height);
  97995. scene.render();
  97996. // At this point size can be a number, or an object (according to engine.prototype.createRenderTargetTexture method)
  97997. 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);
  97998. texture.renderList = null;
  97999. texture.samples = samples;
  98000. if (antialiasing) {
  98001. texture.addPostProcess(new _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_2__["FxaaPostProcess"]('antialiasing', 1.0, scene.activeCamera));
  98002. }
  98003. texture.onAfterRenderObservable.add(function () {
  98004. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].DumpFramebuffer(width, height, engine, successCallback, mimeType, fileName);
  98005. });
  98006. scene.incrementRenderId();
  98007. scene.resetCachedMaterial();
  98008. texture.render(true);
  98009. texture.dispose();
  98010. if (previousCamera) {
  98011. scene.activeCamera = previousCamera;
  98012. }
  98013. engine.setSize(originalSize.width, originalSize.height);
  98014. camera.getProjectionMatrix(true); // Force cache refresh;
  98015. };
  98016. return ScreenshotTools;
  98017. }());
  98018. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshot = ScreenshotTools.CreateScreenshot;
  98019. _tools__WEBPACK_IMPORTED_MODULE_5__["Tools"].CreateScreenshotUsingRenderTarget = ScreenshotTools.CreateScreenshotUsingRenderTarget;
  98020. /***/ }),
  98021. /***/ "./Misc/smartArray.ts":
  98022. /*!****************************!*\
  98023. !*** ./Misc/smartArray.ts ***!
  98024. \****************************/
  98025. /*! exports provided: SmartArray, SmartArrayNoDuplicate */
  98026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98027. "use strict";
  98028. __webpack_require__.r(__webpack_exports__);
  98029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return SmartArray; });
  98030. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return SmartArrayNoDuplicate; });
  98031. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98032. /**
  98033. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  98034. */
  98035. var SmartArray = /** @class */ (function () {
  98036. /**
  98037. * Instantiates a Smart Array.
  98038. * @param capacity defines the default capacity of the array.
  98039. */
  98040. function SmartArray(capacity) {
  98041. /**
  98042. * The active length of the array.
  98043. */
  98044. this.length = 0;
  98045. this.data = new Array(capacity);
  98046. this._id = SmartArray._GlobalId++;
  98047. }
  98048. /**
  98049. * Pushes a value at the end of the active data.
  98050. * @param value defines the object to push in the array.
  98051. */
  98052. SmartArray.prototype.push = function (value) {
  98053. this.data[this.length++] = value;
  98054. if (this.length > this.data.length) {
  98055. this.data.length *= 2;
  98056. }
  98057. };
  98058. /**
  98059. * Iterates over the active data and apply the lambda to them.
  98060. * @param func defines the action to apply on each value.
  98061. */
  98062. SmartArray.prototype.forEach = function (func) {
  98063. for (var index = 0; index < this.length; index++) {
  98064. func(this.data[index]);
  98065. }
  98066. };
  98067. /**
  98068. * Sorts the full sets of data.
  98069. * @param compareFn defines the comparison function to apply.
  98070. */
  98071. SmartArray.prototype.sort = function (compareFn) {
  98072. this.data.sort(compareFn);
  98073. };
  98074. /**
  98075. * Resets the active data to an empty array.
  98076. */
  98077. SmartArray.prototype.reset = function () {
  98078. this.length = 0;
  98079. };
  98080. /**
  98081. * Releases all the data from the array as well as the array.
  98082. */
  98083. SmartArray.prototype.dispose = function () {
  98084. this.reset();
  98085. if (this.data) {
  98086. this.data.length = 0;
  98087. this.data = [];
  98088. }
  98089. };
  98090. /**
  98091. * Concats the active data with a given array.
  98092. * @param array defines the data to concatenate with.
  98093. */
  98094. SmartArray.prototype.concat = function (array) {
  98095. if (array.length === 0) {
  98096. return;
  98097. }
  98098. if (this.length + array.length > this.data.length) {
  98099. this.data.length = (this.length + array.length) * 2;
  98100. }
  98101. for (var index = 0; index < array.length; index++) {
  98102. this.data[this.length++] = (array.data || array)[index];
  98103. }
  98104. };
  98105. /**
  98106. * Returns the position of a value in the active data.
  98107. * @param value defines the value to find the index for
  98108. * @returns the index if found in the active data otherwise -1
  98109. */
  98110. SmartArray.prototype.indexOf = function (value) {
  98111. var position = this.data.indexOf(value);
  98112. if (position >= this.length) {
  98113. return -1;
  98114. }
  98115. return position;
  98116. };
  98117. /**
  98118. * Returns whether an element is part of the active data.
  98119. * @param value defines the value to look for
  98120. * @returns true if found in the active data otherwise false
  98121. */
  98122. SmartArray.prototype.contains = function (value) {
  98123. return this.indexOf(value) !== -1;
  98124. };
  98125. // Statics
  98126. SmartArray._GlobalId = 0;
  98127. return SmartArray;
  98128. }());
  98129. /**
  98130. * Defines an GC Friendly array where the backfield array do not shrink to prevent over allocations.
  98131. * The data in this array can only be present once
  98132. */
  98133. var SmartArrayNoDuplicate = /** @class */ (function (_super) {
  98134. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SmartArrayNoDuplicate, _super);
  98135. function SmartArrayNoDuplicate() {
  98136. var _this = _super !== null && _super.apply(this, arguments) || this;
  98137. _this._duplicateId = 0;
  98138. return _this;
  98139. }
  98140. /**
  98141. * Pushes a value at the end of the active data.
  98142. * THIS DOES NOT PREVENT DUPPLICATE DATA
  98143. * @param value defines the object to push in the array.
  98144. */
  98145. SmartArrayNoDuplicate.prototype.push = function (value) {
  98146. _super.prototype.push.call(this, value);
  98147. if (!value.__smartArrayFlags) {
  98148. value.__smartArrayFlags = {};
  98149. }
  98150. value.__smartArrayFlags[this._id] = this._duplicateId;
  98151. };
  98152. /**
  98153. * Pushes a value at the end of the active data.
  98154. * If the data is already present, it won t be added again
  98155. * @param value defines the object to push in the array.
  98156. * @returns true if added false if it was already present
  98157. */
  98158. SmartArrayNoDuplicate.prototype.pushNoDuplicate = function (value) {
  98159. if (value.__smartArrayFlags && value.__smartArrayFlags[this._id] === this._duplicateId) {
  98160. return false;
  98161. }
  98162. this.push(value);
  98163. return true;
  98164. };
  98165. /**
  98166. * Resets the active data to an empty array.
  98167. */
  98168. SmartArrayNoDuplicate.prototype.reset = function () {
  98169. _super.prototype.reset.call(this);
  98170. this._duplicateId++;
  98171. };
  98172. /**
  98173. * Concats the active data with a given array.
  98174. * This ensures no dupplicate will be present in the result.
  98175. * @param array defines the data to concatenate with.
  98176. */
  98177. SmartArrayNoDuplicate.prototype.concatWithNoDuplicate = function (array) {
  98178. if (array.length === 0) {
  98179. return;
  98180. }
  98181. if (this.length + array.length > this.data.length) {
  98182. this.data.length = (this.length + array.length) * 2;
  98183. }
  98184. for (var index = 0; index < array.length; index++) {
  98185. var item = (array.data || array)[index];
  98186. this.pushNoDuplicate(item);
  98187. }
  98188. };
  98189. return SmartArrayNoDuplicate;
  98190. }(SmartArray));
  98191. /***/ }),
  98192. /***/ "./Misc/stringDictionary.ts":
  98193. /*!**********************************!*\
  98194. !*** ./Misc/stringDictionary.ts ***!
  98195. \**********************************/
  98196. /*! exports provided: StringDictionary */
  98197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98198. "use strict";
  98199. __webpack_require__.r(__webpack_exports__);
  98200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return StringDictionary; });
  98201. /**
  98202. * This class implement a typical dictionary using a string as key and the generic type T as value.
  98203. * The underlying implementation relies on an associative array to ensure the best performances.
  98204. * The value can be anything including 'null' but except 'undefined'
  98205. */
  98206. var StringDictionary = /** @class */ (function () {
  98207. function StringDictionary() {
  98208. this._count = 0;
  98209. this._data = {};
  98210. }
  98211. /**
  98212. * This will clear this dictionary and copy the content from the 'source' one.
  98213. * If the T value is a custom object, it won't be copied/cloned, the same object will be used
  98214. * @param source the dictionary to take the content from and copy to this dictionary
  98215. */
  98216. StringDictionary.prototype.copyFrom = function (source) {
  98217. var _this = this;
  98218. this.clear();
  98219. source.forEach(function (t, v) { return _this.add(t, v); });
  98220. };
  98221. /**
  98222. * Get a value based from its key
  98223. * @param key the given key to get the matching value from
  98224. * @return the value if found, otherwise undefined is returned
  98225. */
  98226. StringDictionary.prototype.get = function (key) {
  98227. var val = this._data[key];
  98228. if (val !== undefined) {
  98229. return val;
  98230. }
  98231. return undefined;
  98232. };
  98233. /**
  98234. * Get a value from its key or add it if it doesn't exist.
  98235. * This method will ensure you that a given key/data will be present in the dictionary.
  98236. * @param key the given key to get the matching value from
  98237. * @param factory the factory that will create the value if the key is not present in the dictionary.
  98238. * The factory will only be invoked if there's no data for the given key.
  98239. * @return the value corresponding to the key.
  98240. */
  98241. StringDictionary.prototype.getOrAddWithFactory = function (key, factory) {
  98242. var val = this.get(key);
  98243. if (val !== undefined) {
  98244. return val;
  98245. }
  98246. val = factory(key);
  98247. if (val) {
  98248. this.add(key, val);
  98249. }
  98250. return val;
  98251. };
  98252. /**
  98253. * Get a value from its key if present in the dictionary otherwise add it
  98254. * @param key the key to get the value from
  98255. * @param val if there's no such key/value pair in the dictionary add it with this value
  98256. * @return the value corresponding to the key
  98257. */
  98258. StringDictionary.prototype.getOrAdd = function (key, val) {
  98259. var curVal = this.get(key);
  98260. if (curVal !== undefined) {
  98261. return curVal;
  98262. }
  98263. this.add(key, val);
  98264. return val;
  98265. };
  98266. /**
  98267. * Check if there's a given key in the dictionary
  98268. * @param key the key to check for
  98269. * @return true if the key is present, false otherwise
  98270. */
  98271. StringDictionary.prototype.contains = function (key) {
  98272. return this._data[key] !== undefined;
  98273. };
  98274. /**
  98275. * Add a new key and its corresponding value
  98276. * @param key the key to add
  98277. * @param value the value corresponding to the key
  98278. * @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
  98279. */
  98280. StringDictionary.prototype.add = function (key, value) {
  98281. if (this._data[key] !== undefined) {
  98282. return false;
  98283. }
  98284. this._data[key] = value;
  98285. ++this._count;
  98286. return true;
  98287. };
  98288. /**
  98289. * Update a specific value associated to a key
  98290. * @param key defines the key to use
  98291. * @param value defines the value to store
  98292. * @returns true if the value was updated (or false if the key was not found)
  98293. */
  98294. StringDictionary.prototype.set = function (key, value) {
  98295. if (this._data[key] === undefined) {
  98296. return false;
  98297. }
  98298. this._data[key] = value;
  98299. return true;
  98300. };
  98301. /**
  98302. * Get the element of the given key and remove it from the dictionary
  98303. * @param key defines the key to search
  98304. * @returns the value associated with the key or null if not found
  98305. */
  98306. StringDictionary.prototype.getAndRemove = function (key) {
  98307. var val = this.get(key);
  98308. if (val !== undefined) {
  98309. delete this._data[key];
  98310. --this._count;
  98311. return val;
  98312. }
  98313. return null;
  98314. };
  98315. /**
  98316. * Remove a key/value from the dictionary.
  98317. * @param key the key to remove
  98318. * @return true if the item was successfully deleted, false if no item with such key exist in the dictionary
  98319. */
  98320. StringDictionary.prototype.remove = function (key) {
  98321. if (this.contains(key)) {
  98322. delete this._data[key];
  98323. --this._count;
  98324. return true;
  98325. }
  98326. return false;
  98327. };
  98328. /**
  98329. * Clear the whole content of the dictionary
  98330. */
  98331. StringDictionary.prototype.clear = function () {
  98332. this._data = {};
  98333. this._count = 0;
  98334. };
  98335. Object.defineProperty(StringDictionary.prototype, "count", {
  98336. /**
  98337. * Gets the current count
  98338. */
  98339. get: function () {
  98340. return this._count;
  98341. },
  98342. enumerable: true,
  98343. configurable: true
  98344. });
  98345. /**
  98346. * Execute a callback on each key/val of the dictionary.
  98347. * Note that you can remove any element in this dictionary in the callback implementation
  98348. * @param callback the callback to execute on a given key/value pair
  98349. */
  98350. StringDictionary.prototype.forEach = function (callback) {
  98351. for (var cur in this._data) {
  98352. var val = this._data[cur];
  98353. callback(cur, val);
  98354. }
  98355. };
  98356. /**
  98357. * Execute a callback on every occurrence of the dictionary until it returns a valid TRes object.
  98358. * If the callback returns null or undefined the method will iterate to the next key/value pair
  98359. * Note that you can remove any element in this dictionary in the callback implementation
  98360. * @param callback the callback to execute, if it return a valid T instanced object the enumeration will stop and the object will be returned
  98361. * @returns the first item
  98362. */
  98363. StringDictionary.prototype.first = function (callback) {
  98364. for (var cur in this._data) {
  98365. var val = this._data[cur];
  98366. var res = callback(cur, val);
  98367. if (res) {
  98368. return res;
  98369. }
  98370. }
  98371. return null;
  98372. };
  98373. return StringDictionary;
  98374. }());
  98375. /***/ }),
  98376. /***/ "./Misc/tags.ts":
  98377. /*!**********************!*\
  98378. !*** ./Misc/tags.ts ***!
  98379. \**********************/
  98380. /*! exports provided: Tags */
  98381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98382. "use strict";
  98383. __webpack_require__.r(__webpack_exports__);
  98384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return Tags; });
  98385. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  98386. /* harmony import */ var _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./andOrNotEvaluator */ "./Misc/andOrNotEvaluator.ts");
  98387. /**
  98388. * Class used to store custom tags
  98389. */
  98390. var Tags = /** @class */ (function () {
  98391. function Tags() {
  98392. }
  98393. /**
  98394. * Adds support for tags on the given object
  98395. * @param obj defines the object to use
  98396. */
  98397. Tags.EnableFor = function (obj) {
  98398. obj._tags = obj._tags || {};
  98399. obj.hasTags = function () {
  98400. return Tags.HasTags(obj);
  98401. };
  98402. obj.addTags = function (tagsString) {
  98403. return Tags.AddTagsTo(obj, tagsString);
  98404. };
  98405. obj.removeTags = function (tagsString) {
  98406. return Tags.RemoveTagsFrom(obj, tagsString);
  98407. };
  98408. obj.matchesTagsQuery = function (tagsQuery) {
  98409. return Tags.MatchesQuery(obj, tagsQuery);
  98410. };
  98411. };
  98412. /**
  98413. * Removes tags support
  98414. * @param obj defines the object to use
  98415. */
  98416. Tags.DisableFor = function (obj) {
  98417. delete obj._tags;
  98418. delete obj.hasTags;
  98419. delete obj.addTags;
  98420. delete obj.removeTags;
  98421. delete obj.matchesTagsQuery;
  98422. };
  98423. /**
  98424. * Gets a boolean indicating if the given object has tags
  98425. * @param obj defines the object to use
  98426. * @returns a boolean
  98427. */
  98428. Tags.HasTags = function (obj) {
  98429. if (!obj._tags) {
  98430. return false;
  98431. }
  98432. return !_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].IsEmpty(obj._tags);
  98433. };
  98434. /**
  98435. * Gets the tags available on a given object
  98436. * @param obj defines the object to use
  98437. * @param asString defines if the tags must be returned as a string instead of an array of strings
  98438. * @returns the tags
  98439. */
  98440. Tags.GetTags = function (obj, asString) {
  98441. if (asString === void 0) { asString = true; }
  98442. if (!obj._tags) {
  98443. return null;
  98444. }
  98445. if (asString) {
  98446. var tagsArray = [];
  98447. for (var tag in obj._tags) {
  98448. if (obj._tags.hasOwnProperty(tag) && obj._tags[tag] === true) {
  98449. tagsArray.push(tag);
  98450. }
  98451. }
  98452. return tagsArray.join(" ");
  98453. }
  98454. else {
  98455. return obj._tags;
  98456. }
  98457. };
  98458. /**
  98459. * Adds tags to an object
  98460. * @param obj defines the object to use
  98461. * @param tagsString defines the tag string. The tags 'true' and 'false' are reserved and cannot be used as tags.
  98462. * A tag cannot start with '||', '&&', and '!'. It cannot contain whitespaces
  98463. */
  98464. Tags.AddTagsTo = function (obj, tagsString) {
  98465. if (!tagsString) {
  98466. return;
  98467. }
  98468. if (typeof tagsString !== "string") {
  98469. return;
  98470. }
  98471. var tags = tagsString.split(" ");
  98472. tags.forEach(function (tag, index, array) {
  98473. Tags._AddTagTo(obj, tag);
  98474. });
  98475. };
  98476. /**
  98477. * @hidden
  98478. */
  98479. Tags._AddTagTo = function (obj, tag) {
  98480. tag = tag.trim();
  98481. if (tag === "" || tag === "true" || tag === "false") {
  98482. return;
  98483. }
  98484. if (tag.match(/[\s]/) || tag.match(/^([!]|([|]|[&]){2})/)) {
  98485. return;
  98486. }
  98487. Tags.EnableFor(obj);
  98488. obj._tags[tag] = true;
  98489. };
  98490. /**
  98491. * Removes specific tags from a specific object
  98492. * @param obj defines the object to use
  98493. * @param tagsString defines the tags to remove
  98494. */
  98495. Tags.RemoveTagsFrom = function (obj, tagsString) {
  98496. if (!Tags.HasTags(obj)) {
  98497. return;
  98498. }
  98499. var tags = tagsString.split(" ");
  98500. for (var t in tags) {
  98501. Tags._RemoveTagFrom(obj, tags[t]);
  98502. }
  98503. };
  98504. /**
  98505. * @hidden
  98506. */
  98507. Tags._RemoveTagFrom = function (obj, tag) {
  98508. delete obj._tags[tag];
  98509. };
  98510. /**
  98511. * Defines if tags hosted on an object match a given query
  98512. * @param obj defines the object to use
  98513. * @param tagsQuery defines the tag query
  98514. * @returns a boolean
  98515. */
  98516. Tags.MatchesQuery = function (obj, tagsQuery) {
  98517. if (tagsQuery === undefined) {
  98518. return true;
  98519. }
  98520. if (tagsQuery === "") {
  98521. return Tags.HasTags(obj);
  98522. }
  98523. return _andOrNotEvaluator__WEBPACK_IMPORTED_MODULE_1__["AndOrNotEvaluator"].Eval(tagsQuery, function (r) { return Tags.HasTags(obj) && obj._tags[r]; });
  98524. };
  98525. return Tags;
  98526. }());
  98527. /***/ }),
  98528. /***/ "./Misc/textureTools.ts":
  98529. /*!******************************!*\
  98530. !*** ./Misc/textureTools.ts ***!
  98531. \******************************/
  98532. /*! exports provided: TextureTools */
  98533. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98534. "use strict";
  98535. __webpack_require__.r(__webpack_exports__);
  98536. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return TextureTools; });
  98537. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  98538. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  98539. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  98540. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98541. /**
  98542. * Class used to host texture specific utilities
  98543. */
  98544. var TextureTools = /** @class */ (function () {
  98545. function TextureTools() {
  98546. }
  98547. /**
  98548. * Uses the GPU to create a copy texture rescaled at a given size
  98549. * @param texture Texture to copy from
  98550. * @param width defines the desired width
  98551. * @param height defines the desired height
  98552. * @param useBilinearMode defines if bilinear mode has to be used
  98553. * @return the generated texture
  98554. */
  98555. TextureTools.CreateResizedCopy = function (texture, width, height, useBilinearMode) {
  98556. if (useBilinearMode === void 0) { useBilinearMode = true; }
  98557. var scene = texture.getScene();
  98558. var engine = scene.getEngine();
  98559. 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);
  98560. rtt.wrapU = texture.wrapU;
  98561. rtt.wrapV = texture.wrapV;
  98562. rtt.uOffset = texture.uOffset;
  98563. rtt.vOffset = texture.vOffset;
  98564. rtt.uScale = texture.uScale;
  98565. rtt.vScale = texture.vScale;
  98566. rtt.uAng = texture.uAng;
  98567. rtt.vAng = texture.vAng;
  98568. rtt.wAng = texture.wAng;
  98569. rtt.coordinatesIndex = texture.coordinatesIndex;
  98570. rtt.level = texture.level;
  98571. rtt.anisotropicFilteringLevel = texture.anisotropicFilteringLevel;
  98572. rtt._texture.isReady = false;
  98573. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  98574. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  98575. 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);
  98576. passPostProcess.getEffect().executeWhenCompiled(function () {
  98577. passPostProcess.onApply = function (effect) {
  98578. effect.setTexture("textureSampler", texture);
  98579. };
  98580. var internalTexture = rtt.getInternalTexture();
  98581. if (internalTexture) {
  98582. scene.postProcessManager.directRender([passPostProcess], internalTexture);
  98583. engine.unBindFramebuffer(internalTexture);
  98584. rtt.disposeFramebufferObjects();
  98585. passPostProcess.dispose();
  98586. internalTexture.isReady = true;
  98587. }
  98588. });
  98589. return rtt;
  98590. };
  98591. /**
  98592. * Gets an environment BRDF texture for a given scene
  98593. * @param scene defines the hosting scene
  98594. * @returns the environment BRDF texture
  98595. */
  98596. TextureTools.GetEnvironmentBRDFTexture = function (scene) {
  98597. if (!scene._environmentBRDFTexture) {
  98598. var texture = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CreateFromBase64String(this._environmentBRDFBase64Texture, "EnvironmentBRDFTexture", scene, true, false, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].BILINEAR_SAMPLINGMODE);
  98599. texture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  98600. texture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_0__["Texture"].CLAMP_ADDRESSMODE;
  98601. scene._environmentBRDFTexture = texture;
  98602. }
  98603. return scene._environmentBRDFTexture;
  98604. };
  98605. TextureTools._environmentBRDFBase64Texture = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAQAAAAEACAYAAABccqhmAAAgAElEQVR4Xu19Z7PtTHbW1g3jMMbGmGDAZAMm5xxMLDAU0WSKWOQcCoqccw6eGdtgk4yNbZxnvvAL+Af8Af6AsQl+06ako9X36dXPSi3pnPu+cz/cOntL3S1pq5+w1mrpLs/eud9fvn27rf9evPPwFz+v22S7fGZ/n7/70G79J5/Xv/qzbLP+Pnvvoc/6Tz7jX/15/c62LfeH7fofbpfP3l/ct36Wf+u4+D37+XYb++G26LPsr/zFttnPuh37bm1bt0f7MvtlnOx4uv0H4fty8UUsz77rfn/57u32cgXvDv72eQf0tl0+G38b0Nf9K4Dl704MEfA16KsE8Gw9JgD+DQE8EA0DT2b7GwK4GHnF4a8iguXZt9/vL5/dbisJbEq/uwD5vIK/fbbAv4N9U/8nJIDNCazKvBLBGwdwu62OhajxmQSAx6gqNp5HCg9wPan2nwSNjhLD8ux/3u8vP3y7vbwDAYjtR8AzFyDqLu1Q+YEINnew23rPCYiKb+q/K7o4AVT4tg0t/h4ydJZfkQASQ/d5b9fZ/Z1ENmuPn/cwYCYEELBguKC3nRkCnE0AFOwOKCOAR/sH/L4hgFMpbSWP5dn/uN9ffs7t9mJ5cAHoBLTyszBAFJ/F/xIKdASw5wgaEWDMLySxAk4svf6L+4QAGPiJCziNAPb4f3UZ2dh/m+z7BK4SAPYrxf5FB6ABPgCUAfANAZwKyscc7IEA/vv9/uLzbreXzx9cQCMACAl00m8jAlF7ov6SCMQ8gJsMFFBnCECSg5H6TxJAU3vPAbwhgFfz9AABeOEDBcIbB3AqPzwQwH+731/8sNvt5Ydut5e3B2C/fG9P+jESgGz/RgxG9r9VAwTUUh0goQDafUz+DYnAnSha5l99Z1l/yQVswAZSGIAugNd/9xBgCw9E8aECkHUB22QPHIAVDlQdQAMWAibhBgZAasAVHUAI8Cqg96Tm0bj3VBS9jwd7IIBvuN9ffMHt9vLTbreXy+32QlwAhgMIeuNzKwOqCoB2Aa00KHE+EsIeDuj4H2N+Hf/TfAC6A4nhgQCQDDwiaKDXiq9KgBEJNPArAtCk0AEd2mpAizW3/lYIoANpBPg3BPA+hjs/9eXZV+0E8Bm32wsJA9aEoBCAuAABPiEAC/yDC4gSgRgKRHkAlgsI6v7iEFqJEMgBwb4BGkEfEEDnDlReoAP/SQRgOYIB+IYDMEE/SQBbXoLNr0jhq4qOZc0PHBSf5oKW519xvz//kbfby8+83V68ABfwniIBgwgQ/HoRUMv8w5qAoQqgk4DWQiCw+63eD8k/XAPQgK5s/5a5xzAAqgR6wY9k+ZEMtCOoJABb230hEHMFWQdgAl0Ap/+uc6tKBrrP/n0AuwfiNwTwNKguHHV5/qX3+/M1B/Ddb7cXax7g2e324vaQB3hhkMAW92tHoFb96cVAbimwkgQ0Vv7R+D8iACfuxzKfLvnNlAAjAsBwwP2MwLQAD9sbYJME0AFcg5uBPSAA0x0AobhtcDKDA0j3KYDhk7Hp8uKj9/vzH3C7vfget9uLT9nDgDUZuOYCLBJA8MNKPyGGIftPrL+4gy3eh5p/lwRUYYAs9Fn7tM/E9lvJwCH2DxJ/mPTr4nyyLiDtBgTAGCrgNuPzNuETgN+suEEAFhng9lkCoICMLH7V0isCeEMCxylrefkl9/uzz90J4NNUGLDmAnYXINUBrf5dCCAuQCcCvYVAYPk3G++VAveVfkIAFRLolgbr2F9ifP33pAqAV/fHRF4HcAS7AKlAAEIYFNwITOszs/wMsB6II4BXFZ0QwBsSOEYCDwTw2TsBfPrt9uLlqzCgcwFABI0EVCiANl8Uvq0JWNsi2JPZ/0YKsOiHxftsW4v51ZqAaBWgZf91PsBL/jFHwEqBR1cCiuJ3gAfCmCEA3cf8rmz8AMZHIoA3JDBPAsuHVgL4jNvt+UoCH34ggK0asIYBGArsAB7AD+reQgCl+GwZ8LaNlP3MEEDaSg4ACMGr/+ulwV4JsAEfLH42/vdKgWElAJ4QpBl+LAlKErHwt+oGMgTA2ngE4IUIOH3dGr/hAKT/m/UBdSJYPuVL7vflU26352sScCWAD+0EsCcDVxewKjfmAzAsENVn4EfgdySgnYB81yEAgL4RA8T8mTUASAAYBgylQAkL8K/+zL6rsl8qF6ArAeS7WRGoAB8Sf7isN/VZqTs6jQ5wXlweWfyqpQ8I4I0TmCCAT/3I/b48u92ef9bt9nwNAdZE4FoOFALYXcAGegkDMByAzzQEgJh+cAIs/legH0IA5QTCPADE+7ISkD0TgA/8sBIgLQfOgF/F9kPcr+J8fIYguyCILQRKgV4DNviOzoKqeJS0u4AA3pBAjQSWT//I/b5OmC0MWB3ASgBrGLA+IryvDNxCgRXo+wKhjgwk8bcTwUACsJ09ANRVAALwCxmEoFcrAUsuAJ4M1E8BDuHABAHomJ8RgACrZfQLyT9dBWi2OOEG9NJd/TDQ8HAQuBE97ZhjGKy6o+imnU+4gDckkCeB5cMfud/v6zr9Dz84gOdCAM/3JwQhF9CAD25gBWWz/8wNgMpj3K9Lfy0foMMBVffXyT4r+cceC9bvCcDFP0311QrATPkvWgosYQFLAuoqQEcQuw3v2si25F+M1RkZXLUU+CgBmCBOEsCbvECOBJbP+Oj9fv+u2+3Zp91uz9cy4Kfebs/3ROD6iPD2b10YJCXB+0PyrgsHdtBuRACfBeTN+uM+suJPSEDbfh3/oxPoHgwiC3/06j8Eutj69sAQqj++I0CUfvIpwCEvYCT90O4Pn1XsT5Ve1/+dcp9FBh3woqXBSEJkvjHHEOUPqJPAjUUCeOMGfCJYPvOj9/t7//d2e7YmAlcS2B3A8xcPYcBm/7ULEDIQew+5gS0EIEA31R8Uf6gAoBsgKwBd9ddvBBJAs6XARgLQXQ2o7T8+IETe+9eRACg7rhCMVgCiE8D4O9wOCb2ubOht1/vYd2ubzLlgKbBHEDSnAMfL6durVm8qBPwXWz7rY/f7/X/fbsvL2+3Zqv4QAjzfw4COAMAJbEC3wC8koBJ9lAhgxZ+4hi3Oh/f8dU8EqtV/JhHgWn9cC4CJQZXZp6GAk/1nawMkrrcqAiwPIIA2FwOB2oaAF5UkcX+GADBs0I5gsNbBQqCorJcFJjqWKvhNMjky0Aek7/LZH7vf3/vO2215vruAD91uz/dSYCOAPQzYkoD7vw34sFIQw4LNymNSUKk8Wv0hCYhkoJ74Q6BboO9eDKoWAHXvBiCvAdPZf4nt3QqA924AbfXV8t8uN4Bt2We029WkoErWpSoCSm11TM8AOYA5uRS4RAITIQDDavaYHxCcm5exfM7H7vd3v2N9McDt9uxDD//WKsAG/ue32/M1DEACuO3g1jkBsf57fqCL/7UbIISAio85AAG0VQEYiIC9DJTYfy/+Dx8HlpeDRK8G90IBHQbgWgD2WT8LoOJ7NyeA5JEkAwwxmuqzur5X6y+sBEwDMggrqoBNH7c68Puk/fI9Vwfwvx4e6H724oEA1iSg5AAaAewlweeyLmAnAHQCTfU1CTAH4GyTMt+QDMRFQFEYQB71lXUAOjHYlvTqh4N2xe5yASoh2PpaJUGDBDrLr9cGIDlY1l+vDlQOAQHckYMiA68KMFsGtOy65RCGsMIDT+QqJoD3yUwCy/f+6P3+7koAt50AXrwigM0FrIuEoBrwHMMAUhmQUKAlAwHo7VmAPURo9h/r//ozLv1V7/5v6wGMV4B3rwYPXEBqIZAQwp4TYDE+LQlqtQfw6my/LgsyZaeLg7wVgmDnWQ5AA5ZWCDRx7ECzyn3udgFptFCIgTlyFRMEUCKgA+O/jl2Xz/3o/f7Otz88QvpszQOsLmAPARoBSDVgud02AthdwPZ5BSxUBVr8L3kAVHrvs076KSLQi3/M9QCJ7H/G/rf4n8X41XIgcwHecuBMDgAe+BHA6uQgqnvbF5DB5hwUQM3vQgIWkKOVftH+gAC6cz0RXZ9MjmD5fh/ZCWCd1CsB7CSwhgArAUgIIC5AQoDOCewJwab+CH79WR4C0mQAZT4hEQS9DgfEztNkoEECDfi6FAhZflb6Q1XXqwHDEECpvZX4a0qP1l7bfAS98cQfzQUo9a4mASMC0CsIm6JGK/2i/QkCuFK9PxmIYPm8nQDu795uy3K7LTvwVyJAB7ARwJoAVLkA7QIkJ9A5AQS95Ad2YmgvAJWwQFcBpB38pUuB9wVKbAWgCXwV86Mz2ICKTwUWFgOxMEBicr0eoBwCGBUADfxsDsAiA+zflNay31ZcfnAdAAXgDGkcdAcfZCJYfuCX3O9vf/vtthHAmgcQF7ATwOoAtn9IACsRSDkQ/wqIIUGoXYEQQ/sL5IDJP539776DwodVAGlr5QBgP8sDdApP3gSUXQa8/rZsRaBeHmy+HwDyCI1MUNlZzX9iJSBO9igJGJYCo4RdIqMfJQ4Ztq8C7FXjHuSnQ92XH/yvdwJ4Z68ErOXAlQRW0O9/JRG42v9GBHsuAImAqv+uzDo30C3yAfVHoHeg9xyAp/7wlp+WFCSWv1sOTBb+0EoAZP5DImBrApAUMFHolQG19c+EAkbpjyUEdQ6gm/QEsCzZFxKDlWNwprJVWfBm/1WAvWrcQ0ie7Lz80H91v7/9v263+9sPI2zrAZAEdvXvXMBKBJIIFDcgyUAEvHICg/o7wA/Bvyt35wCc2F9Cg03RvRyAA34N8hD0xsIfXP7bQgDMFSgyYO8GsF4N/hQ5ALak1yUGRQDZZJ5VWXgKEsie8yQuH63b8vn/8oEA3lsJYJ2EQgD73xX4z9bs/74gaHMBQgA7+DsXAJWBBniHCLTtNx2AUnkG/LYNiUCpvX7wp6sIOHF/lwgkNf8UGagwYMgLMBdgLQCyVgOyciCGCs5nz/Jr8EXOQOcQZEbrfjjTU8qaCBseMyx4vxPB8iP+RU8A24Kg9R8Qgaj/av8lDBgcwApQ+QdVgW0bKr3+jsk//AztzBKgtv4K+Kj08rl7JFgt9BnCAIsQcD2AsQAolQj0CAGAqhOFCK5u3cA+84dyIJLCPm6buAgoBa5qDoDF6wzUkZ13iSDKKwTamSKZSf29cuzJUwq7LV/wz18RwH2Nl9dKABLArv6bC5B/+9OBGxmsIIR1AQ3w2gk4RECTfwBulgC0rP96/FYJUOv9SzkAB/xuKTBY/qsTgZ0LILF/s/RW9v81ywEwhbeAwUIH6hRwGp+wEOhqoF49fojqQoPlR/+z+/3t77jd3n3rdru999CzEYAQAYJfXACEAqL8W5lQgA5uoJUK9zxBB3ii9ALiYT2AjvuN72wFILP+XdlP8gLKFeg6f5QM3AC+VlMMZ9ABGuN+VePHWL6tHVD23or3tQPo2iWfBRgShDp0ELcBjmIAbwTWqEzIJvLM6kEDEFcD9erxCzg3my4/9p/e7299x+323lu32+oAtjwAhgE7Cazqv7mAvRLQcgG7A9B5AAwHus87CWBYsIKFfe+eCSBgt2J+7QBQ+VsogOU/9fIPBvLhASEF8AHwlhPQ2wVYFhmo/Wby74QyYLcmQAEbbbue2FcnAb28QTmHQKBwNVCvHv8IESw//h/f7299pyIA7QIE/LsTeIbqL59hPUADvHIBG8jBIWgn0L4rsKMj2Noomz8QgZELsCoAAnh0Caj8lup7ib9tX+ZBoKgUmFkWTGJ8S/UHZa/kAHT+QGaeoeQmMUC/CoAzVYAjYDvSNwPCq8fPnINus/zEfwQE8O7tdt8dwGZjIQQQ9Y9cwAB+RQIC4I4MdvvdLL+O//E7LgLykn6q3Efjf6X8bOUfkoNYcQZ8z/KzBUBYCqT/YQgjBuOBHxPs7JHh7JoAy/IzWz+xEtBKBEYg8fIGw+SeQQQ+CzHZP+oWXWPU/8z9y0/+h/f729/5kAN4791X/6/cpl4SCsDfLRQwHEBLCmJFYH92vssNgBPo7D8qv4CekIHpAjKgx1iffGbKb5UAQwdguIAtz2KsEWj7vIQggNON91lYoIFN2mznYKj9UBmwQgXLLcDstRTdBchEFWAWcLP9MgC9cuzM8aXN8lP//v3+9v/uCUDyAM0FIBFADqAjAsgFiAvYwK3/MfAL8InSd/Yfy37Qpyv3OSTgxf8C5vZXPfF3aB2AA3hJGg5LghMOgCUBo8SgEAyC3Irvh5xAwhW0cT1iQBKYWds/QQLdeVUQcrEjeGoiWH7633sggHfWJOAaAkglYL/wLQyQf3tYsCp9CwmgFIgOgIJ/JwMdBuB3cQTDX4z9wR2whN+WE9idh67761p/F/8bpb8O/OotQCsJDhZfji0qT9p0LsCI83X9H8E9KH8iCSiTrQO29bwAAbvlCipPAw4T/oRKQAVElbaMJ472t7jnqnEjrlt+1t+539/6P4oAxLquawIkF7Bb/40M9hAAHcD2GVzABmBYKSgxfyMGAbROCipl1w6gs/8ZF0Cy/UIOOr7vHAIu9iHP/2v77yX9ROUt29+AHVUCnDJgtvSn8wXsnQGzIUAW3F27qFS4z2CrD07wCogqbR8LtGecUwR4vX/5OX/7FQFsOYC9FCiToBGAEAH83ZwA5AM06BspiPKrNQIt/kcg69iffBegNqVXb/wdQgIMC0DltUuQ+L+Bmz0OrNTdK/91+4JVf15SEPMCYRkwEfc3stBxurMS0AoTMKRocaV8cKw6jpcFsdUn2/8qRT8buGeP55HC8vP+5v3+1v99cADvvfNQBZB4dO24Kv5GAntSUOz/+n1wAis4wAnoMAC/N9svSUKsBABgmwPAbQTwWzsW/2vAI6j14h+1CEjnBYZFQWSxj+sEVFyPjgBBrhf+aOtPY39vRaBVJlQ2vyOGIATQsb6etBguDMSQyAF4IMhUAmZANNNnUNSqBDvtzzif6HSWL/wbuwN4eycA4gDEBQgRYPzfSGC3/BYBdOCHxKBHBAJoAbdWfIz1I9XXsf5g9y0yAJB7iUDPCaC6e2EA2ngMGyIHwAgBldncf4ID0EDXVp1NYmbnrclOtyfDhiPOoCO4CEXB/rOBfOZ4yy/8a7sDAALY1gKAfWMEgOovoNdk0IArKr+7gwH02gWQ2L4t/sEEoLL2IQnoFX96HYC4CIz/jcSgAJSVAtu2RPZ/SPRBHkC7AkYEqceC2fqBfdKaCcHAAeAkpKVBCANcElBVgBQRTC4HngHOTJ+rQo2jhEbP6xf/VU4AmBza7L+EAZgLgGSgxP8dGQDwmQOQbS2xp6oEWAnQn1seIEMCJO4fsv8Q2w/JQU0IJMvPiCCT/NPuQP/noJ0rAFBa23VSr1N/vQhIgxzzB9odMMIAkGvFZPF6JkyIlJeFFl6IcRYYX0ciOOOcll/6l+/3t/7fngPYy4BSCmyT0SGAlgvY4/+BAET10fZjUhAWCg2AV8nBEPQ6D6DJgSUAoQ/G+Dr+T9l/pfg0HxAs/e3WBUhbsihIgHKkHGiGCQHYO/UHomDgdd0BcRkZlYtyAFlgZNtlzqkSJcwc1xr/6FjLL/tLPQG8t+YA3tuXBKPiqISgAB//bjZdkoNE/Rs5EAIYXIAKCwYHYJADlvhalp8RgS4PogNwFN8jgo1A2LoALxRw1gA09TbCAjckQHBZlQEFwEoS0Iv1S3mAYFGPlwOIJn+0v+ocPohEsHzRX9gJYM0BvPvwTyoB2gGsP6iEAowANsBJWAAVgRYeAPCb/WdkAKEAttNJwRbzM+UPQI8K36k9Kf3RagBTe2vhj3o8uAFXLxUGxTdXBrK1AIltTZ2JzUe7Lp/Ralvxvrb5kcWP9nv2fwBzIRF4FRFkx/XcwRljHCGm5Vf++fv9re+63d4xCABVRhOAJoOtRCguQKoCmghwv7L/mBPQwB/KfMQhCEF0ym8RAUkIToUAxrP/gxOwSoDGmn9WCjTzASw3kHQA5poA7Q4g3n+MEMAChiadiopXwHZV26usvB43e/7Lr/pznADakmBdDcB8AFj+5ggcF4AhgAlwwyUM6m+pPgF8U3BS6jOdAAkJ3HUAO5C7ZKBT99/IVDsGhwyY3e8qNfhCERXDa5BrlW/ftaoqe265Ar0U+PIQQCUzqwqYBYfnSK4AcuW8sjmHaMzl1/zZnQDeud3eXRcCrfH/ngNYbyxzAKL8nQNAMiC5gI0gBNz42XIBAnAkBACwqDyWByPlp2BPWP7WD0Crs/5ewq+1JaBnWX8rEajbDiVAlbNpwHRyAJ4D6EqECQcQWfxo/0wI4E3wcPJnUbSLXqH5A26qHaD9kb7ssKaj+nV/ZiSALRG4rwhsJLBfUKt/k3yAJMGwEtCFBGD/PTIY4n6d8ANyaEk/Q/nPUv8h+WeRgXYCVgIwSwbK3osKi4PonEGUC2C2Pngc2LL73Xanlj9bBTg7BIgAFe2vuoxZS14B7wy/DCT8xX/qfn/rrYccwLtrElA7AJkgkrDSJUHJfO/Z/wZ4Kx8g4IXyYKfm0i9QfkoSJK5HghALr51Ce2Jwv0ad9BvAj1WCidKfZf1x3UDnvPQ90HYf7o1WfSQMGbOpU1D3H6oCynpjPE7VfSccpoalMEHNdAxFKkDLgDzTRo5ZaXukz1E34f1Gy2/8kzEB6MUlsjCoCwWMEAAdgOcGTECrnECn+JYTgPyABn0U82vwt7hfJft0rK9DAlHooTSolH94GxBUAnTSL/reAbz6UBADt344SDkIJBIT5E62HgnEAwgFmjq3ChFkAJUFd7Zd9fwsdZ89nnX85Tf/8Z0A1hwAOgDJAxBbuU1usboYCoiCKvWX+L/lAUDlNUG0bD8Bt7dviP9Vf0v9LbV3XQCz/3qbZf2d0h8D+JAPYDb/RAfArL1l92W7Z/OjEICpOZvkw7bES0EisET7M0RxRNkzx78qJGj37rf+MUUA+zoAnQjs1gTAhJNyFy4X7kBtkYHKB0ifDMgrLiADfJMESGa/Cwe0/a+CHsmA5QQ8N6ByAzJZh1IhEobOAegsvwaVDhEKDkCre0cielYbau4SQfIZggyIM0DMtMkc6ywnMHMsduzlt/+R+/2tt2+3d8QBiAtQSUBaEVDxPyYB22cEuiYDQgJtLUFk7539ke1vgAeAR05gC3ekbAclwuaEjEVA3XoAAnLpT6sBCuStrUrIpqsBHhkwcBOVTecFJAteCAFSyk/GzapwBOJofwV0mbEQkNX2p/X9HX9IEcB7eyLw3q8IlPgSbV/LBThEIMreQJkhAeYOIsDrsELV8VmIgHX9ITGo1L+BnxGB5wQY6IvKLzZZCKD7nsj8m+sADjoAVHk9ga19tF1CzSk5GO8T9MCUAdpZbSqEUW17lpNYfucfvN/fBgfwLlQBcEnwdkA9cdGiCjCgGrCpZhACDMSA6wL28dewgKl6GzuI963EXwtf1Nr/wQ0YMb+bCJwAPgKc5gPIPeiImeUC4B5J2zbZnGXBQjI4Mdk2HFNPYqv9MNlJCJByAzPPEezIiUAe7a8ANjPWGYpePc52Db/799/vb7/zKgQQAnhvDwH0cwFWLqBluwkRYJ7AqgoMTiHjApTqR9ZfbLxbCbCUX1wOKQGiO8ASn7XdKgMimL2SoG4nkxGVnqk+OoeBDHR4AN87EmCWnlULBGiBuiNJMFC5RJB8HsACRgYwZ7WpEEY2pNEuYOoYv/f37Q7g3dvtnT3+39YC6BBAv3IK1wVA9p8SAYC5gRDBqz53QDasvag/dQboGMCy0zBA7e/CgoTyszX/VeA35QeH1YGc2Hwr2YchGn5mJNGVd8FdoEOIHEBo9VkeQc3cqFJgEkPhxSBHwoIMCVTAlx1vlggq4y+/7/fe72+tDuDdV2XARgD7isDtd95BpZWjKRUov4Acwa6BT5OEsEjICg1aBUAl8DpwA2kgQeCYbHsjL0zygfKbll9XC5xk3zYGgM1yA0IKERGgI2PJQJ20M13CAQfgWv1kEjBj+Yc2zlqAGdWPgBPtrwI2O16FXMrn8Ad+z04AaxVgTwDiasAtBNgnrK4E6HBgSApichCBBHkBCnQNbmb1iTPoSEXlDXCfTv6x0EAA2OUDtCPA70bMT6sAXjVAlf4sIhieC8BYXy0CYk5gIPKCA8CJGzoAI5QYJqoRzx8NAZ6KCLLgzra7igSWP/i79hzA6gCAAMQFrBMNSUCrFypUm+x78k/cQRffY45AqatOGDJy0CDHkh5dDERielFhWvrTIYHO+icy/jK+qe6sCkCAH70erLsXylXMWv5GFowQrLyACISU6HZ0W+RALX0Qz2ug4NgYUWScRNQ+q6IZ8GbaVMCdHS99jX/4dwIBCAmsoNd5AHAB1sRDArByAV1YgLkBnfRDF6AtPbP4LNY32lkOgMX/tPynSKFzC466Y2JP+mT+mk8BOiVAVP2MA9COgH4nQGcgHxyCAe5uMicqARTcJ+QBIlB5+6O+V4E7c9wMCSx/9HfkCEDyAMPDJiQZ2AABqtZUVwG7s+ZWMlCDO/F9iPFZso9l/IkDaMRgxPqe4g8JQa30yg14pdaM7TddgWHxXcUPVgLqvnqyWw6AqrlT0jPV33AekYJb4IlAdfX+6LwR0BVi8Yhg+WO//X5/e68AyLMAawlwCAEwF2BkpTfgqwlu5QU6G45KrdYNsNi9qwAQMgjBnyEDI77XYGcxfjXut1wAhlfSptsGoNHJPab6XkLwTAeAk1MIidp+mJlRJYCqPxCABwizr0aUDl3I/ogEMsDMjJEZp0oYjECWP/HbSA4ACEDWAbA8gJ6MjADWbYP6i5LqvyRROBBABHgjXEAV14k963s7d0koOkm/s+J+FiaERADqbjkAHKNNrsRCoE7lmYsQ0HjlPm+dgMzKRLmQkkgyBJhR/SPWPwPyTJuriWD5U78FHMB7eyJQ5QDaYiBhXL0mgGWumRNQAO/KbieTASMOL8bvVgUSq2/lAvAaOvDiwiEjs6/BThdZ6bUBJNvfuQN0Z+pzVzI09nXqrT3UMRMAACAASURBVJcKg+J6xKAnLao7Tvruc6ZcyBS6EDpUXUIEvgyAz2oTnQuqe+aYzT386d98v69rALZ1AEIAazVgz/4zBzC8aorlAdS2rkIgC4e8v2TxkOsGMLeA45I6vgZ7ygFg4g8JQhOdl+FPZv+ZnRey0CQhE4PtH1TfCBmkXQd+S+1ZXkCTiQZq0gG4sb6qMHSAKFYQHpsIMoDMtKla/syYy5/9Tb0DWGP/7R8QgOUA2NtnzEw3LhRS6hjlA9CK6/gfS4XU5rOk427p9bg02cfATtS9CwGcSsB6/taTf9Zvx0ItvQ2JgH7WgEYyMMA+5AwmHMBMDsAjAhrPTz5M9H4mggy4M65g+XO/YSeAXf1lLYAsBca/24D7MwKdakBIYOUBxKYyJ0BDAeIOTOW2QI75AgVkXNVH7b+VBFTgDisAQda/gd5LrCrlZpa/WXJrEVBk+cGxNWAkqwDMQWiFNq2/zNKgDOi6A2NFICULRAV8rrSN7HgEzmh/NH4G2MZlDi8qXf78Fz8QgNj/thjIcADtvw9HNcgQwGxIwPIGLHTQVj8BfszWmzkAlZsQwFrlPbcCYOUCjBwKKwl6pUBRWyFhukxY7LmO7414X8f61BVY4YLY9iDBhy6BTX6LPJCoPHtcAXelbQRUD+gZEojGZyCvjrv8hV/fOwArBGBLgnFpcGdJYUJ0gNknxLDNCwm8xKEV6xtqPwt4DWpm92kIQICN7bSNF2Xv/pLfUgNd5wxoCEAA34GbqL0VAmhSuMIBuIqv8wGJRUQWmCzAfNIQwV/8tff7O+9BEhBKgEMiUIUAXjLQinMbAAAcCIruFWMVgBPFX28iLhW2Yvzu+JCo06A21wAQm69XRVJwk+RpaiEQCxeQKEDlaWhgtEWQWEqvt7vhwoQDKAFfjR+5hytdgjf20X1HLH/kIpa//GtUCLATgE4CogOQz628IwzslKx0gosuG1bWnuUGotJhyzUYYUIjBSsnoJKVXZnPCAeYo3EBH1UDDIA38CniiBR/CA1I1r5VEQBUg/1XVt8jjG7iWZUD5WEz5UIK8sRagIhYquQQgfqI/a/aeBYKZMOD5a/86r0MCGsApAqQcQDbgTQBMNuqJ70GE/nuOgMSGjDFj7ZZhNABnxBTIxon459Vfa9yYpUEEfRU5RXounEUkJEgGJlEYNb9O2IQ16hsO07y9nk2ETjzJKG4JIKUSlgQKqyDzgzQM22ic/AcxPLXflXSAew30no8eDsJvBGWyhmJsKojQOAOi3R0yRFtPcvuqxo/tf7qeryYv2T/mZqT0IARgfzmG9Eg6erP8Jvr+4Tk4Sk6IwnWfgA/IxsCPhmfKWuk3ugcqENIgLwC+hl1j4Ac7c+CPDNOd4/++q/ccwCRA1iFHkqAtBrA3ICh/J46Yp7AjM+DHIK27t1aA0YIbKGPIisrw59NAOqSH/0NEKyMCBS4qwnAtNpnk4JGnN8pfKYKoIgiA2R2DEYglW1XE8FZQI6AHu1vv8nf+BUPBNDKgFYOgDkAsHdmQhAnkhP74kNDg72OwgMP0CRuN90GW+CTdCwWoVluQKv3EAYQ1cZjuOpv9JXJNyT49KIgliMwlByVu7kJUFwvPBjcQuaxYSuUOBAGZMjGIxEP1BEQn3z/3/oi4gA0CQD4uxAACMBLCKLNjFSPJd3Q7rtJOWu1oZNcHMgmE+8H5T3P3Xj7OlCzCgEeN+sEVDs8Rpu4Ol9ggd1ScuYWkAQIsDv1lrYqB+BZ/2FfsBqQAe3sbZG6Xwn2aGzr3Ja//cuJA8CnAXfr314SajgBkwBwAs6EAwmwWWFChThY0s8iI297B3DDPYRtCLi3Psb2AdRAHrKvqb9BCEyNtaKXS4OkoqAnomXjKUEo9e/GSjqAs0HvAS8C5WzfaNwKES1/95cZDmAlAbIacPudIRcgi4H0oqBuUirgU6WDSVtJsHnJw8gtZNyGWeJLEJNn61vZzYjzo/3dQ0Ea1DgmUXMWAqTAbil9UOaLynttQj+iAzibCCLQRfstUM+ShJiqqP/y937p7gDuex5gBz5bByD23woDMA9ACeCAG8jkCLTis+8ZUhjCAisZOKvwySw/OoWONFWMrmv4ZsWAqX+wrXMGbLkwnMvgIowEIWuHTsV1CTKz978WeViA88IKDzRnA/Ts8TyCcUng7/+SngC2twFZJLBPljIB4IQ1wgA9waPM+rCfJApN9Tae1beOGZ1LO06CEKj7UbF9A7CVB7AShIa9R3Uf1gOwhF9V6S1iEEQFDqFN3my14IJEYNYRTANNERd+PZMMIsXXp7H8g198v68VgHf2uP9dBX5xAtvbgaUUqEqCg/1HKweAlx9vsLeGIlqxchWojCyqY1RCgXK5jxGHofIsD9B+V92nSAgIxCEkgLEGBU8mAaO4PgoVmEJbOQQG1CzIs+08Msg6kAwRzJBOlgiWf/SLRgewksCq8l0YAKBveQAgBGb/t4vDhJQmAwf4a9dQeZPWnJbiHMfgOYeNlAKlx3BFOxs3L6B+LySS8EUg6rzwuEgQ3luBGugDqx/lCzyCGPbtCBBi05M9Io2OFB4hEXgmGLMgzZDEjIvYruUf/0I7BGgkAJWAbY46SUArGThMyAIZVADH2ppEkiCBir2n5xmpu5ME1I5pUH+LYEnFICKEDpiFEADPSSu0JhQX/MphTBFBIYnI3MRjgLviLs48H9OR/JNf4IcAK9bxPwoV9TerAXgj4T0BOJk9MhAQDZOfACUCNgIy0zbTJpPZpyGAQwTiKug7AYkr0L+N991Vf00gpGyHINbK3yZVMQQwVT2xEMh1BEZ/Nvk1EKsKmgXyGeOeTQQdEf/TL3wggNX2b/H//jqwLRGo1gC0HMCeD9AlQPw+WDqZJEZIoCdaNY6OgOmFAVq5u7ae3Y9AHam7sd8kApUsZHaekclAvrv86eoBcwkZkFvrA1hf1wU4Cu4Btu1T/c8G/hWgrxDEmSFDc0D//OdDCEAqADoPIMnA7a8wrv6LpSEFfJlkoQtAdfKShEmAWlUDN7xgOYYE6DPuBY+Lv0W0HRXdK/cN2X6l0jqcsICubbx2AVeFAK7Sy+zV1YDiasAjgH6MvqZth+vXH6sksfyLn/eKAFaw6yoA5gEE9FYScDsZZfsR8CwhSJNb2Tq5UVLsQO0lE5Pk4bqRiBDU/oEcHFVn9X1T4dFZ6TKhYfWZcltqbm6HsZm6D07QKuGRcqQGgEUKSF5N2QySYPutbZkw4SmJwCIIJIXIYSz/8uf2BEDXAWAosN/w7gUhAHwhge7GY2wGBKFtf5oMGKgcl1Cx/wKwKKQY2hWB3oHbqver7ab6J8t/2L9VbaR6sM8auk4gArlRNbBchQnSaBw5RyV7lRCAgSYCerS/otRZwqiMmSECc7x/9XNUDkCvAyB5AAwDtrlBQgG8KegCOsvolQgrgPKcQKTQSReBhOCquBP3a8LTToXF/vpY8ls2J6AdBFH/rNJfov4YDoL6UzVP5gDc8MBJBFbBnwHrWW08EEcqrvhw+5oNBZZ//bMLBCDqb7kAcAJtUQeyOuQDcGIPnzFeJQClSbJqngBULW3xIzKpkBYe3wGxkISn/u5zASwccLbh5NHhht43ELsFcGeFXwfmA1UAdBsZ9YxU/ej+zDkwJ+RtO5Mkmhh9yc+637cKwJ79lxyAlP/kKcC1IqBzAJgL0K4AQwC0m7hgyAsBrAVEaL0HJU6SQKeiyT6dWictOwsTsqW+9ttosAax/pA3AKJBEqEhQLX+T+J2PG9GEIxEPPC6ag/SNzhOtm/fZo3JABYpfLT/KBFU+leUvxHNR37mSAAC/lYBUDkA76EgIYWOAHASKnXHm4/hwaB8pIxIV8oFFpxlziNws/0diSgF91bwuQQmE7QQ+2fUvwO+pf7KkXRA9db6W6QB1+KCHu1qMgTQE70DoTOG24/Y5qMuIEMOFYBXQ4FM++WjP2MnAFUClGTg5gCEAMhy4M4F7JNou/eZ0qBWELD7qO6D0uNkZXmEwKqb4HXI4wzAa8ejLTYSjb5mfXz8jgCvlP86YrhC/ZH4lfpSFU4SgAfMo88TZFxAlRgyY1aI4Iy2zQF87KfbBLCVAAP199YCaBJAV9AlnAxX0NqwnIBSrHSSziAPa/VeJt/ACMp0AY6l1+CNvofqb6h6NikoJMMUHN2apayZNt3YxRwAPa6Tb2iTXj4cVP2MwkdkUQFz5njsGt1tX/rTHghArwHY7P++DBhdwDanYCWgzgPIfh2TtfUB+6QcJhcBedfGUXoGwAaOyXhdKy4rC1rxPAtlymqfjP0x5h6ArVSdARJdiQa6BWC8t3h8RhQ616AnY+cEigRQdREWUZ1NDBnFz4I5Y+OroMf2y5f9VE4ACH50AS4B7OD28gDtxyEVgW6yOIQwWGlg/Uz8bQLXcBoa/AM56Dq8FcMbCTyx/o3ISF3fsvaMWPRv7JLEPht08nC4TyTDb5UNI1VnwO3coaHQFPBKxa0QwAO/G1LAucwA+2oHkDkny2Vs27/8pygCANUXF9D+h2CdC1CA334rcQf7Z7yxsp8qiFpBOKhPQAiW6jIlN9UdzllAKQBjdtxT9eF8HJLQ5xNae6Lska1nSu+pfyMjb3GOlxwEYrHANwA6sO/abdBxyRiPAf4ZoGf6WOA9y0Es/+YnAwHs4JfsP4v/JSEoTgD/is1veYFZEsB+xAp7gDEX0yRU2asQaHX2wD8QjEEsCDKt0pZqM2LpSqaiiNpteCW7mQSgukc4UTWxsH0Z8EaKT/erRGIW/E/pAo6AOdt35+Pxvwf/t0gA8BKQFfzZMiDmAYakoJ4oUB2gE4UtHDLiYQSa9bnsDEhJj4HfdBYHF/V4Vn8gvh3sh9Rfk60ot7c9Uf+Xc80AkDnCNGng+RrnzCa/RS6Z8zXBJDv0ORnf9bHY96Pbov7LV/ykMQfQrQMgVQABvP67//60BKgXA7UTU9Z/mDgk+TeAndjrBtpCBcEF9Wz23on7j1p9TW74mzaH4jgC/Vtri20uDdakzvIDbTL0y1I9Gx+V8CJHgNeTBfIMEXhjz5LDU5HB8pU/ccwByBOAXQ6AxP9sQVBL5EJGF8uByPYDCehJE1UGAuB7JKD3MadA22iFx9DCiPPpeZAFOZWyH46Jk2cDPiZFRX1IvI7XrMdg2fsOvCRsYGMM25QadgC8KAeQIg5BblAajOL26v5Z4DPrb6m95wKWf/cTxhwAPgJskQAu/aUhAIB5+22J9aelQa0uOuFFQoRBCY2Soc4PNBDBMQVAGJ50amqVI8kYOH4F3FTZsyU9EvuLMs4q/NBP3SNT1Y2FPQyQcs0RYYT7JxYTZQgiAmoE/Ki/8E80DgO+RQYe8Nvx/v2P3wng9updALgAyEoEYrY/ejS4katyBegG2OfOEqpSX7s4K0QohgVUpSft+5VgR7BFsb/nEkxScByD/s31pB2IIOMSIETRE9YLF0wiOGMtwcUu4EoyyIAe79uyEsDwIhAsBSrrT6sAuyJ0i4KU6p9CAkpl9boBNuHT7iCw9vThJBJfe8erKrt2IZZjoWSIcTkLCTwVt6oC6nojwLKYvuoWIsUf1DsZRljn7m3PAPcMBY/GqIK8YU/IHTYs/+HHKQLYAd+tBCQkMIQA7L0AQAxo8bbjI1MXPiOIqMJNOgIEly4HmvsUIaUA7oQ0tD/LuBsAzTqC7XosUnAy/MwBZADtKTl1fjhB2aT19j9RCHAGOWTGyII/Gyos//HHAgEo5c8kAbv4X6m+lRDEmy73EtViSEA5pcFOIVTSMHIEAgTLVuvVceXVeFWwO3F+ByIW5zuxv1ZRRqL6d2TK64E1Y/9dIiDWfVB3veqPEcEThAARcDNgPKtNdC6Dw/lPP+Z+fxcWAOHbgM2FQKDsQ/wP+7TSo+qzsiAqk1apLmGoVUor4kTpcCCDALzZen1EQpbNp+QEjgNdiZWxN8t4pCKQUXeLOChZOFacEoFxTmzsYRIjEZwQAnjjRwCL7Hu0PxofLnVc1IM7gzxGE96vWgkAHwUWF8AWAuGDQOyhIAQ/KwPu+9t5KmVvJwXtMHSgE9BQfU0g7oMy2g4byb9ZMFtkwUCMhNDtJ2VDDVoNLBoSEBLpQBYB18kPpElkv9HM1XRzwFB85gzw2BaArX4uoRRAFYG7up+RQYYgKm5i+aof/RACiPK39wAAEbB3ArSq3v4Bl//qpcAa8Nt3QhAM7N0FE7DTSWc4goEUAAwm8Ky1CNYCG69syWr/BJBWLkArvWflL1H/iDwE2I6dH0hKJkeyYtCRFYCThSdZYLuEwo6hCGwGlE9FBsNx//OP2gkAwwBJBBoVgK4SsE8KyQWwuJ8RAoIdCQJvpMXqVnlQA3z4TpRdjsHA1IEo6hss7JFzQQDQYwaE0AHAUmMrSWgAmJKomuRH7D8DmOVWGMAjgHb7T8oBeORR2XcFOcyMyfps2776C/ocwPr7df8rkEMC23xS/0uQLgVm3IBOAHYni1ldneHVcSMJKdbJEYYOQU7BDR+M8VMZeQZUY1tHVNYxlQJnQgJNKNbk9tzGAFovx0CWDXurDkPF1+MVcgBZhzDbbgaoVWdQsftNaIHcNwLQIYCQgCh9SwaC2jfgQ/lPg92qAnQnokIB6gCUcrlVAqNsZqqco+xMtTM2/FTwVxyBofAsvGGgNe25UxqskgxV+ETIkCaCAgFEzkLmqdXuqZ1ARBam6gMAl6/5kSoEUPYfwa/fBNSeBQBi2MZW7wRox8skBgnYTUfgKLeA11O4KDk3gJ0pWzI00BOYxuhOeU9fhwXWqdg/Io7MfuJKKNhBfRrAJisAFJgH1wF4oPYAF4HxyP6oLwN6xhls/f7Lj7jf5dHf9hdeBNoRgJH5L4UB+2TSpBDmBADsCG5U9izYq+Sg25uKqqsJhnJ64JdrcC13Mfan14tAdDL76MhM0qmOFdh2fRxGJBZQoycKI7BkQZ5tFx0v2h+BPw30BrhXH7bweCOA/eWf+kUgFvjxKcChGqAAbuYADCLQ4N5O14j9I/DjftcGe1UDpn7Ogh2LhCrHfyzw098Hwews/aVkkMzkD8qd7JciggNJQItUjoC0CuAjxMLOMzz3r/3h4ADgLcDM+ktOwKwC4HJg9ZmV/RoXWaGBUv1TiYABO8ofWLHwRDLPBd8JCn8quLMWPeMkiPozK5/dNpBCkAPIgnwWiLP9QqAqBc8of6rN1/3wh4VA8gRg9AxARwI7iFgJUCcAKwlBFg50lQIdDoCbMC1rpYKQrBygW+kUMcjkR+CsxvHus/sReCPQRvsR0A74rPCBnXtK6ZVTsdzgYwK+ovaVthE5zCi/8MnydZ+vQgC1AIiFARveINHnJQMbNlHlAbDbiTj7NBmUiYCoNqsiDBNUT+YjoHaSh3Lz3BDBcivedkaSjvqa8X2ypBe+QEQBVl9vBHrmCCi4H7EKcJban00GFcJYvv6H9UlA+i4AXAuAZT/1WWf/LdXv8G6VAQkxlMHPMsJFJ3CJylugstTaU2FPdT3wZpQ9UZ4LiYvU/TswJ1xDRsWZ88v0a0oIFjtDNt7YEQCPEEc0dnX/AwGQ2P9oDkDCAvld9XdP9dEV4I3tbpaenMZ3V2lIn0yCSlv0wyTh1Nkz9p6ppxVGoFU2VV/UOqn+6NKiMbtzdQgmcgRv1P/hJlXdw/C7/dcfajsAifeFDESU27MB+wa5jzoUaOB3LD4SA4v9NVF4LgAnd3ehgeozAHugHianEx6wCR+FG2YeA294whVQYtjvWQRUMw9BlDIkG7b6j4VmVrusOp9s/y0ncJX6R+POAD4kiI0A4L8BQ+Uf3gfg2H/2MBBTfdP+C7vAzdaPAFfIwLSERHVoIoqUBjNKm3EDGVIwx8kAOFLuaL86hkkkxcU/jDgrSh8CUhG9B6iMzc+0iUB7xO6H4EWszLqBb/ghJARgTwKytwI7OYAhBHBcQDYckOtlTmFYABIA3XILbCEJ3QaE1ampsRItHTbsF+mqqpUryCzZzYA/QzJJN+ICPLFqLwPCI/F/aXy5N4YjiRT6akB7BGmd2/INP/ghBGjJPwL+1QnIfGf2X8CuQ4GGEZXoO9UFEOdwhAxYDiCtXE79ngKh2t7LFWTAHwAbSTEKEby2kaqznEHUJ6XmCUJJjaPUdFbFK4CvtI2IprJ/+caVAHQSkD0ObL0MxCgJbnNNqb7+XlX+KATYLlwdky4NZVaRxY/ZcMGLZwNHkCaXCPwZ1bbOBZXNyS0wkJruSKmll1w9CsrHdACzZOBdYwWwYj7CcAhcijf+8o0/KHYAkgzs/u4Trqm+/g7gKYUDRNG7F4jKhTlAbz+SbgNjdz+g0S5yA0wFO5AQAnHVzwOoZ/vPAn8yMeclKSMlPwOspm1nhO2oeRZEM+0qgH8q9d/O8ZtWAig4AMGQuRDIWQ48JAUBkO3eRcDWuQSi+pETQOBSdpxQ/kjJI7IYljkrVXaBlajpZxbqeGrOQEDzGqA8OoywfvdqHP5+IICznEKFSDJOYhjvm35g0QEkFwIh2Bm4w3AgcAJ6MrV5R+y9BpcmCFQl+oOz8MByE0qNu/EK4UDkJBihWHF7Bvz4m5jAJct+I8Wn+6+I1a8YE0k4+OwBtaLwlbYZwIfjrQQwrP4jK/82+6+2y8q/IQmolR2SiNvvqFUc3x/A9jOwESfAgB6BnxGJFR6E9tWbhJ499ey9FUbIhDT6ejadAjwKMbSVtkgxY7kvAOuZjwFn1fvq0CACeAhucGPycejzzT9gdABYERheCLqDUQhh+0qeC2iYNcBvWf4wMWgQhE7+CdHoC04TAlFy0zkY6+41udAJkyANar8JKVIHEBFEspYfOZLIxofkmSEOr82B+H9WvWcIoALaStuILNj+bdtKAF4JUKu+uQpQx/5AFKj6NBwQeiLOYCCxKEegCELb++GHcCoCA2taYHXU0IrtXTJhjsd5kKcDpziDBEEgQZkkg+MBWVigiYjA/T3gZofjGI4kC+azwTszXgTaqwlgHX/5ls97tRRYVL2tADRCgUH1yYKgDofE4nc4VqDG/EGbE0ZiziMIF/yGYlCHYJEKKzviJLaOEWTbQ5CQpN9AAhcoP5JWGaBA8lmyKYHZI+FgldwMeLNhgncNlX0RWczufyAAWQqcjP2tCgACV+Z+t0RYAUmIpAOxEdtHTmDbTybBsHaAnIMmiuHmatcBk9m8iexcEgrqVgP2c6cxvFL+LMii2HkYJ5Er8H6TaeL4ANj/CKSPofiIowcH8P23COBGnwHQhOBVALxHg1l4kCED0mbIEVjqTIhk+4GT26dJIXAF0yGBQR4U6MR5ZNsNTkIRS0mVsa8ir+o4LnF4ZKvPYXKV3xWK/1o4gG/9/ioJKC8E9dyAAXaM75sDANDp+N8LA7p3CyjF1Y5B3xxKEsZ6AVo5SIDYZHMvGRUlqqLseLCSbzunpBVGMsy6hTA0icAWXf9sIjC45irZyPzKuJUjIH4KxR8cwLd+v50A1PMAmOzTnwXTYvkld7Bth5uM+9uBo3yAodKR8uP4HUEQ5dFtGYEM25QCDwQQqVAEzAgcQdx/JvipC4jICX50Cpxk/wzoorCkAsrM8WbHM0WCEGXU9qr9y0oAWwiglH8LCYz1/w3wqvznqr5BDhqsUwuEqg5BkUwHdgOI2yGsx02tHIHcaGd/pMQIbArMRF7hCGAwFMqAxWwTEdys+sO9zJzfjBuoKPVVba8lgGISsFsApElivyE45wdXADdNhwUdlkm8nnYCCeWXY+l439tecgvG5OxuZqSMjnPoJnwWYJETYUoenWOkaBP9M2C2yDML8my72fg/Am2FLKKxZvZvfb7t+77KAWxOwEj8NXUHp7DNb3QBCvwSAnSCq0MAQhiitugOcCzcbsX71qrAri9OXEY21nMGHUu9GnG4oQVncMg2Z8FPSDEFNMcVHemf6ssIidw3a6wsyM9oVwXhUQLwznkQMVIKbQRAV/45RKDJoAHcIQMhiwjUQwjQscer3hYh0BWBxhhCNCzej/ZZx9FuIsolHLbMFUWfAXIUviAY2ecKOUVjMTIoXH8EmAwhRSA/Cuoj/c255pHot33uQw6A5QFku5cLQGAjMSDmLCcw4BImixUaCDCZkntuwGtPCcABCx6nHBJkVDg7qSuvwEoAcQDIBPi9MTIAKyt59rcKyGWWHCr9IvJ4kv2NAII8gIC1Wwqs1wUAoi0yEABrx82UP+sGziCFDsgkHLDyBN1N80gjqCLg+CkQJOPqdn4BUOhEniENVJtE/2x8TduRa/IAmT1WBMSzxomO8yj7P/65r1YCotIPn0m8j28BFpVvwGdkoCRf2/gOd1k3MNgImIEEyBZZYEKJugVrHYEoi3EsTSzu5HEIZCCFyuQPnMIl4If7kgVMtt0hUkOCMj5XgVex7VM2XU3IlEAQxyPDdP0//n3GlYAh+FWs370OXBbbqWSfblNxAlbbsuUPyMLLBeA9YLafTZruB8+AO2vps+32650Flqem4b4T1d881oyreWICqJLL1e2XjQDkjUDkmX+d5WffEVeWE0CBNJU/qfq6f0eQBdVv/Qw1tdyCBWzGsDJGqBIZgiCAzjqK0kQ6A1hnjOGBNUEwIUmd5AAqxyndB0PFw7nkOAY9R5ePf+9XSUBGBAJudAVt234Ttn37xi4ESGyTE0rnAIBtBqwfAD/+Zl68r8nGdA3RykEsy2TtfJYkKsfWk+wM4GavJwnA2fj/CDCPgqzSPwoLov1HSOUVAeBKwGgtgJH80+AfbL8OC9A66Od0gFy0UiuCa+Sjt0cKboYQRGmHsR0w4vmGE0GRltk+AapuIlTbG9dcDh8mxpkCauL6wt/eUcojfY8AUiv0Wd+tc3ogAA/8xsKfDuykTVP2/YO1GlCLNnUCiii0Cpu7LUfgjUf2WTG/JgXLORwFtbkE2VLQRNKPTgiHjNKASBw7PZZ2J0Vnc+Q4ugsk6gAAG0BJREFUVVKKQH/muZxKCp/4Xv3DQGLn0fI3sEerAPVTghAaaFyllgcDi1Asq43t6yzwI2IIKgHiOFKWjZyjZ3XZBMuAOJqYbTJVwwuDfIb/l8FR2cy5VX6Ts0HmZdunz90i7eClJZnjZdoMv1EjAMcFbLiYAT+x8TpX0DCeAHPXxAA5XTug7YiW7on9NPYPwgLtEEKiSNjcTg2y4YSehCeBv+xUZid98ne5khCmwHaQDGeOGfVZVgKwqgAiiBH4U2XAfTCco1qxNcAZxiOAm+J/kSvwEoYU4Anl325ath0hr5BYNPDYq9Sr4LzY+reJfBZZVa/vhPYRGGf2Z/p4bZZPfM++CmCFAF4YIETR/upnApw3AqUJAQ4ShQPD/ovA3wjdANDwwxvKZbVjN45uSwI427eqnIywpsbIKOT7iAAy4Ix+p5kxMn2kzSsCCKoA+AiwJoOOAJTtF8vPSAK3NSFLhAJdPwLuTKiwHc8jhsx+1YaGBSRxJdeadQgWETBVTJNG0mVEE3TbXww9yg6lmPzL/gapawNSitpXgIdcF40783tlzmUd94EAEiVAuc8m+HWOoCH61fxAy19R/mplAElHicqrryeD3wM1fVkpm1gBkOgxHEV0gZA4VnpiFlQ5MzHNNoXjpM+9APBozKuI59BvpgAwJgE/B0KA6CWgrP7vZP4bWcBJZJYEI1FYQuzlAtw8gTFg2jXs12I+diz7gQA9tu/2GaRkOQvrfYapiZgNR6znyMn1zQCkpG7GOZfG0PenQAAZIM6cS2bcq9osnxAC0C6AgH14+Ie9EIQQwoY5FRo0HAbbKY5In3Yf2QtHEGVWiGEAVhHow1cHPHgeJnAZqAIll3GrSUdKBkdyBmQF41WTsxv3LMK6mAAe5bdwSKt6/AcCMEIAmevrbz88A7Dv1CofVQQ66w9ftAJrMdSuAHD46ucIiEGDeRDcKCwgB43KgZYa47l4biIav0QyybjfOufhWGcRiQHK7nivKQFUATcQ+Ylgnhl7+cT3sEOARgDO038dATjZ/w74AKTM9q05AScjBY8YEHRVy4/Kr4mEKZXbRnaSa/IAvR3HISk3CZkkr3AMOPeM3c2SiTtWAfyzgDyz3+xYZ/6e6XPoCMBZ9tuAboB8cALKIbT5x54H2CeVBrkGOHUFHjFQNlBJ6wnVZ+AWgogA3Fg6cVymuJ1zME/kYQdT0CwgXTUpEFdmUodtCgQQjrVf2NXtMuNn2lTu18x4rxyACgO8sp+n+ts+A+Rs+a+0Z1jFfXS/ASLLGQxjJEAYlgpn1FwdN0UazloDD6wR4aQVH4GTPP+ZCUkn/MmhxtWgsu7H7O9x5fkun/hsFQKw5B+AGsGfjfc9UrDIYjukmmjatlv4taoAFduvyccFWYJIvOSdFvIo7s8Avps0ScBaE606VoVUdFvL9byO4Inc2PvhnEcC2CfL+mf7p+P//ar1dgTsEA7AmJ1gFrZ36k36tXEjV8CshFwT3tEsqBPt2rDQNqX68GNl2kfEUQGmpcQR+VSOkQJIQf2vUMorxkxdd1R+hbl6aLzmAMhCnuEZAKPmrxW+EYAFcGtpsLM9dATgUrSiMvLQbSruYArQCaKIAJxyCjgxnGN6hGLuyy55npicFuEcJZSjAD7aPwvOK46TGfPBAej4nz3959T8B8VXYMR5aK4HIACOLD8DLZvzlp2nZiAB1G1+J9pVbD8jrdR6Awts5PymQL+Pf6j6EBCCNVHN/7iV/lgq6XkWCcn1k2NmwX2UxLLHyQBeLkPGXD7x3cccQGbdP1P9UPmt5CAAqiMLOVvD8re2XkjggHXASALUWfAzl4BzKLT0wblk+kdt0vuNc6lMbBPkhtU9tMpRgfUogGaApfmi8lsdPd9S/44ASLyPQEelZwlATQqIPU/56ctB1MtEGI61slP1NybvU4LfELBXmxMZfzZGxnGkQY8HgB9rxkVM9XkK0imqfYUYqgRYAnHBEelxXzkAJwcg4EOFz9p+5hSasBPlZuGCMgIPIkwmiN50RjWg+22zDsFxHRnwR21cEKtzjADvTUx0OzMgjsY2VbEI/iq4ps+L3JiKslfPszJ2pS2exwMBZHMA+8Re709HAGxxELTtnACgWZNIa5ew/APY9c0xngno+qlBXHxfDP7tBlaOwSZjsn+GFLZJciAMOUQYRQI4dKxHBvWVJDAz9vKJz4rXAYjidiHA/sPRtQDWE4LGOwIt1e+2KxvgEsD7DPyotNPqXwQNO84ApIkxI3IJwXryMcPjnUAAVeCd1f6MaxsJgNX9WXjgKbzlCIwyX7vn3jJhpZCUAGBjRBCKTzjukoraOlfbp04iooTk04mFic4I6QiwvQkvp+XlL44cewYkZwF0uDZ1D2Ztu76VR8ZZPv5ZDxpOwwDr+X9P4ZV9b66B2HodRmgXnHEGrc8Tgz98B4GF4wJp0Bud7B+BqDu9fcxMn6hNaT+5llL/IsnNkMNMn9eZUDYC0M/5I2jXzxqowzaw9l1bZzsCl1p9I1zQJCHkhffeVH+HJBgA9HwysZYE4TA/Z/sZziECi+clPAXOKg62y5xLFHJMjZFU2ciVnA30GRJ4jD7Lxz/zVQ5AwFVa/rt3osAv5gIQ3A+25OFuenbefV6AlBLZeBb4U/hMNSLQC8gonPyzx7Xq7gapyObwfKJx4SfIOJmzjveYQM78VlW7PktU2eseCSCI9wegW5Y/SQwakDpksPYLM1juofVTQHFxE71NKGkJQmyGDTyt9qsFGeCYo8N5ZcfJtnMnsvo9smNm2mWBUHU50bFnjvvYY67H6wiAvvLLyQPgk3xWqKCFRZSdAbdti5KBilws8YrcAd70cgxfJYtAYQPI97uPEog62DbxCmNGE7UKJjx2duwz2kVjXLl/hiAihzEz5isCCFYByhzRCj0A37H92xjE1neuwtmP/V1nQBYKWfMbQ40MCKvtD5EMO6ErgBqMGQGBnWa6z37sdPujoUYUipy4f9a+R0A/c9zl277bXgXYRQABjsDUIK0Anym7DiW0m2CCaS0ZHsggafuzYO6GSwCQNkn0CwnojDESYUwFjDjcTL9osVHZTTwigCMgvu77txCAEkCy7s9IAcHI3IIGNoJwIAV0ppmwYD+4xgn9HoCpAuIQl0aDsF9nH0J6KDWo2v5DKk86zxy/QjCZtq9Tm+hcrtq/EUCn9M4LQIYwYL+x5mpABUgK8H0jgmH47IC/U38Sl1fBnwV+GryzuYILwd+GTl5ENPmyzNONkzx2xg7PklP2ujLtHqtNdJxov3YljQBEibW1t7Y34CVW/Wngt3vv9MXxB4sPd5w5CBY+6PESTvihCUzU7JzF68uCwzrnSnKudCx1MZmJUxo/itWTP+bMeWX7PEW7s46ZGSdq00IA+uYfou4DkEG9vX2W7Weqz8gBccjcAQNPRfnNuUjcCQPB6a7BZIMqBI32SfBVjhZNtm6sxPFL48HglX5XtM2OeWa7zFhWm+VbP6NPAgrYXOX3VH8fwFT9qEqg+rvq76izRxQZfEVlQXcOJ4nDBdgZY6TZKoZ6ZpLFo4iq8JZHj1Htf1X7K8bNjDnTZiCAyPLPxvs4LnUEiaW/HaifCPyReEXEkSGfM22/nO82OaKTTyP4QMOLQo/M5NdnfXWf6viZ9pk263Vm2m0hwOoAUK3NxUCBsrvEkFH9YI1AN3+zFYHki0M6UBog8bCDYcth0SUHOgW3pwxyAPiJ9wvMjp6Z7Gzsx+pXPU62/RntGgFYyt/IQVnS9au3DwHL6vc6RIjWASDIBntvOMvsSkAPwBZuuu0HQBuNUwUFPd+LwZ+diFc4kPSxyQ/52H2rx6u0z7bV7ZZvkRyAEddr694BP3IFmXyAE/NHlt8iAv2fjXju1wJ/Cvhq4AzOzDZO58y4mXxClUxObX/4IvqzyU547xqOjnGkf7VvpX2p7bd8eCIJKIpLXAFTfq322jl0feCOee00qC2HYIHfUt408GFgb26n5v0JawVmiOVUgHuDpX6E+GwqEzseLRcnXz3OzDVV+3jtl5UAEKAIOhO40WO+mZifOA5KBEG7DuCJhUADIcDkZPPUJIQDil21/dP4KXYsNs9g46HNgYGrkz1/UucRwHrMo+c527/abwwBdgLoSIAou1bjSNU98jD/81Ct/t7/IyAuRPocAH9F9be2pEM0x+l+tTEag03u11H55Zy2yTZzURUUH2xbBVDmcEfGfOy+yzfrEMBaCrzfTAbsiBwyYcGg/oSEAOu9sKi2oe2fUP3WJQnacN4XbH84lp6VB9xJZoKn25RPPD3yaQ2PAC5zEkfHP9I/03cjAAbgAegHFv9YBMEsPyqsPgcNbNaWgb+bh4QsNLHgjWV9Q4IxZoZFIubxghmWcRWZSVrgj/xwb8Df/VYZMEY/7hVjPBAAgIIqvKHGkfJ3Y0UEsl99+L4AaQcoxLmm593Z4Gfz2pvrw76kg5giBXIiV+EwHDdsEE336/efAaiZszzzuEfHWr7508k7ARXIEMjMGZhKnnkpKGnDxhu2ESWfAX8K0Jn/ZwBmgjn3E7Y/i5uIWDITM3uszFgdYV01cPVEgvZHwXP0dK46fmXc5Zs+nZcBN8BFqn10v7H8V5NMZ7kTVYHBoicBTMkgqaqhC3AaRHiJ9m8TccJZeBM4dUw2wIHrjABVmdjkJ2nDV8eJzuus/VeelzX2RgCDwnuLghxV74CbedQ3Uy5MvBQkUn53P7odreIJUFnzvdueGKdq+b3xLwF2NqE/zRxnweiDNc6VpLD+Uo0AGnjBWg92f6dVur2yNFhA59h4nEfb5+T6fw2MCPxU9ZV8mG3UXKNzn1yjnqIRZtz9RXIpinaIplkiCgd+08D9Bc4ihuUbMQRQkzXrDBAv4UNBcllR+IDK/Ejgb5MZZnVEIJ7V9J4M9EAdEUI7ZqZhVrkzZJawFslTegPvR/gFMiSxEYBW2PX7oPIROWTe+JsIHzoygS/6fDTwjiq/Bv8s8BmJAOfR2x6BxnMW1dDBIyxrTkbnt/VzGqX6PwIgjhxCX0MGXEeO9xh912t4IIAo5nfAj2o0kAaqeDLb341hHNcDf/QEoAvsI8lCA4nW5D/iAE5558ABxR/O/SDCD3a/DCuZ83q/E8HyDZ/mVAF2pCEoKcizdj5DJEIaVfAnlgJXwT/lApxS3wzoM2DLTNSK8mfHE+UvtS/A9apxM6fwlMeW81vJ5WrnsREAA/W2LQHsVMyfGKez/gr8Q1ignEXm8V8PzFXXYIHJUmY2mWbIwPq/EvWEzkzeTJuQNMgg2XEzIJwJb6rjHgp7zjrYI43D3MryX8EBWHZ+VvUtEmGAbseAGUSPWwT/2apvglntOAv0bRwDWRnAXdYmM/BkEvKpgZm8tEeC7nWH6QhgRvVdkColt9rKcT1ioC4gsP0V8LttjUnMwFkBvjXJhu2EFGcBEk3saL8cN5uHmD3PaMpnzzMax9v/GMc4cn5n9N0IANXXBWnmPQCi0Enwb8AO2mbAXwFw1fJXiKQBxLg7FYJAR8aGiyboZfvVwNFxMhN1ZoyZPplzie5hZYzXve3y9RICEBAOZJAEdQnQxpiuG3DWBWA//RnJhu5TdyskFTIDKwBPtU2qfwQGb3/Ut/utEo0TTUxczPSd6ZMF5pVjZ88hanfkHDcCiAC7HSAqFQJthi4icAlU8YMyImPtAcAOmLBtCHzCHikwR6GEvtMnVxQY6ZFD2vMt8TDTjFN5yj5Xgisa29t/BNSV4y5f/6nj04ADABNZfI8kqJor5XcVPwF+D7RybimSgF/PHDNQ5YhAPCC2vkl3EYF6VvlpP7VxZpJW+lTasntbAYLVduYcKse9evzoXJav+9RX6wBkMnUKfgH4U+VFDcTkcmANCAR/SBIF8M+CPOUUCDnijZwB9UyfDlSJmZpo0s3HTPtMm7McRMkNRcgK9s9e18HDDt03AugArx7qMfftQ0XKP+MmvD4U4HguhDi8PpV9mfUGTJFToJdrMGaGNWHO2u46iYCQjgAwC4RsuyxRZoA0c8xo3CvGjI7p3dvla4kD2Dqom06JIOsOEs8A4A9jOZCzwV9yBKpxBtSZNt01JY5h3cwzicA7p84VZGZech1AFhjZdjPneYTIop+iet7ReGed60YAFuBc9T8R/IPiF2N+Rh6RWtM+xEmIw/EmlEckacA6KnsGuL0JaO5LJv2ykztqF+2fBXV23LNApcc5cnyPCM4Yd/kv6ACyoM62q7wSTD+BaDiQlAuYLBNSIBeAGRGBSQbkTlZAf0bb4dySbqQ62TOTNtPGDVkIarJjnkkCR45Z/V1nHMPa5xUBwEQ/TfnhF3DHJC8TYa7gKPhLqg8Hi4Bd3W9ZbDZhzgB3ZYx2bs7szUzsqM3R/Y/pBqJzPZM0HgP4eD0bAaTi/WxeoBDvD6SQIAzG/K1bslJgEUF3o48+XUhi32EiFev8WYKYAjzOPBCDSFkicHj7o75Zlc+MQy4vurS2vzp+9ryvtveZ81i+5lPGMiBT3zRJ7J3Tig9UHvVxHYC6SxmQm22csVwC2q8lcgTbGGRWHQF4tq83KbYxjNkegWAW6NG4mUk84wYyx50Zt3K+FgFUzu2o+9gIIALeVeBHuxmdQxb8VeAP48IAEZCn9zvHsCZQFuDZdvQ4CeWPJudTE0F0fjNOoDLmEQKoHmfmWjRhLF8dOQA1KVygFpKDrwP4B7IwgDkNdOYIDJBlgXt2O7wPenJEE3IG7DN9qhM9Ou8rx5slgMo5zzoT5hY2AjBBfTL48cfZhs6+OhzOvANtArBpR5AA5mEiIHc5GjPrCLLEcIXyW5O3uj07sTNgybTJgjU7Vna8KtEebe/1X/6z5QAmwT+AnL1g9CD4hTzcsMAiDba9mPCLQEv3G2RlTfoMoDNtvEnZ+quBZlR6Buwzx7lCvTMAz7SZIYDsuFlyZCrvnddGAIMDCMDfgbxCFIkKgUcg2q6m1X3/VWj7yTUD7Ec1iSHhLrJEcAT0dLIVKxHRRKwSQQSAq/dH15PdX2030z76LRj4oz7LV2kHQJRqIAgB1GOD31DRChF0bR3lM8GcKO91fYvuwmJr73y8yeQSRlL5zwL1rOJHk/jo/oxyR8e4GtDZ41fPoyeAQhKvVBk4Q/kD8FdIYLvhCTLxQozIAWzDBwCLQB3tj87BnQwTyl8hgkrbzKSNAHD1/gxJZNtkrhfVPLo2rfyV9hsBlMH8RMpfBjn8MpbyZ8asEEEbT/1GFZWOgB/tD13EBcpfBfwVbiCa+FfvrwA7OpfKWLNksZ7D8p8+lFwI9AS2H1U0A1Rp47YlwLTaTwF/7xSB9Oj+I+pfeX15SCYGyWYm5etGAhlQPmabqxwFjrsRgAaO+f0k5ccTcI+dBGuaHJLjReByCSNQ16PAj/qHgIUBKqrN2h7tH6ncFQQRgSoCeLQ/Gj+65gxxasufPSZrt/zHrAN4jcCfBjyG4RPPCZQdgAOuCLgeqUSEFIIeZt0VQD46pjeBryCBCMRX788CNjqPCplYx9wIIHQAB8GfVvwT3gNAgTQBflflme0l7qJCIDMgzwCvtQmcSZpECi82rTiECBTVsWbHi/pl9kdtzgT20bGW/xA5gNcc/K4bOAh8D8DdD3/kPygplhVLoL9Q+TPnESlUFdTV9rPOIgLw0f1HQRv9rjpE8I63EYDpAF5D8LuAP2j5o7GpSkMn/UNXvlfaZtxCa3Oh8lcAWWk7C9yzjpEFmAes2X3ZY2dIKNNm+feWA3hC8FeASNuS9QxZNbeOTfur38i6edkxI2BnVFc7kyPWPnO8yvhntI0m9WOSwBGQRy7g6P4skWwEMDiASfDjzTFdxX5m3f4CYCNyyCzwicZIkQUBv6fiFYWvtDVB9cjKnyWLqrqfBehZsM4CcbZfFrjR+BFRynGWf6cdwCT4GahSJBCAPwJrtx++6GOnQK3icVO5T3p+oAL0qG13fYScvImVAW/p+CoIzYxfPb8qkUSAuIIgZseMzjWzP9NmPb+NABpYXgPwlwAPE02vZjwT8BHJsMn7ZG6AzLoMAM9qU7H5Z6j7GWNkVLd6nCwAFVe2r5HCn7V/+crVAVSeAUALbyjhrPJ7LsIC9NaHKN4lDsBQVtMpOI7CIyg2ebxjzKr/DOgzfSok8NhtI2CeCfQjID3SN7pG3L985cvEOgAE/ZFXfSceCio7AMO1uIShriflFhySqQL2DMKgx0yofwbAnnupALYCpsx5PUaY8H4ILSoAjxzG8hUvi88C7Ee3VB5PjrZJuA02BgVp4EBSwM7E/cn1BBVV90A2tQ86RQCOCCuz/ygRZAF/lETOBLSnypXz9Igssy8igIp7WP7tTgAhcCfVuyOBE8DfLq4A/shVuERhAGsKpBeFBNH/gmRNqogoov2PRQJHj/MYJDBDDkeAPHs8fcxGAJaiVwHMwLZtS4Df7Kst+8HKgQX44fj7hizYz24XKbH8rmjzItAe3R+dU9WmZ53AB5UEZoE8228ggH+TdQAFADMgpQhGAZ0SAlHkSOGj/VZ4MRNCZPvMtuv6JQgqA9gqKWTBmAV3tl32uGcpvgWy6vZZpT8L5CgQlAA85a2qtwZ6RflDB5AEfwT4aL+21Fb7LIhn+kfAzfzHIhVgR22j8zmq/BVQZc61SgKV41fH9n6bWXI4q9/y5SoJiAMfBb9Xm7ccwXB8cQVE7QayIW8groI0s5KwOmYEHm9Cm/suUP+MEp/V5oiaV8B6VdsZEphR9Jk+FXLYCMAE0oTtb2OpCZoBq+kAjLFMsgDP4x33TOsfugohMnJuEUEM56lmRaSIV+/PnP8RwGfHrxzjyrZnksPlBPBlRhlwxrpnwW8CnWXJC0RymBCS5b4zwV5Wf+hwBNhH+lqW9rHdwVF1P9r/dQZ6ljiWlQC0SjIbPLRRilYFv0cC7Yc9WOrLAFWf94y9n+ljnZurdie8YnzquMS9PAUJHAVshqCs63oMsFeuzzvPaB8eZ/lS7QCU4jJVNckgUGurH1XuiVJfilSYFTdUtUIgR0nA67/tU7OjouBll2GEKVnQZ4EWXUPFps8es3KM15EEskoPt3T7KP02AojUO0UCk+CnoCWAzII7Au2w3yG8o6COzoUBioKCnKPrFBjJqRlQcQLVY2WJIjNuBaCvIwlUVX0G0NVjdATwMXEAAYBdEnhC8Ecgc/efGPNH5xFNdhOQRdt/ptpHCh3tj675CFE8JTFUjv2UriFz7GUlgOp/DNKRwUHwdxPfUeMjDoCCq5BfOOoEZvpr2x+BLavolXEyAM6obnTMzHEqoMuc09HxKv2rbTPAVYZO/ydUbXfkKP4/BnecprBuissAAAAASUVORK5CYII=";
  98606. return TextureTools;
  98607. }());
  98608. /***/ }),
  98609. /***/ "./Misc/tga.ts":
  98610. /*!*********************!*\
  98611. !*** ./Misc/tga.ts ***!
  98612. \*********************/
  98613. /*! exports provided: TGATools */
  98614. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98615. "use strict";
  98616. __webpack_require__.r(__webpack_exports__);
  98617. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return TGATools; });
  98618. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  98619. /**
  98620. * Based on jsTGALoader - Javascript loader for TGA file
  98621. * By Vincent Thibault
  98622. * @see http://blog.robrowser.com/javascript-tga-loader.html
  98623. */
  98624. var TGATools = /** @class */ (function () {
  98625. function TGATools() {
  98626. }
  98627. /**
  98628. * Gets the header of a TGA file
  98629. * @param data defines the TGA data
  98630. * @returns the header
  98631. */
  98632. TGATools.GetTGAHeader = function (data) {
  98633. var offset = 0;
  98634. var header = {
  98635. id_length: data[offset++],
  98636. colormap_type: data[offset++],
  98637. image_type: data[offset++],
  98638. colormap_index: data[offset++] | data[offset++] << 8,
  98639. colormap_length: data[offset++] | data[offset++] << 8,
  98640. colormap_size: data[offset++],
  98641. origin: [
  98642. data[offset++] | data[offset++] << 8,
  98643. data[offset++] | data[offset++] << 8
  98644. ],
  98645. width: data[offset++] | data[offset++] << 8,
  98646. height: data[offset++] | data[offset++] << 8,
  98647. pixel_size: data[offset++],
  98648. flags: data[offset++]
  98649. };
  98650. return header;
  98651. };
  98652. /**
  98653. * Uploads TGA content to a Babylon Texture
  98654. * @hidden
  98655. */
  98656. TGATools.UploadContent = function (texture, data) {
  98657. // Not enough data to contain header ?
  98658. if (data.length < 19) {
  98659. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data to contain header");
  98660. return;
  98661. }
  98662. // Read Header
  98663. var offset = 18;
  98664. var header = TGATools.GetTGAHeader(data);
  98665. // Assume it's a valid Targa file.
  98666. if (header.id_length + offset > data.length) {
  98667. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Unable to load TGA file - Not enough data");
  98668. return;
  98669. }
  98670. // Skip not needed data
  98671. offset += header.id_length;
  98672. var use_rle = false;
  98673. var use_pal = false;
  98674. var use_grey = false;
  98675. // Get some informations.
  98676. switch (header.image_type) {
  98677. case TGATools._TYPE_RLE_INDEXED:
  98678. use_rle = true;
  98679. case TGATools._TYPE_INDEXED:
  98680. use_pal = true;
  98681. break;
  98682. case TGATools._TYPE_RLE_RGB:
  98683. use_rle = true;
  98684. case TGATools._TYPE_RGB:
  98685. // use_rgb = true;
  98686. break;
  98687. case TGATools._TYPE_RLE_GREY:
  98688. use_rle = true;
  98689. case TGATools._TYPE_GREY:
  98690. use_grey = true;
  98691. break;
  98692. }
  98693. var pixel_data;
  98694. // var numAlphaBits = header.flags & 0xf;
  98695. var pixel_size = header.pixel_size >> 3;
  98696. var pixel_total = header.width * header.height * pixel_size;
  98697. // Read palettes
  98698. var palettes;
  98699. if (use_pal) {
  98700. palettes = data.subarray(offset, offset += header.colormap_length * (header.colormap_size >> 3));
  98701. }
  98702. // Read LRE
  98703. if (use_rle) {
  98704. pixel_data = new Uint8Array(pixel_total);
  98705. var c, count, i;
  98706. var localOffset = 0;
  98707. var pixels = new Uint8Array(pixel_size);
  98708. while (offset < pixel_total && localOffset < pixel_total) {
  98709. c = data[offset++];
  98710. count = (c & 0x7f) + 1;
  98711. // RLE pixels
  98712. if (c & 0x80) {
  98713. // Bind pixel tmp array
  98714. for (i = 0; i < pixel_size; ++i) {
  98715. pixels[i] = data[offset++];
  98716. }
  98717. // Copy pixel array
  98718. for (i = 0; i < count; ++i) {
  98719. pixel_data.set(pixels, localOffset + i * pixel_size);
  98720. }
  98721. localOffset += pixel_size * count;
  98722. }
  98723. // Raw pixels
  98724. else {
  98725. count *= pixel_size;
  98726. for (i = 0; i < count; ++i) {
  98727. pixel_data[localOffset + i] = data[offset++];
  98728. }
  98729. localOffset += count;
  98730. }
  98731. }
  98732. }
  98733. // RAW Pixels
  98734. else {
  98735. pixel_data = data.subarray(offset, offset += (use_pal ? header.width * header.height : pixel_total));
  98736. }
  98737. // Load to texture
  98738. var x_start, y_start, x_step, y_step, y_end, x_end;
  98739. switch ((header.flags & TGATools._ORIGIN_MASK) >> TGATools._ORIGIN_SHIFT) {
  98740. default:
  98741. case TGATools._ORIGIN_UL:
  98742. x_start = 0;
  98743. x_step = 1;
  98744. x_end = header.width;
  98745. y_start = 0;
  98746. y_step = 1;
  98747. y_end = header.height;
  98748. break;
  98749. case TGATools._ORIGIN_BL:
  98750. x_start = 0;
  98751. x_step = 1;
  98752. x_end = header.width;
  98753. y_start = header.height - 1;
  98754. y_step = -1;
  98755. y_end = -1;
  98756. break;
  98757. case TGATools._ORIGIN_UR:
  98758. x_start = header.width - 1;
  98759. x_step = -1;
  98760. x_end = -1;
  98761. y_start = 0;
  98762. y_step = 1;
  98763. y_end = header.height;
  98764. break;
  98765. case TGATools._ORIGIN_BR:
  98766. x_start = header.width - 1;
  98767. x_step = -1;
  98768. x_end = -1;
  98769. y_start = header.height - 1;
  98770. y_step = -1;
  98771. y_end = -1;
  98772. break;
  98773. }
  98774. // Load the specify method
  98775. var func = '_getImageData' + (use_grey ? 'Grey' : '') + (header.pixel_size) + 'bits';
  98776. var imageData = TGATools[func](header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end);
  98777. var engine = texture.getEngine();
  98778. engine._uploadDataToTextureDirectly(texture, imageData);
  98779. };
  98780. /** @hidden */
  98781. TGATools._getImageData8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98782. var image = pixel_data, colormap = palettes;
  98783. var width = header.width, height = header.height;
  98784. var color, i = 0, x, y;
  98785. var imageData = new Uint8Array(width * height * 4);
  98786. for (y = y_start; y !== y_end; y += y_step) {
  98787. for (x = x_start; x !== x_end; x += x_step, i++) {
  98788. color = image[i];
  98789. imageData[(x + width * y) * 4 + 3] = 255;
  98790. imageData[(x + width * y) * 4 + 2] = colormap[(color * 3) + 0];
  98791. imageData[(x + width * y) * 4 + 1] = colormap[(color * 3) + 1];
  98792. imageData[(x + width * y) * 4 + 0] = colormap[(color * 3) + 2];
  98793. }
  98794. }
  98795. return imageData;
  98796. };
  98797. /** @hidden */
  98798. TGATools._getImageData16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98799. var image = pixel_data;
  98800. var width = header.width, height = header.height;
  98801. var color, i = 0, x, y;
  98802. var imageData = new Uint8Array(width * height * 4);
  98803. for (y = y_start; y !== y_end; y += y_step) {
  98804. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98805. color = image[i + 0] + (image[i + 1] << 8); // Inversed ?
  98806. var r = (((color & 0x7C00) >> 10) * 255) / 0x1F | 0;
  98807. var g = (((color & 0x03E0) >> 5) * 255) / 0x1F | 0;
  98808. var b = ((color & 0x001F) * 255) / 0x1F | 0;
  98809. imageData[(x + width * y) * 4 + 0] = r;
  98810. imageData[(x + width * y) * 4 + 1] = g;
  98811. imageData[(x + width * y) * 4 + 2] = b;
  98812. imageData[(x + width * y) * 4 + 3] = (color & 0x8000) ? 0 : 255;
  98813. }
  98814. }
  98815. return imageData;
  98816. };
  98817. /** @hidden */
  98818. TGATools._getImageData24bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98819. var image = pixel_data;
  98820. var width = header.width, height = header.height;
  98821. var i = 0, x, y;
  98822. var imageData = new Uint8Array(width * height * 4);
  98823. for (y = y_start; y !== y_end; y += y_step) {
  98824. for (x = x_start; x !== x_end; x += x_step, i += 3) {
  98825. imageData[(x + width * y) * 4 + 3] = 255;
  98826. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98827. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98828. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98829. }
  98830. }
  98831. return imageData;
  98832. };
  98833. /** @hidden */
  98834. TGATools._getImageData32bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98835. var image = pixel_data;
  98836. var width = header.width, height = header.height;
  98837. var i = 0, x, y;
  98838. var imageData = new Uint8Array(width * height * 4);
  98839. for (y = y_start; y !== y_end; y += y_step) {
  98840. for (x = x_start; x !== x_end; x += x_step, i += 4) {
  98841. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98842. imageData[(x + width * y) * 4 + 1] = image[i + 1];
  98843. imageData[(x + width * y) * 4 + 0] = image[i + 2];
  98844. imageData[(x + width * y) * 4 + 3] = image[i + 3];
  98845. }
  98846. }
  98847. return imageData;
  98848. };
  98849. /** @hidden */
  98850. TGATools._getImageDataGrey8bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98851. var image = pixel_data;
  98852. var width = header.width, height = header.height;
  98853. var color, i = 0, x, y;
  98854. var imageData = new Uint8Array(width * height * 4);
  98855. for (y = y_start; y !== y_end; y += y_step) {
  98856. for (x = x_start; x !== x_end; x += x_step, i++) {
  98857. color = image[i];
  98858. imageData[(x + width * y) * 4 + 0] = color;
  98859. imageData[(x + width * y) * 4 + 1] = color;
  98860. imageData[(x + width * y) * 4 + 2] = color;
  98861. imageData[(x + width * y) * 4 + 3] = 255;
  98862. }
  98863. }
  98864. return imageData;
  98865. };
  98866. /** @hidden */
  98867. TGATools._getImageDataGrey16bits = function (header, palettes, pixel_data, y_start, y_step, y_end, x_start, x_step, x_end) {
  98868. var image = pixel_data;
  98869. var width = header.width, height = header.height;
  98870. var i = 0, x, y;
  98871. var imageData = new Uint8Array(width * height * 4);
  98872. for (y = y_start; y !== y_end; y += y_step) {
  98873. for (x = x_start; x !== x_end; x += x_step, i += 2) {
  98874. imageData[(x + width * y) * 4 + 0] = image[i + 0];
  98875. imageData[(x + width * y) * 4 + 1] = image[i + 0];
  98876. imageData[(x + width * y) * 4 + 2] = image[i + 0];
  98877. imageData[(x + width * y) * 4 + 3] = image[i + 1];
  98878. }
  98879. }
  98880. return imageData;
  98881. };
  98882. //private static _TYPE_NO_DATA = 0;
  98883. TGATools._TYPE_INDEXED = 1;
  98884. TGATools._TYPE_RGB = 2;
  98885. TGATools._TYPE_GREY = 3;
  98886. TGATools._TYPE_RLE_INDEXED = 9;
  98887. TGATools._TYPE_RLE_RGB = 10;
  98888. TGATools._TYPE_RLE_GREY = 11;
  98889. TGATools._ORIGIN_MASK = 0x30;
  98890. TGATools._ORIGIN_SHIFT = 0x04;
  98891. TGATools._ORIGIN_BL = 0x00;
  98892. TGATools._ORIGIN_BR = 0x01;
  98893. TGATools._ORIGIN_UL = 0x02;
  98894. TGATools._ORIGIN_UR = 0x03;
  98895. return TGATools;
  98896. }());
  98897. /***/ }),
  98898. /***/ "./Misc/tools.ts":
  98899. /*!***********************!*\
  98900. !*** ./Misc/tools.ts ***!
  98901. \***********************/
  98902. /*! exports provided: ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop */
  98903. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  98904. "use strict";
  98905. __webpack_require__.r(__webpack_exports__);
  98906. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return ColorGradient; });
  98907. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return Color3Gradient; });
  98908. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return FactorGradient; });
  98909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return LoadFileError; });
  98910. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return RetryStrategy; });
  98911. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return Tools; });
  98912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return PerfCounter; });
  98913. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "className", function() { return className; });
  98914. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return AsyncLoop; });
  98915. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  98916. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  98917. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  98918. /* harmony import */ var _observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./observable */ "./Misc/observable.ts");
  98919. /* harmony import */ var _filesInputStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./filesInputStore */ "./Misc/filesInputStore.ts");
  98920. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  98921. /* harmony import */ var _domManagement__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./domManagement */ "./Misc/domManagement.ts");
  98922. /* harmony import */ var _logger__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./logger */ "./Misc/logger.ts");
  98923. /* harmony import */ var _typeStore__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./typeStore */ "./Misc/typeStore.ts");
  98924. /* harmony import */ var _deepCopier__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./deepCopier */ "./Misc/deepCopier.ts");
  98925. /* harmony import */ var _precisionDate__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./precisionDate */ "./Misc/precisionDate.ts");
  98926. /* harmony import */ var _devTools__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./devTools */ "./Misc/devTools.ts");
  98927. /** Class used to store color4 gradient */
  98928. var ColorGradient = /** @class */ (function () {
  98929. function ColorGradient() {
  98930. }
  98931. /**
  98932. * Will get a color picked randomly between color1 and color2.
  98933. * If color2 is undefined then color1 will be used
  98934. * @param result defines the target Color4 to store the result in
  98935. */
  98936. ColorGradient.prototype.getColorToRef = function (result) {
  98937. if (!this.color2) {
  98938. result.copyFrom(this.color1);
  98939. return;
  98940. }
  98941. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"].LerpToRef(this.color1, this.color2, Math.random(), result);
  98942. };
  98943. return ColorGradient;
  98944. }());
  98945. /** Class used to store color 3 gradient */
  98946. var Color3Gradient = /** @class */ (function () {
  98947. function Color3Gradient() {
  98948. }
  98949. return Color3Gradient;
  98950. }());
  98951. /** Class used to store factor gradient */
  98952. var FactorGradient = /** @class */ (function () {
  98953. function FactorGradient() {
  98954. }
  98955. /**
  98956. * Will get a number picked randomly between factor1 and factor2.
  98957. * If factor2 is undefined then factor1 will be used
  98958. * @returns the picked number
  98959. */
  98960. FactorGradient.prototype.getFactor = function () {
  98961. if (this.factor2 === undefined) {
  98962. return this.factor1;
  98963. }
  98964. return _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].Lerp(this.factor1, this.factor2, Math.random());
  98965. };
  98966. return FactorGradient;
  98967. }());
  98968. /**
  98969. * @ignore
  98970. * Application error to support additional information when loading a file
  98971. */
  98972. var LoadFileError = /** @class */ (function (_super) {
  98973. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LoadFileError, _super);
  98974. /**
  98975. * Creates a new LoadFileError
  98976. * @param message defines the message of the error
  98977. * @param request defines the optional XHR request
  98978. */
  98979. function LoadFileError(message,
  98980. /** defines the optional XHR request */
  98981. request) {
  98982. var _this = _super.call(this, message) || this;
  98983. _this.request = request;
  98984. _this.name = "LoadFileError";
  98985. LoadFileError._setPrototypeOf(_this, LoadFileError.prototype);
  98986. return _this;
  98987. }
  98988. // See https://stackoverflow.com/questions/12915412/how-do-i-extend-a-host-object-e-g-error-in-typescript
  98989. // and https://github.com/Microsoft/TypeScript/wiki/Breaking-Changes#extending-built-ins-like-error-array-and-map-may-no-longer-work
  98990. // Polyfill for Object.setPrototypeOf if necessary.
  98991. LoadFileError._setPrototypeOf = Object.setPrototypeOf || (function (o, proto) { o.__proto__ = proto; return o; });
  98992. return LoadFileError;
  98993. }(Error));
  98994. /**
  98995. * Class used to define a retry strategy when error happens while loading assets
  98996. */
  98997. var RetryStrategy = /** @class */ (function () {
  98998. function RetryStrategy() {
  98999. }
  99000. /**
  99001. * Function used to defines an exponential back off strategy
  99002. * @param maxRetries defines the maximum number of retries (3 by default)
  99003. * @param baseInterval defines the interval between retries
  99004. * @returns the strategy function to use
  99005. */
  99006. RetryStrategy.ExponentialBackoff = function (maxRetries, baseInterval) {
  99007. if (maxRetries === void 0) { maxRetries = 3; }
  99008. if (baseInterval === void 0) { baseInterval = 500; }
  99009. return function (url, request, retryIndex) {
  99010. if (request.status !== 0 || retryIndex >= maxRetries || url.indexOf("file:") !== -1) {
  99011. return -1;
  99012. }
  99013. return Math.pow(2, retryIndex) * baseInterval;
  99014. };
  99015. };
  99016. return RetryStrategy;
  99017. }());
  99018. // Screenshots
  99019. var screenshotCanvas;
  99020. /**
  99021. * Class containing a set of static utilities functions
  99022. */
  99023. var Tools = /** @class */ (function () {
  99024. function Tools() {
  99025. }
  99026. /**
  99027. * Read the content of a byte array at a specified coordinates (taking in account wrapping)
  99028. * @param u defines the coordinate on X axis
  99029. * @param v defines the coordinate on Y axis
  99030. * @param width defines the width of the source data
  99031. * @param height defines the height of the source data
  99032. * @param pixels defines the source byte array
  99033. * @param color defines the output color
  99034. */
  99035. Tools.FetchToRef = function (u, v, width, height, pixels, color) {
  99036. var wrappedU = ((Math.abs(u) * width) % width) | 0;
  99037. var wrappedV = ((Math.abs(v) * height) % height) | 0;
  99038. var position = (wrappedU + wrappedV * width) * 4;
  99039. color.r = pixels[position] / 255;
  99040. color.g = pixels[position + 1] / 255;
  99041. color.b = pixels[position + 2] / 255;
  99042. color.a = pixels[position + 3] / 255;
  99043. };
  99044. /**
  99045. * Interpolates between a and b via alpha
  99046. * @param a The lower value (returned when alpha = 0)
  99047. * @param b The upper value (returned when alpha = 1)
  99048. * @param alpha The interpolation-factor
  99049. * @return The mixed value
  99050. */
  99051. Tools.Mix = function (a, b, alpha) {
  99052. return a * (1 - alpha) + b * alpha;
  99053. };
  99054. /**
  99055. * Tries to instantiate a new object from a given class name
  99056. * @param className defines the class name to instantiate
  99057. * @returns the new object or null if the system was not able to do the instantiation
  99058. */
  99059. Tools.Instantiate = function (className) {
  99060. if (Tools.RegisteredExternalClasses && Tools.RegisteredExternalClasses[className]) {
  99061. return Tools.RegisteredExternalClasses[className];
  99062. }
  99063. var internalClass = _typeStore__WEBPACK_IMPORTED_MODULE_8__["_TypeStore"].GetClass(className);
  99064. if (internalClass) {
  99065. return internalClass;
  99066. }
  99067. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(className + " not found, you may have missed an import.");
  99068. var arr = className.split(".");
  99069. var fn = (window || this);
  99070. for (var i = 0, len = arr.length; i < len; i++) {
  99071. fn = fn[arr[i]];
  99072. }
  99073. if (typeof fn !== "function") {
  99074. return null;
  99075. }
  99076. return fn;
  99077. };
  99078. /**
  99079. * Provides a slice function that will work even on IE
  99080. * @param data defines the array to slice
  99081. * @param start defines the start of the data (optional)
  99082. * @param end defines the end of the data (optional)
  99083. * @returns the new sliced array
  99084. */
  99085. Tools.Slice = function (data, start, end) {
  99086. if (data.slice) {
  99087. return data.slice(start, end);
  99088. }
  99089. return Array.prototype.slice.call(data, start, end);
  99090. };
  99091. /**
  99092. * Polyfill for setImmediate
  99093. * @param action defines the action to execute after the current execution block
  99094. */
  99095. Tools.SetImmediate = function (action) {
  99096. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && window.setImmediate) {
  99097. window.setImmediate(action);
  99098. }
  99099. else {
  99100. setTimeout(action, 1);
  99101. }
  99102. };
  99103. /**
  99104. * Function indicating if a number is an exponent of 2
  99105. * @param value defines the value to test
  99106. * @returns true if the value is an exponent of 2
  99107. */
  99108. Tools.IsExponentOfTwo = function (value) {
  99109. var count = 1;
  99110. do {
  99111. count *= 2;
  99112. } while (count < value);
  99113. return count === value;
  99114. };
  99115. /**
  99116. * Returns the nearest 32-bit single precision float representation of a Number
  99117. * @param value A Number. If the parameter is of a different type, it will get converted
  99118. * to a number or to NaN if it cannot be converted
  99119. * @returns number
  99120. */
  99121. Tools.FloatRound = function (value) {
  99122. if (Math.fround) {
  99123. return Math.fround(value);
  99124. }
  99125. return (Tools._tmpFloatArray[0] = value);
  99126. };
  99127. /**
  99128. * Find the next highest power of two.
  99129. * @param x Number to start search from.
  99130. * @return Next highest power of two.
  99131. */
  99132. Tools.CeilingPOT = function (x) {
  99133. x--;
  99134. x |= x >> 1;
  99135. x |= x >> 2;
  99136. x |= x >> 4;
  99137. x |= x >> 8;
  99138. x |= x >> 16;
  99139. x++;
  99140. return x;
  99141. };
  99142. /**
  99143. * Find the next lowest power of two.
  99144. * @param x Number to start search from.
  99145. * @return Next lowest power of two.
  99146. */
  99147. Tools.FloorPOT = function (x) {
  99148. x = x | (x >> 1);
  99149. x = x | (x >> 2);
  99150. x = x | (x >> 4);
  99151. x = x | (x >> 8);
  99152. x = x | (x >> 16);
  99153. return x - (x >> 1);
  99154. };
  99155. /**
  99156. * Find the nearest power of two.
  99157. * @param x Number to start search from.
  99158. * @return Next nearest power of two.
  99159. */
  99160. Tools.NearestPOT = function (x) {
  99161. var c = Tools.CeilingPOT(x);
  99162. var f = Tools.FloorPOT(x);
  99163. return (c - x) > (x - f) ? f : c;
  99164. };
  99165. /**
  99166. * Get the closest exponent of two
  99167. * @param value defines the value to approximate
  99168. * @param max defines the maximum value to return
  99169. * @param mode defines how to define the closest value
  99170. * @returns closest exponent of two of the given value
  99171. */
  99172. Tools.GetExponentOfTwo = function (value, max, mode) {
  99173. if (mode === void 0) { mode = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST; }
  99174. var pot;
  99175. switch (mode) {
  99176. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_FLOOR:
  99177. pot = Tools.FloorPOT(value);
  99178. break;
  99179. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_NEAREST:
  99180. pot = Tools.NearestPOT(value);
  99181. break;
  99182. case _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].SCALEMODE_CEILING:
  99183. default:
  99184. pot = Tools.CeilingPOT(value);
  99185. break;
  99186. }
  99187. return Math.min(pot, max);
  99188. };
  99189. /**
  99190. * Extracts the filename from a path
  99191. * @param path defines the path to use
  99192. * @returns the filename
  99193. */
  99194. Tools.GetFilename = function (path) {
  99195. var index = path.lastIndexOf("/");
  99196. if (index < 0) {
  99197. return path;
  99198. }
  99199. return path.substring(index + 1);
  99200. };
  99201. /**
  99202. * Extracts the "folder" part of a path (everything before the filename).
  99203. * @param uri The URI to extract the info from
  99204. * @param returnUnchangedIfNoSlash Do not touch the URI if no slashes are present
  99205. * @returns The "folder" part of the path
  99206. */
  99207. Tools.GetFolderPath = function (uri, returnUnchangedIfNoSlash) {
  99208. if (returnUnchangedIfNoSlash === void 0) { returnUnchangedIfNoSlash = false; }
  99209. var index = uri.lastIndexOf("/");
  99210. if (index < 0) {
  99211. if (returnUnchangedIfNoSlash) {
  99212. return uri;
  99213. }
  99214. return "";
  99215. }
  99216. return uri.substring(0, index + 1);
  99217. };
  99218. /**
  99219. * Convert an angle in radians to degrees
  99220. * @param angle defines the angle to convert
  99221. * @returns the angle in degrees
  99222. */
  99223. Tools.ToDegrees = function (angle) {
  99224. return angle * 180 / Math.PI;
  99225. };
  99226. /**
  99227. * Convert an angle in degrees to radians
  99228. * @param angle defines the angle to convert
  99229. * @returns the angle in radians
  99230. */
  99231. Tools.ToRadians = function (angle) {
  99232. return angle * Math.PI / 180;
  99233. };
  99234. /**
  99235. * Encode a buffer to a base64 string
  99236. * @param buffer defines the buffer to encode
  99237. * @returns the encoded string
  99238. */
  99239. Tools.EncodeArrayBufferTobase64 = function (buffer) {
  99240. var keyStr = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
  99241. var output = "";
  99242. var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
  99243. var i = 0;
  99244. var bytes = new Uint8Array(buffer);
  99245. while (i < bytes.length) {
  99246. chr1 = bytes[i++];
  99247. chr2 = i < bytes.length ? bytes[i++] : Number.NaN; // Not sure if the index
  99248. chr3 = i < bytes.length ? bytes[i++] : Number.NaN; // checks are needed here
  99249. enc1 = chr1 >> 2;
  99250. enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
  99251. enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
  99252. enc4 = chr3 & 63;
  99253. if (isNaN(chr2)) {
  99254. enc3 = enc4 = 64;
  99255. }
  99256. else if (isNaN(chr3)) {
  99257. enc4 = 64;
  99258. }
  99259. output += keyStr.charAt(enc1) + keyStr.charAt(enc2) +
  99260. keyStr.charAt(enc3) + keyStr.charAt(enc4);
  99261. }
  99262. return "data:image/png;base64," + output;
  99263. };
  99264. /**
  99265. * Extracts minimum and maximum values from a list of indexed positions
  99266. * @param positions defines the positions to use
  99267. * @param indices defines the indices to the positions
  99268. * @param indexStart defines the start index
  99269. * @param indexCount defines the end index
  99270. * @param bias defines bias value to add to the result
  99271. * @return minimum and maximum values
  99272. */
  99273. Tools.ExtractMinAndMaxIndexed = function (positions, indices, indexStart, indexCount, bias) {
  99274. if (bias === void 0) { bias = null; }
  99275. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  99276. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  99277. for (var index = indexStart; index < indexStart + indexCount; index++) {
  99278. var offset = indices[index] * 3;
  99279. var x = positions[offset];
  99280. var y = positions[offset + 1];
  99281. var z = positions[offset + 2];
  99282. minimum.minimizeInPlaceFromFloats(x, y, z);
  99283. maximum.maximizeInPlaceFromFloats(x, y, z);
  99284. }
  99285. if (bias) {
  99286. minimum.x -= minimum.x * bias.x + bias.y;
  99287. minimum.y -= minimum.y * bias.x + bias.y;
  99288. minimum.z -= minimum.z * bias.x + bias.y;
  99289. maximum.x += maximum.x * bias.x + bias.y;
  99290. maximum.y += maximum.y * bias.x + bias.y;
  99291. maximum.z += maximum.z * bias.x + bias.y;
  99292. }
  99293. return {
  99294. minimum: minimum,
  99295. maximum: maximum
  99296. };
  99297. };
  99298. /**
  99299. * Extracts minimum and maximum values from a list of positions
  99300. * @param positions defines the positions to use
  99301. * @param start defines the start index in the positions array
  99302. * @param count defines the number of positions to handle
  99303. * @param bias defines bias value to add to the result
  99304. * @param stride defines the stride size to use (distance between two positions in the positions array)
  99305. * @return minimum and maximum values
  99306. */
  99307. Tools.ExtractMinAndMax = function (positions, start, count, bias, stride) {
  99308. if (bias === void 0) { bias = null; }
  99309. var minimum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  99310. var maximum = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  99311. if (!stride) {
  99312. stride = 3;
  99313. }
  99314. for (var index = start, offset = start * stride; index < start + count; index++, offset += stride) {
  99315. var x = positions[offset];
  99316. var y = positions[offset + 1];
  99317. var z = positions[offset + 2];
  99318. minimum.minimizeInPlaceFromFloats(x, y, z);
  99319. maximum.maximizeInPlaceFromFloats(x, y, z);
  99320. }
  99321. if (bias) {
  99322. minimum.x -= minimum.x * bias.x + bias.y;
  99323. minimum.y -= minimum.y * bias.x + bias.y;
  99324. minimum.z -= minimum.z * bias.x + bias.y;
  99325. maximum.x += maximum.x * bias.x + bias.y;
  99326. maximum.y += maximum.y * bias.x + bias.y;
  99327. maximum.z += maximum.z * bias.x + bias.y;
  99328. }
  99329. return {
  99330. minimum: minimum,
  99331. maximum: maximum
  99332. };
  99333. };
  99334. /**
  99335. * Returns an array if obj is not an array
  99336. * @param obj defines the object to evaluate as an array
  99337. * @param allowsNullUndefined defines a boolean indicating if obj is allowed to be null or undefined
  99338. * @returns either obj directly if obj is an array or a new array containing obj
  99339. */
  99340. Tools.MakeArray = function (obj, allowsNullUndefined) {
  99341. if (allowsNullUndefined !== true && (obj === undefined || obj == null)) {
  99342. return null;
  99343. }
  99344. return Array.isArray(obj) ? obj : [obj];
  99345. };
  99346. /**
  99347. * Gets the pointer prefix to use
  99348. * @returns "pointer" if touch is enabled. Else returns "mouse"
  99349. */
  99350. Tools.GetPointerPrefix = function () {
  99351. var eventPrefix = "pointer";
  99352. // Check if pointer events are supported
  99353. if (_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() && !window.PointerEvent && !navigator.pointerEnabled) {
  99354. eventPrefix = "mouse";
  99355. }
  99356. return eventPrefix;
  99357. };
  99358. /**
  99359. * Queue a new function into the requested animation frame pool (ie. this function will be executed byt the browser for the next frame)
  99360. * @param func - the function to be called
  99361. * @param requester - the object that will request the next frame. Falls back to window.
  99362. * @returns frame number
  99363. */
  99364. Tools.QueueNewFrame = function (func, requester) {
  99365. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99366. return setTimeout(func, 16);
  99367. }
  99368. if (!requester) {
  99369. requester = window;
  99370. }
  99371. if (requester.requestAnimationFrame) {
  99372. return requester.requestAnimationFrame(func);
  99373. }
  99374. else if (requester.msRequestAnimationFrame) {
  99375. return requester.msRequestAnimationFrame(func);
  99376. }
  99377. else if (requester.webkitRequestAnimationFrame) {
  99378. return requester.webkitRequestAnimationFrame(func);
  99379. }
  99380. else if (requester.mozRequestAnimationFrame) {
  99381. return requester.mozRequestAnimationFrame(func);
  99382. }
  99383. else if (requester.oRequestAnimationFrame) {
  99384. return requester.oRequestAnimationFrame(func);
  99385. }
  99386. else {
  99387. return window.setTimeout(func, 16);
  99388. }
  99389. };
  99390. /**
  99391. * Ask the browser to promote the current element to fullscreen rendering mode
  99392. * @param element defines the DOM element to promote
  99393. */
  99394. Tools.RequestFullscreen = function (element) {
  99395. var requestFunction = element.requestFullscreen || element.msRequestFullscreen || element.webkitRequestFullscreen || element.mozRequestFullScreen;
  99396. if (!requestFunction) {
  99397. return;
  99398. }
  99399. requestFunction.call(element);
  99400. };
  99401. /**
  99402. * Asks the browser to exit fullscreen mode
  99403. */
  99404. Tools.ExitFullscreen = function () {
  99405. if (document.exitFullscreen) {
  99406. document.exitFullscreen();
  99407. }
  99408. else if (document.mozCancelFullScreen) {
  99409. document.mozCancelFullScreen();
  99410. }
  99411. else if (document.webkitCancelFullScreen) {
  99412. document.webkitCancelFullScreen();
  99413. }
  99414. else if (document.msCancelFullScreen) {
  99415. document.msCancelFullScreen();
  99416. }
  99417. };
  99418. /**
  99419. * Sets the cors behavior on a dom element. This will add the required Tools.CorsBehavior to the element.
  99420. * @param url define the url we are trying
  99421. * @param element define the dom element where to configure the cors policy
  99422. */
  99423. Tools.SetCorsBehavior = function (url, element) {
  99424. if (url && url.indexOf("data:") === 0) {
  99425. return;
  99426. }
  99427. if (Tools.CorsBehavior) {
  99428. if (typeof (Tools.CorsBehavior) === 'string' || Tools.CorsBehavior instanceof String) {
  99429. element.crossOrigin = Tools.CorsBehavior;
  99430. }
  99431. else {
  99432. var result = Tools.CorsBehavior(url);
  99433. if (result) {
  99434. element.crossOrigin = result;
  99435. }
  99436. }
  99437. }
  99438. };
  99439. // External files
  99440. /**
  99441. * Removes unwanted characters from an url
  99442. * @param url defines the url to clean
  99443. * @returns the cleaned url
  99444. */
  99445. Tools.CleanUrl = function (url) {
  99446. url = url.replace(/#/mg, "%23");
  99447. return url;
  99448. };
  99449. /**
  99450. * Loads an image as an HTMLImageElement.
  99451. * @param input url string, ArrayBuffer, or Blob to load
  99452. * @param onLoad callback called when the image successfully loads
  99453. * @param onError callback called when the image fails to load
  99454. * @param offlineProvider offline provider for caching
  99455. * @returns the HTMLImageElement of the loaded image
  99456. */
  99457. Tools.LoadImage = function (input, onLoad, onError, offlineProvider) {
  99458. var url;
  99459. var usingObjectURL = false;
  99460. if (input instanceof ArrayBuffer) {
  99461. url = URL.createObjectURL(new Blob([input]));
  99462. usingObjectURL = true;
  99463. }
  99464. else if (input instanceof Blob) {
  99465. url = URL.createObjectURL(input);
  99466. usingObjectURL = true;
  99467. }
  99468. else {
  99469. url = Tools.CleanUrl(input);
  99470. url = Tools.PreprocessUrl(input);
  99471. }
  99472. var img = new Image();
  99473. Tools.SetCorsBehavior(url, img);
  99474. var loadHandler = function () {
  99475. if (usingObjectURL && img.src) {
  99476. URL.revokeObjectURL(img.src);
  99477. }
  99478. img.removeEventListener("load", loadHandler);
  99479. img.removeEventListener("error", errorHandler);
  99480. onLoad(img);
  99481. };
  99482. var errorHandler = function (err) {
  99483. if (usingObjectURL && img.src) {
  99484. URL.revokeObjectURL(img.src);
  99485. }
  99486. img.removeEventListener("load", loadHandler);
  99487. img.removeEventListener("error", errorHandler);
  99488. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error("Error while trying to load image: " + input);
  99489. if (onError) {
  99490. onError("Error while trying to load image: " + input, err);
  99491. }
  99492. };
  99493. img.addEventListener("load", loadHandler);
  99494. img.addEventListener("error", errorHandler);
  99495. var noOfflineSupport = function () {
  99496. img.src = url;
  99497. };
  99498. var loadFromOfflineSupport = function () {
  99499. if (offlineProvider) {
  99500. offlineProvider.loadImage(url, img);
  99501. }
  99502. };
  99503. if (url.substr(0, 5) !== "data:" && offlineProvider && offlineProvider.enableTexturesOffline) {
  99504. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport);
  99505. }
  99506. else {
  99507. if (url.indexOf("file:") !== -1) {
  99508. var textureName = decodeURIComponent(url.substring(5).toLowerCase());
  99509. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]) {
  99510. try {
  99511. var blobURL;
  99512. try {
  99513. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  99514. }
  99515. catch (ex) {
  99516. // Chrome doesn't support oneTimeOnly parameter
  99517. blobURL = URL.createObjectURL(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[textureName]);
  99518. }
  99519. img.src = blobURL;
  99520. usingObjectURL = true;
  99521. }
  99522. catch (e) {
  99523. img.src = "";
  99524. }
  99525. return img;
  99526. }
  99527. }
  99528. noOfflineSupport();
  99529. }
  99530. return img;
  99531. };
  99532. /**
  99533. * Loads a file
  99534. * @param url url string, ArrayBuffer, or Blob to load
  99535. * @param onSuccess callback called when the file successfully loads
  99536. * @param onProgress callback called while file is loading (if the server supports this mode)
  99537. * @param offlineProvider defines the offline provider for caching
  99538. * @param useArrayBuffer defines a boolean indicating that date must be returned as ArrayBuffer
  99539. * @param onError callback called when the file fails to load
  99540. * @returns a file request object
  99541. */
  99542. Tools.LoadFile = function (url, onSuccess, onProgress, offlineProvider, useArrayBuffer, onError) {
  99543. url = Tools.CleanUrl(url);
  99544. url = Tools.PreprocessUrl(url);
  99545. // If file and file input are set
  99546. if (url.indexOf("file:") !== -1) {
  99547. var fileName = decodeURIComponent(url.substring(5).toLowerCase());
  99548. if (_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName]) {
  99549. return Tools.ReadFile(_filesInputStore__WEBPACK_IMPORTED_MODULE_4__["FilesInputStore"].FilesToLoad[fileName], onSuccess, onProgress, useArrayBuffer);
  99550. }
  99551. }
  99552. var loadUrl = Tools.BaseUrl + url;
  99553. var aborted = false;
  99554. var fileRequest = {
  99555. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99556. abort: function () { return aborted = true; },
  99557. };
  99558. var requestFile = function () {
  99559. var request = new XMLHttpRequest();
  99560. var retryHandle = null;
  99561. fileRequest.abort = function () {
  99562. aborted = true;
  99563. if (request.readyState !== (XMLHttpRequest.DONE || 4)) {
  99564. request.abort();
  99565. }
  99566. if (retryHandle !== null) {
  99567. clearTimeout(retryHandle);
  99568. retryHandle = null;
  99569. }
  99570. };
  99571. var retryLoop = function (retryIndex) {
  99572. request.open('GET', loadUrl, true);
  99573. if (useArrayBuffer) {
  99574. request.responseType = "arraybuffer";
  99575. }
  99576. if (onProgress) {
  99577. request.addEventListener("progress", onProgress);
  99578. }
  99579. var onLoadEnd = function () {
  99580. request.removeEventListener("loadend", onLoadEnd);
  99581. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  99582. fileRequest.onCompleteObservable.clear();
  99583. };
  99584. request.addEventListener("loadend", onLoadEnd);
  99585. var onReadyStateChange = function () {
  99586. if (aborted) {
  99587. return;
  99588. }
  99589. // In case of undefined state in some browsers.
  99590. if (request.readyState === (XMLHttpRequest.DONE || 4)) {
  99591. // Some browsers have issues where onreadystatechange can be called multiple times with the same value.
  99592. request.removeEventListener("readystatechange", onReadyStateChange);
  99593. if ((request.status >= 200 && request.status < 300) || (request.status === 0 && (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist() || Tools.IsFileURL()))) {
  99594. onSuccess(!useArrayBuffer ? request.responseText : request.response, request.responseURL);
  99595. return;
  99596. }
  99597. var retryStrategy = Tools.DefaultRetryStrategy;
  99598. if (retryStrategy) {
  99599. var waitTime = retryStrategy(loadUrl, request, retryIndex);
  99600. if (waitTime !== -1) {
  99601. // Prevent the request from completing for retry.
  99602. request.removeEventListener("loadend", onLoadEnd);
  99603. request = new XMLHttpRequest();
  99604. retryHandle = setTimeout(function () { return retryLoop(retryIndex + 1); }, waitTime);
  99605. return;
  99606. }
  99607. }
  99608. var e = new LoadFileError("Error status: " + request.status + " " + request.statusText + " - Unable to load " + loadUrl, request);
  99609. if (onError) {
  99610. onError(request, e);
  99611. }
  99612. else {
  99613. throw e;
  99614. }
  99615. }
  99616. };
  99617. request.addEventListener("readystatechange", onReadyStateChange);
  99618. if (Tools.UseCustomRequestHeaders) {
  99619. Tools.InjectCustomRequestHeaders(request);
  99620. }
  99621. request.send();
  99622. };
  99623. retryLoop(0);
  99624. };
  99625. // Caching all files
  99626. if (offlineProvider && offlineProvider.enableSceneOffline) {
  99627. var noOfflineSupport_1 = function (request) {
  99628. if (request && request.status > 400) {
  99629. if (onError) {
  99630. onError(request);
  99631. }
  99632. }
  99633. else {
  99634. if (!aborted) {
  99635. requestFile();
  99636. }
  99637. }
  99638. };
  99639. var loadFromOfflineSupport = function () {
  99640. // TODO: database needs to support aborting and should return a IFileRequest
  99641. if (aborted) {
  99642. return;
  99643. }
  99644. if (offlineProvider) {
  99645. offlineProvider.loadFile(url, function (data) {
  99646. if (!aborted) {
  99647. onSuccess(data);
  99648. }
  99649. fileRequest.onCompleteObservable.notifyObservers(fileRequest);
  99650. }, onProgress ? function (event) {
  99651. if (!aborted) {
  99652. onProgress(event);
  99653. }
  99654. } : undefined, noOfflineSupport_1, useArrayBuffer);
  99655. }
  99656. };
  99657. offlineProvider.open(loadFromOfflineSupport, noOfflineSupport_1);
  99658. }
  99659. else {
  99660. requestFile();
  99661. }
  99662. return fileRequest;
  99663. };
  99664. /**
  99665. * Load a script (identified by an url). When the url returns, the
  99666. * content of this file is added into a new script element, attached to the DOM (body element)
  99667. * @param scriptUrl defines the url of the script to laod
  99668. * @param onSuccess defines the callback called when the script is loaded
  99669. * @param onError defines the callback to call if an error occurs
  99670. */
  99671. Tools.LoadScript = function (scriptUrl, onSuccess, onError) {
  99672. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  99673. return;
  99674. }
  99675. var head = document.getElementsByTagName('head')[0];
  99676. var script = document.createElement('script');
  99677. script.type = 'text/javascript';
  99678. script.src = scriptUrl;
  99679. script.onload = function () {
  99680. if (onSuccess) {
  99681. onSuccess();
  99682. }
  99683. };
  99684. script.onerror = function (e) {
  99685. if (onError) {
  99686. onError("Unable to load script '" + scriptUrl + "'", e);
  99687. }
  99688. };
  99689. head.appendChild(script);
  99690. };
  99691. /**
  99692. * Loads a file from a blob
  99693. * @param fileToLoad defines the blob to use
  99694. * @param callback defines the callback to call when data is loaded
  99695. * @param progressCallback defines the callback to call during loading process
  99696. * @returns a file request object
  99697. */
  99698. Tools.ReadFileAsDataURL = function (fileToLoad, callback, progressCallback) {
  99699. var reader = new FileReader();
  99700. var request = {
  99701. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99702. abort: function () { return reader.abort(); },
  99703. };
  99704. reader.onloadend = function (e) {
  99705. request.onCompleteObservable.notifyObservers(request);
  99706. };
  99707. reader.onload = function (e) {
  99708. //target doesn't have result from ts 1.3
  99709. callback(e.target['result']);
  99710. };
  99711. reader.onprogress = progressCallback;
  99712. reader.readAsDataURL(fileToLoad);
  99713. return request;
  99714. };
  99715. /**
  99716. * Loads a file
  99717. * @param fileToLoad defines the file to load
  99718. * @param callback defines the callback to call when data is loaded
  99719. * @param progressCallBack defines the callback to call during loading process
  99720. * @param useArrayBuffer defines a boolean indicating that data must be returned as an ArrayBuffer
  99721. * @returns a file request object
  99722. */
  99723. Tools.ReadFile = function (fileToLoad, callback, progressCallBack, useArrayBuffer) {
  99724. var reader = new FileReader();
  99725. var request = {
  99726. onCompleteObservable: new _observable__WEBPACK_IMPORTED_MODULE_3__["Observable"](),
  99727. abort: function () { return reader.abort(); },
  99728. };
  99729. reader.onloadend = function (e) { return request.onCompleteObservable.notifyObservers(request); };
  99730. reader.onerror = function (e) {
  99731. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log("Error while reading file: " + fileToLoad.name);
  99732. callback(JSON.stringify({ autoClear: true, clearColor: [1, 0, 0], ambientColor: [0, 0, 0], gravity: [0, -9.807, 0], meshes: [], cameras: [], lights: [] }));
  99733. };
  99734. reader.onload = function (e) {
  99735. //target doesn't have result from ts 1.3
  99736. callback(e.target['result']);
  99737. };
  99738. if (progressCallBack) {
  99739. reader.onprogress = progressCallBack;
  99740. }
  99741. if (!useArrayBuffer) {
  99742. // Asynchronous read
  99743. reader.readAsText(fileToLoad);
  99744. }
  99745. else {
  99746. reader.readAsArrayBuffer(fileToLoad);
  99747. }
  99748. return request;
  99749. };
  99750. /**
  99751. * Creates a data url from a given string content
  99752. * @param content defines the content to convert
  99753. * @returns the new data url link
  99754. */
  99755. Tools.FileAsURL = function (content) {
  99756. var fileBlob = new Blob([content]);
  99757. var url = window.URL || window.webkitURL;
  99758. var link = url.createObjectURL(fileBlob);
  99759. return link;
  99760. };
  99761. /**
  99762. * Format the given number to a specific decimal format
  99763. * @param value defines the number to format
  99764. * @param decimals defines the number of decimals to use
  99765. * @returns the formatted string
  99766. */
  99767. Tools.Format = function (value, decimals) {
  99768. if (decimals === void 0) { decimals = 2; }
  99769. return value.toFixed(decimals);
  99770. };
  99771. /**
  99772. * Checks if a given vector is inside a specific range
  99773. * @param v defines the vector to test
  99774. * @param min defines the minimum range
  99775. * @param max defines the maximum range
  99776. */
  99777. Tools.CheckExtends = function (v, min, max) {
  99778. min.minimizeInPlace(v);
  99779. max.maximizeInPlace(v);
  99780. };
  99781. /**
  99782. * Tries to copy an object by duplicating every property
  99783. * @param source defines the source object
  99784. * @param destination defines the target object
  99785. * @param doNotCopyList defines a list of properties to avoid
  99786. * @param mustCopyList defines a list of properties to copy (even if they start with _)
  99787. */
  99788. Tools.DeepCopy = function (source, destination, doNotCopyList, mustCopyList) {
  99789. _deepCopier__WEBPACK_IMPORTED_MODULE_9__["DeepCopier"].DeepCopy(source, destination, doNotCopyList, mustCopyList);
  99790. };
  99791. /**
  99792. * Gets a boolean indicating if the given object has no own property
  99793. * @param obj defines the object to test
  99794. * @returns true if object has no own property
  99795. */
  99796. Tools.IsEmpty = function (obj) {
  99797. for (var i in obj) {
  99798. if (obj.hasOwnProperty(i)) {
  99799. return false;
  99800. }
  99801. }
  99802. return true;
  99803. };
  99804. /**
  99805. * Function used to register events at window level
  99806. * @param events defines the events to register
  99807. */
  99808. Tools.RegisterTopRootEvents = function (events) {
  99809. for (var index = 0; index < events.length; index++) {
  99810. var event = events[index];
  99811. window.addEventListener(event.name, event.handler, false);
  99812. try {
  99813. if (window.parent) {
  99814. window.parent.addEventListener(event.name, event.handler, false);
  99815. }
  99816. }
  99817. catch (e) {
  99818. // Silently fails...
  99819. }
  99820. }
  99821. };
  99822. /**
  99823. * Function used to unregister events from window level
  99824. * @param events defines the events to unregister
  99825. */
  99826. Tools.UnregisterTopRootEvents = function (events) {
  99827. for (var index = 0; index < events.length; index++) {
  99828. var event = events[index];
  99829. window.removeEventListener(event.name, event.handler);
  99830. try {
  99831. if (window.parent) {
  99832. window.parent.removeEventListener(event.name, event.handler);
  99833. }
  99834. }
  99835. catch (e) {
  99836. // Silently fails...
  99837. }
  99838. }
  99839. };
  99840. /**
  99841. * Dumps the current bound framebuffer
  99842. * @param width defines the rendering width
  99843. * @param height defines the rendering height
  99844. * @param engine defines the hosting engine
  99845. * @param successCallback defines the callback triggered once the data are available
  99846. * @param mimeType defines the mime type of the result
  99847. * @param fileName defines the filename to download. If present, the result will automatically be downloaded
  99848. */
  99849. Tools.DumpFramebuffer = function (width, height, engine, successCallback, mimeType, fileName) {
  99850. if (mimeType === void 0) { mimeType = "image/png"; }
  99851. // Read the contents of the framebuffer
  99852. var numberOfChannelsByLine = width * 4;
  99853. var halfHeight = height / 2;
  99854. //Reading datas from WebGL
  99855. var data = engine.readPixels(0, 0, width, height);
  99856. //To flip image on Y axis.
  99857. for (var i = 0; i < halfHeight; i++) {
  99858. for (var j = 0; j < numberOfChannelsByLine; j++) {
  99859. var currentCell = j + i * numberOfChannelsByLine;
  99860. var targetLine = height - i - 1;
  99861. var targetCell = j + targetLine * numberOfChannelsByLine;
  99862. var temp = data[currentCell];
  99863. data[currentCell] = data[targetCell];
  99864. data[targetCell] = temp;
  99865. }
  99866. }
  99867. // Create a 2D canvas to store the result
  99868. if (!screenshotCanvas) {
  99869. screenshotCanvas = document.createElement('canvas');
  99870. }
  99871. screenshotCanvas.width = width;
  99872. screenshotCanvas.height = height;
  99873. var context = screenshotCanvas.getContext('2d');
  99874. if (context) {
  99875. // Copy the pixels to a 2D canvas
  99876. var imageData = context.createImageData(width, height);
  99877. var castData = (imageData.data);
  99878. castData.set(data);
  99879. context.putImageData(imageData, 0, 0);
  99880. Tools.EncodeScreenshotCanvasData(successCallback, mimeType, fileName);
  99881. }
  99882. };
  99883. /**
  99884. * Converts the canvas data to blob.
  99885. * This acts as a polyfill for browsers not supporting the to blob function.
  99886. * @param canvas Defines the canvas to extract the data from
  99887. * @param successCallback Defines the callback triggered once the data are available
  99888. * @param mimeType Defines the mime type of the result
  99889. */
  99890. Tools.ToBlob = function (canvas, successCallback, mimeType) {
  99891. if (mimeType === void 0) { mimeType = "image/png"; }
  99892. // We need HTMLCanvasElement.toBlob for HD screenshots
  99893. if (!canvas.toBlob) {
  99894. // low performance polyfill based on toDataURL (https://developer.mozilla.org/en-US/docs/Web/API/HTMLCanvasElement/toBlob)
  99895. canvas.toBlob = function (callback, type, quality) {
  99896. var _this = this;
  99897. setTimeout(function () {
  99898. var binStr = atob(_this.toDataURL(type, quality).split(',')[1]), len = binStr.length, arr = new Uint8Array(len);
  99899. for (var i = 0; i < len; i++) {
  99900. arr[i] = binStr.charCodeAt(i);
  99901. }
  99902. callback(new Blob([arr]));
  99903. });
  99904. };
  99905. }
  99906. canvas.toBlob(function (blob) {
  99907. successCallback(blob);
  99908. }, mimeType);
  99909. };
  99910. /**
  99911. * Encodes the canvas data to base 64 or automatically download the result if filename is defined
  99912. * @param successCallback defines the callback triggered once the data are available
  99913. * @param mimeType defines the mime type of the result
  99914. * @param fileName defines he filename to download. If present, the result will automatically be downloaded
  99915. */
  99916. Tools.EncodeScreenshotCanvasData = function (successCallback, mimeType, fileName) {
  99917. if (mimeType === void 0) { mimeType = "image/png"; }
  99918. if (successCallback) {
  99919. var base64Image = screenshotCanvas.toDataURL(mimeType);
  99920. successCallback(base64Image);
  99921. }
  99922. else {
  99923. this.ToBlob(screenshotCanvas, function (blob) {
  99924. //Creating a link if the browser have the download attribute on the a tag, to automatically start download generated image.
  99925. if (("download" in document.createElement("a"))) {
  99926. if (!fileName) {
  99927. var date = new Date();
  99928. var stringDate = (date.getFullYear() + "-" + (date.getMonth() + 1)).slice(2) + "-" + date.getDate() + "_" + date.getHours() + "-" + ('0' + date.getMinutes()).slice(-2);
  99929. fileName = "screenshot_" + stringDate + ".png";
  99930. }
  99931. Tools.Download(blob, fileName);
  99932. }
  99933. else {
  99934. var url = URL.createObjectURL(blob);
  99935. var newWindow = window.open("");
  99936. if (!newWindow) {
  99937. return;
  99938. }
  99939. var img = newWindow.document.createElement("img");
  99940. img.onload = function () {
  99941. // no longer need to read the blob so it's revoked
  99942. URL.revokeObjectURL(url);
  99943. };
  99944. img.src = url;
  99945. newWindow.document.body.appendChild(img);
  99946. }
  99947. }, mimeType);
  99948. }
  99949. };
  99950. /**
  99951. * Downloads a blob in the browser
  99952. * @param blob defines the blob to download
  99953. * @param fileName defines the name of the downloaded file
  99954. */
  99955. Tools.Download = function (blob, fileName) {
  99956. if (navigator && navigator.msSaveBlob) {
  99957. navigator.msSaveBlob(blob, fileName);
  99958. return;
  99959. }
  99960. var url = window.URL.createObjectURL(blob);
  99961. var a = document.createElement("a");
  99962. document.body.appendChild(a);
  99963. a.style.display = "none";
  99964. a.href = url;
  99965. a.download = fileName;
  99966. a.addEventListener("click", function () {
  99967. if (a.parentElement) {
  99968. a.parentElement.removeChild(a);
  99969. }
  99970. });
  99971. a.click();
  99972. window.URL.revokeObjectURL(url);
  99973. };
  99974. /**
  99975. * Captures a screenshot of the current rendering
  99976. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99977. * @param engine defines the rendering engine
  99978. * @param camera defines the source camera
  99979. * @param size This parameter can be set to a single number or to an object with the
  99980. * following (optional) properties: precision, width, height. If a single number is passed,
  99981. * it will be used for both width and height. If an object is passed, the screenshot size
  99982. * will be derived from the parameters. The precision property is a multiplier allowing
  99983. * rendering at a higher or lower resolution
  99984. * @param successCallback defines the callback receives a single parameter which contains the
  99985. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  99986. * src parameter of an <img> to display it
  99987. * @param mimeType defines the MIME type of the screenshot image (default: image/png).
  99988. * Check your browser for supported MIME types
  99989. */
  99990. Tools.CreateScreenshot = function (engine, camera, size, successCallback, mimeType) {
  99991. if (mimeType === void 0) { mimeType = "image/png"; }
  99992. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  99993. };
  99994. /**
  99995. * Generates an image screenshot from the specified camera.
  99996. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_png
  99997. * @param engine The engine to use for rendering
  99998. * @param camera The camera to use for rendering
  99999. * @param size This parameter can be set to a single number or to an object with the
  100000. * following (optional) properties: precision, width, height. If a single number is passed,
  100001. * it will be used for both width and height. If an object is passed, the screenshot size
  100002. * will be derived from the parameters. The precision property is a multiplier allowing
  100003. * rendering at a higher or lower resolution
  100004. * @param successCallback The callback receives a single parameter which contains the
  100005. * screenshot as a string of base64-encoded characters. This string can be assigned to the
  100006. * src parameter of an <img> to display it
  100007. * @param mimeType The MIME type of the screenshot image (default: image/png).
  100008. * Check your browser for supported MIME types
  100009. * @param samples Texture samples (default: 1)
  100010. * @param antialiasing Whether antialiasing should be turned on or not (default: false)
  100011. * @param fileName A name for for the downloaded file.
  100012. */
  100013. Tools.CreateScreenshotUsingRenderTarget = function (engine, camera, size, successCallback, mimeType, samples, antialiasing, fileName) {
  100014. if (mimeType === void 0) { mimeType = "image/png"; }
  100015. if (samples === void 0) { samples = 1; }
  100016. if (antialiasing === void 0) { antialiasing = false; }
  100017. throw _devTools__WEBPACK_IMPORTED_MODULE_11__["_DevTools"].WarnImport("ScreenshotTools");
  100018. };
  100019. /**
  100020. * Implementation from http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript/2117523#answer-2117523
  100021. * Be aware Math.random() could cause collisions, but:
  100022. * "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"
  100023. * @returns a pseudo random id
  100024. */
  100025. Tools.RandomId = function () {
  100026. return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
  100027. var r = Math.random() * 16 | 0, v = c === 'x' ? r : (r & 0x3 | 0x8);
  100028. return v.toString(16);
  100029. });
  100030. };
  100031. /**
  100032. * Test if the given uri is a base64 string
  100033. * @param uri The uri to test
  100034. * @return True if the uri is a base64 string or false otherwise
  100035. */
  100036. Tools.IsBase64 = function (uri) {
  100037. return uri.length < 5 ? false : uri.substr(0, 5) === "data:";
  100038. };
  100039. /**
  100040. * Decode the given base64 uri.
  100041. * @param uri The uri to decode
  100042. * @return The decoded base64 data.
  100043. */
  100044. Tools.DecodeBase64 = function (uri) {
  100045. var decodedString = atob(uri.split(",")[1]);
  100046. var bufferLength = decodedString.length;
  100047. var bufferView = new Uint8Array(new ArrayBuffer(bufferLength));
  100048. for (var i = 0; i < bufferLength; i++) {
  100049. bufferView[i] = decodedString.charCodeAt(i);
  100050. }
  100051. return bufferView.buffer;
  100052. };
  100053. Object.defineProperty(Tools, "errorsCount", {
  100054. /**
  100055. * Gets a value indicating the number of loading errors
  100056. * @ignorenaming
  100057. */
  100058. get: function () {
  100059. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].errorsCount;
  100060. },
  100061. enumerable: true,
  100062. configurable: true
  100063. });
  100064. /**
  100065. * Log a message to the console
  100066. * @param message defines the message to log
  100067. */
  100068. Tools.Log = function (message) {
  100069. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Log(message);
  100070. };
  100071. /**
  100072. * Write a warning message to the console
  100073. * @param message defines the message to log
  100074. */
  100075. Tools.Warn = function (message) {
  100076. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Warn(message);
  100077. };
  100078. /**
  100079. * Write an error message to the console
  100080. * @param message defines the message to log
  100081. */
  100082. Tools.Error = function (message) {
  100083. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].Error(message);
  100084. };
  100085. Object.defineProperty(Tools, "LogCache", {
  100086. /**
  100087. * Gets current log cache (list of logs)
  100088. */
  100089. get: function () {
  100090. return _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogCache;
  100091. },
  100092. enumerable: true,
  100093. configurable: true
  100094. });
  100095. /**
  100096. * Clears the log cache
  100097. */
  100098. Tools.ClearLogCache = function () {
  100099. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ClearLogCache();
  100100. };
  100101. Object.defineProperty(Tools, "LogLevels", {
  100102. /**
  100103. * Sets the current log level (MessageLogLevel / WarningLogLevel / ErrorLogLevel)
  100104. */
  100105. set: function (level) {
  100106. _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].LogLevels = level;
  100107. },
  100108. enumerable: true,
  100109. configurable: true
  100110. });
  100111. /**
  100112. * Checks if the loaded document was accessed via `file:`-Protocol.
  100113. * @returns boolean
  100114. */
  100115. Tools.IsFileURL = function () {
  100116. return location.protocol === "file:";
  100117. };
  100118. Object.defineProperty(Tools, "PerformanceLogLevel", {
  100119. /**
  100120. * Sets the current performance log level
  100121. */
  100122. set: function (level) {
  100123. if ((level & Tools.PerformanceUserMarkLogLevel) === Tools.PerformanceUserMarkLogLevel) {
  100124. Tools.StartPerformanceCounter = Tools._StartUserMark;
  100125. Tools.EndPerformanceCounter = Tools._EndUserMark;
  100126. return;
  100127. }
  100128. if ((level & Tools.PerformanceConsoleLogLevel) === Tools.PerformanceConsoleLogLevel) {
  100129. Tools.StartPerformanceCounter = Tools._StartPerformanceConsole;
  100130. Tools.EndPerformanceCounter = Tools._EndPerformanceConsole;
  100131. return;
  100132. }
  100133. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  100134. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  100135. },
  100136. enumerable: true,
  100137. configurable: true
  100138. });
  100139. Tools._StartPerformanceCounterDisabled = function (counterName, condition) {
  100140. };
  100141. Tools._EndPerformanceCounterDisabled = function (counterName, condition) {
  100142. };
  100143. Tools._StartUserMark = function (counterName, condition) {
  100144. if (condition === void 0) { condition = true; }
  100145. if (!Tools._performance) {
  100146. if (!_domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist()) {
  100147. return;
  100148. }
  100149. Tools._performance = window.performance;
  100150. }
  100151. if (!condition || !Tools._performance.mark) {
  100152. return;
  100153. }
  100154. Tools._performance.mark(counterName + "-Begin");
  100155. };
  100156. Tools._EndUserMark = function (counterName, condition) {
  100157. if (condition === void 0) { condition = true; }
  100158. if (!condition || !Tools._performance.mark) {
  100159. return;
  100160. }
  100161. Tools._performance.mark(counterName + "-End");
  100162. Tools._performance.measure(counterName, counterName + "-Begin", counterName + "-End");
  100163. };
  100164. Tools._StartPerformanceConsole = function (counterName, condition) {
  100165. if (condition === void 0) { condition = true; }
  100166. if (!condition) {
  100167. return;
  100168. }
  100169. Tools._StartUserMark(counterName, condition);
  100170. if (console.time) {
  100171. console.time(counterName);
  100172. }
  100173. };
  100174. Tools._EndPerformanceConsole = function (counterName, condition) {
  100175. if (condition === void 0) { condition = true; }
  100176. if (!condition) {
  100177. return;
  100178. }
  100179. Tools._EndUserMark(counterName, condition);
  100180. if (console.time) {
  100181. console.timeEnd(counterName);
  100182. }
  100183. };
  100184. /**
  100185. * Injects the @see CustomRequestHeaders into the given request
  100186. * @param request the request that should be used for injection
  100187. */
  100188. Tools.InjectCustomRequestHeaders = function (request) {
  100189. for (var key in Tools.CustomRequestHeaders) {
  100190. var val = Tools.CustomRequestHeaders[key];
  100191. if (val) {
  100192. request.setRequestHeader(key, val);
  100193. }
  100194. }
  100195. };
  100196. Object.defineProperty(Tools, "Now", {
  100197. /**
  100198. * Gets either window.performance.now() if supported or Date.now() else
  100199. */
  100200. get: function () {
  100201. return _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  100202. },
  100203. enumerable: true,
  100204. configurable: true
  100205. });
  100206. /**
  100207. * This method will return the name of the class used to create the instance of the given object.
  100208. * It will works only on Javascript basic data types (number, string, ...) and instance of class declared with the @className decorator.
  100209. * @param object the object to get the class name from
  100210. * @param isType defines if the object is actually a type
  100211. * @returns the name of the class, will be "object" for a custom data type not using the @className decorator
  100212. */
  100213. Tools.GetClassName = function (object, isType) {
  100214. if (isType === void 0) { isType = false; }
  100215. var name = null;
  100216. if (!isType && object.getClassName) {
  100217. name = object.getClassName();
  100218. }
  100219. else {
  100220. if (object instanceof Object) {
  100221. var classObj = isType ? object : Object.getPrototypeOf(object);
  100222. name = classObj.constructor["__bjsclassName__"];
  100223. }
  100224. if (!name) {
  100225. name = typeof object;
  100226. }
  100227. }
  100228. return name;
  100229. };
  100230. /**
  100231. * Gets the first element of an array satisfying a given predicate
  100232. * @param array defines the array to browse
  100233. * @param predicate defines the predicate to use
  100234. * @returns null if not found or the element
  100235. */
  100236. Tools.First = function (array, predicate) {
  100237. for (var _i = 0, array_1 = array; _i < array_1.length; _i++) {
  100238. var el = array_1[_i];
  100239. if (predicate(el)) {
  100240. return el;
  100241. }
  100242. }
  100243. return null;
  100244. };
  100245. /**
  100246. * This method will return the name of the full name of the class, including its owning module (if any).
  100247. * 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).
  100248. * @param object the object to get the class name from
  100249. * @param isType defines if the object is actually a type
  100250. * @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.
  100251. * @ignorenaming
  100252. */
  100253. Tools.getFullClassName = function (object, isType) {
  100254. if (isType === void 0) { isType = false; }
  100255. var className = null;
  100256. var moduleName = null;
  100257. if (!isType && object.getClassName) {
  100258. className = object.getClassName();
  100259. }
  100260. else {
  100261. if (object instanceof Object) {
  100262. var classObj = isType ? object : Object.getPrototypeOf(object);
  100263. className = classObj.constructor["__bjsclassName__"];
  100264. moduleName = classObj.constructor["__bjsmoduleName__"];
  100265. }
  100266. if (!className) {
  100267. className = typeof object;
  100268. }
  100269. }
  100270. if (!className) {
  100271. return null;
  100272. }
  100273. return ((moduleName != null) ? (moduleName + ".") : "") + className;
  100274. };
  100275. /**
  100276. * Returns a promise that resolves after the given amount of time.
  100277. * @param delay Number of milliseconds to delay
  100278. * @returns Promise that resolves after the given amount of time
  100279. */
  100280. Tools.DelayAsync = function (delay) {
  100281. return new Promise(function (resolve) {
  100282. setTimeout(function () {
  100283. resolve();
  100284. }, delay);
  100285. });
  100286. };
  100287. /**
  100288. * Gets the current gradient from an array of IValueGradient
  100289. * @param ratio defines the current ratio to get
  100290. * @param gradients defines the array of IValueGradient
  100291. * @param updateFunc defines the callback function used to get the final value from the selected gradients
  100292. */
  100293. Tools.GetCurrentGradient = function (ratio, gradients, updateFunc) {
  100294. for (var gradientIndex = 0; gradientIndex < gradients.length - 1; gradientIndex++) {
  100295. var currentGradient = gradients[gradientIndex];
  100296. var nextGradient = gradients[gradientIndex + 1];
  100297. if (ratio >= currentGradient.gradient && ratio <= nextGradient.gradient) {
  100298. var scale = (ratio - currentGradient.gradient) / (nextGradient.gradient - currentGradient.gradient);
  100299. updateFunc(currentGradient, nextGradient, scale);
  100300. return;
  100301. }
  100302. }
  100303. // Use last index if over
  100304. var lastIndex = gradients.length - 1;
  100305. updateFunc(gradients[lastIndex], gradients[lastIndex], 1.0);
  100306. };
  100307. /**
  100308. * Gets or sets the base URL to use to load assets
  100309. */
  100310. Tools.BaseUrl = "";
  100311. /**
  100312. * Enable/Disable Custom HTTP Request Headers globally.
  100313. * default = false
  100314. * @see CustomRequestHeaders
  100315. */
  100316. Tools.UseCustomRequestHeaders = false;
  100317. /**
  100318. * Custom HTTP Request Headers to be sent with XMLHttpRequests
  100319. * i.e. when loading files, where the server/service expects an Authorization header.
  100320. * @see InjectCustomRequestHeaders injects them to an XMLHttpRequest
  100321. */
  100322. Tools.CustomRequestHeaders = {};
  100323. /**
  100324. * Gets or sets the retry strategy to apply when an error happens while loading an asset
  100325. */
  100326. Tools.DefaultRetryStrategy = RetryStrategy.ExponentialBackoff();
  100327. /**
  100328. * Default behaviour for cors in the application.
  100329. * It can be a string if the expected behavior is identical in the entire app.
  100330. * Or a callback to be able to set it per url or on a group of them (in case of Video source for instance)
  100331. */
  100332. Tools.CorsBehavior = "anonymous";
  100333. /**
  100334. * Gets or sets a global variable indicating if fallback texture must be used when a texture cannot be loaded
  100335. * @ignorenaming
  100336. */
  100337. Tools.UseFallbackTexture = true;
  100338. /**
  100339. * Use this object to register external classes like custom textures or material
  100340. * to allow the laoders to instantiate them
  100341. */
  100342. Tools.RegisteredExternalClasses = {};
  100343. /**
  100344. * Texture content used if a texture cannot loaded
  100345. * @ignorenaming
  100346. */
  100347. 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";
  100348. Tools._tmpFloatArray = new Float32Array(1);
  100349. /**
  100350. * Extracts text content from a DOM element hierarchy
  100351. * Back Compat only, please use DomManagement.GetDOMTextContent instead.
  100352. */
  100353. Tools.GetDOMTextContent = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].GetDOMTextContent;
  100354. /**
  100355. * Gets or sets a function used to pre-process url before using them to load assets
  100356. */
  100357. Tools.PreprocessUrl = function (url) {
  100358. return url;
  100359. };
  100360. // Logs
  100361. /**
  100362. * No log
  100363. */
  100364. Tools.NoneLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].NoneLogLevel;
  100365. /**
  100366. * Only message logs
  100367. */
  100368. Tools.MessageLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].MessageLogLevel;
  100369. /**
  100370. * Only warning logs
  100371. */
  100372. Tools.WarningLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].WarningLogLevel;
  100373. /**
  100374. * Only error logs
  100375. */
  100376. Tools.ErrorLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].ErrorLogLevel;
  100377. /**
  100378. * All logs
  100379. */
  100380. Tools.AllLogLevel = _logger__WEBPACK_IMPORTED_MODULE_7__["Logger"].AllLogLevel;
  100381. /**
  100382. * Checks if the window object exists
  100383. * Back Compat only, please use DomManagement.IsWindowObjectExist instead.
  100384. */
  100385. Tools.IsWindowObjectExist = _domManagement__WEBPACK_IMPORTED_MODULE_6__["DomManagement"].IsWindowObjectExist;
  100386. // Performances
  100387. /**
  100388. * No performance log
  100389. */
  100390. Tools.PerformanceNoneLogLevel = 0;
  100391. /**
  100392. * Use user marks to log performance
  100393. */
  100394. Tools.PerformanceUserMarkLogLevel = 1;
  100395. /**
  100396. * Log performance to the console
  100397. */
  100398. Tools.PerformanceConsoleLogLevel = 2;
  100399. /**
  100400. * Starts a performance counter
  100401. */
  100402. Tools.StartPerformanceCounter = Tools._StartPerformanceCounterDisabled;
  100403. /**
  100404. * Ends a specific performance coutner
  100405. */
  100406. Tools.EndPerformanceCounter = Tools._EndPerformanceCounterDisabled;
  100407. return Tools;
  100408. }());
  100409. /**
  100410. * This class is used to track a performance counter which is number based.
  100411. * The user has access to many properties which give statistics of different nature.
  100412. *
  100413. * The implementer can track two kinds of Performance Counter: time and count.
  100414. * 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.
  100415. * 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.
  100416. */
  100417. var PerfCounter = /** @class */ (function () {
  100418. /**
  100419. * Creates a new counter
  100420. */
  100421. function PerfCounter() {
  100422. this._startMonitoringTime = 0;
  100423. this._min = 0;
  100424. this._max = 0;
  100425. this._average = 0;
  100426. this._lastSecAverage = 0;
  100427. this._current = 0;
  100428. this._totalValueCount = 0;
  100429. this._totalAccumulated = 0;
  100430. this._lastSecAccumulated = 0;
  100431. this._lastSecTime = 0;
  100432. this._lastSecValueCount = 0;
  100433. }
  100434. Object.defineProperty(PerfCounter.prototype, "min", {
  100435. /**
  100436. * Returns the smallest value ever
  100437. */
  100438. get: function () {
  100439. return this._min;
  100440. },
  100441. enumerable: true,
  100442. configurable: true
  100443. });
  100444. Object.defineProperty(PerfCounter.prototype, "max", {
  100445. /**
  100446. * Returns the biggest value ever
  100447. */
  100448. get: function () {
  100449. return this._max;
  100450. },
  100451. enumerable: true,
  100452. configurable: true
  100453. });
  100454. Object.defineProperty(PerfCounter.prototype, "average", {
  100455. /**
  100456. * Returns the average value since the performance counter is running
  100457. */
  100458. get: function () {
  100459. return this._average;
  100460. },
  100461. enumerable: true,
  100462. configurable: true
  100463. });
  100464. Object.defineProperty(PerfCounter.prototype, "lastSecAverage", {
  100465. /**
  100466. * Returns the average value of the last second the counter was monitored
  100467. */
  100468. get: function () {
  100469. return this._lastSecAverage;
  100470. },
  100471. enumerable: true,
  100472. configurable: true
  100473. });
  100474. Object.defineProperty(PerfCounter.prototype, "current", {
  100475. /**
  100476. * Returns the current value
  100477. */
  100478. get: function () {
  100479. return this._current;
  100480. },
  100481. enumerable: true,
  100482. configurable: true
  100483. });
  100484. Object.defineProperty(PerfCounter.prototype, "total", {
  100485. /**
  100486. * Gets the accumulated total
  100487. */
  100488. get: function () {
  100489. return this._totalAccumulated;
  100490. },
  100491. enumerable: true,
  100492. configurable: true
  100493. });
  100494. Object.defineProperty(PerfCounter.prototype, "count", {
  100495. /**
  100496. * Gets the total value count
  100497. */
  100498. get: function () {
  100499. return this._totalValueCount;
  100500. },
  100501. enumerable: true,
  100502. configurable: true
  100503. });
  100504. /**
  100505. * Call this method to start monitoring a new frame.
  100506. * 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.
  100507. */
  100508. PerfCounter.prototype.fetchNewFrame = function () {
  100509. this._totalValueCount++;
  100510. this._current = 0;
  100511. this._lastSecValueCount++;
  100512. };
  100513. /**
  100514. * Call this method to monitor a count of something (e.g. mesh drawn in viewport count)
  100515. * @param newCount the count value to add to the monitored count
  100516. * @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.
  100517. */
  100518. PerfCounter.prototype.addCount = function (newCount, fetchResult) {
  100519. if (!PerfCounter.Enabled) {
  100520. return;
  100521. }
  100522. this._current += newCount;
  100523. if (fetchResult) {
  100524. this._fetchResult();
  100525. }
  100526. };
  100527. /**
  100528. * Start monitoring this performance counter
  100529. */
  100530. PerfCounter.prototype.beginMonitoring = function () {
  100531. if (!PerfCounter.Enabled) {
  100532. return;
  100533. }
  100534. this._startMonitoringTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  100535. };
  100536. /**
  100537. * Compute the time lapsed since the previous beginMonitoring() call.
  100538. * @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
  100539. */
  100540. PerfCounter.prototype.endMonitoring = function (newFrame) {
  100541. if (newFrame === void 0) { newFrame = true; }
  100542. if (!PerfCounter.Enabled) {
  100543. return;
  100544. }
  100545. if (newFrame) {
  100546. this.fetchNewFrame();
  100547. }
  100548. var currentTime = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  100549. this._current = currentTime - this._startMonitoringTime;
  100550. if (newFrame) {
  100551. this._fetchResult();
  100552. }
  100553. };
  100554. PerfCounter.prototype._fetchResult = function () {
  100555. this._totalAccumulated += this._current;
  100556. this._lastSecAccumulated += this._current;
  100557. // Min/Max update
  100558. this._min = Math.min(this._min, this._current);
  100559. this._max = Math.max(this._max, this._current);
  100560. this._average = this._totalAccumulated / this._totalValueCount;
  100561. // Reset last sec?
  100562. var now = _precisionDate__WEBPACK_IMPORTED_MODULE_10__["PrecisionDate"].Now;
  100563. if ((now - this._lastSecTime) > 1000) {
  100564. this._lastSecAverage = this._lastSecAccumulated / this._lastSecValueCount;
  100565. this._lastSecTime = now;
  100566. this._lastSecAccumulated = 0;
  100567. this._lastSecValueCount = 0;
  100568. }
  100569. };
  100570. /**
  100571. * Gets or sets a global boolean to turn on and off all the counters
  100572. */
  100573. PerfCounter.Enabled = true;
  100574. return PerfCounter;
  100575. }());
  100576. /**
  100577. * Use this className as a decorator on a given class definition to add it a name and optionally its module.
  100578. * You can then use the Tools.getClassName(obj) on an instance to retrieve its class name.
  100579. * This method is the only way to get it done in all cases, even if the .js file declaring the class is minified
  100580. * @param name The name of the class, case should be preserved
  100581. * @param module The name of the Module hosting the class, optional, but strongly recommended to specify if possible. Case should be preserved.
  100582. */
  100583. function className(name, module) {
  100584. return function (target) {
  100585. target["__bjsclassName__"] = name;
  100586. target["__bjsmoduleName__"] = (module != null) ? module : null;
  100587. };
  100588. }
  100589. /**
  100590. * An implementation of a loop for asynchronous functions.
  100591. */
  100592. var AsyncLoop = /** @class */ (function () {
  100593. /**
  100594. * Constructor.
  100595. * @param iterations the number of iterations.
  100596. * @param func the function to run each iteration
  100597. * @param successCallback the callback that will be called upon succesful execution
  100598. * @param offset starting offset.
  100599. */
  100600. function AsyncLoop(
  100601. /**
  100602. * Defines the number of iterations for the loop
  100603. */
  100604. iterations, func, successCallback, offset) {
  100605. if (offset === void 0) { offset = 0; }
  100606. this.iterations = iterations;
  100607. this.index = offset - 1;
  100608. this._done = false;
  100609. this._fn = func;
  100610. this._successCallback = successCallback;
  100611. }
  100612. /**
  100613. * Execute the next iteration. Must be called after the last iteration was finished.
  100614. */
  100615. AsyncLoop.prototype.executeNext = function () {
  100616. if (!this._done) {
  100617. if (this.index + 1 < this.iterations) {
  100618. ++this.index;
  100619. this._fn(this);
  100620. }
  100621. else {
  100622. this.breakLoop();
  100623. }
  100624. }
  100625. };
  100626. /**
  100627. * Break the loop and run the success callback.
  100628. */
  100629. AsyncLoop.prototype.breakLoop = function () {
  100630. this._done = true;
  100631. this._successCallback();
  100632. };
  100633. /**
  100634. * Create and run an async loop.
  100635. * @param iterations the number of iterations.
  100636. * @param fn the function to run each iteration
  100637. * @param successCallback the callback that will be called upon succesful execution
  100638. * @param offset starting offset.
  100639. * @returns the created async loop object
  100640. */
  100641. AsyncLoop.Run = function (iterations, fn, successCallback, offset) {
  100642. if (offset === void 0) { offset = 0; }
  100643. var loop = new AsyncLoop(iterations, fn, successCallback, offset);
  100644. loop.executeNext();
  100645. return loop;
  100646. };
  100647. /**
  100648. * A for-loop that will run a given number of iterations synchronous and the rest async.
  100649. * @param iterations total number of iterations
  100650. * @param syncedIterations number of synchronous iterations in each async iteration.
  100651. * @param fn the function to call each iteration.
  100652. * @param callback a success call back that will be called when iterating stops.
  100653. * @param breakFunction a break condition (optional)
  100654. * @param timeout timeout settings for the setTimeout function. default - 0.
  100655. * @returns the created async loop object
  100656. */
  100657. AsyncLoop.SyncAsyncForLoop = function (iterations, syncedIterations, fn, callback, breakFunction, timeout) {
  100658. if (timeout === void 0) { timeout = 0; }
  100659. return AsyncLoop.Run(Math.ceil(iterations / syncedIterations), function (loop) {
  100660. if (breakFunction && breakFunction()) {
  100661. loop.breakLoop();
  100662. }
  100663. else {
  100664. setTimeout(function () {
  100665. for (var i = 0; i < syncedIterations; ++i) {
  100666. var iteration = (loop.index * syncedIterations) + i;
  100667. if (iteration >= iterations) {
  100668. break;
  100669. }
  100670. fn(iteration);
  100671. if (breakFunction && breakFunction()) {
  100672. loop.breakLoop();
  100673. break;
  100674. }
  100675. }
  100676. loop.executeNext();
  100677. }, timeout);
  100678. }
  100679. }, callback);
  100680. };
  100681. return AsyncLoop;
  100682. }());
  100683. /***/ }),
  100684. /***/ "./Misc/typeStore.ts":
  100685. /*!***************************!*\
  100686. !*** ./Misc/typeStore.ts ***!
  100687. \***************************/
  100688. /*! exports provided: _TypeStore */
  100689. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100690. "use strict";
  100691. __webpack_require__.r(__webpack_exports__);
  100692. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _TypeStore; });
  100693. /** @hidden */
  100694. var _TypeStore = /** @class */ (function () {
  100695. function _TypeStore() {
  100696. }
  100697. /** @hidden */
  100698. _TypeStore.GetClass = function (fqdn) {
  100699. if (this.RegisteredTypes && this.RegisteredTypes[fqdn]) {
  100700. return this.RegisteredTypes[fqdn];
  100701. }
  100702. return null;
  100703. };
  100704. /** @hidden */
  100705. _TypeStore.RegisteredTypes = {};
  100706. return _TypeStore;
  100707. }());
  100708. /***/ }),
  100709. /***/ "./Misc/videoRecorder.ts":
  100710. /*!*******************************!*\
  100711. !*** ./Misc/videoRecorder.ts ***!
  100712. \*******************************/
  100713. /*! exports provided: VideoRecorder */
  100714. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100715. "use strict";
  100716. __webpack_require__.r(__webpack_exports__);
  100717. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return VideoRecorder; });
  100718. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  100719. /* harmony import */ var _tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./tools */ "./Misc/tools.ts");
  100720. /**
  100721. * This can helps recording videos from BabylonJS.
  100722. * This is based on the available WebRTC functionalities of the browser.
  100723. *
  100724. * @see http://doc.babylonjs.com/how_to/render_scene_on_a_video
  100725. */
  100726. var VideoRecorder = /** @class */ (function () {
  100727. /**
  100728. * Create a new VideoCapture object which can help converting what you see in Babylon to
  100729. * a video file.
  100730. * @param engine Defines the BabylonJS Engine you wish to record
  100731. * @param options Defines options that can be used to customized the capture
  100732. */
  100733. function VideoRecorder(engine, options) {
  100734. if (options === void 0) { options = null; }
  100735. if (!VideoRecorder.IsSupported(engine)) {
  100736. throw "Your browser does not support recording so far.";
  100737. }
  100738. var canvas = engine.getRenderingCanvas();
  100739. if (!canvas) {
  100740. throw "The babylon engine must have a canvas to be recorded";
  100741. }
  100742. this._canvas = canvas;
  100743. this._canvas.isRecording = false;
  100744. this._options = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({}, VideoRecorder._defaultOptions, options);
  100745. var stream = this._canvas.captureStream(this._options.fps);
  100746. this._mediaRecorder = new MediaRecorder(stream, { mimeType: this._options.mimeType });
  100747. this._mediaRecorder.ondataavailable = this._handleDataAvailable.bind(this);
  100748. this._mediaRecorder.onerror = this._handleError.bind(this);
  100749. this._mediaRecorder.onstop = this._handleStop.bind(this);
  100750. }
  100751. /**
  100752. * Returns wehther or not the VideoRecorder is available in your browser.
  100753. * @param engine Defines the Babylon Engine to check the support for
  100754. * @returns true if supported otherwise false
  100755. */
  100756. VideoRecorder.IsSupported = function (engine) {
  100757. var canvas = engine.getRenderingCanvas();
  100758. return (!!canvas && typeof canvas.captureStream === "function");
  100759. };
  100760. Object.defineProperty(VideoRecorder.prototype, "isRecording", {
  100761. /**
  100762. * True wether a recording is already in progress.
  100763. */
  100764. get: function () {
  100765. return !!this._canvas && this._canvas.isRecording;
  100766. },
  100767. enumerable: true,
  100768. configurable: true
  100769. });
  100770. /**
  100771. * Stops the current recording before the default capture timeout passed in the startRecording
  100772. * functions.
  100773. */
  100774. VideoRecorder.prototype.stopRecording = function () {
  100775. if (!this._canvas || !this._mediaRecorder) {
  100776. return;
  100777. }
  100778. if (!this.isRecording) {
  100779. return;
  100780. }
  100781. this._canvas.isRecording = false;
  100782. this._mediaRecorder.stop();
  100783. };
  100784. /**
  100785. * Starts recording the canvas for a max duration specified in parameters.
  100786. * @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.
  100787. * @param maxDuration Defines the maximum recording time in seconds.
  100788. * It default to 7 seconds. A value of zero will not stop automatically, you would need to call stopRecording manually.
  100789. * @return a promise callback at the end of the recording with the video data in Blob.
  100790. */
  100791. VideoRecorder.prototype.startRecording = function (fileName, maxDuration) {
  100792. var _this = this;
  100793. if (fileName === void 0) { fileName = "babylonjs.webm"; }
  100794. if (maxDuration === void 0) { maxDuration = 7; }
  100795. if (!this._canvas || !this._mediaRecorder) {
  100796. throw "Recorder has already been disposed";
  100797. }
  100798. if (this.isRecording) {
  100799. throw "Recording already in progress";
  100800. }
  100801. if (maxDuration > 0) {
  100802. setTimeout(function () {
  100803. _this.stopRecording();
  100804. }, maxDuration * 1000);
  100805. }
  100806. this._fileName = fileName;
  100807. this._recordedChunks = [];
  100808. this._resolve = null;
  100809. this._reject = null;
  100810. this._canvas.isRecording = true;
  100811. this._mediaRecorder.start(this._options.recordChunckSize);
  100812. return new Promise(function (resolve, reject) {
  100813. _this._resolve = resolve;
  100814. _this._reject = reject;
  100815. });
  100816. };
  100817. /**
  100818. * Releases internal resources used during the recording.
  100819. */
  100820. VideoRecorder.prototype.dispose = function () {
  100821. this._canvas = null;
  100822. this._mediaRecorder = null;
  100823. this._recordedChunks = [];
  100824. this._fileName = null;
  100825. this._resolve = null;
  100826. this._reject = null;
  100827. };
  100828. VideoRecorder.prototype._handleDataAvailable = function (event) {
  100829. if (event.data.size > 0) {
  100830. this._recordedChunks.push(event.data);
  100831. }
  100832. };
  100833. VideoRecorder.prototype._handleError = function (event) {
  100834. this.stopRecording();
  100835. if (this._reject) {
  100836. this._reject(event.error);
  100837. }
  100838. else {
  100839. throw new event.error();
  100840. }
  100841. };
  100842. VideoRecorder.prototype._handleStop = function () {
  100843. this.stopRecording();
  100844. var superBuffer = new Blob(this._recordedChunks);
  100845. if (this._resolve) {
  100846. this._resolve(superBuffer);
  100847. }
  100848. window.URL.createObjectURL(superBuffer);
  100849. if (this._fileName) {
  100850. _tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].Download(superBuffer, this._fileName);
  100851. }
  100852. };
  100853. VideoRecorder._defaultOptions = {
  100854. mimeType: "video/webm",
  100855. fps: 25,
  100856. recordChunckSize: 3000
  100857. };
  100858. return VideoRecorder;
  100859. }());
  100860. /***/ }),
  100861. /***/ "./Misc/virtualJoystick.ts":
  100862. /*!*********************************!*\
  100863. !*** ./Misc/virtualJoystick.ts ***!
  100864. \*********************************/
  100865. /*! exports provided: JoystickAxis, VirtualJoystick */
  100866. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  100867. "use strict";
  100868. __webpack_require__.r(__webpack_exports__);
  100869. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return JoystickAxis; });
  100870. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return VirtualJoystick; });
  100871. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  100872. /* harmony import */ var _stringDictionary__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./stringDictionary */ "./Misc/stringDictionary.ts");
  100873. // Mainly based on these 2 articles :
  100874. // 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
  100875. // & on Seb Lee-Delisle original work: http://seb.ly/2011/04/multi-touch-game-controller-in-javascripthtml5-for-ipad/
  100876. /**
  100877. * Defines the potential axis of a Joystick
  100878. */
  100879. var JoystickAxis;
  100880. (function (JoystickAxis) {
  100881. /** X axis */
  100882. JoystickAxis[JoystickAxis["X"] = 0] = "X";
  100883. /** Y axis */
  100884. JoystickAxis[JoystickAxis["Y"] = 1] = "Y";
  100885. /** Z axis */
  100886. JoystickAxis[JoystickAxis["Z"] = 2] = "Z";
  100887. })(JoystickAxis || (JoystickAxis = {}));
  100888. /**
  100889. * Class used to define virtual joystick (used in touch mode)
  100890. */
  100891. var VirtualJoystick = /** @class */ (function () {
  100892. /**
  100893. * Creates a new virtual joystick
  100894. * @param leftJoystick defines that the joystick is for left hand (false by default)
  100895. */
  100896. function VirtualJoystick(leftJoystick) {
  100897. var _this = this;
  100898. if (leftJoystick) {
  100899. this._leftJoystick = true;
  100900. }
  100901. else {
  100902. this._leftJoystick = false;
  100903. }
  100904. VirtualJoystick._globalJoystickIndex++;
  100905. // By default left & right arrow keys are moving the X
  100906. // and up & down keys are moving the Y
  100907. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  100908. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  100909. this.reverseLeftRight = false;
  100910. this.reverseUpDown = false;
  100911. // collections of pointers
  100912. this._touches = new _stringDictionary__WEBPACK_IMPORTED_MODULE_1__["StringDictionary"]();
  100913. this.deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  100914. this._joystickSensibility = 25;
  100915. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100916. this._onResize = function (evt) {
  100917. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100918. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100919. if (VirtualJoystick.Canvas) {
  100920. VirtualJoystick.Canvas.width = VirtualJoystick.vjCanvasWidth;
  100921. VirtualJoystick.Canvas.height = VirtualJoystick.vjCanvasHeight;
  100922. }
  100923. VirtualJoystick.halfWidth = VirtualJoystick.vjCanvasWidth / 2;
  100924. };
  100925. // injecting a canvas element on top of the canvas 3D game
  100926. if (!VirtualJoystick.Canvas) {
  100927. window.addEventListener("resize", this._onResize, false);
  100928. VirtualJoystick.Canvas = document.createElement("canvas");
  100929. VirtualJoystick.vjCanvasWidth = window.innerWidth;
  100930. VirtualJoystick.vjCanvasHeight = window.innerHeight;
  100931. VirtualJoystick.Canvas.width = window.innerWidth;
  100932. VirtualJoystick.Canvas.height = window.innerHeight;
  100933. VirtualJoystick.Canvas.style.width = "100%";
  100934. VirtualJoystick.Canvas.style.height = "100%";
  100935. VirtualJoystick.Canvas.style.position = "absolute";
  100936. VirtualJoystick.Canvas.style.backgroundColor = "transparent";
  100937. VirtualJoystick.Canvas.style.top = "0px";
  100938. VirtualJoystick.Canvas.style.left = "0px";
  100939. VirtualJoystick.Canvas.style.zIndex = "5";
  100940. VirtualJoystick.Canvas.style.msTouchAction = "none";
  100941. // Support for jQuery PEP polyfill
  100942. VirtualJoystick.Canvas.setAttribute("touch-action", "none");
  100943. var context = VirtualJoystick.Canvas.getContext('2d');
  100944. if (!context) {
  100945. throw new Error("Unable to create canvas for virtual joystick");
  100946. }
  100947. VirtualJoystick.vjCanvasContext = context;
  100948. VirtualJoystick.vjCanvasContext.strokeStyle = "#ffffff";
  100949. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  100950. document.body.appendChild(VirtualJoystick.Canvas);
  100951. }
  100952. VirtualJoystick.halfWidth = VirtualJoystick.Canvas.width / 2;
  100953. this.pressed = false;
  100954. // default joystick color
  100955. this._joystickColor = "cyan";
  100956. this._joystickPointerID = -1;
  100957. // current joystick position
  100958. this._joystickPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100959. this._joystickPreviousPointerPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100960. // origin joystick position
  100961. this._joystickPointerStartPos = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100962. this._deltaJoystickVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  100963. this._onPointerDownHandlerRef = function (evt) {
  100964. _this._onPointerDown(evt);
  100965. };
  100966. this._onPointerMoveHandlerRef = function (evt) {
  100967. _this._onPointerMove(evt);
  100968. };
  100969. this._onPointerUpHandlerRef = function (evt) {
  100970. _this._onPointerUp(evt);
  100971. };
  100972. VirtualJoystick.Canvas.addEventListener('pointerdown', this._onPointerDownHandlerRef, false);
  100973. VirtualJoystick.Canvas.addEventListener('pointermove', this._onPointerMoveHandlerRef, false);
  100974. VirtualJoystick.Canvas.addEventListener('pointerup', this._onPointerUpHandlerRef, false);
  100975. VirtualJoystick.Canvas.addEventListener('pointerout', this._onPointerUpHandlerRef, false);
  100976. VirtualJoystick.Canvas.addEventListener("contextmenu", function (evt) {
  100977. evt.preventDefault(); // Disables system menu
  100978. }, false);
  100979. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  100980. }
  100981. /**
  100982. * Defines joystick sensibility (ie. the ratio beteen a physical move and virtual joystick position change)
  100983. * @param newJoystickSensibility defines the new sensibility
  100984. */
  100985. VirtualJoystick.prototype.setJoystickSensibility = function (newJoystickSensibility) {
  100986. this._joystickSensibility = newJoystickSensibility;
  100987. this._inversedSensibility = 1 / (this._joystickSensibility / 1000);
  100988. };
  100989. VirtualJoystick.prototype._onPointerDown = function (e) {
  100990. var positionOnScreenCondition;
  100991. e.preventDefault();
  100992. if (this._leftJoystick === true) {
  100993. positionOnScreenCondition = (e.clientX < VirtualJoystick.halfWidth);
  100994. }
  100995. else {
  100996. positionOnScreenCondition = (e.clientX > VirtualJoystick.halfWidth);
  100997. }
  100998. if (positionOnScreenCondition && this._joystickPointerID < 0) {
  100999. // First contact will be dedicated to the virtual joystick
  101000. this._joystickPointerID = e.pointerId;
  101001. this._joystickPointerStartPos.x = e.clientX;
  101002. this._joystickPointerStartPos.y = e.clientY;
  101003. this._joystickPointerPos = this._joystickPointerStartPos.clone();
  101004. this._joystickPreviousPointerPos = this._joystickPointerStartPos.clone();
  101005. this._deltaJoystickVector.x = 0;
  101006. this._deltaJoystickVector.y = 0;
  101007. this.pressed = true;
  101008. this._touches.add(e.pointerId.toString(), e);
  101009. }
  101010. else {
  101011. // You can only trigger the action buttons with a joystick declared
  101012. if (VirtualJoystick._globalJoystickIndex < 2 && this._action) {
  101013. this._action();
  101014. this._touches.add(e.pointerId.toString(), { x: e.clientX, y: e.clientY, prevX: e.clientX, prevY: e.clientY });
  101015. }
  101016. }
  101017. };
  101018. VirtualJoystick.prototype._onPointerMove = function (e) {
  101019. // If the current pointer is the one associated to the joystick (first touch contact)
  101020. if (this._joystickPointerID == e.pointerId) {
  101021. this._joystickPointerPos.x = e.clientX;
  101022. this._joystickPointerPos.y = e.clientY;
  101023. this._deltaJoystickVector = this._joystickPointerPos.clone();
  101024. this._deltaJoystickVector = this._deltaJoystickVector.subtract(this._joystickPointerStartPos);
  101025. var directionLeftRight = this.reverseLeftRight ? -1 : 1;
  101026. var deltaJoystickX = directionLeftRight * this._deltaJoystickVector.x / this._inversedSensibility;
  101027. switch (this._axisTargetedByLeftAndRight) {
  101028. case JoystickAxis.X:
  101029. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickX));
  101030. break;
  101031. case JoystickAxis.Y:
  101032. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickX));
  101033. break;
  101034. case JoystickAxis.Z:
  101035. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickX));
  101036. break;
  101037. }
  101038. var directionUpDown = this.reverseUpDown ? 1 : -1;
  101039. var deltaJoystickY = directionUpDown * this._deltaJoystickVector.y / this._inversedSensibility;
  101040. switch (this._axisTargetedByUpAndDown) {
  101041. case JoystickAxis.X:
  101042. this.deltaPosition.x = Math.min(1, Math.max(-1, deltaJoystickY));
  101043. break;
  101044. case JoystickAxis.Y:
  101045. this.deltaPosition.y = Math.min(1, Math.max(-1, deltaJoystickY));
  101046. break;
  101047. case JoystickAxis.Z:
  101048. this.deltaPosition.z = Math.min(1, Math.max(-1, deltaJoystickY));
  101049. break;
  101050. }
  101051. }
  101052. else {
  101053. var data = this._touches.get(e.pointerId.toString());
  101054. if (data) {
  101055. data.x = e.clientX;
  101056. data.y = e.clientY;
  101057. }
  101058. }
  101059. };
  101060. VirtualJoystick.prototype._onPointerUp = function (e) {
  101061. if (this._joystickPointerID == e.pointerId) {
  101062. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPointerStartPos.x - 64, this._joystickPointerStartPos.y - 64, 128, 128);
  101063. VirtualJoystick.vjCanvasContext.clearRect(this._joystickPreviousPointerPos.x - 42, this._joystickPreviousPointerPos.y - 42, 84, 84);
  101064. this._joystickPointerID = -1;
  101065. this.pressed = false;
  101066. }
  101067. else {
  101068. var touch = this._touches.get(e.pointerId.toString());
  101069. if (touch) {
  101070. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  101071. }
  101072. }
  101073. this._deltaJoystickVector.x = 0;
  101074. this._deltaJoystickVector.y = 0;
  101075. this._touches.remove(e.pointerId.toString());
  101076. };
  101077. /**
  101078. * Change the color of the virtual joystick
  101079. * @param newColor a string that must be a CSS color value (like "red") or the hexa value (like "#FF0000")
  101080. */
  101081. VirtualJoystick.prototype.setJoystickColor = function (newColor) {
  101082. this._joystickColor = newColor;
  101083. };
  101084. /**
  101085. * Defines a callback to call when the joystick is touched
  101086. * @param action defines the callback
  101087. */
  101088. VirtualJoystick.prototype.setActionOnTouch = function (action) {
  101089. this._action = action;
  101090. };
  101091. /**
  101092. * Defines which axis you'd like to control for left & right
  101093. * @param axis defines the axis to use
  101094. */
  101095. VirtualJoystick.prototype.setAxisForLeftRight = function (axis) {
  101096. switch (axis) {
  101097. case JoystickAxis.X:
  101098. case JoystickAxis.Y:
  101099. case JoystickAxis.Z:
  101100. this._axisTargetedByLeftAndRight = axis;
  101101. break;
  101102. default:
  101103. this._axisTargetedByLeftAndRight = JoystickAxis.X;
  101104. break;
  101105. }
  101106. };
  101107. /**
  101108. * Defines which axis you'd like to control for up & down
  101109. * @param axis defines the axis to use
  101110. */
  101111. VirtualJoystick.prototype.setAxisForUpDown = function (axis) {
  101112. switch (axis) {
  101113. case JoystickAxis.X:
  101114. case JoystickAxis.Y:
  101115. case JoystickAxis.Z:
  101116. this._axisTargetedByUpAndDown = axis;
  101117. break;
  101118. default:
  101119. this._axisTargetedByUpAndDown = JoystickAxis.Y;
  101120. break;
  101121. }
  101122. };
  101123. VirtualJoystick.prototype._drawVirtualJoystick = function () {
  101124. var _this = this;
  101125. if (this.pressed) {
  101126. this._touches.forEach(function (key, touch) {
  101127. if (touch.pointerId === _this._joystickPointerID) {
  101128. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPointerStartPos.x - 64, _this._joystickPointerStartPos.y - 64, 128, 128);
  101129. VirtualJoystick.vjCanvasContext.clearRect(_this._joystickPreviousPointerPos.x - 42, _this._joystickPreviousPointerPos.y - 42, 84, 84);
  101130. VirtualJoystick.vjCanvasContext.beginPath();
  101131. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  101132. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  101133. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 40, 0, Math.PI * 2, true);
  101134. VirtualJoystick.vjCanvasContext.stroke();
  101135. VirtualJoystick.vjCanvasContext.closePath();
  101136. VirtualJoystick.vjCanvasContext.beginPath();
  101137. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  101138. VirtualJoystick.vjCanvasContext.lineWidth = 2;
  101139. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerStartPos.x, _this._joystickPointerStartPos.y, 60, 0, Math.PI * 2, true);
  101140. VirtualJoystick.vjCanvasContext.stroke();
  101141. VirtualJoystick.vjCanvasContext.closePath();
  101142. VirtualJoystick.vjCanvasContext.beginPath();
  101143. VirtualJoystick.vjCanvasContext.strokeStyle = _this._joystickColor;
  101144. VirtualJoystick.vjCanvasContext.arc(_this._joystickPointerPos.x, _this._joystickPointerPos.y, 40, 0, Math.PI * 2, true);
  101145. VirtualJoystick.vjCanvasContext.stroke();
  101146. VirtualJoystick.vjCanvasContext.closePath();
  101147. _this._joystickPreviousPointerPos = _this._joystickPointerPos.clone();
  101148. }
  101149. else {
  101150. VirtualJoystick.vjCanvasContext.clearRect(touch.prevX - 44, touch.prevY - 44, 88, 88);
  101151. VirtualJoystick.vjCanvasContext.beginPath();
  101152. VirtualJoystick.vjCanvasContext.fillStyle = "white";
  101153. VirtualJoystick.vjCanvasContext.beginPath();
  101154. VirtualJoystick.vjCanvasContext.strokeStyle = "red";
  101155. VirtualJoystick.vjCanvasContext.lineWidth = 6;
  101156. VirtualJoystick.vjCanvasContext.arc(touch.x, touch.y, 40, 0, Math.PI * 2, true);
  101157. VirtualJoystick.vjCanvasContext.stroke();
  101158. VirtualJoystick.vjCanvasContext.closePath();
  101159. touch.prevX = touch.x;
  101160. touch.prevY = touch.y;
  101161. }
  101162. });
  101163. }
  101164. requestAnimationFrame(function () { _this._drawVirtualJoystick(); });
  101165. };
  101166. /**
  101167. * Release internal HTML canvas
  101168. */
  101169. VirtualJoystick.prototype.releaseCanvas = function () {
  101170. if (VirtualJoystick.Canvas) {
  101171. VirtualJoystick.Canvas.removeEventListener('pointerdown', this._onPointerDownHandlerRef);
  101172. VirtualJoystick.Canvas.removeEventListener('pointermove', this._onPointerMoveHandlerRef);
  101173. VirtualJoystick.Canvas.removeEventListener('pointerup', this._onPointerUpHandlerRef);
  101174. VirtualJoystick.Canvas.removeEventListener('pointerout', this._onPointerUpHandlerRef);
  101175. window.removeEventListener("resize", this._onResize);
  101176. document.body.removeChild(VirtualJoystick.Canvas);
  101177. VirtualJoystick.Canvas = null;
  101178. }
  101179. };
  101180. // Used to draw the virtual joystick inside a 2D canvas on top of the WebGL rendering canvas
  101181. VirtualJoystick._globalJoystickIndex = 0;
  101182. return VirtualJoystick;
  101183. }());
  101184. /***/ }),
  101185. /***/ "./Misc/workerPool.ts":
  101186. /*!****************************!*\
  101187. !*** ./Misc/workerPool.ts ***!
  101188. \****************************/
  101189. /*! exports provided: WorkerPool */
  101190. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101191. "use strict";
  101192. __webpack_require__.r(__webpack_exports__);
  101193. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return WorkerPool; });
  101194. /**
  101195. * Helper class to push actions to a pool of workers.
  101196. */
  101197. var WorkerPool = /** @class */ (function () {
  101198. /**
  101199. * Constructor
  101200. * @param workers Array of workers to use for actions
  101201. */
  101202. function WorkerPool(workers) {
  101203. this._pendingActions = new Array();
  101204. this._workerInfos = workers.map(function (worker) { return ({
  101205. worker: worker,
  101206. active: false
  101207. }); });
  101208. }
  101209. /**
  101210. * Terminates all workers and clears any pending actions.
  101211. */
  101212. WorkerPool.prototype.dispose = function () {
  101213. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  101214. var workerInfo = _a[_i];
  101215. workerInfo.worker.terminate();
  101216. }
  101217. delete this._workerInfos;
  101218. delete this._pendingActions;
  101219. };
  101220. /**
  101221. * Pushes an action to the worker pool. If all the workers are active, the action will be
  101222. * pended until a worker has completed its action.
  101223. * @param action The action to perform. Call onComplete when the action is complete.
  101224. */
  101225. WorkerPool.prototype.push = function (action) {
  101226. for (var _i = 0, _a = this._workerInfos; _i < _a.length; _i++) {
  101227. var workerInfo = _a[_i];
  101228. if (!workerInfo.active) {
  101229. this._execute(workerInfo, action);
  101230. return;
  101231. }
  101232. }
  101233. this._pendingActions.push(action);
  101234. };
  101235. WorkerPool.prototype._execute = function (workerInfo, action) {
  101236. var _this = this;
  101237. workerInfo.active = true;
  101238. action(workerInfo.worker, function () {
  101239. workerInfo.active = false;
  101240. var nextAction = _this._pendingActions.shift();
  101241. if (nextAction) {
  101242. _this._execute(workerInfo, nextAction);
  101243. }
  101244. });
  101245. };
  101246. return WorkerPool;
  101247. }());
  101248. /***/ }),
  101249. /***/ "./Morph/index.ts":
  101250. /*!************************!*\
  101251. !*** ./Morph/index.ts ***!
  101252. \************************/
  101253. /*! exports provided: MorphTarget, MorphTargetManager */
  101254. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101255. "use strict";
  101256. __webpack_require__.r(__webpack_exports__);
  101257. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  101258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _morphTarget__WEBPACK_IMPORTED_MODULE_0__["MorphTarget"]; });
  101259. /* harmony import */ var _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./morphTargetManager */ "./Morph/morphTargetManager.ts");
  101260. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _morphTargetManager__WEBPACK_IMPORTED_MODULE_1__["MorphTargetManager"]; });
  101261. /***/ }),
  101262. /***/ "./Morph/morphTarget.ts":
  101263. /*!******************************!*\
  101264. !*** ./Morph/morphTarget.ts ***!
  101265. \******************************/
  101266. /*! exports provided: MorphTarget */
  101267. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101268. "use strict";
  101269. __webpack_require__.r(__webpack_exports__);
  101270. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return MorphTarget; });
  101271. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  101272. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  101273. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  101274. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  101275. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  101276. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  101277. /**
  101278. * Defines a target to use with MorphTargetManager
  101279. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  101280. */
  101281. var MorphTarget = /** @class */ (function () {
  101282. /**
  101283. * Creates a new MorphTarget
  101284. * @param name defines the name of the target
  101285. * @param influence defines the influence to use
  101286. * @param scene defines the scene the morphtarget belongs to
  101287. */
  101288. function MorphTarget(
  101289. /** defines the name of the target */
  101290. name, influence, scene) {
  101291. if (influence === void 0) { influence = 0; }
  101292. if (scene === void 0) { scene = null; }
  101293. this.name = name;
  101294. /**
  101295. * Gets or sets the list of animations
  101296. */
  101297. this.animations = new Array();
  101298. this._positions = null;
  101299. this._normals = null;
  101300. this._tangents = null;
  101301. /**
  101302. * Observable raised when the influence changes
  101303. */
  101304. this.onInfluenceChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  101305. /** @hidden */
  101306. this._onDataLayoutChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  101307. this._animationPropertiesOverride = null;
  101308. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  101309. this.influence = influence;
  101310. }
  101311. Object.defineProperty(MorphTarget.prototype, "influence", {
  101312. /**
  101313. * Gets or sets the influence of this target (ie. its weight in the overall morphing)
  101314. */
  101315. get: function () {
  101316. return this._influence;
  101317. },
  101318. set: function (influence) {
  101319. if (this._influence === influence) {
  101320. return;
  101321. }
  101322. var previous = this._influence;
  101323. this._influence = influence;
  101324. if (this.onInfluenceChanged.hasObservers) {
  101325. this.onInfluenceChanged.notifyObservers(previous === 0 || influence === 0);
  101326. }
  101327. },
  101328. enumerable: true,
  101329. configurable: true
  101330. });
  101331. Object.defineProperty(MorphTarget.prototype, "animationPropertiesOverride", {
  101332. /**
  101333. * Gets or sets the animation properties override
  101334. */
  101335. get: function () {
  101336. if (!this._animationPropertiesOverride && this._scene) {
  101337. return this._scene.animationPropertiesOverride;
  101338. }
  101339. return this._animationPropertiesOverride;
  101340. },
  101341. set: function (value) {
  101342. this._animationPropertiesOverride = value;
  101343. },
  101344. enumerable: true,
  101345. configurable: true
  101346. });
  101347. Object.defineProperty(MorphTarget.prototype, "hasPositions", {
  101348. /**
  101349. * Gets a boolean defining if the target contains position data
  101350. */
  101351. get: function () {
  101352. return !!this._positions;
  101353. },
  101354. enumerable: true,
  101355. configurable: true
  101356. });
  101357. Object.defineProperty(MorphTarget.prototype, "hasNormals", {
  101358. /**
  101359. * Gets a boolean defining if the target contains normal data
  101360. */
  101361. get: function () {
  101362. return !!this._normals;
  101363. },
  101364. enumerable: true,
  101365. configurable: true
  101366. });
  101367. Object.defineProperty(MorphTarget.prototype, "hasTangents", {
  101368. /**
  101369. * Gets a boolean defining if the target contains tangent data
  101370. */
  101371. get: function () {
  101372. return !!this._tangents;
  101373. },
  101374. enumerable: true,
  101375. configurable: true
  101376. });
  101377. /**
  101378. * Affects position data to this target
  101379. * @param data defines the position data to use
  101380. */
  101381. MorphTarget.prototype.setPositions = function (data) {
  101382. var hadPositions = this.hasPositions;
  101383. this._positions = data;
  101384. if (hadPositions !== this.hasPositions) {
  101385. this._onDataLayoutChanged.notifyObservers(undefined);
  101386. }
  101387. };
  101388. /**
  101389. * Gets the position data stored in this target
  101390. * @returns a FloatArray containing the position data (or null if not present)
  101391. */
  101392. MorphTarget.prototype.getPositions = function () {
  101393. return this._positions;
  101394. };
  101395. /**
  101396. * Affects normal data to this target
  101397. * @param data defines the normal data to use
  101398. */
  101399. MorphTarget.prototype.setNormals = function (data) {
  101400. var hadNormals = this.hasNormals;
  101401. this._normals = data;
  101402. if (hadNormals !== this.hasNormals) {
  101403. this._onDataLayoutChanged.notifyObservers(undefined);
  101404. }
  101405. };
  101406. /**
  101407. * Gets the normal data stored in this target
  101408. * @returns a FloatArray containing the normal data (or null if not present)
  101409. */
  101410. MorphTarget.prototype.getNormals = function () {
  101411. return this._normals;
  101412. };
  101413. /**
  101414. * Affects tangent data to this target
  101415. * @param data defines the tangent data to use
  101416. */
  101417. MorphTarget.prototype.setTangents = function (data) {
  101418. var hadTangents = this.hasTangents;
  101419. this._tangents = data;
  101420. if (hadTangents !== this.hasTangents) {
  101421. this._onDataLayoutChanged.notifyObservers(undefined);
  101422. }
  101423. };
  101424. /**
  101425. * Gets the tangent data stored in this target
  101426. * @returns a FloatArray containing the tangent data (or null if not present)
  101427. */
  101428. MorphTarget.prototype.getTangents = function () {
  101429. return this._tangents;
  101430. };
  101431. /**
  101432. * Serializes the current target into a Serialization object
  101433. * @returns the serialized object
  101434. */
  101435. MorphTarget.prototype.serialize = function () {
  101436. var serializationObject = {};
  101437. serializationObject.name = this.name;
  101438. serializationObject.influence = this.influence;
  101439. serializationObject.positions = Array.prototype.slice.call(this.getPositions());
  101440. if (this.id != null) {
  101441. serializationObject.id = this.id;
  101442. }
  101443. if (this.hasNormals) {
  101444. serializationObject.normals = Array.prototype.slice.call(this.getNormals());
  101445. }
  101446. if (this.hasTangents) {
  101447. serializationObject.tangents = Array.prototype.slice.call(this.getTangents());
  101448. }
  101449. // Animations
  101450. _Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["SerializationHelper"].AppendSerializedAnimations(this, serializationObject);
  101451. return serializationObject;
  101452. };
  101453. /**
  101454. * Returns the string "MorphTarget"
  101455. * @returns "MorphTarget"
  101456. */
  101457. MorphTarget.prototype.getClassName = function () {
  101458. return "MorphTarget";
  101459. };
  101460. // Statics
  101461. /**
  101462. * Creates a new target from serialized data
  101463. * @param serializationObject defines the serialized data to use
  101464. * @returns a new MorphTarget
  101465. */
  101466. MorphTarget.Parse = function (serializationObject) {
  101467. var result = new MorphTarget(serializationObject.name, serializationObject.influence);
  101468. result.setPositions(serializationObject.positions);
  101469. if (serializationObject.id != null) {
  101470. result.id = serializationObject.id;
  101471. }
  101472. if (serializationObject.normals) {
  101473. result.setNormals(serializationObject.normals);
  101474. }
  101475. if (serializationObject.tangents) {
  101476. result.setTangents(serializationObject.tangents);
  101477. }
  101478. // Animations
  101479. if (serializationObject.animations) {
  101480. for (var animationIndex = 0; animationIndex < serializationObject.animations.length; animationIndex++) {
  101481. var parsedAnimation = serializationObject.animations[animationIndex];
  101482. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_5__["_TypeStore"].GetClass("BABYLON.Animation");
  101483. if (internalClass) {
  101484. result.animations.push(internalClass.Parse(parsedAnimation));
  101485. }
  101486. }
  101487. }
  101488. return result;
  101489. };
  101490. /**
  101491. * Creates a MorphTarget from mesh data
  101492. * @param mesh defines the source mesh
  101493. * @param name defines the name to use for the new target
  101494. * @param influence defines the influence to attach to the target
  101495. * @returns a new MorphTarget
  101496. */
  101497. MorphTarget.FromMesh = function (mesh, name, influence) {
  101498. if (!name) {
  101499. name = mesh.name;
  101500. }
  101501. var result = new MorphTarget(name, influence, mesh.getScene());
  101502. result.setPositions(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].PositionKind));
  101503. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind)) {
  101504. result.setNormals(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].NormalKind));
  101505. }
  101506. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind)) {
  101507. result.setTangents(mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_3__["VertexBuffer"].TangentKind));
  101508. }
  101509. return result;
  101510. };
  101511. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  101512. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_4__["serialize"])()
  101513. ], MorphTarget.prototype, "id", void 0);
  101514. return MorphTarget;
  101515. }());
  101516. /***/ }),
  101517. /***/ "./Morph/morphTargetManager.ts":
  101518. /*!*************************************!*\
  101519. !*** ./Morph/morphTargetManager.ts ***!
  101520. \*************************************/
  101521. /*! exports provided: MorphTargetManager */
  101522. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101523. "use strict";
  101524. __webpack_require__.r(__webpack_exports__);
  101525. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return MorphTargetManager; });
  101526. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  101527. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101528. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  101529. /* harmony import */ var _morphTarget__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./morphTarget */ "./Morph/morphTarget.ts");
  101530. /**
  101531. * This class is used to deform meshes using morphing between different targets
  101532. * @see http://doc.babylonjs.com/how_to/how_to_use_morphtargets
  101533. */
  101534. var MorphTargetManager = /** @class */ (function () {
  101535. /**
  101536. * Creates a new MorphTargetManager
  101537. * @param scene defines the current scene
  101538. */
  101539. function MorphTargetManager(scene) {
  101540. if (scene === void 0) { scene = null; }
  101541. this._targets = new Array();
  101542. this._targetInfluenceChangedObservers = new Array();
  101543. this._targetDataLayoutChangedObservers = new Array();
  101544. this._activeTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  101545. this._supportsNormals = false;
  101546. this._supportsTangents = false;
  101547. this._vertexCount = 0;
  101548. this._uniqueId = 0;
  101549. this._tempInfluences = new Array();
  101550. if (!scene) {
  101551. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_2__["EngineStore"].LastCreatedScene;
  101552. }
  101553. this._scene = scene;
  101554. if (this._scene) {
  101555. this._scene.morphTargetManagers.push(this);
  101556. this._uniqueId = this._scene.getUniqueId();
  101557. }
  101558. }
  101559. Object.defineProperty(MorphTargetManager.prototype, "uniqueId", {
  101560. /**
  101561. * Gets the unique ID of this manager
  101562. */
  101563. get: function () {
  101564. return this._uniqueId;
  101565. },
  101566. enumerable: true,
  101567. configurable: true
  101568. });
  101569. Object.defineProperty(MorphTargetManager.prototype, "vertexCount", {
  101570. /**
  101571. * Gets the number of vertices handled by this manager
  101572. */
  101573. get: function () {
  101574. return this._vertexCount;
  101575. },
  101576. enumerable: true,
  101577. configurable: true
  101578. });
  101579. Object.defineProperty(MorphTargetManager.prototype, "supportsNormals", {
  101580. /**
  101581. * Gets a boolean indicating if this manager supports morphing of normals
  101582. */
  101583. get: function () {
  101584. return this._supportsNormals;
  101585. },
  101586. enumerable: true,
  101587. configurable: true
  101588. });
  101589. Object.defineProperty(MorphTargetManager.prototype, "supportsTangents", {
  101590. /**
  101591. * Gets a boolean indicating if this manager supports morphing of tangents
  101592. */
  101593. get: function () {
  101594. return this._supportsTangents;
  101595. },
  101596. enumerable: true,
  101597. configurable: true
  101598. });
  101599. Object.defineProperty(MorphTargetManager.prototype, "numTargets", {
  101600. /**
  101601. * Gets the number of targets stored in this manager
  101602. */
  101603. get: function () {
  101604. return this._targets.length;
  101605. },
  101606. enumerable: true,
  101607. configurable: true
  101608. });
  101609. Object.defineProperty(MorphTargetManager.prototype, "numInfluencers", {
  101610. /**
  101611. * Gets the number of influencers (ie. the number of targets with influences > 0)
  101612. */
  101613. get: function () {
  101614. return this._activeTargets.length;
  101615. },
  101616. enumerable: true,
  101617. configurable: true
  101618. });
  101619. Object.defineProperty(MorphTargetManager.prototype, "influences", {
  101620. /**
  101621. * Gets the list of influences (one per target)
  101622. */
  101623. get: function () {
  101624. return this._influences;
  101625. },
  101626. enumerable: true,
  101627. configurable: true
  101628. });
  101629. /**
  101630. * Gets the active target at specified index. An active target is a target with an influence > 0
  101631. * @param index defines the index to check
  101632. * @returns the requested target
  101633. */
  101634. MorphTargetManager.prototype.getActiveTarget = function (index) {
  101635. return this._activeTargets.data[index];
  101636. };
  101637. /**
  101638. * Gets the target at specified index
  101639. * @param index defines the index to check
  101640. * @returns the requested target
  101641. */
  101642. MorphTargetManager.prototype.getTarget = function (index) {
  101643. return this._targets[index];
  101644. };
  101645. /**
  101646. * Add a new target to this manager
  101647. * @param target defines the target to add
  101648. */
  101649. MorphTargetManager.prototype.addTarget = function (target) {
  101650. var _this = this;
  101651. this._targets.push(target);
  101652. this._targetInfluenceChangedObservers.push(target.onInfluenceChanged.add(function (needUpdate) {
  101653. _this._syncActiveTargets(needUpdate);
  101654. }));
  101655. this._targetDataLayoutChangedObservers.push(target._onDataLayoutChanged.add(function () {
  101656. _this._syncActiveTargets(true);
  101657. }));
  101658. this._syncActiveTargets(true);
  101659. };
  101660. /**
  101661. * Removes a target from the manager
  101662. * @param target defines the target to remove
  101663. */
  101664. MorphTargetManager.prototype.removeTarget = function (target) {
  101665. var index = this._targets.indexOf(target);
  101666. if (index >= 0) {
  101667. this._targets.splice(index, 1);
  101668. target.onInfluenceChanged.remove(this._targetInfluenceChangedObservers.splice(index, 1)[0]);
  101669. target._onDataLayoutChanged.remove(this._targetDataLayoutChangedObservers.splice(index, 1)[0]);
  101670. this._syncActiveTargets(true);
  101671. }
  101672. };
  101673. /**
  101674. * Serializes the current manager into a Serialization object
  101675. * @returns the serialized object
  101676. */
  101677. MorphTargetManager.prototype.serialize = function () {
  101678. var serializationObject = {};
  101679. serializationObject.id = this.uniqueId;
  101680. serializationObject.targets = [];
  101681. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101682. var target = _a[_i];
  101683. serializationObject.targets.push(target.serialize());
  101684. }
  101685. return serializationObject;
  101686. };
  101687. MorphTargetManager.prototype._syncActiveTargets = function (needUpdate) {
  101688. var influenceCount = 0;
  101689. this._activeTargets.reset();
  101690. this._supportsNormals = true;
  101691. this._supportsTangents = true;
  101692. this._vertexCount = 0;
  101693. for (var _i = 0, _a = this._targets; _i < _a.length; _i++) {
  101694. var target = _a[_i];
  101695. if (target.influence === 0) {
  101696. continue;
  101697. }
  101698. this._activeTargets.push(target);
  101699. this._tempInfluences[influenceCount++] = target.influence;
  101700. this._supportsNormals = this._supportsNormals && target.hasNormals;
  101701. this._supportsTangents = this._supportsTangents && target.hasTangents;
  101702. var positions = target.getPositions();
  101703. if (positions) {
  101704. var vertexCount = positions.length / 3;
  101705. if (this._vertexCount === 0) {
  101706. this._vertexCount = vertexCount;
  101707. }
  101708. else if (this._vertexCount !== vertexCount) {
  101709. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Incompatible target. Targets must all have the same vertices count.");
  101710. return;
  101711. }
  101712. }
  101713. }
  101714. if (!this._influences || this._influences.length !== influenceCount) {
  101715. this._influences = new Float32Array(influenceCount);
  101716. }
  101717. for (var index = 0; index < influenceCount; index++) {
  101718. this._influences[index] = this._tempInfluences[index];
  101719. }
  101720. if (needUpdate) {
  101721. this.synchronize();
  101722. }
  101723. };
  101724. /**
  101725. * Syncrhonize the targets with all the meshes using this morph target manager
  101726. */
  101727. MorphTargetManager.prototype.synchronize = function () {
  101728. if (!this._scene) {
  101729. return;
  101730. }
  101731. // Flag meshes as dirty to resync with the active targets
  101732. for (var _i = 0, _a = this._scene.meshes; _i < _a.length; _i++) {
  101733. var mesh = _a[_i];
  101734. if (mesh.morphTargetManager === this) {
  101735. mesh._syncGeometryWithMorphTargetManager();
  101736. }
  101737. }
  101738. };
  101739. // Statics
  101740. /**
  101741. * Creates a new MorphTargetManager from serialized data
  101742. * @param serializationObject defines the serialized data
  101743. * @param scene defines the hosting scene
  101744. * @returns the new MorphTargetManager
  101745. */
  101746. MorphTargetManager.Parse = function (serializationObject, scene) {
  101747. var result = new MorphTargetManager(scene);
  101748. result._uniqueId = serializationObject.id;
  101749. for (var _i = 0, _a = serializationObject.targets; _i < _a.length; _i++) {
  101750. var targetData = _a[_i];
  101751. result.addTarget(_morphTarget__WEBPACK_IMPORTED_MODULE_3__["MorphTarget"].Parse(targetData));
  101752. }
  101753. return result;
  101754. };
  101755. return MorphTargetManager;
  101756. }());
  101757. /***/ }),
  101758. /***/ "./Offline/database.ts":
  101759. /*!*****************************!*\
  101760. !*** ./Offline/database.ts ***!
  101761. \*****************************/
  101762. /*! exports provided: Database */
  101763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  101764. "use strict";
  101765. __webpack_require__.r(__webpack_exports__);
  101766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return Database; });
  101767. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  101768. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  101769. /* harmony import */ var _Misc_tga__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/tga */ "./Misc/tga.ts");
  101770. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  101771. // Sets the default offline provider to Babylon.js
  101772. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].OfflineProviderFactory = function (urlToScene, callbackManifestChecked, disableManifestCheck) {
  101773. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101774. return new Database(urlToScene, callbackManifestChecked, disableManifestCheck);
  101775. };
  101776. /**
  101777. * Class used to enable access to IndexedDB
  101778. * @see http://doc.babylonjs.com/how_to/caching_resources_in_indexeddb
  101779. */
  101780. var Database = /** @class */ (function () {
  101781. /**
  101782. * Creates a new Database
  101783. * @param urlToScene defines the url to load the scene
  101784. * @param callbackManifestChecked defines the callback to use when manifest is checked
  101785. * @param disableManifestCheck defines a boolean indicating that we want to skip the manifest validation (it will be considered validated and up to date)
  101786. */
  101787. function Database(urlToScene, callbackManifestChecked, disableManifestCheck) {
  101788. if (disableManifestCheck === void 0) { disableManifestCheck = false; }
  101789. var _this = this;
  101790. // Handling various flavors of prefixed version of IndexedDB
  101791. this._idbFactory = (window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB);
  101792. this._callbackManifestChecked = callbackManifestChecked;
  101793. this._currentSceneUrl = Database._ReturnFullUrlLocation(urlToScene);
  101794. this._db = null;
  101795. this._enableSceneOffline = false;
  101796. this._enableTexturesOffline = false;
  101797. this._manifestVersionFound = 0;
  101798. this._mustUpdateRessources = false;
  101799. this._hasReachedQuota = false;
  101800. if (!Database.IDBStorageEnabled) {
  101801. this._callbackManifestChecked(true);
  101802. }
  101803. else {
  101804. if (disableManifestCheck) {
  101805. this._enableSceneOffline = true;
  101806. this._enableTexturesOffline = true;
  101807. this._manifestVersionFound = 1;
  101808. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].SetImmediate(function () {
  101809. _this._callbackManifestChecked(true);
  101810. });
  101811. }
  101812. else {
  101813. this._checkManifestFile();
  101814. }
  101815. }
  101816. }
  101817. Object.defineProperty(Database.prototype, "enableSceneOffline", {
  101818. /**
  101819. * Gets a boolean indicating if scene must be saved in the database
  101820. */
  101821. get: function () {
  101822. return this._enableSceneOffline;
  101823. },
  101824. enumerable: true,
  101825. configurable: true
  101826. });
  101827. Object.defineProperty(Database.prototype, "enableTexturesOffline", {
  101828. /**
  101829. * Gets a boolean indicating if textures must be saved in the database
  101830. */
  101831. get: function () {
  101832. return this._enableTexturesOffline;
  101833. },
  101834. enumerable: true,
  101835. configurable: true
  101836. });
  101837. Database.prototype._checkManifestFile = function () {
  101838. var _this = this;
  101839. var noManifestFile = function () {
  101840. _this._enableSceneOffline = false;
  101841. _this._enableTexturesOffline = false;
  101842. _this._callbackManifestChecked(false);
  101843. };
  101844. var timeStampUsed = false;
  101845. var manifestURL = this._currentSceneUrl + ".manifest";
  101846. var xhr = new XMLHttpRequest();
  101847. if (navigator.onLine) {
  101848. // Adding a timestamp to by-pass browsers' cache
  101849. timeStampUsed = true;
  101850. manifestURL = manifestURL + (manifestURL.match(/\?/) == null ? "?" : "&") + Date.now();
  101851. }
  101852. xhr.open("GET", manifestURL, true);
  101853. xhr.addEventListener("load", function () {
  101854. if (xhr.status === 200 || Database._ValidateXHRData(xhr, 1)) {
  101855. try {
  101856. var manifestFile = JSON.parse(xhr.response);
  101857. _this._enableSceneOffline = manifestFile.enableSceneOffline;
  101858. _this._enableTexturesOffline = manifestFile.enableTexturesOffline && Database.IsUASupportingBlobStorage;
  101859. if (manifestFile.version && !isNaN(parseInt(manifestFile.version))) {
  101860. _this._manifestVersionFound = manifestFile.version;
  101861. }
  101862. if (_this._callbackManifestChecked) {
  101863. _this._callbackManifestChecked(true);
  101864. }
  101865. }
  101866. catch (ex) {
  101867. noManifestFile();
  101868. }
  101869. }
  101870. else {
  101871. noManifestFile();
  101872. }
  101873. }, false);
  101874. xhr.addEventListener("error", function () {
  101875. if (timeStampUsed) {
  101876. timeStampUsed = false;
  101877. // Let's retry without the timeStamp
  101878. // It could fail when coupled with HTML5 Offline API
  101879. var retryManifestURL = _this._currentSceneUrl + ".manifest";
  101880. xhr.open("GET", retryManifestURL, true);
  101881. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101882. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101883. }
  101884. xhr.send();
  101885. }
  101886. else {
  101887. noManifestFile();
  101888. }
  101889. }, false);
  101890. try {
  101891. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  101892. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  101893. }
  101894. xhr.send();
  101895. }
  101896. catch (ex) {
  101897. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error on XHR send request.");
  101898. this._callbackManifestChecked(false);
  101899. }
  101900. };
  101901. /**
  101902. * Open the database and make it available
  101903. * @param successCallback defines the callback to call on success
  101904. * @param errorCallback defines the callback to call on error
  101905. */
  101906. Database.prototype.open = function (successCallback, errorCallback) {
  101907. var _this = this;
  101908. var handleError = function () {
  101909. _this._isSupported = false;
  101910. if (errorCallback) {
  101911. errorCallback();
  101912. }
  101913. };
  101914. if (!this._idbFactory || !(this._enableSceneOffline || this._enableTexturesOffline)) {
  101915. // Your browser doesn't support IndexedDB
  101916. this._isSupported = false;
  101917. if (errorCallback) {
  101918. errorCallback();
  101919. }
  101920. }
  101921. else {
  101922. // If the DB hasn't been opened or created yet
  101923. if (!this._db) {
  101924. this._hasReachedQuota = false;
  101925. this._isSupported = true;
  101926. var request = this._idbFactory.open("babylonjs", 1);
  101927. // Could occur if user is blocking the quota for the DB and/or doesn't grant access to IndexedDB
  101928. request.onerror = function () {
  101929. handleError();
  101930. };
  101931. // executes when a version change transaction cannot complete due to other active transactions
  101932. request.onblocked = function () {
  101933. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("IDB request blocked. Please reload the page.");
  101934. handleError();
  101935. };
  101936. // DB has been opened successfully
  101937. request.onsuccess = function () {
  101938. _this._db = request.result;
  101939. successCallback();
  101940. };
  101941. // Initialization of the DB. Creating Scenes & Textures stores
  101942. request.onupgradeneeded = function (event) {
  101943. _this._db = (event.target).result;
  101944. if (_this._db) {
  101945. try {
  101946. _this._db.createObjectStore("scenes", { keyPath: "sceneUrl" });
  101947. _this._db.createObjectStore("versions", { keyPath: "sceneUrl" });
  101948. _this._db.createObjectStore("textures", { keyPath: "textureUrl" });
  101949. }
  101950. catch (ex) {
  101951. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while creating object stores. Exception: " + ex.message);
  101952. handleError();
  101953. }
  101954. }
  101955. };
  101956. }
  101957. // DB has already been created and opened
  101958. else {
  101959. if (successCallback) {
  101960. successCallback();
  101961. }
  101962. }
  101963. }
  101964. };
  101965. /**
  101966. * Loads an image from the database
  101967. * @param url defines the url to load from
  101968. * @param image defines the target DOM image
  101969. */
  101970. Database.prototype.loadImage = function (url, image) {
  101971. var _this = this;
  101972. var completeURL = Database._ReturnFullUrlLocation(url);
  101973. var saveAndLoadImage = function () {
  101974. if (!_this._hasReachedQuota && _this._db !== null) {
  101975. // the texture is not yet in the DB, let's try to save it
  101976. _this._saveImageIntoDBAsync(completeURL, image);
  101977. }
  101978. // If the texture is not in the DB and we've reached the DB quota limit
  101979. // let's load it directly from the web
  101980. else {
  101981. image.src = url;
  101982. }
  101983. };
  101984. if (!this._mustUpdateRessources) {
  101985. this._loadImageFromDBAsync(completeURL, image, saveAndLoadImage);
  101986. }
  101987. // First time we're download the images or update requested in the manifest file by a version change
  101988. else {
  101989. saveAndLoadImage();
  101990. }
  101991. };
  101992. Database.prototype._loadImageFromDBAsync = function (url, image, notInDBCallback) {
  101993. if (this._isSupported && this._db !== null) {
  101994. var texture;
  101995. var transaction = this._db.transaction(["textures"]);
  101996. transaction.onabort = function () {
  101997. image.src = url;
  101998. };
  101999. transaction.oncomplete = function () {
  102000. var blobTextureURL;
  102001. if (texture) {
  102002. var URL = window.URL || window.webkitURL;
  102003. blobTextureURL = URL.createObjectURL(texture.data);
  102004. image.onerror = function () {
  102005. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading image from blob URL: " + blobTextureURL + " switching back to web url: " + url);
  102006. image.src = url;
  102007. };
  102008. image.src = blobTextureURL;
  102009. }
  102010. else {
  102011. notInDBCallback();
  102012. }
  102013. };
  102014. var getRequest = transaction.objectStore("textures").get(url);
  102015. getRequest.onsuccess = function (event) {
  102016. texture = (event.target).result;
  102017. };
  102018. getRequest.onerror = function () {
  102019. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading texture " + url + " from DB.");
  102020. image.src = url;
  102021. };
  102022. }
  102023. else {
  102024. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  102025. image.src = url;
  102026. }
  102027. };
  102028. Database.prototype._saveImageIntoDBAsync = function (url, image) {
  102029. var _this = this;
  102030. if (this._isSupported) {
  102031. // In case of error (type not supported or quota exceeded), we're at least sending back XHR data to allow texture loading later on
  102032. var generateBlobUrl = function () {
  102033. var blobTextureURL;
  102034. if (blob) {
  102035. var URL = window.URL || window.webkitURL;
  102036. try {
  102037. blobTextureURL = URL.createObjectURL(blob);
  102038. }
  102039. // Chrome is raising a type error if we're setting the oneTimeOnly parameter
  102040. catch (ex) {
  102041. blobTextureURL = URL.createObjectURL(blob);
  102042. }
  102043. }
  102044. if (blobTextureURL) {
  102045. image.src = blobTextureURL;
  102046. }
  102047. };
  102048. if (Database.IsUASupportingBlobStorage) { // Create XHR
  102049. var xhr = new XMLHttpRequest(), blob;
  102050. xhr.open("GET", url, true);
  102051. xhr.responseType = "blob";
  102052. xhr.addEventListener("load", function () {
  102053. if (xhr.status === 200 && _this._db) {
  102054. // Blob as response (XHR2)
  102055. blob = xhr.response;
  102056. var transaction = _this._db.transaction(["textures"], "readwrite");
  102057. // the transaction could abort because of a QuotaExceededError error
  102058. transaction.onabort = function (event) {
  102059. try {
  102060. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  102061. var srcElement = (event.srcElement || event.target);
  102062. var error = srcElement.error;
  102063. if (error && error.name === "QuotaExceededError") {
  102064. _this._hasReachedQuota = true;
  102065. }
  102066. }
  102067. catch (ex) { }
  102068. generateBlobUrl();
  102069. };
  102070. transaction.oncomplete = function () {
  102071. generateBlobUrl();
  102072. };
  102073. var newTexture = { textureUrl: url, data: blob };
  102074. try {
  102075. // Put the blob into the dabase
  102076. var addRequest = transaction.objectStore("textures").put(newTexture);
  102077. addRequest.onsuccess = function () {
  102078. };
  102079. addRequest.onerror = function () {
  102080. generateBlobUrl();
  102081. };
  102082. }
  102083. catch (ex) {
  102084. // "DataCloneError" generated by Chrome when you try to inject blob into IndexedDB
  102085. if (ex.code === 25) {
  102086. Database.IsUASupportingBlobStorage = false;
  102087. _this._enableTexturesOffline = false;
  102088. }
  102089. image.src = url;
  102090. }
  102091. }
  102092. else {
  102093. image.src = url;
  102094. }
  102095. }, false);
  102096. xhr.addEventListener("error", function () {
  102097. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in XHR request in BABYLON.Database.");
  102098. image.src = url;
  102099. }, false);
  102100. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].CustomRequestHeaders) {
  102101. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  102102. }
  102103. xhr.send();
  102104. }
  102105. else {
  102106. image.src = url;
  102107. }
  102108. }
  102109. else {
  102110. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  102111. image.src = url;
  102112. }
  102113. };
  102114. Database.prototype._checkVersionFromDB = function (url, versionLoaded) {
  102115. var _this = this;
  102116. var updateVersion = function () {
  102117. // the version is not yet in the DB or we need to update it
  102118. _this._saveVersionIntoDBAsync(url, versionLoaded);
  102119. };
  102120. this._loadVersionFromDBAsync(url, versionLoaded, updateVersion);
  102121. };
  102122. Database.prototype._loadVersionFromDBAsync = function (url, callback, updateInDBCallback) {
  102123. var _this = this;
  102124. if (this._isSupported && this._db) {
  102125. var version;
  102126. try {
  102127. var transaction = this._db.transaction(["versions"]);
  102128. transaction.oncomplete = function () {
  102129. if (version) {
  102130. // If the version in the JSON file is different from the version in DB
  102131. if (_this._manifestVersionFound !== version.data) {
  102132. _this._mustUpdateRessources = true;
  102133. updateInDBCallback();
  102134. }
  102135. else {
  102136. callback(version.data);
  102137. }
  102138. }
  102139. // version was not found in DB
  102140. else {
  102141. _this._mustUpdateRessources = true;
  102142. updateInDBCallback();
  102143. }
  102144. };
  102145. transaction.onabort = function () {
  102146. callback(-1);
  102147. };
  102148. var getRequest = transaction.objectStore("versions").get(url);
  102149. getRequest.onsuccess = function (event) {
  102150. version = (event.target).result;
  102151. };
  102152. getRequest.onerror = function () {
  102153. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading version for scene " + url + " from DB.");
  102154. callback(-1);
  102155. };
  102156. }
  102157. catch (ex) {
  102158. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (READ OP). Exception: " + ex.message);
  102159. callback(-1);
  102160. }
  102161. }
  102162. else {
  102163. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  102164. callback(-1);
  102165. }
  102166. };
  102167. Database.prototype._saveVersionIntoDBAsync = function (url, callback) {
  102168. var _this = this;
  102169. if (this._isSupported && !this._hasReachedQuota && this._db) {
  102170. try {
  102171. // Open a transaction to the database
  102172. var transaction = this._db.transaction(["versions"], "readwrite");
  102173. // the transaction could abort because of a QuotaExceededError error
  102174. transaction.onabort = function (event) {
  102175. try { //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  102176. var error = event.srcElement['error'];
  102177. if (error && error.name === "QuotaExceededError") {
  102178. _this._hasReachedQuota = true;
  102179. }
  102180. }
  102181. catch (ex) { }
  102182. callback(-1);
  102183. };
  102184. transaction.oncomplete = function () {
  102185. callback(_this._manifestVersionFound);
  102186. };
  102187. var newVersion = { sceneUrl: url, data: this._manifestVersionFound };
  102188. // Put the scene into the database
  102189. var addRequest = transaction.objectStore("versions").put(newVersion);
  102190. addRequest.onsuccess = function () {
  102191. };
  102192. addRequest.onerror = function () {
  102193. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add version request in BABYLON.Database.");
  102194. };
  102195. }
  102196. catch (ex) {
  102197. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error while accessing 'versions' object store (WRITE OP). Exception: " + ex.message);
  102198. callback(-1);
  102199. }
  102200. }
  102201. else {
  102202. callback(-1);
  102203. }
  102204. };
  102205. /**
  102206. * Loads a file from database
  102207. * @param url defines the URL to load from
  102208. * @param sceneLoaded defines a callback to call on success
  102209. * @param progressCallBack defines a callback to call when progress changed
  102210. * @param errorCallback defines a callback to call on error
  102211. * @param useArrayBuffer defines a boolean to use array buffer instead of text string
  102212. */
  102213. Database.prototype.loadFile = function (url, sceneLoaded, progressCallBack, errorCallback, useArrayBuffer) {
  102214. var _this = this;
  102215. var completeUrl = Database._ReturnFullUrlLocation(url);
  102216. var saveAndLoadFile = function () {
  102217. // the scene is not yet in the DB, let's try to save it
  102218. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  102219. };
  102220. this._checkVersionFromDB(completeUrl, function (version) {
  102221. if (version !== -1) {
  102222. if (!_this._mustUpdateRessources) {
  102223. _this._loadFileAsync(completeUrl, sceneLoaded, saveAndLoadFile);
  102224. }
  102225. else {
  102226. _this._saveFileAsync(completeUrl, sceneLoaded, progressCallBack, useArrayBuffer, errorCallback);
  102227. }
  102228. }
  102229. else {
  102230. if (errorCallback) {
  102231. errorCallback();
  102232. }
  102233. }
  102234. });
  102235. };
  102236. Database.prototype._loadFileAsync = function (url, callback, notInDBCallback) {
  102237. if (this._isSupported && this._db) {
  102238. var targetStore;
  102239. if (url.indexOf(".babylon") !== -1) {
  102240. targetStore = "scenes";
  102241. }
  102242. else {
  102243. targetStore = "textures";
  102244. }
  102245. var file;
  102246. var transaction = this._db.transaction([targetStore]);
  102247. transaction.oncomplete = function () {
  102248. if (file) {
  102249. callback(file.data);
  102250. }
  102251. // file was not found in DB
  102252. else {
  102253. notInDBCallback();
  102254. }
  102255. };
  102256. transaction.onabort = function () {
  102257. notInDBCallback();
  102258. };
  102259. var getRequest = transaction.objectStore(targetStore).get(url);
  102260. getRequest.onsuccess = function (event) {
  102261. file = (event.target).result;
  102262. };
  102263. getRequest.onerror = function () {
  102264. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error loading file " + url + " from DB.");
  102265. notInDBCallback();
  102266. };
  102267. }
  102268. else {
  102269. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or BabylonJS Database is not open.");
  102270. callback();
  102271. }
  102272. };
  102273. Database.prototype._saveFileAsync = function (url, callback, progressCallback, useArrayBuffer, errorCallback) {
  102274. var _this = this;
  102275. if (this._isSupported) {
  102276. var targetStore;
  102277. if (url.indexOf(".babylon") !== -1) {
  102278. targetStore = "scenes";
  102279. }
  102280. else {
  102281. targetStore = "textures";
  102282. }
  102283. // Create XHR
  102284. var xhr = new XMLHttpRequest();
  102285. var fileData;
  102286. xhr.open("GET", url + "?" + Date.now(), true);
  102287. if (useArrayBuffer) {
  102288. xhr.responseType = "arraybuffer";
  102289. }
  102290. if (progressCallback) {
  102291. xhr.onprogress = progressCallback;
  102292. }
  102293. xhr.addEventListener("load", function () {
  102294. if (xhr.status === 200 || (xhr.status < 400 && Database._ValidateXHRData(xhr, !useArrayBuffer ? 1 : 6))) {
  102295. // Blob as response (XHR2)
  102296. fileData = !useArrayBuffer ? xhr.responseText : xhr.response;
  102297. if (!_this._hasReachedQuota && _this._db) {
  102298. // Open a transaction to the database
  102299. var transaction = _this._db.transaction([targetStore], "readwrite");
  102300. // the transaction could abort because of a QuotaExceededError error
  102301. transaction.onabort = function (event) {
  102302. try {
  102303. //backwards compatibility with ts 1.0, srcElement doesn't have an "error" according to ts 1.3
  102304. var error = event.srcElement['error'];
  102305. if (error && error.name === "QuotaExceededError") {
  102306. _this._hasReachedQuota = true;
  102307. }
  102308. }
  102309. catch (ex) { }
  102310. callback(fileData);
  102311. };
  102312. transaction.oncomplete = function () {
  102313. callback(fileData);
  102314. };
  102315. var newFile;
  102316. if (targetStore === "scenes") {
  102317. newFile = { sceneUrl: url, data: fileData, version: _this._manifestVersionFound };
  102318. }
  102319. else {
  102320. newFile = { textureUrl: url, data: fileData };
  102321. }
  102322. try {
  102323. // Put the scene into the database
  102324. var addRequest = transaction.objectStore(targetStore).put(newFile);
  102325. addRequest.onsuccess = function () {
  102326. };
  102327. addRequest.onerror = function () {
  102328. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error in DB add file request in BABYLON.Database.");
  102329. };
  102330. }
  102331. catch (ex) {
  102332. callback(fileData);
  102333. }
  102334. }
  102335. else {
  102336. callback(fileData);
  102337. }
  102338. }
  102339. else {
  102340. if (xhr.status >= 400 && errorCallback) {
  102341. errorCallback(xhr);
  102342. }
  102343. else {
  102344. callback();
  102345. }
  102346. }
  102347. }, false);
  102348. xhr.addEventListener("error", function () {
  102349. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("error on XHR request.");
  102350. callback();
  102351. }, false);
  102352. if (_Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].UseCustomRequestHeaders) {
  102353. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].InjectCustomRequestHeaders(xhr);
  102354. }
  102355. xhr.send();
  102356. }
  102357. else {
  102358. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("Error: IndexedDB not supported by your browser or Babylon.js Database is not open.");
  102359. callback();
  102360. }
  102361. };
  102362. /**
  102363. * Validates if xhr data is correct
  102364. * @param xhr defines the request to validate
  102365. * @param dataType defines the expected data type
  102366. * @returns true if data is correct
  102367. */
  102368. Database._ValidateXHRData = function (xhr, dataType) {
  102369. // 1 for text (.babylon, manifest and shaders), 2 for TGA, 4 for DDS, 7 for all
  102370. if (dataType === void 0) { dataType = 7; }
  102371. try {
  102372. if (dataType & 1) {
  102373. if (xhr.responseText && xhr.responseText.length > 0) {
  102374. return true;
  102375. }
  102376. else if (dataType === 1) {
  102377. return false;
  102378. }
  102379. }
  102380. if (dataType & 2) {
  102381. // Check header width and height since there is no "TGA" magic number
  102382. var tgaHeader = _Misc_tga__WEBPACK_IMPORTED_MODULE_2__["TGATools"].GetTGAHeader(xhr.response);
  102383. if (tgaHeader.width && tgaHeader.height && tgaHeader.width > 0 && tgaHeader.height > 0) {
  102384. return true;
  102385. }
  102386. else if (dataType === 2) {
  102387. return false;
  102388. }
  102389. }
  102390. if (dataType & 4) {
  102391. // Check for the "DDS" magic number
  102392. var ddsHeader = new Uint8Array(xhr.response, 0, 3);
  102393. if (ddsHeader[0] === 68 && ddsHeader[1] === 68 && ddsHeader[2] === 83) {
  102394. return true;
  102395. }
  102396. else {
  102397. return false;
  102398. }
  102399. }
  102400. }
  102401. catch (e) {
  102402. // Global protection
  102403. }
  102404. return false;
  102405. };
  102406. /** Gets a boolean indicating if the user agent supports blob storage (this value will be updated after creating the first Database object) */
  102407. Database.IsUASupportingBlobStorage = true;
  102408. /**
  102409. * Gets a boolean indicating if Database storate is enabled (off by default)
  102410. */
  102411. Database.IDBStorageEnabled = false;
  102412. Database._ParseURL = function (url) {
  102413. var a = document.createElement('a');
  102414. a.href = url;
  102415. var urlWithoutHash = url.substring(0, url.lastIndexOf("#"));
  102416. var fileName = url.substring(urlWithoutHash.lastIndexOf("/") + 1, url.length);
  102417. var absLocation = url.substring(0, url.indexOf(fileName, 0));
  102418. return absLocation;
  102419. };
  102420. Database._ReturnFullUrlLocation = function (url) {
  102421. if (url.indexOf("http:/") === -1 && url.indexOf("https:/") === -1) {
  102422. return (Database._ParseURL(window.location.href) + url);
  102423. }
  102424. else {
  102425. return url;
  102426. }
  102427. };
  102428. return Database;
  102429. }());
  102430. /***/ }),
  102431. /***/ "./Offline/index.ts":
  102432. /*!**************************!*\
  102433. !*** ./Offline/index.ts ***!
  102434. \**************************/
  102435. /*! exports provided: Database */
  102436. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102437. "use strict";
  102438. __webpack_require__.r(__webpack_exports__);
  102439. /* harmony import */ var _database__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./database */ "./Offline/database.ts");
  102440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _database__WEBPACK_IMPORTED_MODULE_0__["Database"]; });
  102441. /***/ }),
  102442. /***/ "./Particles/EmitterTypes/boxParticleEmitter.ts":
  102443. /*!******************************************************!*\
  102444. !*** ./Particles/EmitterTypes/boxParticleEmitter.ts ***!
  102445. \******************************************************/
  102446. /*! exports provided: BoxParticleEmitter */
  102447. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102448. "use strict";
  102449. __webpack_require__.r(__webpack_exports__);
  102450. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return BoxParticleEmitter; });
  102451. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102452. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102453. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102454. /**
  102455. * Particle emitter emitting particles from the inside of a box.
  102456. * It emits the particles randomly between 2 given directions.
  102457. */
  102458. var BoxParticleEmitter = /** @class */ (function () {
  102459. /**
  102460. * Creates a new instance BoxParticleEmitter
  102461. */
  102462. function BoxParticleEmitter() {
  102463. /**
  102464. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102465. */
  102466. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102467. /**
  102468. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  102469. */
  102470. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  102471. /**
  102472. * 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.
  102473. */
  102474. this.minEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](-0.5, -0.5, -0.5);
  102475. /**
  102476. * 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.
  102477. */
  102478. this.maxEmitBox = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0.5, 0.5, 0.5);
  102479. }
  102480. /**
  102481. * Called by the particle System when the direction is computed for the created particle.
  102482. * @param worldMatrix is the world matrix of the particle system
  102483. * @param directionToUpdate is the direction vector to update with the result
  102484. * @param particle is the particle we are computed the direction for
  102485. */
  102486. BoxParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102487. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102488. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102489. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102490. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102491. };
  102492. /**
  102493. * Called by the particle System when the position is computed for the created particle.
  102494. * @param worldMatrix is the world matrix of the particle system
  102495. * @param positionToUpdate is the position vector to update with the result
  102496. * @param particle is the particle we are computed the position for
  102497. */
  102498. BoxParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102499. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.x, this.maxEmitBox.x);
  102500. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.y, this.maxEmitBox.y);
  102501. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.minEmitBox.z, this.maxEmitBox.z);
  102502. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102503. };
  102504. /**
  102505. * Clones the current emitter and returns a copy of it
  102506. * @returns the new emitter
  102507. */
  102508. BoxParticleEmitter.prototype.clone = function () {
  102509. var newOne = new BoxParticleEmitter();
  102510. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102511. return newOne;
  102512. };
  102513. /**
  102514. * Called by the GPUParticleSystem to setup the update shader
  102515. * @param effect defines the update shader
  102516. */
  102517. BoxParticleEmitter.prototype.applyToShader = function (effect) {
  102518. effect.setVector3("direction1", this.direction1);
  102519. effect.setVector3("direction2", this.direction2);
  102520. effect.setVector3("minEmitBox", this.minEmitBox);
  102521. effect.setVector3("maxEmitBox", this.maxEmitBox);
  102522. };
  102523. /**
  102524. * Returns a string to use to update the GPU particles update shader
  102525. * @returns a string containng the defines string
  102526. */
  102527. BoxParticleEmitter.prototype.getEffectDefines = function () {
  102528. return "#define BOXEMITTER";
  102529. };
  102530. /**
  102531. * Returns the string "BoxParticleEmitter"
  102532. * @returns a string containing the class name
  102533. */
  102534. BoxParticleEmitter.prototype.getClassName = function () {
  102535. return "BoxParticleEmitter";
  102536. };
  102537. /**
  102538. * Serializes the particle system to a JSON object.
  102539. * @returns the JSON object
  102540. */
  102541. BoxParticleEmitter.prototype.serialize = function () {
  102542. var serializationObject = {};
  102543. serializationObject.type = this.getClassName();
  102544. serializationObject.direction1 = this.direction1.asArray();
  102545. serializationObject.direction2 = this.direction2.asArray();
  102546. serializationObject.minEmitBox = this.minEmitBox.asArray();
  102547. serializationObject.maxEmitBox = this.maxEmitBox.asArray();
  102548. return serializationObject;
  102549. };
  102550. /**
  102551. * Parse properties from a JSON object
  102552. * @param serializationObject defines the JSON object
  102553. */
  102554. BoxParticleEmitter.prototype.parse = function (serializationObject) {
  102555. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  102556. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  102557. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.minEmitBox, 0, this.minEmitBox);
  102558. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.maxEmitBox, 0, this.maxEmitBox);
  102559. };
  102560. return BoxParticleEmitter;
  102561. }());
  102562. /***/ }),
  102563. /***/ "./Particles/EmitterTypes/coneParticleEmitter.ts":
  102564. /*!*******************************************************!*\
  102565. !*** ./Particles/EmitterTypes/coneParticleEmitter.ts ***!
  102566. \*******************************************************/
  102567. /*! exports provided: ConeParticleEmitter */
  102568. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102569. "use strict";
  102570. __webpack_require__.r(__webpack_exports__);
  102571. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return ConeParticleEmitter; });
  102572. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102573. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102574. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102575. /**
  102576. * Particle emitter emitting particles from the inside of a cone.
  102577. * It emits the particles alongside the cone volume from the base to the particle.
  102578. * The emission direction might be randomized.
  102579. */
  102580. var ConeParticleEmitter = /** @class */ (function () {
  102581. /**
  102582. * Creates a new instance ConeParticleEmitter
  102583. * @param radius the radius of the emission cone (1 by default)
  102584. * @param angle the cone base angle (PI by default)
  102585. * @param directionRandomizer defines how much to randomize the particle direction [0-1] (default is 0)
  102586. */
  102587. function ConeParticleEmitter(radius, angle,
  102588. /** defines how much to randomize the particle direction [0-1] (default is 0) */
  102589. directionRandomizer) {
  102590. if (radius === void 0) { radius = 1; }
  102591. if (angle === void 0) { angle = Math.PI; }
  102592. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102593. this.directionRandomizer = directionRandomizer;
  102594. /**
  102595. * Gets or sets a value indicating where on the radius the start position should be picked (1 = everywhere, 0 = only surface)
  102596. */
  102597. this.radiusRange = 1;
  102598. /**
  102599. * Gets or sets a value indicating where on the height the start position should be picked (1 = everywhere, 0 = only surface)
  102600. */
  102601. this.heightRange = 1;
  102602. /**
  102603. * Gets or sets a value indicating if all the particles should be emitted from the spawn point only (the base of the cone)
  102604. */
  102605. this.emitFromSpawnPointOnly = false;
  102606. this.angle = angle;
  102607. this.radius = radius;
  102608. }
  102609. Object.defineProperty(ConeParticleEmitter.prototype, "radius", {
  102610. /**
  102611. * Gets or sets the radius of the emission cone
  102612. */
  102613. get: function () {
  102614. return this._radius;
  102615. },
  102616. set: function (value) {
  102617. this._radius = value;
  102618. this._buildHeight();
  102619. },
  102620. enumerable: true,
  102621. configurable: true
  102622. });
  102623. Object.defineProperty(ConeParticleEmitter.prototype, "angle", {
  102624. /**
  102625. * Gets or sets the angle of the emission cone
  102626. */
  102627. get: function () {
  102628. return this._angle;
  102629. },
  102630. set: function (value) {
  102631. this._angle = value;
  102632. this._buildHeight();
  102633. },
  102634. enumerable: true,
  102635. configurable: true
  102636. });
  102637. ConeParticleEmitter.prototype._buildHeight = function () {
  102638. if (this._angle !== 0) {
  102639. this._height = this._radius / Math.tan(this._angle / 2);
  102640. }
  102641. else {
  102642. this._height = 1;
  102643. }
  102644. };
  102645. /**
  102646. * Called by the particle System when the direction is computed for the created particle.
  102647. * @param worldMatrix is the world matrix of the particle system
  102648. * @param directionToUpdate is the direction vector to update with the result
  102649. * @param particle is the particle we are computed the direction for
  102650. */
  102651. ConeParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102652. if (Math.abs(Math.cos(this._angle)) === 1.0) {
  102653. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(0, 1.0, 0, worldMatrix, directionToUpdate);
  102654. }
  102655. else {
  102656. // measure the direction Vector from the emitter to the particle.
  102657. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102658. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102659. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102660. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  102661. direction.x += randX;
  102662. direction.y += randY;
  102663. direction.z += randZ;
  102664. direction.normalize();
  102665. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102666. }
  102667. };
  102668. /**
  102669. * Called by the particle System when the position is computed for the created particle.
  102670. * @param worldMatrix is the world matrix of the particle system
  102671. * @param positionToUpdate is the position vector to update with the result
  102672. * @param particle is the particle we are computed the position for
  102673. */
  102674. ConeParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102675. var s = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, Math.PI * 2);
  102676. var h;
  102677. if (!this.emitFromSpawnPointOnly) {
  102678. h = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.heightRange);
  102679. // Better distribution in a cone at normal angles.
  102680. h = 1 - h * h;
  102681. }
  102682. else {
  102683. h = 0.0001;
  102684. }
  102685. var radius = this._radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this._radius * this.radiusRange);
  102686. radius = radius * h;
  102687. var randX = radius * Math.sin(s);
  102688. var randZ = radius * Math.cos(s);
  102689. var randY = h * this._height;
  102690. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  102691. };
  102692. /**
  102693. * Clones the current emitter and returns a copy of it
  102694. * @returns the new emitter
  102695. */
  102696. ConeParticleEmitter.prototype.clone = function () {
  102697. var newOne = new ConeParticleEmitter(this._radius, this._angle, this.directionRandomizer);
  102698. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  102699. return newOne;
  102700. };
  102701. /**
  102702. * Called by the GPUParticleSystem to setup the update shader
  102703. * @param effect defines the update shader
  102704. */
  102705. ConeParticleEmitter.prototype.applyToShader = function (effect) {
  102706. effect.setFloat2("radius", this._radius, this.radiusRange);
  102707. effect.setFloat("coneAngle", this._angle);
  102708. effect.setFloat2("height", this._height, this.heightRange);
  102709. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102710. };
  102711. /**
  102712. * Returns a string to use to update the GPU particles update shader
  102713. * @returns a string containng the defines string
  102714. */
  102715. ConeParticleEmitter.prototype.getEffectDefines = function () {
  102716. var defines = "#define CONEEMITTER";
  102717. if (this.emitFromSpawnPointOnly) {
  102718. defines += "\n#define CONEEMITTERSPAWNPOINT";
  102719. }
  102720. return defines;
  102721. };
  102722. /**
  102723. * Returns the string "ConeParticleEmitter"
  102724. * @returns a string containing the class name
  102725. */
  102726. ConeParticleEmitter.prototype.getClassName = function () {
  102727. return "ConeParticleEmitter";
  102728. };
  102729. /**
  102730. * Serializes the particle system to a JSON object.
  102731. * @returns the JSON object
  102732. */
  102733. ConeParticleEmitter.prototype.serialize = function () {
  102734. var serializationObject = {};
  102735. serializationObject.type = this.getClassName();
  102736. serializationObject.radius = this._radius;
  102737. serializationObject.angle = this._angle;
  102738. serializationObject.directionRandomizer = this.directionRandomizer;
  102739. return serializationObject;
  102740. };
  102741. /**
  102742. * Parse properties from a JSON object
  102743. * @param serializationObject defines the JSON object
  102744. */
  102745. ConeParticleEmitter.prototype.parse = function (serializationObject) {
  102746. this.radius = serializationObject.radius;
  102747. this.angle = serializationObject.angle;
  102748. this.directionRandomizer = serializationObject.directionRandomizer;
  102749. };
  102750. return ConeParticleEmitter;
  102751. }());
  102752. /***/ }),
  102753. /***/ "./Particles/EmitterTypes/cylinderParticleEmitter.ts":
  102754. /*!***********************************************************!*\
  102755. !*** ./Particles/EmitterTypes/cylinderParticleEmitter.ts ***!
  102756. \***********************************************************/
  102757. /*! exports provided: CylinderParticleEmitter, CylinderDirectedParticleEmitter */
  102758. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  102759. "use strict";
  102760. __webpack_require__.r(__webpack_exports__);
  102761. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return CylinderParticleEmitter; });
  102762. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return CylinderDirectedParticleEmitter; });
  102763. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  102764. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  102765. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  102766. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  102767. /**
  102768. * Particle emitter emitting particles from the inside of a cylinder.
  102769. * It emits the particles alongside the cylinder radius. The emission direction might be randomized.
  102770. */
  102771. var CylinderParticleEmitter = /** @class */ (function () {
  102772. /**
  102773. * Creates a new instance CylinderParticleEmitter
  102774. * @param radius the radius of the emission cylinder (1 by default)
  102775. * @param height the height of the emission cylinder (1 by default)
  102776. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102777. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  102778. */
  102779. function CylinderParticleEmitter(
  102780. /**
  102781. * The radius of the emission cylinder.
  102782. */
  102783. radius,
  102784. /**
  102785. * The height of the emission cylinder.
  102786. */
  102787. height,
  102788. /**
  102789. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  102790. */
  102791. radiusRange,
  102792. /**
  102793. * How much to randomize the particle direction [0-1].
  102794. */
  102795. directionRandomizer) {
  102796. if (radius === void 0) { radius = 1; }
  102797. if (height === void 0) { height = 1; }
  102798. if (radiusRange === void 0) { radiusRange = 1; }
  102799. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  102800. this.radius = radius;
  102801. this.height = height;
  102802. this.radiusRange = radiusRange;
  102803. this.directionRandomizer = directionRandomizer;
  102804. }
  102805. /**
  102806. * Called by the particle System when the direction is computed for the created particle.
  102807. * @param worldMatrix is the world matrix of the particle system
  102808. * @param directionToUpdate is the direction vector to update with the result
  102809. * @param particle is the particle we are computed the direction for
  102810. */
  102811. CylinderParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102812. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  102813. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.directionRandomizer / 2, this.directionRandomizer / 2);
  102814. var angle = Math.atan2(direction.x, direction.z);
  102815. angle += _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-Math.PI / 2, Math.PI / 2) * this.directionRandomizer;
  102816. direction.y = randY; // set direction y to rand y to mirror normal of cylinder surface
  102817. direction.x = Math.sin(angle);
  102818. direction.z = Math.cos(angle);
  102819. direction.normalize();
  102820. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  102821. };
  102822. /**
  102823. * Called by the particle System when the position is computed for the created particle.
  102824. * @param worldMatrix is the world matrix of the particle system
  102825. * @param positionToUpdate is the position vector to update with the result
  102826. * @param particle is the particle we are computed the position for
  102827. */
  102828. CylinderParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  102829. var yPos = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(-this.height / 2, this.height / 2);
  102830. var angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  102831. // Pick a properly distributed point within the circle https://programming.guide/random-point-within-circle.html
  102832. var radiusDistribution = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange((1 - this.radiusRange) * (1 - this.radiusRange), 1);
  102833. var positionRadius = Math.sqrt(radiusDistribution) * this.radius;
  102834. var xPos = positionRadius * Math.cos(angle);
  102835. var zPos = positionRadius * Math.sin(angle);
  102836. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(xPos, yPos, zPos, worldMatrix, positionToUpdate);
  102837. };
  102838. /**
  102839. * Clones the current emitter and returns a copy of it
  102840. * @returns the new emitter
  102841. */
  102842. CylinderParticleEmitter.prototype.clone = function () {
  102843. var newOne = new CylinderParticleEmitter(this.radius, this.directionRandomizer);
  102844. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102845. return newOne;
  102846. };
  102847. /**
  102848. * Called by the GPUParticleSystem to setup the update shader
  102849. * @param effect defines the update shader
  102850. */
  102851. CylinderParticleEmitter.prototype.applyToShader = function (effect) {
  102852. effect.setFloat("radius", this.radius);
  102853. effect.setFloat("height", this.height);
  102854. effect.setFloat("radiusRange", this.radiusRange);
  102855. effect.setFloat("directionRandomizer", this.directionRandomizer);
  102856. };
  102857. /**
  102858. * Returns a string to use to update the GPU particles update shader
  102859. * @returns a string containng the defines string
  102860. */
  102861. CylinderParticleEmitter.prototype.getEffectDefines = function () {
  102862. return "#define CYLINDEREMITTER";
  102863. };
  102864. /**
  102865. * Returns the string "CylinderParticleEmitter"
  102866. * @returns a string containing the class name
  102867. */
  102868. CylinderParticleEmitter.prototype.getClassName = function () {
  102869. return "CylinderParticleEmitter";
  102870. };
  102871. /**
  102872. * Serializes the particle system to a JSON object.
  102873. * @returns the JSON object
  102874. */
  102875. CylinderParticleEmitter.prototype.serialize = function () {
  102876. var serializationObject = {};
  102877. serializationObject.type = this.getClassName();
  102878. serializationObject.radius = this.radius;
  102879. serializationObject.height = this.height;
  102880. serializationObject.radiusRange = this.radiusRange;
  102881. serializationObject.directionRandomizer = this.directionRandomizer;
  102882. return serializationObject;
  102883. };
  102884. /**
  102885. * Parse properties from a JSON object
  102886. * @param serializationObject defines the JSON object
  102887. */
  102888. CylinderParticleEmitter.prototype.parse = function (serializationObject) {
  102889. this.radius = serializationObject.radius;
  102890. this.height = serializationObject.height;
  102891. this.radiusRange = serializationObject.radiusRange;
  102892. this.directionRandomizer = serializationObject.directionRandomizer;
  102893. };
  102894. return CylinderParticleEmitter;
  102895. }());
  102896. /**
  102897. * Particle emitter emitting particles from the inside of a cylinder.
  102898. * It emits the particles randomly between two vectors.
  102899. */
  102900. var CylinderDirectedParticleEmitter = /** @class */ (function (_super) {
  102901. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CylinderDirectedParticleEmitter, _super);
  102902. /**
  102903. * Creates a new instance CylinderDirectedParticleEmitter
  102904. * @param radius the radius of the emission cylinder (1 by default)
  102905. * @param height the height of the emission cylinder (1 by default)
  102906. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  102907. * @param direction1 the min limit of the emission direction (up vector by default)
  102908. * @param direction2 the max limit of the emission direction (up vector by default)
  102909. */
  102910. function CylinderDirectedParticleEmitter(radius, height, radiusRange,
  102911. /**
  102912. * The min limit of the emission direction.
  102913. */
  102914. direction1,
  102915. /**
  102916. * The max limit of the emission direction.
  102917. */
  102918. direction2) {
  102919. if (radius === void 0) { radius = 1; }
  102920. if (height === void 0) { height = 1; }
  102921. if (radiusRange === void 0) { radiusRange = 1; }
  102922. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102923. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  102924. var _this = _super.call(this, radius, height, radiusRange) || this;
  102925. _this.direction1 = direction1;
  102926. _this.direction2 = direction2;
  102927. return _this;
  102928. }
  102929. /**
  102930. * Called by the particle System when the direction is computed for the created particle.
  102931. * @param worldMatrix is the world matrix of the particle system
  102932. * @param directionToUpdate is the direction vector to update with the result
  102933. * @param particle is the particle we are computed the direction for
  102934. */
  102935. CylinderDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  102936. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  102937. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  102938. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  102939. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  102940. };
  102941. /**
  102942. * Clones the current emitter and returns a copy of it
  102943. * @returns the new emitter
  102944. */
  102945. CylinderDirectedParticleEmitter.prototype.clone = function () {
  102946. var newOne = new CylinderDirectedParticleEmitter(this.radius, this.height, this.radiusRange, this.direction1, this.direction2);
  102947. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  102948. return newOne;
  102949. };
  102950. /**
  102951. * Called by the GPUParticleSystem to setup the update shader
  102952. * @param effect defines the update shader
  102953. */
  102954. CylinderDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  102955. effect.setFloat("radius", this.radius);
  102956. effect.setFloat("height", this.height);
  102957. effect.setFloat("radiusRange", this.radiusRange);
  102958. effect.setVector3("direction1", this.direction1);
  102959. effect.setVector3("direction2", this.direction2);
  102960. };
  102961. /**
  102962. * Returns a string to use to update the GPU particles update shader
  102963. * @returns a string containng the defines string
  102964. */
  102965. CylinderDirectedParticleEmitter.prototype.getEffectDefines = function () {
  102966. return "#define CYLINDEREMITTER\n#define DIRECTEDCYLINDEREMITTER";
  102967. };
  102968. /**
  102969. * Returns the string "CylinderDirectedParticleEmitter"
  102970. * @returns a string containing the class name
  102971. */
  102972. CylinderDirectedParticleEmitter.prototype.getClassName = function () {
  102973. return "CylinderDirectedParticleEmitter";
  102974. };
  102975. /**
  102976. * Serializes the particle system to a JSON object.
  102977. * @returns the JSON object
  102978. */
  102979. CylinderDirectedParticleEmitter.prototype.serialize = function () {
  102980. var serializationObject = _super.prototype.serialize.call(this);
  102981. serializationObject.direction1 = this.direction1.asArray();
  102982. serializationObject.direction2 = this.direction2.asArray();
  102983. return serializationObject;
  102984. };
  102985. /**
  102986. * Parse properties from a JSON object
  102987. * @param serializationObject defines the JSON object
  102988. */
  102989. CylinderDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  102990. _super.prototype.parse.call(this, serializationObject);
  102991. this.direction1.copyFrom(serializationObject.direction1);
  102992. this.direction2.copyFrom(serializationObject.direction2);
  102993. };
  102994. return CylinderDirectedParticleEmitter;
  102995. }(CylinderParticleEmitter));
  102996. /***/ }),
  102997. /***/ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts":
  102998. /*!**************************************************************!*\
  102999. !*** ./Particles/EmitterTypes/hemisphericParticleEmitter.ts ***!
  103000. \**************************************************************/
  103001. /*! exports provided: HemisphericParticleEmitter */
  103002. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103003. "use strict";
  103004. __webpack_require__.r(__webpack_exports__);
  103005. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return HemisphericParticleEmitter; });
  103006. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103007. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103008. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103009. /**
  103010. * Particle emitter emitting particles from the inside of a hemisphere.
  103011. * It emits the particles alongside the hemisphere radius. The emission direction might be randomized.
  103012. */
  103013. var HemisphericParticleEmitter = /** @class */ (function () {
  103014. /**
  103015. * Creates a new instance HemisphericParticleEmitter
  103016. * @param radius the radius of the emission hemisphere (1 by default)
  103017. * @param radiusRange the range of the emission hemisphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103018. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  103019. */
  103020. function HemisphericParticleEmitter(
  103021. /**
  103022. * The radius of the emission hemisphere.
  103023. */
  103024. radius,
  103025. /**
  103026. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  103027. */
  103028. radiusRange,
  103029. /**
  103030. * How much to randomize the particle direction [0-1].
  103031. */
  103032. directionRandomizer) {
  103033. if (radius === void 0) { radius = 1; }
  103034. if (radiusRange === void 0) { radiusRange = 1; }
  103035. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103036. this.radius = radius;
  103037. this.radiusRange = radiusRange;
  103038. this.directionRandomizer = directionRandomizer;
  103039. }
  103040. /**
  103041. * Called by the particle System when the direction is computed for the created particle.
  103042. * @param worldMatrix is the world matrix of the particle system
  103043. * @param directionToUpdate is the direction vector to update with the result
  103044. * @param particle is the particle we are computed the direction for
  103045. */
  103046. HemisphericParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103047. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  103048. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103049. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103050. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103051. direction.x += randX;
  103052. direction.y += randY;
  103053. direction.z += randZ;
  103054. direction.normalize();
  103055. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  103056. };
  103057. /**
  103058. * Called by the particle System when the position is computed for the created particle.
  103059. * @param worldMatrix is the world matrix of the particle system
  103060. * @param positionToUpdate is the position vector to update with the result
  103061. * @param particle is the particle we are computed the position for
  103062. */
  103063. HemisphericParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103064. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  103065. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  103066. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  103067. var theta = Math.acos(2 * v - 1);
  103068. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  103069. var randY = randRadius * Math.cos(theta);
  103070. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  103071. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, Math.abs(randY), randZ, worldMatrix, positionToUpdate);
  103072. };
  103073. /**
  103074. * Clones the current emitter and returns a copy of it
  103075. * @returns the new emitter
  103076. */
  103077. HemisphericParticleEmitter.prototype.clone = function () {
  103078. var newOne = new HemisphericParticleEmitter(this.radius, this.directionRandomizer);
  103079. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103080. return newOne;
  103081. };
  103082. /**
  103083. * Called by the GPUParticleSystem to setup the update shader
  103084. * @param effect defines the update shader
  103085. */
  103086. HemisphericParticleEmitter.prototype.applyToShader = function (effect) {
  103087. effect.setFloat("radius", this.radius);
  103088. effect.setFloat("radiusRange", this.radiusRange);
  103089. effect.setFloat("directionRandomizer", this.directionRandomizer);
  103090. };
  103091. /**
  103092. * Returns a string to use to update the GPU particles update shader
  103093. * @returns a string containng the defines string
  103094. */
  103095. HemisphericParticleEmitter.prototype.getEffectDefines = function () {
  103096. return "#define HEMISPHERICEMITTER";
  103097. };
  103098. /**
  103099. * Returns the string "HemisphericParticleEmitter"
  103100. * @returns a string containing the class name
  103101. */
  103102. HemisphericParticleEmitter.prototype.getClassName = function () {
  103103. return "HemisphericParticleEmitter";
  103104. };
  103105. /**
  103106. * Serializes the particle system to a JSON object.
  103107. * @returns the JSON object
  103108. */
  103109. HemisphericParticleEmitter.prototype.serialize = function () {
  103110. var serializationObject = {};
  103111. serializationObject.type = this.getClassName();
  103112. serializationObject.radius = this.radius;
  103113. serializationObject.radiusRange = this.radiusRange;
  103114. serializationObject.directionRandomizer = this.directionRandomizer;
  103115. return serializationObject;
  103116. };
  103117. /**
  103118. * Parse properties from a JSON object
  103119. * @param serializationObject defines the JSON object
  103120. */
  103121. HemisphericParticleEmitter.prototype.parse = function (serializationObject) {
  103122. this.radius = serializationObject.radius;
  103123. this.radiusRange = serializationObject.radiusRange;
  103124. this.directionRandomizer = serializationObject.directionRandomizer;
  103125. };
  103126. return HemisphericParticleEmitter;
  103127. }());
  103128. /***/ }),
  103129. /***/ "./Particles/EmitterTypes/index.ts":
  103130. /*!*****************************************!*\
  103131. !*** ./Particles/EmitterTypes/index.ts ***!
  103132. \*****************************************/
  103133. /*! exports provided: BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  103134. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103135. "use strict";
  103136. __webpack_require__.r(__webpack_exports__);
  103137. /* harmony import */ var _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  103138. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _boxParticleEmitter__WEBPACK_IMPORTED_MODULE_0__["BoxParticleEmitter"]; });
  103139. /* harmony import */ var _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./coneParticleEmitter */ "./Particles/EmitterTypes/coneParticleEmitter.ts");
  103140. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _coneParticleEmitter__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  103141. /* harmony import */ var _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./cylinderParticleEmitter */ "./Particles/EmitterTypes/cylinderParticleEmitter.ts");
  103142. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"]; });
  103143. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _cylinderParticleEmitter__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"]; });
  103144. /* harmony import */ var _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./hemisphericParticleEmitter */ "./Particles/EmitterTypes/hemisphericParticleEmitter.ts");
  103145. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _hemisphericParticleEmitter__WEBPACK_IMPORTED_MODULE_3__["HemisphericParticleEmitter"]; });
  103146. /* harmony import */ var _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./pointParticleEmitter */ "./Particles/EmitterTypes/pointParticleEmitter.ts");
  103147. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _pointParticleEmitter__WEBPACK_IMPORTED_MODULE_4__["PointParticleEmitter"]; });
  103148. /* harmony import */ var _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./sphereParticleEmitter */ "./Particles/EmitterTypes/sphereParticleEmitter.ts");
  103149. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereParticleEmitter"]; });
  103150. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _sphereParticleEmitter__WEBPACK_IMPORTED_MODULE_5__["SphereDirectedParticleEmitter"]; });
  103151. /***/ }),
  103152. /***/ "./Particles/EmitterTypes/pointParticleEmitter.ts":
  103153. /*!********************************************************!*\
  103154. !*** ./Particles/EmitterTypes/pointParticleEmitter.ts ***!
  103155. \********************************************************/
  103156. /*! exports provided: PointParticleEmitter */
  103157. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103158. "use strict";
  103159. __webpack_require__.r(__webpack_exports__);
  103160. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return PointParticleEmitter; });
  103161. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103162. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103163. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103164. /**
  103165. * Particle emitter emitting particles from a point.
  103166. * It emits the particles randomly between 2 given directions.
  103167. */
  103168. var PointParticleEmitter = /** @class */ (function () {
  103169. /**
  103170. * Creates a new instance PointParticleEmitter
  103171. */
  103172. function PointParticleEmitter() {
  103173. /**
  103174. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103175. */
  103176. this.direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103177. /**
  103178. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103179. */
  103180. this.direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1.0, 0);
  103181. }
  103182. /**
  103183. * Called by the particle System when the direction is computed for the created particle.
  103184. * @param worldMatrix is the world matrix of the particle system
  103185. * @param directionToUpdate is the direction vector to update with the result
  103186. * @param particle is the particle we are computed the direction for
  103187. */
  103188. PointParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103189. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  103190. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  103191. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  103192. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  103193. };
  103194. /**
  103195. * Called by the particle System when the position is computed for the created particle.
  103196. * @param worldMatrix is the world matrix of the particle system
  103197. * @param positionToUpdate is the position vector to update with the result
  103198. * @param particle is the particle we are computed the position for
  103199. */
  103200. PointParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103201. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(0, 0, 0, worldMatrix, positionToUpdate);
  103202. };
  103203. /**
  103204. * Clones the current emitter and returns a copy of it
  103205. * @returns the new emitter
  103206. */
  103207. PointParticleEmitter.prototype.clone = function () {
  103208. var newOne = new PointParticleEmitter();
  103209. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_0__["DeepCopier"].DeepCopy(this, newOne);
  103210. return newOne;
  103211. };
  103212. /**
  103213. * Called by the GPUParticleSystem to setup the update shader
  103214. * @param effect defines the update shader
  103215. */
  103216. PointParticleEmitter.prototype.applyToShader = function (effect) {
  103217. effect.setVector3("direction1", this.direction1);
  103218. effect.setVector3("direction2", this.direction2);
  103219. };
  103220. /**
  103221. * Returns a string to use to update the GPU particles update shader
  103222. * @returns a string containng the defines string
  103223. */
  103224. PointParticleEmitter.prototype.getEffectDefines = function () {
  103225. return "#define POINTEMITTER";
  103226. };
  103227. /**
  103228. * Returns the string "PointParticleEmitter"
  103229. * @returns a string containing the class name
  103230. */
  103231. PointParticleEmitter.prototype.getClassName = function () {
  103232. return "PointParticleEmitter";
  103233. };
  103234. /**
  103235. * Serializes the particle system to a JSON object.
  103236. * @returns the JSON object
  103237. */
  103238. PointParticleEmitter.prototype.serialize = function () {
  103239. var serializationObject = {};
  103240. serializationObject.type = this.getClassName();
  103241. serializationObject.direction1 = this.direction1.asArray();
  103242. serializationObject.direction2 = this.direction2.asArray();
  103243. return serializationObject;
  103244. };
  103245. /**
  103246. * Parse properties from a JSON object
  103247. * @param serializationObject defines the JSON object
  103248. */
  103249. PointParticleEmitter.prototype.parse = function (serializationObject) {
  103250. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction1, 0, this.direction1);
  103251. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArrayToRef(serializationObject.direction2, 0, this.direction2);
  103252. };
  103253. return PointParticleEmitter;
  103254. }());
  103255. /***/ }),
  103256. /***/ "./Particles/EmitterTypes/sphereParticleEmitter.ts":
  103257. /*!*********************************************************!*\
  103258. !*** ./Particles/EmitterTypes/sphereParticleEmitter.ts ***!
  103259. \*********************************************************/
  103260. /*! exports provided: SphereParticleEmitter, SphereDirectedParticleEmitter */
  103261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103262. "use strict";
  103263. __webpack_require__.r(__webpack_exports__);
  103264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return SphereParticleEmitter; });
  103265. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return SphereDirectedParticleEmitter; });
  103266. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  103267. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  103268. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  103269. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Misc/deepCopier */ "./Misc/deepCopier.ts");
  103270. /**
  103271. * Particle emitter emitting particles from the inside of a sphere.
  103272. * It emits the particles alongside the sphere radius. The emission direction might be randomized.
  103273. */
  103274. var SphereParticleEmitter = /** @class */ (function () {
  103275. /**
  103276. * Creates a new instance SphereParticleEmitter
  103277. * @param radius the radius of the emission sphere (1 by default)
  103278. * @param radiusRange the range of the emission sphere [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  103279. * @param directionRandomizer defines how much to randomize the particle direction [0-1]
  103280. */
  103281. function SphereParticleEmitter(
  103282. /**
  103283. * The radius of the emission sphere.
  103284. */
  103285. radius,
  103286. /**
  103287. * The range of emission [0-1] 0 Surface only, 1 Entire Radius.
  103288. */
  103289. radiusRange,
  103290. /**
  103291. * How much to randomize the particle direction [0-1].
  103292. */
  103293. directionRandomizer) {
  103294. if (radius === void 0) { radius = 1; }
  103295. if (radiusRange === void 0) { radiusRange = 1; }
  103296. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  103297. this.radius = radius;
  103298. this.radiusRange = radiusRange;
  103299. this.directionRandomizer = directionRandomizer;
  103300. }
  103301. /**
  103302. * Called by the particle System when the direction is computed for the created particle.
  103303. * @param worldMatrix is the world matrix of the particle system
  103304. * @param directionToUpdate is the direction vector to update with the result
  103305. * @param particle is the particle we are computed the direction for
  103306. */
  103307. SphereParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103308. var direction = particle.position.subtract(worldMatrix.getTranslation()).normalize();
  103309. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103310. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103311. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.directionRandomizer);
  103312. direction.x += randX;
  103313. direction.y += randY;
  103314. direction.z += randZ;
  103315. direction.normalize();
  103316. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(direction.x, direction.y, direction.z, worldMatrix, directionToUpdate);
  103317. };
  103318. /**
  103319. * Called by the particle System when the position is computed for the created particle.
  103320. * @param worldMatrix is the world matrix of the particle system
  103321. * @param positionToUpdate is the position vector to update with the result
  103322. * @param particle is the particle we are computed the position for
  103323. */
  103324. SphereParticleEmitter.prototype.startPositionFunction = function (worldMatrix, positionToUpdate, particle) {
  103325. var randRadius = this.radius - _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, this.radius * this.radiusRange);
  103326. var v = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 1.0);
  103327. var phi = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(0, 2 * Math.PI);
  103328. var theta = Math.acos(2 * v - 1);
  103329. var randX = randRadius * Math.cos(phi) * Math.sin(theta);
  103330. var randY = randRadius * Math.cos(theta);
  103331. var randZ = randRadius * Math.sin(phi) * Math.sin(theta);
  103332. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinatesFromFloatsToRef(randX, randY, randZ, worldMatrix, positionToUpdate);
  103333. };
  103334. /**
  103335. * Clones the current emitter and returns a copy of it
  103336. * @returns the new emitter
  103337. */
  103338. SphereParticleEmitter.prototype.clone = function () {
  103339. var newOne = new SphereParticleEmitter(this.radius, this.directionRandomizer);
  103340. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  103341. return newOne;
  103342. };
  103343. /**
  103344. * Called by the GPUParticleSystem to setup the update shader
  103345. * @param effect defines the update shader
  103346. */
  103347. SphereParticleEmitter.prototype.applyToShader = function (effect) {
  103348. effect.setFloat("radius", this.radius);
  103349. effect.setFloat("radiusRange", this.radiusRange);
  103350. effect.setFloat("directionRandomizer", this.directionRandomizer);
  103351. };
  103352. /**
  103353. * Returns a string to use to update the GPU particles update shader
  103354. * @returns a string containng the defines string
  103355. */
  103356. SphereParticleEmitter.prototype.getEffectDefines = function () {
  103357. return "#define SPHEREEMITTER";
  103358. };
  103359. /**
  103360. * Returns the string "SphereParticleEmitter"
  103361. * @returns a string containing the class name
  103362. */
  103363. SphereParticleEmitter.prototype.getClassName = function () {
  103364. return "SphereParticleEmitter";
  103365. };
  103366. /**
  103367. * Serializes the particle system to a JSON object.
  103368. * @returns the JSON object
  103369. */
  103370. SphereParticleEmitter.prototype.serialize = function () {
  103371. var serializationObject = {};
  103372. serializationObject.type = this.getClassName();
  103373. serializationObject.radius = this.radius;
  103374. serializationObject.radiusRange = this.radiusRange;
  103375. serializationObject.directionRandomizer = this.directionRandomizer;
  103376. return serializationObject;
  103377. };
  103378. /**
  103379. * Parse properties from a JSON object
  103380. * @param serializationObject defines the JSON object
  103381. */
  103382. SphereParticleEmitter.prototype.parse = function (serializationObject) {
  103383. this.radius = serializationObject.radius;
  103384. this.radiusRange = serializationObject.radiusRange;
  103385. this.directionRandomizer = serializationObject.directionRandomizer;
  103386. };
  103387. return SphereParticleEmitter;
  103388. }());
  103389. /**
  103390. * Particle emitter emitting particles from the inside of a sphere.
  103391. * It emits the particles randomly between two vectors.
  103392. */
  103393. var SphereDirectedParticleEmitter = /** @class */ (function (_super) {
  103394. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SphereDirectedParticleEmitter, _super);
  103395. /**
  103396. * Creates a new instance SphereDirectedParticleEmitter
  103397. * @param radius the radius of the emission sphere (1 by default)
  103398. * @param direction1 the min limit of the emission direction (up vector by default)
  103399. * @param direction2 the max limit of the emission direction (up vector by default)
  103400. */
  103401. function SphereDirectedParticleEmitter(radius,
  103402. /**
  103403. * The min limit of the emission direction.
  103404. */
  103405. direction1,
  103406. /**
  103407. * The max limit of the emission direction.
  103408. */
  103409. direction2) {
  103410. if (radius === void 0) { radius = 1; }
  103411. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  103412. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, 1, 0); }
  103413. var _this = _super.call(this, radius) || this;
  103414. _this.direction1 = direction1;
  103415. _this.direction2 = direction2;
  103416. return _this;
  103417. }
  103418. /**
  103419. * Called by the particle System when the direction is computed for the created particle.
  103420. * @param worldMatrix is the world matrix of the particle system
  103421. * @param directionToUpdate is the direction vector to update with the result
  103422. * @param particle is the particle we are computed the direction for
  103423. */
  103424. SphereDirectedParticleEmitter.prototype.startDirectionFunction = function (worldMatrix, directionToUpdate, particle) {
  103425. var randX = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.x, this.direction2.x);
  103426. var randY = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.y, this.direction2.y);
  103427. var randZ = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_2__["Scalar"].RandomRange(this.direction1.z, this.direction2.z);
  103428. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformNormalFromFloatsToRef(randX, randY, randZ, worldMatrix, directionToUpdate);
  103429. };
  103430. /**
  103431. * Clones the current emitter and returns a copy of it
  103432. * @returns the new emitter
  103433. */
  103434. SphereDirectedParticleEmitter.prototype.clone = function () {
  103435. var newOne = new SphereDirectedParticleEmitter(this.radius, this.direction1, this.direction2);
  103436. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_3__["DeepCopier"].DeepCopy(this, newOne);
  103437. return newOne;
  103438. };
  103439. /**
  103440. * Called by the GPUParticleSystem to setup the update shader
  103441. * @param effect defines the update shader
  103442. */
  103443. SphereDirectedParticleEmitter.prototype.applyToShader = function (effect) {
  103444. effect.setFloat("radius", this.radius);
  103445. effect.setFloat("radiusRange", this.radiusRange);
  103446. effect.setVector3("direction1", this.direction1);
  103447. effect.setVector3("direction2", this.direction2);
  103448. };
  103449. /**
  103450. * Returns a string to use to update the GPU particles update shader
  103451. * @returns a string containng the defines string
  103452. */
  103453. SphereDirectedParticleEmitter.prototype.getEffectDefines = function () {
  103454. return "#define SPHEREEMITTER\n#define DIRECTEDSPHEREEMITTER";
  103455. };
  103456. /**
  103457. * Returns the string "SphereDirectedParticleEmitter"
  103458. * @returns a string containing the class name
  103459. */
  103460. SphereDirectedParticleEmitter.prototype.getClassName = function () {
  103461. return "SphereDirectedParticleEmitter";
  103462. };
  103463. /**
  103464. * Serializes the particle system to a JSON object.
  103465. * @returns the JSON object
  103466. */
  103467. SphereDirectedParticleEmitter.prototype.serialize = function () {
  103468. var serializationObject = _super.prototype.serialize.call(this);
  103469. serializationObject.direction1 = this.direction1.asArray();
  103470. serializationObject.direction2 = this.direction2.asArray();
  103471. return serializationObject;
  103472. };
  103473. /**
  103474. * Parse properties from a JSON object
  103475. * @param serializationObject defines the JSON object
  103476. */
  103477. SphereDirectedParticleEmitter.prototype.parse = function (serializationObject) {
  103478. _super.prototype.parse.call(this, serializationObject);
  103479. this.direction1.copyFrom(serializationObject.direction1);
  103480. this.direction2.copyFrom(serializationObject.direction2);
  103481. };
  103482. return SphereDirectedParticleEmitter;
  103483. }(SphereParticleEmitter));
  103484. /***/ }),
  103485. /***/ "./Particles/baseParticleSystem.ts":
  103486. /*!*****************************************!*\
  103487. !*** ./Particles/baseParticleSystem.ts ***!
  103488. \*****************************************/
  103489. /*! exports provided: BaseParticleSystem */
  103490. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  103491. "use strict";
  103492. __webpack_require__.r(__webpack_exports__);
  103493. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return BaseParticleSystem; });
  103494. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  103495. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  103496. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  103497. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  103498. /**
  103499. * This represents the base class for particle system in Babylon.
  103500. * 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.
  103501. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  103502. * @example https://doc.babylonjs.com/babylon101/particles
  103503. */
  103504. var BaseParticleSystem = /** @class */ (function () {
  103505. /**
  103506. * Instantiates a particle system.
  103507. * 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.
  103508. * @param name The name of the particle system
  103509. */
  103510. function BaseParticleSystem(name) {
  103511. /**
  103512. * List of animations used by the particle system.
  103513. */
  103514. this.animations = [];
  103515. /**
  103516. * The rendering group used by the Particle system to chose when to render.
  103517. */
  103518. this.renderingGroupId = 0;
  103519. /**
  103520. * The emitter represents the Mesh or position we are attaching the particle system to.
  103521. */
  103522. this.emitter = null;
  103523. /**
  103524. * The maximum number of particles to emit per frame
  103525. */
  103526. this.emitRate = 10;
  103527. /**
  103528. * If you want to launch only a few particles at once, that can be done, as well.
  103529. */
  103530. this.manualEmitCount = -1;
  103531. /**
  103532. * The overall motion speed (0.01 is default update speed, faster updates = faster animation)
  103533. */
  103534. this.updateSpeed = 0.01;
  103535. /**
  103536. * The amount of time the particle system is running (depends of the overall update speed).
  103537. */
  103538. this.targetStopDuration = 0;
  103539. /**
  103540. * Specifies whether the particle system will be disposed once it reaches the end of the animation.
  103541. */
  103542. this.disposeOnStop = false;
  103543. /**
  103544. * Minimum power of emitting particles.
  103545. */
  103546. this.minEmitPower = 1;
  103547. /**
  103548. * Maximum power of emitting particles.
  103549. */
  103550. this.maxEmitPower = 1;
  103551. /**
  103552. * Minimum life time of emitting particles.
  103553. */
  103554. this.minLifeTime = 1;
  103555. /**
  103556. * Maximum life time of emitting particles.
  103557. */
  103558. this.maxLifeTime = 1;
  103559. /**
  103560. * Minimum Size of emitting particles.
  103561. */
  103562. this.minSize = 1;
  103563. /**
  103564. * Maximum Size of emitting particles.
  103565. */
  103566. this.maxSize = 1;
  103567. /**
  103568. * Minimum scale of emitting particles on X axis.
  103569. */
  103570. this.minScaleX = 1;
  103571. /**
  103572. * Maximum scale of emitting particles on X axis.
  103573. */
  103574. this.maxScaleX = 1;
  103575. /**
  103576. * Minimum scale of emitting particles on Y axis.
  103577. */
  103578. this.minScaleY = 1;
  103579. /**
  103580. * Maximum scale of emitting particles on Y axis.
  103581. */
  103582. this.maxScaleY = 1;
  103583. /**
  103584. * Gets or sets the minimal initial rotation in radians.
  103585. */
  103586. this.minInitialRotation = 0;
  103587. /**
  103588. * Gets or sets the maximal initial rotation in radians.
  103589. */
  103590. this.maxInitialRotation = 0;
  103591. /**
  103592. * Minimum angular speed of emitting particles (Z-axis rotation for each particle).
  103593. */
  103594. this.minAngularSpeed = 0;
  103595. /**
  103596. * Maximum angular speed of emitting particles (Z-axis rotation for each particle).
  103597. */
  103598. this.maxAngularSpeed = 0;
  103599. /**
  103600. * The layer mask we are rendering the particles through.
  103601. */
  103602. this.layerMask = 0x0FFFFFFF;
  103603. /**
  103604. * This can help using your own shader to render the particle system.
  103605. * The according effect will be created
  103606. */
  103607. this.customShader = null;
  103608. /**
  103609. * By default particle system starts as soon as they are created. This prevents the
  103610. * automatic start to happen and let you decide when to start emitting particles.
  103611. */
  103612. this.preventAutoStart = false;
  103613. /** Gets or sets the strength to apply to the noise value (default is (10, 10, 10)) */
  103614. this.noiseStrength = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](10, 10, 10);
  103615. /**
  103616. * Callback triggered when the particle animation is ending.
  103617. */
  103618. this.onAnimationEnd = null;
  103619. /**
  103620. * Blend mode use to render the particle, it can be either ParticleSystem.BLENDMODE_ONEONE or ParticleSystem.BLENDMODE_STANDARD.
  103621. */
  103622. this.blendMode = BaseParticleSystem.BLENDMODE_ONEONE;
  103623. /**
  103624. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  103625. * to override the particles.
  103626. */
  103627. this.forceDepthWrite = false;
  103628. /** 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 */
  103629. this.preWarmCycles = 0;
  103630. /** Gets or sets a value indicating the time step multiplier to use in pre-warm mode (default is 1) */
  103631. this.preWarmStepOffset = 1;
  103632. /**
  103633. * 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)
  103634. */
  103635. this.spriteCellChangeSpeed = 1;
  103636. /**
  103637. * If using a spritesheet (isAnimationSheetEnabled) defines the first sprite cell to display
  103638. */
  103639. this.startSpriteCellID = 0;
  103640. /**
  103641. * If using a spritesheet (isAnimationSheetEnabled) defines the last sprite cell to display
  103642. */
  103643. this.endSpriteCellID = 0;
  103644. /**
  103645. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell width to use
  103646. */
  103647. this.spriteCellWidth = 0;
  103648. /**
  103649. * If using a spritesheet (isAnimationSheetEnabled), defines the sprite cell height to use
  103650. */
  103651. this.spriteCellHeight = 0;
  103652. /**
  103653. * This allows the system to random pick the start cell ID between startSpriteCellID and endSpriteCellID
  103654. */
  103655. this.spriteRandomStartCell = false;
  103656. /** Gets or sets a Vector2 used to move the pivot (by default (0,0)) */
  103657. this.translationPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](0, 0);
  103658. /**
  103659. * Gets or sets a boolean indicating that hosted animations (in the system.animations array) must be started when system.start() is called
  103660. */
  103661. this.beginAnimationOnStart = false;
  103662. /**
  103663. * Gets or sets the frame to start the animation from when beginAnimationOnStart is true
  103664. */
  103665. this.beginAnimationFrom = 0;
  103666. /**
  103667. * Gets or sets the frame to end the animation on when beginAnimationOnStart is true
  103668. */
  103669. this.beginAnimationTo = 60;
  103670. /**
  103671. * Gets or sets a boolean indicating if animations must loop when beginAnimationOnStart is true
  103672. */
  103673. this.beginAnimationLoop = false;
  103674. /**
  103675. * You can use gravity if you want to give an orientation to your particles.
  103676. */
  103677. this.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103678. this._colorGradients = null;
  103679. this._sizeGradients = null;
  103680. this._lifeTimeGradients = null;
  103681. this._angularSpeedGradients = null;
  103682. this._velocityGradients = null;
  103683. this._limitVelocityGradients = null;
  103684. this._dragGradients = null;
  103685. this._emitRateGradients = null;
  103686. this._startSizeGradients = null;
  103687. this._rampGradients = null;
  103688. this._colorRemapGradients = null;
  103689. this._alphaRemapGradients = null;
  103690. /**
  103691. * Defines the delay in milliseconds before starting the system (0 by default)
  103692. */
  103693. this.startDelay = 0;
  103694. /** Gets or sets a value indicating the damping to apply if the limit velocity factor is reached */
  103695. this.limitVelocityDamping = 0.4;
  103696. /**
  103697. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103698. */
  103699. this.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103700. /**
  103701. * Random color of each particle after it has been emitted, between color1 and color2 vectors
  103702. */
  103703. this.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103704. /**
  103705. * Color the particle will have at the end of its lifetime
  103706. */
  103707. this.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 1.0);
  103708. /**
  103709. * An optional mask to filter some colors out of the texture, or filter a part of the alpha channel
  103710. */
  103711. this.textureMask = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  103712. /** @hidden */
  103713. this._isSubEmitter = false;
  103714. /**
  103715. * Gets or sets the billboard mode to use when isBillboardBased = true.
  103716. * Value can be: ParticleSystem.BILLBOARDMODE_ALL, ParticleSystem.BILLBOARDMODE_Y, ParticleSystem.BILLBOARDMODE_STRETCHED
  103717. */
  103718. this.billboardMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  103719. this._isBillboardBased = true;
  103720. /**
  103721. * Local cache of defines for image processing.
  103722. */
  103723. this._imageProcessingConfigurationDefines = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_1__["ImageProcessingConfigurationDefines"]();
  103724. this.id = name;
  103725. this.name = name;
  103726. }
  103727. Object.defineProperty(BaseParticleSystem.prototype, "noiseTexture", {
  103728. /**
  103729. * Gets or sets a texture used to add random noise to particle positions
  103730. */
  103731. get: function () {
  103732. return this._noiseTexture;
  103733. },
  103734. set: function (value) {
  103735. if (this._noiseTexture === value) {
  103736. return;
  103737. }
  103738. this._noiseTexture = value;
  103739. this._reset();
  103740. },
  103741. enumerable: true,
  103742. configurable: true
  103743. });
  103744. Object.defineProperty(BaseParticleSystem.prototype, "isAnimationSheetEnabled", {
  103745. /**
  103746. * Gets or sets whether an animation sprite sheet is enabled or not on the particle system
  103747. */
  103748. get: function () {
  103749. return this._isAnimationSheetEnabled;
  103750. },
  103751. set: function (value) {
  103752. if (this._isAnimationSheetEnabled == value) {
  103753. return;
  103754. }
  103755. this._isAnimationSheetEnabled = value;
  103756. this._reset();
  103757. },
  103758. enumerable: true,
  103759. configurable: true
  103760. });
  103761. /**
  103762. * Get hosting scene
  103763. * @returns the scene
  103764. */
  103765. BaseParticleSystem.prototype.getScene = function () {
  103766. return this._scene;
  103767. };
  103768. BaseParticleSystem.prototype._hasTargetStopDurationDependantGradient = function () {
  103769. return (this._startSizeGradients && this._startSizeGradients.length > 0)
  103770. || (this._emitRateGradients && this._emitRateGradients.length > 0)
  103771. || (this._lifeTimeGradients && this._lifeTimeGradients.length > 0);
  103772. };
  103773. /**
  103774. * Gets the current list of drag gradients.
  103775. * You must use addDragGradient and removeDragGradient to udpate this list
  103776. * @returns the list of drag gradients
  103777. */
  103778. BaseParticleSystem.prototype.getDragGradients = function () {
  103779. return this._dragGradients;
  103780. };
  103781. /**
  103782. * Gets the current list of limit velocity gradients.
  103783. * You must use addLimitVelocityGradient and removeLimitVelocityGradient to udpate this list
  103784. * @returns the list of limit velocity gradients
  103785. */
  103786. BaseParticleSystem.prototype.getLimitVelocityGradients = function () {
  103787. return this._limitVelocityGradients;
  103788. };
  103789. /**
  103790. * Gets the current list of color gradients.
  103791. * You must use addColorGradient and removeColorGradient to udpate this list
  103792. * @returns the list of color gradients
  103793. */
  103794. BaseParticleSystem.prototype.getColorGradients = function () {
  103795. return this._colorGradients;
  103796. };
  103797. /**
  103798. * Gets the current list of size gradients.
  103799. * You must use addSizeGradient and removeSizeGradient to udpate this list
  103800. * @returns the list of size gradients
  103801. */
  103802. BaseParticleSystem.prototype.getSizeGradients = function () {
  103803. return this._sizeGradients;
  103804. };
  103805. /**
  103806. * Gets the current list of color remap gradients.
  103807. * You must use addColorRemapGradient and removeColorRemapGradient to udpate this list
  103808. * @returns the list of color remap gradients
  103809. */
  103810. BaseParticleSystem.prototype.getColorRemapGradients = function () {
  103811. return this._colorRemapGradients;
  103812. };
  103813. /**
  103814. * Gets the current list of alpha remap gradients.
  103815. * You must use addAlphaRemapGradient and removeAlphaRemapGradient to udpate this list
  103816. * @returns the list of alpha remap gradients
  103817. */
  103818. BaseParticleSystem.prototype.getAlphaRemapGradients = function () {
  103819. return this._alphaRemapGradients;
  103820. };
  103821. /**
  103822. * Gets the current list of life time gradients.
  103823. * You must use addLifeTimeGradient and removeLifeTimeGradient to udpate this list
  103824. * @returns the list of life time gradients
  103825. */
  103826. BaseParticleSystem.prototype.getLifeTimeGradients = function () {
  103827. return this._lifeTimeGradients;
  103828. };
  103829. /**
  103830. * Gets the current list of angular speed gradients.
  103831. * You must use addAngularSpeedGradient and removeAngularSpeedGradient to udpate this list
  103832. * @returns the list of angular speed gradients
  103833. */
  103834. BaseParticleSystem.prototype.getAngularSpeedGradients = function () {
  103835. return this._angularSpeedGradients;
  103836. };
  103837. /**
  103838. * Gets the current list of velocity gradients.
  103839. * You must use addVelocityGradient and removeVelocityGradient to udpate this list
  103840. * @returns the list of velocity gradients
  103841. */
  103842. BaseParticleSystem.prototype.getVelocityGradients = function () {
  103843. return this._velocityGradients;
  103844. };
  103845. /**
  103846. * Gets the current list of start size gradients.
  103847. * You must use addStartSizeGradient and removeStartSizeGradient to udpate this list
  103848. * @returns the list of start size gradients
  103849. */
  103850. BaseParticleSystem.prototype.getStartSizeGradients = function () {
  103851. return this._startSizeGradients;
  103852. };
  103853. /**
  103854. * Gets the current list of emit rate gradients.
  103855. * You must use addEmitRateGradient and removeEmitRateGradient to udpate this list
  103856. * @returns the list of emit rate gradients
  103857. */
  103858. BaseParticleSystem.prototype.getEmitRateGradients = function () {
  103859. return this._emitRateGradients;
  103860. };
  103861. Object.defineProperty(BaseParticleSystem.prototype, "direction1", {
  103862. /**
  103863. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103864. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103865. */
  103866. get: function () {
  103867. if (this.particleEmitterType.direction1) {
  103868. return this.particleEmitterType.direction1;
  103869. }
  103870. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103871. },
  103872. set: function (value) {
  103873. if (this.particleEmitterType.direction1) {
  103874. this.particleEmitterType.direction1 = value;
  103875. }
  103876. },
  103877. enumerable: true,
  103878. configurable: true
  103879. });
  103880. Object.defineProperty(BaseParticleSystem.prototype, "direction2", {
  103881. /**
  103882. * Random direction of each particle after it has been emitted, between direction1 and direction2 vectors.
  103883. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103884. */
  103885. get: function () {
  103886. if (this.particleEmitterType.direction2) {
  103887. return this.particleEmitterType.direction2;
  103888. }
  103889. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103890. },
  103891. set: function (value) {
  103892. if (this.particleEmitterType.direction2) {
  103893. this.particleEmitterType.direction2 = value;
  103894. }
  103895. },
  103896. enumerable: true,
  103897. configurable: true
  103898. });
  103899. Object.defineProperty(BaseParticleSystem.prototype, "minEmitBox", {
  103900. /**
  103901. * 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.
  103902. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103903. */
  103904. get: function () {
  103905. if (this.particleEmitterType.minEmitBox) {
  103906. return this.particleEmitterType.minEmitBox;
  103907. }
  103908. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103909. },
  103910. set: function (value) {
  103911. if (this.particleEmitterType.minEmitBox) {
  103912. this.particleEmitterType.minEmitBox = value;
  103913. }
  103914. },
  103915. enumerable: true,
  103916. configurable: true
  103917. });
  103918. Object.defineProperty(BaseParticleSystem.prototype, "maxEmitBox", {
  103919. /**
  103920. * 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.
  103921. * This only works when particleEmitterTyps is a BoxParticleEmitter
  103922. */
  103923. get: function () {
  103924. if (this.particleEmitterType.maxEmitBox) {
  103925. return this.particleEmitterType.maxEmitBox;
  103926. }
  103927. return _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  103928. },
  103929. set: function (value) {
  103930. if (this.particleEmitterType.maxEmitBox) {
  103931. this.particleEmitterType.maxEmitBox = value;
  103932. }
  103933. },
  103934. enumerable: true,
  103935. configurable: true
  103936. });
  103937. Object.defineProperty(BaseParticleSystem.prototype, "isBillboardBased", {
  103938. /**
  103939. * Gets or sets a boolean indicating if the particles must be rendered as billboard or aligned with the direction
  103940. */
  103941. get: function () {
  103942. return this._isBillboardBased;
  103943. },
  103944. set: function (value) {
  103945. if (this._isBillboardBased === value) {
  103946. return;
  103947. }
  103948. this._isBillboardBased = value;
  103949. this._reset();
  103950. },
  103951. enumerable: true,
  103952. configurable: true
  103953. });
  103954. Object.defineProperty(BaseParticleSystem.prototype, "imageProcessingConfiguration", {
  103955. /**
  103956. * Gets the image processing configuration used either in this material.
  103957. */
  103958. get: function () {
  103959. return this._imageProcessingConfiguration;
  103960. },
  103961. /**
  103962. * Sets the Default image processing configuration used either in the this material.
  103963. *
  103964. * If sets to null, the scene one is in use.
  103965. */
  103966. set: function (value) {
  103967. this._attachImageProcessingConfiguration(value);
  103968. },
  103969. enumerable: true,
  103970. configurable: true
  103971. });
  103972. /**
  103973. * Attaches a new image processing configuration to the Standard Material.
  103974. * @param configuration
  103975. */
  103976. BaseParticleSystem.prototype._attachImageProcessingConfiguration = function (configuration) {
  103977. if (configuration === this._imageProcessingConfiguration) {
  103978. return;
  103979. }
  103980. // Pick the scene configuration if needed.
  103981. if (!configuration) {
  103982. this._imageProcessingConfiguration = this._scene.imageProcessingConfiguration;
  103983. }
  103984. else {
  103985. this._imageProcessingConfiguration = configuration;
  103986. }
  103987. };
  103988. /** @hidden */
  103989. BaseParticleSystem.prototype._reset = function () {
  103990. };
  103991. /** @hidden */
  103992. BaseParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  103993. if (!gradients) {
  103994. return this;
  103995. }
  103996. var index = 0;
  103997. for (var _i = 0, gradients_1 = gradients; _i < gradients_1.length; _i++) {
  103998. var valueGradient = gradients_1[_i];
  103999. if (valueGradient.gradient === gradient) {
  104000. gradients.splice(index, 1);
  104001. break;
  104002. }
  104003. index++;
  104004. }
  104005. if (texture) {
  104006. texture.dispose();
  104007. }
  104008. return this;
  104009. };
  104010. /**
  104011. * Creates a Point Emitter for the particle system (emits directly from the emitter position)
  104012. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  104013. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  104014. * @returns the emitter
  104015. */
  104016. BaseParticleSystem.prototype.createPointEmitter = function (direction1, direction2) {
  104017. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["PointParticleEmitter"]();
  104018. particleEmitter.direction1 = direction1;
  104019. particleEmitter.direction2 = direction2;
  104020. this.particleEmitterType = particleEmitter;
  104021. return particleEmitter;
  104022. };
  104023. /**
  104024. * Creates a Hemisphere Emitter for the particle system (emits along the hemisphere radius)
  104025. * @param radius The radius of the hemisphere to emit from
  104026. * @param radiusRange The range of the hemisphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  104027. * @returns the emitter
  104028. */
  104029. BaseParticleSystem.prototype.createHemisphericEmitter = function (radius, radiusRange) {
  104030. if (radius === void 0) { radius = 1; }
  104031. if (radiusRange === void 0) { radiusRange = 1; }
  104032. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["HemisphericParticleEmitter"](radius, radiusRange);
  104033. this.particleEmitterType = particleEmitter;
  104034. return particleEmitter;
  104035. };
  104036. /**
  104037. * Creates a Sphere Emitter for the particle system (emits along the sphere radius)
  104038. * @param radius The radius of the sphere to emit from
  104039. * @param radiusRange The range of the sphere to emit from [0-1] 0 Surface Only, 1 Entire Radius
  104040. * @returns the emitter
  104041. */
  104042. BaseParticleSystem.prototype.createSphereEmitter = function (radius, radiusRange) {
  104043. if (radius === void 0) { radius = 1; }
  104044. if (radiusRange === void 0) { radiusRange = 1; }
  104045. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereParticleEmitter"](radius, radiusRange);
  104046. this.particleEmitterType = particleEmitter;
  104047. return particleEmitter;
  104048. };
  104049. /**
  104050. * Creates a Directed Sphere Emitter for the particle system (emits between direction1 and direction2)
  104051. * @param radius The radius of the sphere to emit from
  104052. * @param direction1 Particles are emitted between the direction1 and direction2 from within the sphere
  104053. * @param direction2 Particles are emitted between the direction1 and direction2 from within the sphere
  104054. * @returns the emitter
  104055. */
  104056. BaseParticleSystem.prototype.createDirectedSphereEmitter = function (radius, direction1, direction2) {
  104057. if (radius === void 0) { radius = 1; }
  104058. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104059. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104060. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["SphereDirectedParticleEmitter"](radius, direction1, direction2);
  104061. this.particleEmitterType = particleEmitter;
  104062. return particleEmitter;
  104063. };
  104064. /**
  104065. * Creates a Cylinder Emitter for the particle system (emits from the cylinder to the particle position)
  104066. * @param radius The radius of the emission cylinder
  104067. * @param height The height of the emission cylinder
  104068. * @param radiusRange The range of emission [0-1] 0 Surface only, 1 Entire Radius
  104069. * @param directionRandomizer How much to randomize the particle direction [0-1]
  104070. * @returns the emitter
  104071. */
  104072. BaseParticleSystem.prototype.createCylinderEmitter = function (radius, height, radiusRange, directionRandomizer) {
  104073. if (radius === void 0) { radius = 1; }
  104074. if (height === void 0) { height = 1; }
  104075. if (radiusRange === void 0) { radiusRange = 1; }
  104076. if (directionRandomizer === void 0) { directionRandomizer = 0; }
  104077. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderParticleEmitter"](radius, height, radiusRange, directionRandomizer);
  104078. this.particleEmitterType = particleEmitter;
  104079. return particleEmitter;
  104080. };
  104081. /**
  104082. * Creates a Directed Cylinder Emitter for the particle system (emits between direction1 and direction2)
  104083. * @param radius The radius of the cylinder to emit from
  104084. * @param height The height of the emission cylinder
  104085. * @param radiusRange the range of the emission cylinder [0-1] 0 Surface only, 1 Entire Radius (1 by default)
  104086. * @param direction1 Particles are emitted between the direction1 and direction2 from within the cylinder
  104087. * @param direction2 Particles are emitted between the direction1 and direction2 from within the cylinder
  104088. * @returns the emitter
  104089. */
  104090. BaseParticleSystem.prototype.createDirectedCylinderEmitter = function (radius, height, radiusRange, direction1, direction2) {
  104091. if (radius === void 0) { radius = 1; }
  104092. if (height === void 0) { height = 1; }
  104093. if (radiusRange === void 0) { radiusRange = 1; }
  104094. if (direction1 === void 0) { direction1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104095. if (direction2 === void 0) { direction2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 1.0, 0); }
  104096. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["CylinderDirectedParticleEmitter"](radius, height, radiusRange, direction1, direction2);
  104097. this.particleEmitterType = particleEmitter;
  104098. return particleEmitter;
  104099. };
  104100. /**
  104101. * Creates a Cone Emitter for the particle system (emits from the cone to the particle position)
  104102. * @param radius The radius of the cone to emit from
  104103. * @param angle The base angle of the cone
  104104. * @returns the emitter
  104105. */
  104106. BaseParticleSystem.prototype.createConeEmitter = function (radius, angle) {
  104107. if (radius === void 0) { radius = 1; }
  104108. if (angle === void 0) { angle = Math.PI / 4; }
  104109. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["ConeParticleEmitter"](radius, angle);
  104110. this.particleEmitterType = particleEmitter;
  104111. return particleEmitter;
  104112. };
  104113. /**
  104114. * Creates a Box Emitter for the particle system. (emits between direction1 and direction2 from withing the box defined by minEmitBox and maxEmitBox)
  104115. * @param direction1 Particles are emitted between the direction1 and direction2 from within the box
  104116. * @param direction2 Particles are emitted between the direction1 and direction2 from within the box
  104117. * @param minEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  104118. * @param maxEmitBox Particles are emitted from the box between minEmitBox and maxEmitBox
  104119. * @returns the emitter
  104120. */
  104121. BaseParticleSystem.prototype.createBoxEmitter = function (direction1, direction2, minEmitBox, maxEmitBox) {
  104122. var particleEmitter = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_2__["BoxParticleEmitter"]();
  104123. this.particleEmitterType = particleEmitter;
  104124. this.direction1 = direction1;
  104125. this.direction2 = direction2;
  104126. this.minEmitBox = minEmitBox;
  104127. this.maxEmitBox = maxEmitBox;
  104128. return particleEmitter;
  104129. };
  104130. /**
  104131. * Source color is added to the destination color without alpha affecting the result
  104132. */
  104133. BaseParticleSystem.BLENDMODE_ONEONE = 0;
  104134. /**
  104135. * Blend current color and particle color using particle’s alpha
  104136. */
  104137. BaseParticleSystem.BLENDMODE_STANDARD = 1;
  104138. /**
  104139. * Add current color and particle color multiplied by particle’s alpha
  104140. */
  104141. BaseParticleSystem.BLENDMODE_ADD = 2;
  104142. /**
  104143. * Multiply current color with particle color
  104144. */
  104145. BaseParticleSystem.BLENDMODE_MULTIPLY = 3;
  104146. /**
  104147. * Multiply current color with particle color then add current color and particle color multiplied by particle’s alpha
  104148. */
  104149. BaseParticleSystem.BLENDMODE_MULTIPLYADD = 4;
  104150. return BaseParticleSystem;
  104151. }());
  104152. /***/ }),
  104153. /***/ "./Particles/gpuParticleSystem.ts":
  104154. /*!****************************************!*\
  104155. !*** ./Particles/gpuParticleSystem.ts ***!
  104156. \****************************************/
  104157. /*! exports provided: GPUParticleSystem */
  104158. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  104159. "use strict";
  104160. __webpack_require__.r(__webpack_exports__);
  104161. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return GPUParticleSystem; });
  104162. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  104163. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  104164. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  104165. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  104166. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  104167. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  104168. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  104169. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  104170. /* harmony import */ var _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Particles/EmitterTypes/boxParticleEmitter */ "./Particles/EmitterTypes/boxParticleEmitter.ts");
  104171. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  104172. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  104173. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  104174. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  104175. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  104176. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  104177. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  104178. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  104179. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  104180. /* harmony import */ var _Shaders_gpuUpdateParticles_fragment__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.fragment */ "./Shaders/gpuUpdateParticles.fragment.ts");
  104181. /* harmony import */ var _Shaders_gpuUpdateParticles_vertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Shaders/gpuUpdateParticles.vertex */ "./Shaders/gpuUpdateParticles.vertex.ts");
  104182. /* harmony import */ var _Shaders_gpuRenderParticles_fragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.fragment */ "./Shaders/gpuRenderParticles.fragment.ts");
  104183. /* harmony import */ var _Shaders_gpuRenderParticles_vertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Shaders/gpuRenderParticles.vertex */ "./Shaders/gpuRenderParticles.vertex.ts");
  104184. /**
  104185. * This represents a GPU particle system in Babylon
  104186. * This is the fastest particle system in Babylon as it uses the GPU to update the individual particle data
  104187. * @see https://www.babylonjs-playground.com/#PU4WYI#4
  104188. */
  104189. var GPUParticleSystem = /** @class */ (function (_super) {
  104190. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GPUParticleSystem, _super);
  104191. /**
  104192. * Instantiates a GPU particle system.
  104193. * 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.
  104194. * @param name The name of the particle system
  104195. * @param options The options used to create the system
  104196. * @param scene The scene the particle system belongs to
  104197. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  104198. */
  104199. function GPUParticleSystem(name, options, scene, isAnimationSheetEnabled) {
  104200. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  104201. var _this = _super.call(this, name) || this;
  104202. /**
  104203. * The layer mask we are rendering the particles through.
  104204. */
  104205. _this.layerMask = 0x0FFFFFFF;
  104206. _this._accumulatedCount = 0;
  104207. _this._targetIndex = 0;
  104208. _this._currentRenderId = -1;
  104209. _this._started = false;
  104210. _this._stopped = false;
  104211. _this._timeDelta = 0;
  104212. _this._actualFrame = 0;
  104213. _this._rawTextureWidth = 256;
  104214. /**
  104215. * An event triggered when the system is disposed.
  104216. */
  104217. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  104218. /**
  104219. * Forces the particle to write their depth information to the depth buffer. This can help preventing other draw calls
  104220. * to override the particles.
  104221. */
  104222. _this.forceDepthWrite = false;
  104223. _this._preWarmDone = false;
  104224. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene;
  104225. // Setup the default processing configuration to the scene.
  104226. _this._attachImageProcessingConfiguration(null);
  104227. _this._engine = _this._scene.getEngine();
  104228. if (!options.randomTextureSize) {
  104229. delete options.randomTextureSize;
  104230. }
  104231. var fullOptions = tslib__WEBPACK_IMPORTED_MODULE_0__["__assign"]({ capacity: 50000, randomTextureSize: _this._engine.getCaps().maxTextureSize }, options);
  104232. var optionsAsNumber = options;
  104233. if (isFinite(optionsAsNumber)) {
  104234. fullOptions.capacity = optionsAsNumber;
  104235. }
  104236. _this._capacity = fullOptions.capacity;
  104237. _this._activeCount = fullOptions.capacity;
  104238. _this._currentActiveCount = 0;
  104239. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  104240. _this._scene.particleSystems.push(_this);
  104241. _this._updateEffectOptions = {
  104242. attributes: ["position", "age", "life", "seed", "size", "color", "direction", "initialDirection", "angle", "cellIndex", "cellStartOffset", "noiseCoordinates1", "noiseCoordinates2"],
  104243. uniformsNames: ["currentCount", "timeDelta", "emitterWM", "lifeTime", "color1", "color2", "sizeRange", "scaleRange", "gravity", "emitPower",
  104244. "direction1", "direction2", "minEmitBox", "maxEmitBox", "radius", "directionRandomizer", "height", "coneAngle", "stopFactor",
  104245. "angleRange", "radiusRange", "cellInfos", "noiseStrength", "limitVelocityDamping"],
  104246. uniformBuffersNames: [],
  104247. samplers: ["randomSampler", "randomSampler2", "sizeGradientSampler", "angularSpeedGradientSampler", "velocityGradientSampler", "limitVelocityGradientSampler", "noiseSampler", "dragGradientSampler"],
  104248. defines: "",
  104249. fallbacks: null,
  104250. onCompiled: null,
  104251. onError: null,
  104252. indexParameters: null,
  104253. maxSimultaneousLights: 0,
  104254. transformFeedbackVaryings: []
  104255. };
  104256. _this.particleEmitterType = new _Particles_EmitterTypes_boxParticleEmitter__WEBPACK_IMPORTED_MODULE_8__["BoxParticleEmitter"]();
  104257. // Random data
  104258. var maxTextureSize = Math.min(_this._engine.getCaps().maxTextureSize, fullOptions.randomTextureSize);
  104259. var d = [];
  104260. for (var i = 0; i < maxTextureSize; ++i) {
  104261. d.push(Math.random());
  104262. d.push(Math.random());
  104263. d.push(Math.random());
  104264. d.push(Math.random());
  104265. }
  104266. _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);
  104267. _this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  104268. _this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  104269. d = [];
  104270. for (var i = 0; i < maxTextureSize; ++i) {
  104271. d.push(Math.random());
  104272. d.push(Math.random());
  104273. d.push(Math.random());
  104274. d.push(Math.random());
  104275. }
  104276. _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);
  104277. _this._randomTexture2.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  104278. _this._randomTexture2.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"].WRAP_ADDRESSMODE;
  104279. _this._randomTextureSize = maxTextureSize;
  104280. return _this;
  104281. }
  104282. Object.defineProperty(GPUParticleSystem, "IsSupported", {
  104283. /**
  104284. * Gets a boolean indicating if the GPU particles can be rendered on current browser
  104285. */
  104286. get: function () {
  104287. if (!_Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine) {
  104288. return false;
  104289. }
  104290. return _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedEngine.webGLVersion > 1;
  104291. },
  104292. enumerable: true,
  104293. configurable: true
  104294. });
  104295. /**
  104296. * Gets the maximum number of particles active at the same time.
  104297. * @returns The max number of active particles.
  104298. */
  104299. GPUParticleSystem.prototype.getCapacity = function () {
  104300. return this._capacity;
  104301. };
  104302. Object.defineProperty(GPUParticleSystem.prototype, "activeParticleCount", {
  104303. /**
  104304. * Gets or set the number of active particles
  104305. */
  104306. get: function () {
  104307. return this._activeCount;
  104308. },
  104309. set: function (value) {
  104310. this._activeCount = Math.min(value, this._capacity);
  104311. },
  104312. enumerable: true,
  104313. configurable: true
  104314. });
  104315. /**
  104316. * Is this system ready to be used/rendered
  104317. * @return true if the system is ready
  104318. */
  104319. GPUParticleSystem.prototype.isReady = function () {
  104320. if (!this._updateEffect) {
  104321. this._recreateUpdateEffect();
  104322. this._recreateRenderEffect();
  104323. return false;
  104324. }
  104325. if (!this.emitter || !this._updateEffect.isReady() || !this._imageProcessingConfiguration.isReady() || !this._renderEffect.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  104326. return false;
  104327. }
  104328. return true;
  104329. };
  104330. /**
  104331. * Gets if the system has been started. (Note: this will still be true after stop is called)
  104332. * @returns True if it has been started, otherwise false.
  104333. */
  104334. GPUParticleSystem.prototype.isStarted = function () {
  104335. return this._started;
  104336. };
  104337. /**
  104338. * Starts the particle system and begins to emit
  104339. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  104340. */
  104341. GPUParticleSystem.prototype.start = function (delay) {
  104342. var _this = this;
  104343. if (delay === void 0) { delay = this.startDelay; }
  104344. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  104345. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  104346. }
  104347. if (delay) {
  104348. setTimeout(function () {
  104349. _this.start(0);
  104350. }, delay);
  104351. return;
  104352. }
  104353. this._started = true;
  104354. this._stopped = false;
  104355. this._preWarmDone = false;
  104356. // Animations
  104357. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  104358. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  104359. }
  104360. };
  104361. /**
  104362. * Stops the particle system.
  104363. */
  104364. GPUParticleSystem.prototype.stop = function () {
  104365. this._stopped = true;
  104366. };
  104367. /**
  104368. * Remove all active particles
  104369. */
  104370. GPUParticleSystem.prototype.reset = function () {
  104371. this._releaseBuffers();
  104372. this._releaseVAOs();
  104373. this._currentActiveCount = 0;
  104374. this._targetIndex = 0;
  104375. };
  104376. /**
  104377. * Returns the string "GPUParticleSystem"
  104378. * @returns a string containing the class name
  104379. */
  104380. GPUParticleSystem.prototype.getClassName = function () {
  104381. return "GPUParticleSystem";
  104382. };
  104383. GPUParticleSystem.prototype._removeGradientAndTexture = function (gradient, gradients, texture) {
  104384. _super.prototype._removeGradientAndTexture.call(this, gradient, gradients, texture);
  104385. this._releaseBuffers();
  104386. return this;
  104387. };
  104388. /**
  104389. * Adds a new color gradient
  104390. * @param gradient defines the gradient to use (between 0 and 1)
  104391. * @param color1 defines the color to affect to the specified gradient
  104392. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  104393. * @returns the current particle system
  104394. */
  104395. GPUParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  104396. if (!this._colorGradients) {
  104397. this._colorGradients = [];
  104398. }
  104399. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  104400. colorGradient.gradient = gradient;
  104401. colorGradient.color1 = color1;
  104402. this._colorGradients.push(colorGradient);
  104403. this._colorGradients.sort(function (a, b) {
  104404. if (a.gradient < b.gradient) {
  104405. return -1;
  104406. }
  104407. else if (a.gradient > b.gradient) {
  104408. return 1;
  104409. }
  104410. return 0;
  104411. });
  104412. if (this._colorGradientsTexture) {
  104413. this._colorGradientsTexture.dispose();
  104414. this._colorGradientsTexture = null;
  104415. }
  104416. this._releaseBuffers();
  104417. return this;
  104418. };
  104419. /**
  104420. * Remove a specific color gradient
  104421. * @param gradient defines the gradient to remove
  104422. * @returns the current particle system
  104423. */
  104424. GPUParticleSystem.prototype.removeColorGradient = function (gradient) {
  104425. this._removeGradientAndTexture(gradient, this._colorGradients, this._colorGradientsTexture);
  104426. this._colorGradientsTexture = null;
  104427. return this;
  104428. };
  104429. GPUParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor) {
  104430. var valueGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  104431. valueGradient.gradient = gradient;
  104432. valueGradient.factor1 = factor;
  104433. factorGradients.push(valueGradient);
  104434. factorGradients.sort(function (a, b) {
  104435. if (a.gradient < b.gradient) {
  104436. return -1;
  104437. }
  104438. else if (a.gradient > b.gradient) {
  104439. return 1;
  104440. }
  104441. return 0;
  104442. });
  104443. this._releaseBuffers();
  104444. };
  104445. /**
  104446. * Adds a new size gradient
  104447. * @param gradient defines the gradient to use (between 0 and 1)
  104448. * @param factor defines the size factor to affect to the specified gradient
  104449. * @returns the current particle system
  104450. */
  104451. GPUParticleSystem.prototype.addSizeGradient = function (gradient, factor) {
  104452. if (!this._sizeGradients) {
  104453. this._sizeGradients = [];
  104454. }
  104455. this._addFactorGradient(this._sizeGradients, gradient, factor);
  104456. if (this._sizeGradientsTexture) {
  104457. this._sizeGradientsTexture.dispose();
  104458. this._sizeGradientsTexture = null;
  104459. }
  104460. this._releaseBuffers();
  104461. return this;
  104462. };
  104463. /**
  104464. * Remove a specific size gradient
  104465. * @param gradient defines the gradient to remove
  104466. * @returns the current particle system
  104467. */
  104468. GPUParticleSystem.prototype.removeSizeGradient = function (gradient) {
  104469. this._removeGradientAndTexture(gradient, this._sizeGradients, this._sizeGradientsTexture);
  104470. this._sizeGradientsTexture = null;
  104471. return this;
  104472. };
  104473. /**
  104474. * Adds a new angular speed gradient
  104475. * @param gradient defines the gradient to use (between 0 and 1)
  104476. * @param factor defines the angular speed to affect to the specified gradient
  104477. * @returns the current particle system
  104478. */
  104479. GPUParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor) {
  104480. if (!this._angularSpeedGradients) {
  104481. this._angularSpeedGradients = [];
  104482. }
  104483. this._addFactorGradient(this._angularSpeedGradients, gradient, factor);
  104484. if (this._angularSpeedGradientsTexture) {
  104485. this._angularSpeedGradientsTexture.dispose();
  104486. this._angularSpeedGradientsTexture = null;
  104487. }
  104488. this._releaseBuffers();
  104489. return this;
  104490. };
  104491. /**
  104492. * Remove a specific angular speed gradient
  104493. * @param gradient defines the gradient to remove
  104494. * @returns the current particle system
  104495. */
  104496. GPUParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  104497. this._removeGradientAndTexture(gradient, this._angularSpeedGradients, this._angularSpeedGradientsTexture);
  104498. this._angularSpeedGradientsTexture = null;
  104499. return this;
  104500. };
  104501. /**
  104502. * Adds a new velocity gradient
  104503. * @param gradient defines the gradient to use (between 0 and 1)
  104504. * @param factor defines the velocity to affect to the specified gradient
  104505. * @returns the current particle system
  104506. */
  104507. GPUParticleSystem.prototype.addVelocityGradient = function (gradient, factor) {
  104508. if (!this._velocityGradients) {
  104509. this._velocityGradients = [];
  104510. }
  104511. this._addFactorGradient(this._velocityGradients, gradient, factor);
  104512. if (this._velocityGradientsTexture) {
  104513. this._velocityGradientsTexture.dispose();
  104514. this._velocityGradientsTexture = null;
  104515. }
  104516. this._releaseBuffers();
  104517. return this;
  104518. };
  104519. /**
  104520. * Remove a specific velocity gradient
  104521. * @param gradient defines the gradient to remove
  104522. * @returns the current particle system
  104523. */
  104524. GPUParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  104525. this._removeGradientAndTexture(gradient, this._velocityGradients, this._velocityGradientsTexture);
  104526. this._velocityGradientsTexture = null;
  104527. return this;
  104528. };
  104529. /**
  104530. * Adds a new limit velocity gradient
  104531. * @param gradient defines the gradient to use (between 0 and 1)
  104532. * @param factor defines the limit velocity value to affect to the specified gradient
  104533. * @returns the current particle system
  104534. */
  104535. GPUParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor) {
  104536. if (!this._limitVelocityGradients) {
  104537. this._limitVelocityGradients = [];
  104538. }
  104539. this._addFactorGradient(this._limitVelocityGradients, gradient, factor);
  104540. if (this._limitVelocityGradientsTexture) {
  104541. this._limitVelocityGradientsTexture.dispose();
  104542. this._limitVelocityGradientsTexture = null;
  104543. }
  104544. this._releaseBuffers();
  104545. return this;
  104546. };
  104547. /**
  104548. * Remove a specific limit velocity gradient
  104549. * @param gradient defines the gradient to remove
  104550. * @returns the current particle system
  104551. */
  104552. GPUParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  104553. this._removeGradientAndTexture(gradient, this._limitVelocityGradients, this._limitVelocityGradientsTexture);
  104554. this._limitVelocityGradientsTexture = null;
  104555. return this;
  104556. };
  104557. /**
  104558. * Adds a new drag gradient
  104559. * @param gradient defines the gradient to use (between 0 and 1)
  104560. * @param factor defines the drag value to affect to the specified gradient
  104561. * @returns the current particle system
  104562. */
  104563. GPUParticleSystem.prototype.addDragGradient = function (gradient, factor) {
  104564. if (!this._dragGradients) {
  104565. this._dragGradients = [];
  104566. }
  104567. this._addFactorGradient(this._dragGradients, gradient, factor);
  104568. if (this._dragGradientsTexture) {
  104569. this._dragGradientsTexture.dispose();
  104570. this._dragGradientsTexture = null;
  104571. }
  104572. this._releaseBuffers();
  104573. return this;
  104574. };
  104575. /**
  104576. * Remove a specific drag gradient
  104577. * @param gradient defines the gradient to remove
  104578. * @returns the current particle system
  104579. */
  104580. GPUParticleSystem.prototype.removeDragGradient = function (gradient) {
  104581. this._removeGradientAndTexture(gradient, this._dragGradients, this._dragGradientsTexture);
  104582. this._dragGradientsTexture = null;
  104583. return this;
  104584. };
  104585. /**
  104586. * Not supported by GPUParticleSystem
  104587. * @param gradient defines the gradient to use (between 0 and 1)
  104588. * @param factor defines the emit rate value to affect to the specified gradient
  104589. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104590. * @returns the current particle system
  104591. */
  104592. GPUParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  104593. // Do nothing as emit rate is not supported by GPUParticleSystem
  104594. return this;
  104595. };
  104596. /**
  104597. * Not supported by GPUParticleSystem
  104598. * @param gradient defines the gradient to remove
  104599. * @returns the current particle system
  104600. */
  104601. GPUParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  104602. // Do nothing as emit rate is not supported by GPUParticleSystem
  104603. return this;
  104604. };
  104605. /**
  104606. * Not supported by GPUParticleSystem
  104607. * @param gradient defines the gradient to use (between 0 and 1)
  104608. * @param factor defines the start size value to affect to the specified gradient
  104609. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104610. * @returns the current particle system
  104611. */
  104612. GPUParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  104613. // Do nothing as start size is not supported by GPUParticleSystem
  104614. return this;
  104615. };
  104616. /**
  104617. * Not supported by GPUParticleSystem
  104618. * @param gradient defines the gradient to remove
  104619. * @returns the current particle system
  104620. */
  104621. GPUParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  104622. // Do nothing as start size is not supported by GPUParticleSystem
  104623. return this;
  104624. };
  104625. /**
  104626. * Not supported by GPUParticleSystem
  104627. * @param gradient defines the gradient to use (between 0 and 1)
  104628. * @param min defines the color remap minimal range
  104629. * @param max defines the color remap maximal range
  104630. * @returns the current particle system
  104631. */
  104632. GPUParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  104633. // Do nothing as start size is not supported by GPUParticleSystem
  104634. return this;
  104635. };
  104636. /**
  104637. * Not supported by GPUParticleSystem
  104638. * @param gradient defines the gradient to remove
  104639. * @returns the current particle system
  104640. */
  104641. GPUParticleSystem.prototype.removeColorRemapGradient = function () {
  104642. // Do nothing as start size is not supported by GPUParticleSystem
  104643. return this;
  104644. };
  104645. /**
  104646. * Not supported by GPUParticleSystem
  104647. * @param gradient defines the gradient to use (between 0 and 1)
  104648. * @param min defines the alpha remap minimal range
  104649. * @param max defines the alpha remap maximal range
  104650. * @returns the current particle system
  104651. */
  104652. GPUParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  104653. // Do nothing as start size is not supported by GPUParticleSystem
  104654. return this;
  104655. };
  104656. /**
  104657. * Not supported by GPUParticleSystem
  104658. * @param gradient defines the gradient to remove
  104659. * @returns the current particle system
  104660. */
  104661. GPUParticleSystem.prototype.removeAlphaRemapGradient = function () {
  104662. // Do nothing as start size is not supported by GPUParticleSystem
  104663. return this;
  104664. };
  104665. /**
  104666. * Not supported by GPUParticleSystem
  104667. * @param gradient defines the gradient to use (between 0 and 1)
  104668. * @param color defines the color to affect to the specified gradient
  104669. * @returns the current particle system
  104670. */
  104671. GPUParticleSystem.prototype.addRampGradient = function (gradient, color) {
  104672. //Not supported by GPUParticleSystem
  104673. return this;
  104674. };
  104675. /**
  104676. * Not supported by GPUParticleSystem
  104677. * @param gradient defines the gradient to remove
  104678. * @returns the current particle system
  104679. */
  104680. GPUParticleSystem.prototype.removeRampGradient = function () {
  104681. //Not supported by GPUParticleSystem
  104682. return this;
  104683. };
  104684. /**
  104685. * Not supported by GPUParticleSystem
  104686. * @returns the list of ramp gradients
  104687. */
  104688. GPUParticleSystem.prototype.getRampGradients = function () {
  104689. return null;
  104690. };
  104691. Object.defineProperty(GPUParticleSystem.prototype, "useRampGradients", {
  104692. /**
  104693. * Not supported by GPUParticleSystem
  104694. * Gets or sets a boolean indicating that ramp gradients must be used
  104695. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  104696. */
  104697. get: function () {
  104698. //Not supported by GPUParticleSystem
  104699. return false;
  104700. },
  104701. set: function (value) {
  104702. //Not supported by GPUParticleSystem
  104703. },
  104704. enumerable: true,
  104705. configurable: true
  104706. });
  104707. /**
  104708. * Not supported by GPUParticleSystem
  104709. * @param gradient defines the gradient to use (between 0 and 1)
  104710. * @param factor defines the life time factor to affect to the specified gradient
  104711. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  104712. * @returns the current particle system
  104713. */
  104714. GPUParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  104715. //Not supported by GPUParticleSystem
  104716. return this;
  104717. };
  104718. /**
  104719. * Not supported by GPUParticleSystem
  104720. * @param gradient defines the gradient to remove
  104721. * @returns the current particle system
  104722. */
  104723. GPUParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  104724. //Not supported by GPUParticleSystem
  104725. return this;
  104726. };
  104727. GPUParticleSystem.prototype._reset = function () {
  104728. this._releaseBuffers();
  104729. };
  104730. GPUParticleSystem.prototype._createUpdateVAO = function (source) {
  104731. var updateVertexBuffers = {};
  104732. updateVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3);
  104733. updateVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1);
  104734. updateVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1);
  104735. updateVertexBuffers["seed"] = source.createVertexBuffer("seed", 5, 4);
  104736. updateVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3);
  104737. var offset = 12;
  104738. if (!this._colorGradientsTexture) {
  104739. updateVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4);
  104740. offset += 4;
  104741. }
  104742. updateVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3);
  104743. offset += 3;
  104744. if (!this._isBillboardBased) {
  104745. updateVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3);
  104746. offset += 3;
  104747. }
  104748. if (this._angularSpeedGradientsTexture) {
  104749. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1);
  104750. offset += 1;
  104751. }
  104752. else {
  104753. updateVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 2);
  104754. offset += 2;
  104755. }
  104756. if (this._isAnimationSheetEnabled) {
  104757. updateVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1);
  104758. offset += 1;
  104759. if (this.spriteRandomStartCell) {
  104760. updateVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1);
  104761. offset += 1;
  104762. }
  104763. }
  104764. if (this.noiseTexture) {
  104765. updateVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3);
  104766. offset += 3;
  104767. updateVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3);
  104768. offset += 3;
  104769. }
  104770. var vao = this._engine.recordVertexArrayObject(updateVertexBuffers, null, this._updateEffect);
  104771. this._engine.bindArrayBuffer(null);
  104772. return vao;
  104773. };
  104774. GPUParticleSystem.prototype._createRenderVAO = function (source, spriteSource) {
  104775. var renderVertexBuffers = {};
  104776. renderVertexBuffers["position"] = source.createVertexBuffer("position", 0, 3, this._attributesStrideSize, true);
  104777. renderVertexBuffers["age"] = source.createVertexBuffer("age", 3, 1, this._attributesStrideSize, true);
  104778. renderVertexBuffers["life"] = source.createVertexBuffer("life", 4, 1, this._attributesStrideSize, true);
  104779. renderVertexBuffers["size"] = source.createVertexBuffer("size", 9, 3, this._attributesStrideSize, true);
  104780. var offset = 12;
  104781. if (!this._colorGradientsTexture) {
  104782. renderVertexBuffers["color"] = source.createVertexBuffer("color", offset, 4, this._attributesStrideSize, true);
  104783. offset += 4;
  104784. }
  104785. if (this.billboardMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED) {
  104786. renderVertexBuffers["direction"] = source.createVertexBuffer("direction", offset, 3, this._attributesStrideSize, true);
  104787. }
  104788. offset += 3; // Direction
  104789. if (!this._isBillboardBased) {
  104790. renderVertexBuffers["initialDirection"] = source.createVertexBuffer("initialDirection", offset, 3, this._attributesStrideSize, true);
  104791. offset += 3;
  104792. }
  104793. renderVertexBuffers["angle"] = source.createVertexBuffer("angle", offset, 1, this._attributesStrideSize, true);
  104794. if (this._angularSpeedGradientsTexture) {
  104795. offset++;
  104796. }
  104797. else {
  104798. offset += 2;
  104799. }
  104800. if (this._isAnimationSheetEnabled) {
  104801. renderVertexBuffers["cellIndex"] = source.createVertexBuffer("cellIndex", offset, 1, this._attributesStrideSize, true);
  104802. offset += 1;
  104803. if (this.spriteRandomStartCell) {
  104804. renderVertexBuffers["cellStartOffset"] = source.createVertexBuffer("cellStartOffset", offset, 1, this._attributesStrideSize, true);
  104805. offset += 1;
  104806. }
  104807. }
  104808. if (this.noiseTexture) {
  104809. renderVertexBuffers["noiseCoordinates1"] = source.createVertexBuffer("noiseCoordinates1", offset, 3, this._attributesStrideSize, true);
  104810. offset += 3;
  104811. renderVertexBuffers["noiseCoordinates2"] = source.createVertexBuffer("noiseCoordinates2", offset, 3, this._attributesStrideSize, true);
  104812. offset += 3;
  104813. }
  104814. renderVertexBuffers["offset"] = spriteSource.createVertexBuffer("offset", 0, 2);
  104815. renderVertexBuffers["uv"] = spriteSource.createVertexBuffer("uv", 2, 2);
  104816. var vao = this._engine.recordVertexArrayObject(renderVertexBuffers, null, this._renderEffect);
  104817. this._engine.bindArrayBuffer(null);
  104818. return vao;
  104819. };
  104820. GPUParticleSystem.prototype._initialize = function (force) {
  104821. if (force === void 0) { force = false; }
  104822. if (this._buffer0 && !force) {
  104823. return;
  104824. }
  104825. var engine = this._scene.getEngine();
  104826. var data = new Array();
  104827. this._attributesStrideSize = 21;
  104828. this._targetIndex = 0;
  104829. if (!this.isBillboardBased) {
  104830. this._attributesStrideSize += 3;
  104831. }
  104832. if (this._colorGradientsTexture) {
  104833. this._attributesStrideSize -= 4;
  104834. }
  104835. if (this._angularSpeedGradientsTexture) {
  104836. this._attributesStrideSize -= 1;
  104837. }
  104838. if (this._isAnimationSheetEnabled) {
  104839. this._attributesStrideSize += 1;
  104840. if (this.spriteRandomStartCell) {
  104841. this._attributesStrideSize += 1;
  104842. }
  104843. }
  104844. if (this.noiseTexture) {
  104845. this._attributesStrideSize += 6;
  104846. }
  104847. for (var particleIndex = 0; particleIndex < this._capacity; particleIndex++) {
  104848. // position
  104849. data.push(0.0);
  104850. data.push(0.0);
  104851. data.push(0.0);
  104852. // Age and life
  104853. data.push(0.0); // create the particle as a dead one to create a new one at start
  104854. data.push(0.0);
  104855. // Seed
  104856. data.push(Math.random());
  104857. data.push(Math.random());
  104858. data.push(Math.random());
  104859. data.push(Math.random());
  104860. // Size
  104861. data.push(0.0);
  104862. data.push(0.0);
  104863. data.push(0.0);
  104864. if (!this._colorGradientsTexture) {
  104865. // color
  104866. data.push(0.0);
  104867. data.push(0.0);
  104868. data.push(0.0);
  104869. data.push(0.0);
  104870. }
  104871. // direction
  104872. data.push(0.0);
  104873. data.push(0.0);
  104874. data.push(0.0);
  104875. if (!this.isBillboardBased) {
  104876. // initialDirection
  104877. data.push(0.0);
  104878. data.push(0.0);
  104879. data.push(0.0);
  104880. }
  104881. // angle
  104882. data.push(0.0);
  104883. if (!this._angularSpeedGradientsTexture) {
  104884. data.push(0.0);
  104885. }
  104886. if (this._isAnimationSheetEnabled) {
  104887. data.push(0.0);
  104888. if (this.spriteRandomStartCell) {
  104889. data.push(0.0);
  104890. }
  104891. }
  104892. if (this.noiseTexture) { // Random coordinates for reading into noise texture
  104893. data.push(Math.random());
  104894. data.push(Math.random());
  104895. data.push(Math.random());
  104896. data.push(Math.random());
  104897. data.push(Math.random());
  104898. data.push(Math.random());
  104899. }
  104900. }
  104901. // Sprite data
  104902. var spriteData = new Float32Array([0.5, 0.5, 1, 1,
  104903. -0.5, 0.5, 0, 1,
  104904. -0.5, -0.5, 0, 0,
  104905. 0.5, -0.5, 1, 0]);
  104906. // Buffers
  104907. this._buffer0 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104908. this._buffer1 = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, data, false, this._attributesStrideSize);
  104909. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 4);
  104910. // Update VAO
  104911. this._updateVAO = [];
  104912. this._updateVAO.push(this._createUpdateVAO(this._buffer0));
  104913. this._updateVAO.push(this._createUpdateVAO(this._buffer1));
  104914. // Render VAO
  104915. this._renderVAO = [];
  104916. this._renderVAO.push(this._createRenderVAO(this._buffer1, this._spriteBuffer));
  104917. this._renderVAO.push(this._createRenderVAO(this._buffer0, this._spriteBuffer));
  104918. // Links
  104919. this._sourceBuffer = this._buffer0;
  104920. this._targetBuffer = this._buffer1;
  104921. };
  104922. /** @hidden */
  104923. GPUParticleSystem.prototype._recreateUpdateEffect = function () {
  104924. var defines = this.particleEmitterType ? this.particleEmitterType.getEffectDefines() : "";
  104925. if (this._isBillboardBased) {
  104926. defines += "\n#define BILLBOARD";
  104927. }
  104928. if (this._colorGradientsTexture) {
  104929. defines += "\n#define COLORGRADIENTS";
  104930. }
  104931. if (this._sizeGradientsTexture) {
  104932. defines += "\n#define SIZEGRADIENTS";
  104933. }
  104934. if (this._angularSpeedGradientsTexture) {
  104935. defines += "\n#define ANGULARSPEEDGRADIENTS";
  104936. }
  104937. if (this._velocityGradientsTexture) {
  104938. defines += "\n#define VELOCITYGRADIENTS";
  104939. }
  104940. if (this._limitVelocityGradientsTexture) {
  104941. defines += "\n#define LIMITVELOCITYGRADIENTS";
  104942. }
  104943. if (this._dragGradientsTexture) {
  104944. defines += "\n#define DRAGGRADIENTS";
  104945. }
  104946. if (this.isAnimationSheetEnabled) {
  104947. defines += "\n#define ANIMATESHEET";
  104948. if (this.spriteRandomStartCell) {
  104949. defines += "\n#define ANIMATESHEETRANDOMSTART";
  104950. }
  104951. }
  104952. if (this.noiseTexture) {
  104953. defines += "\n#define NOISE";
  104954. }
  104955. if (this._updateEffect && this._updateEffectOptions.defines === defines) {
  104956. return;
  104957. }
  104958. this._updateEffectOptions.transformFeedbackVaryings = ["outPosition", "outAge", "outLife", "outSeed", "outSize"];
  104959. if (!this._colorGradientsTexture) {
  104960. this._updateEffectOptions.transformFeedbackVaryings.push("outColor");
  104961. }
  104962. this._updateEffectOptions.transformFeedbackVaryings.push("outDirection");
  104963. if (!this._isBillboardBased) {
  104964. this._updateEffectOptions.transformFeedbackVaryings.push("outInitialDirection");
  104965. }
  104966. this._updateEffectOptions.transformFeedbackVaryings.push("outAngle");
  104967. if (this.isAnimationSheetEnabled) {
  104968. this._updateEffectOptions.transformFeedbackVaryings.push("outCellIndex");
  104969. if (this.spriteRandomStartCell) {
  104970. this._updateEffectOptions.transformFeedbackVaryings.push("outCellStartOffset");
  104971. }
  104972. }
  104973. if (this.noiseTexture) {
  104974. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates1");
  104975. this._updateEffectOptions.transformFeedbackVaryings.push("outNoiseCoordinates2");
  104976. }
  104977. this._updateEffectOptions.defines = defines;
  104978. this._updateEffect = new _Materials_effect__WEBPACK_IMPORTED_MODULE_9__["Effect"]("gpuUpdateParticles", this._updateEffectOptions, this._scene.getEngine());
  104979. };
  104980. /** @hidden */
  104981. GPUParticleSystem.prototype._recreateRenderEffect = function () {
  104982. var defines = "";
  104983. if (this._scene.clipPlane) {
  104984. defines = "\n#define CLIPPLANE";
  104985. }
  104986. if (this._scene.clipPlane2) {
  104987. defines = "\n#define CLIPPLANE2";
  104988. }
  104989. if (this._scene.clipPlane3) {
  104990. defines = "\n#define CLIPPLANE3";
  104991. }
  104992. if (this._scene.clipPlane4) {
  104993. defines = "\n#define CLIPPLANE4";
  104994. }
  104995. if (this.blendMode === _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY) {
  104996. defines = "\n#define BLENDMULTIPLYMODE";
  104997. }
  104998. if (this._isBillboardBased) {
  104999. defines += "\n#define BILLBOARD";
  105000. switch (this.billboardMode) {
  105001. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_Y:
  105002. defines += "\n#define BILLBOARDY";
  105003. break;
  105004. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_STRETCHED:
  105005. defines += "\n#define BILLBOARDSTRETCHED";
  105006. break;
  105007. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BILLBOARDMODE_ALL:
  105008. default:
  105009. break;
  105010. }
  105011. }
  105012. if (this._colorGradientsTexture) {
  105013. defines += "\n#define COLORGRADIENTS";
  105014. }
  105015. if (this.isAnimationSheetEnabled) {
  105016. defines += "\n#define ANIMATESHEET";
  105017. }
  105018. if (this._imageProcessingConfiguration) {
  105019. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  105020. defines += "\n" + this._imageProcessingConfigurationDefines.toString();
  105021. }
  105022. if (this._renderEffect && this._renderEffect.defines === defines) {
  105023. return;
  105024. }
  105025. var uniforms = ["view", "projection", "colorDead", "invView", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "sheetInfos", "translationPivot", "eyePosition"];
  105026. var samplers = ["textureSampler", "colorGradientSampler"];
  105027. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"]) {
  105028. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._imageProcessingConfigurationDefines);
  105029. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_12__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  105030. }
  105031. 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);
  105032. };
  105033. /**
  105034. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  105035. * @param preWarm defines if we are in the pre-warmimg phase
  105036. */
  105037. GPUParticleSystem.prototype.animate = function (preWarm) {
  105038. if (preWarm === void 0) { preWarm = false; }
  105039. this._timeDelta = this.updateSpeed * (preWarm ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  105040. this._actualFrame += this._timeDelta;
  105041. if (!this._stopped) {
  105042. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  105043. this.stop();
  105044. }
  105045. }
  105046. };
  105047. GPUParticleSystem.prototype._createFactorGradientTexture = function (factorGradients, textureName) {
  105048. var texture = this[textureName];
  105049. if (!factorGradients || !factorGradients.length || texture) {
  105050. return;
  105051. }
  105052. var data = new Float32Array(this._rawTextureWidth);
  105053. for (var x = 0; x < this._rawTextureWidth; x++) {
  105054. var ratio = x / this._rawTextureWidth;
  105055. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, factorGradients, function (currentGradient, nextGradient, scale) {
  105056. data[x] = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  105057. });
  105058. }
  105059. 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);
  105060. };
  105061. GPUParticleSystem.prototype._createSizeGradientTexture = function () {
  105062. this._createFactorGradientTexture(this._sizeGradients, "_sizeGradientsTexture");
  105063. };
  105064. GPUParticleSystem.prototype._createAngularSpeedGradientTexture = function () {
  105065. this._createFactorGradientTexture(this._angularSpeedGradients, "_angularSpeedGradientsTexture");
  105066. };
  105067. GPUParticleSystem.prototype._createVelocityGradientTexture = function () {
  105068. this._createFactorGradientTexture(this._velocityGradients, "_velocityGradientsTexture");
  105069. };
  105070. GPUParticleSystem.prototype._createLimitVelocityGradientTexture = function () {
  105071. this._createFactorGradientTexture(this._limitVelocityGradients, "_limitVelocityGradientsTexture");
  105072. };
  105073. GPUParticleSystem.prototype._createDragGradientTexture = function () {
  105074. this._createFactorGradientTexture(this._dragGradients, "_dragGradientsTexture");
  105075. };
  105076. GPUParticleSystem.prototype._createColorGradientTexture = function () {
  105077. if (!this._colorGradients || !this._colorGradients.length || this._colorGradientsTexture) {
  105078. return;
  105079. }
  105080. var data = new Uint8Array(this._rawTextureWidth * 4);
  105081. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color4[0];
  105082. for (var x = 0; x < this._rawTextureWidth; x++) {
  105083. var ratio = x / this._rawTextureWidth;
  105084. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._colorGradients, function (currentGradient, nextGradient, scale) {
  105085. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(currentGradient.color1, nextGradient.color1, scale, tmpColor);
  105086. data[x * 4] = tmpColor.r * 255;
  105087. data[x * 4 + 1] = tmpColor.g * 255;
  105088. data[x * 4 + 2] = tmpColor.b * 255;
  105089. data[x * 4 + 3] = tmpColor.a * 255;
  105090. });
  105091. }
  105092. 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);
  105093. };
  105094. /**
  105095. * Renders the particle system in its current state
  105096. * @param preWarm defines if the system should only update the particles but not render them
  105097. * @returns the current number of particles
  105098. */
  105099. GPUParticleSystem.prototype.render = function (preWarm) {
  105100. if (preWarm === void 0) { preWarm = false; }
  105101. if (!this._started) {
  105102. return 0;
  105103. }
  105104. this._createColorGradientTexture();
  105105. this._createSizeGradientTexture();
  105106. this._createAngularSpeedGradientTexture();
  105107. this._createVelocityGradientTexture();
  105108. this._createLimitVelocityGradientTexture();
  105109. this._createDragGradientTexture();
  105110. this._recreateUpdateEffect();
  105111. this._recreateRenderEffect();
  105112. if (!this.isReady()) {
  105113. return 0;
  105114. }
  105115. if (!preWarm) {
  105116. if (!this._preWarmDone && this.preWarmCycles) {
  105117. for (var index = 0; index < this.preWarmCycles; index++) {
  105118. this.animate(true);
  105119. this.render(true);
  105120. }
  105121. this._preWarmDone = true;
  105122. }
  105123. if (this._currentRenderId === this._scene.getFrameId()) {
  105124. return 0;
  105125. }
  105126. this._currentRenderId = this._scene.getFrameId();
  105127. }
  105128. // Get everything ready to render
  105129. this._initialize();
  105130. this._accumulatedCount += this.emitRate * this._timeDelta;
  105131. if (this._accumulatedCount > 1) {
  105132. var intPart = this._accumulatedCount | 0;
  105133. this._accumulatedCount -= intPart;
  105134. this._currentActiveCount = Math.min(this._activeCount, this._currentActiveCount + intPart);
  105135. }
  105136. if (!this._currentActiveCount) {
  105137. return 0;
  105138. }
  105139. // Enable update effect
  105140. this._engine.enableEffect(this._updateEffect);
  105141. this._engine.setState(false);
  105142. this._updateEffect.setFloat("currentCount", this._currentActiveCount);
  105143. this._updateEffect.setFloat("timeDelta", this._timeDelta);
  105144. this._updateEffect.setFloat("stopFactor", this._stopped ? 0 : 1);
  105145. this._updateEffect.setTexture("randomSampler", this._randomTexture);
  105146. this._updateEffect.setTexture("randomSampler2", this._randomTexture2);
  105147. this._updateEffect.setFloat2("lifeTime", this.minLifeTime, this.maxLifeTime);
  105148. this._updateEffect.setFloat2("emitPower", this.minEmitPower, this.maxEmitPower);
  105149. if (!this._colorGradientsTexture) {
  105150. this._updateEffect.setDirectColor4("color1", this.color1);
  105151. this._updateEffect.setDirectColor4("color2", this.color2);
  105152. }
  105153. this._updateEffect.setFloat2("sizeRange", this.minSize, this.maxSize);
  105154. this._updateEffect.setFloat4("scaleRange", this.minScaleX, this.maxScaleX, this.minScaleY, this.maxScaleY);
  105155. this._updateEffect.setFloat4("angleRange", this.minAngularSpeed, this.maxAngularSpeed, this.minInitialRotation, this.maxInitialRotation);
  105156. this._updateEffect.setVector3("gravity", this.gravity);
  105157. if (this._sizeGradientsTexture) {
  105158. this._updateEffect.setTexture("sizeGradientSampler", this._sizeGradientsTexture);
  105159. }
  105160. if (this._angularSpeedGradientsTexture) {
  105161. this._updateEffect.setTexture("angularSpeedGradientSampler", this._angularSpeedGradientsTexture);
  105162. }
  105163. if (this._velocityGradientsTexture) {
  105164. this._updateEffect.setTexture("velocityGradientSampler", this._velocityGradientsTexture);
  105165. }
  105166. if (this._limitVelocityGradientsTexture) {
  105167. this._updateEffect.setTexture("limitVelocityGradientSampler", this._limitVelocityGradientsTexture);
  105168. this._updateEffect.setFloat("limitVelocityDamping", this.limitVelocityDamping);
  105169. }
  105170. if (this._dragGradientsTexture) {
  105171. this._updateEffect.setTexture("dragGradientSampler", this._dragGradientsTexture);
  105172. }
  105173. if (this.particleEmitterType) {
  105174. this.particleEmitterType.applyToShader(this._updateEffect);
  105175. }
  105176. if (this._isAnimationSheetEnabled) {
  105177. this._updateEffect.setFloat3("cellInfos", this.startSpriteCellID, this.endSpriteCellID, this.spriteCellChangeSpeed);
  105178. }
  105179. if (this.noiseTexture) {
  105180. this._updateEffect.setTexture("noiseSampler", this.noiseTexture);
  105181. this._updateEffect.setVector3("noiseStrength", this.noiseStrength);
  105182. }
  105183. var emitterWM;
  105184. if (this.emitter.position) {
  105185. var emitterMesh = this.emitter;
  105186. emitterWM = emitterMesh.getWorldMatrix();
  105187. }
  105188. else {
  105189. var emitterPosition = this.emitter;
  105190. emitterWM = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  105191. }
  105192. this._updateEffect.setMatrix("emitterWM", emitterWM);
  105193. // Bind source VAO
  105194. this._engine.bindVertexArrayObject(this._updateVAO[this._targetIndex], null);
  105195. // Update
  105196. this._engine.bindTransformFeedbackBuffer(this._targetBuffer.getBuffer());
  105197. this._engine.setRasterizerState(false);
  105198. this._engine.beginTransformFeedback(true);
  105199. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].PointListDrawMode, 0, this._currentActiveCount);
  105200. this._engine.endTransformFeedback();
  105201. this._engine.setRasterizerState(true);
  105202. this._engine.bindTransformFeedbackBuffer(null);
  105203. if (!preWarm) {
  105204. // Enable render effect
  105205. this._engine.enableEffect(this._renderEffect);
  105206. var viewMatrix = this._scene.getViewMatrix();
  105207. this._renderEffect.setMatrix("view", viewMatrix);
  105208. this._renderEffect.setMatrix("projection", this._scene.getProjectionMatrix());
  105209. this._renderEffect.setTexture("textureSampler", this.particleTexture);
  105210. this._renderEffect.setVector2("translationPivot", this.translationPivot);
  105211. if (this._colorGradientsTexture) {
  105212. this._renderEffect.setTexture("colorGradientSampler", this._colorGradientsTexture);
  105213. }
  105214. else {
  105215. this._renderEffect.setDirectColor4("colorDead", this.colorDead);
  105216. }
  105217. if (this._isAnimationSheetEnabled && this.particleTexture) {
  105218. var baseSize = this.particleTexture.getBaseSize();
  105219. this._renderEffect.setFloat3("sheetInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  105220. }
  105221. if (this._isBillboardBased) {
  105222. var camera = this._scene.activeCamera;
  105223. this._renderEffect.setVector3("eyePosition", camera.globalPosition);
  105224. }
  105225. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  105226. var invView = viewMatrix.clone();
  105227. invView.invert();
  105228. this._renderEffect.setMatrix("invView", invView);
  105229. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_11__["MaterialHelper"].BindClipPlane(this._renderEffect, this._scene);
  105230. }
  105231. // image processing
  105232. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  105233. this._imageProcessingConfiguration.bind(this._renderEffect);
  105234. }
  105235. // Draw order
  105236. switch (this.blendMode) {
  105237. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ADD:
  105238. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ADD);
  105239. break;
  105240. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_ONEONE:
  105241. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_ONEONE);
  105242. break;
  105243. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_STANDARD:
  105244. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_COMBINE);
  105245. break;
  105246. case _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"].BLENDMODE_MULTIPLY:
  105247. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_MULTIPLY);
  105248. break;
  105249. }
  105250. if (this.forceDepthWrite) {
  105251. this._engine.setDepthWrite(true);
  105252. }
  105253. // Bind source VAO
  105254. this._engine.bindVertexArrayObject(this._renderVAO[this._targetIndex], null);
  105255. // Render
  105256. this._engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_10__["Material"].TriangleFanDrawMode, 0, 4, this._currentActiveCount);
  105257. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_15__["Constants"].ALPHA_DISABLE);
  105258. }
  105259. // Switch VAOs
  105260. this._targetIndex++;
  105261. if (this._targetIndex === 2) {
  105262. this._targetIndex = 0;
  105263. }
  105264. // Switch buffers
  105265. var tmpBuffer = this._sourceBuffer;
  105266. this._sourceBuffer = this._targetBuffer;
  105267. this._targetBuffer = tmpBuffer;
  105268. return this._currentActiveCount;
  105269. };
  105270. /**
  105271. * Rebuilds the particle system
  105272. */
  105273. GPUParticleSystem.prototype.rebuild = function () {
  105274. this._initialize(true);
  105275. };
  105276. GPUParticleSystem.prototype._releaseBuffers = function () {
  105277. if (this._buffer0) {
  105278. this._buffer0.dispose();
  105279. this._buffer0 = null;
  105280. }
  105281. if (this._buffer1) {
  105282. this._buffer1.dispose();
  105283. this._buffer1 = null;
  105284. }
  105285. if (this._spriteBuffer) {
  105286. this._spriteBuffer.dispose();
  105287. this._spriteBuffer = null;
  105288. }
  105289. };
  105290. GPUParticleSystem.prototype._releaseVAOs = function () {
  105291. if (!this._updateVAO) {
  105292. return;
  105293. }
  105294. for (var index = 0; index < this._updateVAO.length; index++) {
  105295. this._engine.releaseVertexArrayObject(this._updateVAO[index]);
  105296. }
  105297. this._updateVAO = [];
  105298. for (var index = 0; index < this._renderVAO.length; index++) {
  105299. this._engine.releaseVertexArrayObject(this._renderVAO[index]);
  105300. }
  105301. this._renderVAO = [];
  105302. };
  105303. /**
  105304. * Disposes the particle system and free the associated resources
  105305. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  105306. */
  105307. GPUParticleSystem.prototype.dispose = function (disposeTexture) {
  105308. if (disposeTexture === void 0) { disposeTexture = true; }
  105309. var index = this._scene.particleSystems.indexOf(this);
  105310. if (index > -1) {
  105311. this._scene.particleSystems.splice(index, 1);
  105312. }
  105313. this._releaseBuffers();
  105314. this._releaseVAOs();
  105315. if (this._colorGradientsTexture) {
  105316. this._colorGradientsTexture.dispose();
  105317. this._colorGradientsTexture = null;
  105318. }
  105319. if (this._sizeGradientsTexture) {
  105320. this._sizeGradientsTexture.dispose();
  105321. this._sizeGradientsTexture = null;
  105322. }
  105323. if (this._angularSpeedGradientsTexture) {
  105324. this._angularSpeedGradientsTexture.dispose();
  105325. this._angularSpeedGradientsTexture = null;
  105326. }
  105327. if (this._velocityGradientsTexture) {
  105328. this._velocityGradientsTexture.dispose();
  105329. this._velocityGradientsTexture = null;
  105330. }
  105331. if (this._limitVelocityGradientsTexture) {
  105332. this._limitVelocityGradientsTexture.dispose();
  105333. this._limitVelocityGradientsTexture = null;
  105334. }
  105335. if (this._dragGradientsTexture) {
  105336. this._dragGradientsTexture.dispose();
  105337. this._dragGradientsTexture = null;
  105338. }
  105339. if (this._randomTexture) {
  105340. this._randomTexture.dispose();
  105341. this._randomTexture = null;
  105342. }
  105343. if (this._randomTexture2) {
  105344. this._randomTexture2.dispose();
  105345. this._randomTexture2 = null;
  105346. }
  105347. if (disposeTexture && this.particleTexture) {
  105348. this.particleTexture.dispose();
  105349. this.particleTexture = null;
  105350. }
  105351. if (disposeTexture && this.noiseTexture) {
  105352. this.noiseTexture.dispose();
  105353. this.noiseTexture = null;
  105354. }
  105355. // Callback
  105356. this.onDisposeObservable.notifyObservers(this);
  105357. this.onDisposeObservable.clear();
  105358. };
  105359. /**
  105360. * Clones the particle system.
  105361. * @param name The name of the cloned object
  105362. * @param newEmitter The new emitter to use
  105363. * @returns the cloned particle system
  105364. */
  105365. GPUParticleSystem.prototype.clone = function (name, newEmitter) {
  105366. var result = new GPUParticleSystem(name, { capacity: this._capacity, randomTextureSize: this._randomTextureSize }, this._scene);
  105367. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_17__["DeepCopier"].DeepCopy(this, result);
  105368. if (newEmitter === undefined) {
  105369. newEmitter = this.emitter;
  105370. }
  105371. result.emitter = newEmitter;
  105372. if (this.particleTexture) {
  105373. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_13__["Texture"](this.particleTexture.url, this._scene);
  105374. }
  105375. return result;
  105376. };
  105377. /**
  105378. * Serializes the particle system to a JSON object.
  105379. * @returns the JSON object
  105380. */
  105381. GPUParticleSystem.prototype.serialize = function () {
  105382. var serializationObject = {};
  105383. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Serialize(serializationObject, this);
  105384. serializationObject.activeParticleCount = this.activeParticleCount;
  105385. return serializationObject;
  105386. };
  105387. /**
  105388. * Parses a JSON object to create a GPU particle system.
  105389. * @param parsedParticleSystem The JSON object to parse
  105390. * @param scene The scene to create the particle system in
  105391. * @param rootUrl The root url to use to load external dependencies like texture
  105392. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  105393. * @returns the parsed GPU particle system
  105394. */
  105395. GPUParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  105396. if (doNotStart === void 0) { doNotStart = false; }
  105397. var name = parsedParticleSystem.name;
  105398. var particleSystem = new GPUParticleSystem(name, { capacity: parsedParticleSystem.capacity, randomTextureSize: parsedParticleSystem.randomTextureSize }, scene);
  105399. if (parsedParticleSystem.activeParticleCount) {
  105400. particleSystem.activeParticleCount = parsedParticleSystem.activeParticleCount;
  105401. }
  105402. _particleSystem__WEBPACK_IMPORTED_MODULE_7__["ParticleSystem"]._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  105403. // Auto start
  105404. if (parsedParticleSystem.preventAutoStart) {
  105405. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  105406. }
  105407. if (!doNotStart && !particleSystem.preventAutoStart) {
  105408. particleSystem.start();
  105409. }
  105410. return particleSystem;
  105411. };
  105412. return GPUParticleSystem;
  105413. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_6__["BaseParticleSystem"]));
  105414. /***/ }),
  105415. /***/ "./Particles/index.ts":
  105416. /*!****************************!*\
  105417. !*** ./Particles/index.ts ***!
  105418. \****************************/
  105419. /*! exports provided: BaseParticleSystem, GPUParticleSystem, Particle, ParticleHelper, ParticleSystem, _IDoNeedToBeInTheBuild, ParticleSystemSet, SolidParticle, ModelShape, DepthSortedParticle, SolidParticleSystem, SubEmitterType, SubEmitter, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter */
  105420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105421. "use strict";
  105422. __webpack_require__.r(__webpack_exports__);
  105423. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _baseParticleSystem__WEBPACK_IMPORTED_MODULE_0__["BaseParticleSystem"]; });
  105425. /* harmony import */ var _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["BoxParticleEmitter"]; });
  105427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["ConeParticleEmitter"]; });
  105428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderParticleEmitter"]; });
  105429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["CylinderDirectedParticleEmitter"]; });
  105430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["HemisphericParticleEmitter"]; });
  105431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["PointParticleEmitter"]; });
  105432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereParticleEmitter"]; });
  105433. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _EmitterTypes_index__WEBPACK_IMPORTED_MODULE_1__["SphereDirectedParticleEmitter"]; });
  105434. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  105435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__["GPUParticleSystem"]; });
  105436. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _particle__WEBPACK_IMPORTED_MODULE_3__["Particle"]; });
  105438. /* harmony import */ var _particleHelper__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleHelper */ "./Particles/particleHelper.ts");
  105439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _particleHelper__WEBPACK_IMPORTED_MODULE_4__["ParticleHelper"]; });
  105440. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _particleSystem__WEBPACK_IMPORTED_MODULE_5__["ParticleSystem"]; });
  105442. /* harmony import */ var _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystemComponent */ "./Particles/particleSystemComponent.ts");
  105443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _particleSystemComponent__WEBPACK_IMPORTED_MODULE_6__["_IDoNeedToBeInTheBuild"]; });
  105444. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  105445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _particleSystemSet__WEBPACK_IMPORTED_MODULE_7__["ParticleSystemSet"]; });
  105446. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  105447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["SolidParticle"]; });
  105448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["ModelShape"]; });
  105449. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _solidParticle__WEBPACK_IMPORTED_MODULE_8__["DepthSortedParticle"]; });
  105450. /* harmony import */ var _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./solidParticleSystem */ "./Particles/solidParticleSystem.ts");
  105451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _solidParticleSystem__WEBPACK_IMPORTED_MODULE_9__["SolidParticleSystem"]; });
  105452. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105453. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitterType"]; });
  105454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _subEmitter__WEBPACK_IMPORTED_MODULE_10__["SubEmitter"]; });
  105455. /***/ }),
  105456. /***/ "./Particles/particle.ts":
  105457. /*!*******************************!*\
  105458. !*** ./Particles/particle.ts ***!
  105459. \*******************************/
  105460. /*! exports provided: Particle */
  105461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105462. "use strict";
  105463. __webpack_require__.r(__webpack_exports__);
  105464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return Particle; });
  105465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105466. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105467. /**
  105468. * A particle represents one of the element emitted by a particle system.
  105469. * This is mainly define by its coordinates, direction, velocity and age.
  105470. */
  105471. var Particle = /** @class */ (function () {
  105472. /**
  105473. * Creates a new instance Particle
  105474. * @param particleSystem the particle system the particle belongs to
  105475. */
  105476. function Particle(
  105477. /**
  105478. * The particle system the particle belongs to.
  105479. */
  105480. particleSystem) {
  105481. this.particleSystem = particleSystem;
  105482. /**
  105483. * The world position of the particle in the scene.
  105484. */
  105485. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105486. /**
  105487. * The world direction of the particle in the scene.
  105488. */
  105489. this.direction = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  105490. /**
  105491. * The color of the particle.
  105492. */
  105493. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  105494. /**
  105495. * The color change of the particle per step.
  105496. */
  105497. this.colorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  105498. /**
  105499. * Defines how long will the life of the particle be.
  105500. */
  105501. this.lifeTime = 1.0;
  105502. /**
  105503. * The current age of the particle.
  105504. */
  105505. this.age = 0;
  105506. /**
  105507. * The current size of the particle.
  105508. */
  105509. this.size = 0;
  105510. /**
  105511. * The current scale of the particle.
  105512. */
  105513. this.scale = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector2"](1, 1);
  105514. /**
  105515. * The current angle of the particle.
  105516. */
  105517. this.angle = 0;
  105518. /**
  105519. * Defines how fast is the angle changing.
  105520. */
  105521. this.angularSpeed = 0;
  105522. /**
  105523. * Defines the cell index used by the particle to be rendered from a sprite.
  105524. */
  105525. this.cellIndex = 0;
  105526. /** @hidden */
  105527. this._attachedSubEmitters = null;
  105528. /** @hidden */
  105529. this._currentColor1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  105530. /** @hidden */
  105531. this._currentColor2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  105532. /** @hidden */
  105533. this._currentSize1 = 0;
  105534. /** @hidden */
  105535. this._currentSize2 = 0;
  105536. /** @hidden */
  105537. this._currentAngularSpeed1 = 0;
  105538. /** @hidden */
  105539. this._currentAngularSpeed2 = 0;
  105540. /** @hidden */
  105541. this._currentVelocity1 = 0;
  105542. /** @hidden */
  105543. this._currentVelocity2 = 0;
  105544. /** @hidden */
  105545. this._currentLimitVelocity1 = 0;
  105546. /** @hidden */
  105547. this._currentLimitVelocity2 = 0;
  105548. /** @hidden */
  105549. this._currentDrag1 = 0;
  105550. /** @hidden */
  105551. this._currentDrag2 = 0;
  105552. this.id = Particle._Count++;
  105553. if (!this.particleSystem.isAnimationSheetEnabled) {
  105554. return;
  105555. }
  105556. this.updateCellInfoFromSystem();
  105557. }
  105558. Particle.prototype.updateCellInfoFromSystem = function () {
  105559. this.cellIndex = this.particleSystem.startSpriteCellID;
  105560. };
  105561. /**
  105562. * Defines how the sprite cell index is updated for the particle
  105563. */
  105564. Particle.prototype.updateCellIndex = function () {
  105565. var offsetAge = this.age;
  105566. var changeSpeed = this.particleSystem.spriteCellChangeSpeed;
  105567. if (this.particleSystem.spriteRandomStartCell) {
  105568. if (this._randomCellOffset === undefined) {
  105569. this._randomCellOffset = Math.random() * this.lifeTime;
  105570. }
  105571. if (changeSpeed === 0) { // Special case when speed = 0 meaning we want to stay on initial cell
  105572. changeSpeed = 1;
  105573. offsetAge = this._randomCellOffset;
  105574. }
  105575. else {
  105576. offsetAge += this._randomCellOffset;
  105577. }
  105578. }
  105579. var dist = (this._initialEndSpriteCellID - this._initialStartSpriteCellID);
  105580. var ratio = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_1__["Scalar"].Clamp(((offsetAge * changeSpeed) % this.lifeTime) / this.lifeTime);
  105581. this.cellIndex = this._initialStartSpriteCellID + (ratio * dist) | 0;
  105582. };
  105583. /** @hidden */
  105584. Particle.prototype._inheritParticleInfoToSubEmitter = function (subEmitter) {
  105585. if (subEmitter.particleSystem.emitter.position) {
  105586. var emitterMesh = subEmitter.particleSystem.emitter;
  105587. emitterMesh.position.copyFrom(this.position);
  105588. if (subEmitter.inheritDirection) {
  105589. emitterMesh.position.subtractToRef(this.direction, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  105590. // Look at using Y as forward
  105591. emitterMesh.lookAt(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0], 0, Math.PI / 2);
  105592. }
  105593. }
  105594. else {
  105595. var emitterPosition = subEmitter.particleSystem.emitter;
  105596. emitterPosition.copyFrom(this.position);
  105597. }
  105598. // Set inheritedVelocityOffset to be used when new particles are created
  105599. this.direction.scaleToRef(subEmitter.inheritedVelocityAmount / 2, _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  105600. subEmitter.particleSystem._inheritedVelocityOffset.copyFrom(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0]);
  105601. };
  105602. /** @hidden */
  105603. Particle.prototype._inheritParticleInfoToSubEmitters = function () {
  105604. var _this = this;
  105605. if (this._attachedSubEmitters && this._attachedSubEmitters.length > 0) {
  105606. this._attachedSubEmitters.forEach(function (subEmitter) {
  105607. _this._inheritParticleInfoToSubEmitter(subEmitter);
  105608. });
  105609. }
  105610. };
  105611. /** @hidden */
  105612. Particle.prototype._reset = function () {
  105613. this.age = 0;
  105614. this._currentColorGradient = null;
  105615. this._currentSizeGradient = null;
  105616. this._currentAngularSpeedGradient = null;
  105617. this._currentVelocityGradient = null;
  105618. this._currentLimitVelocityGradient = null;
  105619. this._currentDragGradient = null;
  105620. this.cellIndex = this.particleSystem.startSpriteCellID;
  105621. this._randomCellOffset = undefined;
  105622. };
  105623. /**
  105624. * Copy the properties of particle to another one.
  105625. * @param other the particle to copy the information to.
  105626. */
  105627. Particle.prototype.copyTo = function (other) {
  105628. other.position.copyFrom(this.position);
  105629. if (this._initialDirection) {
  105630. if (other._initialDirection) {
  105631. other._initialDirection.copyFrom(this._initialDirection);
  105632. }
  105633. else {
  105634. other._initialDirection = this._initialDirection.clone();
  105635. }
  105636. }
  105637. else {
  105638. other._initialDirection = null;
  105639. }
  105640. other.direction.copyFrom(this.direction);
  105641. other.color.copyFrom(this.color);
  105642. other.colorStep.copyFrom(this.colorStep);
  105643. other.lifeTime = this.lifeTime;
  105644. other.age = this.age;
  105645. other._randomCellOffset = this._randomCellOffset;
  105646. other.size = this.size;
  105647. other.scale.copyFrom(this.scale);
  105648. other.angle = this.angle;
  105649. other.angularSpeed = this.angularSpeed;
  105650. other.particleSystem = this.particleSystem;
  105651. other.cellIndex = this.cellIndex;
  105652. other.id = this.id;
  105653. other._attachedSubEmitters = this._attachedSubEmitters;
  105654. if (this._currentColorGradient) {
  105655. other._currentColorGradient = this._currentColorGradient;
  105656. other._currentColor1.copyFrom(this._currentColor1);
  105657. other._currentColor2.copyFrom(this._currentColor2);
  105658. }
  105659. if (this._currentSizeGradient) {
  105660. other._currentSizeGradient = this._currentSizeGradient;
  105661. other._currentSize1 = this._currentSize1;
  105662. other._currentSize2 = this._currentSize2;
  105663. }
  105664. if (this._currentAngularSpeedGradient) {
  105665. other._currentAngularSpeedGradient = this._currentAngularSpeedGradient;
  105666. other._currentAngularSpeed1 = this._currentAngularSpeed1;
  105667. other._currentAngularSpeed2 = this._currentAngularSpeed2;
  105668. }
  105669. if (this._currentVelocityGradient) {
  105670. other._currentVelocityGradient = this._currentVelocityGradient;
  105671. other._currentVelocity1 = this._currentVelocity1;
  105672. other._currentVelocity2 = this._currentVelocity2;
  105673. }
  105674. if (this._currentLimitVelocityGradient) {
  105675. other._currentLimitVelocityGradient = this._currentLimitVelocityGradient;
  105676. other._currentLimitVelocity1 = this._currentLimitVelocity1;
  105677. other._currentLimitVelocity2 = this._currentLimitVelocity2;
  105678. }
  105679. if (this._currentDragGradient) {
  105680. other._currentDragGradient = this._currentDragGradient;
  105681. other._currentDrag1 = this._currentDrag1;
  105682. other._currentDrag2 = this._currentDrag2;
  105683. }
  105684. if (this.particleSystem.isAnimationSheetEnabled) {
  105685. other._initialStartSpriteCellID = this._initialStartSpriteCellID;
  105686. other._initialEndSpriteCellID = this._initialEndSpriteCellID;
  105687. }
  105688. if (this.particleSystem.useRampGradients) {
  105689. other.remapData.copyFrom(this.remapData);
  105690. }
  105691. if (this._randomNoiseCoordinates1) {
  105692. if (other._randomNoiseCoordinates1) {
  105693. other._randomNoiseCoordinates1.copyFrom(this._randomNoiseCoordinates1);
  105694. other._randomNoiseCoordinates2.copyFrom(this._randomNoiseCoordinates2);
  105695. }
  105696. else {
  105697. other._randomNoiseCoordinates1 = this._randomNoiseCoordinates1.clone();
  105698. other._randomNoiseCoordinates2 = this._randomNoiseCoordinates2.clone();
  105699. }
  105700. }
  105701. };
  105702. Particle._Count = 0;
  105703. return Particle;
  105704. }());
  105705. /***/ }),
  105706. /***/ "./Particles/particleHelper.ts":
  105707. /*!*************************************!*\
  105708. !*** ./Particles/particleHelper.ts ***!
  105709. \*************************************/
  105710. /*! exports provided: ParticleHelper */
  105711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105712. "use strict";
  105713. __webpack_require__.r(__webpack_exports__);
  105714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return ParticleHelper; });
  105715. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105716. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105717. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105718. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105719. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  105720. /* harmony import */ var _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./particleSystemSet */ "./Particles/particleSystemSet.ts");
  105721. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  105722. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105723. /**
  105724. * This class is made for on one-liner static method to help creating particle system set.
  105725. */
  105726. var ParticleHelper = /** @class */ (function () {
  105727. function ParticleHelper() {
  105728. }
  105729. /**
  105730. * Create a default particle system that you can tweak
  105731. * @param emitter defines the emitter to use
  105732. * @param capacity defines the system capacity (default is 500 particles)
  105733. * @param scene defines the hosting scene
  105734. * @param useGPU defines if a GPUParticleSystem must be created (default is false)
  105735. * @returns the new Particle system
  105736. */
  105737. ParticleHelper.CreateDefault = function (emitter, capacity, scene, useGPU) {
  105738. if (capacity === void 0) { capacity = 500; }
  105739. if (useGPU === void 0) { useGPU = false; }
  105740. var system;
  105741. if (useGPU) {
  105742. system = new _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"]("default system", { capacity: capacity }, scene);
  105743. }
  105744. else {
  105745. system = new _particleSystem__WEBPACK_IMPORTED_MODULE_6__["ParticleSystem"]("default system", capacity, scene);
  105746. }
  105747. system.emitter = emitter;
  105748. system.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"]("https://www.babylonjs.com/assets/Flare.png", system.getScene());
  105749. system.createConeEmitter(0.1, Math.PI / 4);
  105750. // Particle color
  105751. system.color1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105752. system.color2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 1.0);
  105753. system.colorDead = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Color4"](1.0, 1.0, 1.0, 0.0);
  105754. // Particle Size
  105755. system.minSize = 0.1;
  105756. system.maxSize = 0.1;
  105757. // Emission speed
  105758. system.minEmitPower = 2;
  105759. system.maxEmitPower = 2;
  105760. // Update speed
  105761. system.updateSpeed = 1 / 60;
  105762. system.emitRate = 30;
  105763. return system;
  105764. };
  105765. /**
  105766. * This is the main static method (one-liner) of this helper to create different particle systems
  105767. * @param type This string represents the type to the particle system to create
  105768. * @param scene The scene where the particle system should live
  105769. * @param gpu If the system will use gpu
  105770. * @returns the ParticleSystemSet created
  105771. */
  105772. ParticleHelper.CreateAsync = function (type, scene, gpu) {
  105773. if (gpu === void 0) { gpu = false; }
  105774. if (!scene) {
  105775. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  105776. }
  105777. var token = {};
  105778. scene._addPendingData(token);
  105779. return new Promise(function (resolve, reject) {
  105780. if (gpu && !_gpuParticleSystem__WEBPACK_IMPORTED_MODULE_4__["GPUParticleSystem"].IsSupported) {
  105781. scene._removePendingData(token);
  105782. return reject("Particle system with GPU is not supported.");
  105783. }
  105784. _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].LoadFile(ParticleHelper.BaseAssetsUrl + "/systems/" + type + ".json", function (data) {
  105785. scene._removePendingData(token);
  105786. var newData = JSON.parse(data.toString());
  105787. return resolve(_particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"].Parse(newData, scene, gpu));
  105788. }, undefined, undefined, undefined, function () {
  105789. scene._removePendingData(token);
  105790. return reject("An error occured while the creation of your particle system. Check if your type '" + type + "' exists.");
  105791. });
  105792. });
  105793. };
  105794. /**
  105795. * Static function used to export a particle system to a ParticleSystemSet variable.
  105796. * Please note that the emitter shape is not exported
  105797. * @param systems defines the particle systems to export
  105798. * @returns the created particle system set
  105799. */
  105800. ParticleHelper.ExportSet = function (systems) {
  105801. var set = new _particleSystemSet__WEBPACK_IMPORTED_MODULE_5__["ParticleSystemSet"]();
  105802. for (var _i = 0, systems_1 = systems; _i < systems_1.length; _i++) {
  105803. var system = systems_1[_i];
  105804. set.systems.push(system);
  105805. }
  105806. return set;
  105807. };
  105808. /**
  105809. * Gets or sets base Assets URL
  105810. */
  105811. ParticleHelper.BaseAssetsUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_7__["Constants"].PARTICLES_BaseAssetsUrl;
  105812. return ParticleHelper;
  105813. }());
  105814. /***/ }),
  105815. /***/ "./Particles/particleSystem.ts":
  105816. /*!*************************************!*\
  105817. !*** ./Particles/particleSystem.ts ***!
  105818. \*************************************/
  105819. /*! exports provided: ParticleSystem */
  105820. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  105821. "use strict";
  105822. __webpack_require__.r(__webpack_exports__);
  105823. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return ParticleSystem; });
  105824. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  105825. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  105826. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  105827. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  105828. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math.scalar */ "./Maths/math.scalar.ts");
  105829. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  105830. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  105831. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  105832. /* harmony import */ var _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/materialHelper */ "./Materials/materialHelper.ts");
  105833. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  105834. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  105835. /* harmony import */ var _Materials_Textures_rawTexture__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Materials/Textures/rawTexture */ "./Materials/Textures/rawTexture.ts");
  105836. /* harmony import */ var _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Materials/Textures/Procedurals/proceduralTexture */ "./Materials/Textures/Procedurals/proceduralTexture.ts");
  105837. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  105838. /* harmony import */ var _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Particles/EmitterTypes/index */ "./Particles/EmitterTypes/index.ts");
  105839. /* harmony import */ var _baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./baseParticleSystem */ "./Particles/baseParticleSystem.ts");
  105840. /* harmony import */ var _particle__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./particle */ "./Particles/particle.ts");
  105841. /* harmony import */ var _subEmitter__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./subEmitter */ "./Particles/subEmitter.ts");
  105842. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  105843. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  105844. /* harmony import */ var _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../Misc/deepCopier */ "./Misc/deepCopier.ts");
  105845. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../Misc/typeStore */ "./Misc/typeStore.ts");
  105846. /* harmony import */ var _Shaders_particles_fragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../Shaders/particles.fragment */ "./Shaders/particles.fragment.ts");
  105847. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  105848. /**
  105849. * This represents a particle system in Babylon.
  105850. * 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.
  105851. * Particles can take different shapes while emitted like box, sphere, cone or you can write your custom function.
  105852. * @example https://doc.babylonjs.com/babylon101/particles
  105853. */
  105854. var ParticleSystem = /** @class */ (function (_super) {
  105855. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ParticleSystem, _super);
  105856. /**
  105857. * Instantiates a particle system.
  105858. * 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.
  105859. * @param name The name of the particle system
  105860. * @param capacity The max number of particles alive at the same time
  105861. * @param scene The scene the particle system belongs to
  105862. * @param customEffect a custom effect used to change the way particles are rendered by default
  105863. * @param isAnimationSheetEnabled Must be true if using a spritesheet to animate the particles texture
  105864. * @param epsilon Offset used to render the particles
  105865. */
  105866. function ParticleSystem(name, capacity, scene, customEffect, isAnimationSheetEnabled, epsilon) {
  105867. if (customEffect === void 0) { customEffect = null; }
  105868. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  105869. if (epsilon === void 0) { epsilon = 0.01; }
  105870. var _this = _super.call(this, name) || this;
  105871. /**
  105872. * @hidden
  105873. */
  105874. _this._inheritedVelocityOffset = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"]();
  105875. /**
  105876. * An event triggered when the system is disposed
  105877. */
  105878. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  105879. _this._particles = new Array();
  105880. _this._stockParticles = new Array();
  105881. _this._newPartsExcess = 0;
  105882. _this._vertexBuffers = {};
  105883. _this._scaledColorStep = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105884. _this._colorDiff = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0, 0, 0, 0);
  105885. _this._scaledDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105886. _this._scaledGravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  105887. _this._currentRenderId = -1;
  105888. _this._useInstancing = false;
  105889. _this._started = false;
  105890. _this._stopped = false;
  105891. _this._actualFrame = 0;
  105892. /** @hidden */
  105893. _this._currentEmitRate1 = 0;
  105894. /** @hidden */
  105895. _this._currentEmitRate2 = 0;
  105896. /** @hidden */
  105897. _this._currentStartSize1 = 0;
  105898. /** @hidden */
  105899. _this._currentStartSize2 = 0;
  105900. _this._rawTextureWidth = 256;
  105901. _this._useRampGradients = false;
  105902. /**
  105903. * @hidden
  105904. * If the particle systems emitter should be disposed when the particle system is disposed
  105905. */
  105906. _this._disposeEmitterOnDispose = false;
  105907. // start of sub system methods
  105908. /**
  105909. * "Recycles" one of the particle by copying it back to the "stock" of particles and removing it from the active list.
  105910. * Its lifetime will start back at 0.
  105911. */
  105912. _this.recycleParticle = function (particle) {
  105913. // move particle from activeParticle list to stock particles
  105914. var lastParticle = _this._particles.pop();
  105915. if (lastParticle !== particle) {
  105916. lastParticle.copyTo(particle);
  105917. }
  105918. _this._stockParticles.push(lastParticle);
  105919. };
  105920. _this._createParticle = function () {
  105921. var particle;
  105922. if (_this._stockParticles.length !== 0) {
  105923. particle = _this._stockParticles.pop();
  105924. particle._reset();
  105925. }
  105926. else {
  105927. particle = new _particle__WEBPACK_IMPORTED_MODULE_16__["Particle"](_this);
  105928. }
  105929. // Attach emitters
  105930. if (_this._subEmitters && _this._subEmitters.length > 0) {
  105931. var subEmitters = _this._subEmitters[Math.floor(Math.random() * _this._subEmitters.length)];
  105932. particle._attachedSubEmitters = [];
  105933. subEmitters.forEach(function (subEmitter) {
  105934. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].ATTACHED) {
  105935. var newEmitter = subEmitter.clone();
  105936. particle._attachedSubEmitters.push(newEmitter);
  105937. newEmitter.particleSystem.start();
  105938. }
  105939. });
  105940. }
  105941. return particle;
  105942. };
  105943. _this._emitFromParticle = function (particle) {
  105944. if (!_this._subEmitters || _this._subEmitters.length === 0) {
  105945. return;
  105946. }
  105947. var templateIndex = Math.floor(Math.random() * _this._subEmitters.length);
  105948. _this._subEmitters[templateIndex].forEach(function (subEmitter) {
  105949. if (subEmitter.type === _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitterType"].END) {
  105950. var subSystem = subEmitter.clone();
  105951. particle._inheritParticleInfoToSubEmitter(subSystem);
  105952. subSystem.particleSystem._rootParticleSystem = _this;
  105953. _this.activeSubSystems.push(subSystem.particleSystem);
  105954. subSystem.particleSystem.start();
  105955. }
  105956. });
  105957. };
  105958. _this._capacity = capacity;
  105959. _this._epsilon = epsilon;
  105960. _this._isAnimationSheetEnabled = isAnimationSheetEnabled;
  105961. _this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_13__["EngineStore"].LastCreatedScene;
  105962. // Setup the default processing configuration to the scene.
  105963. _this._attachImageProcessingConfiguration(null);
  105964. _this._customEffect = customEffect;
  105965. _this._scene.particleSystems.push(_this);
  105966. _this._useInstancing = _this._scene.getEngine().getCaps().instancedArrays;
  105967. _this._createIndexBuffer();
  105968. _this._createVertexBuffers();
  105969. // Default emitter type
  105970. _this.particleEmitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  105971. // Update
  105972. _this.updateFunction = function (particles) {
  105973. var noiseTextureSize = null;
  105974. var noiseTextureData = null;
  105975. if (_this.noiseTexture) { // We need to get texture data back to CPU
  105976. noiseTextureSize = _this.noiseTexture.getSize();
  105977. noiseTextureData = (_this.noiseTexture.getContent());
  105978. }
  105979. var _loop_1 = function () {
  105980. particle = particles[index];
  105981. var scaledUpdateSpeed = _this._scaledUpdateSpeed;
  105982. var previousAge = particle.age;
  105983. particle.age += scaledUpdateSpeed;
  105984. // Evaluate step to death
  105985. if (particle.age > particle.lifeTime) {
  105986. var diff = particle.age - previousAge;
  105987. var oldDiff = particle.lifeTime - previousAge;
  105988. scaledUpdateSpeed = (oldDiff * scaledUpdateSpeed) / diff;
  105989. particle.age = particle.lifeTime;
  105990. }
  105991. var ratio = particle.age / particle.lifeTime;
  105992. // Color
  105993. if (_this._colorGradients && _this._colorGradients.length > 0) {
  105994. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorGradients, function (currentGradient, nextGradient, scale) {
  105995. if (currentGradient !== particle._currentColorGradient) {
  105996. particle._currentColor1.copyFrom(particle._currentColor2);
  105997. nextGradient.getColorToRef(particle._currentColor2);
  105998. particle._currentColorGradient = currentGradient;
  105999. }
  106000. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(particle._currentColor1, particle._currentColor2, scale, particle.color);
  106001. });
  106002. }
  106003. else {
  106004. particle.colorStep.scaleToRef(scaledUpdateSpeed, _this._scaledColorStep);
  106005. particle.color.addInPlace(_this._scaledColorStep);
  106006. if (particle.color.a < 0) {
  106007. particle.color.a = 0;
  106008. }
  106009. }
  106010. // Angular speed
  106011. if (_this._angularSpeedGradients && _this._angularSpeedGradients.length > 0) {
  106012. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._angularSpeedGradients, function (currentGradient, nextGradient, scale) {
  106013. if (currentGradient !== particle._currentAngularSpeedGradient) {
  106014. particle._currentAngularSpeed1 = particle._currentAngularSpeed2;
  106015. particle._currentAngularSpeed2 = nextGradient.getFactor();
  106016. particle._currentAngularSpeedGradient = currentGradient;
  106017. }
  106018. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentAngularSpeed1, particle._currentAngularSpeed2, scale);
  106019. });
  106020. }
  106021. particle.angle += particle.angularSpeed * scaledUpdateSpeed;
  106022. // Direction
  106023. var directionScale = scaledUpdateSpeed;
  106024. /// Velocity
  106025. if (_this._velocityGradients && _this._velocityGradients.length > 0) {
  106026. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._velocityGradients, function (currentGradient, nextGradient, scale) {
  106027. if (currentGradient !== particle._currentVelocityGradient) {
  106028. particle._currentVelocity1 = particle._currentVelocity2;
  106029. particle._currentVelocity2 = nextGradient.getFactor();
  106030. particle._currentVelocityGradient = currentGradient;
  106031. }
  106032. directionScale *= _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentVelocity1, particle._currentVelocity2, scale);
  106033. });
  106034. }
  106035. particle.direction.scaleToRef(directionScale, _this._scaledDirection);
  106036. /// Limit velocity
  106037. if (_this._limitVelocityGradients && _this._limitVelocityGradients.length > 0) {
  106038. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._limitVelocityGradients, function (currentGradient, nextGradient, scale) {
  106039. if (currentGradient !== particle._currentLimitVelocityGradient) {
  106040. particle._currentLimitVelocity1 = particle._currentLimitVelocity2;
  106041. particle._currentLimitVelocity2 = nextGradient.getFactor();
  106042. particle._currentLimitVelocityGradient = currentGradient;
  106043. }
  106044. var limitVelocity = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentLimitVelocity1, particle._currentLimitVelocity2, scale);
  106045. var currentVelocity = particle.direction.length();
  106046. if (currentVelocity > limitVelocity) {
  106047. particle.direction.scaleInPlace(_this.limitVelocityDamping);
  106048. }
  106049. });
  106050. }
  106051. /// Drag
  106052. if (_this._dragGradients && _this._dragGradients.length > 0) {
  106053. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._dragGradients, function (currentGradient, nextGradient, scale) {
  106054. if (currentGradient !== particle._currentDragGradient) {
  106055. particle._currentDrag1 = particle._currentDrag2;
  106056. particle._currentDrag2 = nextGradient.getFactor();
  106057. particle._currentDragGradient = currentGradient;
  106058. }
  106059. var drag = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentDrag1, particle._currentDrag2, scale);
  106060. _this._scaledDirection.scaleInPlace(1.0 - drag);
  106061. });
  106062. }
  106063. particle.position.addInPlace(_this._scaledDirection);
  106064. // Noise
  106065. if (noiseTextureData && noiseTextureSize && particle._randomNoiseCoordinates1) {
  106066. var fetchedColorR = _this._fetchR(particle._randomNoiseCoordinates1.x, particle._randomNoiseCoordinates1.y, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106067. var fetchedColorG = _this._fetchR(particle._randomNoiseCoordinates1.z, particle._randomNoiseCoordinates2.x, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106068. var fetchedColorB = _this._fetchR(particle._randomNoiseCoordinates2.y, particle._randomNoiseCoordinates2.z, noiseTextureSize.width, noiseTextureSize.height, noiseTextureData);
  106069. var force = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[0];
  106070. var scaledForce = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector3[1];
  106071. force.copyFromFloats((2 * fetchedColorR - 1) * _this.noiseStrength.x, (2 * fetchedColorG - 1) * _this.noiseStrength.y, (2 * fetchedColorB - 1) * _this.noiseStrength.z);
  106072. force.scaleToRef(scaledUpdateSpeed, scaledForce);
  106073. particle.direction.addInPlace(scaledForce);
  106074. }
  106075. // Gravity
  106076. _this.gravity.scaleToRef(scaledUpdateSpeed, _this._scaledGravity);
  106077. particle.direction.addInPlace(_this._scaledGravity);
  106078. // Size
  106079. if (_this._sizeGradients && _this._sizeGradients.length > 0) {
  106080. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._sizeGradients, function (currentGradient, nextGradient, scale) {
  106081. if (currentGradient !== particle._currentSizeGradient) {
  106082. particle._currentSize1 = particle._currentSize2;
  106083. particle._currentSize2 = nextGradient.getFactor();
  106084. particle._currentSizeGradient = currentGradient;
  106085. }
  106086. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(particle._currentSize1, particle._currentSize2, scale);
  106087. });
  106088. }
  106089. // Remap data
  106090. if (_this._useRampGradients) {
  106091. if (_this._colorRemapGradients && _this._colorRemapGradients.length > 0) {
  106092. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._colorRemapGradients, function (currentGradient, nextGradient, scale) {
  106093. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  106094. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  106095. particle.remapData.x = min;
  106096. particle.remapData.y = max - min;
  106097. });
  106098. }
  106099. if (_this._alphaRemapGradients && _this._alphaRemapGradients.length > 0) {
  106100. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, _this._alphaRemapGradients, function (currentGradient, nextGradient, scale) {
  106101. var min = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor1, nextGradient.factor1, scale);
  106102. var max = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(currentGradient.factor2, nextGradient.factor2, scale);
  106103. particle.remapData.z = min;
  106104. particle.remapData.w = max - min;
  106105. });
  106106. }
  106107. }
  106108. if (_this._isAnimationSheetEnabled) {
  106109. particle.updateCellIndex();
  106110. }
  106111. // Update the position of the attached sub-emitters to match their attached particle
  106112. particle._inheritParticleInfoToSubEmitters();
  106113. if (particle.age >= particle.lifeTime) { // Recycle by swapping with last particle
  106114. _this._emitFromParticle(particle);
  106115. if (particle._attachedSubEmitters) {
  106116. particle._attachedSubEmitters.forEach(function (subEmitter) {
  106117. subEmitter.particleSystem.disposeOnStop = true;
  106118. subEmitter.particleSystem.stop();
  106119. });
  106120. particle._attachedSubEmitters = null;
  106121. }
  106122. _this.recycleParticle(particle);
  106123. index--;
  106124. return "continue";
  106125. }
  106126. };
  106127. var particle;
  106128. for (var index = 0; index < particles.length; index++) {
  106129. _loop_1();
  106130. }
  106131. };
  106132. return _this;
  106133. }
  106134. Object.defineProperty(ParticleSystem.prototype, "onDispose", {
  106135. /**
  106136. * Sets a callback that will be triggered when the system is disposed
  106137. */
  106138. set: function (callback) {
  106139. if (this._onDisposeObserver) {
  106140. this.onDisposeObservable.remove(this._onDisposeObserver);
  106141. }
  106142. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  106143. },
  106144. enumerable: true,
  106145. configurable: true
  106146. });
  106147. Object.defineProperty(ParticleSystem.prototype, "useRampGradients", {
  106148. /** Gets or sets a boolean indicating that ramp gradients must be used
  106149. * @see http://doc.babylonjs.com/babylon101/particles#ramp-gradients
  106150. */
  106151. get: function () {
  106152. return this._useRampGradients;
  106153. },
  106154. set: function (value) {
  106155. if (this._useRampGradients === value) {
  106156. return;
  106157. }
  106158. this._useRampGradients = value;
  106159. this._resetEffect();
  106160. },
  106161. enumerable: true,
  106162. configurable: true
  106163. });
  106164. Object.defineProperty(ParticleSystem.prototype, "particles", {
  106165. //end of Sub-emitter
  106166. /**
  106167. * Gets the current list of active particles
  106168. */
  106169. get: function () {
  106170. return this._particles;
  106171. },
  106172. enumerable: true,
  106173. configurable: true
  106174. });
  106175. /**
  106176. * Returns the string "ParticleSystem"
  106177. * @returns a string containing the class name
  106178. */
  106179. ParticleSystem.prototype.getClassName = function () {
  106180. return "ParticleSystem";
  106181. };
  106182. ParticleSystem.prototype._addFactorGradient = function (factorGradients, gradient, factor, factor2) {
  106183. var newGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["FactorGradient"]();
  106184. newGradient.gradient = gradient;
  106185. newGradient.factor1 = factor;
  106186. newGradient.factor2 = factor2;
  106187. factorGradients.push(newGradient);
  106188. factorGradients.sort(function (a, b) {
  106189. if (a.gradient < b.gradient) {
  106190. return -1;
  106191. }
  106192. else if (a.gradient > b.gradient) {
  106193. return 1;
  106194. }
  106195. return 0;
  106196. });
  106197. };
  106198. ParticleSystem.prototype._removeFactorGradient = function (factorGradients, gradient) {
  106199. if (!factorGradients) {
  106200. return;
  106201. }
  106202. var index = 0;
  106203. for (var _i = 0, factorGradients_1 = factorGradients; _i < factorGradients_1.length; _i++) {
  106204. var factorGradient = factorGradients_1[_i];
  106205. if (factorGradient.gradient === gradient) {
  106206. factorGradients.splice(index, 1);
  106207. break;
  106208. }
  106209. index++;
  106210. }
  106211. };
  106212. /**
  106213. * Adds a new life time gradient
  106214. * @param gradient defines the gradient to use (between 0 and 1)
  106215. * @param factor defines the life time factor to affect to the specified gradient
  106216. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106217. * @returns the current particle system
  106218. */
  106219. ParticleSystem.prototype.addLifeTimeGradient = function (gradient, factor, factor2) {
  106220. if (!this._lifeTimeGradients) {
  106221. this._lifeTimeGradients = [];
  106222. }
  106223. this._addFactorGradient(this._lifeTimeGradients, gradient, factor, factor2);
  106224. return this;
  106225. };
  106226. /**
  106227. * Remove a specific life time gradient
  106228. * @param gradient defines the gradient to remove
  106229. * @returns the current particle system
  106230. */
  106231. ParticleSystem.prototype.removeLifeTimeGradient = function (gradient) {
  106232. this._removeFactorGradient(this._lifeTimeGradients, gradient);
  106233. return this;
  106234. };
  106235. /**
  106236. * Adds a new size gradient
  106237. * @param gradient defines the gradient to use (between 0 and 1)
  106238. * @param factor defines the size factor to affect to the specified gradient
  106239. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106240. * @returns the current particle system
  106241. */
  106242. ParticleSystem.prototype.addSizeGradient = function (gradient, factor, factor2) {
  106243. if (!this._sizeGradients) {
  106244. this._sizeGradients = [];
  106245. }
  106246. this._addFactorGradient(this._sizeGradients, gradient, factor, factor2);
  106247. return this;
  106248. };
  106249. /**
  106250. * Remove a specific size gradient
  106251. * @param gradient defines the gradient to remove
  106252. * @returns the current particle system
  106253. */
  106254. ParticleSystem.prototype.removeSizeGradient = function (gradient) {
  106255. this._removeFactorGradient(this._sizeGradients, gradient);
  106256. return this;
  106257. };
  106258. /**
  106259. * Adds a new color remap gradient
  106260. * @param gradient defines the gradient to use (between 0 and 1)
  106261. * @param min defines the color remap minimal range
  106262. * @param max defines the color remap maximal range
  106263. * @returns the current particle system
  106264. */
  106265. ParticleSystem.prototype.addColorRemapGradient = function (gradient, min, max) {
  106266. if (!this._colorRemapGradients) {
  106267. this._colorRemapGradients = [];
  106268. }
  106269. this._addFactorGradient(this._colorRemapGradients, gradient, min, max);
  106270. return this;
  106271. };
  106272. /**
  106273. * Remove a specific color remap gradient
  106274. * @param gradient defines the gradient to remove
  106275. * @returns the current particle system
  106276. */
  106277. ParticleSystem.prototype.removeColorRemapGradient = function (gradient) {
  106278. this._removeFactorGradient(this._colorRemapGradients, gradient);
  106279. return this;
  106280. };
  106281. /**
  106282. * Adds a new alpha remap gradient
  106283. * @param gradient defines the gradient to use (between 0 and 1)
  106284. * @param min defines the alpha remap minimal range
  106285. * @param max defines the alpha remap maximal range
  106286. * @returns the current particle system
  106287. */
  106288. ParticleSystem.prototype.addAlphaRemapGradient = function (gradient, min, max) {
  106289. if (!this._alphaRemapGradients) {
  106290. this._alphaRemapGradients = [];
  106291. }
  106292. this._addFactorGradient(this._alphaRemapGradients, gradient, min, max);
  106293. return this;
  106294. };
  106295. /**
  106296. * Remove a specific alpha remap gradient
  106297. * @param gradient defines the gradient to remove
  106298. * @returns the current particle system
  106299. */
  106300. ParticleSystem.prototype.removeAlphaRemapGradient = function (gradient) {
  106301. this._removeFactorGradient(this._alphaRemapGradients, gradient);
  106302. return this;
  106303. };
  106304. /**
  106305. * Adds a new angular speed gradient
  106306. * @param gradient defines the gradient to use (between 0 and 1)
  106307. * @param factor defines the angular speed to affect to the specified gradient
  106308. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106309. * @returns the current particle system
  106310. */
  106311. ParticleSystem.prototype.addAngularSpeedGradient = function (gradient, factor, factor2) {
  106312. if (!this._angularSpeedGradients) {
  106313. this._angularSpeedGradients = [];
  106314. }
  106315. this._addFactorGradient(this._angularSpeedGradients, gradient, factor, factor2);
  106316. return this;
  106317. };
  106318. /**
  106319. * Remove a specific angular speed gradient
  106320. * @param gradient defines the gradient to remove
  106321. * @returns the current particle system
  106322. */
  106323. ParticleSystem.prototype.removeAngularSpeedGradient = function (gradient) {
  106324. this._removeFactorGradient(this._angularSpeedGradients, gradient);
  106325. return this;
  106326. };
  106327. /**
  106328. * Adds a new velocity gradient
  106329. * @param gradient defines the gradient to use (between 0 and 1)
  106330. * @param factor defines the velocity to affect to the specified gradient
  106331. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106332. * @returns the current particle system
  106333. */
  106334. ParticleSystem.prototype.addVelocityGradient = function (gradient, factor, factor2) {
  106335. if (!this._velocityGradients) {
  106336. this._velocityGradients = [];
  106337. }
  106338. this._addFactorGradient(this._velocityGradients, gradient, factor, factor2);
  106339. return this;
  106340. };
  106341. /**
  106342. * Remove a specific velocity gradient
  106343. * @param gradient defines the gradient to remove
  106344. * @returns the current particle system
  106345. */
  106346. ParticleSystem.prototype.removeVelocityGradient = function (gradient) {
  106347. this._removeFactorGradient(this._velocityGradients, gradient);
  106348. return this;
  106349. };
  106350. /**
  106351. * Adds a new limit velocity gradient
  106352. * @param gradient defines the gradient to use (between 0 and 1)
  106353. * @param factor defines the limit velocity value to affect to the specified gradient
  106354. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106355. * @returns the current particle system
  106356. */
  106357. ParticleSystem.prototype.addLimitVelocityGradient = function (gradient, factor, factor2) {
  106358. if (!this._limitVelocityGradients) {
  106359. this._limitVelocityGradients = [];
  106360. }
  106361. this._addFactorGradient(this._limitVelocityGradients, gradient, factor, factor2);
  106362. return this;
  106363. };
  106364. /**
  106365. * Remove a specific limit velocity gradient
  106366. * @param gradient defines the gradient to remove
  106367. * @returns the current particle system
  106368. */
  106369. ParticleSystem.prototype.removeLimitVelocityGradient = function (gradient) {
  106370. this._removeFactorGradient(this._limitVelocityGradients, gradient);
  106371. return this;
  106372. };
  106373. /**
  106374. * Adds a new drag gradient
  106375. * @param gradient defines the gradient to use (between 0 and 1)
  106376. * @param factor defines the drag value to affect to the specified gradient
  106377. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106378. * @returns the current particle system
  106379. */
  106380. ParticleSystem.prototype.addDragGradient = function (gradient, factor, factor2) {
  106381. if (!this._dragGradients) {
  106382. this._dragGradients = [];
  106383. }
  106384. this._addFactorGradient(this._dragGradients, gradient, factor, factor2);
  106385. return this;
  106386. };
  106387. /**
  106388. * Remove a specific drag gradient
  106389. * @param gradient defines the gradient to remove
  106390. * @returns the current particle system
  106391. */
  106392. ParticleSystem.prototype.removeDragGradient = function (gradient) {
  106393. this._removeFactorGradient(this._dragGradients, gradient);
  106394. return this;
  106395. };
  106396. /**
  106397. * Adds a new emit rate gradient (please note that this will only work if you set the targetStopDuration property)
  106398. * @param gradient defines the gradient to use (between 0 and 1)
  106399. * @param factor defines the emit rate value to affect to the specified gradient
  106400. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106401. * @returns the current particle system
  106402. */
  106403. ParticleSystem.prototype.addEmitRateGradient = function (gradient, factor, factor2) {
  106404. if (!this._emitRateGradients) {
  106405. this._emitRateGradients = [];
  106406. }
  106407. this._addFactorGradient(this._emitRateGradients, gradient, factor, factor2);
  106408. return this;
  106409. };
  106410. /**
  106411. * Remove a specific emit rate gradient
  106412. * @param gradient defines the gradient to remove
  106413. * @returns the current particle system
  106414. */
  106415. ParticleSystem.prototype.removeEmitRateGradient = function (gradient) {
  106416. this._removeFactorGradient(this._emitRateGradients, gradient);
  106417. return this;
  106418. };
  106419. /**
  106420. * Adds a new start size gradient (please note that this will only work if you set the targetStopDuration property)
  106421. * @param gradient defines the gradient to use (between 0 and 1)
  106422. * @param factor defines the start size value to affect to the specified gradient
  106423. * @param factor2 defines an additional factor used to define a range ([factor, factor2]) with main value to pick the final value from
  106424. * @returns the current particle system
  106425. */
  106426. ParticleSystem.prototype.addStartSizeGradient = function (gradient, factor, factor2) {
  106427. if (!this._startSizeGradients) {
  106428. this._startSizeGradients = [];
  106429. }
  106430. this._addFactorGradient(this._startSizeGradients, gradient, factor, factor2);
  106431. return this;
  106432. };
  106433. /**
  106434. * Remove a specific start size gradient
  106435. * @param gradient defines the gradient to remove
  106436. * @returns the current particle system
  106437. */
  106438. ParticleSystem.prototype.removeStartSizeGradient = function (gradient) {
  106439. this._removeFactorGradient(this._emitRateGradients, gradient);
  106440. return this;
  106441. };
  106442. ParticleSystem.prototype._createRampGradientTexture = function () {
  106443. if (!this._rampGradients || !this._rampGradients.length || this._rampGradientsTexture) {
  106444. return;
  106445. }
  106446. var data = new Uint8Array(this._rawTextureWidth * 4);
  106447. var tmpColor = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Color3[0];
  106448. for (var x = 0; x < this._rawTextureWidth; x++) {
  106449. var ratio = x / this._rawTextureWidth;
  106450. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._rampGradients, function (currentGradient, nextGradient, scale) {
  106451. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].LerpToRef(currentGradient.color, nextGradient.color, scale, tmpColor);
  106452. data[x * 4] = tmpColor.r * 255;
  106453. data[x * 4 + 1] = tmpColor.g * 255;
  106454. data[x * 4 + 2] = tmpColor.b * 255;
  106455. data[x * 4 + 3] = 255;
  106456. });
  106457. }
  106458. 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);
  106459. };
  106460. /**
  106461. * Gets the current list of ramp gradients.
  106462. * You must use addRampGradient and removeRampGradient to udpate this list
  106463. * @returns the list of ramp gradients
  106464. */
  106465. ParticleSystem.prototype.getRampGradients = function () {
  106466. return this._rampGradients;
  106467. };
  106468. /**
  106469. * Adds a new ramp gradient used to remap particle colors
  106470. * @param gradient defines the gradient to use (between 0 and 1)
  106471. * @param color defines the color to affect to the specified gradient
  106472. * @returns the current particle system
  106473. */
  106474. ParticleSystem.prototype.addRampGradient = function (gradient, color) {
  106475. if (!this._rampGradients) {
  106476. this._rampGradients = [];
  106477. }
  106478. var rampGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Color3Gradient"]();
  106479. rampGradient.gradient = gradient;
  106480. rampGradient.color = color;
  106481. this._rampGradients.push(rampGradient);
  106482. this._rampGradients.sort(function (a, b) {
  106483. if (a.gradient < b.gradient) {
  106484. return -1;
  106485. }
  106486. else if (a.gradient > b.gradient) {
  106487. return 1;
  106488. }
  106489. return 0;
  106490. });
  106491. if (this._rampGradientsTexture) {
  106492. this._rampGradientsTexture.dispose();
  106493. this._rampGradientsTexture = null;
  106494. }
  106495. this._createRampGradientTexture();
  106496. return this;
  106497. };
  106498. /**
  106499. * Remove a specific ramp gradient
  106500. * @param gradient defines the gradient to remove
  106501. * @returns the current particle system
  106502. */
  106503. ParticleSystem.prototype.removeRampGradient = function (gradient) {
  106504. this._removeGradientAndTexture(gradient, this._rampGradients, this._rampGradientsTexture);
  106505. this._rampGradientsTexture = null;
  106506. if (this._rampGradients && this._rampGradients.length > 0) {
  106507. this._createRampGradientTexture();
  106508. }
  106509. return this;
  106510. };
  106511. /**
  106512. * Adds a new color gradient
  106513. * @param gradient defines the gradient to use (between 0 and 1)
  106514. * @param color1 defines the color to affect to the specified gradient
  106515. * @param color2 defines an additional color used to define a range ([color, color2]) with main color to pick the final color from
  106516. * @returns this particle system
  106517. */
  106518. ParticleSystem.prototype.addColorGradient = function (gradient, color1, color2) {
  106519. if (!this._colorGradients) {
  106520. this._colorGradients = [];
  106521. }
  106522. var colorGradient = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["ColorGradient"]();
  106523. colorGradient.gradient = gradient;
  106524. colorGradient.color1 = color1;
  106525. colorGradient.color2 = color2;
  106526. this._colorGradients.push(colorGradient);
  106527. this._colorGradients.sort(function (a, b) {
  106528. if (a.gradient < b.gradient) {
  106529. return -1;
  106530. }
  106531. else if (a.gradient > b.gradient) {
  106532. return 1;
  106533. }
  106534. return 0;
  106535. });
  106536. return this;
  106537. };
  106538. /**
  106539. * Remove a specific color gradient
  106540. * @param gradient defines the gradient to remove
  106541. * @returns this particle system
  106542. */
  106543. ParticleSystem.prototype.removeColorGradient = function (gradient) {
  106544. if (!this._colorGradients) {
  106545. return this;
  106546. }
  106547. var index = 0;
  106548. for (var _i = 0, _a = this._colorGradients; _i < _a.length; _i++) {
  106549. var colorGradient = _a[_i];
  106550. if (colorGradient.gradient === gradient) {
  106551. this._colorGradients.splice(index, 1);
  106552. break;
  106553. }
  106554. index++;
  106555. }
  106556. return this;
  106557. };
  106558. ParticleSystem.prototype._fetchR = function (u, v, width, height, pixels) {
  106559. u = Math.abs(u) * 0.5 + 0.5;
  106560. v = Math.abs(v) * 0.5 + 0.5;
  106561. var wrappedU = ((u * width) % width) | 0;
  106562. var wrappedV = ((v * height) % height) | 0;
  106563. var position = (wrappedU + wrappedV * width) * 4;
  106564. return pixels[position] / 255;
  106565. };
  106566. ParticleSystem.prototype._reset = function () {
  106567. this._resetEffect();
  106568. };
  106569. ParticleSystem.prototype._resetEffect = function () {
  106570. if (this._vertexBuffer) {
  106571. this._vertexBuffer.dispose();
  106572. this._vertexBuffer = null;
  106573. }
  106574. if (this._spriteBuffer) {
  106575. this._spriteBuffer.dispose();
  106576. this._spriteBuffer = null;
  106577. }
  106578. this._createVertexBuffers();
  106579. };
  106580. ParticleSystem.prototype._createVertexBuffers = function () {
  106581. this._vertexBufferSize = this._useInstancing ? 10 : 12;
  106582. if (this._isAnimationSheetEnabled) {
  106583. this._vertexBufferSize += 1;
  106584. }
  106585. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106586. this._vertexBufferSize += 3;
  106587. }
  106588. if (this._useRampGradients) {
  106589. this._vertexBufferSize += 4;
  106590. }
  106591. var engine = this._scene.getEngine();
  106592. this._vertexData = new Float32Array(this._capacity * this._vertexBufferSize * (this._useInstancing ? 1 : 4));
  106593. this._vertexBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, this._vertexData, true, this._vertexBufferSize);
  106594. var dataOffset = 0;
  106595. var positions = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  106596. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind] = positions;
  106597. dataOffset += 3;
  106598. var colors = this._vertexBuffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  106599. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind] = colors;
  106600. dataOffset += 4;
  106601. var options = this._vertexBuffer.createVertexBuffer("angle", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  106602. this._vertexBuffers["angle"] = options;
  106603. dataOffset += 1;
  106604. var size = this._vertexBuffer.createVertexBuffer("size", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  106605. this._vertexBuffers["size"] = size;
  106606. dataOffset += 2;
  106607. if (this._isAnimationSheetEnabled) {
  106608. var cellIndexBuffer = this._vertexBuffer.createVertexBuffer("cellIndex", dataOffset, 1, this._vertexBufferSize, this._useInstancing);
  106609. this._vertexBuffers["cellIndex"] = cellIndexBuffer;
  106610. dataOffset += 1;
  106611. }
  106612. if (!this._isBillboardBased || this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106613. var directionBuffer = this._vertexBuffer.createVertexBuffer("direction", dataOffset, 3, this._vertexBufferSize, this._useInstancing);
  106614. this._vertexBuffers["direction"] = directionBuffer;
  106615. dataOffset += 3;
  106616. }
  106617. if (this._useRampGradients) {
  106618. var rampDataBuffer = this._vertexBuffer.createVertexBuffer("remapData", dataOffset, 4, this._vertexBufferSize, this._useInstancing);
  106619. this._vertexBuffers["remapData"] = rampDataBuffer;
  106620. dataOffset += 4;
  106621. }
  106622. var offsets;
  106623. if (this._useInstancing) {
  106624. var spriteData = new Float32Array([0, 0, 1, 0, 1, 1, 0, 1]);
  106625. this._spriteBuffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["Buffer"](engine, spriteData, false, 2);
  106626. offsets = this._spriteBuffer.createVertexBuffer("offset", 0, 2);
  106627. }
  106628. else {
  106629. offsets = this._vertexBuffer.createVertexBuffer("offset", dataOffset, 2, this._vertexBufferSize, this._useInstancing);
  106630. dataOffset += 2;
  106631. }
  106632. this._vertexBuffers["offset"] = offsets;
  106633. };
  106634. ParticleSystem.prototype._createIndexBuffer = function () {
  106635. if (this._useInstancing) {
  106636. return;
  106637. }
  106638. var indices = [];
  106639. var index = 0;
  106640. for (var count = 0; count < this._capacity; count++) {
  106641. indices.push(index);
  106642. indices.push(index + 1);
  106643. indices.push(index + 2);
  106644. indices.push(index);
  106645. indices.push(index + 2);
  106646. indices.push(index + 3);
  106647. index += 4;
  106648. }
  106649. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  106650. };
  106651. /**
  106652. * Gets the maximum number of particles active at the same time.
  106653. * @returns The max number of active particles.
  106654. */
  106655. ParticleSystem.prototype.getCapacity = function () {
  106656. return this._capacity;
  106657. };
  106658. /**
  106659. * Gets whether there are still active particles in the system.
  106660. * @returns True if it is alive, otherwise false.
  106661. */
  106662. ParticleSystem.prototype.isAlive = function () {
  106663. return this._alive;
  106664. };
  106665. /**
  106666. * Gets if the system has been started. (Note: this will still be true after stop is called)
  106667. * @returns True if it has been started, otherwise false.
  106668. */
  106669. ParticleSystem.prototype.isStarted = function () {
  106670. return this._started;
  106671. };
  106672. ParticleSystem.prototype._prepareSubEmitterInternalArray = function () {
  106673. var _this = this;
  106674. this._subEmitters = new Array();
  106675. if (this.subEmitters) {
  106676. this.subEmitters.forEach(function (subEmitter) {
  106677. if (subEmitter instanceof ParticleSystem) {
  106678. _this._subEmitters.push([new _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"](subEmitter)]);
  106679. }
  106680. else if (subEmitter instanceof _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]) {
  106681. _this._subEmitters.push([subEmitter]);
  106682. }
  106683. else if (subEmitter instanceof Array) {
  106684. _this._subEmitters.push(subEmitter);
  106685. }
  106686. });
  106687. }
  106688. };
  106689. /**
  106690. * Starts the particle system and begins to emit
  106691. * @param delay defines the delay in milliseconds before starting the system (this.startDelay by default)
  106692. */
  106693. ParticleSystem.prototype.start = function (delay) {
  106694. var _this = this;
  106695. if (delay === void 0) { delay = this.startDelay; }
  106696. if (!this.targetStopDuration && this._hasTargetStopDurationDependantGradient()) {
  106697. throw "Particle system started with a targetStopDuration dependant gradient (eg. startSizeGradients) but no targetStopDuration set";
  106698. }
  106699. if (delay) {
  106700. setTimeout(function () {
  106701. _this.start(0);
  106702. }, delay);
  106703. return;
  106704. }
  106705. // Convert the subEmitters field to the constant type field _subEmitters
  106706. this._prepareSubEmitterInternalArray();
  106707. this._started = true;
  106708. this._stopped = false;
  106709. this._actualFrame = 0;
  106710. if (this._subEmitters && this._subEmitters.length != 0) {
  106711. this.activeSubSystems = new Array();
  106712. }
  106713. // Reset emit gradient so it acts the same on every start
  106714. if (this._emitRateGradients) {
  106715. if (this._emitRateGradients.length > 0) {
  106716. this._currentEmitRateGradient = this._emitRateGradients[0];
  106717. this._currentEmitRate1 = this._currentEmitRateGradient.getFactor();
  106718. this._currentEmitRate2 = this._currentEmitRate1;
  106719. }
  106720. if (this._emitRateGradients.length > 1) {
  106721. this._currentEmitRate2 = this._emitRateGradients[1].getFactor();
  106722. }
  106723. }
  106724. // Reset start size gradient so it acts the same on every start
  106725. if (this._startSizeGradients) {
  106726. if (this._startSizeGradients.length > 0) {
  106727. this._currentStartSizeGradient = this._startSizeGradients[0];
  106728. this._currentStartSize1 = this._currentStartSizeGradient.getFactor();
  106729. this._currentStartSize2 = this._currentStartSize1;
  106730. }
  106731. if (this._startSizeGradients.length > 1) {
  106732. this._currentStartSize2 = this._startSizeGradients[1].getFactor();
  106733. }
  106734. }
  106735. if (this.preWarmCycles) {
  106736. if (this.emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_6__["AbstractMesh"]) {
  106737. this.emitter.computeWorldMatrix(true);
  106738. }
  106739. var noiseTextureAsProcedural_1 = this.noiseTexture;
  106740. if (noiseTextureAsProcedural_1 && noiseTextureAsProcedural_1.onGeneratedObservable) {
  106741. noiseTextureAsProcedural_1.onGeneratedObservable.addOnce(function () {
  106742. setTimeout(function () {
  106743. for (var index = 0; index < _this.preWarmCycles; index++) {
  106744. _this.animate(true);
  106745. noiseTextureAsProcedural_1.render();
  106746. }
  106747. });
  106748. });
  106749. }
  106750. else {
  106751. for (var index = 0; index < this.preWarmCycles; index++) {
  106752. this.animate(true);
  106753. }
  106754. }
  106755. }
  106756. // Animations
  106757. if (this.beginAnimationOnStart && this.animations && this.animations.length > 0) {
  106758. this.getScene().beginAnimation(this, this.beginAnimationFrom, this.beginAnimationTo, this.beginAnimationLoop);
  106759. }
  106760. };
  106761. /**
  106762. * Stops the particle system.
  106763. * @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.
  106764. */
  106765. ParticleSystem.prototype.stop = function (stopSubEmitters) {
  106766. if (stopSubEmitters === void 0) { stopSubEmitters = true; }
  106767. this._stopped = true;
  106768. if (stopSubEmitters) {
  106769. this._stopSubEmitters();
  106770. }
  106771. };
  106772. // animation sheet
  106773. /**
  106774. * Remove all active particles
  106775. */
  106776. ParticleSystem.prototype.reset = function () {
  106777. this._stockParticles = [];
  106778. this._particles = [];
  106779. };
  106780. /**
  106781. * @hidden (for internal use only)
  106782. */
  106783. ParticleSystem.prototype._appendParticleVertex = function (index, particle, offsetX, offsetY) {
  106784. var offset = index * this._vertexBufferSize;
  106785. this._vertexData[offset++] = particle.position.x;
  106786. this._vertexData[offset++] = particle.position.y;
  106787. this._vertexData[offset++] = particle.position.z;
  106788. this._vertexData[offset++] = particle.color.r;
  106789. this._vertexData[offset++] = particle.color.g;
  106790. this._vertexData[offset++] = particle.color.b;
  106791. this._vertexData[offset++] = particle.color.a;
  106792. this._vertexData[offset++] = particle.angle;
  106793. this._vertexData[offset++] = particle.scale.x * particle.size;
  106794. this._vertexData[offset++] = particle.scale.y * particle.size;
  106795. if (this._isAnimationSheetEnabled) {
  106796. this._vertexData[offset++] = particle.cellIndex;
  106797. }
  106798. if (!this._isBillboardBased) {
  106799. if (particle._initialDirection) {
  106800. this._vertexData[offset++] = particle._initialDirection.x;
  106801. this._vertexData[offset++] = particle._initialDirection.y;
  106802. this._vertexData[offset++] = particle._initialDirection.z;
  106803. }
  106804. else {
  106805. this._vertexData[offset++] = particle.direction.x;
  106806. this._vertexData[offset++] = particle.direction.y;
  106807. this._vertexData[offset++] = particle.direction.z;
  106808. }
  106809. }
  106810. else if (this.billboardMode === ParticleSystem.BILLBOARDMODE_STRETCHED) {
  106811. this._vertexData[offset++] = particle.direction.x;
  106812. this._vertexData[offset++] = particle.direction.y;
  106813. this._vertexData[offset++] = particle.direction.z;
  106814. }
  106815. if (this._useRampGradients) {
  106816. this._vertexData[offset++] = particle.remapData.x;
  106817. this._vertexData[offset++] = particle.remapData.y;
  106818. this._vertexData[offset++] = particle.remapData.z;
  106819. this._vertexData[offset++] = particle.remapData.w;
  106820. }
  106821. if (!this._useInstancing) {
  106822. if (this._isAnimationSheetEnabled) {
  106823. if (offsetX === 0) {
  106824. offsetX = this._epsilon;
  106825. }
  106826. else if (offsetX === 1) {
  106827. offsetX = 1 - this._epsilon;
  106828. }
  106829. if (offsetY === 0) {
  106830. offsetY = this._epsilon;
  106831. }
  106832. else if (offsetY === 1) {
  106833. offsetY = 1 - this._epsilon;
  106834. }
  106835. }
  106836. this._vertexData[offset++] = offsetX;
  106837. this._vertexData[offset++] = offsetY;
  106838. }
  106839. };
  106840. ParticleSystem.prototype._stopSubEmitters = function () {
  106841. if (!this.activeSubSystems) {
  106842. return;
  106843. }
  106844. this.activeSubSystems.forEach(function (subSystem) {
  106845. subSystem.stop(true);
  106846. });
  106847. this.activeSubSystems = new Array();
  106848. };
  106849. ParticleSystem.prototype._removeFromRoot = function () {
  106850. if (!this._rootParticleSystem) {
  106851. return;
  106852. }
  106853. var index = this._rootParticleSystem.activeSubSystems.indexOf(this);
  106854. if (index !== -1) {
  106855. this._rootParticleSystem.activeSubSystems.splice(index, 1);
  106856. }
  106857. this._rootParticleSystem = null;
  106858. };
  106859. // End of sub system methods
  106860. ParticleSystem.prototype._update = function (newParticles) {
  106861. var _this = this;
  106862. // Update current
  106863. this._alive = this._particles.length > 0;
  106864. if (this.emitter.position) {
  106865. var emitterMesh = this.emitter;
  106866. this._emitterWorldMatrix = emitterMesh.getWorldMatrix();
  106867. }
  106868. else {
  106869. var emitterPosition = this.emitter;
  106870. this._emitterWorldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Translation(emitterPosition.x, emitterPosition.y, emitterPosition.z);
  106871. }
  106872. this.updateFunction(this._particles);
  106873. // Add new ones
  106874. var particle;
  106875. var _loop_2 = function () {
  106876. if (this_1._particles.length === this_1._capacity) {
  106877. return "break";
  106878. }
  106879. particle = this_1._createParticle();
  106880. this_1._particles.push(particle);
  106881. // Emitter
  106882. var emitPower = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minEmitPower, this_1.maxEmitPower);
  106883. if (this_1.startPositionFunction) {
  106884. this_1.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106885. }
  106886. else {
  106887. this_1.particleEmitterType.startPositionFunction(this_1._emitterWorldMatrix, particle.position, particle);
  106888. }
  106889. if (this_1.startDirectionFunction) {
  106890. this_1.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106891. }
  106892. else {
  106893. this_1.particleEmitterType.startDirectionFunction(this_1._emitterWorldMatrix, particle.direction, particle);
  106894. }
  106895. if (emitPower === 0) {
  106896. if (!particle._initialDirection) {
  106897. particle._initialDirection = particle.direction.clone();
  106898. }
  106899. else {
  106900. particle._initialDirection.copyFrom(particle.direction);
  106901. }
  106902. }
  106903. else {
  106904. particle._initialDirection = null;
  106905. }
  106906. particle.direction.scaleInPlace(emitPower);
  106907. // Life time
  106908. if (this_1.targetStopDuration && this_1._lifeTimeGradients && this_1._lifeTimeGradients.length > 0) {
  106909. var ratio_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(this_1._actualFrame / this_1.targetStopDuration);
  106910. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio_1, this_1._lifeTimeGradients, function (currentGradient, nextGradient) {
  106911. var factorGradient1 = currentGradient;
  106912. var factorGradient2 = nextGradient;
  106913. var lifeTime1 = factorGradient1.getFactor();
  106914. var lifeTime2 = factorGradient2.getFactor();
  106915. var gradient = (ratio_1 - factorGradient1.gradient) / (factorGradient2.gradient - factorGradient1.gradient);
  106916. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(lifeTime1, lifeTime2, gradient);
  106917. });
  106918. }
  106919. else {
  106920. particle.lifeTime = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minLifeTime, this_1.maxLifeTime);
  106921. }
  106922. // Size
  106923. if (!this_1._sizeGradients || this_1._sizeGradients.length === 0) {
  106924. particle.size = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minSize, this_1.maxSize);
  106925. }
  106926. else {
  106927. particle._currentSizeGradient = this_1._sizeGradients[0];
  106928. particle._currentSize1 = particle._currentSizeGradient.getFactor();
  106929. particle.size = particle._currentSize1;
  106930. if (this_1._sizeGradients.length > 1) {
  106931. particle._currentSize2 = this_1._sizeGradients[1].getFactor();
  106932. }
  106933. else {
  106934. particle._currentSize2 = particle._currentSize1;
  106935. }
  106936. }
  106937. // Size and scale
  106938. 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));
  106939. // Adjust scale by start size
  106940. if (this_1._startSizeGradients && this_1._startSizeGradients[0] && this_1.targetStopDuration) {
  106941. var ratio = this_1._actualFrame / this_1.targetStopDuration;
  106942. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this_1._startSizeGradients, function (currentGradient, nextGradient, scale) {
  106943. if (currentGradient !== _this._currentStartSizeGradient) {
  106944. _this._currentStartSize1 = _this._currentStartSize2;
  106945. _this._currentStartSize2 = nextGradient.getFactor();
  106946. _this._currentStartSizeGradient = currentGradient;
  106947. }
  106948. var value = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentStartSize1, _this._currentStartSize2, scale);
  106949. particle.scale.scaleInPlace(value);
  106950. });
  106951. }
  106952. // Angle
  106953. if (!this_1._angularSpeedGradients || this_1._angularSpeedGradients.length === 0) {
  106954. particle.angularSpeed = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minAngularSpeed, this_1.maxAngularSpeed);
  106955. }
  106956. else {
  106957. particle._currentAngularSpeedGradient = this_1._angularSpeedGradients[0];
  106958. particle.angularSpeed = particle._currentAngularSpeedGradient.getFactor();
  106959. particle._currentAngularSpeed1 = particle.angularSpeed;
  106960. if (this_1._angularSpeedGradients.length > 1) {
  106961. particle._currentAngularSpeed2 = this_1._angularSpeedGradients[1].getFactor();
  106962. }
  106963. else {
  106964. particle._currentAngularSpeed2 = particle._currentAngularSpeed1;
  106965. }
  106966. }
  106967. particle.angle = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(this_1.minInitialRotation, this_1.maxInitialRotation);
  106968. // Velocity
  106969. if (this_1._velocityGradients && this_1._velocityGradients.length > 0) {
  106970. particle._currentVelocityGradient = this_1._velocityGradients[0];
  106971. particle._currentVelocity1 = particle._currentVelocityGradient.getFactor();
  106972. if (this_1._velocityGradients.length > 1) {
  106973. particle._currentVelocity2 = this_1._velocityGradients[1].getFactor();
  106974. }
  106975. else {
  106976. particle._currentVelocity2 = particle._currentVelocity1;
  106977. }
  106978. }
  106979. // Limit velocity
  106980. if (this_1._limitVelocityGradients && this_1._limitVelocityGradients.length > 0) {
  106981. particle._currentLimitVelocityGradient = this_1._limitVelocityGradients[0];
  106982. particle._currentLimitVelocity1 = particle._currentLimitVelocityGradient.getFactor();
  106983. if (this_1._limitVelocityGradients.length > 1) {
  106984. particle._currentLimitVelocity2 = this_1._limitVelocityGradients[1].getFactor();
  106985. }
  106986. else {
  106987. particle._currentLimitVelocity2 = particle._currentLimitVelocity1;
  106988. }
  106989. }
  106990. // Drag
  106991. if (this_1._dragGradients && this_1._dragGradients.length > 0) {
  106992. particle._currentDragGradient = this_1._dragGradients[0];
  106993. particle._currentDrag1 = particle._currentDragGradient.getFactor();
  106994. if (this_1._dragGradients.length > 1) {
  106995. particle._currentDrag2 = this_1._dragGradients[1].getFactor();
  106996. }
  106997. else {
  106998. particle._currentDrag2 = particle._currentDrag1;
  106999. }
  107000. }
  107001. // Color
  107002. if (!this_1._colorGradients || this_1._colorGradients.length === 0) {
  107003. step = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].RandomRange(0, 1.0);
  107004. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].LerpToRef(this_1.color1, this_1.color2, step, particle.color);
  107005. this_1.colorDead.subtractToRef(particle.color, this_1._colorDiff);
  107006. this_1._colorDiff.scaleToRef(1.0 / particle.lifeTime, particle.colorStep);
  107007. }
  107008. else {
  107009. particle._currentColorGradient = this_1._colorGradients[0];
  107010. particle._currentColorGradient.getColorToRef(particle.color);
  107011. particle._currentColor1.copyFrom(particle.color);
  107012. if (this_1._colorGradients.length > 1) {
  107013. this_1._colorGradients[1].getColorToRef(particle._currentColor2);
  107014. }
  107015. else {
  107016. particle._currentColor2.copyFrom(particle.color);
  107017. }
  107018. }
  107019. // Sheet
  107020. if (this_1._isAnimationSheetEnabled) {
  107021. particle._initialStartSpriteCellID = this_1.startSpriteCellID;
  107022. particle._initialEndSpriteCellID = this_1.endSpriteCellID;
  107023. }
  107024. // Inherited Velocity
  107025. particle.direction.addInPlace(this_1._inheritedVelocityOffset);
  107026. // Ramp
  107027. if (this_1._useRampGradients) {
  107028. particle.remapData = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector4"](0, 1, 0, 1);
  107029. }
  107030. // Noise texture coordinates
  107031. if (this_1.noiseTexture) {
  107032. if (particle._randomNoiseCoordinates1) {
  107033. particle._randomNoiseCoordinates1.copyFromFloats(Math.random(), Math.random(), Math.random());
  107034. particle._randomNoiseCoordinates2.copyFromFloats(Math.random(), Math.random(), Math.random());
  107035. }
  107036. else {
  107037. particle._randomNoiseCoordinates1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  107038. particle._randomNoiseCoordinates2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.random(), Math.random(), Math.random());
  107039. }
  107040. }
  107041. // Update the position of the attached sub-emitters to match their attached particle
  107042. particle._inheritParticleInfoToSubEmitters();
  107043. };
  107044. var this_1 = this, step;
  107045. for (var index = 0; index < newParticles; index++) {
  107046. var state_1 = _loop_2();
  107047. if (state_1 === "break")
  107048. break;
  107049. }
  107050. };
  107051. /** @hidden */
  107052. ParticleSystem._GetAttributeNamesOrOptions = function (isAnimationSheetEnabled, isBillboardBased, useRampGradients) {
  107053. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107054. if (isBillboardBased === void 0) { isBillboardBased = false; }
  107055. if (useRampGradients === void 0) { useRampGradients = false; }
  107056. var attributeNamesOrOptions = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_5__["VertexBuffer"].ColorKind, "angle", "offset", "size"];
  107057. if (isAnimationSheetEnabled) {
  107058. attributeNamesOrOptions.push("cellIndex");
  107059. }
  107060. if (!isBillboardBased) {
  107061. attributeNamesOrOptions.push("direction");
  107062. }
  107063. if (useRampGradients) {
  107064. attributeNamesOrOptions.push("remapData");
  107065. }
  107066. return attributeNamesOrOptions;
  107067. };
  107068. /** @hidden */
  107069. ParticleSystem._GetEffectCreationOptions = function (isAnimationSheetEnabled) {
  107070. if (isAnimationSheetEnabled === void 0) { isAnimationSheetEnabled = false; }
  107071. var effectCreationOption = ["invView", "view", "projection", "vClipPlane", "vClipPlane2", "vClipPlane3", "vClipPlane4", "textureMask", "translationPivot", "eyePosition"];
  107072. if (isAnimationSheetEnabled) {
  107073. effectCreationOption.push("particlesInfos");
  107074. }
  107075. return effectCreationOption;
  107076. };
  107077. /** @hidden */
  107078. ParticleSystem.prototype._getEffect = function (blendMode) {
  107079. if (this._customEffect) {
  107080. return this._customEffect;
  107081. }
  107082. var defines = [];
  107083. if (this._scene.clipPlane) {
  107084. defines.push("#define CLIPPLANE");
  107085. }
  107086. if (this._scene.clipPlane2) {
  107087. defines.push("#define CLIPPLANE2");
  107088. }
  107089. if (this._scene.clipPlane3) {
  107090. defines.push("#define CLIPPLANE3");
  107091. }
  107092. if (this._scene.clipPlane4) {
  107093. defines.push("#define CLIPPLANE4");
  107094. }
  107095. if (this._isAnimationSheetEnabled) {
  107096. defines.push("#define ANIMATESHEET");
  107097. }
  107098. if (blendMode === ParticleSystem.BLENDMODE_MULTIPLY) {
  107099. defines.push("#define BLENDMULTIPLYMODE");
  107100. }
  107101. if (this._useRampGradients) {
  107102. defines.push("#define RAMPGRADIENT");
  107103. }
  107104. if (this._isBillboardBased) {
  107105. defines.push("#define BILLBOARD");
  107106. switch (this.billboardMode) {
  107107. case ParticleSystem.BILLBOARDMODE_Y:
  107108. defines.push("#define BILLBOARDY");
  107109. break;
  107110. case ParticleSystem.BILLBOARDMODE_STRETCHED:
  107111. defines.push("#define BILLBOARDSTRETCHED");
  107112. break;
  107113. case ParticleSystem.BILLBOARDMODE_ALL:
  107114. default:
  107115. break;
  107116. }
  107117. }
  107118. if (this._imageProcessingConfiguration) {
  107119. this._imageProcessingConfiguration.prepareDefines(this._imageProcessingConfigurationDefines);
  107120. defines.push(this._imageProcessingConfigurationDefines.toString());
  107121. }
  107122. // Effect
  107123. var join = defines.join("\n");
  107124. if (this._cachedDefines !== join) {
  107125. this._cachedDefines = join;
  107126. var attributesNamesOrOptions = ParticleSystem._GetAttributeNamesOrOptions(this._isAnimationSheetEnabled, this._isBillboardBased && this.billboardMode !== ParticleSystem.BILLBOARDMODE_STRETCHED, this._useRampGradients);
  107127. var effectCreationOption = ParticleSystem._GetEffectCreationOptions(this._isAnimationSheetEnabled);
  107128. var samplers = ["diffuseSampler", "rampSampler"];
  107129. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"]) {
  107130. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareUniforms(effectCreationOption, this._imageProcessingConfigurationDefines);
  107131. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_9__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._imageProcessingConfigurationDefines);
  107132. }
  107133. this._effect = this._scene.getEngine().createEffect("particles", attributesNamesOrOptions, effectCreationOption, samplers, join);
  107134. }
  107135. return this._effect;
  107136. };
  107137. /**
  107138. * Animates the particle system for the current frame by emitting new particles and or animating the living ones.
  107139. * @param preWarmOnly will prevent the system from updating the vertex buffer (default is false)
  107140. */
  107141. ParticleSystem.prototype.animate = function (preWarmOnly) {
  107142. var _this = this;
  107143. if (preWarmOnly === void 0) { preWarmOnly = false; }
  107144. if (!this._started) {
  107145. return;
  107146. }
  107147. if (!preWarmOnly) {
  107148. // Check
  107149. if (!this.isReady()) {
  107150. return;
  107151. }
  107152. if (this._currentRenderId === this._scene.getFrameId()) {
  107153. return;
  107154. }
  107155. this._currentRenderId = this._scene.getFrameId();
  107156. }
  107157. this._scaledUpdateSpeed = this.updateSpeed * (preWarmOnly ? this.preWarmStepOffset : this._scene.getAnimationRatio());
  107158. // Determine the number of particles we need to create
  107159. var newParticles;
  107160. if (this.manualEmitCount > -1) {
  107161. newParticles = this.manualEmitCount;
  107162. this._newPartsExcess = 0;
  107163. this.manualEmitCount = 0;
  107164. }
  107165. else {
  107166. var rate_1 = this.emitRate;
  107167. if (this._emitRateGradients && this._emitRateGradients.length > 0 && this.targetStopDuration) {
  107168. var ratio = this._actualFrame / this.targetStopDuration;
  107169. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetCurrentGradient(ratio, this._emitRateGradients, function (currentGradient, nextGradient, scale) {
  107170. if (currentGradient !== _this._currentEmitRateGradient) {
  107171. _this._currentEmitRate1 = _this._currentEmitRate2;
  107172. _this._currentEmitRate2 = nextGradient.getFactor();
  107173. _this._currentEmitRateGradient = currentGradient;
  107174. }
  107175. rate_1 = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Lerp(_this._currentEmitRate1, _this._currentEmitRate2, scale);
  107176. });
  107177. }
  107178. newParticles = ((rate_1 * this._scaledUpdateSpeed) >> 0);
  107179. this._newPartsExcess += rate_1 * this._scaledUpdateSpeed - newParticles;
  107180. }
  107181. if (this._newPartsExcess > 1.0) {
  107182. newParticles += this._newPartsExcess >> 0;
  107183. this._newPartsExcess -= this._newPartsExcess >> 0;
  107184. }
  107185. this._alive = false;
  107186. if (!this._stopped) {
  107187. this._actualFrame += this._scaledUpdateSpeed;
  107188. if (this.targetStopDuration && this._actualFrame >= this.targetStopDuration) {
  107189. this.stop();
  107190. }
  107191. }
  107192. else {
  107193. newParticles = 0;
  107194. }
  107195. this._update(newParticles);
  107196. // Stopped?
  107197. if (this._stopped) {
  107198. if (!this._alive) {
  107199. this._started = false;
  107200. if (this.onAnimationEnd) {
  107201. this.onAnimationEnd();
  107202. }
  107203. if (this.disposeOnStop) {
  107204. this._scene._toBeDisposed.push(this);
  107205. }
  107206. }
  107207. }
  107208. if (!preWarmOnly) {
  107209. // Update VBO
  107210. var offset = 0;
  107211. for (var index = 0; index < this._particles.length; index++) {
  107212. var particle = this._particles[index];
  107213. this._appendParticleVertices(offset, particle);
  107214. offset += this._useInstancing ? 1 : 4;
  107215. }
  107216. if (this._vertexBuffer) {
  107217. this._vertexBuffer.update(this._vertexData);
  107218. }
  107219. }
  107220. if (this.manualEmitCount === 0 && this.disposeOnStop) {
  107221. this.stop();
  107222. }
  107223. };
  107224. ParticleSystem.prototype._appendParticleVertices = function (offset, particle) {
  107225. this._appendParticleVertex(offset++, particle, 0, 0);
  107226. if (!this._useInstancing) {
  107227. this._appendParticleVertex(offset++, particle, 1, 0);
  107228. this._appendParticleVertex(offset++, particle, 1, 1);
  107229. this._appendParticleVertex(offset++, particle, 0, 1);
  107230. }
  107231. };
  107232. /**
  107233. * Rebuilds the particle system.
  107234. */
  107235. ParticleSystem.prototype.rebuild = function () {
  107236. this._createIndexBuffer();
  107237. if (this._vertexBuffer) {
  107238. this._vertexBuffer._rebuild();
  107239. }
  107240. };
  107241. /**
  107242. * Is this system ready to be used/rendered
  107243. * @return true if the system is ready
  107244. */
  107245. ParticleSystem.prototype.isReady = function () {
  107246. if (!this.emitter || !this._imageProcessingConfiguration.isReady() || !this.particleTexture || !this.particleTexture.isReady()) {
  107247. return false;
  107248. }
  107249. if (this.blendMode !== ParticleSystem.BLENDMODE_MULTIPLYADD) {
  107250. if (!this._getEffect(this.blendMode).isReady()) {
  107251. return false;
  107252. }
  107253. }
  107254. else {
  107255. if (!this._getEffect(ParticleSystem.BLENDMODE_MULTIPLY).isReady()) {
  107256. return false;
  107257. }
  107258. if (!this._getEffect(ParticleSystem.BLENDMODE_ADD).isReady()) {
  107259. return false;
  107260. }
  107261. }
  107262. return true;
  107263. };
  107264. ParticleSystem.prototype._render = function (blendMode) {
  107265. var effect = this._getEffect(blendMode);
  107266. var engine = this._scene.getEngine();
  107267. // Render
  107268. engine.enableEffect(effect);
  107269. var viewMatrix = this._scene.getViewMatrix();
  107270. effect.setTexture("diffuseSampler", this.particleTexture);
  107271. effect.setMatrix("view", viewMatrix);
  107272. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  107273. if (this._isAnimationSheetEnabled && this.particleTexture) {
  107274. var baseSize = this.particleTexture.getBaseSize();
  107275. effect.setFloat3("particlesInfos", this.spriteCellWidth / baseSize.width, this.spriteCellHeight / baseSize.height, baseSize.width / this.spriteCellWidth);
  107276. }
  107277. effect.setVector2("translationPivot", this.translationPivot);
  107278. effect.setFloat4("textureMask", this.textureMask.r, this.textureMask.g, this.textureMask.b, this.textureMask.a);
  107279. if (this._isBillboardBased) {
  107280. var camera = this._scene.activeCamera;
  107281. effect.setVector3("eyePosition", camera.globalPosition);
  107282. }
  107283. if (this._rampGradientsTexture) {
  107284. effect.setTexture("rampSampler", this._rampGradientsTexture);
  107285. }
  107286. if (this._scene.clipPlane || this._scene.clipPlane2 || this._scene.clipPlane3 || this._scene.clipPlane4) {
  107287. var invView = viewMatrix.clone();
  107288. invView.invert();
  107289. effect.setMatrix("invView", invView);
  107290. _Materials_materialHelper__WEBPACK_IMPORTED_MODULE_8__["MaterialHelper"].BindClipPlane(effect, this._scene);
  107291. }
  107292. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  107293. // image processing
  107294. if (this._imageProcessingConfiguration && !this._imageProcessingConfiguration.applyByPostProcess) {
  107295. this._imageProcessingConfiguration.bind(effect);
  107296. }
  107297. // Draw order
  107298. switch (blendMode) {
  107299. case ParticleSystem.BLENDMODE_ADD:
  107300. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ADD);
  107301. break;
  107302. case ParticleSystem.BLENDMODE_ONEONE:
  107303. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_ONEONE);
  107304. break;
  107305. case ParticleSystem.BLENDMODE_STANDARD:
  107306. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_COMBINE);
  107307. break;
  107308. case ParticleSystem.BLENDMODE_MULTIPLY:
  107309. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_MULTIPLY);
  107310. break;
  107311. }
  107312. if (this._useInstancing) {
  107313. engine.drawArraysType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFanDrawMode, 0, 4, this._particles.length);
  107314. }
  107315. else {
  107316. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, this._particles.length * 6);
  107317. }
  107318. return this._particles.length;
  107319. };
  107320. /**
  107321. * Renders the particle system in its current state.
  107322. * @returns the current number of particles
  107323. */
  107324. ParticleSystem.prototype.render = function () {
  107325. // Check
  107326. if (!this.isReady() || !this._particles.length) {
  107327. return 0;
  107328. }
  107329. var engine = this._scene.getEngine();
  107330. engine.setState(false);
  107331. if (this.forceDepthWrite) {
  107332. engine.setDepthWrite(true);
  107333. }
  107334. var outparticles = 0;
  107335. if (this.blendMode === ParticleSystem.BLENDMODE_MULTIPLYADD) {
  107336. outparticles = this._render(ParticleSystem.BLENDMODE_MULTIPLY) + this._render(ParticleSystem.BLENDMODE_ADD);
  107337. }
  107338. outparticles = this._render(this.blendMode);
  107339. engine.unbindInstanceAttributes();
  107340. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].ALPHA_DISABLE);
  107341. return outparticles;
  107342. };
  107343. /**
  107344. * Disposes the particle system and free the associated resources
  107345. * @param disposeTexture defines if the particule texture must be disposed as well (true by default)
  107346. */
  107347. ParticleSystem.prototype.dispose = function (disposeTexture) {
  107348. if (disposeTexture === void 0) { disposeTexture = true; }
  107349. if (this._vertexBuffer) {
  107350. this._vertexBuffer.dispose();
  107351. this._vertexBuffer = null;
  107352. }
  107353. if (this._spriteBuffer) {
  107354. this._spriteBuffer.dispose();
  107355. this._spriteBuffer = null;
  107356. }
  107357. if (this._indexBuffer) {
  107358. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  107359. this._indexBuffer = null;
  107360. }
  107361. if (disposeTexture && this.particleTexture) {
  107362. this.particleTexture.dispose();
  107363. this.particleTexture = null;
  107364. }
  107365. if (disposeTexture && this.noiseTexture) {
  107366. this.noiseTexture.dispose();
  107367. this.noiseTexture = null;
  107368. }
  107369. if (this._rampGradientsTexture) {
  107370. this._rampGradientsTexture.dispose();
  107371. this._rampGradientsTexture = null;
  107372. }
  107373. this._removeFromRoot();
  107374. if (this._subEmitters && this._subEmitters.length) {
  107375. for (var index = 0; index < this._subEmitters.length; index++) {
  107376. for (var _i = 0, _a = this._subEmitters[index]; _i < _a.length; _i++) {
  107377. var subEmitter = _a[_i];
  107378. subEmitter.dispose();
  107379. }
  107380. }
  107381. this._subEmitters = [];
  107382. this.subEmitters = [];
  107383. }
  107384. if (this._disposeEmitterOnDispose && this.emitter && this.emitter.dispose) {
  107385. this.emitter.dispose(true);
  107386. }
  107387. // Remove from scene
  107388. var index = this._scene.particleSystems.indexOf(this);
  107389. if (index > -1) {
  107390. this._scene.particleSystems.splice(index, 1);
  107391. }
  107392. this._scene._activeParticleSystems.dispose();
  107393. // Callback
  107394. this.onDisposeObservable.notifyObservers(this);
  107395. this.onDisposeObservable.clear();
  107396. this.reset();
  107397. };
  107398. // Clone
  107399. /**
  107400. * Clones the particle system.
  107401. * @param name The name of the cloned object
  107402. * @param newEmitter The new emitter to use
  107403. * @returns the cloned particle system
  107404. */
  107405. ParticleSystem.prototype.clone = function (name, newEmitter) {
  107406. var custom = null;
  107407. var program = null;
  107408. if (this.customShader != null) {
  107409. program = this.customShader;
  107410. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107411. custom = this._scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107412. }
  107413. else if (this._customEffect) {
  107414. custom = this._customEffect;
  107415. }
  107416. var result = new ParticleSystem(name, this._capacity, this._scene, custom);
  107417. result.customShader = program;
  107418. _Misc_deepCopier__WEBPACK_IMPORTED_MODULE_20__["DeepCopier"].DeepCopy(this, result, ["particles", "customShader", "noiseTexture"]);
  107419. if (newEmitter === undefined) {
  107420. newEmitter = this.emitter;
  107421. }
  107422. result.noiseTexture = this.noiseTexture;
  107423. result.emitter = newEmitter;
  107424. if (this.particleTexture) {
  107425. result.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](this.particleTexture.url, this._scene);
  107426. }
  107427. // Clone gradients
  107428. if (this._colorGradients) {
  107429. this._colorGradients.forEach(function (v) {
  107430. result.addColorGradient(v.gradient, v.color1, v.color2);
  107431. });
  107432. }
  107433. if (this._dragGradients) {
  107434. this._dragGradients.forEach(function (v) {
  107435. result.addDragGradient(v.gradient, v.factor1, v.factor2);
  107436. });
  107437. }
  107438. if (this._angularSpeedGradients) {
  107439. this._angularSpeedGradients.forEach(function (v) {
  107440. result.addAngularSpeedGradient(v.gradient, v.factor1, v.factor2);
  107441. });
  107442. }
  107443. if (this._emitRateGradients) {
  107444. this._emitRateGradients.forEach(function (v) {
  107445. result.addEmitRateGradient(v.gradient, v.factor1, v.factor2);
  107446. });
  107447. }
  107448. if (this._lifeTimeGradients) {
  107449. this._lifeTimeGradients.forEach(function (v) {
  107450. result.addLifeTimeGradient(v.gradient, v.factor1, v.factor2);
  107451. });
  107452. }
  107453. if (this._limitVelocityGradients) {
  107454. this._limitVelocityGradients.forEach(function (v) {
  107455. result.addLimitVelocityGradient(v.gradient, v.factor1, v.factor2);
  107456. });
  107457. }
  107458. if (this._sizeGradients) {
  107459. this._sizeGradients.forEach(function (v) {
  107460. result.addSizeGradient(v.gradient, v.factor1, v.factor2);
  107461. });
  107462. }
  107463. if (this._startSizeGradients) {
  107464. this._startSizeGradients.forEach(function (v) {
  107465. result.addStartSizeGradient(v.gradient, v.factor1, v.factor2);
  107466. });
  107467. }
  107468. if (this._velocityGradients) {
  107469. this._velocityGradients.forEach(function (v) {
  107470. result.addVelocityGradient(v.gradient, v.factor1, v.factor2);
  107471. });
  107472. }
  107473. if (this._rampGradients) {
  107474. this._rampGradients.forEach(function (v) {
  107475. result.addRampGradient(v.gradient, v.color);
  107476. });
  107477. }
  107478. if (this._colorRemapGradients) {
  107479. this._colorRemapGradients.forEach(function (v) {
  107480. result.addColorRemapGradient(v.gradient, v.factor1, v.factor2);
  107481. });
  107482. }
  107483. if (this._alphaRemapGradients) {
  107484. this._alphaRemapGradients.forEach(function (v) {
  107485. result.addAlphaRemapGradient(v.gradient, v.factor1, v.factor2);
  107486. });
  107487. }
  107488. if (!this.preventAutoStart) {
  107489. result.start();
  107490. }
  107491. return result;
  107492. };
  107493. /**
  107494. * Serializes the particle system to a JSON object.
  107495. * @returns the JSON object
  107496. */
  107497. ParticleSystem.prototype.serialize = function () {
  107498. var serializationObject = {};
  107499. ParticleSystem._Serialize(serializationObject, this);
  107500. serializationObject.textureMask = this.textureMask.asArray();
  107501. serializationObject.customShader = this.customShader;
  107502. serializationObject.preventAutoStart = this.preventAutoStart;
  107503. // SubEmitters
  107504. if (this.subEmitters) {
  107505. serializationObject.subEmitters = [];
  107506. if (!this._subEmitters) {
  107507. this._prepareSubEmitterInternalArray();
  107508. }
  107509. for (var _i = 0, _a = this._subEmitters; _i < _a.length; _i++) {
  107510. var subs = _a[_i];
  107511. var cell = [];
  107512. for (var _b = 0, subs_1 = subs; _b < subs_1.length; _b++) {
  107513. var sub = subs_1[_b];
  107514. cell.push(sub.serialize());
  107515. }
  107516. serializationObject.subEmitters.push(cell);
  107517. }
  107518. }
  107519. return serializationObject;
  107520. };
  107521. /** @hidden */
  107522. ParticleSystem._Serialize = function (serializationObject, particleSystem) {
  107523. serializationObject.name = particleSystem.name;
  107524. serializationObject.id = particleSystem.id;
  107525. serializationObject.capacity = particleSystem.getCapacity();
  107526. // Emitter
  107527. if (particleSystem.emitter.position) {
  107528. var emitterMesh = particleSystem.emitter;
  107529. serializationObject.emitterId = emitterMesh.id;
  107530. }
  107531. else {
  107532. var emitterPosition = particleSystem.emitter;
  107533. serializationObject.emitter = emitterPosition.asArray();
  107534. }
  107535. // Emitter
  107536. if (particleSystem.particleEmitterType) {
  107537. serializationObject.particleEmitterType = particleSystem.particleEmitterType.serialize();
  107538. }
  107539. if (particleSystem.particleTexture) {
  107540. serializationObject.textureName = particleSystem.particleTexture.name;
  107541. serializationObject.invertY = particleSystem.particleTexture._invertY;
  107542. }
  107543. // Animations
  107544. _Misc_decorators__WEBPACK_IMPORTED_MODULE_19__["SerializationHelper"].AppendSerializedAnimations(particleSystem, serializationObject);
  107545. serializationObject.beginAnimationOnStart = particleSystem.beginAnimationOnStart;
  107546. serializationObject.beginAnimationFrom = particleSystem.beginAnimationFrom;
  107547. serializationObject.beginAnimationTo = particleSystem.beginAnimationTo;
  107548. serializationObject.beginAnimationLoop = particleSystem.beginAnimationLoop;
  107549. // Particle system
  107550. serializationObject.startDelay = particleSystem.startDelay;
  107551. serializationObject.renderingGroupId = particleSystem.renderingGroupId;
  107552. serializationObject.isBillboardBased = particleSystem.isBillboardBased;
  107553. serializationObject.billboardMode = particleSystem.billboardMode;
  107554. serializationObject.minAngularSpeed = particleSystem.minAngularSpeed;
  107555. serializationObject.maxAngularSpeed = particleSystem.maxAngularSpeed;
  107556. serializationObject.minSize = particleSystem.minSize;
  107557. serializationObject.maxSize = particleSystem.maxSize;
  107558. serializationObject.minScaleX = particleSystem.minScaleX;
  107559. serializationObject.maxScaleX = particleSystem.maxScaleX;
  107560. serializationObject.minScaleY = particleSystem.minScaleY;
  107561. serializationObject.maxScaleY = particleSystem.maxScaleY;
  107562. serializationObject.minEmitPower = particleSystem.minEmitPower;
  107563. serializationObject.maxEmitPower = particleSystem.maxEmitPower;
  107564. serializationObject.minLifeTime = particleSystem.minLifeTime;
  107565. serializationObject.maxLifeTime = particleSystem.maxLifeTime;
  107566. serializationObject.emitRate = particleSystem.emitRate;
  107567. serializationObject.gravity = particleSystem.gravity.asArray();
  107568. serializationObject.noiseStrength = particleSystem.noiseStrength.asArray();
  107569. serializationObject.color1 = particleSystem.color1.asArray();
  107570. serializationObject.color2 = particleSystem.color2.asArray();
  107571. serializationObject.colorDead = particleSystem.colorDead.asArray();
  107572. serializationObject.updateSpeed = particleSystem.updateSpeed;
  107573. serializationObject.targetStopDuration = particleSystem.targetStopDuration;
  107574. serializationObject.blendMode = particleSystem.blendMode;
  107575. serializationObject.preWarmCycles = particleSystem.preWarmCycles;
  107576. serializationObject.preWarmStepOffset = particleSystem.preWarmStepOffset;
  107577. serializationObject.minInitialRotation = particleSystem.minInitialRotation;
  107578. serializationObject.maxInitialRotation = particleSystem.maxInitialRotation;
  107579. serializationObject.startSpriteCellID = particleSystem.startSpriteCellID;
  107580. serializationObject.endSpriteCellID = particleSystem.endSpriteCellID;
  107581. serializationObject.spriteCellChangeSpeed = particleSystem.spriteCellChangeSpeed;
  107582. serializationObject.spriteCellWidth = particleSystem.spriteCellWidth;
  107583. serializationObject.spriteCellHeight = particleSystem.spriteCellHeight;
  107584. serializationObject.spriteRandomStartCell = particleSystem.spriteRandomStartCell;
  107585. serializationObject.isAnimationSheetEnabled = particleSystem.isAnimationSheetEnabled;
  107586. var colorGradients = particleSystem.getColorGradients();
  107587. if (colorGradients) {
  107588. serializationObject.colorGradients = [];
  107589. for (var _i = 0, colorGradients_1 = colorGradients; _i < colorGradients_1.length; _i++) {
  107590. var colorGradient = colorGradients_1[_i];
  107591. var serializedGradient = {
  107592. gradient: colorGradient.gradient,
  107593. color1: colorGradient.color1.asArray()
  107594. };
  107595. if (colorGradient.color2) {
  107596. serializedGradient.color2 = colorGradient.color2.asArray();
  107597. }
  107598. serializationObject.colorGradients.push(serializedGradient);
  107599. }
  107600. }
  107601. var rampGradients = particleSystem.getRampGradients();
  107602. if (rampGradients) {
  107603. serializationObject.rampGradients = [];
  107604. for (var _a = 0, rampGradients_1 = rampGradients; _a < rampGradients_1.length; _a++) {
  107605. var rampGradient = rampGradients_1[_a];
  107606. var serializedGradient = {
  107607. gradient: rampGradient.gradient,
  107608. color: rampGradient.color.asArray()
  107609. };
  107610. serializationObject.rampGradients.push(serializedGradient);
  107611. }
  107612. serializationObject.useRampGradients = particleSystem.useRampGradients;
  107613. }
  107614. var colorRemapGradients = particleSystem.getColorRemapGradients();
  107615. if (colorRemapGradients) {
  107616. serializationObject.colorRemapGradients = [];
  107617. for (var _b = 0, colorRemapGradients_1 = colorRemapGradients; _b < colorRemapGradients_1.length; _b++) {
  107618. var colorRemapGradient = colorRemapGradients_1[_b];
  107619. var serializedGradient = {
  107620. gradient: colorRemapGradient.gradient,
  107621. factor1: colorRemapGradient.factor1
  107622. };
  107623. if (colorRemapGradient.factor2 !== undefined) {
  107624. serializedGradient.factor2 = colorRemapGradient.factor2;
  107625. }
  107626. serializationObject.colorRemapGradients.push(serializedGradient);
  107627. }
  107628. }
  107629. var alphaRemapGradients = particleSystem.getAlphaRemapGradients();
  107630. if (alphaRemapGradients) {
  107631. serializationObject.alphaRemapGradients = [];
  107632. for (var _c = 0, alphaRemapGradients_1 = alphaRemapGradients; _c < alphaRemapGradients_1.length; _c++) {
  107633. var alphaRemapGradient = alphaRemapGradients_1[_c];
  107634. var serializedGradient = {
  107635. gradient: alphaRemapGradient.gradient,
  107636. factor1: alphaRemapGradient.factor1
  107637. };
  107638. if (alphaRemapGradient.factor2 !== undefined) {
  107639. serializedGradient.factor2 = alphaRemapGradient.factor2;
  107640. }
  107641. serializationObject.alphaRemapGradients.push(serializedGradient);
  107642. }
  107643. }
  107644. var sizeGradients = particleSystem.getSizeGradients();
  107645. if (sizeGradients) {
  107646. serializationObject.sizeGradients = [];
  107647. for (var _d = 0, sizeGradients_1 = sizeGradients; _d < sizeGradients_1.length; _d++) {
  107648. var sizeGradient = sizeGradients_1[_d];
  107649. var serializedGradient = {
  107650. gradient: sizeGradient.gradient,
  107651. factor1: sizeGradient.factor1
  107652. };
  107653. if (sizeGradient.factor2 !== undefined) {
  107654. serializedGradient.factor2 = sizeGradient.factor2;
  107655. }
  107656. serializationObject.sizeGradients.push(serializedGradient);
  107657. }
  107658. }
  107659. var angularSpeedGradients = particleSystem.getAngularSpeedGradients();
  107660. if (angularSpeedGradients) {
  107661. serializationObject.angularSpeedGradients = [];
  107662. for (var _e = 0, angularSpeedGradients_1 = angularSpeedGradients; _e < angularSpeedGradients_1.length; _e++) {
  107663. var angularSpeedGradient = angularSpeedGradients_1[_e];
  107664. var serializedGradient = {
  107665. gradient: angularSpeedGradient.gradient,
  107666. factor1: angularSpeedGradient.factor1
  107667. };
  107668. if (angularSpeedGradient.factor2 !== undefined) {
  107669. serializedGradient.factor2 = angularSpeedGradient.factor2;
  107670. }
  107671. serializationObject.angularSpeedGradients.push(serializedGradient);
  107672. }
  107673. }
  107674. var velocityGradients = particleSystem.getVelocityGradients();
  107675. if (velocityGradients) {
  107676. serializationObject.velocityGradients = [];
  107677. for (var _f = 0, velocityGradients_1 = velocityGradients; _f < velocityGradients_1.length; _f++) {
  107678. var velocityGradient = velocityGradients_1[_f];
  107679. var serializedGradient = {
  107680. gradient: velocityGradient.gradient,
  107681. factor1: velocityGradient.factor1
  107682. };
  107683. if (velocityGradient.factor2 !== undefined) {
  107684. serializedGradient.factor2 = velocityGradient.factor2;
  107685. }
  107686. serializationObject.velocityGradients.push(serializedGradient);
  107687. }
  107688. }
  107689. var dragGradients = particleSystem.getDragGradients();
  107690. if (dragGradients) {
  107691. serializationObject.dragyGradients = [];
  107692. for (var _g = 0, dragGradients_1 = dragGradients; _g < dragGradients_1.length; _g++) {
  107693. var dragGradient = dragGradients_1[_g];
  107694. var serializedGradient = {
  107695. gradient: dragGradient.gradient,
  107696. factor1: dragGradient.factor1
  107697. };
  107698. if (dragGradient.factor2 !== undefined) {
  107699. serializedGradient.factor2 = dragGradient.factor2;
  107700. }
  107701. serializationObject.dragGradients.push(serializedGradient);
  107702. }
  107703. }
  107704. var emitRateGradients = particleSystem.getEmitRateGradients();
  107705. if (emitRateGradients) {
  107706. serializationObject.emitRateGradients = [];
  107707. for (var _h = 0, emitRateGradients_1 = emitRateGradients; _h < emitRateGradients_1.length; _h++) {
  107708. var emitRateGradient = emitRateGradients_1[_h];
  107709. var serializedGradient = {
  107710. gradient: emitRateGradient.gradient,
  107711. factor1: emitRateGradient.factor1
  107712. };
  107713. if (emitRateGradient.factor2 !== undefined) {
  107714. serializedGradient.factor2 = emitRateGradient.factor2;
  107715. }
  107716. serializationObject.emitRateGradients.push(serializedGradient);
  107717. }
  107718. }
  107719. var startSizeGradients = particleSystem.getStartSizeGradients();
  107720. if (startSizeGradients) {
  107721. serializationObject.startSizeGradients = [];
  107722. for (var _j = 0, startSizeGradients_1 = startSizeGradients; _j < startSizeGradients_1.length; _j++) {
  107723. var startSizeGradient = startSizeGradients_1[_j];
  107724. var serializedGradient = {
  107725. gradient: startSizeGradient.gradient,
  107726. factor1: startSizeGradient.factor1
  107727. };
  107728. if (startSizeGradient.factor2 !== undefined) {
  107729. serializedGradient.factor2 = startSizeGradient.factor2;
  107730. }
  107731. serializationObject.startSizeGradients.push(serializedGradient);
  107732. }
  107733. }
  107734. var lifeTimeGradients = particleSystem.getLifeTimeGradients();
  107735. if (lifeTimeGradients) {
  107736. serializationObject.lifeTimeGradients = [];
  107737. for (var _k = 0, lifeTimeGradients_1 = lifeTimeGradients; _k < lifeTimeGradients_1.length; _k++) {
  107738. var lifeTimeGradient = lifeTimeGradients_1[_k];
  107739. var serializedGradient = {
  107740. gradient: lifeTimeGradient.gradient,
  107741. factor1: lifeTimeGradient.factor1
  107742. };
  107743. if (lifeTimeGradient.factor2 !== undefined) {
  107744. serializedGradient.factor2 = lifeTimeGradient.factor2;
  107745. }
  107746. serializationObject.lifeTimeGradients.push(serializedGradient);
  107747. }
  107748. }
  107749. var limitVelocityGradients = particleSystem.getLimitVelocityGradients();
  107750. if (limitVelocityGradients) {
  107751. serializationObject.limitVelocityGradients = [];
  107752. for (var _l = 0, limitVelocityGradients_1 = limitVelocityGradients; _l < limitVelocityGradients_1.length; _l++) {
  107753. var limitVelocityGradient = limitVelocityGradients_1[_l];
  107754. var serializedGradient = {
  107755. gradient: limitVelocityGradient.gradient,
  107756. factor1: limitVelocityGradient.factor1
  107757. };
  107758. if (limitVelocityGradient.factor2 !== undefined) {
  107759. serializedGradient.factor2 = limitVelocityGradient.factor2;
  107760. }
  107761. serializationObject.limitVelocityGradients.push(serializedGradient);
  107762. }
  107763. serializationObject.limitVelocityDamping = particleSystem.limitVelocityDamping;
  107764. }
  107765. if (particleSystem.noiseTexture) {
  107766. serializationObject.noiseTexture = particleSystem.noiseTexture.serialize();
  107767. }
  107768. };
  107769. /** @hidden */
  107770. ParticleSystem._Parse = function (parsedParticleSystem, particleSystem, scene, rootUrl) {
  107771. // Texture
  107772. if (parsedParticleSystem.textureName) {
  107773. particleSystem.particleTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_10__["Texture"](rootUrl + parsedParticleSystem.textureName, scene, false, parsedParticleSystem.invertY !== undefined ? parsedParticleSystem.invertY : true);
  107774. particleSystem.particleTexture.name = parsedParticleSystem.textureName;
  107775. }
  107776. // Emitter
  107777. if (!parsedParticleSystem.emitterId && parsedParticleSystem.emitterId !== 0 && parsedParticleSystem.emitter === undefined) {
  107778. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  107779. }
  107780. else if (parsedParticleSystem.emitterId) {
  107781. particleSystem.emitter = scene.getLastMeshByID(parsedParticleSystem.emitterId);
  107782. }
  107783. else {
  107784. particleSystem.emitter = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.emitter);
  107785. }
  107786. // Misc.
  107787. if (parsedParticleSystem.renderingGroupId !== undefined) {
  107788. particleSystem.renderingGroupId = parsedParticleSystem.renderingGroupId;
  107789. }
  107790. if (parsedParticleSystem.isBillboardBased !== undefined) {
  107791. particleSystem.isBillboardBased = parsedParticleSystem.isBillboardBased;
  107792. }
  107793. if (parsedParticleSystem.billboardMode !== undefined) {
  107794. particleSystem.billboardMode = parsedParticleSystem.billboardMode;
  107795. }
  107796. // Animations
  107797. if (parsedParticleSystem.animations) {
  107798. for (var animationIndex = 0; animationIndex < parsedParticleSystem.animations.length; animationIndex++) {
  107799. var parsedAnimation = parsedParticleSystem.animations[animationIndex];
  107800. var internalClass = _Misc_typeStore__WEBPACK_IMPORTED_MODULE_21__["_TypeStore"].GetClass("BABYLON.Animation");
  107801. if (internalClass) {
  107802. particleSystem.animations.push(internalClass.Parse(parsedAnimation));
  107803. }
  107804. }
  107805. particleSystem.beginAnimationOnStart = parsedParticleSystem.beginAnimationOnStart;
  107806. particleSystem.beginAnimationFrom = parsedParticleSystem.beginAnimationFrom;
  107807. particleSystem.beginAnimationTo = parsedParticleSystem.beginAnimationTo;
  107808. particleSystem.beginAnimationLoop = parsedParticleSystem.beginAnimationLoop;
  107809. }
  107810. if (parsedParticleSystem.autoAnimate) {
  107811. scene.beginAnimation(particleSystem, parsedParticleSystem.autoAnimateFrom, parsedParticleSystem.autoAnimateTo, parsedParticleSystem.autoAnimateLoop, parsedParticleSystem.autoAnimateSpeed || 1.0);
  107812. }
  107813. // Particle system
  107814. particleSystem.startDelay = parsedParticleSystem.startDelay | 0;
  107815. particleSystem.minAngularSpeed = parsedParticleSystem.minAngularSpeed;
  107816. particleSystem.maxAngularSpeed = parsedParticleSystem.maxAngularSpeed;
  107817. particleSystem.minSize = parsedParticleSystem.minSize;
  107818. particleSystem.maxSize = parsedParticleSystem.maxSize;
  107819. if (parsedParticleSystem.minScaleX) {
  107820. particleSystem.minScaleX = parsedParticleSystem.minScaleX;
  107821. particleSystem.maxScaleX = parsedParticleSystem.maxScaleX;
  107822. particleSystem.minScaleY = parsedParticleSystem.minScaleY;
  107823. particleSystem.maxScaleY = parsedParticleSystem.maxScaleY;
  107824. }
  107825. if (parsedParticleSystem.preWarmCycles !== undefined) {
  107826. particleSystem.preWarmCycles = parsedParticleSystem.preWarmCycles;
  107827. particleSystem.preWarmStepOffset = parsedParticleSystem.preWarmStepOffset;
  107828. }
  107829. if (parsedParticleSystem.minInitialRotation !== undefined) {
  107830. particleSystem.minInitialRotation = parsedParticleSystem.minInitialRotation;
  107831. particleSystem.maxInitialRotation = parsedParticleSystem.maxInitialRotation;
  107832. }
  107833. particleSystem.minLifeTime = parsedParticleSystem.minLifeTime;
  107834. particleSystem.maxLifeTime = parsedParticleSystem.maxLifeTime;
  107835. particleSystem.minEmitPower = parsedParticleSystem.minEmitPower;
  107836. particleSystem.maxEmitPower = parsedParticleSystem.maxEmitPower;
  107837. particleSystem.emitRate = parsedParticleSystem.emitRate;
  107838. particleSystem.gravity = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.gravity);
  107839. if (parsedParticleSystem.noiseStrength) {
  107840. particleSystem.noiseStrength = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].FromArray(parsedParticleSystem.noiseStrength);
  107841. }
  107842. particleSystem.color1 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color1);
  107843. particleSystem.color2 = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.color2);
  107844. particleSystem.colorDead = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.colorDead);
  107845. particleSystem.updateSpeed = parsedParticleSystem.updateSpeed;
  107846. particleSystem.targetStopDuration = parsedParticleSystem.targetStopDuration;
  107847. particleSystem.blendMode = parsedParticleSystem.blendMode;
  107848. if (parsedParticleSystem.colorGradients) {
  107849. for (var _i = 0, _a = parsedParticleSystem.colorGradients; _i < _a.length; _i++) {
  107850. var colorGradient = _a[_i];
  107851. 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);
  107852. }
  107853. }
  107854. if (parsedParticleSystem.rampGradients) {
  107855. for (var _b = 0, _c = parsedParticleSystem.rampGradients; _b < _c.length; _b++) {
  107856. var rampGradient = _c[_b];
  107857. particleSystem.addRampGradient(rampGradient.gradient, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"].FromArray(rampGradient.color));
  107858. }
  107859. particleSystem.useRampGradients = parsedParticleSystem.useRampGradients;
  107860. }
  107861. if (parsedParticleSystem.colorRemapGradients) {
  107862. for (var _d = 0, _e = parsedParticleSystem.colorRemapGradients; _d < _e.length; _d++) {
  107863. var colorRemapGradient = _e[_d];
  107864. particleSystem.addColorRemapGradient(colorRemapGradient.gradient, colorRemapGradient.factor1 !== undefined ? colorRemapGradient.factor1 : colorRemapGradient.factor, colorRemapGradient.factor2);
  107865. }
  107866. }
  107867. if (parsedParticleSystem.alphaRemapGradients) {
  107868. for (var _f = 0, _g = parsedParticleSystem.alphaRemapGradients; _f < _g.length; _f++) {
  107869. var alphaRemapGradient = _g[_f];
  107870. particleSystem.addAlphaRemapGradient(alphaRemapGradient.gradient, alphaRemapGradient.factor1 !== undefined ? alphaRemapGradient.factor1 : alphaRemapGradient.factor, alphaRemapGradient.factor2);
  107871. }
  107872. }
  107873. if (parsedParticleSystem.sizeGradients) {
  107874. for (var _h = 0, _j = parsedParticleSystem.sizeGradients; _h < _j.length; _h++) {
  107875. var sizeGradient = _j[_h];
  107876. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107877. }
  107878. }
  107879. if (parsedParticleSystem.sizeGradients) {
  107880. for (var _k = 0, _l = parsedParticleSystem.sizeGradients; _k < _l.length; _k++) {
  107881. var sizeGradient = _l[_k];
  107882. particleSystem.addSizeGradient(sizeGradient.gradient, sizeGradient.factor1 !== undefined ? sizeGradient.factor1 : sizeGradient.factor, sizeGradient.factor2);
  107883. }
  107884. }
  107885. if (parsedParticleSystem.angularSpeedGradients) {
  107886. for (var _m = 0, _o = parsedParticleSystem.angularSpeedGradients; _m < _o.length; _m++) {
  107887. var angularSpeedGradient = _o[_m];
  107888. particleSystem.addAngularSpeedGradient(angularSpeedGradient.gradient, angularSpeedGradient.factor1 !== undefined ? angularSpeedGradient.factor1 : angularSpeedGradient.factor, angularSpeedGradient.factor2);
  107889. }
  107890. }
  107891. if (parsedParticleSystem.velocityGradients) {
  107892. for (var _p = 0, _q = parsedParticleSystem.velocityGradients; _p < _q.length; _p++) {
  107893. var velocityGradient = _q[_p];
  107894. particleSystem.addVelocityGradient(velocityGradient.gradient, velocityGradient.factor1 !== undefined ? velocityGradient.factor1 : velocityGradient.factor, velocityGradient.factor2);
  107895. }
  107896. }
  107897. if (parsedParticleSystem.dragGradients) {
  107898. for (var _r = 0, _s = parsedParticleSystem.dragGradients; _r < _s.length; _r++) {
  107899. var dragGradient = _s[_r];
  107900. particleSystem.addDragGradient(dragGradient.gradient, dragGradient.factor1 !== undefined ? dragGradient.factor1 : dragGradient.factor, dragGradient.factor2);
  107901. }
  107902. }
  107903. if (parsedParticleSystem.emitRateGradients) {
  107904. for (var _t = 0, _u = parsedParticleSystem.emitRateGradients; _t < _u.length; _t++) {
  107905. var emitRateGradient = _u[_t];
  107906. particleSystem.addEmitRateGradient(emitRateGradient.gradient, emitRateGradient.factor1 !== undefined ? emitRateGradient.factor1 : emitRateGradient.factor, emitRateGradient.factor2);
  107907. }
  107908. }
  107909. if (parsedParticleSystem.startSizeGradients) {
  107910. for (var _v = 0, _w = parsedParticleSystem.startSizeGradients; _v < _w.length; _v++) {
  107911. var startSizeGradient = _w[_v];
  107912. particleSystem.addStartSizeGradient(startSizeGradient.gradient, startSizeGradient.factor1 !== undefined ? startSizeGradient.factor1 : startSizeGradient.factor, startSizeGradient.factor2);
  107913. }
  107914. }
  107915. if (parsedParticleSystem.lifeTimeGradients) {
  107916. for (var _x = 0, _y = parsedParticleSystem.lifeTimeGradients; _x < _y.length; _x++) {
  107917. var lifeTimeGradient = _y[_x];
  107918. particleSystem.addLifeTimeGradient(lifeTimeGradient.gradient, lifeTimeGradient.factor1 !== undefined ? lifeTimeGradient.factor1 : lifeTimeGradient.factor, lifeTimeGradient.factor2);
  107919. }
  107920. }
  107921. if (parsedParticleSystem.limitVelocityGradients) {
  107922. for (var _z = 0, _0 = parsedParticleSystem.limitVelocityGradients; _z < _0.length; _z++) {
  107923. var limitVelocityGradient = _0[_z];
  107924. particleSystem.addLimitVelocityGradient(limitVelocityGradient.gradient, limitVelocityGradient.factor1 !== undefined ? limitVelocityGradient.factor1 : limitVelocityGradient.factor, limitVelocityGradient.factor2);
  107925. }
  107926. particleSystem.limitVelocityDamping = parsedParticleSystem.limitVelocityDamping;
  107927. }
  107928. if (parsedParticleSystem.noiseTexture) {
  107929. particleSystem.noiseTexture = _Materials_Textures_Procedurals_proceduralTexture__WEBPACK_IMPORTED_MODULE_12__["ProceduralTexture"].Parse(parsedParticleSystem.noiseTexture, scene, rootUrl);
  107930. }
  107931. // Emitter
  107932. var emitterType;
  107933. if (parsedParticleSystem.particleEmitterType) {
  107934. switch (parsedParticleSystem.particleEmitterType.type) {
  107935. case "SphereParticleEmitter":
  107936. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereParticleEmitter"]();
  107937. break;
  107938. case "SphereDirectedParticleEmitter":
  107939. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["SphereDirectedParticleEmitter"]();
  107940. break;
  107941. case "ConeEmitter":
  107942. case "ConeParticleEmitter":
  107943. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["ConeParticleEmitter"]();
  107944. break;
  107945. case "CylinderParticleEmitter":
  107946. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["CylinderParticleEmitter"]();
  107947. break;
  107948. case "HemisphericParticleEmitter":
  107949. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["HemisphericParticleEmitter"]();
  107950. break;
  107951. case "BoxEmitter":
  107952. case "BoxParticleEmitter":
  107953. default:
  107954. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107955. break;
  107956. }
  107957. emitterType.parse(parsedParticleSystem.particleEmitterType);
  107958. }
  107959. else {
  107960. emitterType = new _Particles_EmitterTypes_index__WEBPACK_IMPORTED_MODULE_14__["BoxParticleEmitter"]();
  107961. emitterType.parse(parsedParticleSystem);
  107962. }
  107963. particleSystem.particleEmitterType = emitterType;
  107964. // Animation sheet
  107965. particleSystem.startSpriteCellID = parsedParticleSystem.startSpriteCellID;
  107966. particleSystem.endSpriteCellID = parsedParticleSystem.endSpriteCellID;
  107967. particleSystem.spriteCellWidth = parsedParticleSystem.spriteCellWidth;
  107968. particleSystem.spriteCellHeight = parsedParticleSystem.spriteCellHeight;
  107969. particleSystem.spriteCellChangeSpeed = parsedParticleSystem.spriteCellChangeSpeed;
  107970. particleSystem.spriteRandomStartCell = parsedParticleSystem.spriteRandomStartCell;
  107971. };
  107972. /**
  107973. * Parses a JSON object to create a particle system.
  107974. * @param parsedParticleSystem The JSON object to parse
  107975. * @param scene The scene to create the particle system in
  107976. * @param rootUrl The root url to use to load external dependencies like texture
  107977. * @param doNotStart Ignore the preventAutoStart attribute and does not start
  107978. * @returns the Parsed particle system
  107979. */
  107980. ParticleSystem.Parse = function (parsedParticleSystem, scene, rootUrl, doNotStart) {
  107981. if (doNotStart === void 0) { doNotStart = false; }
  107982. var name = parsedParticleSystem.name;
  107983. var custom = null;
  107984. var program = null;
  107985. if (parsedParticleSystem.customShader) {
  107986. program = parsedParticleSystem.customShader;
  107987. var defines = (program.shaderOptions.defines.length > 0) ? program.shaderOptions.defines.join("\n") : "";
  107988. custom = scene.getEngine().createEffectForParticles(program.shaderPath.fragmentElement, program.shaderOptions.uniforms, program.shaderOptions.samplers, defines);
  107989. }
  107990. var particleSystem = new ParticleSystem(name, parsedParticleSystem.capacity, scene, custom, parsedParticleSystem.isAnimationSheetEnabled);
  107991. particleSystem.customShader = program;
  107992. if (parsedParticleSystem.id) {
  107993. particleSystem.id = parsedParticleSystem.id;
  107994. }
  107995. // SubEmitters
  107996. if (parsedParticleSystem.subEmitters) {
  107997. particleSystem.subEmitters = [];
  107998. for (var _i = 0, _a = parsedParticleSystem.subEmitters; _i < _a.length; _i++) {
  107999. var cell = _a[_i];
  108000. var cellArray = [];
  108001. for (var _b = 0, cell_1 = cell; _b < cell_1.length; _b++) {
  108002. var sub = cell_1[_b];
  108003. cellArray.push(_subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"].Parse(sub, scene, rootUrl));
  108004. }
  108005. particleSystem.subEmitters.push(cellArray);
  108006. }
  108007. }
  108008. ParticleSystem._Parse(parsedParticleSystem, particleSystem, scene, rootUrl);
  108009. particleSystem.textureMask = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"].FromArray(parsedParticleSystem.textureMask);
  108010. // Auto start
  108011. if (parsedParticleSystem.preventAutoStart) {
  108012. particleSystem.preventAutoStart = parsedParticleSystem.preventAutoStart;
  108013. }
  108014. if (!doNotStart && !particleSystem.preventAutoStart) {
  108015. particleSystem.start();
  108016. }
  108017. return particleSystem;
  108018. };
  108019. /**
  108020. * Billboard mode will only apply to Y axis
  108021. */
  108022. ParticleSystem.BILLBOARDMODE_Y = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_Y;
  108023. /**
  108024. * Billboard mode will apply to all axes
  108025. */
  108026. ParticleSystem.BILLBOARDMODE_ALL = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_ALL;
  108027. /**
  108028. * Special billboard mode where the particle will be biilboard to the camera but rotated to align with direction
  108029. */
  108030. ParticleSystem.BILLBOARDMODE_STRETCHED = _Engines_constants__WEBPACK_IMPORTED_MODULE_18__["Constants"].PARTICLES_BILLBOARDMODE_STRETCHED;
  108031. return ParticleSystem;
  108032. }(_baseParticleSystem__WEBPACK_IMPORTED_MODULE_15__["BaseParticleSystem"]));
  108033. _subEmitter__WEBPACK_IMPORTED_MODULE_17__["SubEmitter"]._ParseParticleSystem = ParticleSystem.Parse;
  108034. /***/ }),
  108035. /***/ "./Particles/particleSystemComponent.ts":
  108036. /*!**********************************************!*\
  108037. !*** ./Particles/particleSystemComponent.ts ***!
  108038. \**********************************************/
  108039. /*! exports provided: _IDoNeedToBeInTheBuild */
  108040. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108041. "use strict";
  108042. __webpack_require__.r(__webpack_exports__);
  108043. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _IDoNeedToBeInTheBuild; });
  108044. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108045. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108046. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  108047. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  108048. /* harmony import */ var _particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./particleSystem */ "./Particles/particleSystem.ts");
  108049. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  108050. /* harmony import */ var _Shaders_particles_vertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/particles.vertex */ "./Shaders/particles.vertex.ts");
  108051. // Adds the parsers to the scene parsers.
  108052. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedData, scene, container, rootUrl) {
  108053. var individualParser = _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].GetIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM);
  108054. if (!individualParser) {
  108055. return;
  108056. }
  108057. // Particles Systems
  108058. if (parsedData.particleSystems !== undefined && parsedData.particleSystems !== null) {
  108059. for (var index = 0, cache = parsedData.particleSystems.length; index < cache; index++) {
  108060. var parsedParticleSystem = parsedData.particleSystems[index];
  108061. container.particleSystems.push(individualParser(parsedParticleSystem, scene, rootUrl));
  108062. }
  108063. }
  108064. });
  108065. _abstractScene__WEBPACK_IMPORTED_MODULE_2__["AbstractScene"].AddIndividualParser(_sceneComponent__WEBPACK_IMPORTED_MODULE_5__["SceneComponentConstants"].NAME_PARTICLESYSTEM, function (parsedParticleSystem, scene, rootUrl) {
  108066. if (parsedParticleSystem.activeParticleCount) {
  108067. var ps = _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_1__["GPUParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  108068. return ps;
  108069. }
  108070. else {
  108071. var ps = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"].Parse(parsedParticleSystem, scene, rootUrl);
  108072. return ps;
  108073. }
  108074. });
  108075. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"].prototype.createEffectForParticles = function (fragmentName, uniformsNames, samplers, defines, fallbacks, onCompiled, onError) {
  108076. if (uniformsNames === void 0) { uniformsNames = []; }
  108077. if (samplers === void 0) { samplers = []; }
  108078. if (defines === void 0) { defines = ""; }
  108079. var attributesNamesOrOptions = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetAttributeNamesOrOptions();
  108080. var effectCreationOption = _particleSystem__WEBPACK_IMPORTED_MODULE_4__["ParticleSystem"]._GetEffectCreationOptions();
  108081. if (defines.indexOf(" BILLBOARD") === -1) {
  108082. defines += "\n#define BILLBOARD\n";
  108083. }
  108084. if (samplers.indexOf("diffuseSampler") === -1) {
  108085. samplers.push("diffuseSampler");
  108086. }
  108087. return this.createEffect({
  108088. vertex: "particles",
  108089. fragmentElement: fragmentName
  108090. }, attributesNamesOrOptions, effectCreationOption.concat(uniformsNames), samplers, defines, fallbacks, onCompiled, onError);
  108091. };
  108092. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getEmittedParticleSystems = function () {
  108093. var results = new Array();
  108094. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  108095. var particleSystem = this.getScene().particleSystems[index];
  108096. if (particleSystem.emitter === this) {
  108097. results.push(particleSystem);
  108098. }
  108099. }
  108100. return results;
  108101. };
  108102. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_0__["Mesh"].prototype.getHierarchyEmittedParticleSystems = function () {
  108103. var results = new Array();
  108104. var descendants = this.getDescendants();
  108105. descendants.push(this);
  108106. for (var index = 0; index < this.getScene().particleSystems.length; index++) {
  108107. var particleSystem = this.getScene().particleSystems[index];
  108108. var emitter = particleSystem.emitter;
  108109. if (emitter.position && descendants.indexOf(emitter) !== -1) {
  108110. results.push(particleSystem);
  108111. }
  108112. }
  108113. return results;
  108114. };
  108115. /**
  108116. * @hidden
  108117. */
  108118. var _IDoNeedToBeInTheBuild = 42;
  108119. /***/ }),
  108120. /***/ "./Particles/particleSystemSet.ts":
  108121. /*!****************************************!*\
  108122. !*** ./Particles/particleSystemSet.ts ***!
  108123. \****************************************/
  108124. /*! exports provided: ParticleSystemSet */
  108125. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108126. "use strict";
  108127. __webpack_require__.r(__webpack_exports__);
  108128. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return ParticleSystemSet; });
  108129. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108130. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  108131. /* harmony import */ var _gpuParticleSystem__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./gpuParticleSystem */ "./Particles/gpuParticleSystem.ts");
  108132. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108133. /* harmony import */ var _Particles_particleSystem__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Particles/particleSystem */ "./Particles/particleSystem.ts");
  108134. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  108135. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  108136. /** Internal class used to store shapes for emitters */
  108137. var ParticleSystemSetEmitterCreationOptions = /** @class */ (function () {
  108138. function ParticleSystemSetEmitterCreationOptions() {
  108139. }
  108140. return ParticleSystemSetEmitterCreationOptions;
  108141. }());
  108142. /**
  108143. * Represents a set of particle systems working together to create a specific effect
  108144. */
  108145. var ParticleSystemSet = /** @class */ (function () {
  108146. function ParticleSystemSet() {
  108147. /**
  108148. * Gets the particle system list
  108149. */
  108150. this.systems = new Array();
  108151. }
  108152. Object.defineProperty(ParticleSystemSet.prototype, "emitterNode", {
  108153. /**
  108154. * Gets the emitter node used with this set
  108155. */
  108156. get: function () {
  108157. return this._emitterNode;
  108158. },
  108159. enumerable: true,
  108160. configurable: true
  108161. });
  108162. /**
  108163. * Creates a new emitter mesh as a sphere
  108164. * @param options defines the options used to create the sphere
  108165. * @param renderingGroupId defines the renderingGroupId to use for the sphere
  108166. * @param scene defines the hosting scene
  108167. */
  108168. ParticleSystemSet.prototype.setEmitterAsSphere = function (options, renderingGroupId, scene) {
  108169. if (this._emitterNode) {
  108170. this._emitterNode.dispose();
  108171. }
  108172. this._emitterCreationOptions = {
  108173. kind: "Sphere",
  108174. options: options,
  108175. renderingGroupId: renderingGroupId
  108176. };
  108177. var emitterMesh = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_1__["SphereBuilder"].CreateSphere("emitterSphere", { diameter: options.diameter, segments: options.segments }, scene);
  108178. emitterMesh.renderingGroupId = renderingGroupId;
  108179. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_5__["StandardMaterial"]("emitterSphereMaterial", scene);
  108180. material.emissiveColor = options.color;
  108181. emitterMesh.material = material;
  108182. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  108183. var system = _a[_i];
  108184. system.emitter = emitterMesh;
  108185. }
  108186. this._emitterNode = emitterMesh;
  108187. };
  108188. /**
  108189. * Starts all particle systems of the set
  108190. * @param emitter defines an optional mesh to use as emitter for the particle systems
  108191. */
  108192. ParticleSystemSet.prototype.start = function (emitter) {
  108193. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  108194. var system = _a[_i];
  108195. if (emitter) {
  108196. system.emitter = emitter;
  108197. }
  108198. system.start();
  108199. }
  108200. };
  108201. /**
  108202. * Release all associated resources
  108203. */
  108204. ParticleSystemSet.prototype.dispose = function () {
  108205. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  108206. var system = _a[_i];
  108207. system.dispose();
  108208. }
  108209. this.systems = [];
  108210. if (this._emitterNode) {
  108211. this._emitterNode.dispose();
  108212. this._emitterNode = null;
  108213. }
  108214. };
  108215. /**
  108216. * Serialize the set into a JSON compatible object
  108217. * @returns a JSON compatible representation of the set
  108218. */
  108219. ParticleSystemSet.prototype.serialize = function () {
  108220. var result = {};
  108221. result.systems = [];
  108222. for (var _i = 0, _a = this.systems; _i < _a.length; _i++) {
  108223. var system = _a[_i];
  108224. result.systems.push(system.serialize());
  108225. }
  108226. if (this._emitterNode) {
  108227. result.emitter = this._emitterCreationOptions;
  108228. }
  108229. return result;
  108230. };
  108231. /**
  108232. * Parse a new ParticleSystemSet from a serialized source
  108233. * @param data defines a JSON compatible representation of the set
  108234. * @param scene defines the hosting scene
  108235. * @param gpu defines if we want GPU particles or CPU particles
  108236. * @returns a new ParticleSystemSet
  108237. */
  108238. ParticleSystemSet.Parse = function (data, scene, gpu) {
  108239. if (gpu === void 0) { gpu = false; }
  108240. var result = new ParticleSystemSet();
  108241. var rootUrl = _Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].PARTICLES_BaseAssetsUrl + "/textures/";
  108242. scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene;
  108243. for (var _i = 0, _a = data.systems; _i < _a.length; _i++) {
  108244. var system = _a[_i];
  108245. 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));
  108246. }
  108247. if (data.emitter) {
  108248. var options = data.emitter.options;
  108249. switch (data.emitter.kind) {
  108250. case "Sphere":
  108251. result.setEmitterAsSphere({
  108252. diameter: options.diameter,
  108253. segments: options.segments,
  108254. color: _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color3"].FromArray(options.color)
  108255. }, data.emitter.renderingGroupId, scene);
  108256. break;
  108257. }
  108258. }
  108259. return result;
  108260. };
  108261. return ParticleSystemSet;
  108262. }());
  108263. /***/ }),
  108264. /***/ "./Particles/solidParticle.ts":
  108265. /*!************************************!*\
  108266. !*** ./Particles/solidParticle.ts ***!
  108267. \************************************/
  108268. /*! exports provided: SolidParticle, ModelShape, DepthSortedParticle */
  108269. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108270. "use strict";
  108271. __webpack_require__.r(__webpack_exports__);
  108272. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return SolidParticle; });
  108273. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return ModelShape; });
  108274. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return DepthSortedParticle; });
  108275. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108276. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  108277. /* harmony import */ var _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/boundingSphere */ "./Culling/boundingSphere.ts");
  108278. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  108279. /**
  108280. * Represents one particle of a solid particle system.
  108281. */
  108282. var SolidParticle = /** @class */ (function () {
  108283. /**
  108284. * Creates a Solid Particle object.
  108285. * Don't create particles manually, use instead the Solid Particle System internal tools like _addParticle()
  108286. * @param particleIndex (integer) is the particle index in the Solid Particle System pool. It's also the particle identifier.
  108287. * @param positionIndex (integer) is the starting index of the particle vertices in the SPS "positions" array.
  108288. * @param indiceIndex (integer) is the starting index of the particle indices in the SPS "indices" array.
  108289. * @param model (ModelShape) is a reference to the model shape on what the particle is designed.
  108290. * @param shapeId (integer) is the model shape identifier in the SPS.
  108291. * @param idxInShape (integer) is the index of the particle in the current model (ex: the 10th box of addShape(box, 30))
  108292. * @param sps defines the sps it is associated to
  108293. * @param modelBoundingInfo is the reference to the model BoundingInfo used for intersection computations.
  108294. */
  108295. function SolidParticle(particleIndex, positionIndex, indiceIndex, model, shapeId, idxInShape, sps, modelBoundingInfo) {
  108296. if (modelBoundingInfo === void 0) { modelBoundingInfo = null; }
  108297. /**
  108298. * particle global index
  108299. */
  108300. this.idx = 0;
  108301. /**
  108302. * The color of the particle
  108303. */
  108304. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  108305. /**
  108306. * The world space position of the particle.
  108307. */
  108308. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108309. /**
  108310. * The world space rotation of the particle. (Not use if rotationQuaternion is set)
  108311. */
  108312. this.rotation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108313. /**
  108314. * The scaling of the particle.
  108315. */
  108316. this.scaling = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].One();
  108317. /**
  108318. * The uvs of the particle.
  108319. */
  108320. this.uvs = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector4"](0.0, 0.0, 1.0, 1.0);
  108321. /**
  108322. * The current speed of the particle.
  108323. */
  108324. this.velocity = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108325. /**
  108326. * The pivot point in the particle local space.
  108327. */
  108328. this.pivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108329. /**
  108330. * Must the particle be translated from its pivot point in its local space ?
  108331. * In this case, the pivot point is set at the origin of the particle local space and the particle is translated.
  108332. * Default : false
  108333. */
  108334. this.translateFromPivot = false;
  108335. /**
  108336. * Is the particle active or not ?
  108337. */
  108338. this.alive = true;
  108339. /**
  108340. * Is the particle visible or not ?
  108341. */
  108342. this.isVisible = true;
  108343. /**
  108344. * Index of this particle in the global "positions" array (Internal use)
  108345. * @hidden
  108346. */
  108347. this._pos = 0;
  108348. /**
  108349. * @hidden Index of this particle in the global "indices" array (Internal use)
  108350. */
  108351. this._ind = 0;
  108352. /**
  108353. * ModelShape id of this particle
  108354. */
  108355. this.shapeId = 0;
  108356. /**
  108357. * Index of the particle in its shape id (Internal use)
  108358. */
  108359. this.idxInShape = 0;
  108360. /**
  108361. * @hidden Still set as invisible in order to skip useless computations (Internal use)
  108362. */
  108363. this._stillInvisible = false;
  108364. /**
  108365. * @hidden Last computed particle rotation matrix
  108366. */
  108367. this._rotationMatrix = [1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0];
  108368. /**
  108369. * Parent particle Id, if any.
  108370. * Default null.
  108371. */
  108372. this.parentId = null;
  108373. /**
  108374. * The culling strategy to use to check whether the solid particle must be culled or not when using isInFrustum().
  108375. * The possible values are :
  108376. * - AbstractMesh.CULLINGSTRATEGY_STANDARD
  108377. * - AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108378. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION
  108379. * - AbstractMesh.CULLINGSTRATEGY_OPTIMISTIC_INCLUSION_THEN_BSPHERE_ONLY
  108380. * The default value for solid particles is AbstractMesh.CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY
  108381. * Please read each static variable documentation in the class AbstractMesh to get details about the culling process.
  108382. * */
  108383. this.cullingStrategy = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"].CULLINGSTRATEGY_BOUNDINGSPHERE_ONLY;
  108384. /**
  108385. * @hidden Internal global position in the SPS.
  108386. */
  108387. this._globalPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108388. this.idx = particleIndex;
  108389. this._pos = positionIndex;
  108390. this._ind = indiceIndex;
  108391. this._model = model;
  108392. this.shapeId = shapeId;
  108393. this.idxInShape = idxInShape;
  108394. this._sps = sps;
  108395. if (modelBoundingInfo) {
  108396. this._modelBoundingInfo = modelBoundingInfo;
  108397. this._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_1__["BoundingInfo"](modelBoundingInfo.minimum, modelBoundingInfo.maximum);
  108398. }
  108399. }
  108400. Object.defineProperty(SolidParticle.prototype, "scale", {
  108401. /**
  108402. * Legacy support, changed scale to scaling
  108403. */
  108404. get: function () {
  108405. return this.scaling;
  108406. },
  108407. /**
  108408. * Legacy support, changed scale to scaling
  108409. */
  108410. set: function (scale) {
  108411. this.scaling = scale;
  108412. },
  108413. enumerable: true,
  108414. configurable: true
  108415. });
  108416. Object.defineProperty(SolidParticle.prototype, "quaternion", {
  108417. /**
  108418. * Legacy support, changed quaternion to rotationQuaternion
  108419. */
  108420. get: function () {
  108421. return this.rotationQuaternion;
  108422. },
  108423. /**
  108424. * Legacy support, changed quaternion to rotationQuaternion
  108425. */
  108426. set: function (q) {
  108427. this.rotationQuaternion = q;
  108428. },
  108429. enumerable: true,
  108430. configurable: true
  108431. });
  108432. /**
  108433. * Returns a boolean. True if the particle intersects another particle or another mesh, else false.
  108434. * The intersection is computed on the particle bounding sphere and Axis Aligned Bounding Box (AABB)
  108435. * @param target is the object (solid particle or mesh) what the intersection is computed against.
  108436. * @returns true if it intersects
  108437. */
  108438. SolidParticle.prototype.intersectsMesh = function (target) {
  108439. if (!this._boundingInfo || !target._boundingInfo) {
  108440. return false;
  108441. }
  108442. if (this._sps._bSphereOnly) {
  108443. return _Culling_boundingSphere__WEBPACK_IMPORTED_MODULE_2__["BoundingSphere"].Intersects(this._boundingInfo.boundingSphere, target._boundingInfo.boundingSphere);
  108444. }
  108445. return this._boundingInfo.intersects(target._boundingInfo, false);
  108446. };
  108447. /**
  108448. * Returns `true` if the solid particle is within the frustum defined by the passed array of planes.
  108449. * A particle is in the frustum if its bounding box intersects the frustum
  108450. * @param frustumPlanes defines the frustum to test
  108451. * @returns true if the particle is in the frustum planes
  108452. */
  108453. SolidParticle.prototype.isInFrustum = function (frustumPlanes) {
  108454. return this._boundingInfo !== null && this._boundingInfo.isInFrustum(frustumPlanes, this.cullingStrategy);
  108455. };
  108456. /**
  108457. * get the rotation matrix of the particle
  108458. * @hidden
  108459. */
  108460. SolidParticle.prototype.getRotationMatrix = function (m) {
  108461. var quaternion;
  108462. if (this.rotationQuaternion) {
  108463. quaternion = this.rotationQuaternion;
  108464. }
  108465. else {
  108466. quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  108467. var rotation = this.rotation;
  108468. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  108469. }
  108470. quaternion.toRotationMatrix(m);
  108471. };
  108472. return SolidParticle;
  108473. }());
  108474. /**
  108475. * Represents the shape of the model used by one particle of a solid particle system.
  108476. * SPS internal tool, don't use it manually.
  108477. */
  108478. var ModelShape = /** @class */ (function () {
  108479. /**
  108480. * 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.
  108481. * SPS internal tool, don't use it manually.
  108482. * @hidden
  108483. */
  108484. function ModelShape(id, shape, indicesLength, shapeUV, posFunction, vtxFunction) {
  108485. /**
  108486. * length of the shape in the model indices array (internal use)
  108487. * @hidden
  108488. */
  108489. this._indicesLength = 0;
  108490. this.shapeID = id;
  108491. this._shape = shape;
  108492. this._indicesLength = indicesLength;
  108493. this._shapeUV = shapeUV;
  108494. this._positionFunction = posFunction;
  108495. this._vertexFunction = vtxFunction;
  108496. }
  108497. return ModelShape;
  108498. }());
  108499. /**
  108500. * Represents a Depth Sorted Particle in the solid particle system.
  108501. */
  108502. var DepthSortedParticle = /** @class */ (function () {
  108503. function DepthSortedParticle() {
  108504. /**
  108505. * Index of the particle in the "indices" array
  108506. */
  108507. this.ind = 0;
  108508. /**
  108509. * Length of the particle shape in the "indices" array
  108510. */
  108511. this.indicesLength = 0;
  108512. /**
  108513. * Squared distance from the particle to the camera
  108514. */
  108515. this.sqDistance = 0.0;
  108516. }
  108517. return DepthSortedParticle;
  108518. }());
  108519. /***/ }),
  108520. /***/ "./Particles/solidParticleSystem.ts":
  108521. /*!******************************************!*\
  108522. !*** ./Particles/solidParticleSystem.ts ***!
  108523. \******************************************/
  108524. /*! exports provided: SolidParticleSystem */
  108525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  108526. "use strict";
  108527. __webpack_require__.r(__webpack_exports__);
  108528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return SolidParticleSystem; });
  108529. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  108530. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  108531. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  108532. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  108533. /* harmony import */ var _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/Builders/discBuilder */ "./Meshes/Builders/discBuilder.ts");
  108534. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  108535. /* harmony import */ var _solidParticle__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./solidParticle */ "./Particles/solidParticle.ts");
  108536. /* harmony import */ var _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Culling/boundingInfo */ "./Culling/boundingInfo.ts");
  108537. var depthSortFunction = function (p1, p2) { return p2.sqDistance - p1.sqDistance; };
  108538. /**
  108539. * The SPS is a single updatable mesh. The solid particles are simply separate parts or faces fo this big mesh.
  108540. *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.
  108541. * The SPS is also a particle system. It provides some methods to manage the particles.
  108542. * However it is behavior agnostic. This means it has no emitter, no particle physics, no particle recycler. You have to implement your own behavior.
  108543. *
  108544. * Full documentation here : http://doc.babylonjs.com/overviews/Solid_Particle_System
  108545. */
  108546. var SolidParticleSystem = /** @class */ (function () {
  108547. /**
  108548. * Creates a SPS (Solid Particle System) object.
  108549. * @param name (String) is the SPS name, this will be the underlying mesh name.
  108550. * @param scene (Scene) is the scene in which the SPS is added.
  108551. * @param options defines the options of the sps e.g.
  108552. * * updatable (optional boolean, default true) : if the SPS must be updatable or immutable.
  108553. * * isPickable (optional boolean, default false) : if the solid particles must be pickable.
  108554. * * enableDepthSort (optional boolean, default false) : if the solid particles must be sorted in the geometry according to their distance to the camera.
  108555. * * particleIntersection (optional boolean, default false) : if the solid particle intersections must be computed.
  108556. * * boundingSphereOnly (optional boolean, default false) : if the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster).
  108557. * * bSphereRadiusFactor (optional float, default 1.0) : a number to multiply the boundind sphere radius by in order to reduce it for instance.
  108558. * @example bSphereRadiusFactor = 1.0 / Math.sqrt(3.0) => the bounding sphere exactly matches a spherical mesh.
  108559. */
  108560. function SolidParticleSystem(name, scene, options) {
  108561. /**
  108562. * The SPS array of Solid Particle objects. Just access each particle as with any classic array.
  108563. * Example : var p = SPS.particles[i];
  108564. */
  108565. this.particles = new Array();
  108566. /**
  108567. * The SPS total number of particles. Read only. Use SPS.counter instead if you need to set your own value.
  108568. */
  108569. this.nbParticles = 0;
  108570. /**
  108571. * If the particles must ever face the camera (default false). Useful for planar particles.
  108572. */
  108573. this.billboard = false;
  108574. /**
  108575. * Recompute normals when adding a shape
  108576. */
  108577. this.recomputeNormals = true;
  108578. /**
  108579. * This a counter ofr your own usage. It's not set by any SPS functions.
  108580. */
  108581. this.counter = 0;
  108582. /**
  108583. * This empty object is intended to store some SPS specific or temporary values in order to lower the Garbage Collector activity.
  108584. * Please read : http://doc.babylonjs.com/overviews/Solid_Particle_System#garbage-collector-concerns
  108585. */
  108586. this.vars = {};
  108587. /**
  108588. * If the particle intersection must be computed only with the bounding sphere (no bounding box computation, so faster). (Internal use only)
  108589. * @hidden
  108590. */
  108591. this._bSphereOnly = false;
  108592. /**
  108593. * A number to multiply the boundind sphere radius by in order to reduce it for instance. (Internal use only)
  108594. * @hidden
  108595. */
  108596. this._bSphereRadiusFactor = 1.0;
  108597. this._positions = new Array();
  108598. this._indices = new Array();
  108599. this._normals = new Array();
  108600. this._colors = new Array();
  108601. this._uvs = new Array();
  108602. this._index = 0; // indices index
  108603. this._updatable = true;
  108604. this._pickable = false;
  108605. this._isVisibilityBoxLocked = false;
  108606. this._alwaysVisible = false;
  108607. this._depthSort = false;
  108608. this._shapeCounter = 0;
  108609. this._copy = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](0, 0, 0, null, 0, 0, this);
  108610. this._color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0, 0, 0, 0);
  108611. this._computeParticleColor = true;
  108612. this._computeParticleTexture = true;
  108613. this._computeParticleRotation = true;
  108614. this._computeParticleVertex = false;
  108615. this._computeBoundingBox = false;
  108616. this._depthSortParticles = true;
  108617. this._mustUnrotateFixedNormals = false;
  108618. this._particlesIntersect = false;
  108619. this._needs32Bits = false;
  108620. this.name = name;
  108621. this._scene = scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_5__["EngineStore"].LastCreatedScene;
  108622. this._camera = scene.activeCamera;
  108623. this._pickable = options ? options.isPickable : false;
  108624. this._depthSort = options ? options.enableDepthSort : false;
  108625. this._particlesIntersect = options ? options.particleIntersection : false;
  108626. this._bSphereOnly = options ? options.boundingSphereOnly : false;
  108627. this._bSphereRadiusFactor = (options && options.bSphereRadiusFactor) ? options.bSphereRadiusFactor : 1.0;
  108628. if (options && options.updatable !== undefined) {
  108629. this._updatable = options.updatable;
  108630. }
  108631. else {
  108632. this._updatable = true;
  108633. }
  108634. if (this._pickable) {
  108635. this.pickedParticles = [];
  108636. }
  108637. if (this._depthSort) {
  108638. this.depthSortedParticles = [];
  108639. }
  108640. }
  108641. /**
  108642. * Builds the SPS underlying mesh. Returns a standard Mesh.
  108643. * If no model shape was added to the SPS, the returned mesh is just a single triangular plane.
  108644. * @returns the created mesh
  108645. */
  108646. SolidParticleSystem.prototype.buildMesh = function () {
  108647. if (this.nbParticles === 0) {
  108648. var triangle = _Meshes_Builders_discBuilder__WEBPACK_IMPORTED_MODULE_4__["DiscBuilder"].CreateDisc("", { radius: 1, tessellation: 3 }, this._scene);
  108649. this.addShape(triangle, 1);
  108650. triangle.dispose();
  108651. }
  108652. this._indices32 = (this._needs32Bits) ? new Uint32Array(this._indices) : new Uint16Array(this._indices);
  108653. this._positions32 = new Float32Array(this._positions);
  108654. this._uvs32 = new Float32Array(this._uvs);
  108655. this._colors32 = new Float32Array(this._colors);
  108656. if (this.recomputeNormals) {
  108657. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(this._positions32, this._indices32, this._normals);
  108658. }
  108659. this._normals32 = new Float32Array(this._normals);
  108660. this._fixedNormal32 = new Float32Array(this._normals);
  108661. if (this._mustUnrotateFixedNormals) { // the particles could be created already rotated in the mesh with a positionFunction
  108662. this._unrotateFixedNormals();
  108663. }
  108664. var vertexData = new _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"]();
  108665. vertexData.indices = (this._depthSort) ? this._indices : this._indices32;
  108666. vertexData.set(this._positions32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108667. vertexData.set(this._normals32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108668. if (this._uvs32.length > 0) {
  108669. vertexData.set(this._uvs32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108670. }
  108671. if (this._colors32.length > 0) {
  108672. vertexData.set(this._colors32, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108673. }
  108674. var mesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_3__["Mesh"](this.name, this._scene);
  108675. vertexData.applyToMesh(mesh, this._updatable);
  108676. this.mesh = mesh;
  108677. this.mesh.isPickable = this._pickable;
  108678. // free memory
  108679. if (!this._depthSort) {
  108680. this._indices = null;
  108681. }
  108682. this._positions = null;
  108683. this._normals = null;
  108684. this._uvs = null;
  108685. this._colors = null;
  108686. if (!this._updatable) {
  108687. this.particles.length = 0;
  108688. }
  108689. return mesh;
  108690. };
  108691. /**
  108692. * Digests the mesh and generates as many solid particles in the system as wanted. Returns the SPS.
  108693. * These particles will have the same geometry than the mesh parts and will be positioned at the same localisation than the mesh original places.
  108694. * Thus the particles generated from `digest()` have their property `position` set yet.
  108695. * @param mesh ( Mesh ) is the mesh to be digested
  108696. * @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
  108697. * {delta} (optional integer, default 0) is the random extra number of facets per particle , each particle will have between `facetNb` and `facetNb + delta` facets
  108698. * {number} (optional positive integer) is the wanted number of particles : each particle is built with `mesh_total_facets / number` facets
  108699. * @returns the current SPS
  108700. */
  108701. SolidParticleSystem.prototype.digest = function (mesh, options) {
  108702. var size = (options && options.facetNb) || 1;
  108703. var number = (options && options.number) || 0;
  108704. var delta = (options && options.delta) || 0;
  108705. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108706. var meshInd = mesh.getIndices();
  108707. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108708. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108709. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108710. var f = 0; // facet counter
  108711. var totalFacets = meshInd.length / 3; // a facet is a triangle, so 3 indices
  108712. // compute size from number
  108713. if (number) {
  108714. number = (number > totalFacets) ? totalFacets : number;
  108715. size = Math.round(totalFacets / number);
  108716. delta = 0;
  108717. }
  108718. else {
  108719. size = (size > totalFacets) ? totalFacets : size;
  108720. }
  108721. var facetPos = []; // submesh positions
  108722. var facetInd = []; // submesh indices
  108723. var facetUV = []; // submesh UV
  108724. var facetCol = []; // submesh colors
  108725. var barycenter = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  108726. var sizeO = size;
  108727. while (f < totalFacets) {
  108728. size = sizeO + Math.floor((1 + delta) * Math.random());
  108729. if (f > totalFacets - size) {
  108730. size = totalFacets - f;
  108731. }
  108732. // reset temp arrays
  108733. facetPos.length = 0;
  108734. facetInd.length = 0;
  108735. facetUV.length = 0;
  108736. facetCol.length = 0;
  108737. // iterate over "size" facets
  108738. var fi = 0;
  108739. for (var j = f * 3; j < (f + size) * 3; j++) {
  108740. facetInd.push(fi);
  108741. var i = meshInd[j];
  108742. facetPos.push(meshPos[i * 3], meshPos[i * 3 + 1], meshPos[i * 3 + 2]);
  108743. if (meshUV) {
  108744. facetUV.push(meshUV[i * 2], meshUV[i * 2 + 1]);
  108745. }
  108746. if (meshCol) {
  108747. facetCol.push(meshCol[i * 4], meshCol[i * 4 + 1], meshCol[i * 4 + 2], meshCol[i * 4 + 3]);
  108748. }
  108749. fi++;
  108750. }
  108751. // create a model shape for each single particle
  108752. var idx = this.nbParticles;
  108753. var shape = this._posToShape(facetPos);
  108754. var shapeUV = this._uvsToShapeUV(facetUV);
  108755. // compute the barycenter of the shape
  108756. var v;
  108757. for (v = 0; v < shape.length; v++) {
  108758. barycenter.addInPlace(shape[v]);
  108759. }
  108760. barycenter.scaleInPlace(1 / shape.length);
  108761. // shift the shape from its barycenter to the origin
  108762. for (v = 0; v < shape.length; v++) {
  108763. shape[v].subtractInPlace(barycenter);
  108764. }
  108765. var bInfo;
  108766. if (this._particlesIntersect) {
  108767. bInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](barycenter, barycenter);
  108768. }
  108769. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, size * 3, shapeUV, null, null);
  108770. // add the particle in the SPS
  108771. var currentPos = this._positions.length;
  108772. var currentInd = this._indices.length;
  108773. this._meshBuilder(this._index, shape, this._positions, facetInd, this._indices, facetUV, this._uvs, facetCol, this._colors, meshNor, this._normals, idx, 0, null);
  108774. this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, 0, bInfo);
  108775. // initialize the particle position
  108776. this.particles[this.nbParticles].position.addInPlace(barycenter);
  108777. this._index += shape.length;
  108778. idx++;
  108779. this.nbParticles++;
  108780. this._shapeCounter++;
  108781. f += size;
  108782. }
  108783. return this;
  108784. };
  108785. // unrotate the fixed normals in case the mesh was built with pre-rotated particles, ex : use of positionFunction in addShape()
  108786. SolidParticleSystem.prototype._unrotateFixedNormals = function () {
  108787. var index = 0;
  108788. var idx = 0;
  108789. var tmpNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108790. var quaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Quaternion[0];
  108791. var invertedRotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108792. for (var p = 0; p < this.particles.length; p++) {
  108793. var particle = this.particles[p];
  108794. var shape = particle._model._shape;
  108795. // computing the inverse of the rotation matrix from the quaternion
  108796. // is equivalent to computing the matrix of the inverse quaternion, i.e of the conjugate quaternion
  108797. if (particle.rotationQuaternion) {
  108798. particle.rotationQuaternion.conjugateToRef(quaternion);
  108799. }
  108800. else {
  108801. var rotation = particle.rotation;
  108802. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"].RotationYawPitchRollToRef(rotation.y, rotation.x, rotation.z, quaternion);
  108803. quaternion.conjugateInPlace();
  108804. }
  108805. quaternion.toRotationMatrix(invertedRotMatrix);
  108806. for (var pt = 0; pt < shape.length; pt++) {
  108807. idx = index + pt * 3;
  108808. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(this._normals32[idx], this._normals32[idx + 1], this._normals32[idx + 2], invertedRotMatrix, tmpNormal);
  108809. tmpNormal.toArray(this._fixedNormal32, idx);
  108810. }
  108811. index = idx + 3;
  108812. }
  108813. };
  108814. //reset copy
  108815. SolidParticleSystem.prototype._resetCopy = function () {
  108816. var copy = this._copy;
  108817. copy.position.setAll(0);
  108818. copy.rotation.setAll(0);
  108819. copy.rotationQuaternion = null;
  108820. copy.scaling.setAll(1);
  108821. copy.uvs.copyFromFloats(0.0, 0.0, 1.0, 1.0);
  108822. copy.color = null;
  108823. copy.translateFromPivot = false;
  108824. };
  108825. // _meshBuilder : inserts the shape model in the global SPS mesh
  108826. SolidParticleSystem.prototype._meshBuilder = function (p, shape, positions, meshInd, indices, meshUV, uvs, meshCol, colors, meshNor, normals, idx, idxInShape, options) {
  108827. var i;
  108828. var u = 0;
  108829. var c = 0;
  108830. var n = 0;
  108831. this._resetCopy();
  108832. var copy = this._copy;
  108833. if (options && options.positionFunction) { // call to custom positionFunction
  108834. options.positionFunction(copy, idx, idxInShape);
  108835. this._mustUnrotateFixedNormals = true;
  108836. }
  108837. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108838. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108839. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108840. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108841. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  108842. copy.getRotationMatrix(rotMatrix);
  108843. copy.pivot.multiplyToRef(copy.scaling, scaledPivot);
  108844. if (copy.translateFromPivot) {
  108845. pivotBackTranslation.setAll(0.0);
  108846. }
  108847. else {
  108848. pivotBackTranslation.copyFrom(scaledPivot);
  108849. }
  108850. for (i = 0; i < shape.length; i++) {
  108851. tmpVertex.copyFrom(shape[i]);
  108852. if (options && options.vertexFunction) {
  108853. options.vertexFunction(copy, tmpVertex, i);
  108854. }
  108855. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  108856. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  108857. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position);
  108858. positions.push(tmpRotated.x, tmpRotated.y, tmpRotated.z);
  108859. if (meshUV) {
  108860. var copyUvs = copy.uvs;
  108861. uvs.push((copyUvs.z - copyUvs.x) * meshUV[u] + copyUvs.x, (copyUvs.w - copyUvs.y) * meshUV[u + 1] + copyUvs.y);
  108862. u += 2;
  108863. }
  108864. if (copy.color) {
  108865. this._color = copy.color;
  108866. }
  108867. else {
  108868. var color = this._color;
  108869. if (meshCol && meshCol[c] !== undefined) {
  108870. color.r = meshCol[c];
  108871. color.g = meshCol[c + 1];
  108872. color.b = meshCol[c + 2];
  108873. color.a = meshCol[c + 3];
  108874. }
  108875. else {
  108876. color.r = 1.0;
  108877. color.g = 1.0;
  108878. color.b = 1.0;
  108879. color.a = 1.0;
  108880. }
  108881. }
  108882. colors.push(this._color.r, this._color.g, this._color.b, this._color.a);
  108883. c += 4;
  108884. if (!this.recomputeNormals && meshNor) {
  108885. tmpVertex.x = meshNor[n];
  108886. tmpVertex.y = meshNor[n + 1];
  108887. tmpVertex.z = meshNor[n + 2];
  108888. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, rotMatrix, tmpVertex);
  108889. normals.push(tmpVertex.x, tmpVertex.y, tmpVertex.z);
  108890. n += 3;
  108891. }
  108892. }
  108893. for (i = 0; i < meshInd.length; i++) {
  108894. var current_ind = p + meshInd[i];
  108895. indices.push(current_ind);
  108896. if (current_ind > 65535) {
  108897. this._needs32Bits = true;
  108898. }
  108899. }
  108900. if (this._pickable) {
  108901. var nbfaces = meshInd.length / 3;
  108902. for (i = 0; i < nbfaces; i++) {
  108903. this.pickedParticles.push({ idx: idx, faceId: i });
  108904. }
  108905. }
  108906. if (this._depthSort) {
  108907. this.depthSortedParticles.push(new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["DepthSortedParticle"]());
  108908. }
  108909. return copy;
  108910. };
  108911. // returns a shape array from positions array
  108912. SolidParticleSystem.prototype._posToShape = function (positions) {
  108913. var shape = [];
  108914. for (var i = 0; i < positions.length; i += 3) {
  108915. shape.push(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].FromArray(positions, i));
  108916. }
  108917. return shape;
  108918. };
  108919. // returns a shapeUV array from a Vector4 uvs
  108920. SolidParticleSystem.prototype._uvsToShapeUV = function (uvs) {
  108921. var shapeUV = [];
  108922. if (uvs) {
  108923. for (var i = 0; i < uvs.length; i++) {
  108924. shapeUV.push(uvs[i]);
  108925. }
  108926. }
  108927. return shapeUV;
  108928. };
  108929. // adds a new particle object in the particles array
  108930. SolidParticleSystem.prototype._addParticle = function (idx, idxpos, idxind, model, shapeId, idxInShape, bInfo) {
  108931. if (bInfo === void 0) { bInfo = null; }
  108932. var sp = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["SolidParticle"](idx, idxpos, idxind, model, shapeId, idxInShape, this, bInfo);
  108933. this.particles.push(sp);
  108934. return sp;
  108935. };
  108936. /**
  108937. * Adds some particles to the SPS from the model shape. Returns the shape id.
  108938. * Please read the doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#create-an-immutable-sps
  108939. * @param mesh is any Mesh object that will be used as a model for the solid particles.
  108940. * @param nb (positive integer) the number of particles to be created from this model
  108941. * @param options {positionFunction} is an optional javascript function to called for each particle on SPS creation.
  108942. * {vertexFunction} is an optional javascript function to called for each vertex of each particle on SPS creation
  108943. * @returns the number of shapes in the system
  108944. */
  108945. SolidParticleSystem.prototype.addShape = function (mesh, nb, options) {
  108946. var meshPos = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  108947. var meshInd = mesh.getIndices();
  108948. var meshUV = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  108949. var meshCol = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind);
  108950. var meshNor = mesh.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind);
  108951. var bbInfo;
  108952. if (this._particlesIntersect) {
  108953. bbInfo = mesh.getBoundingInfo();
  108954. }
  108955. var shape = this._posToShape(meshPos);
  108956. var shapeUV = this._uvsToShapeUV(meshUV);
  108957. var posfunc = options ? options.positionFunction : null;
  108958. var vtxfunc = options ? options.vertexFunction : null;
  108959. var modelShape = new _solidParticle__WEBPACK_IMPORTED_MODULE_6__["ModelShape"](this._shapeCounter, shape, meshInd.length, shapeUV, posfunc, vtxfunc);
  108960. // particles
  108961. var sp;
  108962. var currentCopy;
  108963. var idx = this.nbParticles;
  108964. for (var i = 0; i < nb; i++) {
  108965. var currentPos = this._positions.length;
  108966. var currentInd = this._indices.length;
  108967. currentCopy = this._meshBuilder(this._index, shape, this._positions, meshInd, this._indices, meshUV, this._uvs, meshCol, this._colors, meshNor, this._normals, idx, i, options);
  108968. if (this._updatable) {
  108969. sp = this._addParticle(idx, currentPos, currentInd, modelShape, this._shapeCounter, i, bbInfo);
  108970. sp.position.copyFrom(currentCopy.position);
  108971. sp.rotation.copyFrom(currentCopy.rotation);
  108972. if (currentCopy.rotationQuaternion && sp.rotationQuaternion) {
  108973. sp.rotationQuaternion.copyFrom(currentCopy.rotationQuaternion);
  108974. }
  108975. if (currentCopy.color && sp.color) {
  108976. sp.color.copyFrom(currentCopy.color);
  108977. }
  108978. sp.scaling.copyFrom(currentCopy.scaling);
  108979. sp.uvs.copyFrom(currentCopy.uvs);
  108980. }
  108981. this._index += shape.length;
  108982. idx++;
  108983. }
  108984. this.nbParticles += nb;
  108985. this._shapeCounter++;
  108986. return this._shapeCounter - 1;
  108987. };
  108988. // rebuilds a particle back to its just built status : if needed, recomputes the custom positions and vertices
  108989. SolidParticleSystem.prototype._rebuildParticle = function (particle) {
  108990. this._resetCopy();
  108991. var copy = this._copy;
  108992. if (particle._model._positionFunction) { // recall to stored custom positionFunction
  108993. particle._model._positionFunction(copy, particle.idx, particle.idxInShape);
  108994. }
  108995. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  108996. var tmpVertex = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[0];
  108997. var tmpRotated = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[1];
  108998. var pivotBackTranslation = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[2];
  108999. var scaledPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3[3];
  109000. copy.getRotationMatrix(rotMatrix);
  109001. particle.pivot.multiplyToRef(particle.scaling, scaledPivot);
  109002. if (copy.translateFromPivot) {
  109003. pivotBackTranslation.copyFromFloats(0.0, 0.0, 0.0);
  109004. }
  109005. else {
  109006. pivotBackTranslation.copyFrom(scaledPivot);
  109007. }
  109008. var shape = particle._model._shape;
  109009. for (var pt = 0; pt < shape.length; pt++) {
  109010. tmpVertex.copyFrom(shape[pt]);
  109011. if (particle._model._vertexFunction) {
  109012. particle._model._vertexFunction(copy, tmpVertex, pt); // recall to stored vertexFunction
  109013. }
  109014. tmpVertex.multiplyInPlace(copy.scaling).subtractInPlace(scaledPivot);
  109015. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(tmpVertex, rotMatrix, tmpRotated);
  109016. tmpRotated.addInPlace(pivotBackTranslation).addInPlace(copy.position).toArray(this._positions32, particle._pos + pt * 3);
  109017. }
  109018. particle.position.setAll(0.0);
  109019. particle.rotation.setAll(0.0);
  109020. particle.rotationQuaternion = null;
  109021. particle.scaling.setAll(1.0);
  109022. particle.uvs.setAll(0.0);
  109023. particle.pivot.setAll(0.0);
  109024. particle.translateFromPivot = false;
  109025. particle.parentId = null;
  109026. };
  109027. /**
  109028. * Rebuilds the whole mesh and updates the VBO : custom positions and vertices are recomputed if needed.
  109029. * @returns the SPS.
  109030. */
  109031. SolidParticleSystem.prototype.rebuildMesh = function () {
  109032. for (var p = 0; p < this.particles.length; p++) {
  109033. this._rebuildParticle(this.particles[p]);
  109034. }
  109035. this.mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, this._positions32, false, false);
  109036. return this;
  109037. };
  109038. /**
  109039. * Sets all the particles : this method actually really updates the mesh according to the particle positions, rotations, colors, textures, etc.
  109040. * This method calls `updateParticle()` for each particle of the SPS.
  109041. * For an animated SPS, it is usually called within the render loop.
  109042. * @param start The particle index in the particle array where to start to compute the particle property values _(default 0)_
  109043. * @param end The particle index in the particle array where to stop to compute the particle property values _(default nbParticle - 1)_
  109044. * @param update If the mesh must be finally updated on this call after all the particle computations _(default true)_
  109045. * @returns the SPS.
  109046. */
  109047. SolidParticleSystem.prototype.setParticles = function (start, end, update) {
  109048. if (start === void 0) { start = 0; }
  109049. if (end === void 0) { end = this.nbParticles - 1; }
  109050. if (update === void 0) { update = true; }
  109051. if (!this._updatable) {
  109052. return this;
  109053. }
  109054. // custom beforeUpdate
  109055. this.beforeUpdateParticles(start, end, update);
  109056. var rotMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[0];
  109057. var invertedMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Matrix[1];
  109058. var mesh = this.mesh;
  109059. var colors32 = this._colors32;
  109060. var positions32 = this._positions32;
  109061. var normals32 = this._normals32;
  109062. var uvs32 = this._uvs32;
  109063. var indices32 = this._indices32;
  109064. var indices = this._indices;
  109065. var fixedNormal32 = this._fixedNormal32;
  109066. var tempVectors = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Tmp"].Vector3;
  109067. var camAxisX = tempVectors[5].copyFromFloats(1.0, 0.0, 0.0);
  109068. var camAxisY = tempVectors[6].copyFromFloats(0.0, 1.0, 0.0);
  109069. var camAxisZ = tempVectors[7].copyFromFloats(0.0, 0.0, 1.0);
  109070. var minimum = tempVectors[8].setAll(Number.MAX_VALUE);
  109071. var maximum = tempVectors[9].setAll(-Number.MAX_VALUE);
  109072. var camInvertedPosition = tempVectors[10].setAll(0);
  109073. // cases when the World Matrix is to be computed first
  109074. if (this.billboard || this._depthSort) {
  109075. this.mesh.computeWorldMatrix(true);
  109076. this.mesh._worldMatrix.invertToRef(invertedMatrix);
  109077. }
  109078. // if the particles will always face the camera
  109079. if (this.billboard) {
  109080. // compute the camera position and un-rotate it by the current mesh rotation
  109081. var tmpVertex = tempVectors[0];
  109082. this._camera.getDirectionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_0__["Axis"].Z, tmpVertex);
  109083. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalToRef(tmpVertex, invertedMatrix, camAxisZ);
  109084. camAxisZ.normalize();
  109085. // same for camera up vector extracted from the cam view matrix
  109086. var view = this._camera.getViewMatrix(true);
  109087. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformNormalFromFloatsToRef(view.m[1], view.m[5], view.m[9], invertedMatrix, camAxisY);
  109088. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].CrossToRef(camAxisY, camAxisZ, camAxisX);
  109089. camAxisY.normalize();
  109090. camAxisX.normalize();
  109091. }
  109092. // if depthSort, compute the camera global position in the mesh local system
  109093. if (this._depthSort) {
  109094. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(this._camera.globalPosition, invertedMatrix, camInvertedPosition); // then un-rotate the camera
  109095. }
  109096. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].IdentityToRef(rotMatrix);
  109097. var idx = 0; // current position index in the global array positions32
  109098. var index = 0; // position start index in the global array positions32 of the current particle
  109099. var colidx = 0; // current color index in the global array colors32
  109100. var colorIndex = 0; // color start index in the global array colors32 of the current particle
  109101. var uvidx = 0; // current uv index in the global array uvs32
  109102. var uvIndex = 0; // uv start index in the global array uvs32 of the current particle
  109103. var pt = 0; // current index in the particle model shape
  109104. if (this.mesh.isFacetDataEnabled) {
  109105. this._computeBoundingBox = true;
  109106. }
  109107. end = (end >= this.nbParticles) ? this.nbParticles - 1 : end;
  109108. if (this._computeBoundingBox) {
  109109. if (start != 0 || end != this.nbParticles - 1) { // only some particles are updated, then use the current existing BBox basis. Note : it can only increase.
  109110. var boundingInfo = this.mesh._boundingInfo;
  109111. if (boundingInfo) {
  109112. minimum.copyFrom(boundingInfo.minimum);
  109113. maximum.copyFrom(boundingInfo.maximum);
  109114. }
  109115. }
  109116. }
  109117. // particle loop
  109118. index = this.particles[start]._pos;
  109119. var vpos = (index / 3) | 0;
  109120. colorIndex = vpos * 4;
  109121. uvIndex = vpos * 2;
  109122. for (var p = start; p <= end; p++) {
  109123. var particle = this.particles[p];
  109124. // call to custom user function to update the particle properties
  109125. this.updateParticle(particle);
  109126. var shape = particle._model._shape;
  109127. var shapeUV = particle._model._shapeUV;
  109128. var particleRotationMatrix = particle._rotationMatrix;
  109129. var particlePosition = particle.position;
  109130. var particleRotation = particle.rotation;
  109131. var particleScaling = particle.scaling;
  109132. var particleGlobalPosition = particle._globalPosition;
  109133. // camera-particle distance for depth sorting
  109134. if (this._depthSort && this._depthSortParticles) {
  109135. var dsp = this.depthSortedParticles[p];
  109136. dsp.ind = particle._ind;
  109137. dsp.indicesLength = particle._model._indicesLength;
  109138. dsp.sqDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].DistanceSquared(particle.position, camInvertedPosition);
  109139. }
  109140. // skip the computations for inactive or already invisible particles
  109141. if (!particle.alive || (particle._stillInvisible && !particle.isVisible)) {
  109142. // increment indexes for the next particle
  109143. pt = shape.length;
  109144. index += pt * 3;
  109145. colorIndex += pt * 4;
  109146. uvIndex += pt * 2;
  109147. continue;
  109148. }
  109149. if (particle.isVisible) {
  109150. particle._stillInvisible = false; // un-mark permanent invisibility
  109151. var scaledPivot = tempVectors[12];
  109152. particle.pivot.multiplyToRef(particleScaling, scaledPivot);
  109153. // particle rotation matrix
  109154. if (this.billboard) {
  109155. particleRotation.x = 0.0;
  109156. particleRotation.y = 0.0;
  109157. }
  109158. if (this._computeParticleRotation || this.billboard) {
  109159. particle.getRotationMatrix(rotMatrix);
  109160. }
  109161. var particleHasParent = (particle.parentId !== null);
  109162. if (particleHasParent) {
  109163. var parent_1 = this.particles[particle.parentId];
  109164. var parentRotationMatrix = parent_1._rotationMatrix;
  109165. var parentGlobalPosition = parent_1._globalPosition;
  109166. var rotatedY = particlePosition.x * parentRotationMatrix[1] + particlePosition.y * parentRotationMatrix[4] + particlePosition.z * parentRotationMatrix[7];
  109167. var rotatedX = particlePosition.x * parentRotationMatrix[0] + particlePosition.y * parentRotationMatrix[3] + particlePosition.z * parentRotationMatrix[6];
  109168. var rotatedZ = particlePosition.x * parentRotationMatrix[2] + particlePosition.y * parentRotationMatrix[5] + particlePosition.z * parentRotationMatrix[8];
  109169. particleGlobalPosition.x = parentGlobalPosition.x + rotatedX;
  109170. particleGlobalPosition.y = parentGlobalPosition.y + rotatedY;
  109171. particleGlobalPosition.z = parentGlobalPosition.z + rotatedZ;
  109172. if (this._computeParticleRotation || this.billboard) {
  109173. var rotMatrixValues = rotMatrix.m;
  109174. particleRotationMatrix[0] = rotMatrixValues[0] * parentRotationMatrix[0] + rotMatrixValues[1] * parentRotationMatrix[3] + rotMatrixValues[2] * parentRotationMatrix[6];
  109175. particleRotationMatrix[1] = rotMatrixValues[0] * parentRotationMatrix[1] + rotMatrixValues[1] * parentRotationMatrix[4] + rotMatrixValues[2] * parentRotationMatrix[7];
  109176. particleRotationMatrix[2] = rotMatrixValues[0] * parentRotationMatrix[2] + rotMatrixValues[1] * parentRotationMatrix[5] + rotMatrixValues[2] * parentRotationMatrix[8];
  109177. particleRotationMatrix[3] = rotMatrixValues[4] * parentRotationMatrix[0] + rotMatrixValues[5] * parentRotationMatrix[3] + rotMatrixValues[6] * parentRotationMatrix[6];
  109178. particleRotationMatrix[4] = rotMatrixValues[4] * parentRotationMatrix[1] + rotMatrixValues[5] * parentRotationMatrix[4] + rotMatrixValues[6] * parentRotationMatrix[7];
  109179. particleRotationMatrix[5] = rotMatrixValues[4] * parentRotationMatrix[2] + rotMatrixValues[5] * parentRotationMatrix[5] + rotMatrixValues[6] * parentRotationMatrix[8];
  109180. particleRotationMatrix[6] = rotMatrixValues[8] * parentRotationMatrix[0] + rotMatrixValues[9] * parentRotationMatrix[3] + rotMatrixValues[10] * parentRotationMatrix[6];
  109181. particleRotationMatrix[7] = rotMatrixValues[8] * parentRotationMatrix[1] + rotMatrixValues[9] * parentRotationMatrix[4] + rotMatrixValues[10] * parentRotationMatrix[7];
  109182. particleRotationMatrix[8] = rotMatrixValues[8] * parentRotationMatrix[2] + rotMatrixValues[9] * parentRotationMatrix[5] + rotMatrixValues[10] * parentRotationMatrix[8];
  109183. }
  109184. }
  109185. else {
  109186. particleGlobalPosition.x = particlePosition.x;
  109187. particleGlobalPosition.y = particlePosition.y;
  109188. particleGlobalPosition.z = particlePosition.z;
  109189. if (this._computeParticleRotation || this.billboard) {
  109190. var rotMatrixValues = rotMatrix.m;
  109191. particleRotationMatrix[0] = rotMatrixValues[0];
  109192. particleRotationMatrix[1] = rotMatrixValues[1];
  109193. particleRotationMatrix[2] = rotMatrixValues[2];
  109194. particleRotationMatrix[3] = rotMatrixValues[4];
  109195. particleRotationMatrix[4] = rotMatrixValues[5];
  109196. particleRotationMatrix[5] = rotMatrixValues[6];
  109197. particleRotationMatrix[6] = rotMatrixValues[8];
  109198. particleRotationMatrix[7] = rotMatrixValues[9];
  109199. particleRotationMatrix[8] = rotMatrixValues[10];
  109200. }
  109201. }
  109202. var pivotBackTranslation = tempVectors[11];
  109203. if (particle.translateFromPivot) {
  109204. pivotBackTranslation.setAll(0.0);
  109205. }
  109206. else {
  109207. pivotBackTranslation.copyFrom(scaledPivot);
  109208. }
  109209. // particle vertex loop
  109210. for (pt = 0; pt < shape.length; pt++) {
  109211. idx = index + pt * 3;
  109212. colidx = colorIndex + pt * 4;
  109213. uvidx = uvIndex + pt * 2;
  109214. var tmpVertex = tempVectors[0];
  109215. tmpVertex.copyFrom(shape[pt]);
  109216. if (this._computeParticleVertex) {
  109217. this.updateParticleVertex(particle, tmpVertex, pt);
  109218. }
  109219. // positions
  109220. var vertexX = tmpVertex.x * particleScaling.x - scaledPivot.x;
  109221. var vertexY = tmpVertex.y * particleScaling.y - scaledPivot.y;
  109222. var vertexZ = tmpVertex.z * particleScaling.z - scaledPivot.z;
  109223. var rotatedX = vertexX * particleRotationMatrix[0] + vertexY * particleRotationMatrix[3] + vertexZ * particleRotationMatrix[6];
  109224. var rotatedY = vertexX * particleRotationMatrix[1] + vertexY * particleRotationMatrix[4] + vertexZ * particleRotationMatrix[7];
  109225. var rotatedZ = vertexX * particleRotationMatrix[2] + vertexY * particleRotationMatrix[5] + vertexZ * particleRotationMatrix[8];
  109226. rotatedX += pivotBackTranslation.x;
  109227. rotatedY += pivotBackTranslation.y;
  109228. rotatedZ += pivotBackTranslation.z;
  109229. var px = positions32[idx] = particleGlobalPosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  109230. var py = positions32[idx + 1] = particleGlobalPosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  109231. var pz = positions32[idx + 2] = particleGlobalPosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  109232. if (this._computeBoundingBox) {
  109233. minimum.minimizeInPlaceFromFloats(px, py, pz);
  109234. maximum.maximizeInPlaceFromFloats(px, py, pz);
  109235. }
  109236. // normals : if the particles can't be morphed then just rotate the normals, what is much more faster than ComputeNormals()
  109237. if (!this._computeParticleVertex) {
  109238. var normalx = fixedNormal32[idx];
  109239. var normaly = fixedNormal32[idx + 1];
  109240. var normalz = fixedNormal32[idx + 2];
  109241. var rotatedx = normalx * particleRotationMatrix[0] + normaly * particleRotationMatrix[3] + normalz * particleRotationMatrix[6];
  109242. var rotatedy = normalx * particleRotationMatrix[1] + normaly * particleRotationMatrix[4] + normalz * particleRotationMatrix[7];
  109243. var rotatedz = normalx * particleRotationMatrix[2] + normaly * particleRotationMatrix[5] + normalz * particleRotationMatrix[8];
  109244. normals32[idx] = camAxisX.x * rotatedx + camAxisY.x * rotatedy + camAxisZ.x * rotatedz;
  109245. normals32[idx + 1] = camAxisX.y * rotatedx + camAxisY.y * rotatedy + camAxisZ.y * rotatedz;
  109246. normals32[idx + 2] = camAxisX.z * rotatedx + camAxisY.z * rotatedy + camAxisZ.z * rotatedz;
  109247. }
  109248. if (this._computeParticleColor && particle.color) {
  109249. var color = particle.color;
  109250. var colors32_1 = this._colors32;
  109251. colors32_1[colidx] = color.r;
  109252. colors32_1[colidx + 1] = color.g;
  109253. colors32_1[colidx + 2] = color.b;
  109254. colors32_1[colidx + 3] = color.a;
  109255. }
  109256. if (this._computeParticleTexture) {
  109257. var uvs = particle.uvs;
  109258. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  109259. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  109260. }
  109261. }
  109262. }
  109263. // particle just set invisible : scaled to zero and positioned at the origin
  109264. else {
  109265. particle._stillInvisible = true; // mark the particle as invisible
  109266. for (pt = 0; pt < shape.length; pt++) {
  109267. idx = index + pt * 3;
  109268. colidx = colorIndex + pt * 4;
  109269. uvidx = uvIndex + pt * 2;
  109270. positions32[idx] = positions32[idx + 1] = positions32[idx + 2] = 0;
  109271. normals32[idx] = normals32[idx + 1] = normals32[idx + 2] = 0;
  109272. if (this._computeParticleColor && particle.color) {
  109273. var color = particle.color;
  109274. colors32[colidx] = color.r;
  109275. colors32[colidx + 1] = color.g;
  109276. colors32[colidx + 2] = color.b;
  109277. colors32[colidx + 3] = color.a;
  109278. }
  109279. if (this._computeParticleTexture) {
  109280. var uvs = particle.uvs;
  109281. uvs32[uvidx] = shapeUV[pt * 2] * (uvs.z - uvs.x) + uvs.x;
  109282. uvs32[uvidx + 1] = shapeUV[pt * 2 + 1] * (uvs.w - uvs.y) + uvs.y;
  109283. }
  109284. }
  109285. }
  109286. // if the particle intersections must be computed : update the bbInfo
  109287. if (this._particlesIntersect) {
  109288. var bInfo = particle._boundingInfo;
  109289. var bBox = bInfo.boundingBox;
  109290. var bSphere = bInfo.boundingSphere;
  109291. var modelBoundingInfo = particle._modelBoundingInfo;
  109292. if (!this._bSphereOnly) {
  109293. // place, scale and rotate the particle bbox within the SPS local system, then update it
  109294. var modelBoundingInfoVectors = modelBoundingInfo.boundingBox.vectors;
  109295. var tempMin = tempVectors[1];
  109296. var tempMax = tempVectors[2];
  109297. tempMin.setAll(Number.MAX_VALUE);
  109298. tempMax.setAll(-Number.MAX_VALUE);
  109299. for (var b = 0; b < 8; b++) {
  109300. var scaledX = modelBoundingInfoVectors[b].x * particleScaling.x;
  109301. var scaledY = modelBoundingInfoVectors[b].y * particleScaling.y;
  109302. var scaledZ = modelBoundingInfoVectors[b].z * particleScaling.z;
  109303. var rotatedX = scaledX * particleRotationMatrix[0] + scaledY * particleRotationMatrix[3] + scaledZ * particleRotationMatrix[6];
  109304. var rotatedY = scaledX * particleRotationMatrix[1] + scaledY * particleRotationMatrix[4] + scaledZ * particleRotationMatrix[7];
  109305. var rotatedZ = scaledX * particleRotationMatrix[2] + scaledY * particleRotationMatrix[5] + scaledZ * particleRotationMatrix[8];
  109306. var x = particlePosition.x + camAxisX.x * rotatedX + camAxisY.x * rotatedY + camAxisZ.x * rotatedZ;
  109307. var y = particlePosition.y + camAxisX.y * rotatedX + camAxisY.y * rotatedY + camAxisZ.y * rotatedZ;
  109308. var z = particlePosition.z + camAxisX.z * rotatedX + camAxisY.z * rotatedY + camAxisZ.z * rotatedZ;
  109309. tempMin.minimizeInPlaceFromFloats(x, y, z);
  109310. tempMax.maximizeInPlaceFromFloats(x, y, z);
  109311. }
  109312. bBox.reConstruct(tempMin, tempMax, mesh._worldMatrix);
  109313. }
  109314. // place and scale the particle bouding sphere in the SPS local system, then update it
  109315. var minBbox = modelBoundingInfo.minimum.multiplyToRef(particleScaling, tempVectors[1]);
  109316. var maxBbox = modelBoundingInfo.maximum.multiplyToRef(particleScaling, tempVectors[2]);
  109317. var bSphereCenter = maxBbox.addToRef(minBbox, tempVectors[3]).scaleInPlace(0.5).addInPlace(particleGlobalPosition);
  109318. var halfDiag = maxBbox.subtractToRef(minBbox, tempVectors[4]).scaleInPlace(0.5 * this._bSphereRadiusFactor);
  109319. var bSphereMinBbox = bSphereCenter.subtractToRef(halfDiag, tempVectors[1]);
  109320. var bSphereMaxBbox = bSphereCenter.addToRef(halfDiag, tempVectors[2]);
  109321. bSphere.reConstruct(bSphereMinBbox, bSphereMaxBbox, mesh._worldMatrix);
  109322. }
  109323. // increment indexes for the next particle
  109324. index = idx + 3;
  109325. colorIndex = colidx + 4;
  109326. uvIndex = uvidx + 2;
  109327. }
  109328. // if the VBO must be updated
  109329. if (update) {
  109330. if (this._computeParticleColor) {
  109331. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].ColorKind, colors32, false, false);
  109332. }
  109333. if (this._computeParticleTexture) {
  109334. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind, uvs32, false, false);
  109335. }
  109336. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, positions32, false, false);
  109337. if (!mesh.areNormalsFrozen || mesh.isFacetDataEnabled) {
  109338. if (this._computeParticleVertex || mesh.isFacetDataEnabled) {
  109339. // recompute the normals only if the particles can be morphed, update then also the normal reference array _fixedNormal32[]
  109340. var params = mesh.isFacetDataEnabled ? mesh.getFacetDataParameters() : null;
  109341. _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_2__["VertexData"].ComputeNormals(positions32, indices32, normals32, params);
  109342. for (var i = 0; i < normals32.length; i++) {
  109343. fixedNormal32[i] = normals32[i];
  109344. }
  109345. }
  109346. if (!mesh.areNormalsFrozen) {
  109347. mesh.updateVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind, normals32, false, false);
  109348. }
  109349. }
  109350. if (this._depthSort && this._depthSortParticles) {
  109351. var depthSortedParticles = this.depthSortedParticles;
  109352. depthSortedParticles.sort(depthSortFunction);
  109353. var dspl = depthSortedParticles.length;
  109354. var sid = 0;
  109355. for (var sorted = 0; sorted < dspl; sorted++) {
  109356. var lind = depthSortedParticles[sorted].indicesLength;
  109357. var sind = depthSortedParticles[sorted].ind;
  109358. for (var i = 0; i < lind; i++) {
  109359. indices32[sid] = indices[sind + i];
  109360. sid++;
  109361. }
  109362. }
  109363. mesh.updateIndices(indices32);
  109364. }
  109365. }
  109366. if (this._computeBoundingBox) {
  109367. if (mesh._boundingInfo) {
  109368. mesh._boundingInfo.reConstruct(minimum, maximum, mesh._worldMatrix);
  109369. }
  109370. else {
  109371. mesh._boundingInfo = new _Culling_boundingInfo__WEBPACK_IMPORTED_MODULE_7__["BoundingInfo"](minimum, maximum, mesh._worldMatrix);
  109372. }
  109373. }
  109374. this.afterUpdateParticles(start, end, update);
  109375. return this;
  109376. };
  109377. /**
  109378. * Disposes the SPS.
  109379. */
  109380. SolidParticleSystem.prototype.dispose = function () {
  109381. this.mesh.dispose();
  109382. this.vars = null;
  109383. // drop references to internal big arrays for the GC
  109384. this._positions = null;
  109385. this._indices = null;
  109386. this._normals = null;
  109387. this._uvs = null;
  109388. this._colors = null;
  109389. this._indices32 = null;
  109390. this._positions32 = null;
  109391. this._normals32 = null;
  109392. this._fixedNormal32 = null;
  109393. this._uvs32 = null;
  109394. this._colors32 = null;
  109395. this.pickedParticles = null;
  109396. };
  109397. /**
  109398. * Visibilty helper : Recomputes the visible size according to the mesh bounding box
  109399. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109400. * @returns the SPS.
  109401. */
  109402. SolidParticleSystem.prototype.refreshVisibleSize = function () {
  109403. if (!this._isVisibilityBoxLocked) {
  109404. this.mesh.refreshBoundingInfo();
  109405. }
  109406. return this;
  109407. };
  109408. /**
  109409. * Visibility helper : Sets the size of a visibility box, this sets the underlying mesh bounding box.
  109410. * @param size the size (float) of the visibility box
  109411. * note : this doesn't lock the SPS mesh bounding box.
  109412. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109413. */
  109414. SolidParticleSystem.prototype.setVisibilityBox = function (size) {
  109415. var vis = size / 2;
  109416. 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));
  109417. };
  109418. Object.defineProperty(SolidParticleSystem.prototype, "isAlwaysVisible", {
  109419. /**
  109420. * Gets whether the SPS as always visible or not
  109421. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109422. */
  109423. get: function () {
  109424. return this._alwaysVisible;
  109425. },
  109426. /**
  109427. * Sets the SPS as always visible or not
  109428. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109429. */
  109430. set: function (val) {
  109431. this._alwaysVisible = val;
  109432. this.mesh.alwaysSelectAsActiveMesh = val;
  109433. },
  109434. enumerable: true,
  109435. configurable: true
  109436. });
  109437. Object.defineProperty(SolidParticleSystem.prototype, "isVisibilityBoxLocked", {
  109438. /**
  109439. * Gets if the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109440. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109441. */
  109442. get: function () {
  109443. return this._isVisibilityBoxLocked;
  109444. },
  109445. /**
  109446. * Sets the SPS visibility box as locked or not. This enables/disables the underlying mesh bounding box updates.
  109447. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#sps-visibility
  109448. */
  109449. set: function (val) {
  109450. this._isVisibilityBoxLocked = val;
  109451. var boundingInfo = this.mesh.getBoundingInfo();
  109452. boundingInfo.isLocked = val;
  109453. },
  109454. enumerable: true,
  109455. configurable: true
  109456. });
  109457. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleRotation", {
  109458. /**
  109459. * Gets if `setParticles()` computes the particle rotations or not.
  109460. * Default value : true. The SPS is faster when it's set to false.
  109461. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109462. */
  109463. get: function () {
  109464. return this._computeParticleRotation;
  109465. },
  109466. /**
  109467. * Tells to `setParticles()` to compute the particle rotations or not.
  109468. * Default value : true. The SPS is faster when it's set to false.
  109469. * Note : the particle rotations aren't stored values, so setting `computeParticleRotation` to false will prevents the particle to rotate.
  109470. */
  109471. set: function (val) {
  109472. this._computeParticleRotation = val;
  109473. },
  109474. enumerable: true,
  109475. configurable: true
  109476. });
  109477. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleColor", {
  109478. /**
  109479. * Gets if `setParticles()` computes the particle colors or not.
  109480. * Default value : true. The SPS is faster when it's set to false.
  109481. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109482. */
  109483. get: function () {
  109484. return this._computeParticleColor;
  109485. },
  109486. /**
  109487. * Tells to `setParticles()` to compute the particle colors or not.
  109488. * Default value : true. The SPS is faster when it's set to false.
  109489. * Note : the particle colors are stored values, so setting `computeParticleColor` to false will keep yet the last colors set.
  109490. */
  109491. set: function (val) {
  109492. this._computeParticleColor = val;
  109493. },
  109494. enumerable: true,
  109495. configurable: true
  109496. });
  109497. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleTexture", {
  109498. /**
  109499. * Gets if `setParticles()` computes the particle textures or not.
  109500. * Default value : true. The SPS is faster when it's set to false.
  109501. * Note : the particle textures are stored values, so setting `computeParticleTexture` to false will keep yet the last colors set.
  109502. */
  109503. get: function () {
  109504. return this._computeParticleTexture;
  109505. },
  109506. set: function (val) {
  109507. this._computeParticleTexture = val;
  109508. },
  109509. enumerable: true,
  109510. configurable: true
  109511. });
  109512. Object.defineProperty(SolidParticleSystem.prototype, "computeParticleVertex", {
  109513. /**
  109514. * Gets if `setParticles()` calls the vertex function for each vertex of each particle, or not.
  109515. * Default value : false. The SPS is faster when it's set to false.
  109516. * Note : the particle custom vertex positions aren't stored values.
  109517. */
  109518. get: function () {
  109519. return this._computeParticleVertex;
  109520. },
  109521. /**
  109522. * Tells to `setParticles()` to call the vertex function for each vertex of each particle, or not.
  109523. * Default value : false. The SPS is faster when it's set to false.
  109524. * Note : the particle custom vertex positions aren't stored values.
  109525. */
  109526. set: function (val) {
  109527. this._computeParticleVertex = val;
  109528. },
  109529. enumerable: true,
  109530. configurable: true
  109531. });
  109532. Object.defineProperty(SolidParticleSystem.prototype, "computeBoundingBox", {
  109533. /**
  109534. * Gets if `setParticles()` computes or not the mesh bounding box when computing the particle positions.
  109535. */
  109536. get: function () {
  109537. return this._computeBoundingBox;
  109538. },
  109539. /**
  109540. * Tells to `setParticles()` to compute or not the mesh bounding box when computing the particle positions.
  109541. */
  109542. set: function (val) {
  109543. this._computeBoundingBox = val;
  109544. },
  109545. enumerable: true,
  109546. configurable: true
  109547. });
  109548. Object.defineProperty(SolidParticleSystem.prototype, "depthSortParticles", {
  109549. /**
  109550. * Gets if `setParticles()` sorts or not the distance between each particle and the camera.
  109551. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109552. * Default : `true`
  109553. */
  109554. get: function () {
  109555. return this._depthSortParticles;
  109556. },
  109557. /**
  109558. * Tells to `setParticles()` to sort or not the distance between each particle and the camera.
  109559. * Skipped when `enableDepthSort` is set to `false` (default) at construction time.
  109560. * Default : `true`
  109561. */
  109562. set: function (val) {
  109563. this._depthSortParticles = val;
  109564. },
  109565. enumerable: true,
  109566. configurable: true
  109567. });
  109568. // =======================================================================
  109569. // Particle behavior logic
  109570. // these following methods may be overwritten by the user to fit his needs
  109571. /**
  109572. * This function does nothing. It may be overwritten to set all the particle first values.
  109573. * The SPS doesn't call this function, you may have to call it by your own.
  109574. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  109575. */
  109576. SolidParticleSystem.prototype.initParticles = function () {
  109577. };
  109578. /**
  109579. * This function does nothing. It may be overwritten to recycle a particle.
  109580. * The SPS doesn't call this function, you may have to call it by your own.
  109581. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  109582. * @param particle The particle to recycle
  109583. * @returns the recycled particle
  109584. */
  109585. SolidParticleSystem.prototype.recycleParticle = function (particle) {
  109586. return particle;
  109587. };
  109588. /**
  109589. * Updates a particle : this function should be overwritten by the user.
  109590. * It is called on each particle by `setParticles()`. This is the place to code each particle behavior.
  109591. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#particle-management
  109592. * @example : just set a particle position or velocity and recycle conditions
  109593. * @param particle The particle to update
  109594. * @returns the updated particle
  109595. */
  109596. SolidParticleSystem.prototype.updateParticle = function (particle) {
  109597. return particle;
  109598. };
  109599. /**
  109600. * Updates a vertex of a particle : it can be overwritten by the user.
  109601. * This will be called on each vertex particle by `setParticles()` if `computeParticleVertex` is set to true only.
  109602. * @param particle the current particle
  109603. * @param vertex the current index of the current particle
  109604. * @param pt the index of the current vertex in the particle shape
  109605. * doc : http://doc.babylonjs.com/overviews/Solid_Particle_System#update-each-particle-shape
  109606. * @example : just set a vertex particle position
  109607. * @returns the updated vertex
  109608. */
  109609. SolidParticleSystem.prototype.updateParticleVertex = function (particle, vertex, pt) {
  109610. return vertex;
  109611. };
  109612. /**
  109613. * This will be called before any other treatment by `setParticles()` and will be passed three parameters.
  109614. * This does nothing and may be overwritten by the user.
  109615. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109616. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109617. * @param update the boolean update value actually passed to setParticles()
  109618. */
  109619. SolidParticleSystem.prototype.beforeUpdateParticles = function (start, stop, update) {
  109620. };
  109621. /**
  109622. * This will be called by `setParticles()` after all the other treatments and just before the actual mesh update.
  109623. * This will be passed three parameters.
  109624. * This does nothing and may be overwritten by the user.
  109625. * @param start the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109626. * @param stop the particle index in the particle array where to stop to iterate, same than the value passed to setParticle()
  109627. * @param update the boolean update value actually passed to setParticles()
  109628. */
  109629. SolidParticleSystem.prototype.afterUpdateParticles = function (start, stop, update) {
  109630. };
  109631. return SolidParticleSystem;
  109632. }());
  109633. /***/ }),
  109634. /***/ "./Particles/subEmitter.ts":
  109635. /*!*********************************!*\
  109636. !*** ./Particles/subEmitter.ts ***!
  109637. \*********************************/
  109638. /*! exports provided: SubEmitterType, SubEmitter */
  109639. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109640. "use strict";
  109641. __webpack_require__.r(__webpack_exports__);
  109642. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return SubEmitterType; });
  109643. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return SubEmitter; });
  109644. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  109645. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  109646. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  109647. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  109648. /**
  109649. * Type of sub emitter
  109650. */
  109651. var SubEmitterType;
  109652. (function (SubEmitterType) {
  109653. /**
  109654. * Attached to the particle over it's lifetime
  109655. */
  109656. SubEmitterType[SubEmitterType["ATTACHED"] = 0] = "ATTACHED";
  109657. /**
  109658. * Created when the particle dies
  109659. */
  109660. SubEmitterType[SubEmitterType["END"] = 1] = "END";
  109661. })(SubEmitterType || (SubEmitterType = {}));
  109662. /**
  109663. * Sub emitter class used to emit particles from an existing particle
  109664. */
  109665. var SubEmitter = /** @class */ (function () {
  109666. /**
  109667. * Creates a sub emitter
  109668. * @param particleSystem the particle system to be used by the sub emitter
  109669. */
  109670. function SubEmitter(
  109671. /**
  109672. * the particle system to be used by the sub emitter
  109673. */
  109674. particleSystem) {
  109675. this.particleSystem = particleSystem;
  109676. /**
  109677. * Type of the submitter (Default: END)
  109678. */
  109679. this.type = SubEmitterType.END;
  109680. /**
  109681. * 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)
  109682. * Note: This only is supported when using an emitter of type Mesh
  109683. */
  109684. this.inheritDirection = false;
  109685. /**
  109686. * How much of the attached particles speed should be added to the sub emitted particle (default: 0)
  109687. */
  109688. this.inheritedVelocityAmount = 0;
  109689. // Create mesh as emitter to support rotation
  109690. if (!particleSystem.emitter || !particleSystem.emitter.dispose) {
  109691. particleSystem.emitter = new _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]("SubemitterSystemEmitter", particleSystem.getScene());
  109692. }
  109693. // Automatically dispose of subemitter when system is disposed
  109694. particleSystem.onDisposeObservable.add(function () {
  109695. if (particleSystem.emitter && particleSystem.emitter.dispose) {
  109696. particleSystem.emitter.dispose();
  109697. }
  109698. });
  109699. }
  109700. /**
  109701. * Clones the sub emitter
  109702. * @returns the cloned sub emitter
  109703. */
  109704. SubEmitter.prototype.clone = function () {
  109705. // Clone particle system
  109706. var emitter = this.particleSystem.emitter;
  109707. if (!emitter) {
  109708. emitter = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109709. }
  109710. else if (emitter instanceof _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]) {
  109711. emitter = emitter.clone();
  109712. }
  109713. else if (emitter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"]) {
  109714. emitter = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("", emitter.getScene());
  109715. emitter.isVisible = false;
  109716. }
  109717. var clone = new SubEmitter(this.particleSystem.clone("", emitter));
  109718. // Clone properties
  109719. clone.type = this.type;
  109720. clone.inheritDirection = this.inheritDirection;
  109721. clone.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109722. clone.particleSystem._disposeEmitterOnDispose = true;
  109723. clone.particleSystem.disposeOnStop = true;
  109724. return clone;
  109725. };
  109726. /**
  109727. * Serialize current object to a JSON object
  109728. * @returns the serialized object
  109729. */
  109730. SubEmitter.prototype.serialize = function () {
  109731. var serializationObject = {};
  109732. serializationObject.type = this.type;
  109733. serializationObject.inheritDirection = this.inheritDirection;
  109734. serializationObject.inheritedVelocityAmount = this.inheritedVelocityAmount;
  109735. serializationObject.particleSystem = this.particleSystem.serialize();
  109736. return serializationObject;
  109737. };
  109738. /** @hidden */
  109739. SubEmitter._ParseParticleSystem = function (system, scene, rootUrl) {
  109740. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_3__["_DevTools"].WarnImport("ParseParticle");
  109741. };
  109742. /**
  109743. * Creates a new SubEmitter from a serialized JSON version
  109744. * @param serializationObject defines the JSON object to read from
  109745. * @param scene defines the hosting scene
  109746. * @param rootUrl defines the rootUrl for data loading
  109747. * @returns a new SubEmitter
  109748. */
  109749. SubEmitter.Parse = function (serializationObject, scene, rootUrl) {
  109750. var system = serializationObject.particleSystem;
  109751. var subEmitter = new SubEmitter(SubEmitter._ParseParticleSystem(system, scene, rootUrl));
  109752. subEmitter.type = serializationObject.type;
  109753. subEmitter.inheritDirection = serializationObject.inheritDirection;
  109754. subEmitter.inheritedVelocityAmount = serializationObject.inheritedVelocityAmount;
  109755. subEmitter.particleSystem._isSubEmitter = true;
  109756. return subEmitter;
  109757. };
  109758. /** Release associated resources */
  109759. SubEmitter.prototype.dispose = function () {
  109760. this.particleSystem.dispose();
  109761. };
  109762. return SubEmitter;
  109763. }());
  109764. /***/ }),
  109765. /***/ "./Physics/Plugins/ammoJSPlugin.ts":
  109766. /*!*****************************************!*\
  109767. !*** ./Physics/Plugins/ammoJSPlugin.ts ***!
  109768. \*****************************************/
  109769. /*! exports provided: AmmoJSPlugin */
  109770. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  109771. "use strict";
  109772. __webpack_require__.r(__webpack_exports__);
  109773. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return AmmoJSPlugin; });
  109774. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  109775. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  109776. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  109777. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  109778. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  109779. /**
  109780. * AmmoJS Physics plugin
  109781. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  109782. * @see https://github.com/kripken/ammo.js/
  109783. */
  109784. var AmmoJSPlugin = /** @class */ (function () {
  109785. /**
  109786. * Initializes the ammoJS plugin
  109787. * @param _useDeltaForWorldStep if the time between frames should be used when calculating physics steps (Default: true)
  109788. * @param ammoInjection can be used to inject your own ammo reference
  109789. */
  109790. function AmmoJSPlugin(_useDeltaForWorldStep, ammoInjection) {
  109791. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  109792. if (ammoInjection === void 0) { ammoInjection = Ammo; }
  109793. var _this = this;
  109794. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  109795. /**
  109796. * Reference to the Ammo library
  109797. */
  109798. this.bjsAMMO = {};
  109799. /**
  109800. * Name of the plugin
  109801. */
  109802. this.name = "AmmoJSPlugin";
  109803. this._timeStep = 1 / 60;
  109804. this._fixedTimeStep = 1 / 60;
  109805. this._maxSteps = 5;
  109806. this._tmpQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Quaternion"]();
  109807. this._tmpContactCallbackResult = false;
  109808. this._tmpVector = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  109809. this._tmpMatrix = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"]();
  109810. if (typeof ammoInjection === "function") {
  109811. ammoInjection(this.bjsAMMO);
  109812. }
  109813. else {
  109814. this.bjsAMMO = ammoInjection;
  109815. }
  109816. if (!this.isSupported()) {
  109817. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("AmmoJS is not available. Please make sure you included the js file.");
  109818. return;
  109819. }
  109820. // Initialize the physics world
  109821. this._collisionConfiguration = new this.bjsAMMO.btDefaultCollisionConfiguration();
  109822. this._dispatcher = new this.bjsAMMO.btCollisionDispatcher(this._collisionConfiguration);
  109823. this._overlappingPairCache = new this.bjsAMMO.btDbvtBroadphase();
  109824. this._solver = new this.bjsAMMO.btSequentialImpulseConstraintSolver();
  109825. this.world = new this.bjsAMMO.btDiscreteDynamicsWorld(this._dispatcher, this._overlappingPairCache, this._solver, this._collisionConfiguration);
  109826. this._tmpAmmoConcreteContactResultCallback = new this.bjsAMMO.ConcreteContactResultCallback();
  109827. this._tmpAmmoConcreteContactResultCallback.addSingleResult = function () { _this._tmpContactCallbackResult = true; };
  109828. // Create temp ammo variables
  109829. this._tmpAmmoTransform = new this.bjsAMMO.btTransform();
  109830. this._tmpAmmoTransform.setIdentity();
  109831. this._tmpAmmoQuaternion = new this.bjsAMMO.btQuaternion(0, 0, 0, 1);
  109832. this._tmpAmmoVectorA = new this.bjsAMMO.btVector3(0, 0, 0);
  109833. this._tmpAmmoVectorB = new this.bjsAMMO.btVector3(0, 0, 0);
  109834. this._tmpAmmoVectorC = new this.bjsAMMO.btVector3(0, 0, 0);
  109835. }
  109836. /**
  109837. * Sets the gravity of the physics world (m/(s^2))
  109838. * @param gravity Gravity to set
  109839. */
  109840. AmmoJSPlugin.prototype.setGravity = function (gravity) {
  109841. this._tmpAmmoVectorA.setValue(gravity.x, gravity.y, gravity.z);
  109842. this.world.setGravity(this._tmpAmmoVectorA);
  109843. };
  109844. /**
  109845. * Amount of time to step forward on each frame (only used if useDeltaForWorldStep is false in the constructor)
  109846. * @param timeStep timestep to use in seconds
  109847. */
  109848. AmmoJSPlugin.prototype.setTimeStep = function (timeStep) {
  109849. this._timeStep = timeStep;
  109850. };
  109851. /**
  109852. * 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)
  109853. * @param fixedTimeStep fixedTimeStep to use in seconds
  109854. */
  109855. AmmoJSPlugin.prototype.setFixedTimeStep = function (fixedTimeStep) {
  109856. this._fixedTimeStep = fixedTimeStep;
  109857. };
  109858. /**
  109859. * Sets the maximum number of steps by the physics engine per frame (Default: 5)
  109860. * @param maxSteps the maximum number of steps by the physics engine per frame
  109861. */
  109862. AmmoJSPlugin.prototype.setMaxSteps = function (maxSteps) {
  109863. this._maxSteps = maxSteps;
  109864. };
  109865. /**
  109866. * Gets the current timestep (only used if useDeltaForWorldStep is false in the constructor)
  109867. * @returns the current timestep in seconds
  109868. */
  109869. AmmoJSPlugin.prototype.getTimeStep = function () {
  109870. return this._timeStep;
  109871. };
  109872. // Ammo's contactTest and contactPairTest take a callback that runs synchronously, wrap them so that they are easier to consume
  109873. AmmoJSPlugin.prototype._isImpostorInContact = function (impostor) {
  109874. this._tmpContactCallbackResult = false;
  109875. this.world.contactTest(impostor.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109876. return this._tmpContactCallbackResult;
  109877. };
  109878. // Ammo's collision events have some weird quirks
  109879. // contactPairTest fires too many events as it fires events even when objects are close together but contactTest does not
  109880. // so only fire event if both contactTest and contactPairTest have a hit
  109881. AmmoJSPlugin.prototype._isImpostorPairInContact = function (impostorA, impostorB) {
  109882. this._tmpContactCallbackResult = false;
  109883. this.world.contactPairTest(impostorA.physicsBody, impostorB.physicsBody, this._tmpAmmoConcreteContactResultCallback);
  109884. return this._tmpContactCallbackResult;
  109885. };
  109886. // Ammo's behavior when maxSteps > 0 does not behave as described in docs
  109887. // @see http://www.bulletphysics.org/mediawiki-1.5.8/index.php/Stepping_The_World
  109888. //
  109889. // When maxSteps is 0 do the entire simulation in one step
  109890. // 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)
  109891. // Note: To get deterministic physics, timeStep would always need to be divisible by fixedTimeStep
  109892. AmmoJSPlugin.prototype._stepSimulation = function (timeStep, maxSteps, fixedTimeStep) {
  109893. if (timeStep === void 0) { timeStep = 1 / 60; }
  109894. if (maxSteps === void 0) { maxSteps = 10; }
  109895. if (fixedTimeStep === void 0) { fixedTimeStep = 1 / 60; }
  109896. if (maxSteps == 0) {
  109897. this.world.stepSimulation(timeStep, 0);
  109898. }
  109899. else {
  109900. while (maxSteps > 0 && timeStep > 0) {
  109901. if (timeStep - fixedTimeStep < fixedTimeStep) {
  109902. this.world.stepSimulation(timeStep, 0);
  109903. timeStep = 0;
  109904. }
  109905. else {
  109906. timeStep -= fixedTimeStep;
  109907. this.world.stepSimulation(fixedTimeStep, 0);
  109908. }
  109909. maxSteps--;
  109910. }
  109911. }
  109912. };
  109913. /**
  109914. * Moves the physics simulation forward delta seconds and updates the given physics imposters
  109915. * Prior to the step the imposters physics location is set to the position of the babylon meshes
  109916. * After the step the babylon meshes are set to the position of the physics imposters
  109917. * @param delta amount of time to step forward
  109918. * @param impostors array of imposters to update before/after the step
  109919. */
  109920. AmmoJSPlugin.prototype.executeStep = function (delta, impostors) {
  109921. for (var _i = 0, impostors_1 = impostors; _i < impostors_1.length; _i++) {
  109922. var impostor = impostors_1[_i];
  109923. // Update physics world objects to match babylon world
  109924. impostor.beforeStep();
  109925. }
  109926. this._stepSimulation(this._useDeltaForWorldStep ? delta : this._timeStep, this._maxSteps, this._fixedTimeStep);
  109927. for (var _a = 0, impostors_2 = impostors; _a < impostors_2.length; _a++) {
  109928. var mainImpostor = impostors_2[_a];
  109929. // After physics update make babylon world objects match physics world objects
  109930. mainImpostor.afterStep();
  109931. // Handle collision event
  109932. if (mainImpostor._onPhysicsCollideCallbacks.length > 0) {
  109933. if (this._isImpostorInContact(mainImpostor)) {
  109934. for (var _b = 0, _c = mainImpostor._onPhysicsCollideCallbacks; _b < _c.length; _b++) {
  109935. var collideCallback = _c[_b];
  109936. for (var _d = 0, _e = collideCallback.otherImpostors; _d < _e.length; _d++) {
  109937. var otherImpostor = _e[_d];
  109938. if (mainImpostor.physicsBody.isActive() || otherImpostor.physicsBody.isActive()) {
  109939. if (this._isImpostorPairInContact(mainImpostor, otherImpostor)) {
  109940. mainImpostor.onCollide({ body: otherImpostor.physicsBody });
  109941. otherImpostor.onCollide({ body: mainImpostor.physicsBody });
  109942. }
  109943. }
  109944. }
  109945. }
  109946. }
  109947. }
  109948. }
  109949. };
  109950. /**
  109951. * Applies an implulse on the imposter
  109952. * @param impostor imposter to apply impulse
  109953. * @param force amount of force to be applied to the imposter
  109954. * @param contactPoint the location to apply the impulse on the imposter
  109955. */
  109956. AmmoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  109957. impostor.physicsBody.activate();
  109958. var worldPoint = this._tmpAmmoVectorA;
  109959. var impulse = this._tmpAmmoVectorB;
  109960. // Convert contactPoint into world space
  109961. if (impostor.object && impostor.object.getWorldMatrix) {
  109962. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109963. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109964. contactPoint = this._tmpVector;
  109965. }
  109966. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109967. impulse.setValue(force.x, force.y, force.z);
  109968. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  109969. };
  109970. /**
  109971. * Applies a force on the imposter
  109972. * @param impostor imposter to apply force
  109973. * @param force amount of force to be applied to the imposter
  109974. * @param contactPoint the location to apply the force on the imposter
  109975. */
  109976. AmmoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  109977. impostor.physicsBody.activate();
  109978. var worldPoint = this._tmpAmmoVectorA;
  109979. var impulse = this._tmpAmmoVectorB;
  109980. // Convert contactPoint into world space
  109981. if (impostor.object && impostor.object.getWorldMatrix) {
  109982. impostor.object.getWorldMatrix().invertToRef(this._tmpMatrix);
  109983. _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinatesToRef(contactPoint, this._tmpMatrix, this._tmpVector);
  109984. contactPoint = this._tmpVector;
  109985. }
  109986. worldPoint.setValue(contactPoint.x, contactPoint.y, contactPoint.z);
  109987. impulse.setValue(force.x, force.y, force.z);
  109988. impostor.physicsBody.applyForce(impulse, worldPoint);
  109989. };
  109990. /**
  109991. * Creates a physics body using the plugin
  109992. * @param impostor the imposter to create the physics body on
  109993. */
  109994. AmmoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  109995. impostor._pluginData = { toDispose: [] };
  109996. //parent-child relationship
  109997. if (impostor.parent) {
  109998. if (impostor.physicsBody) {
  109999. this.removePhysicsBody(impostor);
  110000. impostor.forceUpdate();
  110001. }
  110002. return;
  110003. }
  110004. if (impostor.isBodyInitRequired()) {
  110005. var colShape = this._createShape(impostor);
  110006. var mass = impostor.getParam("mass");
  110007. impostor._pluginData.mass = mass;
  110008. var localInertia = new Ammo.btVector3(0, 0, 0);
  110009. var startTransform = new Ammo.btTransform();
  110010. startTransform.setIdentity();
  110011. if (mass !== 0) {
  110012. colShape.calculateLocalInertia(mass, localInertia);
  110013. }
  110014. this._tmpAmmoVectorA.setValue(impostor.object.position.x, impostor.object.position.y, impostor.object.position.z);
  110015. this._tmpAmmoQuaternion.setValue(impostor.object.rotationQuaternion.x, impostor.object.rotationQuaternion.y, impostor.object.rotationQuaternion.z, impostor.object.rotationQuaternion.w);
  110016. startTransform.setOrigin(this._tmpAmmoVectorA);
  110017. startTransform.setRotation(this._tmpAmmoQuaternion);
  110018. var myMotionState = new Ammo.btDefaultMotionState(startTransform);
  110019. var rbInfo = new Ammo.btRigidBodyConstructionInfo(mass, myMotionState, colShape, localInertia);
  110020. var body = new Ammo.btRigidBody(rbInfo);
  110021. // Make objects kinematic if it's mass is 0
  110022. if (mass === 0) {
  110023. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.KINEMATIC_FLAG);
  110024. body.setActivationState(AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG);
  110025. }
  110026. // Disable collision if NoImpostor, but keep collision if shape is btCompoundShape
  110027. if (impostor.type == _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor && !colShape.getChildShape) {
  110028. body.setCollisionFlags(body.getCollisionFlags() | AmmoJSPlugin.DISABLE_COLLISION_FLAG);
  110029. }
  110030. this.world.addRigidBody(body);
  110031. impostor.physicsBody = body;
  110032. this.setBodyRestitution(impostor, impostor.getParam("restitution"));
  110033. this.setBodyFriction(impostor, impostor.getParam("friction"));
  110034. impostor._pluginData.toDispose.concat([body, rbInfo, myMotionState, startTransform, localInertia, colShape]);
  110035. }
  110036. };
  110037. /**
  110038. * Removes the physics body from the imposter and disposes of the body's memory
  110039. * @param impostor imposter to remove the physics body from
  110040. */
  110041. AmmoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110042. var _this = this;
  110043. if (this.world) {
  110044. this.world.removeRigidBody(impostor.physicsBody);
  110045. impostor._pluginData.toDispose.forEach(function (d) {
  110046. _this.bjsAMMO.destroy(d);
  110047. });
  110048. }
  110049. };
  110050. /**
  110051. * Generates a joint
  110052. * @param impostorJoint the imposter joint to create the joint with
  110053. */
  110054. AmmoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110055. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110056. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110057. if (!mainBody || !connectedBody) {
  110058. return;
  110059. }
  110060. var jointData = impostorJoint.joint.jointData;
  110061. if (!jointData.mainPivot) {
  110062. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110063. }
  110064. if (!jointData.connectedPivot) {
  110065. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110066. }
  110067. var joint;
  110068. switch (impostorJoint.joint.type) {
  110069. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].DistanceJoint:
  110070. var distance = jointData.maxDistance;
  110071. if (distance) {
  110072. jointData.mainPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -distance / 2, 0);
  110073. jointData.connectedPivot = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, distance / 2, 0);
  110074. }
  110075. 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));
  110076. break;
  110077. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].HingeJoint:
  110078. if (!jointData.mainAxis) {
  110079. jointData.mainAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110080. }
  110081. if (!jointData.connectedAxis) {
  110082. jointData.connectedAxis = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, 0, 0);
  110083. }
  110084. var mainAxis = new Ammo.btVector3(jointData.mainAxis.x, jointData.mainAxis.y, jointData.mainAxis.z);
  110085. var connectedAxis = new Ammo.btVector3(jointData.connectedAxis.x, jointData.connectedAxis.y, jointData.connectedAxis.z);
  110086. 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);
  110087. break;
  110088. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_3__["PhysicsJoint"].BallAndSocketJoint:
  110089. 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));
  110090. break;
  110091. default:
  110092. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("JointType not currently supported by the Ammo plugin, falling back to PhysicsJoint.BallAndSocketJoint");
  110093. 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));
  110094. break;
  110095. }
  110096. this.world.addConstraint(joint, !impostorJoint.joint.jointData.collision);
  110097. impostorJoint.joint.physicsJoint = joint;
  110098. };
  110099. /**
  110100. * Removes a joint
  110101. * @param impostorJoint the imposter joint to remove the joint from
  110102. */
  110103. AmmoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110104. if (this.world) {
  110105. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  110106. }
  110107. };
  110108. // adds all verticies (including child verticies) to the triangle mesh
  110109. AmmoJSPlugin.prototype._addMeshVerts = function (btTriangleMesh, topLevelObject, object) {
  110110. var _this = this;
  110111. var triangleCount = 0;
  110112. if (object && object.getIndices && object.getWorldMatrix && object.getChildMeshes) {
  110113. var indices = object.getIndices();
  110114. if (!indices) {
  110115. indices = [];
  110116. }
  110117. var vertexPositions = object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind);
  110118. if (!vertexPositions) {
  110119. vertexPositions = [];
  110120. }
  110121. object.computeWorldMatrix(false);
  110122. var faceCount = indices.length / 3;
  110123. for (var i = 0; i < faceCount; i++) {
  110124. var triPoints = [];
  110125. for (var point = 0; point < 3; point++) {
  110126. 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]);
  110127. v = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].TransformCoordinates(v, object.getWorldMatrix());
  110128. v.subtractInPlace(topLevelObject.position);
  110129. var vec;
  110130. if (point == 0) {
  110131. vec = this._tmpAmmoVectorA;
  110132. }
  110133. else if (point == 1) {
  110134. vec = this._tmpAmmoVectorB;
  110135. }
  110136. else {
  110137. vec = this._tmpAmmoVectorC;
  110138. }
  110139. vec.setValue(v.x, v.y, v.z);
  110140. triPoints.push(vec);
  110141. }
  110142. btTriangleMesh.addTriangle(triPoints[0], triPoints[1], triPoints[2]);
  110143. triangleCount++;
  110144. }
  110145. object.getChildMeshes().forEach(function (m) {
  110146. triangleCount += _this._addMeshVerts(btTriangleMesh, topLevelObject, m);
  110147. });
  110148. }
  110149. return triangleCount;
  110150. };
  110151. AmmoJSPlugin.prototype._createShape = function (impostor, ignoreChildren) {
  110152. var _this = this;
  110153. if (ignoreChildren === void 0) { ignoreChildren = false; }
  110154. var object = impostor.object;
  110155. var returnValue;
  110156. var extendSize = impostor.getObjectExtendSize();
  110157. if (!ignoreChildren) {
  110158. var meshChildren = impostor.object.getChildMeshes ? impostor.object.getChildMeshes(true) : [];
  110159. returnValue = new Ammo.btCompoundShape();
  110160. // Add shape of all children to the compound shape
  110161. var childrenAdded = 0;
  110162. meshChildren.forEach(function (childMesh) {
  110163. var childImpostor = childMesh.getPhysicsImpostor();
  110164. if (childImpostor) {
  110165. var shape = _this._createShape(childImpostor);
  110166. // Position needs to be scaled based on parent's scaling
  110167. var parentMat = childMesh.parent.getWorldMatrix().clone();
  110168. var s = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"]();
  110169. parentMat.decompose(s);
  110170. _this._tmpAmmoTransform.getOrigin().setValue(childMesh.position.x * s.x, childMesh.position.y * s.y, childMesh.position.z * s.z);
  110171. _this._tmpAmmoQuaternion.setValue(childMesh.rotationQuaternion.x, childMesh.rotationQuaternion.y, childMesh.rotationQuaternion.z, childMesh.rotationQuaternion.w);
  110172. _this._tmpAmmoTransform.setRotation(_this._tmpAmmoQuaternion);
  110173. returnValue.addChildShape(_this._tmpAmmoTransform, shape);
  110174. childImpostor.dispose();
  110175. childrenAdded++;
  110176. }
  110177. });
  110178. if (childrenAdded > 0) {
  110179. // Add parents shape as a child if present
  110180. if (impostor.type != _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor) {
  110181. var shape = this._createShape(impostor, true);
  110182. if (shape) {
  110183. this._tmpAmmoTransform.getOrigin().setValue(0, 0, 0);
  110184. this._tmpAmmoQuaternion.setValue(0, 0, 0, 1);
  110185. this._tmpAmmoTransform.setRotation(this._tmpAmmoQuaternion);
  110186. returnValue.addChildShape(this._tmpAmmoTransform, shape);
  110187. }
  110188. }
  110189. return returnValue;
  110190. }
  110191. else {
  110192. // If no children with impostors create the actual shape below instead
  110193. Ammo.destroy(returnValue);
  110194. returnValue = null;
  110195. }
  110196. }
  110197. switch (impostor.type) {
  110198. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].SphereImpostor:
  110199. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  110200. break;
  110201. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].CylinderImpostor:
  110202. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  110203. returnValue = new Ammo.btCylinderShape(this._tmpAmmoVectorA);
  110204. break;
  110205. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].PlaneImpostor:
  110206. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].BoxImpostor:
  110207. this._tmpAmmoVectorA.setValue(extendSize.x / 2, extendSize.y / 2, extendSize.z / 2);
  110208. returnValue = new Ammo.btBoxShape(this._tmpAmmoVectorA);
  110209. break;
  110210. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].MeshImpostor:
  110211. var tetraMesh = new Ammo.btTriangleMesh();
  110212. impostor._pluginData.toDispose.concat([tetraMesh]);
  110213. var triangeCount = this._addMeshVerts(tetraMesh, object, object);
  110214. if (triangeCount == 0) {
  110215. returnValue = new Ammo.btCompoundShape();
  110216. }
  110217. else {
  110218. returnValue = new Ammo.btBvhTriangleMeshShape(tetraMesh);
  110219. }
  110220. break;
  110221. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_2__["PhysicsImpostor"].NoImpostor:
  110222. // Fill with sphere but collision is disabled on the rigid body in generatePhysicsBody, using an empty shape caused unexpected movement with joints
  110223. returnValue = new Ammo.btSphereShape(extendSize.x / 2);
  110224. break;
  110225. default:
  110226. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("The impostor type is not currently supported by the ammo plugin.");
  110227. break;
  110228. }
  110229. return returnValue;
  110230. };
  110231. /**
  110232. * Sets the physics body position/rotation from the babylon mesh's position/rotation
  110233. * @param impostor imposter containing the physics body and babylon object
  110234. */
  110235. AmmoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110236. impostor.physicsBody.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  110237. impostor.object.position.set(this._tmpAmmoTransform.getOrigin().x(), this._tmpAmmoTransform.getOrigin().y(), this._tmpAmmoTransform.getOrigin().z());
  110238. if (!impostor.object.rotationQuaternion) {
  110239. if (impostor.object.rotation) {
  110240. this._tmpQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  110241. this._tmpQuaternion.toEulerAnglesToRef(impostor.object.rotation);
  110242. }
  110243. }
  110244. else {
  110245. impostor.object.rotationQuaternion.set(this._tmpAmmoTransform.getRotation().x(), this._tmpAmmoTransform.getRotation().y(), this._tmpAmmoTransform.getRotation().z(), this._tmpAmmoTransform.getRotation().w());
  110246. }
  110247. };
  110248. /**
  110249. * Sets the babylon object's position/rotation from the physics body's position/rotation
  110250. * @param impostor imposter containing the physics body and babylon object
  110251. * @param newPosition new position
  110252. * @param newRotation new rotation
  110253. */
  110254. AmmoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110255. var trans = impostor.physicsBody.getWorldTransform();
  110256. // If rotation/position has changed update and activate riged body
  110257. if (trans.getOrigin().x() != newPosition.x ||
  110258. trans.getOrigin().y() != newPosition.y ||
  110259. trans.getOrigin().z() != newPosition.z ||
  110260. trans.getRotation().x() != newRotation.x ||
  110261. trans.getRotation().y() != newRotation.y ||
  110262. trans.getRotation().z() != newRotation.z ||
  110263. trans.getRotation().w() != newRotation.w) {
  110264. this._tmpAmmoVectorA.setValue(newPosition.x, newPosition.y, newPosition.z);
  110265. trans.setOrigin(this._tmpAmmoVectorA);
  110266. this._tmpAmmoQuaternion.setValue(newRotation.x, newRotation.y, newRotation.z, newRotation.w);
  110267. trans.setRotation(this._tmpAmmoQuaternion);
  110268. impostor.physicsBody.setWorldTransform(trans);
  110269. if (impostor.mass == 0) {
  110270. // Kinematic objects must be updated using motion state
  110271. var motionState = impostor.physicsBody.getMotionState();
  110272. if (motionState) {
  110273. motionState.setWorldTransform(trans);
  110274. }
  110275. }
  110276. else {
  110277. impostor.physicsBody.activate();
  110278. }
  110279. }
  110280. };
  110281. /**
  110282. * If this plugin is supported
  110283. * @returns true if its supported
  110284. */
  110285. AmmoJSPlugin.prototype.isSupported = function () {
  110286. return this.bjsAMMO !== undefined;
  110287. };
  110288. /**
  110289. * Sets the linear velocity of the physics body
  110290. * @param impostor imposter to set the velocity on
  110291. * @param velocity velocity to set
  110292. */
  110293. AmmoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110294. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  110295. impostor.physicsBody.setLinearVelocity(this._tmpAmmoVectorA);
  110296. };
  110297. /**
  110298. * Sets the angular velocity of the physics body
  110299. * @param impostor imposter to set the velocity on
  110300. * @param velocity velocity to set
  110301. */
  110302. AmmoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110303. this._tmpAmmoVectorA.setValue(velocity.x, velocity.y, velocity.z);
  110304. impostor.physicsBody.setAngularVelocity(this._tmpAmmoVectorA);
  110305. };
  110306. /**
  110307. * gets the linear velocity
  110308. * @param impostor imposter to get linear velocity from
  110309. * @returns linear velocity
  110310. */
  110311. AmmoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110312. var v = impostor.physicsBody.getLinearVelocity();
  110313. if (!v) {
  110314. return null;
  110315. }
  110316. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  110317. };
  110318. /**
  110319. * gets the angular velocity
  110320. * @param impostor imposter to get angular velocity from
  110321. * @returns angular velocity
  110322. */
  110323. AmmoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110324. var v = impostor.physicsBody.getAngularVelocity();
  110325. if (!v) {
  110326. return null;
  110327. }
  110328. return new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](v.x(), v.y(), v.z());
  110329. };
  110330. /**
  110331. * Sets the mass of physics body
  110332. * @param impostor imposter to set the mass on
  110333. * @param mass mass to set
  110334. */
  110335. AmmoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110336. impostor.physicsBody.setMassProps(mass);
  110337. impostor._pluginData.mass = mass;
  110338. };
  110339. /**
  110340. * Gets the mass of the physics body
  110341. * @param impostor imposter to get the mass from
  110342. * @returns mass
  110343. */
  110344. AmmoJSPlugin.prototype.getBodyMass = function (impostor) {
  110345. return impostor._pluginData.mass;
  110346. };
  110347. /**
  110348. * Gets friction of the impostor
  110349. * @param impostor impostor to get friction from
  110350. * @returns friction value
  110351. */
  110352. AmmoJSPlugin.prototype.getBodyFriction = function (impostor) {
  110353. return impostor._pluginData.friction;
  110354. };
  110355. /**
  110356. * Sets friction of the impostor
  110357. * @param impostor impostor to set friction on
  110358. * @param friction friction value
  110359. */
  110360. AmmoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110361. impostor.physicsBody.setFriction(friction);
  110362. impostor._pluginData.friction = friction;
  110363. };
  110364. /**
  110365. * Gets restitution of the impostor
  110366. * @param impostor impostor to get restitution from
  110367. * @returns restitution value
  110368. */
  110369. AmmoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110370. return impostor._pluginData.restitution;
  110371. };
  110372. /**
  110373. * Sets resitution of the impostor
  110374. * @param impostor impostor to set resitution on
  110375. * @param restitution resitution value
  110376. */
  110377. AmmoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110378. impostor.physicsBody.setRestitution(restitution);
  110379. impostor._pluginData.restitution = restitution;
  110380. };
  110381. /**
  110382. * Sleeps the physics body and stops it from being active
  110383. * @param impostor impostor to sleep
  110384. */
  110385. AmmoJSPlugin.prototype.sleepBody = function (impostor) {
  110386. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("sleepBody is not currently supported by the Ammo physics plugin");
  110387. };
  110388. /**
  110389. * Activates the physics body
  110390. * @param impostor impostor to activate
  110391. */
  110392. AmmoJSPlugin.prototype.wakeUpBody = function (impostor) {
  110393. impostor.physicsBody.activate();
  110394. };
  110395. /**
  110396. * Updates the distance parameters of the joint
  110397. * @param joint joint to update
  110398. * @param maxDistance maximum distance of the joint
  110399. * @param minDistance minimum distance of the joint
  110400. */
  110401. AmmoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  110402. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("updateDistanceJoint is not currently supported by the Ammo physics plugin");
  110403. };
  110404. /**
  110405. * Sets a motor on the joint
  110406. * @param joint joint to set motor on
  110407. * @param speed speed of the motor
  110408. * @param maxForce maximum force of the motor
  110409. * @param motorIndex index of the motor
  110410. */
  110411. AmmoJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  110412. joint.physicsJoint.enableAngularMotor(true, speed, maxForce);
  110413. };
  110414. /**
  110415. * Sets the motors limit
  110416. * @param joint joint to set limit on
  110417. * @param upperLimit upper limit
  110418. * @param lowerLimit lower limit
  110419. */
  110420. AmmoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  110421. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("setLimit is not currently supported by the Ammo physics plugin");
  110422. };
  110423. /**
  110424. * Syncs the position and rotation of a mesh with the impostor
  110425. * @param mesh mesh to sync
  110426. * @param impostor impostor to update the mesh with
  110427. */
  110428. AmmoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  110429. var body = impostor.physicsBody;
  110430. body.getMotionState().getWorldTransform(this._tmpAmmoTransform);
  110431. mesh.position.x = this._tmpAmmoTransform.getOrigin().x();
  110432. mesh.position.y = this._tmpAmmoTransform.getOrigin().y();
  110433. mesh.position.z = this._tmpAmmoTransform.getOrigin().z();
  110434. if (mesh.rotationQuaternion) {
  110435. mesh.rotationQuaternion.x = this._tmpAmmoTransform.getRotation().x();
  110436. mesh.rotationQuaternion.y = this._tmpAmmoTransform.getRotation().y();
  110437. mesh.rotationQuaternion.z = this._tmpAmmoTransform.getRotation().z();
  110438. mesh.rotationQuaternion.w = this._tmpAmmoTransform.getRotation().w();
  110439. }
  110440. };
  110441. /**
  110442. * Gets the radius of the impostor
  110443. * @param impostor impostor to get radius from
  110444. * @returns the radius
  110445. */
  110446. AmmoJSPlugin.prototype.getRadius = function (impostor) {
  110447. var exntend = impostor.getObjectExtendSize();
  110448. return exntend.x / 2;
  110449. };
  110450. /**
  110451. * Gets the box size of the impostor
  110452. * @param impostor impostor to get box size from
  110453. * @param result the resulting box size
  110454. */
  110455. AmmoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  110456. var exntend = impostor.getObjectExtendSize();
  110457. result.x = exntend.x;
  110458. result.y = exntend.y;
  110459. result.z = exntend.z;
  110460. };
  110461. /**
  110462. * Disposes of the impostor
  110463. */
  110464. AmmoJSPlugin.prototype.dispose = function () {
  110465. // Dispose of world
  110466. Ammo.destroy(this.world);
  110467. Ammo.destroy(this._solver);
  110468. Ammo.destroy(this._overlappingPairCache);
  110469. Ammo.destroy(this._dispatcher);
  110470. Ammo.destroy(this._collisionConfiguration);
  110471. // Dispose of tmp variables
  110472. Ammo.destroy(this._tmpAmmoVectorA);
  110473. Ammo.destroy(this._tmpAmmoVectorB);
  110474. Ammo.destroy(this._tmpAmmoVectorC);
  110475. Ammo.destroy(this._tmpAmmoTransform);
  110476. Ammo.destroy(this._tmpAmmoQuaternion);
  110477. Ammo.destroy(this._tmpAmmoConcreteContactResultCallback);
  110478. this.world = null;
  110479. };
  110480. AmmoJSPlugin.DISABLE_COLLISION_FLAG = 4;
  110481. AmmoJSPlugin.KINEMATIC_FLAG = 2;
  110482. AmmoJSPlugin.DISABLE_DEACTIVATION_FLAG = 4;
  110483. return AmmoJSPlugin;
  110484. }());
  110485. /***/ }),
  110486. /***/ "./Physics/Plugins/cannonJSPlugin.ts":
  110487. /*!*******************************************!*\
  110488. !*** ./Physics/Plugins/cannonJSPlugin.ts ***!
  110489. \*******************************************/
  110490. /*! exports provided: CannonJSPlugin */
  110491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  110492. "use strict";
  110493. __webpack_require__.r(__webpack_exports__);
  110494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return CannonJSPlugin; });
  110495. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  110496. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  110497. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Meshes/buffer */ "./Meshes/buffer.ts");
  110498. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  110499. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  110500. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  110501. /** @hidden */
  110502. var CannonJSPlugin = /** @class */ (function () {
  110503. function CannonJSPlugin(_useDeltaForWorldStep, iterations, cannonInjection) {
  110504. if (_useDeltaForWorldStep === void 0) { _useDeltaForWorldStep = true; }
  110505. if (iterations === void 0) { iterations = 10; }
  110506. if (cannonInjection === void 0) { cannonInjection = CANNON; }
  110507. this._useDeltaForWorldStep = _useDeltaForWorldStep;
  110508. this.name = "CannonJSPlugin";
  110509. this._physicsMaterials = new Array();
  110510. this._fixedTimeStep = 1 / 60;
  110511. this._minus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](-0.7071067811865475, 0, 0, 0.7071067811865475);
  110512. this._plus90X = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"](0.7071067811865475, 0, 0, 0.7071067811865475);
  110513. this._tmpPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  110514. this._tmpDeltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  110515. this._tmpUnityRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"]();
  110516. this.BJSCANNON = cannonInjection;
  110517. if (!this.isSupported()) {
  110518. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("CannonJS is not available. Please make sure you included the js file.");
  110519. return;
  110520. }
  110521. this._extendNamespace();
  110522. this.world = new this.BJSCANNON.World();
  110523. this.world.broadphase = new this.BJSCANNON.NaiveBroadphase();
  110524. this.world.solver.iterations = iterations;
  110525. }
  110526. CannonJSPlugin.prototype.setGravity = function (gravity) {
  110527. this.world.gravity.copy(gravity);
  110528. };
  110529. CannonJSPlugin.prototype.setTimeStep = function (timeStep) {
  110530. this._fixedTimeStep = timeStep;
  110531. };
  110532. CannonJSPlugin.prototype.getTimeStep = function () {
  110533. return this._fixedTimeStep;
  110534. };
  110535. CannonJSPlugin.prototype.executeStep = function (delta) {
  110536. this.world.step(this._fixedTimeStep, this._useDeltaForWorldStep ? delta : 0, 3);
  110537. };
  110538. CannonJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  110539. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  110540. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  110541. impostor.physicsBody.applyImpulse(impulse, worldPoint);
  110542. };
  110543. CannonJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  110544. var worldPoint = new this.BJSCANNON.Vec3(contactPoint.x, contactPoint.y, contactPoint.z);
  110545. var impulse = new this.BJSCANNON.Vec3(force.x, force.y, force.z);
  110546. impostor.physicsBody.applyForce(impulse, worldPoint);
  110547. };
  110548. CannonJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  110549. //parent-child relationship. Does this impostor has a parent impostor?
  110550. if (impostor.parent) {
  110551. if (impostor.physicsBody) {
  110552. this.removePhysicsBody(impostor);
  110553. //TODO is that needed?
  110554. impostor.forceUpdate();
  110555. }
  110556. return;
  110557. }
  110558. //should a new body be created for this impostor?
  110559. if (impostor.isBodyInitRequired()) {
  110560. var shape = this._createShape(impostor);
  110561. //unregister events, if body is being changed
  110562. var oldBody = impostor.physicsBody;
  110563. if (oldBody) {
  110564. this.removePhysicsBody(impostor);
  110565. }
  110566. //create the body and material
  110567. var material = this._addMaterial("mat-" + impostor.uniqueId, impostor.getParam("friction"), impostor.getParam("restitution"));
  110568. var bodyCreationObject = {
  110569. mass: impostor.getParam("mass"),
  110570. material: material
  110571. };
  110572. // A simple extend, in case native options were used.
  110573. var nativeOptions = impostor.getParam("nativeOptions");
  110574. for (var key in nativeOptions) {
  110575. if (nativeOptions.hasOwnProperty(key)) {
  110576. bodyCreationObject[key] = nativeOptions[key];
  110577. }
  110578. }
  110579. impostor.physicsBody = new this.BJSCANNON.Body(bodyCreationObject);
  110580. impostor.physicsBody.addEventListener("collide", impostor.onCollide);
  110581. this.world.addEventListener("preStep", impostor.beforeStep);
  110582. this.world.addEventListener("postStep", impostor.afterStep);
  110583. impostor.physicsBody.addShape(shape);
  110584. this.world.add(impostor.physicsBody);
  110585. //try to keep the body moving in the right direction by taking old properties.
  110586. //Should be tested!
  110587. if (oldBody) {
  110588. ['force', 'torque', 'velocity', 'angularVelocity'].forEach(function (param) {
  110589. impostor.physicsBody[param].copy(oldBody[param]);
  110590. });
  110591. }
  110592. this._processChildMeshes(impostor);
  110593. }
  110594. //now update the body's transformation
  110595. this._updatePhysicsBodyTransformation(impostor);
  110596. };
  110597. CannonJSPlugin.prototype._processChildMeshes = function (mainImpostor) {
  110598. var _this = this;
  110599. var meshChildren = mainImpostor.object.getChildMeshes ? mainImpostor.object.getChildMeshes(true) : [];
  110600. var currentRotation = mainImpostor.object.rotationQuaternion;
  110601. if (meshChildren.length) {
  110602. var processMesh = function (localPosition, mesh) {
  110603. if (!currentRotation || !mesh.rotationQuaternion) {
  110604. return;
  110605. }
  110606. var childImpostor = mesh.getPhysicsImpostor();
  110607. if (childImpostor) {
  110608. var parent = childImpostor.parent;
  110609. if (parent !== mainImpostor) {
  110610. var pPosition = mesh.getAbsolutePosition().subtract(mainImpostor.object.getAbsolutePosition());
  110611. var localRotation = mesh.rotationQuaternion.multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Quaternion"].Inverse(currentRotation));
  110612. if (childImpostor.physicsBody) {
  110613. _this.removePhysicsBody(childImpostor);
  110614. childImpostor.physicsBody = null;
  110615. }
  110616. childImpostor.parent = mainImpostor;
  110617. childImpostor.resetUpdateFlags();
  110618. 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));
  110619. //Add the mass of the children.
  110620. mainImpostor.physicsBody.mass += childImpostor.getParam("mass");
  110621. }
  110622. }
  110623. currentRotation.multiplyInPlace(mesh.rotationQuaternion);
  110624. mesh.getChildMeshes(true).filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(_this, mesh.getAbsolutePosition()));
  110625. };
  110626. meshChildren.filter(function (m) { return !!m.physicsImpostor; }).forEach(processMesh.bind(this, mainImpostor.object.getAbsolutePosition()));
  110627. }
  110628. };
  110629. CannonJSPlugin.prototype.removePhysicsBody = function (impostor) {
  110630. impostor.physicsBody.removeEventListener("collide", impostor.onCollide);
  110631. this.world.removeEventListener("preStep", impostor.beforeStep);
  110632. this.world.removeEventListener("postStep", impostor.afterStep);
  110633. this.world.remove(impostor.physicsBody);
  110634. };
  110635. CannonJSPlugin.prototype.generateJoint = function (impostorJoint) {
  110636. var mainBody = impostorJoint.mainImpostor.physicsBody;
  110637. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  110638. if (!mainBody || !connectedBody) {
  110639. return;
  110640. }
  110641. var constraint;
  110642. var jointData = impostorJoint.joint.jointData;
  110643. //TODO - https://github.com/schteppe/this.BJSCANNON.js/blob/gh-pages/demos/collisionFilter.html
  110644. var constraintData = {
  110645. pivotA: jointData.mainPivot ? new this.BJSCANNON.Vec3().copy(jointData.mainPivot) : null,
  110646. pivotB: jointData.connectedPivot ? new this.BJSCANNON.Vec3().copy(jointData.connectedPivot) : null,
  110647. axisA: jointData.mainAxis ? new this.BJSCANNON.Vec3().copy(jointData.mainAxis) : null,
  110648. axisB: jointData.connectedAxis ? new this.BJSCANNON.Vec3().copy(jointData.connectedAxis) : null,
  110649. maxForce: jointData.nativeParams.maxForce,
  110650. collideConnected: !!jointData.collision
  110651. };
  110652. switch (impostorJoint.joint.type) {
  110653. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].HingeJoint:
  110654. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].Hinge2Joint:
  110655. constraint = new this.BJSCANNON.HingeConstraint(mainBody, connectedBody, constraintData);
  110656. break;
  110657. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].DistanceJoint:
  110658. constraint = new this.BJSCANNON.DistanceConstraint(mainBody, connectedBody, jointData.maxDistance || 2);
  110659. break;
  110660. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint:
  110661. var springData = jointData;
  110662. constraint = new this.BJSCANNON.Spring(mainBody, connectedBody, {
  110663. restLength: springData.length,
  110664. stiffness: springData.stiffness,
  110665. damping: springData.damping,
  110666. localAnchorA: constraintData.pivotA,
  110667. localAnchorB: constraintData.pivotB
  110668. });
  110669. break;
  110670. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].LockJoint:
  110671. constraint = new this.BJSCANNON.LockConstraint(mainBody, connectedBody, constraintData);
  110672. break;
  110673. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].PointToPointJoint:
  110674. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].BallAndSocketJoint:
  110675. default:
  110676. constraint = new this.BJSCANNON.PointToPointConstraint(mainBody, constraintData.pivotA, connectedBody, constraintData.pivotB, constraintData.maxForce);
  110677. break;
  110678. }
  110679. //set the collideConnected flag after the creation, since DistanceJoint ignores it.
  110680. constraint.collideConnected = !!jointData.collision;
  110681. impostorJoint.joint.physicsJoint = constraint;
  110682. //don't add spring as constraint, as it is not one.
  110683. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110684. this.world.addConstraint(constraint);
  110685. }
  110686. else {
  110687. impostorJoint.joint.jointData.forceApplicationCallback = impostorJoint.joint.jointData.forceApplicationCallback || function () {
  110688. constraint.applyForce();
  110689. };
  110690. impostorJoint.mainImpostor.registerAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110691. }
  110692. };
  110693. CannonJSPlugin.prototype.removeJoint = function (impostorJoint) {
  110694. if (impostorJoint.joint.type !== _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"].SpringJoint) {
  110695. this.world.removeConstraint(impostorJoint.joint.physicsJoint);
  110696. }
  110697. else {
  110698. impostorJoint.mainImpostor.unregisterAfterPhysicsStep(impostorJoint.joint.jointData.forceApplicationCallback);
  110699. }
  110700. };
  110701. CannonJSPlugin.prototype._addMaterial = function (name, friction, restitution) {
  110702. var index;
  110703. var mat;
  110704. for (index = 0; index < this._physicsMaterials.length; index++) {
  110705. mat = this._physicsMaterials[index];
  110706. if (mat.friction === friction && mat.restitution === restitution) {
  110707. return mat;
  110708. }
  110709. }
  110710. var currentMat = new this.BJSCANNON.Material(name);
  110711. currentMat.friction = friction;
  110712. currentMat.restitution = restitution;
  110713. this._physicsMaterials.push(currentMat);
  110714. return currentMat;
  110715. };
  110716. CannonJSPlugin.prototype._checkWithEpsilon = function (value) {
  110717. return value < _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon ? _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].Epsilon : value;
  110718. };
  110719. CannonJSPlugin.prototype._createShape = function (impostor) {
  110720. var object = impostor.object;
  110721. var returnValue;
  110722. var extendSize = impostor.getObjectExtendSize();
  110723. switch (impostor.type) {
  110724. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].SphereImpostor:
  110725. var radiusX = extendSize.x;
  110726. var radiusY = extendSize.y;
  110727. var radiusZ = extendSize.z;
  110728. returnValue = new this.BJSCANNON.Sphere(Math.max(this._checkWithEpsilon(radiusX), this._checkWithEpsilon(radiusY), this._checkWithEpsilon(radiusZ)) / 2);
  110729. break;
  110730. //TMP also for cylinder - TODO Cannon supports cylinder natively.
  110731. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].CylinderImpostor:
  110732. var nativeParams = impostor.getParam("nativeOptions");
  110733. if (!nativeParams) {
  110734. nativeParams = {};
  110735. }
  110736. var radiusTop = nativeParams.radiusTop !== undefined ? nativeParams.radiusTop : this._checkWithEpsilon(extendSize.x) / 2;
  110737. var radiusBottom = nativeParams.radiusBottom !== undefined ? nativeParams.radiusBottom : this._checkWithEpsilon(extendSize.x) / 2;
  110738. var height = nativeParams.height !== undefined ? nativeParams.height : this._checkWithEpsilon(extendSize.y);
  110739. var numSegments = nativeParams.numSegments !== undefined ? nativeParams.numSegments : 16;
  110740. returnValue = new this.BJSCANNON.Cylinder(radiusTop, radiusBottom, height, numSegments);
  110741. // Rotate 90 degrees as this shape is horizontal in cannon
  110742. var quat = new this.BJSCANNON.Quaternion();
  110743. quat.setFromAxisAngle(new this.BJSCANNON.Vec3(1, 0, 0), -Math.PI / 2);
  110744. var translation = new this.BJSCANNON.Vec3(0, 0, 0);
  110745. returnValue.transformAllPoints(translation, quat);
  110746. break;
  110747. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].BoxImpostor:
  110748. var box = extendSize.scale(0.5);
  110749. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(this._checkWithEpsilon(box.x), this._checkWithEpsilon(box.y), this._checkWithEpsilon(box.z)));
  110750. break;
  110751. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor:
  110752. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Attention, PlaneImposter might not behave as you expect. Consider using BoxImposter instead");
  110753. returnValue = new this.BJSCANNON.Plane();
  110754. break;
  110755. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor:
  110756. // should transform the vertex data to world coordinates!!
  110757. var rawVerts = object.getVerticesData ? object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind) : [];
  110758. var rawFaces = object.getIndices ? object.getIndices() : [];
  110759. if (!rawVerts) {
  110760. return;
  110761. }
  110762. // get only scale! so the object could transform correctly.
  110763. var oldPosition = object.position.clone();
  110764. var oldRotation = object.rotation && object.rotation.clone();
  110765. var oldQuaternion = object.rotationQuaternion && object.rotationQuaternion.clone();
  110766. object.position.copyFromFloats(0, 0, 0);
  110767. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110768. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110769. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110770. var transform = object.computeWorldMatrix(true);
  110771. // convert rawVerts to object space
  110772. var temp = new Array();
  110773. var index;
  110774. for (index = 0; index < rawVerts.length; index += 3) {
  110775. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(rawVerts, index), transform).toArray(temp, index);
  110776. }
  110777. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("MeshImpostor only collides against spheres.");
  110778. returnValue = new this.BJSCANNON.Trimesh(temp, rawFaces);
  110779. //now set back the transformation!
  110780. object.position.copyFrom(oldPosition);
  110781. oldRotation && object.rotation && object.rotation.copyFrom(oldRotation);
  110782. oldQuaternion && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion);
  110783. break;
  110784. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor:
  110785. var oldPosition2 = object.position.clone();
  110786. var oldRotation2 = object.rotation && object.rotation.clone();
  110787. var oldQuaternion2 = object.rotationQuaternion && object.rotationQuaternion.clone();
  110788. object.position.copyFromFloats(0, 0, 0);
  110789. object.rotation && object.rotation.copyFromFloats(0, 0, 0);
  110790. object.rotationQuaternion && object.rotationQuaternion.copyFrom(impostor.getParentsRotation());
  110791. object.rotationQuaternion && object.parent && object.rotationQuaternion.conjugateInPlace();
  110792. object.rotationQuaternion && object.rotationQuaternion.multiplyInPlace(this._minus90X);
  110793. returnValue = this._createHeightmap(object);
  110794. object.position.copyFrom(oldPosition2);
  110795. oldRotation2 && object.rotation && object.rotation.copyFrom(oldRotation2);
  110796. oldQuaternion2 && object.rotationQuaternion && object.rotationQuaternion.copyFrom(oldQuaternion2);
  110797. object.computeWorldMatrix(true);
  110798. break;
  110799. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].ParticleImpostor:
  110800. returnValue = new this.BJSCANNON.Particle();
  110801. break;
  110802. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].NoImpostor:
  110803. returnValue = new this.BJSCANNON.Box(new this.BJSCANNON.Vec3(0, 0, 0));
  110804. break;
  110805. }
  110806. return returnValue;
  110807. };
  110808. CannonJSPlugin.prototype._createHeightmap = function (object, pointDepth) {
  110809. var pos = (object.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind));
  110810. var transform = object.computeWorldMatrix(true);
  110811. // convert rawVerts to object space
  110812. var temp = new Array();
  110813. var index;
  110814. for (index = 0; index < pos.length; index += 3) {
  110815. _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].TransformCoordinates(_Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].FromArray(pos, index), transform).toArray(temp, index);
  110816. }
  110817. pos = temp;
  110818. var matrix = new Array();
  110819. //For now pointDepth will not be used and will be automatically calculated.
  110820. //Future reference - try and find the best place to add a reference to the pointDepth variable.
  110821. var arraySize = pointDepth || ~~(Math.sqrt(pos.length / 3) - 1);
  110822. var boundingInfo = object.getBoundingInfo();
  110823. var dim = Math.min(boundingInfo.boundingBox.extendSizeWorld.x, boundingInfo.boundingBox.extendSizeWorld.y);
  110824. var minY = boundingInfo.boundingBox.extendSizeWorld.z;
  110825. var elementSize = dim * 2 / arraySize;
  110826. for (var i = 0; i < pos.length; i = i + 3) {
  110827. var x = Math.round((pos[i + 0]) / elementSize + arraySize / 2);
  110828. var z = Math.round(((pos[i + 1]) / elementSize - arraySize / 2) * -1);
  110829. var y = -pos[i + 2] + minY;
  110830. if (!matrix[x]) {
  110831. matrix[x] = [];
  110832. }
  110833. if (!matrix[x][z]) {
  110834. matrix[x][z] = y;
  110835. }
  110836. matrix[x][z] = Math.max(y, matrix[x][z]);
  110837. }
  110838. for (var x = 0; x <= arraySize; ++x) {
  110839. if (!matrix[x]) {
  110840. var loc = 1;
  110841. while (!matrix[(x + loc) % arraySize]) {
  110842. loc++;
  110843. }
  110844. matrix[x] = matrix[(x + loc) % arraySize].slice();
  110845. //console.log("missing x", x);
  110846. }
  110847. for (var z = 0; z <= arraySize; ++z) {
  110848. if (!matrix[x][z]) {
  110849. var loc = 1;
  110850. var newValue;
  110851. while (newValue === undefined) {
  110852. newValue = matrix[x][(z + loc++) % arraySize];
  110853. }
  110854. matrix[x][z] = newValue;
  110855. }
  110856. }
  110857. }
  110858. var shape = new this.BJSCANNON.Heightfield(matrix, {
  110859. elementSize: elementSize
  110860. });
  110861. //For future reference, needed for body transformation
  110862. shape.minY = minY;
  110863. return shape;
  110864. };
  110865. CannonJSPlugin.prototype._updatePhysicsBodyTransformation = function (impostor) {
  110866. var object = impostor.object;
  110867. //make sure it is updated...
  110868. object.computeWorldMatrix && object.computeWorldMatrix(true);
  110869. // The delta between the mesh position and the mesh bounding box center
  110870. var bInfo = object.getBoundingInfo();
  110871. if (!bInfo) {
  110872. return;
  110873. }
  110874. var center = impostor.getObjectCenter();
  110875. //m.getAbsolutePosition().subtract(m.getBoundingInfo().boundingBox.centerWorld)
  110876. this._tmpDeltaPosition.copyFrom(object.getAbsolutePivotPoint().subtract(center));
  110877. this._tmpDeltaPosition.divideInPlace(impostor.object.scaling);
  110878. this._tmpPosition.copyFrom(center);
  110879. var quaternion = object.rotationQuaternion;
  110880. if (!quaternion) {
  110881. return;
  110882. }
  110883. //is shape is a plane or a heightmap, it must be rotated 90 degs in the X axis.
  110884. //ideally these would be rotated at time of creation like cylinder but they dont extend ConvexPolyhedron
  110885. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].PlaneImpostor || impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110886. //-90 DEG in X, precalculated
  110887. quaternion = quaternion.multiply(this._minus90X);
  110888. //Invert! (Precalculated, 90 deg in X)
  110889. //No need to clone. this will never change.
  110890. impostor.setDeltaRotation(this._plus90X);
  110891. }
  110892. //If it is a heightfield, if should be centered.
  110893. if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].HeightmapImpostor) {
  110894. var mesh = object;
  110895. var boundingInfo = mesh.getBoundingInfo();
  110896. //calculate the correct body position:
  110897. var rotationQuaternion = mesh.rotationQuaternion;
  110898. mesh.rotationQuaternion = this._tmpUnityRotation;
  110899. mesh.computeWorldMatrix(true);
  110900. //get original center with no rotation
  110901. var c = center.clone();
  110902. var oldPivot = mesh.getPivotMatrix();
  110903. if (oldPivot) {
  110904. // create a copy the pivot Matrix as it is modified in place
  110905. oldPivot = oldPivot.clone();
  110906. }
  110907. else {
  110908. oldPivot = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  110909. }
  110910. //calculate the new center using a pivot (since this.BJSCANNON.js doesn't center height maps)
  110911. var p = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Translation(boundingInfo.boundingBox.extendSizeWorld.x, 0, -boundingInfo.boundingBox.extendSizeWorld.z);
  110912. mesh.setPreTransformMatrix(p);
  110913. mesh.computeWorldMatrix(true);
  110914. //calculate the translation
  110915. var translation = boundingInfo.boundingBox.centerWorld.subtract(center).subtract(mesh.position).negate();
  110916. this._tmpPosition.copyFromFloats(translation.x, translation.y - boundingInfo.boundingBox.extendSizeWorld.y, translation.z);
  110917. //add it inverted to the delta
  110918. this._tmpDeltaPosition.copyFrom(boundingInfo.boundingBox.centerWorld.subtract(c));
  110919. this._tmpDeltaPosition.y += boundingInfo.boundingBox.extendSizeWorld.y;
  110920. //rotation is back
  110921. mesh.rotationQuaternion = rotationQuaternion;
  110922. mesh.setPreTransformMatrix(oldPivot);
  110923. mesh.computeWorldMatrix(true);
  110924. }
  110925. else if (impostor.type === _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"].MeshImpostor) {
  110926. this._tmpDeltaPosition.copyFromFloats(0, 0, 0);
  110927. //this._tmpPosition.copyFrom(object.position);
  110928. }
  110929. impostor.setDeltaPosition(this._tmpDeltaPosition);
  110930. //Now update the impostor object
  110931. impostor.physicsBody.position.copy(this._tmpPosition);
  110932. impostor.physicsBody.quaternion.copy(quaternion);
  110933. };
  110934. CannonJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  110935. impostor.object.position.copyFrom(impostor.physicsBody.position);
  110936. if (impostor.object.rotationQuaternion) {
  110937. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.quaternion);
  110938. }
  110939. };
  110940. CannonJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  110941. impostor.physicsBody.position.copy(newPosition);
  110942. impostor.physicsBody.quaternion.copy(newRotation);
  110943. };
  110944. CannonJSPlugin.prototype.isSupported = function () {
  110945. return this.BJSCANNON !== undefined;
  110946. };
  110947. CannonJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  110948. impostor.physicsBody.velocity.copy(velocity);
  110949. };
  110950. CannonJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  110951. impostor.physicsBody.angularVelocity.copy(velocity);
  110952. };
  110953. CannonJSPlugin.prototype.getLinearVelocity = function (impostor) {
  110954. var v = impostor.physicsBody.velocity;
  110955. if (!v) {
  110956. return null;
  110957. }
  110958. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110959. };
  110960. CannonJSPlugin.prototype.getAngularVelocity = function (impostor) {
  110961. var v = impostor.physicsBody.angularVelocity;
  110962. if (!v) {
  110963. return null;
  110964. }
  110965. return new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](v.x, v.y, v.z);
  110966. };
  110967. CannonJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  110968. impostor.physicsBody.mass = mass;
  110969. impostor.physicsBody.updateMassProperties();
  110970. };
  110971. CannonJSPlugin.prototype.getBodyMass = function (impostor) {
  110972. return impostor.physicsBody.mass;
  110973. };
  110974. CannonJSPlugin.prototype.getBodyFriction = function (impostor) {
  110975. return impostor.physicsBody.material.friction;
  110976. };
  110977. CannonJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  110978. impostor.physicsBody.material.friction = friction;
  110979. };
  110980. CannonJSPlugin.prototype.getBodyRestitution = function (impostor) {
  110981. return impostor.physicsBody.material.restitution;
  110982. };
  110983. CannonJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  110984. impostor.physicsBody.material.restitution = restitution;
  110985. };
  110986. CannonJSPlugin.prototype.sleepBody = function (impostor) {
  110987. impostor.physicsBody.sleep();
  110988. };
  110989. CannonJSPlugin.prototype.wakeUpBody = function (impostor) {
  110990. impostor.physicsBody.wakeUp();
  110991. };
  110992. CannonJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance) {
  110993. joint.physicsJoint.distance = maxDistance;
  110994. };
  110995. // private enableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  110996. // if (!motorIndex) {
  110997. // joint.physicsJoint.enableMotor();
  110998. // }
  110999. // }
  111000. // private disableMotor(joint: IMotorEnabledJoint, motorIndex?: number) {
  111001. // if (!motorIndex) {
  111002. // joint.physicsJoint.disableMotor();
  111003. // }
  111004. // }
  111005. CannonJSPlugin.prototype.setMotor = function (joint, speed, maxForce, motorIndex) {
  111006. if (!motorIndex) {
  111007. joint.physicsJoint.enableMotor();
  111008. joint.physicsJoint.setMotorSpeed(speed);
  111009. if (maxForce) {
  111010. this.setLimit(joint, maxForce);
  111011. }
  111012. }
  111013. };
  111014. CannonJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit) {
  111015. joint.physicsJoint.motorEquation.maxForce = upperLimit;
  111016. joint.physicsJoint.motorEquation.minForce = lowerLimit === void 0 ? -upperLimit : lowerLimit;
  111017. };
  111018. CannonJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  111019. var body = impostor.physicsBody;
  111020. mesh.position.x = body.position.x;
  111021. mesh.position.y = body.position.y;
  111022. mesh.position.z = body.position.z;
  111023. if (mesh.rotationQuaternion) {
  111024. mesh.rotationQuaternion.x = body.quaternion.x;
  111025. mesh.rotationQuaternion.y = body.quaternion.y;
  111026. mesh.rotationQuaternion.z = body.quaternion.z;
  111027. mesh.rotationQuaternion.w = body.quaternion.w;
  111028. }
  111029. };
  111030. CannonJSPlugin.prototype.getRadius = function (impostor) {
  111031. var shape = impostor.physicsBody.shapes[0];
  111032. return shape.boundingSphereRadius;
  111033. };
  111034. CannonJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  111035. var shape = impostor.physicsBody.shapes[0];
  111036. result.x = shape.halfExtents.x * 2;
  111037. result.y = shape.halfExtents.y * 2;
  111038. result.z = shape.halfExtents.z * 2;
  111039. };
  111040. CannonJSPlugin.prototype.dispose = function () {
  111041. };
  111042. CannonJSPlugin.prototype._extendNamespace = function () {
  111043. //this will force cannon to execute at least one step when using interpolation
  111044. var step_tmp1 = new this.BJSCANNON.Vec3();
  111045. var Engine = this.BJSCANNON;
  111046. this.BJSCANNON.World.prototype.step = function (dt, timeSinceLastCalled, maxSubSteps) {
  111047. maxSubSteps = maxSubSteps || 10;
  111048. timeSinceLastCalled = timeSinceLastCalled || 0;
  111049. if (timeSinceLastCalled === 0) {
  111050. this.internalStep(dt);
  111051. this.time += dt;
  111052. }
  111053. else {
  111054. var internalSteps = Math.floor((this.time + timeSinceLastCalled) / dt) - Math.floor(this.time / dt);
  111055. internalSteps = Math.min(internalSteps, maxSubSteps) || 1;
  111056. var t0 = performance.now();
  111057. for (var i = 0; i !== internalSteps; i++) {
  111058. this.internalStep(dt);
  111059. if (performance.now() - t0 > dt * 1000) {
  111060. break;
  111061. }
  111062. }
  111063. this.time += timeSinceLastCalled;
  111064. var h = this.time % dt;
  111065. var h_div_dt = h / dt;
  111066. var interpvelo = step_tmp1;
  111067. var bodies = this.bodies;
  111068. for (var j = 0; j !== bodies.length; j++) {
  111069. var b = bodies[j];
  111070. if (b.type !== Engine.Body.STATIC && b.sleepState !== Engine.Body.SLEEPING) {
  111071. b.position.vsub(b.previousPosition, interpvelo);
  111072. interpvelo.scale(h_div_dt, interpvelo);
  111073. b.position.vadd(interpvelo, b.interpolatedPosition);
  111074. }
  111075. else {
  111076. b.interpolatedPosition.copy(b.position);
  111077. b.interpolatedQuaternion.copy(b.quaternion);
  111078. }
  111079. }
  111080. }
  111081. };
  111082. };
  111083. return CannonJSPlugin;
  111084. }());
  111085. _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"].DefaultPluginFactory = function () { return new CannonJSPlugin(); };
  111086. /***/ }),
  111087. /***/ "./Physics/Plugins/index.ts":
  111088. /*!**********************************!*\
  111089. !*** ./Physics/Plugins/index.ts ***!
  111090. \**********************************/
  111091. /*! exports provided: CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  111092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111093. "use strict";
  111094. __webpack_require__.r(__webpack_exports__);
  111095. /* harmony import */ var _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./cannonJSPlugin */ "./Physics/Plugins/cannonJSPlugin.ts");
  111096. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _cannonJSPlugin__WEBPACK_IMPORTED_MODULE_0__["CannonJSPlugin"]; });
  111097. /* harmony import */ var _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ammoJSPlugin */ "./Physics/Plugins/ammoJSPlugin.ts");
  111098. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _ammoJSPlugin__WEBPACK_IMPORTED_MODULE_1__["AmmoJSPlugin"]; });
  111099. /* harmony import */ var _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./oimoJSPlugin */ "./Physics/Plugins/oimoJSPlugin.ts");
  111100. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _oimoJSPlugin__WEBPACK_IMPORTED_MODULE_2__["OimoJSPlugin"]; });
  111101. /***/ }),
  111102. /***/ "./Physics/Plugins/oimoJSPlugin.ts":
  111103. /*!*****************************************!*\
  111104. !*** ./Physics/Plugins/oimoJSPlugin.ts ***!
  111105. \*****************************************/
  111106. /*! exports provided: OimoJSPlugin */
  111107. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111108. "use strict";
  111109. __webpack_require__.r(__webpack_exports__);
  111110. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return OimoJSPlugin; });
  111111. /* harmony import */ var _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Physics/physicsImpostor */ "./Physics/physicsImpostor.ts");
  111112. /* harmony import */ var _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Physics/physicsJoint */ "./Physics/physicsJoint.ts");
  111113. /* harmony import */ var _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Physics/physicsEngine */ "./Physics/physicsEngine.ts");
  111114. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../Maths/math */ "./Maths/math.ts");
  111115. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../Misc/logger */ "./Misc/logger.ts");
  111116. /** @hidden */
  111117. var OimoJSPlugin = /** @class */ (function () {
  111118. function OimoJSPlugin(iterations, oimoInjection) {
  111119. if (oimoInjection === void 0) { oimoInjection = OIMO; }
  111120. this.name = "OimoJSPlugin";
  111121. this._tmpImpostorsArray = [];
  111122. this._tmpPositionVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  111123. this.BJSOIMO = oimoInjection;
  111124. this.world = new this.BJSOIMO.World({
  111125. iterations: iterations
  111126. });
  111127. this.world.clear();
  111128. }
  111129. OimoJSPlugin.prototype.setGravity = function (gravity) {
  111130. this.world.gravity.copy(gravity);
  111131. };
  111132. OimoJSPlugin.prototype.setTimeStep = function (timeStep) {
  111133. this.world.timeStep = timeStep;
  111134. };
  111135. OimoJSPlugin.prototype.getTimeStep = function () {
  111136. return this.world.timeStep;
  111137. };
  111138. OimoJSPlugin.prototype.executeStep = function (delta, impostors) {
  111139. var _this = this;
  111140. impostors.forEach(function (impostor) {
  111141. impostor.beforeStep();
  111142. });
  111143. this.world.step();
  111144. impostors.forEach(function (impostor) {
  111145. impostor.afterStep();
  111146. //update the ordered impostors array
  111147. _this._tmpImpostorsArray[impostor.uniqueId] = impostor;
  111148. });
  111149. //check for collisions
  111150. var contact = this.world.contacts;
  111151. while (contact !== null) {
  111152. if (contact.touching && !contact.body1.sleeping && !contact.body2.sleeping) {
  111153. contact = contact.next;
  111154. continue;
  111155. }
  111156. //is this body colliding with any other? get the impostor
  111157. var mainImpostor = this._tmpImpostorsArray[+contact.body1.name];
  111158. var collidingImpostor = this._tmpImpostorsArray[+contact.body2.name];
  111159. if (!mainImpostor || !collidingImpostor) {
  111160. contact = contact.next;
  111161. continue;
  111162. }
  111163. mainImpostor.onCollide({ body: collidingImpostor.physicsBody });
  111164. collidingImpostor.onCollide({ body: mainImpostor.physicsBody });
  111165. contact = contact.next;
  111166. }
  111167. };
  111168. OimoJSPlugin.prototype.applyImpulse = function (impostor, force, contactPoint) {
  111169. var mass = impostor.physicsBody.mass;
  111170. impostor.physicsBody.applyImpulse(contactPoint.scale(this.world.invScale), force.scale(this.world.invScale * mass));
  111171. };
  111172. OimoJSPlugin.prototype.applyForce = function (impostor, force, contactPoint) {
  111173. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("Oimo doesn't support applying force. Using impule instead.");
  111174. this.applyImpulse(impostor, force, contactPoint);
  111175. };
  111176. OimoJSPlugin.prototype.generatePhysicsBody = function (impostor) {
  111177. var _this = this;
  111178. //parent-child relationship. Does this impostor has a parent impostor?
  111179. if (impostor.parent) {
  111180. if (impostor.physicsBody) {
  111181. this.removePhysicsBody(impostor);
  111182. //TODO is that needed?
  111183. impostor.forceUpdate();
  111184. }
  111185. return;
  111186. }
  111187. if (impostor.isBodyInitRequired()) {
  111188. var bodyConfig = {
  111189. name: impostor.uniqueId,
  111190. //Oimo must have mass, also for static objects.
  111191. config: [impostor.getParam("mass") || 1, impostor.getParam("friction"), impostor.getParam("restitution")],
  111192. size: [],
  111193. type: [],
  111194. pos: [],
  111195. posShape: [],
  111196. rot: [],
  111197. rotShape: [],
  111198. move: impostor.getParam("mass") !== 0,
  111199. density: impostor.getParam("mass"),
  111200. friction: impostor.getParam("friction"),
  111201. restitution: impostor.getParam("restitution"),
  111202. //Supporting older versions of Oimo
  111203. world: this.world
  111204. };
  111205. var impostors = [impostor];
  111206. var addToArray = function (parent) {
  111207. if (!parent.getChildMeshes) {
  111208. return;
  111209. }
  111210. parent.getChildMeshes().forEach(function (m) {
  111211. if (m.physicsImpostor) {
  111212. impostors.push(m.physicsImpostor);
  111213. //m.physicsImpostor._init();
  111214. }
  111215. });
  111216. };
  111217. addToArray(impostor.object);
  111218. var checkWithEpsilon_1 = function (value) {
  111219. return Math.max(value, _Physics_physicsEngine__WEBPACK_IMPORTED_MODULE_2__["PhysicsEngine"].Epsilon);
  111220. };
  111221. var globalQuaternion_1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Quaternion"]();
  111222. impostors.forEach(function (i) {
  111223. if (!i.object.rotationQuaternion) {
  111224. return;
  111225. }
  111226. //get the correct bounding box
  111227. var oldQuaternion = i.object.rotationQuaternion;
  111228. globalQuaternion_1 = oldQuaternion.clone();
  111229. var rot = oldQuaternion.toEulerAngles();
  111230. var extendSize = i.getObjectExtendSize();
  111231. var radToDeg = 57.295779513082320876;
  111232. if (i === impostor) {
  111233. var center = impostor.getObjectCenter();
  111234. impostor.object.getAbsolutePivotPoint().subtractToRef(center, _this._tmpPositionVector);
  111235. _this._tmpPositionVector.divideInPlace(impostor.object.scaling);
  111236. //Can also use Array.prototype.push.apply
  111237. bodyConfig.pos.push(center.x);
  111238. bodyConfig.pos.push(center.y);
  111239. bodyConfig.pos.push(center.z);
  111240. bodyConfig.posShape.push(0, 0, 0);
  111241. bodyConfig.rotShape.push(0, 0, 0);
  111242. }
  111243. else {
  111244. var localPosition = i.object.getAbsolutePosition().subtract(impostor.object.getAbsolutePosition());
  111245. bodyConfig.posShape.push(localPosition.x);
  111246. bodyConfig.posShape.push(localPosition.y);
  111247. bodyConfig.posShape.push(localPosition.z);
  111248. bodyConfig.pos.push(0, 0, 0);
  111249. bodyConfig.rotShape.push(rot.x * radToDeg);
  111250. bodyConfig.rotShape.push(rot.y * radToDeg);
  111251. bodyConfig.rotShape.push(rot.z * radToDeg);
  111252. }
  111253. // register mesh
  111254. switch (i.type) {
  111255. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].ParticleImpostor:
  111256. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("No Particle support in OIMO.js. using SphereImpostor instead");
  111257. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].SphereImpostor:
  111258. var radiusX = extendSize.x;
  111259. var radiusY = extendSize.y;
  111260. var radiusZ = extendSize.z;
  111261. var size = Math.max(checkWithEpsilon_1(radiusX), checkWithEpsilon_1(radiusY), checkWithEpsilon_1(radiusZ)) / 2;
  111262. bodyConfig.type.push('sphere');
  111263. //due to the way oimo works with compounds, add 3 times
  111264. bodyConfig.size.push(size);
  111265. bodyConfig.size.push(size);
  111266. bodyConfig.size.push(size);
  111267. break;
  111268. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].CylinderImpostor:
  111269. var sizeX = checkWithEpsilon_1(extendSize.x) / 2;
  111270. var sizeY = checkWithEpsilon_1(extendSize.y);
  111271. bodyConfig.type.push('cylinder');
  111272. bodyConfig.size.push(sizeX);
  111273. bodyConfig.size.push(sizeY);
  111274. //due to the way oimo works with compounds, add one more value.
  111275. bodyConfig.size.push(sizeY);
  111276. break;
  111277. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].PlaneImpostor:
  111278. case _Physics_physicsImpostor__WEBPACK_IMPORTED_MODULE_0__["PhysicsImpostor"].BoxImpostor:
  111279. default:
  111280. var sizeX = checkWithEpsilon_1(extendSize.x);
  111281. var sizeY = checkWithEpsilon_1(extendSize.y);
  111282. var sizeZ = checkWithEpsilon_1(extendSize.z);
  111283. bodyConfig.type.push('box');
  111284. //if (i === impostor) {
  111285. bodyConfig.size.push(sizeX);
  111286. bodyConfig.size.push(sizeY);
  111287. bodyConfig.size.push(sizeZ);
  111288. //} else {
  111289. // bodyConfig.size.push(0,0,0);
  111290. //}
  111291. break;
  111292. }
  111293. //actually not needed, but hey...
  111294. i.object.rotationQuaternion = oldQuaternion;
  111295. });
  111296. impostor.physicsBody = this.world.add(bodyConfig);
  111297. // set the quaternion, ignoring the previously defined (euler) rotation
  111298. impostor.physicsBody.resetQuaternion(globalQuaternion_1);
  111299. // update with delta 0, so the body will reveive the new rotation.
  111300. impostor.physicsBody.updatePosition(0);
  111301. }
  111302. else {
  111303. this._tmpPositionVector.copyFromFloats(0, 0, 0);
  111304. }
  111305. impostor.setDeltaPosition(this._tmpPositionVector);
  111306. //this._tmpPositionVector.addInPlace(impostor.mesh.getBoundingInfo().boundingBox.center);
  111307. //this.setPhysicsBodyTransformation(impostor, this._tmpPositionVector, impostor.mesh.rotationQuaternion);
  111308. };
  111309. OimoJSPlugin.prototype.removePhysicsBody = function (impostor) {
  111310. //impostor.physicsBody.dispose();
  111311. //Same as : (older oimo versions)
  111312. this.world.removeRigidBody(impostor.physicsBody);
  111313. };
  111314. OimoJSPlugin.prototype.generateJoint = function (impostorJoint) {
  111315. var mainBody = impostorJoint.mainImpostor.physicsBody;
  111316. var connectedBody = impostorJoint.connectedImpostor.physicsBody;
  111317. if (!mainBody || !connectedBody) {
  111318. return;
  111319. }
  111320. var jointData = impostorJoint.joint.jointData;
  111321. var options = jointData.nativeParams || {};
  111322. var type;
  111323. var nativeJointData = {
  111324. body1: mainBody,
  111325. body2: connectedBody,
  111326. axe1: options.axe1 || (jointData.mainAxis ? jointData.mainAxis.asArray() : null),
  111327. axe2: options.axe2 || (jointData.connectedAxis ? jointData.connectedAxis.asArray() : null),
  111328. pos1: options.pos1 || (jointData.mainPivot ? jointData.mainPivot.asArray() : null),
  111329. pos2: options.pos2 || (jointData.connectedPivot ? jointData.connectedPivot.asArray() : null),
  111330. min: options.min,
  111331. max: options.max,
  111332. collision: options.collision || jointData.collision,
  111333. spring: options.spring,
  111334. //supporting older version of Oimo
  111335. world: this.world
  111336. };
  111337. switch (impostorJoint.joint.type) {
  111338. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].BallAndSocketJoint:
  111339. type = "jointBall";
  111340. break;
  111341. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SpringJoint:
  111342. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OIMO.js doesn't support Spring Constraint. Simulating using DistanceJoint instead");
  111343. var springData = jointData;
  111344. nativeJointData.min = springData.length || nativeJointData.min;
  111345. //Max should also be set, just make sure it is at least min
  111346. nativeJointData.max = Math.max(nativeJointData.min, nativeJointData.max);
  111347. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].DistanceJoint:
  111348. type = "jointDistance";
  111349. nativeJointData.max = jointData.maxDistance;
  111350. break;
  111351. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].PrismaticJoint:
  111352. type = "jointPrisme";
  111353. break;
  111354. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].SliderJoint:
  111355. type = "jointSlide";
  111356. break;
  111357. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].WheelJoint:
  111358. type = "jointWheel";
  111359. break;
  111360. case _Physics_physicsJoint__WEBPACK_IMPORTED_MODULE_1__["PhysicsJoint"].HingeJoint:
  111361. default:
  111362. type = "jointHinge";
  111363. break;
  111364. }
  111365. nativeJointData.type = type;
  111366. impostorJoint.joint.physicsJoint = this.world.add(nativeJointData);
  111367. };
  111368. OimoJSPlugin.prototype.removeJoint = function (impostorJoint) {
  111369. //Bug in Oimo prevents us from disposing a joint in the playground
  111370. //joint.joint.physicsJoint.dispose();
  111371. //So we will bruteforce it!
  111372. try {
  111373. this.world.removeJoint(impostorJoint.joint.physicsJoint);
  111374. }
  111375. catch (e) {
  111376. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn(e);
  111377. }
  111378. };
  111379. OimoJSPlugin.prototype.isSupported = function () {
  111380. return this.BJSOIMO !== undefined;
  111381. };
  111382. OimoJSPlugin.prototype.setTransformationFromPhysicsBody = function (impostor) {
  111383. if (!impostor.physicsBody.sleeping) {
  111384. //TODO check that
  111385. /*if (impostor.physicsBody.shapes.next) {
  111386. var parentShape = this._getLastShape(impostor.physicsBody);
  111387. impostor.object.position.copyFrom(parentShape.position);
  111388. console.log(parentShape.position);
  111389. } else {*/
  111390. impostor.object.position.copyFrom(impostor.physicsBody.getPosition());
  111391. //}
  111392. if (impostor.object.rotationQuaternion) {
  111393. impostor.object.rotationQuaternion.copyFrom(impostor.physicsBody.getQuaternion());
  111394. }
  111395. }
  111396. };
  111397. OimoJSPlugin.prototype.setPhysicsBodyTransformation = function (impostor, newPosition, newRotation) {
  111398. var body = impostor.physicsBody;
  111399. body.position.copy(newPosition);
  111400. body.orientation.copy(newRotation);
  111401. body.syncShapes();
  111402. body.awake();
  111403. };
  111404. /*private _getLastShape(body: any): any {
  111405. var lastShape = body.shapes;
  111406. while (lastShape.next) {
  111407. lastShape = lastShape.next;
  111408. }
  111409. return lastShape;
  111410. }*/
  111411. OimoJSPlugin.prototype.setLinearVelocity = function (impostor, velocity) {
  111412. impostor.physicsBody.linearVelocity.copy(velocity);
  111413. };
  111414. OimoJSPlugin.prototype.setAngularVelocity = function (impostor, velocity) {
  111415. impostor.physicsBody.angularVelocity.copy(velocity);
  111416. };
  111417. OimoJSPlugin.prototype.getLinearVelocity = function (impostor) {
  111418. var v = impostor.physicsBody.linearVelocity;
  111419. if (!v) {
  111420. return null;
  111421. }
  111422. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  111423. };
  111424. OimoJSPlugin.prototype.getAngularVelocity = function (impostor) {
  111425. var v = impostor.physicsBody.angularVelocity;
  111426. if (!v) {
  111427. return null;
  111428. }
  111429. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](v.x, v.y, v.z);
  111430. };
  111431. OimoJSPlugin.prototype.setBodyMass = function (impostor, mass) {
  111432. var staticBody = mass === 0;
  111433. //this will actually set the body's density and not its mass.
  111434. //But this is how oimo treats the mass variable.
  111435. impostor.physicsBody.shapes.density = staticBody ? 1 : mass;
  111436. impostor.physicsBody.setupMass(staticBody ? 0x2 : 0x1);
  111437. };
  111438. OimoJSPlugin.prototype.getBodyMass = function (impostor) {
  111439. return impostor.physicsBody.shapes.density;
  111440. };
  111441. OimoJSPlugin.prototype.getBodyFriction = function (impostor) {
  111442. return impostor.physicsBody.shapes.friction;
  111443. };
  111444. OimoJSPlugin.prototype.setBodyFriction = function (impostor, friction) {
  111445. impostor.physicsBody.shapes.friction = friction;
  111446. };
  111447. OimoJSPlugin.prototype.getBodyRestitution = function (impostor) {
  111448. return impostor.physicsBody.shapes.restitution;
  111449. };
  111450. OimoJSPlugin.prototype.setBodyRestitution = function (impostor, restitution) {
  111451. impostor.physicsBody.shapes.restitution = restitution;
  111452. };
  111453. OimoJSPlugin.prototype.sleepBody = function (impostor) {
  111454. impostor.physicsBody.sleep();
  111455. };
  111456. OimoJSPlugin.prototype.wakeUpBody = function (impostor) {
  111457. impostor.physicsBody.awake();
  111458. };
  111459. OimoJSPlugin.prototype.updateDistanceJoint = function (joint, maxDistance, minDistance) {
  111460. joint.physicsJoint.limitMotor.upperLimit = maxDistance;
  111461. if (minDistance !== void 0) {
  111462. joint.physicsJoint.limitMotor.lowerLimit = minDistance;
  111463. }
  111464. };
  111465. OimoJSPlugin.prototype.setMotor = function (joint, speed, force, motorIndex) {
  111466. if (force !== undefined) {
  111467. _Misc_logger__WEBPACK_IMPORTED_MODULE_4__["Logger"].Warn("OimoJS plugin currently has unexpected behavior when using setMotor with force parameter");
  111468. }
  111469. else {
  111470. force = 1e6;
  111471. }
  111472. speed *= -1;
  111473. //TODO separate rotational and transational motors.
  111474. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  111475. if (motor) {
  111476. motor.setMotor(speed, force);
  111477. }
  111478. };
  111479. OimoJSPlugin.prototype.setLimit = function (joint, upperLimit, lowerLimit, motorIndex) {
  111480. //TODO separate rotational and transational motors.
  111481. var motor = motorIndex ? joint.physicsJoint.rotationalLimitMotor2 : joint.physicsJoint.rotationalLimitMotor1 || joint.physicsJoint.rotationalLimitMotor || joint.physicsJoint.limitMotor;
  111482. if (motor) {
  111483. motor.setLimit(upperLimit, lowerLimit === void 0 ? -upperLimit : lowerLimit);
  111484. }
  111485. };
  111486. OimoJSPlugin.prototype.syncMeshWithImpostor = function (mesh, impostor) {
  111487. var body = impostor.physicsBody;
  111488. mesh.position.x = body.position.x;
  111489. mesh.position.y = body.position.y;
  111490. mesh.position.z = body.position.z;
  111491. if (mesh.rotationQuaternion) {
  111492. mesh.rotationQuaternion.x = body.orientation.x;
  111493. mesh.rotationQuaternion.y = body.orientation.y;
  111494. mesh.rotationQuaternion.z = body.orientation.z;
  111495. mesh.rotationQuaternion.w = body.orientation.s;
  111496. }
  111497. };
  111498. OimoJSPlugin.prototype.getRadius = function (impostor) {
  111499. return impostor.physicsBody.shapes.radius;
  111500. };
  111501. OimoJSPlugin.prototype.getBoxSizeToRef = function (impostor, result) {
  111502. var shape = impostor.physicsBody.shapes;
  111503. result.x = shape.halfWidth * 2;
  111504. result.y = shape.halfHeight * 2;
  111505. result.z = shape.halfDepth * 2;
  111506. };
  111507. OimoJSPlugin.prototype.dispose = function () {
  111508. this.world.clear();
  111509. };
  111510. return OimoJSPlugin;
  111511. }());
  111512. /***/ }),
  111513. /***/ "./Physics/index.ts":
  111514. /*!**************************!*\
  111515. !*** ./Physics/index.ts ***!
  111516. \**************************/
  111517. /*! exports provided: PhysicsEngine, PhysicsEngineSceneComponent, PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin */
  111518. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111519. "use strict";
  111520. __webpack_require__.r(__webpack_exports__);
  111521. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  111522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _physicsEngine__WEBPACK_IMPORTED_MODULE_0__["PhysicsEngine"]; });
  111523. /* harmony import */ var _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./physicsEngineComponent */ "./Physics/physicsEngineComponent.ts");
  111524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _physicsEngineComponent__WEBPACK_IMPORTED_MODULE_1__["PhysicsEngineSceneComponent"]; });
  111525. /* harmony import */ var _physicsHelper__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./physicsHelper */ "./Physics/physicsHelper.ts");
  111526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsHelper"]; });
  111527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialExplosionEvent"]; });
  111528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsGravitationalFieldEvent"]; });
  111529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftEvent"]; });
  111530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsVortexEvent"]; });
  111531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsRadialImpulseFalloff"]; });
  111532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _physicsHelper__WEBPACK_IMPORTED_MODULE_2__["PhysicsUpdraftMode"]; });
  111533. /* harmony import */ var _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./physicsImpostor */ "./Physics/physicsImpostor.ts");
  111534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _physicsImpostor__WEBPACK_IMPORTED_MODULE_3__["PhysicsImpostor"]; });
  111535. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["PhysicsJoint"]; });
  111537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["DistanceJoint"]; });
  111538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["MotorEnabledJoint"]; });
  111539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["HingeJoint"]; });
  111540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _physicsJoint__WEBPACK_IMPORTED_MODULE_4__["Hinge2Joint"]; });
  111541. /* harmony import */ var _Plugins_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Plugins/index */ "./Physics/Plugins/index.ts");
  111542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["CannonJSPlugin"]; });
  111543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["AmmoJSPlugin"]; });
  111544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Plugins_index__WEBPACK_IMPORTED_MODULE_5__["OimoJSPlugin"]; });
  111545. /***/ }),
  111546. /***/ "./Physics/physicsEngine.ts":
  111547. /*!**********************************!*\
  111548. !*** ./Physics/physicsEngine.ts ***!
  111549. \**********************************/
  111550. /*! exports provided: PhysicsEngine */
  111551. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111552. "use strict";
  111553. __webpack_require__.r(__webpack_exports__);
  111554. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return PhysicsEngine; });
  111555. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111556. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  111557. /**
  111558. * Class used to control physics engine
  111559. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111560. */
  111561. var PhysicsEngine = /** @class */ (function () {
  111562. /**
  111563. * Creates a new Physics Engine
  111564. * @param gravity defines the gravity vector used by the simulation
  111565. * @param _physicsPlugin defines the plugin to use (CannonJS by default)
  111566. */
  111567. function PhysicsEngine(gravity, _physicsPlugin) {
  111568. if (_physicsPlugin === void 0) { _physicsPlugin = PhysicsEngine.DefaultPluginFactory(); }
  111569. this._physicsPlugin = _physicsPlugin;
  111570. this._impostors = [];
  111571. this._joints = [];
  111572. if (!this._physicsPlugin.isSupported()) {
  111573. throw new Error("Physics Engine " + this._physicsPlugin.name + " cannot be found. "
  111574. + "Please make sure it is included.");
  111575. }
  111576. gravity = gravity || new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"](0, -9.807, 0);
  111577. this.setGravity(gravity);
  111578. this.setTimeStep();
  111579. }
  111580. /**
  111581. * Factory used to create the default physics plugin.
  111582. * @returns The default physics plugin
  111583. */
  111584. PhysicsEngine.DefaultPluginFactory = function () {
  111585. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_1__["_DevTools"].WarnImport("CannonJSPlugin");
  111586. };
  111587. /**
  111588. * Sets the gravity vector used by the simulation
  111589. * @param gravity defines the gravity vector to use
  111590. */
  111591. PhysicsEngine.prototype.setGravity = function (gravity) {
  111592. this.gravity = gravity;
  111593. this._physicsPlugin.setGravity(this.gravity);
  111594. };
  111595. /**
  111596. * Set the time step of the physics engine.
  111597. * Default is 1/60.
  111598. * To slow it down, enter 1/600 for example.
  111599. * To speed it up, 1/30
  111600. * @param newTimeStep defines the new timestep to apply to this world.
  111601. */
  111602. PhysicsEngine.prototype.setTimeStep = function (newTimeStep) {
  111603. if (newTimeStep === void 0) { newTimeStep = 1 / 60; }
  111604. this._physicsPlugin.setTimeStep(newTimeStep);
  111605. };
  111606. /**
  111607. * Get the time step of the physics engine.
  111608. * @returns the current time step
  111609. */
  111610. PhysicsEngine.prototype.getTimeStep = function () {
  111611. return this._physicsPlugin.getTimeStep();
  111612. };
  111613. /**
  111614. * Release all resources
  111615. */
  111616. PhysicsEngine.prototype.dispose = function () {
  111617. this._impostors.forEach(function (impostor) {
  111618. impostor.dispose();
  111619. });
  111620. this._physicsPlugin.dispose();
  111621. };
  111622. /**
  111623. * Gets the name of the current physics plugin
  111624. * @returns the name of the plugin
  111625. */
  111626. PhysicsEngine.prototype.getPhysicsPluginName = function () {
  111627. return this._physicsPlugin.name;
  111628. };
  111629. /**
  111630. * Adding a new impostor for the impostor tracking.
  111631. * This will be done by the impostor itself.
  111632. * @param impostor the impostor to add
  111633. */
  111634. PhysicsEngine.prototype.addImpostor = function (impostor) {
  111635. impostor.uniqueId = this._impostors.push(impostor);
  111636. //if no parent, generate the body
  111637. if (!impostor.parent) {
  111638. this._physicsPlugin.generatePhysicsBody(impostor);
  111639. }
  111640. };
  111641. /**
  111642. * Remove an impostor from the engine.
  111643. * This impostor and its mesh will not longer be updated by the physics engine.
  111644. * @param impostor the impostor to remove
  111645. */
  111646. PhysicsEngine.prototype.removeImpostor = function (impostor) {
  111647. var index = this._impostors.indexOf(impostor);
  111648. if (index > -1) {
  111649. var removed = this._impostors.splice(index, 1);
  111650. //Is it needed?
  111651. if (removed.length) {
  111652. //this will also remove it from the world.
  111653. removed[0].physicsBody = null;
  111654. }
  111655. }
  111656. };
  111657. /**
  111658. * Add a joint to the physics engine
  111659. * @param mainImpostor defines the main impostor to which the joint is added.
  111660. * @param connectedImpostor defines the impostor that is connected to the main impostor using this joint
  111661. * @param joint defines the joint that will connect both impostors.
  111662. */
  111663. PhysicsEngine.prototype.addJoint = function (mainImpostor, connectedImpostor, joint) {
  111664. var impostorJoint = {
  111665. mainImpostor: mainImpostor,
  111666. connectedImpostor: connectedImpostor,
  111667. joint: joint
  111668. };
  111669. joint.physicsPlugin = this._physicsPlugin;
  111670. this._joints.push(impostorJoint);
  111671. this._physicsPlugin.generateJoint(impostorJoint);
  111672. };
  111673. /**
  111674. * Removes a joint from the simulation
  111675. * @param mainImpostor defines the impostor used with the joint
  111676. * @param connectedImpostor defines the other impostor connected to the main one by the joint
  111677. * @param joint defines the joint to remove
  111678. */
  111679. PhysicsEngine.prototype.removeJoint = function (mainImpostor, connectedImpostor, joint) {
  111680. var matchingJoints = this._joints.filter(function (impostorJoint) {
  111681. return (impostorJoint.connectedImpostor === connectedImpostor
  111682. && impostorJoint.joint === joint
  111683. && impostorJoint.mainImpostor === mainImpostor);
  111684. });
  111685. if (matchingJoints.length) {
  111686. this._physicsPlugin.removeJoint(matchingJoints[0]);
  111687. //TODO remove it from the list as well
  111688. }
  111689. };
  111690. /**
  111691. * Called by the scene. No need to call it.
  111692. * @param delta defines the timespam between frames
  111693. */
  111694. PhysicsEngine.prototype._step = function (delta) {
  111695. var _this = this;
  111696. //check if any mesh has no body / requires an update
  111697. this._impostors.forEach(function (impostor) {
  111698. if (impostor.isBodyInitRequired()) {
  111699. _this._physicsPlugin.generatePhysicsBody(impostor);
  111700. }
  111701. });
  111702. if (delta > 0.1) {
  111703. delta = 0.1;
  111704. }
  111705. else if (delta <= 0) {
  111706. delta = 1.0 / 60.0;
  111707. }
  111708. this._physicsPlugin.executeStep(delta, this._impostors);
  111709. };
  111710. /**
  111711. * Gets the current plugin used to run the simulation
  111712. * @returns current plugin
  111713. */
  111714. PhysicsEngine.prototype.getPhysicsPlugin = function () {
  111715. return this._physicsPlugin;
  111716. };
  111717. /**
  111718. * Gets the list of physic impostors
  111719. * @returns an array of PhysicsImpostor
  111720. */
  111721. PhysicsEngine.prototype.getImpostors = function () {
  111722. return this._impostors;
  111723. };
  111724. /**
  111725. * Gets the impostor for a physics enabled object
  111726. * @param object defines the object impersonated by the impostor
  111727. * @returns the PhysicsImpostor or null if not found
  111728. */
  111729. PhysicsEngine.prototype.getImpostorForPhysicsObject = function (object) {
  111730. for (var i = 0; i < this._impostors.length; ++i) {
  111731. if (this._impostors[i].object === object) {
  111732. return this._impostors[i];
  111733. }
  111734. }
  111735. return null;
  111736. };
  111737. /**
  111738. * Gets the impostor for a physics body object
  111739. * @param body defines physics body used by the impostor
  111740. * @returns the PhysicsImpostor or null if not found
  111741. */
  111742. PhysicsEngine.prototype.getImpostorWithPhysicsBody = function (body) {
  111743. for (var i = 0; i < this._impostors.length; ++i) {
  111744. if (this._impostors[i].physicsBody === body) {
  111745. return this._impostors[i];
  111746. }
  111747. }
  111748. return null;
  111749. };
  111750. /**
  111751. * Global value used to control the smallest number supported by the simulation
  111752. */
  111753. PhysicsEngine.Epsilon = 0.001;
  111754. return PhysicsEngine;
  111755. }());
  111756. /***/ }),
  111757. /***/ "./Physics/physicsEngineComponent.ts":
  111758. /*!*******************************************!*\
  111759. !*** ./Physics/physicsEngineComponent.ts ***!
  111760. \*******************************************/
  111761. /*! exports provided: PhysicsEngineSceneComponent */
  111762. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111763. "use strict";
  111764. __webpack_require__.r(__webpack_exports__);
  111765. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return PhysicsEngineSceneComponent; });
  111766. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111767. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  111768. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  111769. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  111770. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  111771. /* harmony import */ var _physicsEngine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsEngine */ "./Physics/physicsEngine.ts");
  111772. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  111773. /**
  111774. * Gets the current physics engine
  111775. * @returns a IPhysicsEngine or null if none attached
  111776. */
  111777. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.getPhysicsEngine = function () {
  111778. return this._physicsEngine;
  111779. };
  111780. /**
  111781. * Enables physics to the current scene
  111782. * @param gravity defines the scene's gravity for the physics engine
  111783. * @param plugin defines the physics engine to be used. defaults to OimoJS.
  111784. * @return a boolean indicating if the physics engine was initialized
  111785. */
  111786. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.enablePhysics = function (gravity, plugin) {
  111787. if (gravity === void 0) { gravity = null; }
  111788. if (this._physicsEngine) {
  111789. return true;
  111790. }
  111791. // Register the component to the scene
  111792. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE);
  111793. if (!component) {
  111794. component = new PhysicsEngineSceneComponent(this);
  111795. this._addComponent(component);
  111796. }
  111797. try {
  111798. this._physicsEngine = new _physicsEngine__WEBPACK_IMPORTED_MODULE_5__["PhysicsEngine"](gravity, plugin);
  111799. return true;
  111800. }
  111801. catch (e) {
  111802. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error(e.message);
  111803. return false;
  111804. }
  111805. };
  111806. /**
  111807. * Disables and disposes the physics engine associated with the scene
  111808. */
  111809. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.disablePhysicsEngine = function () {
  111810. if (!this._physicsEngine) {
  111811. return;
  111812. }
  111813. this._physicsEngine.dispose();
  111814. this._physicsEngine = null;
  111815. };
  111816. /**
  111817. * Gets a boolean indicating if there is an active physics engine
  111818. * @returns a boolean indicating if there is an active physics engine
  111819. */
  111820. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.isPhysicsEnabled = function () {
  111821. return this._physicsEngine !== undefined;
  111822. };
  111823. /**
  111824. * Deletes a physics compound impostor
  111825. * @param compound defines the compound to delete
  111826. */
  111827. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype.deleteCompoundImpostor = function (compound) {
  111828. var mesh = compound.parts[0].mesh;
  111829. if (mesh.physicsImpostor) {
  111830. mesh.physicsImpostor.dispose( /*true*/);
  111831. mesh.physicsImpostor = null;
  111832. }
  111833. };
  111834. /** @hidden */
  111835. _scene__WEBPACK_IMPORTED_MODULE_4__["Scene"].prototype._advancePhysicsEngineStep = function (step) {
  111836. if (this._physicsEngine) {
  111837. this.onBeforePhysicsObservable.notifyObservers(this);
  111838. this._physicsEngine._step(step / 1000);
  111839. this.onAfterPhysicsObservable.notifyObservers(this);
  111840. }
  111841. };
  111842. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "physicsImpostor", {
  111843. get: function () {
  111844. return this._physicsImpostor;
  111845. },
  111846. set: function (value) {
  111847. var _this = this;
  111848. if (this._physicsImpostor === value) {
  111849. return;
  111850. }
  111851. if (this._disposePhysicsObserver) {
  111852. this.onDisposeObservable.remove(this._disposePhysicsObserver);
  111853. }
  111854. this._physicsImpostor = value;
  111855. if (value) {
  111856. this._disposePhysicsObserver = this.onDisposeObservable.add(function () {
  111857. // Physics
  111858. if (_this.physicsImpostor) {
  111859. _this.physicsImpostor.dispose( /*!doNotRecurse*/);
  111860. _this.physicsImpostor = null;
  111861. }
  111862. });
  111863. }
  111864. },
  111865. enumerable: true,
  111866. configurable: true
  111867. });
  111868. /**
  111869. * Gets the current physics impostor
  111870. * @see http://doc.babylonjs.com/features/physics_engine
  111871. * @returns a physics impostor or null
  111872. */
  111873. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.getPhysicsImpostor = function () {
  111874. return this.physicsImpostor;
  111875. };
  111876. /**
  111877. * Apply a physic impulse to the mesh
  111878. * @param force defines the force to apply
  111879. * @param contactPoint defines where to apply the force
  111880. * @returns the current mesh
  111881. * @see http://doc.babylonjs.com/how_to/using_the_physics_engine
  111882. */
  111883. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.applyImpulse = function (force, contactPoint) {
  111884. if (!this.physicsImpostor) {
  111885. return this;
  111886. }
  111887. this.physicsImpostor.applyImpulse(force, contactPoint);
  111888. return this;
  111889. };
  111890. /**
  111891. * Creates a physic joint between two meshes
  111892. * @param otherMesh defines the other mesh to use
  111893. * @param pivot1 defines the pivot to use on this mesh
  111894. * @param pivot2 defines the pivot to use on the other mesh
  111895. * @param options defines additional options (can be plugin dependent)
  111896. * @returns the current mesh
  111897. * @see https://www.babylonjs-playground.com/#0BS5U0#0
  111898. */
  111899. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.setPhysicsLinkWith = function (otherMesh, pivot1, pivot2, options) {
  111900. if (!this.physicsImpostor || !otherMesh.physicsImpostor) {
  111901. return this;
  111902. }
  111903. this.physicsImpostor.createJoint(otherMesh.physicsImpostor, _physicsJoint__WEBPACK_IMPORTED_MODULE_6__["PhysicsJoint"].HingeJoint, {
  111904. mainPivot: pivot1,
  111905. connectedPivot: pivot2,
  111906. nativeParams: options
  111907. });
  111908. return this;
  111909. };
  111910. /**
  111911. * Defines the physics engine scene component responsible to manage a physics engine
  111912. */
  111913. var PhysicsEngineSceneComponent = /** @class */ (function () {
  111914. /**
  111915. * Creates a new instance of the component for the given scene
  111916. * @param scene Defines the scene to register the component in
  111917. */
  111918. function PhysicsEngineSceneComponent(scene) {
  111919. var _this = this;
  111920. /**
  111921. * The component name helpful to identify the component in the list of scene components.
  111922. */
  111923. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_PHYSICSENGINE;
  111924. this.scene = scene;
  111925. this.scene.onBeforePhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111926. this.scene.onAfterPhysicsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  111927. // Replace the function used to get the deterministic frame time
  111928. this.scene.getDeterministicFrameTime = function () {
  111929. if (_this.scene._physicsEngine) {
  111930. return _this.scene._physicsEngine.getTimeStep() * 1000;
  111931. }
  111932. return 1000.0 / 60.0;
  111933. };
  111934. }
  111935. /**
  111936. * Registers the component in a given scene
  111937. */
  111938. PhysicsEngineSceneComponent.prototype.register = function () {
  111939. };
  111940. /**
  111941. * Rebuilds the elements related to this component in case of
  111942. * context lost for instance.
  111943. */
  111944. PhysicsEngineSceneComponent.prototype.rebuild = function () {
  111945. // Nothing to do for this component
  111946. };
  111947. /**
  111948. * Disposes the component and the associated ressources
  111949. */
  111950. PhysicsEngineSceneComponent.prototype.dispose = function () {
  111951. this.scene.onBeforePhysicsObservable.clear();
  111952. this.scene.onAfterPhysicsObservable.clear();
  111953. if (this.scene._physicsEngine) {
  111954. this.scene.disablePhysicsEngine();
  111955. }
  111956. };
  111957. return PhysicsEngineSceneComponent;
  111958. }());
  111959. /***/ }),
  111960. /***/ "./Physics/physicsHelper.ts":
  111961. /*!**********************************!*\
  111962. !*** ./Physics/physicsHelper.ts ***!
  111963. \**********************************/
  111964. /*! exports provided: PhysicsHelper, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode */
  111965. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  111966. "use strict";
  111967. __webpack_require__.r(__webpack_exports__);
  111968. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return PhysicsHelper; });
  111969. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return PhysicsRadialExplosionEvent; });
  111970. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return PhysicsGravitationalFieldEvent; });
  111971. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return PhysicsUpdraftEvent; });
  111972. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return PhysicsVortexEvent; });
  111973. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return PhysicsRadialImpulseFalloff; });
  111974. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return PhysicsUpdraftMode; });
  111975. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  111976. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  111977. /* harmony import */ var _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/Builders/sphereBuilder */ "./Meshes/Builders/sphereBuilder.ts");
  111978. /* harmony import */ var _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/Builders/cylinderBuilder */ "./Meshes/Builders/cylinderBuilder.ts");
  111979. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  111980. /**
  111981. * A helper for physics simulations
  111982. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  111983. */
  111984. var PhysicsHelper = /** @class */ (function () {
  111985. /**
  111986. * Initializes the Physics helper
  111987. * @param scene Babylon.js scene
  111988. */
  111989. function PhysicsHelper(scene) {
  111990. this._scene = scene;
  111991. this._physicsEngine = this._scene.getPhysicsEngine();
  111992. if (!this._physicsEngine) {
  111993. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you can use the methods.');
  111994. }
  111995. }
  111996. /**
  111997. * Applies a radial explosion impulse
  111998. * @param origin the origin of the explosion
  111999. * @param radius the explosion radius
  112000. * @param strength the explosion strength
  112001. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112002. * @returns A physics radial explosion event, or null
  112003. */
  112004. PhysicsHelper.prototype.applyRadialExplosionImpulse = function (origin, radius, strength, falloff) {
  112005. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112006. if (!this._physicsEngine) {
  112007. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call this method.');
  112008. return null;
  112009. }
  112010. var impostors = this._physicsEngine.getImpostors();
  112011. if (impostors.length === 0) {
  112012. return null;
  112013. }
  112014. var event = new PhysicsRadialExplosionEvent(this._scene);
  112015. impostors.forEach(function (impostor) {
  112016. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  112017. if (!impostorForceAndContactPoint) {
  112018. return;
  112019. }
  112020. impostor.applyImpulse(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112021. });
  112022. event.dispose(false);
  112023. return event;
  112024. };
  112025. /**
  112026. * Applies a radial explosion force
  112027. * @param origin the origin of the explosion
  112028. * @param radius the explosion radius
  112029. * @param strength the explosion strength
  112030. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112031. * @returns A physics radial explosion event, or null
  112032. */
  112033. PhysicsHelper.prototype.applyRadialExplosionForce = function (origin, radius, strength, falloff) {
  112034. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112035. if (!this._physicsEngine) {
  112036. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112037. return null;
  112038. }
  112039. var impostors = this._physicsEngine.getImpostors();
  112040. if (impostors.length === 0) {
  112041. return null;
  112042. }
  112043. var event = new PhysicsRadialExplosionEvent(this._scene);
  112044. impostors.forEach(function (impostor) {
  112045. var impostorForceAndContactPoint = event.getImpostorForceAndContactPoint(impostor, origin, radius, strength, falloff);
  112046. if (!impostorForceAndContactPoint) {
  112047. return;
  112048. }
  112049. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112050. });
  112051. event.dispose(false);
  112052. return event;
  112053. };
  112054. /**
  112055. * Creates a gravitational field
  112056. * @param origin the origin of the explosion
  112057. * @param radius the explosion radius
  112058. * @param strength the explosion strength
  112059. * @param falloff possible options: Constant & Linear. Defaults to Constant
  112060. * @returns A physics gravitational field event, or null
  112061. */
  112062. PhysicsHelper.prototype.gravitationalField = function (origin, radius, strength, falloff) {
  112063. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112064. if (!this._physicsEngine) {
  112065. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112066. return null;
  112067. }
  112068. var impostors = this._physicsEngine.getImpostors();
  112069. if (impostors.length === 0) {
  112070. return null;
  112071. }
  112072. var event = new PhysicsGravitationalFieldEvent(this, this._scene, origin, radius, strength, falloff);
  112073. event.dispose(false);
  112074. return event;
  112075. };
  112076. /**
  112077. * Creates a physics updraft event
  112078. * @param origin the origin of the updraft
  112079. * @param radius the radius of the updraft
  112080. * @param strength the strength of the updraft
  112081. * @param height the height of the updraft
  112082. * @param updraftMode possible options: Center & Perpendicular. Defaults to Center
  112083. * @returns A physics updraft event, or null
  112084. */
  112085. PhysicsHelper.prototype.updraft = function (origin, radius, strength, height, updraftMode) {
  112086. if (updraftMode === void 0) { updraftMode = PhysicsUpdraftMode.Center; }
  112087. if (!this._physicsEngine) {
  112088. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112089. return null;
  112090. }
  112091. if (this._physicsEngine.getImpostors().length === 0) {
  112092. return null;
  112093. }
  112094. var event = new PhysicsUpdraftEvent(this._scene, origin, radius, strength, height, updraftMode);
  112095. event.dispose(false);
  112096. return event;
  112097. };
  112098. /**
  112099. * Creates a physics vortex event
  112100. * @param origin the of the vortex
  112101. * @param radius the radius of the vortex
  112102. * @param strength the strength of the vortex
  112103. * @param height the height of the vortex
  112104. * @returns a Physics vortex event, or null
  112105. * A physics vortex event or null
  112106. */
  112107. PhysicsHelper.prototype.vortex = function (origin, radius, strength, height) {
  112108. if (!this._physicsEngine) {
  112109. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn('Physics engine not enabled. Please enable the physics before you call the PhysicsHelper.');
  112110. return null;
  112111. }
  112112. if (this._physicsEngine.getImpostors().length === 0) {
  112113. return null;
  112114. }
  112115. var event = new PhysicsVortexEvent(this._scene, origin, radius, strength, height);
  112116. event.dispose(false);
  112117. return event;
  112118. };
  112119. return PhysicsHelper;
  112120. }());
  112121. /**
  112122. * Represents a physics radial explosion event
  112123. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112124. */
  112125. var PhysicsRadialExplosionEvent = /** @class */ (function () {
  112126. /**
  112127. * Initializes a radial explosioin event
  112128. * @param scene BabylonJS scene
  112129. */
  112130. function PhysicsRadialExplosionEvent(scene) {
  112131. this._sphereOptions = { segments: 32, diameter: 1 }; // TODO: make configurable
  112132. this._rays = [];
  112133. this._dataFetched = false; // check if the data has been fetched. If not, do cleanup
  112134. this._scene = scene;
  112135. }
  112136. /**
  112137. * Returns the data related to the radial explosion event (sphere & rays).
  112138. * @returns The radial explosion event data
  112139. */
  112140. PhysicsRadialExplosionEvent.prototype.getData = function () {
  112141. this._dataFetched = true;
  112142. return {
  112143. sphere: this._sphere,
  112144. rays: this._rays,
  112145. };
  112146. };
  112147. /**
  112148. * Returns the force and contact point of the impostor or false, if the impostor is not affected by the force/impulse.
  112149. * @param impostor A physics imposter
  112150. * @param origin the origin of the explosion
  112151. * @param radius the explosion radius
  112152. * @param strength the explosion strength
  112153. * @param falloff possible options: Constant & Linear
  112154. * @returns {Nullable<PhysicsForceAndContactPoint>} A physics force and contact point, or null
  112155. */
  112156. PhysicsRadialExplosionEvent.prototype.getImpostorForceAndContactPoint = function (impostor, origin, radius, strength, falloff) {
  112157. if (impostor.mass === 0) {
  112158. return null;
  112159. }
  112160. if (!this._intersectsWithSphere(impostor, origin, radius)) {
  112161. return null;
  112162. }
  112163. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  112164. return null;
  112165. }
  112166. var impostorObjectCenter = impostor.getObjectCenter();
  112167. var direction = impostorObjectCenter.subtract(origin);
  112168. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](origin, direction, radius);
  112169. this._rays.push(ray);
  112170. var hit = ray.intersectsMesh(impostor.object);
  112171. var contactPoint = hit.pickedPoint;
  112172. if (!contactPoint) {
  112173. return null;
  112174. }
  112175. var distanceFromOrigin = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Distance(origin, contactPoint);
  112176. if (distanceFromOrigin > radius) {
  112177. return null;
  112178. }
  112179. var multiplier = falloff === PhysicsRadialImpulseFalloff.Constant
  112180. ? strength
  112181. : strength * (1 - (distanceFromOrigin / radius));
  112182. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  112183. return { force: force, contactPoint: contactPoint };
  112184. };
  112185. /**
  112186. * Disposes the sphere.
  112187. * @param force Specifies if the sphere should be disposed by force
  112188. */
  112189. PhysicsRadialExplosionEvent.prototype.dispose = function (force) {
  112190. var _this = this;
  112191. if (force === void 0) { force = true; }
  112192. if (force) {
  112193. this._sphere.dispose();
  112194. }
  112195. else {
  112196. setTimeout(function () {
  112197. if (!_this._dataFetched) {
  112198. _this._sphere.dispose();
  112199. }
  112200. }, 0);
  112201. }
  112202. };
  112203. /*** Helpers ***/
  112204. PhysicsRadialExplosionEvent.prototype._prepareSphere = function () {
  112205. if (!this._sphere) {
  112206. this._sphere = _Meshes_Builders_sphereBuilder__WEBPACK_IMPORTED_MODULE_2__["SphereBuilder"].CreateSphere("radialExplosionEventSphere", this._sphereOptions, this._scene);
  112207. this._sphere.isVisible = false;
  112208. }
  112209. };
  112210. PhysicsRadialExplosionEvent.prototype._intersectsWithSphere = function (impostor, origin, radius) {
  112211. var impostorObject = impostor.object;
  112212. this._prepareSphere();
  112213. this._sphere.position = origin;
  112214. this._sphere.scaling = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](radius * 2, radius * 2, radius * 2);
  112215. this._sphere._updateBoundingInfo();
  112216. this._sphere.computeWorldMatrix(true);
  112217. return this._sphere.intersectsMesh(impostorObject, true);
  112218. };
  112219. return PhysicsRadialExplosionEvent;
  112220. }());
  112221. /**
  112222. * Represents a gravitational field event
  112223. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112224. */
  112225. var PhysicsGravitationalFieldEvent = /** @class */ (function () {
  112226. /**
  112227. * Initializes the physics gravitational field event
  112228. * @param physicsHelper A physics helper
  112229. * @param scene BabylonJS scene
  112230. * @param origin The origin position of the gravitational field event
  112231. * @param radius The radius of the gravitational field event
  112232. * @param strength The strength of the gravitational field event
  112233. * @param falloff The falloff for the gravitational field event
  112234. */
  112235. function PhysicsGravitationalFieldEvent(physicsHelper, scene, origin, radius, strength, falloff) {
  112236. if (falloff === void 0) { falloff = PhysicsRadialImpulseFalloff.Constant; }
  112237. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  112238. this._physicsHelper = physicsHelper;
  112239. this._scene = scene;
  112240. this._origin = origin;
  112241. this._radius = radius;
  112242. this._strength = strength;
  112243. this._falloff = falloff;
  112244. this._tickCallback = this._tick.bind(this);
  112245. }
  112246. /**
  112247. * Returns the data related to the gravitational field event (sphere).
  112248. * @returns A gravitational field event
  112249. */
  112250. PhysicsGravitationalFieldEvent.prototype.getData = function () {
  112251. this._dataFetched = true;
  112252. return {
  112253. sphere: this._sphere,
  112254. };
  112255. };
  112256. /**
  112257. * Enables the gravitational field.
  112258. */
  112259. PhysicsGravitationalFieldEvent.prototype.enable = function () {
  112260. this._tickCallback.call(this);
  112261. this._scene.registerBeforeRender(this._tickCallback);
  112262. };
  112263. /**
  112264. * Disables the gravitational field.
  112265. */
  112266. PhysicsGravitationalFieldEvent.prototype.disable = function () {
  112267. this._scene.unregisterBeforeRender(this._tickCallback);
  112268. };
  112269. /**
  112270. * Disposes the sphere.
  112271. * @param force The force to dispose from the gravitational field event
  112272. */
  112273. PhysicsGravitationalFieldEvent.prototype.dispose = function (force) {
  112274. var _this = this;
  112275. if (force === void 0) { force = true; }
  112276. if (force) {
  112277. this._sphere.dispose();
  112278. }
  112279. else {
  112280. setTimeout(function () {
  112281. if (!_this._dataFetched) {
  112282. _this._sphere.dispose();
  112283. }
  112284. }, 0);
  112285. }
  112286. };
  112287. PhysicsGravitationalFieldEvent.prototype._tick = function () {
  112288. // Since the params won't change, we fetch the event only once
  112289. if (this._sphere) {
  112290. this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  112291. }
  112292. else {
  112293. var radialExplosionEvent = this._physicsHelper.applyRadialExplosionForce(this._origin, this._radius, this._strength * -1, this._falloff);
  112294. if (radialExplosionEvent) {
  112295. this._sphere = radialExplosionEvent.getData().sphere.clone('radialExplosionEventSphereClone');
  112296. }
  112297. }
  112298. };
  112299. return PhysicsGravitationalFieldEvent;
  112300. }());
  112301. /**
  112302. * Represents a physics updraft event
  112303. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112304. */
  112305. var PhysicsUpdraftEvent = /** @class */ (function () {
  112306. /**
  112307. * Initializes the physics updraft event
  112308. * @param _scene BabylonJS scene
  112309. * @param _origin The origin position of the updraft
  112310. * @param _radius The radius of the updraft
  112311. * @param _strength The strength of the updraft
  112312. * @param _height The height of the updraft
  112313. * @param _updraftMode The mode of the updraft
  112314. */
  112315. function PhysicsUpdraftEvent(_scene, _origin, _radius, _strength, _height, _updraftMode) {
  112316. this._scene = _scene;
  112317. this._origin = _origin;
  112318. this._radius = _radius;
  112319. this._strength = _strength;
  112320. this._height = _height;
  112321. this._updraftMode = _updraftMode;
  112322. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  112323. this._originDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // used if the updraftMode is perpendicular
  112324. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  112325. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  112326. this._physicsEngine = this._scene.getPhysicsEngine();
  112327. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  112328. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  112329. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  112330. this._originDirection = this._origin.subtract(this._originTop).normalize();
  112331. }
  112332. this._tickCallback = this._tick.bind(this);
  112333. this._prepareCylinder();
  112334. }
  112335. /**
  112336. * Returns the data related to the updraft event (cylinder).
  112337. * @returns A physics updraft event
  112338. */
  112339. PhysicsUpdraftEvent.prototype.getData = function () {
  112340. this._dataFetched = true;
  112341. return {
  112342. cylinder: this._cylinder,
  112343. };
  112344. };
  112345. /**
  112346. * Enables the updraft.
  112347. */
  112348. PhysicsUpdraftEvent.prototype.enable = function () {
  112349. this._tickCallback.call(this);
  112350. this._scene.registerBeforeRender(this._tickCallback);
  112351. };
  112352. /**
  112353. * Disables the cortex.
  112354. */
  112355. PhysicsUpdraftEvent.prototype.disable = function () {
  112356. this._scene.unregisterBeforeRender(this._tickCallback);
  112357. };
  112358. /**
  112359. * Disposes the sphere.
  112360. * @param force Specifies if the updraft should be disposed by force
  112361. */
  112362. PhysicsUpdraftEvent.prototype.dispose = function (force) {
  112363. var _this = this;
  112364. if (force === void 0) { force = true; }
  112365. if (!this._cylinder) {
  112366. return;
  112367. }
  112368. if (force) {
  112369. this._cylinder.dispose();
  112370. }
  112371. else {
  112372. setTimeout(function () {
  112373. if (!_this._dataFetched) {
  112374. _this._cylinder.dispose();
  112375. }
  112376. }, 0);
  112377. }
  112378. };
  112379. PhysicsUpdraftEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  112380. if (impostor.mass === 0) {
  112381. return null;
  112382. }
  112383. if (!this._intersectsWithCylinder(impostor)) {
  112384. return null;
  112385. }
  112386. var impostorObjectCenter = impostor.getObjectCenter();
  112387. if (this._updraftMode === PhysicsUpdraftMode.Perpendicular) {
  112388. var direction = this._originDirection;
  112389. }
  112390. else {
  112391. var direction = impostorObjectCenter.subtract(this._originTop);
  112392. }
  112393. var multiplier = this._strength * -1;
  112394. var force = direction.multiplyByFloats(multiplier, multiplier, multiplier);
  112395. return { force: force, contactPoint: impostorObjectCenter };
  112396. };
  112397. PhysicsUpdraftEvent.prototype._tick = function () {
  112398. var _this = this;
  112399. this._physicsEngine.getImpostors().forEach(function (impostor) {
  112400. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  112401. if (!impostorForceAndContactPoint) {
  112402. return;
  112403. }
  112404. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112405. });
  112406. };
  112407. /*** Helpers ***/
  112408. PhysicsUpdraftEvent.prototype._prepareCylinder = function () {
  112409. if (!this._cylinder) {
  112410. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("updraftEventCylinder", {
  112411. height: this._height,
  112412. diameter: this._radius * 2,
  112413. }, this._scene);
  112414. this._cylinder.isVisible = false;
  112415. }
  112416. };
  112417. PhysicsUpdraftEvent.prototype._intersectsWithCylinder = function (impostor) {
  112418. var impostorObject = impostor.object;
  112419. this._cylinder.position = this._cylinderPosition;
  112420. return this._cylinder.intersectsMesh(impostorObject, true);
  112421. };
  112422. return PhysicsUpdraftEvent;
  112423. }());
  112424. /**
  112425. * Represents a physics vortex event
  112426. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112427. */
  112428. var PhysicsVortexEvent = /** @class */ (function () {
  112429. /**
  112430. * Initializes the physics vortex event
  112431. * @param _scene The BabylonJS scene
  112432. * @param _origin The origin position of the vortex
  112433. * @param _radius The radius of the vortex
  112434. * @param _strength The strength of the vortex
  112435. * @param _height The height of the vortex
  112436. */
  112437. function PhysicsVortexEvent(_scene, _origin, _radius, _strength, _height) {
  112438. this._scene = _scene;
  112439. this._origin = _origin;
  112440. this._radius = _radius;
  112441. this._strength = _strength;
  112442. this._height = _height;
  112443. this._originTop = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // the most upper part of the cylinder
  112444. this._centripetalForceThreshold = 0.7; // at which distance, relative to the radius the centripetal forces should kick in
  112445. this._updraftMultiplier = 0.02;
  112446. this._cylinderPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero(); // to keep the cylinders position, because normally the origin is in the center and not on the bottom
  112447. this._dataFetched = false; // check if the has been fetched the data. If not, do cleanup
  112448. this._physicsEngine = this._scene.getPhysicsEngine();
  112449. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height / 2, 0), this._cylinderPosition);
  112450. this._origin.addToRef(new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](0, this._height, 0), this._originTop);
  112451. this._tickCallback = this._tick.bind(this);
  112452. this._prepareCylinder();
  112453. }
  112454. /**
  112455. * Returns the data related to the vortex event (cylinder).
  112456. * @returns The physics vortex event data
  112457. */
  112458. PhysicsVortexEvent.prototype.getData = function () {
  112459. this._dataFetched = true;
  112460. return {
  112461. cylinder: this._cylinder,
  112462. };
  112463. };
  112464. /**
  112465. * Enables the vortex.
  112466. */
  112467. PhysicsVortexEvent.prototype.enable = function () {
  112468. this._tickCallback.call(this);
  112469. this._scene.registerBeforeRender(this._tickCallback);
  112470. };
  112471. /**
  112472. * Disables the cortex.
  112473. */
  112474. PhysicsVortexEvent.prototype.disable = function () {
  112475. this._scene.unregisterBeforeRender(this._tickCallback);
  112476. };
  112477. /**
  112478. * Disposes the sphere.
  112479. * @param force
  112480. */
  112481. PhysicsVortexEvent.prototype.dispose = function (force) {
  112482. var _this = this;
  112483. if (force === void 0) { force = true; }
  112484. if (force) {
  112485. this._cylinder.dispose();
  112486. }
  112487. else {
  112488. setTimeout(function () {
  112489. if (!_this._dataFetched) {
  112490. _this._cylinder.dispose();
  112491. }
  112492. }, 0);
  112493. }
  112494. };
  112495. PhysicsVortexEvent.prototype.getImpostorForceAndContactPoint = function (impostor) {
  112496. if (impostor.mass === 0) {
  112497. return null;
  112498. }
  112499. if (!this._intersectsWithCylinder(impostor)) {
  112500. return null;
  112501. }
  112502. if (impostor.object.getClassName() !== 'Mesh' && impostor.object.getClassName() !== 'InstancedMesh') {
  112503. return null;
  112504. }
  112505. var impostorObjectCenter = impostor.getObjectCenter();
  112506. var originOnPlane = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](this._origin.x, impostorObjectCenter.y, this._origin.z); // the distance to the origin as if both objects were on a plane (Y-axis)
  112507. var originToImpostorDirection = impostorObjectCenter.subtract(originOnPlane);
  112508. var ray = new _Culling_ray__WEBPACK_IMPORTED_MODULE_4__["Ray"](originOnPlane, originToImpostorDirection, this._radius);
  112509. var hit = ray.intersectsMesh(impostor.object);
  112510. var contactPoint = hit.pickedPoint;
  112511. if (!contactPoint) {
  112512. return null;
  112513. }
  112514. var absoluteDistanceFromOrigin = hit.distance / this._radius;
  112515. var perpendicularDirection = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Cross(originOnPlane, impostorObjectCenter).normalize();
  112516. var directionToOrigin = contactPoint.normalize();
  112517. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  112518. directionToOrigin = directionToOrigin.negate();
  112519. }
  112520. // TODO: find a more physically based solution
  112521. if (absoluteDistanceFromOrigin > this._centripetalForceThreshold) {
  112522. var forceX = directionToOrigin.x * this._strength / 8;
  112523. var forceY = directionToOrigin.y * this._updraftMultiplier;
  112524. var forceZ = directionToOrigin.z * this._strength / 8;
  112525. }
  112526. else {
  112527. var forceX = (perpendicularDirection.x + directionToOrigin.x) / 2;
  112528. var forceY = this._originTop.y * this._updraftMultiplier;
  112529. var forceZ = (perpendicularDirection.z + directionToOrigin.z) / 2;
  112530. }
  112531. var force = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"](forceX, forceY, forceZ);
  112532. force = force.multiplyByFloats(this._strength, this._strength, this._strength);
  112533. return { force: force, contactPoint: impostorObjectCenter };
  112534. };
  112535. PhysicsVortexEvent.prototype._tick = function () {
  112536. var _this = this;
  112537. this._physicsEngine.getImpostors().forEach(function (impostor) {
  112538. var impostorForceAndContactPoint = _this.getImpostorForceAndContactPoint(impostor);
  112539. if (!impostorForceAndContactPoint) {
  112540. return;
  112541. }
  112542. impostor.applyForce(impostorForceAndContactPoint.force, impostorForceAndContactPoint.contactPoint);
  112543. });
  112544. };
  112545. /*** Helpers ***/
  112546. PhysicsVortexEvent.prototype._prepareCylinder = function () {
  112547. if (!this._cylinder) {
  112548. this._cylinder = _Meshes_Builders_cylinderBuilder__WEBPACK_IMPORTED_MODULE_3__["CylinderBuilder"].CreateCylinder("vortexEventCylinder", {
  112549. height: this._height,
  112550. diameter: this._radius * 2,
  112551. }, this._scene);
  112552. this._cylinder.isVisible = false;
  112553. }
  112554. };
  112555. PhysicsVortexEvent.prototype._intersectsWithCylinder = function (impostor) {
  112556. var impostorObject = impostor.object;
  112557. this._cylinder.position = this._cylinderPosition;
  112558. return this._cylinder.intersectsMesh(impostorObject, true);
  112559. };
  112560. return PhysicsVortexEvent;
  112561. }());
  112562. /**
  112563. * The strenght of the force in correspondence to the distance of the affected object
  112564. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112565. */
  112566. var PhysicsRadialImpulseFalloff;
  112567. (function (PhysicsRadialImpulseFalloff) {
  112568. /** Defines that impulse is constant in strength across it's whole radius */
  112569. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Constant"] = 0] = "Constant";
  112570. /** DEfines that impulse gets weaker if it's further from the origin */
  112571. PhysicsRadialImpulseFalloff[PhysicsRadialImpulseFalloff["Linear"] = 1] = "Linear";
  112572. })(PhysicsRadialImpulseFalloff || (PhysicsRadialImpulseFalloff = {}));
  112573. /**
  112574. * The strength of the force in correspondence to the distance of the affected object
  112575. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112576. */
  112577. var PhysicsUpdraftMode;
  112578. (function (PhysicsUpdraftMode) {
  112579. /** Defines that the upstream forces will pull towards the top center of the cylinder */
  112580. PhysicsUpdraftMode[PhysicsUpdraftMode["Center"] = 0] = "Center";
  112581. /** Defines that once a impostor is inside the cylinder, it will shoot out perpendicular from the ground of the cylinder */
  112582. PhysicsUpdraftMode[PhysicsUpdraftMode["Perpendicular"] = 1] = "Perpendicular";
  112583. })(PhysicsUpdraftMode || (PhysicsUpdraftMode = {}));
  112584. /***/ }),
  112585. /***/ "./Physics/physicsImpostor.ts":
  112586. /*!************************************!*\
  112587. !*** ./Physics/physicsImpostor.ts ***!
  112588. \************************************/
  112589. /*! exports provided: PhysicsImpostor */
  112590. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  112591. "use strict";
  112592. __webpack_require__.r(__webpack_exports__);
  112593. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return PhysicsImpostor; });
  112594. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  112595. /* harmony import */ var _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/arrayTools */ "./Misc/arrayTools.ts");
  112596. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  112597. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  112598. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  112599. /* harmony import */ var _physicsJoint__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./physicsJoint */ "./Physics/physicsJoint.ts");
  112600. _Meshes_mesh__WEBPACK_IMPORTED_MODULE_4__["Mesh"]._PhysicsImpostorParser = function (scene, physicObject, jsonObject) {
  112601. return new PhysicsImpostor(physicObject, jsonObject.physicsImpostor, {
  112602. mass: jsonObject.physicsMass,
  112603. friction: jsonObject.physicsFriction,
  112604. restitution: jsonObject.physicsRestitution
  112605. }, scene);
  112606. };
  112607. /**
  112608. * Represents a physics imposter
  112609. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  112610. */
  112611. var PhysicsImpostor = /** @class */ (function () {
  112612. /**
  112613. * Initializes the physics imposter
  112614. * @param object The physics-enabled object used as the physics imposter
  112615. * @param type The type of the physics imposter
  112616. * @param _options The options for the physics imposter
  112617. * @param _scene The Babylon scene
  112618. */
  112619. function PhysicsImpostor(
  112620. /**
  112621. * The physics-enabled object used as the physics imposter
  112622. */
  112623. object,
  112624. /**
  112625. * The type of the physics imposter
  112626. */
  112627. type, _options, _scene) {
  112628. if (_options === void 0) { _options = { mass: 0 }; }
  112629. var _this = this;
  112630. this.object = object;
  112631. this.type = type;
  112632. this._options = _options;
  112633. this._scene = _scene;
  112634. this._bodyUpdateRequired = false;
  112635. this._onBeforePhysicsStepCallbacks = new Array();
  112636. this._onAfterPhysicsStepCallbacks = new Array();
  112637. /** @hidden */
  112638. this._onPhysicsCollideCallbacks = [];
  112639. this._deltaPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112640. this._isDisposed = false;
  112641. //temp variables for parent rotation calculations
  112642. //private _mats: Array<Matrix> = [new Matrix(), new Matrix()];
  112643. this._tmpQuat = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112644. this._tmpQuat2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112645. /**
  112646. * this function is executed by the physics engine.
  112647. */
  112648. this.beforeStep = function () {
  112649. if (!_this._physicsEngine) {
  112650. return;
  112651. }
  112652. _this.object.translate(_this._deltaPosition, -1);
  112653. _this._deltaRotationConjugated && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotationConjugated, _this.object.rotationQuaternion);
  112654. _this.object.computeWorldMatrix(false);
  112655. if (_this.object.parent && _this.object.rotationQuaternion) {
  112656. _this.getParentsRotation();
  112657. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this._tmpQuat);
  112658. }
  112659. else {
  112660. _this._tmpQuat.copyFrom(_this.object.rotationQuaternion || new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]());
  112661. }
  112662. if (!_this._options.disableBidirectionalTransformation) {
  112663. _this.object.rotationQuaternion && _this._physicsEngine.getPhysicsPlugin().setPhysicsBodyTransformation(_this, /*bInfo.boundingBox.centerWorld*/ _this.object.getAbsolutePosition(), _this._tmpQuat);
  112664. }
  112665. _this._onBeforePhysicsStepCallbacks.forEach(function (func) {
  112666. func(_this);
  112667. });
  112668. };
  112669. /**
  112670. * this function is executed by the physics engine
  112671. */
  112672. this.afterStep = function () {
  112673. if (!_this._physicsEngine) {
  112674. return;
  112675. }
  112676. _this._onAfterPhysicsStepCallbacks.forEach(function (func) {
  112677. func(_this);
  112678. });
  112679. _this._physicsEngine.getPhysicsPlugin().setTransformationFromPhysicsBody(_this);
  112680. // object has now its world rotation. needs to be converted to local.
  112681. if (_this.object.parent && _this.object.rotationQuaternion) {
  112682. _this.getParentsRotation();
  112683. _this._tmpQuat.conjugateInPlace();
  112684. _this._tmpQuat.multiplyToRef(_this.object.rotationQuaternion, _this.object.rotationQuaternion);
  112685. }
  112686. // take the position set and make it the absolute position of this object.
  112687. _this.object.setAbsolutePosition(_this.object.position);
  112688. _this._deltaRotation && _this.object.rotationQuaternion && _this.object.rotationQuaternion.multiplyToRef(_this._deltaRotation, _this.object.rotationQuaternion);
  112689. _this.object.translate(_this._deltaPosition, 1);
  112690. };
  112691. /**
  112692. * Legacy collision detection event support
  112693. */
  112694. this.onCollideEvent = null;
  112695. /**
  112696. * event and body object due to cannon's event-based architecture.
  112697. */
  112698. this.onCollide = function (e) {
  112699. if (!_this._onPhysicsCollideCallbacks.length && !_this.onCollideEvent) {
  112700. return;
  112701. }
  112702. if (!_this._physicsEngine) {
  112703. return;
  112704. }
  112705. var otherImpostor = _this._physicsEngine.getImpostorWithPhysicsBody(e.body);
  112706. if (otherImpostor) {
  112707. // Legacy collision detection event support
  112708. if (_this.onCollideEvent) {
  112709. _this.onCollideEvent(_this, otherImpostor);
  112710. }
  112711. _this._onPhysicsCollideCallbacks.filter(function (obj) {
  112712. return obj.otherImpostors.indexOf(otherImpostor) !== -1;
  112713. }).forEach(function (obj) {
  112714. obj.callback(_this, otherImpostor);
  112715. });
  112716. }
  112717. };
  112718. //sanity check!
  112719. if (!this.object) {
  112720. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("No object was provided. A physics object is obligatory");
  112721. return;
  112722. }
  112723. // Legacy support for old syntax.
  112724. if (!this._scene && object.getScene) {
  112725. this._scene = object.getScene();
  112726. }
  112727. if (!this._scene) {
  112728. return;
  112729. }
  112730. this._physicsEngine = this._scene.getPhysicsEngine();
  112731. if (!this._physicsEngine) {
  112732. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Error("Physics not enabled. Please use scene.enablePhysics(...) before creating impostors.");
  112733. }
  112734. else {
  112735. //set the object's quaternion, if not set
  112736. if (!this.object.rotationQuaternion) {
  112737. if (this.object.rotation) {
  112738. this.object.rotationQuaternion = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRoll(this.object.rotation.y, this.object.rotation.x, this.object.rotation.z);
  112739. }
  112740. else {
  112741. this.object.rotationQuaternion = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  112742. }
  112743. }
  112744. //default options params
  112745. this._options.mass = (_options.mass === void 0) ? 0 : _options.mass;
  112746. this._options.friction = (_options.friction === void 0) ? 0.2 : _options.friction;
  112747. this._options.restitution = (_options.restitution === void 0) ? 0.2 : _options.restitution;
  112748. this._joints = [];
  112749. //If the mesh has a parent, don't initialize the physicsBody. Instead wait for the parent to do that.
  112750. if (!this.object.parent || this._options.ignoreParent) {
  112751. this._init();
  112752. }
  112753. else if (this.object.parent.physicsImpostor) {
  112754. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("You must affect impostors to children before affecting impostor to parent.");
  112755. }
  112756. }
  112757. }
  112758. Object.defineProperty(PhysicsImpostor.prototype, "isDisposed", {
  112759. /**
  112760. * Specifies if the physics imposter is disposed
  112761. */
  112762. get: function () {
  112763. return this._isDisposed;
  112764. },
  112765. enumerable: true,
  112766. configurable: true
  112767. });
  112768. Object.defineProperty(PhysicsImpostor.prototype, "mass", {
  112769. /**
  112770. * Gets the mass of the physics imposter
  112771. */
  112772. get: function () {
  112773. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyMass(this) : 0;
  112774. },
  112775. set: function (value) {
  112776. this.setMass(value);
  112777. },
  112778. enumerable: true,
  112779. configurable: true
  112780. });
  112781. Object.defineProperty(PhysicsImpostor.prototype, "friction", {
  112782. /**
  112783. * Gets the coefficient of friction
  112784. */
  112785. get: function () {
  112786. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyFriction(this) : 0;
  112787. },
  112788. /**
  112789. * Sets the coefficient of friction
  112790. */
  112791. set: function (value) {
  112792. if (!this._physicsEngine) {
  112793. return;
  112794. }
  112795. this._physicsEngine.getPhysicsPlugin().setBodyFriction(this, value);
  112796. },
  112797. enumerable: true,
  112798. configurable: true
  112799. });
  112800. Object.defineProperty(PhysicsImpostor.prototype, "restitution", {
  112801. /**
  112802. * Gets the coefficient of restitution
  112803. */
  112804. get: function () {
  112805. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getBodyRestitution(this) : 0;
  112806. },
  112807. /**
  112808. * Sets the coefficient of restitution
  112809. */
  112810. set: function (value) {
  112811. if (!this._physicsEngine) {
  112812. return;
  112813. }
  112814. this._physicsEngine.getPhysicsPlugin().setBodyRestitution(this, value);
  112815. },
  112816. enumerable: true,
  112817. configurable: true
  112818. });
  112819. /**
  112820. * This function will completly initialize this impostor.
  112821. * It will create a new body - but only if this mesh has no parent.
  112822. * If it has, this impostor will not be used other than to define the impostor
  112823. * of the child mesh.
  112824. * @hidden
  112825. */
  112826. PhysicsImpostor.prototype._init = function () {
  112827. if (!this._physicsEngine) {
  112828. return;
  112829. }
  112830. this._physicsEngine.removeImpostor(this);
  112831. this.physicsBody = null;
  112832. this._parent = this._parent || this._getPhysicsParent();
  112833. if (!this._isDisposed && (!this.parent || this._options.ignoreParent)) {
  112834. this._physicsEngine.addImpostor(this);
  112835. }
  112836. };
  112837. PhysicsImpostor.prototype._getPhysicsParent = function () {
  112838. if (this.object.parent instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_3__["AbstractMesh"]) {
  112839. var parentMesh = this.object.parent;
  112840. return parentMesh.physicsImpostor;
  112841. }
  112842. return null;
  112843. };
  112844. /**
  112845. * Should a new body be generated.
  112846. * @returns boolean specifying if body initialization is required
  112847. */
  112848. PhysicsImpostor.prototype.isBodyInitRequired = function () {
  112849. return this._bodyUpdateRequired || (!this._physicsBody && !this._parent);
  112850. };
  112851. /**
  112852. * Sets the updated scaling
  112853. * @param updated Specifies if the scaling is updated
  112854. */
  112855. PhysicsImpostor.prototype.setScalingUpdated = function () {
  112856. this.forceUpdate();
  112857. };
  112858. /**
  112859. * Force a regeneration of this or the parent's impostor's body.
  112860. * Use under cautious - This will remove all joints already implemented.
  112861. */
  112862. PhysicsImpostor.prototype.forceUpdate = function () {
  112863. this._init();
  112864. if (this.parent && !this._options.ignoreParent) {
  112865. this.parent.forceUpdate();
  112866. }
  112867. };
  112868. Object.defineProperty(PhysicsImpostor.prototype, "physicsBody", {
  112869. /*public get mesh(): AbstractMesh {
  112870. return this._mesh;
  112871. }*/
  112872. /**
  112873. * Gets the body that holds this impostor. Either its own, or its parent.
  112874. */
  112875. get: function () {
  112876. return (this._parent && !this._options.ignoreParent) ? this._parent.physicsBody : this._physicsBody;
  112877. },
  112878. /**
  112879. * Set the physics body. Used mainly by the physics engine/plugin
  112880. */
  112881. set: function (physicsBody) {
  112882. if (this._physicsBody && this._physicsEngine) {
  112883. this._physicsEngine.getPhysicsPlugin().removePhysicsBody(this);
  112884. }
  112885. this._physicsBody = physicsBody;
  112886. this.resetUpdateFlags();
  112887. },
  112888. enumerable: true,
  112889. configurable: true
  112890. });
  112891. Object.defineProperty(PhysicsImpostor.prototype, "parent", {
  112892. /**
  112893. * Get the parent of the physics imposter
  112894. * @returns Physics imposter or null
  112895. */
  112896. get: function () {
  112897. return !this._options.ignoreParent && this._parent ? this._parent : null;
  112898. },
  112899. /**
  112900. * Sets the parent of the physics imposter
  112901. */
  112902. set: function (value) {
  112903. this._parent = value;
  112904. },
  112905. enumerable: true,
  112906. configurable: true
  112907. });
  112908. /**
  112909. * Resets the update flags
  112910. */
  112911. PhysicsImpostor.prototype.resetUpdateFlags = function () {
  112912. this._bodyUpdateRequired = false;
  112913. };
  112914. /**
  112915. * Gets the object extend size
  112916. * @returns the object extend size
  112917. */
  112918. PhysicsImpostor.prototype.getObjectExtendSize = function () {
  112919. if (this.object.getBoundingInfo) {
  112920. var q = this.object.rotationQuaternion;
  112921. //reset rotation
  112922. this.object.rotationQuaternion = PhysicsImpostor.IDENTITY_QUATERNION;
  112923. //calculate the world matrix with no rotation
  112924. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112925. var boundingInfo = this.object.getBoundingInfo();
  112926. var size = boundingInfo.boundingBox.extendSizeWorld.scale(2);
  112927. //bring back the rotation
  112928. this.object.rotationQuaternion = q;
  112929. //calculate the world matrix with the new rotation
  112930. this.object.computeWorldMatrix && this.object.computeWorldMatrix(true);
  112931. return size;
  112932. }
  112933. else {
  112934. return PhysicsImpostor.DEFAULT_OBJECT_SIZE;
  112935. }
  112936. };
  112937. /**
  112938. * Gets the object center
  112939. * @returns The object center
  112940. */
  112941. PhysicsImpostor.prototype.getObjectCenter = function () {
  112942. if (this.object.getBoundingInfo) {
  112943. var boundingInfo = this.object.getBoundingInfo();
  112944. return boundingInfo.boundingBox.centerWorld;
  112945. }
  112946. else {
  112947. return this.object.position;
  112948. }
  112949. };
  112950. /**
  112951. * Get a specific parametes from the options parameter
  112952. * @param paramName The object parameter name
  112953. * @returns The object parameter
  112954. */
  112955. PhysicsImpostor.prototype.getParam = function (paramName) {
  112956. return this._options[paramName];
  112957. };
  112958. /**
  112959. * Sets a specific parameter in the options given to the physics plugin
  112960. * @param paramName The parameter name
  112961. * @param value The value of the parameter
  112962. */
  112963. PhysicsImpostor.prototype.setParam = function (paramName, value) {
  112964. this._options[paramName] = value;
  112965. this._bodyUpdateRequired = true;
  112966. };
  112967. /**
  112968. * Specifically change the body's mass option. Won't recreate the physics body object
  112969. * @param mass The mass of the physics imposter
  112970. */
  112971. PhysicsImpostor.prototype.setMass = function (mass) {
  112972. if (this.getParam("mass") !== mass) {
  112973. this.setParam("mass", mass);
  112974. }
  112975. if (this._physicsEngine) {
  112976. this._physicsEngine.getPhysicsPlugin().setBodyMass(this, mass);
  112977. }
  112978. };
  112979. /**
  112980. * Gets the linear velocity
  112981. * @returns linear velocity or null
  112982. */
  112983. PhysicsImpostor.prototype.getLinearVelocity = function () {
  112984. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getLinearVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  112985. };
  112986. /**
  112987. * Sets the linear velocity
  112988. * @param velocity linear velocity or null
  112989. */
  112990. PhysicsImpostor.prototype.setLinearVelocity = function (velocity) {
  112991. if (this._physicsEngine) {
  112992. this._physicsEngine.getPhysicsPlugin().setLinearVelocity(this, velocity);
  112993. }
  112994. };
  112995. /**
  112996. * Gets the angular velocity
  112997. * @returns angular velocity or null
  112998. */
  112999. PhysicsImpostor.prototype.getAngularVelocity = function () {
  113000. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getAngularVelocity(this) : _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero();
  113001. };
  113002. /**
  113003. * Sets the angular velocity
  113004. * @param velocity The velocity or null
  113005. */
  113006. PhysicsImpostor.prototype.setAngularVelocity = function (velocity) {
  113007. if (this._physicsEngine) {
  113008. this._physicsEngine.getPhysicsPlugin().setAngularVelocity(this, velocity);
  113009. }
  113010. };
  113011. /**
  113012. * Execute a function with the physics plugin native code
  113013. * Provide a function the will have two variables - the world object and the physics body object
  113014. * @param func The function to execute with the physics plugin native code
  113015. */
  113016. PhysicsImpostor.prototype.executeNativeFunction = function (func) {
  113017. if (this._physicsEngine) {
  113018. func(this._physicsEngine.getPhysicsPlugin().world, this.physicsBody);
  113019. }
  113020. };
  113021. /**
  113022. * Register a function that will be executed before the physics world is stepping forward
  113023. * @param func The function to execute before the physics world is stepped forward
  113024. */
  113025. PhysicsImpostor.prototype.registerBeforePhysicsStep = function (func) {
  113026. this._onBeforePhysicsStepCallbacks.push(func);
  113027. };
  113028. /**
  113029. * Unregister a function that will be executed before the physics world is stepping forward
  113030. * @param func The function to execute before the physics world is stepped forward
  113031. */
  113032. PhysicsImpostor.prototype.unregisterBeforePhysicsStep = function (func) {
  113033. var index = this._onBeforePhysicsStepCallbacks.indexOf(func);
  113034. if (index > -1) {
  113035. this._onBeforePhysicsStepCallbacks.splice(index, 1);
  113036. }
  113037. else {
  113038. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  113039. }
  113040. };
  113041. /**
  113042. * Register a function that will be executed after the physics step
  113043. * @param func The function to execute after physics step
  113044. */
  113045. PhysicsImpostor.prototype.registerAfterPhysicsStep = function (func) {
  113046. this._onAfterPhysicsStepCallbacks.push(func);
  113047. };
  113048. /**
  113049. * Unregisters a function that will be executed after the physics step
  113050. * @param func The function to execute after physics step
  113051. */
  113052. PhysicsImpostor.prototype.unregisterAfterPhysicsStep = function (func) {
  113053. var index = this._onAfterPhysicsStepCallbacks.indexOf(func);
  113054. if (index > -1) {
  113055. this._onAfterPhysicsStepCallbacks.splice(index, 1);
  113056. }
  113057. else {
  113058. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  113059. }
  113060. };
  113061. /**
  113062. * register a function that will be executed when this impostor collides against a different body
  113063. * @param collideAgainst Physics imposter, or array of physics imposters to collide against
  113064. * @param func Callback that is executed on collision
  113065. */
  113066. PhysicsImpostor.prototype.registerOnPhysicsCollide = function (collideAgainst, func) {
  113067. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  113068. this._onPhysicsCollideCallbacks.push({ callback: func, otherImpostors: collidedAgainstList });
  113069. };
  113070. /**
  113071. * Unregisters the physics imposter on contact
  113072. * @param collideAgainst The physics object to collide against
  113073. * @param func Callback to execute on collision
  113074. */
  113075. PhysicsImpostor.prototype.unregisterOnPhysicsCollide = function (collideAgainst, func) {
  113076. var collidedAgainstList = collideAgainst instanceof Array ? collideAgainst : [collideAgainst];
  113077. var index = -1;
  113078. var found = this._onPhysicsCollideCallbacks.some(function (cbDef, idx) {
  113079. if (cbDef.callback === func && cbDef.otherImpostors.length === collidedAgainstList.length) {
  113080. // chcek the arrays match
  113081. var sameList = cbDef.otherImpostors.every(function (impostor) {
  113082. return collidedAgainstList.indexOf(impostor) > -1;
  113083. });
  113084. if (sameList) {
  113085. index = idx;
  113086. }
  113087. return sameList;
  113088. }
  113089. return false;
  113090. });
  113091. if (found) {
  113092. this._onPhysicsCollideCallbacks.splice(index, 1);
  113093. }
  113094. else {
  113095. _Misc_logger__WEBPACK_IMPORTED_MODULE_0__["Logger"].Warn("Function to remove was not found");
  113096. }
  113097. };
  113098. /**
  113099. * Get the parent rotation
  113100. * @returns The parent rotation
  113101. */
  113102. PhysicsImpostor.prototype.getParentsRotation = function () {
  113103. var parent = this.object.parent;
  113104. this._tmpQuat.copyFromFloats(0, 0, 0, 1);
  113105. while (parent) {
  113106. if (parent.rotationQuaternion) {
  113107. this._tmpQuat2.copyFrom(parent.rotationQuaternion);
  113108. }
  113109. else {
  113110. _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].RotationYawPitchRollToRef(parent.rotation.y, parent.rotation.x, parent.rotation.z, this._tmpQuat2);
  113111. }
  113112. this._tmpQuat.multiplyToRef(this._tmpQuat2, this._tmpQuat);
  113113. parent = parent.parent;
  113114. }
  113115. return this._tmpQuat;
  113116. };
  113117. /**
  113118. * Apply a force
  113119. * @param force The force to apply
  113120. * @param contactPoint The contact point for the force
  113121. * @returns The physics imposter
  113122. */
  113123. PhysicsImpostor.prototype.applyForce = function (force, contactPoint) {
  113124. if (this._physicsEngine) {
  113125. this._physicsEngine.getPhysicsPlugin().applyForce(this, force, contactPoint);
  113126. }
  113127. return this;
  113128. };
  113129. /**
  113130. * Apply an impulse
  113131. * @param force The impulse force
  113132. * @param contactPoint The contact point for the impulse force
  113133. * @returns The physics imposter
  113134. */
  113135. PhysicsImpostor.prototype.applyImpulse = function (force, contactPoint) {
  113136. if (this._physicsEngine) {
  113137. this._physicsEngine.getPhysicsPlugin().applyImpulse(this, force, contactPoint);
  113138. }
  113139. return this;
  113140. };
  113141. /**
  113142. * A help function to create a joint
  113143. * @param otherImpostor A physics imposter used to create a joint
  113144. * @param jointType The type of joint
  113145. * @param jointData The data for the joint
  113146. * @returns The physics imposter
  113147. */
  113148. PhysicsImpostor.prototype.createJoint = function (otherImpostor, jointType, jointData) {
  113149. var joint = new _physicsJoint__WEBPACK_IMPORTED_MODULE_5__["PhysicsJoint"](jointType, jointData);
  113150. this.addJoint(otherImpostor, joint);
  113151. return this;
  113152. };
  113153. /**
  113154. * Add a joint to this impostor with a different impostor
  113155. * @param otherImpostor A physics imposter used to add a joint
  113156. * @param joint The joint to add
  113157. * @returns The physics imposter
  113158. */
  113159. PhysicsImpostor.prototype.addJoint = function (otherImpostor, joint) {
  113160. this._joints.push({
  113161. otherImpostor: otherImpostor,
  113162. joint: joint
  113163. });
  113164. if (this._physicsEngine) {
  113165. this._physicsEngine.addJoint(this, otherImpostor, joint);
  113166. }
  113167. return this;
  113168. };
  113169. /**
  113170. * Will keep this body still, in a sleep mode.
  113171. * @returns the physics imposter
  113172. */
  113173. PhysicsImpostor.prototype.sleep = function () {
  113174. if (this._physicsEngine) {
  113175. this._physicsEngine.getPhysicsPlugin().sleepBody(this);
  113176. }
  113177. return this;
  113178. };
  113179. /**
  113180. * Wake the body up.
  113181. * @returns The physics imposter
  113182. */
  113183. PhysicsImpostor.prototype.wakeUp = function () {
  113184. if (this._physicsEngine) {
  113185. this._physicsEngine.getPhysicsPlugin().wakeUpBody(this);
  113186. }
  113187. return this;
  113188. };
  113189. /**
  113190. * Clones the physics imposter
  113191. * @param newObject The physics imposter clones to this physics-enabled object
  113192. * @returns A nullable physics imposter
  113193. */
  113194. PhysicsImpostor.prototype.clone = function (newObject) {
  113195. if (!newObject) {
  113196. return null;
  113197. }
  113198. return new PhysicsImpostor(newObject, this.type, this._options, this._scene);
  113199. };
  113200. /**
  113201. * Disposes the physics imposter
  113202. */
  113203. PhysicsImpostor.prototype.dispose = function ( /*disposeChildren: boolean = true*/) {
  113204. var _this = this;
  113205. //no dispose if no physics engine is available.
  113206. if (!this._physicsEngine) {
  113207. return;
  113208. }
  113209. this._joints.forEach(function (j) {
  113210. if (_this._physicsEngine) {
  113211. _this._physicsEngine.removeJoint(_this, j.otherImpostor, j.joint);
  113212. }
  113213. });
  113214. //dispose the physics body
  113215. this._physicsEngine.removeImpostor(this);
  113216. if (this.parent) {
  113217. this.parent.forceUpdate();
  113218. }
  113219. else {
  113220. /*this._object.getChildMeshes().forEach(function(mesh) {
  113221. if (mesh.physicsImpostor) {
  113222. if (disposeChildren) {
  113223. mesh.physicsImpostor.dispose();
  113224. mesh.physicsImpostor = null;
  113225. }
  113226. }
  113227. })*/
  113228. }
  113229. this._isDisposed = true;
  113230. };
  113231. /**
  113232. * Sets the delta position
  113233. * @param position The delta position amount
  113234. */
  113235. PhysicsImpostor.prototype.setDeltaPosition = function (position) {
  113236. this._deltaPosition.copyFrom(position);
  113237. };
  113238. /**
  113239. * Sets the delta rotation
  113240. * @param rotation The delta rotation amount
  113241. */
  113242. PhysicsImpostor.prototype.setDeltaRotation = function (rotation) {
  113243. if (!this._deltaRotation) {
  113244. this._deltaRotation = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"]();
  113245. }
  113246. this._deltaRotation.copyFrom(rotation);
  113247. this._deltaRotationConjugated = this._deltaRotation.conjugate();
  113248. };
  113249. /**
  113250. * Gets the box size of the physics imposter and stores the result in the input parameter
  113251. * @param result Stores the box size
  113252. * @returns The physics imposter
  113253. */
  113254. PhysicsImpostor.prototype.getBoxSizeToRef = function (result) {
  113255. if (this._physicsEngine) {
  113256. this._physicsEngine.getPhysicsPlugin().getBoxSizeToRef(this, result);
  113257. }
  113258. return this;
  113259. };
  113260. /**
  113261. * Gets the radius of the physics imposter
  113262. * @returns Radius of the physics imposter
  113263. */
  113264. PhysicsImpostor.prototype.getRadius = function () {
  113265. return this._physicsEngine ? this._physicsEngine.getPhysicsPlugin().getRadius(this) : 0;
  113266. };
  113267. /**
  113268. * Sync a bone with this impostor
  113269. * @param bone The bone to sync to the impostor.
  113270. * @param boneMesh The mesh that the bone is influencing.
  113271. * @param jointPivot The pivot of the joint / bone in local space.
  113272. * @param distToJoint Optional distance from the impostor to the joint.
  113273. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113274. */
  113275. PhysicsImpostor.prototype.syncBoneWithImpostor = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation) {
  113276. var tempVec = PhysicsImpostor._tmpVecs[0];
  113277. var mesh = this.object;
  113278. if (mesh.rotationQuaternion) {
  113279. if (adjustRotation) {
  113280. var tempQuat = PhysicsImpostor._tmpQuat;
  113281. mesh.rotationQuaternion.multiplyToRef(adjustRotation, tempQuat);
  113282. bone.setRotationQuaternion(tempQuat, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  113283. }
  113284. else {
  113285. bone.setRotationQuaternion(mesh.rotationQuaternion, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh);
  113286. }
  113287. }
  113288. tempVec.x = 0;
  113289. tempVec.y = 0;
  113290. tempVec.z = 0;
  113291. if (jointPivot) {
  113292. tempVec.x = jointPivot.x;
  113293. tempVec.y = jointPivot.y;
  113294. tempVec.z = jointPivot.z;
  113295. bone.getDirectionToRef(tempVec, boneMesh, tempVec);
  113296. if (distToJoint === undefined || distToJoint === null) {
  113297. distToJoint = jointPivot.length();
  113298. }
  113299. tempVec.x *= distToJoint;
  113300. tempVec.y *= distToJoint;
  113301. tempVec.z *= distToJoint;
  113302. }
  113303. if (bone.getParent()) {
  113304. tempVec.addInPlace(mesh.getAbsolutePosition());
  113305. bone.setAbsolutePosition(tempVec, boneMesh);
  113306. }
  113307. else {
  113308. boneMesh.setAbsolutePosition(mesh.getAbsolutePosition());
  113309. boneMesh.position.x -= tempVec.x;
  113310. boneMesh.position.y -= tempVec.y;
  113311. boneMesh.position.z -= tempVec.z;
  113312. }
  113313. };
  113314. /**
  113315. * Sync impostor to a bone
  113316. * @param bone The bone that the impostor will be synced to.
  113317. * @param boneMesh The mesh that the bone is influencing.
  113318. * @param jointPivot The pivot of the joint / bone in local space.
  113319. * @param distToJoint Optional distance from the impostor to the joint.
  113320. * @param adjustRotation Optional quaternion for adjusting the local rotation of the bone.
  113321. * @param boneAxis Optional vector3 axis the bone is aligned with
  113322. */
  113323. PhysicsImpostor.prototype.syncImpostorWithBone = function (bone, boneMesh, jointPivot, distToJoint, adjustRotation, boneAxis) {
  113324. var mesh = this.object;
  113325. if (mesh.rotationQuaternion) {
  113326. if (adjustRotation) {
  113327. var tempQuat = PhysicsImpostor._tmpQuat;
  113328. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, tempQuat);
  113329. tempQuat.multiplyToRef(adjustRotation, mesh.rotationQuaternion);
  113330. }
  113331. else {
  113332. bone.getRotationQuaternionToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_2__["Space"].WORLD, boneMesh, mesh.rotationQuaternion);
  113333. }
  113334. }
  113335. var pos = PhysicsImpostor._tmpVecs[0];
  113336. var boneDir = PhysicsImpostor._tmpVecs[1];
  113337. if (!boneAxis) {
  113338. boneAxis = PhysicsImpostor._tmpVecs[2];
  113339. boneAxis.x = 0;
  113340. boneAxis.y = 1;
  113341. boneAxis.z = 0;
  113342. }
  113343. bone.getDirectionToRef(boneAxis, boneMesh, boneDir);
  113344. bone.getAbsolutePositionToRef(boneMesh, pos);
  113345. if ((distToJoint === undefined || distToJoint === null) && jointPivot) {
  113346. distToJoint = jointPivot.length();
  113347. }
  113348. if (distToJoint !== undefined && distToJoint !== null) {
  113349. pos.x += boneDir.x * distToJoint;
  113350. pos.y += boneDir.y * distToJoint;
  113351. pos.z += boneDir.z * distToJoint;
  113352. }
  113353. mesh.setAbsolutePosition(pos);
  113354. };
  113355. /**
  113356. * The default object size of the imposter
  113357. */
  113358. PhysicsImpostor.DEFAULT_OBJECT_SIZE = new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"](1, 1, 1);
  113359. /**
  113360. * The identity quaternion of the imposter
  113361. */
  113362. PhysicsImpostor.IDENTITY_QUATERNION = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  113363. PhysicsImpostor._tmpVecs = _Misc_arrayTools__WEBPACK_IMPORTED_MODULE_1__["ArrayTools"].BuildArray(3, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector3"].Zero);
  113364. PhysicsImpostor._tmpQuat = _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Quaternion"].Identity();
  113365. //Impostor types
  113366. /**
  113367. * No-Imposter type
  113368. */
  113369. PhysicsImpostor.NoImpostor = 0;
  113370. /**
  113371. * Sphere-Imposter type
  113372. */
  113373. PhysicsImpostor.SphereImpostor = 1;
  113374. /**
  113375. * Box-Imposter type
  113376. */
  113377. PhysicsImpostor.BoxImpostor = 2;
  113378. /**
  113379. * Plane-Imposter type
  113380. */
  113381. PhysicsImpostor.PlaneImpostor = 3;
  113382. /**
  113383. * Mesh-imposter type
  113384. */
  113385. PhysicsImpostor.MeshImpostor = 4;
  113386. /**
  113387. * Cylinder-Imposter type
  113388. */
  113389. PhysicsImpostor.CylinderImpostor = 7;
  113390. /**
  113391. * Particle-Imposter type
  113392. */
  113393. PhysicsImpostor.ParticleImpostor = 8;
  113394. /**
  113395. * Heightmap-Imposter type
  113396. */
  113397. PhysicsImpostor.HeightmapImpostor = 9;
  113398. return PhysicsImpostor;
  113399. }());
  113400. /***/ }),
  113401. /***/ "./Physics/physicsJoint.ts":
  113402. /*!*********************************!*\
  113403. !*** ./Physics/physicsJoint.ts ***!
  113404. \*********************************/
  113405. /*! exports provided: PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint */
  113406. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113407. "use strict";
  113408. __webpack_require__.r(__webpack_exports__);
  113409. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return PhysicsJoint; });
  113410. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return DistanceJoint; });
  113411. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return MotorEnabledJoint; });
  113412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return HingeJoint; });
  113413. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return Hinge2Joint; });
  113414. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113415. /**
  113416. * This is a holder class for the physics joint created by the physics plugin
  113417. * It holds a set of functions to control the underlying joint
  113418. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113419. */
  113420. var PhysicsJoint = /** @class */ (function () {
  113421. /**
  113422. * Initializes the physics joint
  113423. * @param type The type of the physics joint
  113424. * @param jointData The data for the physics joint
  113425. */
  113426. function PhysicsJoint(
  113427. /**
  113428. * The type of the physics joint
  113429. */
  113430. type,
  113431. /**
  113432. * The data for the physics joint
  113433. */
  113434. jointData) {
  113435. this.type = type;
  113436. this.jointData = jointData;
  113437. jointData.nativeParams = jointData.nativeParams || {};
  113438. }
  113439. Object.defineProperty(PhysicsJoint.prototype, "physicsJoint", {
  113440. /**
  113441. * Gets the physics joint
  113442. */
  113443. get: function () {
  113444. return this._physicsJoint;
  113445. },
  113446. /**
  113447. * Sets the physics joint
  113448. */
  113449. set: function (newJoint) {
  113450. if (this._physicsJoint) {
  113451. //remove from the wolrd
  113452. }
  113453. this._physicsJoint = newJoint;
  113454. },
  113455. enumerable: true,
  113456. configurable: true
  113457. });
  113458. Object.defineProperty(PhysicsJoint.prototype, "physicsPlugin", {
  113459. /**
  113460. * Sets the physics plugin
  113461. */
  113462. set: function (physicsPlugin) {
  113463. this._physicsPlugin = physicsPlugin;
  113464. },
  113465. enumerable: true,
  113466. configurable: true
  113467. });
  113468. /**
  113469. * Execute a function that is physics-plugin specific.
  113470. * @param {Function} func the function that will be executed.
  113471. * It accepts two parameters: the physics world and the physics joint
  113472. */
  113473. PhysicsJoint.prototype.executeNativeFunction = function (func) {
  113474. func(this._physicsPlugin.world, this._physicsJoint);
  113475. };
  113476. //TODO check if the native joints are the same
  113477. //Joint Types
  113478. /**
  113479. * Distance-Joint type
  113480. */
  113481. PhysicsJoint.DistanceJoint = 0;
  113482. /**
  113483. * Hinge-Joint type
  113484. */
  113485. PhysicsJoint.HingeJoint = 1;
  113486. /**
  113487. * Ball-and-Socket joint type
  113488. */
  113489. PhysicsJoint.BallAndSocketJoint = 2;
  113490. /**
  113491. * Wheel-Joint type
  113492. */
  113493. PhysicsJoint.WheelJoint = 3;
  113494. /**
  113495. * Slider-Joint type
  113496. */
  113497. PhysicsJoint.SliderJoint = 4;
  113498. //OIMO
  113499. /**
  113500. * Prismatic-Joint type
  113501. */
  113502. PhysicsJoint.PrismaticJoint = 5;
  113503. //
  113504. /**
  113505. * Universal-Joint type
  113506. * ENERGY FTW! (compare with this - @see http://ode-wiki.org/wiki/index.php?title=Manual:_Joint_Types_and_Functions)
  113507. */
  113508. PhysicsJoint.UniversalJoint = 6;
  113509. /**
  113510. * Hinge-Joint 2 type
  113511. */
  113512. PhysicsJoint.Hinge2Joint = PhysicsJoint.WheelJoint;
  113513. //Cannon
  113514. /**
  113515. * Point to Point Joint type. Similar to a Ball-Joint. Different in parameters
  113516. */
  113517. PhysicsJoint.PointToPointJoint = 8;
  113518. //Cannon only at the moment
  113519. /**
  113520. * Spring-Joint type
  113521. */
  113522. PhysicsJoint.SpringJoint = 9;
  113523. /**
  113524. * Lock-Joint type
  113525. */
  113526. PhysicsJoint.LockJoint = 10;
  113527. return PhysicsJoint;
  113528. }());
  113529. /**
  113530. * A class representing a physics distance joint
  113531. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113532. */
  113533. var DistanceJoint = /** @class */ (function (_super) {
  113534. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DistanceJoint, _super);
  113535. /**
  113536. *
  113537. * @param jointData The data for the Distance-Joint
  113538. */
  113539. function DistanceJoint(jointData) {
  113540. return _super.call(this, PhysicsJoint.DistanceJoint, jointData) || this;
  113541. }
  113542. /**
  113543. * Update the predefined distance.
  113544. * @param maxDistance The maximum preferred distance
  113545. * @param minDistance The minimum preferred distance
  113546. */
  113547. DistanceJoint.prototype.updateDistance = function (maxDistance, minDistance) {
  113548. this._physicsPlugin.updateDistanceJoint(this, maxDistance, minDistance);
  113549. };
  113550. return DistanceJoint;
  113551. }(PhysicsJoint));
  113552. /**
  113553. * Represents a Motor-Enabled Joint
  113554. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113555. */
  113556. var MotorEnabledJoint = /** @class */ (function (_super) {
  113557. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotorEnabledJoint, _super);
  113558. /**
  113559. * Initializes the Motor-Enabled Joint
  113560. * @param type The type of the joint
  113561. * @param jointData The physica joint data for the joint
  113562. */
  113563. function MotorEnabledJoint(type, jointData) {
  113564. return _super.call(this, type, jointData) || this;
  113565. }
  113566. /**
  113567. * Set the motor values.
  113568. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113569. * @param force the force to apply
  113570. * @param maxForce max force for this motor.
  113571. */
  113572. MotorEnabledJoint.prototype.setMotor = function (force, maxForce) {
  113573. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  113574. };
  113575. /**
  113576. * Set the motor's limits.
  113577. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113578. * @param upperLimit The upper limit of the motor
  113579. * @param lowerLimit The lower limit of the motor
  113580. */
  113581. MotorEnabledJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  113582. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  113583. };
  113584. return MotorEnabledJoint;
  113585. }(PhysicsJoint));
  113586. /**
  113587. * This class represents a single physics Hinge-Joint
  113588. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113589. */
  113590. var HingeJoint = /** @class */ (function (_super) {
  113591. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HingeJoint, _super);
  113592. /**
  113593. * Initializes the Hinge-Joint
  113594. * @param jointData The joint data for the Hinge-Joint
  113595. */
  113596. function HingeJoint(jointData) {
  113597. return _super.call(this, PhysicsJoint.HingeJoint, jointData) || this;
  113598. }
  113599. /**
  113600. * Set the motor values.
  113601. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113602. * @param {number} force the force to apply
  113603. * @param {number} maxForce max force for this motor.
  113604. */
  113605. HingeJoint.prototype.setMotor = function (force, maxForce) {
  113606. this._physicsPlugin.setMotor(this, force || 0, maxForce);
  113607. };
  113608. /**
  113609. * Set the motor's limits.
  113610. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113611. * @param upperLimit The upper limit of the motor
  113612. * @param lowerLimit The lower limit of the motor
  113613. */
  113614. HingeJoint.prototype.setLimit = function (upperLimit, lowerLimit) {
  113615. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit);
  113616. };
  113617. return HingeJoint;
  113618. }(MotorEnabledJoint));
  113619. /**
  113620. * This class represents a dual hinge physics joint (same as wheel joint)
  113621. * @see https://doc.babylonjs.com/how_to/using_the_physics_engine
  113622. */
  113623. var Hinge2Joint = /** @class */ (function (_super) {
  113624. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Hinge2Joint, _super);
  113625. /**
  113626. * Initializes the Hinge2-Joint
  113627. * @param jointData The joint data for the Hinge2-Joint
  113628. */
  113629. function Hinge2Joint(jointData) {
  113630. return _super.call(this, PhysicsJoint.Hinge2Joint, jointData) || this;
  113631. }
  113632. /**
  113633. * Set the motor values.
  113634. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113635. * @param {number} targetSpeed the speed the motor is to reach
  113636. * @param {number} maxForce max force for this motor.
  113637. * @param {motorIndex} the motor's index, 0 or 1.
  113638. */
  113639. Hinge2Joint.prototype.setMotor = function (targetSpeed, maxForce, motorIndex) {
  113640. if (motorIndex === void 0) { motorIndex = 0; }
  113641. this._physicsPlugin.setMotor(this, targetSpeed || 0, maxForce, motorIndex);
  113642. };
  113643. /**
  113644. * Set the motor limits.
  113645. * Attention, this function is plugin specific. Engines won't react 100% the same.
  113646. * @param {number} upperLimit the upper limit
  113647. * @param {number} lowerLimit lower limit
  113648. * @param {motorIndex} the motor's index, 0 or 1.
  113649. */
  113650. Hinge2Joint.prototype.setLimit = function (upperLimit, lowerLimit, motorIndex) {
  113651. if (motorIndex === void 0) { motorIndex = 0; }
  113652. this._physicsPlugin.setLimit(this, upperLimit, lowerLimit, motorIndex);
  113653. };
  113654. return Hinge2Joint;
  113655. }(MotorEnabledJoint));
  113656. /***/ }),
  113657. /***/ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts":
  113658. /*!****************************************************************************!*\
  113659. !*** ./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts ***!
  113660. \****************************************************************************/
  113661. /*! exports provided: DefaultRenderingPipeline */
  113662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  113663. "use strict";
  113664. __webpack_require__.r(__webpack_exports__);
  113665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return DefaultRenderingPipeline; });
  113666. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  113667. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  113668. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  113669. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  113670. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  113671. /* harmony import */ var _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Layers/glowLayer */ "./Layers/glowLayer.ts");
  113672. /* harmony import */ var _PostProcesses_sharpenPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  113673. /* harmony import */ var _PostProcesses_imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  113674. /* harmony import */ var _PostProcesses_chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  113675. /* harmony import */ var _PostProcesses_grainPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  113676. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  113677. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  113678. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  113679. /* harmony import */ var _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../PostProcesses/depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  113680. /* harmony import */ var _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../../PostProcesses/bloomEffect */ "./PostProcesses/bloomEffect.ts");
  113681. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  113682. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  113683. /**
  113684. * The default rendering pipeline can be added to a scene to apply common post processing effects such as anti-aliasing or depth of field.
  113685. * See https://doc.babylonjs.com/how_to/using_default_rendering_pipeline
  113686. */
  113687. var DefaultRenderingPipeline = /** @class */ (function (_super) {
  113688. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DefaultRenderingPipeline, _super);
  113689. /**
  113690. * @constructor
  113691. * @param name - The rendering pipeline name (default: "")
  113692. * @param hdr - If high dynamic range textures should be used (default: true)
  113693. * @param scene - The scene linked to this pipeline (default: the last created scene)
  113694. * @param cameras - The array of cameras that the rendering pipeline will be attached to (default: scene.cameras)
  113695. * @param automaticBuild - if false, you will have to manually call prepare() to update the pipeline (default: true)
  113696. */
  113697. function DefaultRenderingPipeline(name, hdr, scene, cameras, automaticBuild) {
  113698. if (name === void 0) { name = ""; }
  113699. if (hdr === void 0) { hdr = true; }
  113700. if (scene === void 0) { scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_16__["EngineStore"].LastCreatedScene; }
  113701. if (automaticBuild === void 0) { automaticBuild = true; }
  113702. var _this = _super.call(this, scene.getEngine(), name) || this;
  113703. _this._camerasToBeAttached = [];
  113704. /**
  113705. * ID of the sharpen post process,
  113706. */
  113707. _this.SharpenPostProcessId = "SharpenPostProcessEffect";
  113708. /**
  113709. * @ignore
  113710. * ID of the image processing post process;
  113711. */
  113712. _this.ImageProcessingPostProcessId = "ImageProcessingPostProcessEffect";
  113713. /**
  113714. * @ignore
  113715. * ID of the Fast Approximate Anti-Aliasing post process;
  113716. */
  113717. _this.FxaaPostProcessId = "FxaaPostProcessEffect";
  113718. /**
  113719. * ID of the chromatic aberration post process,
  113720. */
  113721. _this.ChromaticAberrationPostProcessId = "ChromaticAberrationPostProcessEffect";
  113722. /**
  113723. * ID of the grain post process
  113724. */
  113725. _this.GrainPostProcessId = "GrainPostProcessEffect";
  113726. /**
  113727. * Glow post process which adds a glow to emissive areas of the image
  113728. */
  113729. _this._glowLayer = null;
  113730. /**
  113731. * Animations which can be used to tweak settings over a period of time
  113732. */
  113733. _this.animations = [];
  113734. _this._imageProcessingConfigurationObserver = null;
  113735. // Values
  113736. _this._sharpenEnabled = false;
  113737. _this._bloomEnabled = false;
  113738. _this._depthOfFieldEnabled = false;
  113739. _this._depthOfFieldBlurLevel = _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffectBlurLevel"].Low;
  113740. _this._fxaaEnabled = false;
  113741. _this._imageProcessingEnabled = true;
  113742. _this._bloomScale = 0.5;
  113743. _this._chromaticAberrationEnabled = false;
  113744. _this._grainEnabled = false;
  113745. _this._buildAllowed = true;
  113746. _this._resizeObserver = null;
  113747. _this._hardwareScaleLevel = 1.0;
  113748. _this._bloomKernel = 64;
  113749. /**
  113750. * Specifies the weight of the bloom in the final rendering
  113751. */
  113752. _this._bloomWeight = 0.15;
  113753. /**
  113754. * Specifies the luma threshold for the area that will be blurred by the bloom
  113755. */
  113756. _this._bloomThreshold = 0.9;
  113757. _this._samples = 1;
  113758. _this._hasCleared = false;
  113759. _this._prevPostProcess = null;
  113760. _this._prevPrevPostProcess = null;
  113761. _this._depthOfFieldSceneObserver = null;
  113762. _this._cameras = cameras || scene.cameras;
  113763. _this._cameras = _this._cameras.slice();
  113764. _this._camerasToBeAttached = _this._cameras.slice();
  113765. _this._buildAllowed = automaticBuild;
  113766. // Initialize
  113767. _this._scene = scene;
  113768. var caps = _this._scene.getEngine().getCaps();
  113769. _this._hdr = hdr && (caps.textureHalfFloatRender || caps.textureFloatRender);
  113770. // Misc
  113771. if (_this._hdr) {
  113772. if (caps.textureHalfFloatRender) {
  113773. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_HALF_FLOAT;
  113774. }
  113775. else if (caps.textureFloatRender) {
  113776. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_FLOAT;
  113777. }
  113778. }
  113779. else {
  113780. _this._defaultPipelineTextureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT;
  113781. }
  113782. // Attach
  113783. scene.postProcessRenderPipelineManager.addPipeline(_this);
  113784. var engine = _this._scene.getEngine();
  113785. // Create post processes before hand so they can be modified before enabled.
  113786. // Block compilation flag is set to true to avoid compilation prior to use, these will be updated on first use in build pipeline.
  113787. _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);
  113788. _this._sharpenEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.SharpenPostProcessId, function () { return _this.sharpen; }, true);
  113789. _this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](_this._scene, null, _this._depthOfFieldBlurLevel, _this._defaultPipelineTextureType, true);
  113790. _this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](_this._scene, _this._bloomScale, _this._bloomWeight, _this.bloomKernel, _this._defaultPipelineTextureType, true);
  113791. _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);
  113792. _this._chromaticAberrationEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.ChromaticAberrationPostProcessId, function () { return _this.chromaticAberration; }, true);
  113793. _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);
  113794. _this._grainEffect = new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, _this.GrainPostProcessId, function () { return _this.grain; }, true);
  113795. _this._resizeObserver = engine.onResizeObservable.add(function () {
  113796. _this._hardwareScaleLevel = engine.getHardwareScalingLevel();
  113797. _this.bloomKernel = _this.bloomKernel;
  113798. });
  113799. _this._imageProcessingConfigurationObserver = _this._scene.imageProcessingConfiguration.onUpdateParameters.add(function () {
  113800. _this.bloom._downscale._exposure = _this._scene.imageProcessingConfiguration.exposure;
  113801. });
  113802. _this._buildPipeline();
  113803. return _this;
  113804. }
  113805. Object.defineProperty(DefaultRenderingPipeline.prototype, "scene", {
  113806. /**
  113807. * Gets active scene
  113808. */
  113809. get: function () {
  113810. return this._scene;
  113811. },
  113812. enumerable: true,
  113813. configurable: true
  113814. });
  113815. Object.defineProperty(DefaultRenderingPipeline.prototype, "sharpenEnabled", {
  113816. get: function () {
  113817. return this._sharpenEnabled;
  113818. },
  113819. /**
  113820. * Enable or disable the sharpen process from the pipeline
  113821. */
  113822. set: function (enabled) {
  113823. if (this._sharpenEnabled === enabled) {
  113824. return;
  113825. }
  113826. this._sharpenEnabled = enabled;
  113827. this._buildPipeline();
  113828. },
  113829. enumerable: true,
  113830. configurable: true
  113831. });
  113832. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomKernel", {
  113833. /**
  113834. * Specifies the size of the bloom blur kernel, relative to the final output size
  113835. */
  113836. get: function () {
  113837. return this._bloomKernel;
  113838. },
  113839. set: function (value) {
  113840. this._bloomKernel = value;
  113841. this.bloom.kernel = value / this._hardwareScaleLevel;
  113842. },
  113843. enumerable: true,
  113844. configurable: true
  113845. });
  113846. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomWeight", {
  113847. get: function () {
  113848. return this._bloomWeight;
  113849. },
  113850. /**
  113851. * The strength of the bloom.
  113852. */
  113853. set: function (value) {
  113854. if (this._bloomWeight === value) {
  113855. return;
  113856. }
  113857. this.bloom.weight = value;
  113858. this._bloomWeight = value;
  113859. },
  113860. enumerable: true,
  113861. configurable: true
  113862. });
  113863. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomThreshold", {
  113864. get: function () {
  113865. return this._bloomThreshold;
  113866. },
  113867. /**
  113868. * The strength of the bloom.
  113869. */
  113870. set: function (value) {
  113871. if (this._bloomThreshold === value) {
  113872. return;
  113873. }
  113874. this.bloom.threshold = value;
  113875. this._bloomThreshold = value;
  113876. },
  113877. enumerable: true,
  113878. configurable: true
  113879. });
  113880. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomScale", {
  113881. get: function () {
  113882. return this._bloomScale;
  113883. },
  113884. /**
  113885. * The scale of the bloom, lower value will provide better performance.
  113886. */
  113887. set: function (value) {
  113888. if (this._bloomScale === value) {
  113889. return;
  113890. }
  113891. this._bloomScale = value;
  113892. // recreate bloom and dispose old as this setting is not dynamic
  113893. this._rebuildBloom();
  113894. this._buildPipeline();
  113895. },
  113896. enumerable: true,
  113897. configurable: true
  113898. });
  113899. Object.defineProperty(DefaultRenderingPipeline.prototype, "bloomEnabled", {
  113900. get: function () {
  113901. return this._bloomEnabled;
  113902. },
  113903. /**
  113904. * Enable or disable the bloom from the pipeline
  113905. */
  113906. set: function (enabled) {
  113907. if (this._bloomEnabled === enabled) {
  113908. return;
  113909. }
  113910. this._bloomEnabled = enabled;
  113911. this._buildPipeline();
  113912. },
  113913. enumerable: true,
  113914. configurable: true
  113915. });
  113916. DefaultRenderingPipeline.prototype._rebuildBloom = function () {
  113917. // recreate bloom and dispose old as this setting is not dynamic
  113918. var oldBloom = this.bloom;
  113919. this.bloom = new _PostProcesses_bloomEffect__WEBPACK_IMPORTED_MODULE_14__["BloomEffect"](this._scene, this.bloomScale, this._bloomWeight, this.bloomKernel, this._defaultPipelineTextureType, false);
  113920. this.bloom.threshold = oldBloom.threshold;
  113921. for (var i = 0; i < this._cameras.length; i++) {
  113922. oldBloom.disposeEffects(this._cameras[i]);
  113923. }
  113924. };
  113925. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", {
  113926. /**
  113927. * If the depth of field is enabled.
  113928. */
  113929. get: function () {
  113930. return this._depthOfFieldEnabled;
  113931. },
  113932. set: function (enabled) {
  113933. if (this._depthOfFieldEnabled === enabled) {
  113934. return;
  113935. }
  113936. this._depthOfFieldEnabled = enabled;
  113937. this._buildPipeline();
  113938. },
  113939. enumerable: true,
  113940. configurable: true
  113941. });
  113942. Object.defineProperty(DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", {
  113943. /**
  113944. * Blur level of the depth of field effect. (Higher blur will effect performance)
  113945. */
  113946. get: function () {
  113947. return this._depthOfFieldBlurLevel;
  113948. },
  113949. set: function (value) {
  113950. if (this._depthOfFieldBlurLevel === value) {
  113951. return;
  113952. }
  113953. this._depthOfFieldBlurLevel = value;
  113954. // recreate dof and dispose old as this setting is not dynamic
  113955. var oldDof = this.depthOfField;
  113956. this.depthOfField = new _PostProcesses_depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_13__["DepthOfFieldEffect"](this._scene, null, this._depthOfFieldBlurLevel, this._defaultPipelineTextureType, false);
  113957. this.depthOfField.focalLength = oldDof.focalLength;
  113958. this.depthOfField.focusDistance = oldDof.focusDistance;
  113959. this.depthOfField.fStop = oldDof.fStop;
  113960. this.depthOfField.lensSize = oldDof.lensSize;
  113961. for (var i = 0; i < this._cameras.length; i++) {
  113962. oldDof.disposeEffects(this._cameras[i]);
  113963. }
  113964. this._buildPipeline();
  113965. },
  113966. enumerable: true,
  113967. configurable: true
  113968. });
  113969. Object.defineProperty(DefaultRenderingPipeline.prototype, "fxaaEnabled", {
  113970. get: function () {
  113971. return this._fxaaEnabled;
  113972. },
  113973. /**
  113974. * If the anti aliasing is enabled.
  113975. */
  113976. set: function (enabled) {
  113977. if (this._fxaaEnabled === enabled) {
  113978. return;
  113979. }
  113980. this._fxaaEnabled = enabled;
  113981. this._buildPipeline();
  113982. },
  113983. enumerable: true,
  113984. configurable: true
  113985. });
  113986. Object.defineProperty(DefaultRenderingPipeline.prototype, "samples", {
  113987. get: function () {
  113988. return this._samples;
  113989. },
  113990. /**
  113991. * MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  113992. */
  113993. set: function (sampleCount) {
  113994. if (this._samples === sampleCount) {
  113995. return;
  113996. }
  113997. this._samples = sampleCount;
  113998. this._buildPipeline();
  113999. },
  114000. enumerable: true,
  114001. configurable: true
  114002. });
  114003. Object.defineProperty(DefaultRenderingPipeline.prototype, "imageProcessingEnabled", {
  114004. get: function () {
  114005. return this._imageProcessingEnabled;
  114006. },
  114007. /**
  114008. * If image processing is enabled.
  114009. */
  114010. set: function (enabled) {
  114011. if (this._imageProcessingEnabled === enabled) {
  114012. return;
  114013. }
  114014. this._imageProcessingEnabled = enabled;
  114015. this._buildPipeline();
  114016. },
  114017. enumerable: true,
  114018. configurable: true
  114019. });
  114020. Object.defineProperty(DefaultRenderingPipeline.prototype, "glowLayerEnabled", {
  114021. get: function () {
  114022. return this._glowLayer != null;
  114023. },
  114024. /**
  114025. * If glow layer is enabled. (Adds a glow effect to emmissive materials)
  114026. */
  114027. set: function (enabled) {
  114028. if (enabled && !this._glowLayer) {
  114029. this._glowLayer = new _Layers_glowLayer__WEBPACK_IMPORTED_MODULE_5__["GlowLayer"]("", this._scene);
  114030. }
  114031. else if (!enabled && this._glowLayer) {
  114032. this._glowLayer.dispose();
  114033. this._glowLayer = null;
  114034. }
  114035. },
  114036. enumerable: true,
  114037. configurable: true
  114038. });
  114039. Object.defineProperty(DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", {
  114040. get: function () {
  114041. return this._chromaticAberrationEnabled;
  114042. },
  114043. /**
  114044. * Enable or disable the chromaticAberration process from the pipeline
  114045. */
  114046. set: function (enabled) {
  114047. if (this._chromaticAberrationEnabled === enabled) {
  114048. return;
  114049. }
  114050. this._chromaticAberrationEnabled = enabled;
  114051. this._buildPipeline();
  114052. },
  114053. enumerable: true,
  114054. configurable: true
  114055. });
  114056. Object.defineProperty(DefaultRenderingPipeline.prototype, "grainEnabled", {
  114057. get: function () {
  114058. return this._grainEnabled;
  114059. },
  114060. /**
  114061. * Enable or disable the grain process from the pipeline
  114062. */
  114063. set: function (enabled) {
  114064. if (this._grainEnabled === enabled) {
  114065. return;
  114066. }
  114067. this._grainEnabled = enabled;
  114068. this._buildPipeline();
  114069. },
  114070. enumerable: true,
  114071. configurable: true
  114072. });
  114073. /**
  114074. * Get the class name
  114075. * @returns "DefaultRenderingPipeline"
  114076. */
  114077. DefaultRenderingPipeline.prototype.getClassName = function () {
  114078. return "DefaultRenderingPipeline";
  114079. };
  114080. /**
  114081. * Force the compilation of the entire pipeline.
  114082. */
  114083. DefaultRenderingPipeline.prototype.prepare = function () {
  114084. var previousState = this._buildAllowed;
  114085. this._buildAllowed = true;
  114086. this._buildPipeline();
  114087. this._buildAllowed = previousState;
  114088. };
  114089. DefaultRenderingPipeline.prototype._setAutoClearAndTextureSharing = function (postProcess, skipTextureSharing) {
  114090. if (skipTextureSharing === void 0) { skipTextureSharing = false; }
  114091. if (this._hasCleared) {
  114092. postProcess.autoClear = false;
  114093. }
  114094. else {
  114095. postProcess.autoClear = true;
  114096. this._scene.autoClear = false;
  114097. this._hasCleared = true;
  114098. }
  114099. if (!skipTextureSharing) {
  114100. if (this._prevPrevPostProcess) {
  114101. postProcess.shareOutputWith(this._prevPrevPostProcess);
  114102. }
  114103. else {
  114104. postProcess.useOwnOutput();
  114105. }
  114106. if (this._prevPostProcess) {
  114107. this._prevPrevPostProcess = this._prevPostProcess;
  114108. }
  114109. this._prevPostProcess = postProcess;
  114110. }
  114111. };
  114112. DefaultRenderingPipeline.prototype._buildPipeline = function () {
  114113. var _this = this;
  114114. if (!this._buildAllowed) {
  114115. return;
  114116. }
  114117. this._scene.autoClear = true;
  114118. var engine = this._scene.getEngine();
  114119. this._disposePostProcesses();
  114120. if (this._cameras !== null) {
  114121. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  114122. // get back cameras to be used to reattach pipeline
  114123. this._cameras = this._camerasToBeAttached.slice();
  114124. }
  114125. this._reset();
  114126. this._prevPostProcess = null;
  114127. this._prevPrevPostProcess = null;
  114128. this._hasCleared = false;
  114129. if (this.depthOfFieldEnabled) {
  114130. // Multi camera suport
  114131. if (this._cameras.length > 1) {
  114132. for (var _i = 0, _a = this._cameras; _i < _a.length; _i++) {
  114133. var camera = _a[_i];
  114134. var depthRenderer = this._scene.enableDepthRenderer(camera);
  114135. depthRenderer.useOnlyInActiveCamera = true;
  114136. }
  114137. this._depthOfFieldSceneObserver = this._scene.onAfterRenderTargetsRenderObservable.add(function (scene) {
  114138. if (_this._cameras.indexOf(scene.activeCamera) > -1) {
  114139. _this.depthOfField.depthTexture = scene.enableDepthRenderer(scene.activeCamera).getDepthMap();
  114140. }
  114141. });
  114142. }
  114143. else {
  114144. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  114145. var depthRenderer = this._scene.enableDepthRenderer(this._cameras[0]);
  114146. this.depthOfField.depthTexture = depthRenderer.getDepthMap();
  114147. }
  114148. if (!this.depthOfField._isReady()) {
  114149. this.depthOfField._updateEffects();
  114150. }
  114151. this.addEffect(this.depthOfField);
  114152. this._setAutoClearAndTextureSharing(this.depthOfField._effects[0], true);
  114153. }
  114154. else {
  114155. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  114156. }
  114157. if (this.bloomEnabled) {
  114158. if (!this.bloom._isReady()) {
  114159. this.bloom._updateEffects();
  114160. }
  114161. this.addEffect(this.bloom);
  114162. this._setAutoClearAndTextureSharing(this.bloom._effects[0], true);
  114163. }
  114164. if (this._imageProcessingEnabled) {
  114165. 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);
  114166. if (this._hdr) {
  114167. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.ImageProcessingPostProcessId, function () { return _this.imageProcessing; }, true));
  114168. this._setAutoClearAndTextureSharing(this.imageProcessing);
  114169. }
  114170. else {
  114171. this._scene.imageProcessingConfiguration.applyByPostProcess = false;
  114172. }
  114173. }
  114174. if (this.sharpenEnabled) {
  114175. if (!this.sharpen.isReady()) {
  114176. this.sharpen.updateEffect();
  114177. }
  114178. this.addEffect(this._sharpenEffect);
  114179. this._setAutoClearAndTextureSharing(this.sharpen);
  114180. }
  114181. if (this.grainEnabled) {
  114182. if (!this.grain.isReady()) {
  114183. this.grain.updateEffect();
  114184. }
  114185. this.addEffect(this._grainEffect);
  114186. this._setAutoClearAndTextureSharing(this.grain);
  114187. }
  114188. if (this.chromaticAberrationEnabled) {
  114189. if (!this.chromaticAberration.isReady()) {
  114190. this.chromaticAberration.updateEffect();
  114191. }
  114192. this.addEffect(this._chromaticAberrationEffect);
  114193. this._setAutoClearAndTextureSharing(this.chromaticAberration);
  114194. }
  114195. if (this.fxaaEnabled) {
  114196. 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);
  114197. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_12__["PostProcessRenderEffect"](engine, this.FxaaPostProcessId, function () { return _this.fxaa; }, true));
  114198. this._setAutoClearAndTextureSharing(this.fxaa, true);
  114199. }
  114200. if (this._cameras !== null) {
  114201. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  114202. }
  114203. if (!this._enableMSAAOnFirstPostProcess(this.samples) && this.samples > 1) {
  114204. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  114205. }
  114206. };
  114207. DefaultRenderingPipeline.prototype._disposePostProcesses = function (disposeNonRecreated) {
  114208. if (disposeNonRecreated === void 0) { disposeNonRecreated = false; }
  114209. for (var i = 0; i < this._cameras.length; i++) {
  114210. var camera = this._cameras[i];
  114211. if (this.imageProcessing) {
  114212. this.imageProcessing.dispose(camera);
  114213. }
  114214. if (this.fxaa) {
  114215. this.fxaa.dispose(camera);
  114216. }
  114217. // These are created in the constructor and should not be disposed on every pipeline change
  114218. if (disposeNonRecreated) {
  114219. if (this.sharpen) {
  114220. this.sharpen.dispose(camera);
  114221. }
  114222. if (this.depthOfField) {
  114223. this._scene.onAfterRenderTargetsRenderObservable.remove(this._depthOfFieldSceneObserver);
  114224. this.depthOfField.disposeEffects(camera);
  114225. }
  114226. if (this.bloom) {
  114227. this.bloom.disposeEffects(camera);
  114228. }
  114229. if (this.chromaticAberration) {
  114230. this.chromaticAberration.dispose(camera);
  114231. }
  114232. if (this.grain) {
  114233. this.grain.dispose(camera);
  114234. }
  114235. if (this._glowLayer) {
  114236. this._glowLayer.dispose();
  114237. }
  114238. }
  114239. }
  114240. this.imageProcessing = null;
  114241. this.fxaa = null;
  114242. if (disposeNonRecreated) {
  114243. this.sharpen = null;
  114244. this._sharpenEffect = null;
  114245. this.depthOfField = null;
  114246. this.bloom = null;
  114247. this.chromaticAberration = null;
  114248. this._chromaticAberrationEffect = null;
  114249. this.grain = null;
  114250. this._grainEffect = null;
  114251. this._glowLayer = null;
  114252. }
  114253. };
  114254. /**
  114255. * Adds a camera to the pipeline
  114256. * @param camera the camera to be added
  114257. */
  114258. DefaultRenderingPipeline.prototype.addCamera = function (camera) {
  114259. this._camerasToBeAttached.push(camera);
  114260. this._buildPipeline();
  114261. };
  114262. /**
  114263. * Removes a camera from the pipeline
  114264. * @param camera the camera to remove
  114265. */
  114266. DefaultRenderingPipeline.prototype.removeCamera = function (camera) {
  114267. var index = this._camerasToBeAttached.indexOf(camera);
  114268. this._camerasToBeAttached.splice(index, 1);
  114269. this._buildPipeline();
  114270. };
  114271. /**
  114272. * Dispose of the pipeline and stop all post processes
  114273. */
  114274. DefaultRenderingPipeline.prototype.dispose = function () {
  114275. this._disposePostProcesses(true);
  114276. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  114277. this._scene.autoClear = true;
  114278. if (this._resizeObserver) {
  114279. this._scene.getEngine().onResizeObservable.remove(this._resizeObserver);
  114280. this._resizeObserver = null;
  114281. }
  114282. this._scene.imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingConfigurationObserver);
  114283. _super.prototype.dispose.call(this);
  114284. };
  114285. /**
  114286. * Serialize the rendering pipeline (Used when exporting)
  114287. * @returns the serialized object
  114288. */
  114289. DefaultRenderingPipeline.prototype.serialize = function () {
  114290. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  114291. serializationObject.customType = "DefaultRenderingPipeline";
  114292. return serializationObject;
  114293. };
  114294. /**
  114295. * Parse the serialized pipeline
  114296. * @param source Source pipeline.
  114297. * @param scene The scene to load the pipeline to.
  114298. * @param rootUrl The URL of the serialized pipeline.
  114299. * @returns An instantiated pipeline from the serialized object.
  114300. */
  114301. DefaultRenderingPipeline.Parse = function (source, scene, rootUrl) {
  114302. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new DefaultRenderingPipeline(source._name, source._name._hdr, scene); }, source, scene, rootUrl);
  114303. };
  114304. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114305. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114306. ], DefaultRenderingPipeline.prototype, "sharpenEnabled", null);
  114307. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114308. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114309. ], DefaultRenderingPipeline.prototype, "bloomKernel", null);
  114310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114312. ], DefaultRenderingPipeline.prototype, "_bloomWeight", void 0);
  114313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114315. ], DefaultRenderingPipeline.prototype, "_bloomThreshold", void 0);
  114316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114318. ], DefaultRenderingPipeline.prototype, "_hdr", void 0);
  114319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114321. ], DefaultRenderingPipeline.prototype, "bloomWeight", null);
  114322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114324. ], DefaultRenderingPipeline.prototype, "bloomThreshold", null);
  114325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114327. ], DefaultRenderingPipeline.prototype, "bloomScale", null);
  114328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114330. ], DefaultRenderingPipeline.prototype, "bloomEnabled", null);
  114331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114333. ], DefaultRenderingPipeline.prototype, "depthOfFieldEnabled", null);
  114334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114336. ], DefaultRenderingPipeline.prototype, "depthOfFieldBlurLevel", null);
  114337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114339. ], DefaultRenderingPipeline.prototype, "fxaaEnabled", null);
  114340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114342. ], DefaultRenderingPipeline.prototype, "samples", null);
  114343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114345. ], DefaultRenderingPipeline.prototype, "imageProcessingEnabled", null);
  114346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114348. ], DefaultRenderingPipeline.prototype, "glowLayerEnabled", null);
  114349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114351. ], DefaultRenderingPipeline.prototype, "chromaticAberrationEnabled", null);
  114352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  114353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  114354. ], DefaultRenderingPipeline.prototype, "grainEnabled", null);
  114355. return DefaultRenderingPipeline;
  114356. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_11__["PostProcessRenderPipeline"]));
  114357. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_15__["_TypeStore"].RegisteredTypes["BABYLON.DefaultRenderingPipeline"] = DefaultRenderingPipeline;
  114358. /***/ }),
  114359. /***/ "./PostProcesses/RenderPipeline/Pipelines/index.ts":
  114360. /*!*********************************************************!*\
  114361. !*** ./PostProcesses/RenderPipeline/Pipelines/index.ts ***!
  114362. \*********************************************************/
  114363. /*! exports provided: DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  114364. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114365. "use strict";
  114366. __webpack_require__.r(__webpack_exports__);
  114367. /* harmony import */ var _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./defaultRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/defaultRenderingPipeline.ts");
  114368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _defaultRenderingPipeline__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  114369. /* harmony import */ var _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./lensRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts");
  114370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _lensRenderingPipeline__WEBPACK_IMPORTED_MODULE_1__["LensRenderingPipeline"]; });
  114371. /* harmony import */ var _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ssao2RenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts");
  114372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _ssao2RenderingPipeline__WEBPACK_IMPORTED_MODULE_2__["SSAO2RenderingPipeline"]; });
  114373. /* harmony import */ var _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ssaoRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts");
  114374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _ssaoRenderingPipeline__WEBPACK_IMPORTED_MODULE_3__["SSAORenderingPipeline"]; });
  114375. /* harmony import */ var _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./standardRenderingPipeline */ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts");
  114376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _standardRenderingPipeline__WEBPACK_IMPORTED_MODULE_4__["StandardRenderingPipeline"]; });
  114377. /***/ }),
  114378. /***/ "./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts":
  114379. /*!*************************************************************************!*\
  114380. !*** ./PostProcesses/RenderPipeline/Pipelines/lensRenderingPipeline.ts ***!
  114381. \*************************************************************************/
  114382. /*! exports provided: LensRenderingPipeline */
  114383. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114384. "use strict";
  114385. __webpack_require__.r(__webpack_exports__);
  114386. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return LensRenderingPipeline; });
  114387. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114388. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114389. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114390. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114391. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114392. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114393. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  114394. /* harmony import */ var _Shaders_lensHighlights_fragment__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../Shaders/lensHighlights.fragment */ "./Shaders/lensHighlights.fragment.ts");
  114395. /* harmony import */ var _Shaders_depthOfField_fragment__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../Shaders/depthOfField.fragment */ "./Shaders/depthOfField.fragment.ts");
  114396. /**
  114397. * BABYLON.JS Chromatic Aberration GLSL Shader
  114398. * Author: Olivier Guyot
  114399. * Separates very slightly R, G and B colors on the edges of the screen
  114400. * Inspired by Francois Tarlier & Martins Upitis
  114401. */
  114402. var LensRenderingPipeline = /** @class */ (function (_super) {
  114403. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LensRenderingPipeline, _super);
  114404. /**
  114405. * @constructor
  114406. *
  114407. * Effect parameters are as follow:
  114408. * {
  114409. * chromatic_aberration: number; // from 0 to x (1 for realism)
  114410. * edge_blur: number; // from 0 to x (1 for realism)
  114411. * distortion: number; // from 0 to x (1 for realism)
  114412. * grain_amount: number; // from 0 to 1
  114413. * grain_texture: BABYLON.Texture; // texture to use for grain effect; if unset, use random B&W noise
  114414. * dof_focus_distance: number; // depth-of-field: focus distance; unset to disable (disabled by default)
  114415. * dof_aperture: number; // depth-of-field: focus blur bias (default: 1)
  114416. * dof_darken: number; // depth-of-field: darken that which is out of focus (from 0 to 1, disabled by default)
  114417. * dof_pentagon: boolean; // depth-of-field: makes a pentagon-like "bokeh" effect
  114418. * dof_gain: number; // depth-of-field: highlights gain; unset to disable (disabled by default)
  114419. * dof_threshold: number; // depth-of-field: highlights threshold (default: 1)
  114420. * blur_noise: boolean; // add a little bit of noise to the blur (default: true)
  114421. * }
  114422. * Note: if an effect parameter is unset, effect is disabled
  114423. *
  114424. * @param name The rendering pipeline name
  114425. * @param parameters - An object containing all parameters (see above)
  114426. * @param scene The scene linked to this pipeline
  114427. * @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)
  114428. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114429. */
  114430. function LensRenderingPipeline(name, parameters, scene, ratio, cameras) {
  114431. if (ratio === void 0) { ratio = 1.0; }
  114432. var _this = _super.call(this, scene.getEngine(), name) || this;
  114433. // Lens effects can be of the following:
  114434. // - chromatic aberration (slight shift of RGB colors)
  114435. // - blur on the edge of the lens
  114436. // - lens distortion
  114437. // - depth-of-field blur & highlights enhancing
  114438. // - depth-of-field 'bokeh' effect (shapes appearing in blurred areas)
  114439. // - grain effect (noise or custom texture)
  114440. // Two additional texture samplers are needed:
  114441. // - depth map (for depth-of-field)
  114442. // - grain texture
  114443. /**
  114444. * @ignore
  114445. * The chromatic aberration PostProcess id in the pipeline
  114446. */
  114447. _this.LensChromaticAberrationEffect = "LensChromaticAberrationEffect";
  114448. /**
  114449. * @ignore
  114450. * The highlights enhancing PostProcess id in the pipeline
  114451. */
  114452. _this.HighlightsEnhancingEffect = "HighlightsEnhancingEffect";
  114453. /**
  114454. * @ignore
  114455. * The depth-of-field PostProcess id in the pipeline
  114456. */
  114457. _this.LensDepthOfFieldEffect = "LensDepthOfFieldEffect";
  114458. _this._scene = scene;
  114459. // Fetch texture samplers
  114460. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  114461. if (parameters.grain_texture) {
  114462. _this._grainTexture = parameters.grain_texture;
  114463. }
  114464. else {
  114465. _this._createGrainTexture();
  114466. }
  114467. // save parameters
  114468. _this._edgeBlur = parameters.edge_blur ? parameters.edge_blur : 0;
  114469. _this._grainAmount = parameters.grain_amount ? parameters.grain_amount : 0;
  114470. _this._chromaticAberration = parameters.chromatic_aberration ? parameters.chromatic_aberration : 0;
  114471. _this._distortion = parameters.distortion ? parameters.distortion : 0;
  114472. _this._highlightsGain = parameters.dof_gain !== undefined ? parameters.dof_gain : -1;
  114473. _this._highlightsThreshold = parameters.dof_threshold ? parameters.dof_threshold : 1;
  114474. _this._dofDistance = parameters.dof_focus_distance !== undefined ? parameters.dof_focus_distance : -1;
  114475. _this._dofAperture = parameters.dof_aperture ? parameters.dof_aperture : 1;
  114476. _this._dofDarken = parameters.dof_darken ? parameters.dof_darken : 0;
  114477. _this._dofPentagon = parameters.dof_pentagon !== undefined ? parameters.dof_pentagon : true;
  114478. _this._blurNoise = parameters.blur_noise !== undefined ? parameters.blur_noise : true;
  114479. // Create effects
  114480. _this._createChromaticAberrationPostProcess(ratio);
  114481. _this._createHighlightsPostProcess(ratio);
  114482. _this._createDepthOfFieldPostProcess(ratio / 4);
  114483. // Set up pipeline
  114484. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensChromaticAberrationEffect, function () { return _this._chromaticAberrationPostProcess; }, true));
  114485. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.HighlightsEnhancingEffect, function () { return _this._highlightsPostProcess; }, true));
  114486. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderEffect"](scene.getEngine(), _this.LensDepthOfFieldEffect, function () { return _this._depthOfFieldPostProcess; }, true));
  114487. if (_this._highlightsGain === -1) {
  114488. _this._disableEffect(_this.HighlightsEnhancingEffect, null);
  114489. }
  114490. // Finish
  114491. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114492. if (cameras) {
  114493. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114494. }
  114495. return _this;
  114496. }
  114497. // public methods (self explanatory)
  114498. /**
  114499. * Sets the amount of blur at the edges
  114500. * @param amount blur amount
  114501. */
  114502. LensRenderingPipeline.prototype.setEdgeBlur = function (amount) { this._edgeBlur = amount; };
  114503. /**
  114504. * Sets edge blur to 0
  114505. */
  114506. LensRenderingPipeline.prototype.disableEdgeBlur = function () { this._edgeBlur = 0; };
  114507. /**
  114508. * Sets the amout of grain
  114509. * @param amount Amount of grain
  114510. */
  114511. LensRenderingPipeline.prototype.setGrainAmount = function (amount) { this._grainAmount = amount; };
  114512. /**
  114513. * Set grain amount to 0
  114514. */
  114515. LensRenderingPipeline.prototype.disableGrain = function () { this._grainAmount = 0; };
  114516. /**
  114517. * Sets the chromatic aberration amount
  114518. * @param amount amount of chromatic aberration
  114519. */
  114520. LensRenderingPipeline.prototype.setChromaticAberration = function (amount) { this._chromaticAberration = amount; };
  114521. /**
  114522. * Sets chromatic aberration amount to 0
  114523. */
  114524. LensRenderingPipeline.prototype.disableChromaticAberration = function () { this._chromaticAberration = 0; };
  114525. /**
  114526. * Sets the EdgeDistortion amount
  114527. * @param amount amount of EdgeDistortion
  114528. */
  114529. LensRenderingPipeline.prototype.setEdgeDistortion = function (amount) { this._distortion = amount; };
  114530. /**
  114531. * Sets edge distortion to 0
  114532. */
  114533. LensRenderingPipeline.prototype.disableEdgeDistortion = function () { this._distortion = 0; };
  114534. /**
  114535. * Sets the FocusDistance amount
  114536. * @param amount amount of FocusDistance
  114537. */
  114538. LensRenderingPipeline.prototype.setFocusDistance = function (amount) { this._dofDistance = amount; };
  114539. /**
  114540. * Disables depth of field
  114541. */
  114542. LensRenderingPipeline.prototype.disableDepthOfField = function () { this._dofDistance = -1; };
  114543. /**
  114544. * Sets the Aperture amount
  114545. * @param amount amount of Aperture
  114546. */
  114547. LensRenderingPipeline.prototype.setAperture = function (amount) { this._dofAperture = amount; };
  114548. /**
  114549. * Sets the DarkenOutOfFocus amount
  114550. * @param amount amount of DarkenOutOfFocus
  114551. */
  114552. LensRenderingPipeline.prototype.setDarkenOutOfFocus = function (amount) { this._dofDarken = amount; };
  114553. /**
  114554. * Creates a pentagon bokeh effect
  114555. */
  114556. LensRenderingPipeline.prototype.enablePentagonBokeh = function () {
  114557. this._highlightsPostProcess.updateEffect("#define PENTAGON\n");
  114558. };
  114559. /**
  114560. * Disables the pentagon bokeh effect
  114561. */
  114562. LensRenderingPipeline.prototype.disablePentagonBokeh = function () {
  114563. this._highlightsPostProcess.updateEffect();
  114564. };
  114565. /**
  114566. * Enables noise blur
  114567. */
  114568. LensRenderingPipeline.prototype.enableNoiseBlur = function () { this._blurNoise = true; };
  114569. /**
  114570. * Disables noise blur
  114571. */
  114572. LensRenderingPipeline.prototype.disableNoiseBlur = function () { this._blurNoise = false; };
  114573. /**
  114574. * Sets the HighlightsGain amount
  114575. * @param amount amount of HighlightsGain
  114576. */
  114577. LensRenderingPipeline.prototype.setHighlightsGain = function (amount) {
  114578. this._highlightsGain = amount;
  114579. };
  114580. /**
  114581. * Sets the HighlightsThreshold amount
  114582. * @param amount amount of HighlightsThreshold
  114583. */
  114584. LensRenderingPipeline.prototype.setHighlightsThreshold = function (amount) {
  114585. if (this._highlightsGain === -1) {
  114586. this._highlightsGain = 1.0;
  114587. }
  114588. this._highlightsThreshold = amount;
  114589. };
  114590. /**
  114591. * Disables highlights
  114592. */
  114593. LensRenderingPipeline.prototype.disableHighlights = function () {
  114594. this._highlightsGain = -1;
  114595. };
  114596. /**
  114597. * Removes the internal pipeline assets and detaches the pipeline from the scene cameras
  114598. * @param disableDepthRender If the scens depth rendering should be disabled (default: false)
  114599. */
  114600. LensRenderingPipeline.prototype.dispose = function (disableDepthRender) {
  114601. if (disableDepthRender === void 0) { disableDepthRender = false; }
  114602. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114603. this._chromaticAberrationPostProcess = null;
  114604. this._highlightsPostProcess = null;
  114605. this._depthOfFieldPostProcess = null;
  114606. this._grainTexture.dispose();
  114607. if (disableDepthRender) {
  114608. this._scene.disableDepthRenderer();
  114609. }
  114610. };
  114611. // colors shifting and distortion
  114612. LensRenderingPipeline.prototype._createChromaticAberrationPostProcess = function (ratio) {
  114613. var _this = this;
  114614. this._chromaticAberrationPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensChromaticAberration", "chromaticAberration", ["chromatic_aberration", "screen_width", "screen_height", "direction", "radialIntensity", "centerPosition"], // uniforms
  114615. [], // samplers
  114616. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  114617. this._chromaticAberrationPostProcess.onApply = function (effect) {
  114618. effect.setFloat('chromatic_aberration', _this._chromaticAberration);
  114619. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  114620. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  114621. effect.setFloat('radialIntensity', 1);
  114622. effect.setFloat2('direction', 17, 17);
  114623. effect.setFloat2('centerPosition', 0.5, 0.5);
  114624. };
  114625. };
  114626. // highlights enhancing
  114627. LensRenderingPipeline.prototype._createHighlightsPostProcess = function (ratio) {
  114628. var _this = this;
  114629. this._highlightsPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensHighlights", "lensHighlights", ["gain", "threshold", "screen_width", "screen_height"], // uniforms
  114630. [], // samplers
  114631. ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, this._dofPentagon ? "#define PENTAGON\n" : "");
  114632. this._highlightsPostProcess.onApply = function (effect) {
  114633. effect.setFloat('gain', _this._highlightsGain);
  114634. effect.setFloat('threshold', _this._highlightsThreshold);
  114635. effect.setTextureFromPostProcess("textureSampler", _this._chromaticAberrationPostProcess);
  114636. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  114637. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  114638. };
  114639. };
  114640. // colors shifting and distortion
  114641. LensRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (ratio) {
  114642. var _this = this;
  114643. this._depthOfFieldPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]("LensDepthOfField", "depthOfField", [
  114644. "grain_amount", "blur_noise", "screen_width", "screen_height", "distortion", "dof_enabled",
  114645. "screen_distance", "aperture", "darken", "edge_blur", "highlights", "near", "far"
  114646. ], ["depthSampler", "grainSampler", "highlightsSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].TRILINEAR_SAMPLINGMODE, this._scene.getEngine(), false);
  114647. this._depthOfFieldPostProcess.onApply = function (effect) {
  114648. effect.setTexture("depthSampler", _this._depthTexture);
  114649. effect.setTexture("grainSampler", _this._grainTexture);
  114650. effect.setTextureFromPostProcess("textureSampler", _this._highlightsPostProcess);
  114651. effect.setTextureFromPostProcess("highlightsSampler", _this._depthOfFieldPostProcess);
  114652. effect.setFloat('grain_amount', _this._grainAmount);
  114653. effect.setBool('blur_noise', _this._blurNoise);
  114654. effect.setFloat('screen_width', _this._scene.getEngine().getRenderWidth());
  114655. effect.setFloat('screen_height', _this._scene.getEngine().getRenderHeight());
  114656. effect.setFloat('distortion', _this._distortion);
  114657. effect.setBool('dof_enabled', (_this._dofDistance !== -1));
  114658. effect.setFloat('screen_distance', 1.0 / (0.1 - 1.0 / _this._dofDistance));
  114659. effect.setFloat('aperture', _this._dofAperture);
  114660. effect.setFloat('darken', _this._dofDarken);
  114661. effect.setFloat('edge_blur', _this._edgeBlur);
  114662. effect.setBool('highlights', (_this._highlightsGain !== -1));
  114663. if (_this._scene.activeCamera) {
  114664. effect.setFloat('near', _this._scene.activeCamera.minZ);
  114665. effect.setFloat('far', _this._scene.activeCamera.maxZ);
  114666. }
  114667. };
  114668. };
  114669. // creates a black and white random noise texture, 512x512
  114670. LensRenderingPipeline.prototype._createGrainTexture = function () {
  114671. var size = 512;
  114672. 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);
  114673. this._grainTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114674. this._grainTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].WRAP_ADDRESSMODE;
  114675. var context = this._grainTexture.getContext();
  114676. var rand = function (min, max) {
  114677. return Math.random() * (max - min) + min;
  114678. };
  114679. var value;
  114680. for (var x = 0; x < size; x++) {
  114681. for (var y = 0; y < size; y++) {
  114682. value = Math.floor(rand(0.42, 0.58) * 255);
  114683. context.fillStyle = 'rgb(' + value + ', ' + value + ', ' + value + ')';
  114684. context.fillRect(x, y, 1, 1);
  114685. }
  114686. }
  114687. this._grainTexture.update(false);
  114688. };
  114689. return LensRenderingPipeline;
  114690. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipeline"]));
  114691. /***/ }),
  114692. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts":
  114693. /*!**************************************************************************!*\
  114694. !*** ./PostProcesses/RenderPipeline/Pipelines/ssao2RenderingPipeline.ts ***!
  114695. \**************************************************************************/
  114696. /*! exports provided: SSAO2RenderingPipeline */
  114697. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  114698. "use strict";
  114699. __webpack_require__.r(__webpack_exports__);
  114700. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return SSAO2RenderingPipeline; });
  114701. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  114702. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  114703. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  114704. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  114705. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  114706. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  114707. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  114708. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  114709. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  114710. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  114711. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  114712. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/engineStore */ "./Engines/engineStore.ts");
  114713. /* harmony import */ var _Shaders_ssao2_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssao2.fragment */ "./Shaders/ssao2.fragment.ts");
  114714. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  114715. /**
  114716. * Render pipeline to produce ssao effect
  114717. */
  114718. var SSAO2RenderingPipeline = /** @class */ (function (_super) {
  114719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAO2RenderingPipeline, _super);
  114720. /**
  114721. * @constructor
  114722. * @param name The rendering pipeline name
  114723. * @param scene The scene linked to this pipeline
  114724. * @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 }
  114725. * @param cameras The array of cameras that the rendering pipeline will be attached to
  114726. */
  114727. function SSAO2RenderingPipeline(name, scene, ratio, cameras) {
  114728. var _this = _super.call(this, scene.getEngine(), name) || this;
  114729. // Members
  114730. /**
  114731. * @ignore
  114732. * The PassPostProcess id in the pipeline that contains the original scene color
  114733. */
  114734. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  114735. /**
  114736. * @ignore
  114737. * The SSAO PostProcess id in the pipeline
  114738. */
  114739. _this.SSAORenderEffect = "SSAORenderEffect";
  114740. /**
  114741. * @ignore
  114742. * The horizontal blur PostProcess id in the pipeline
  114743. */
  114744. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  114745. /**
  114746. * @ignore
  114747. * The vertical blur PostProcess id in the pipeline
  114748. */
  114749. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  114750. /**
  114751. * @ignore
  114752. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  114753. */
  114754. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  114755. /**
  114756. * The output strength of the SSAO post-process. Default value is 1.0.
  114757. */
  114758. _this.totalStrength = 1.0;
  114759. /**
  114760. * Maximum depth value to still render AO. A smooth falloff makes the dimming more natural, so there will be no abrupt shading change.
  114761. */
  114762. _this.maxZ = 100.0;
  114763. /**
  114764. * In order to save performances, SSAO radius is clamped on close geometry. This ratio changes by how much
  114765. */
  114766. _this.minZAspect = 0.2;
  114767. _this._samples = 8;
  114768. _this._textureSamples = 1;
  114769. _this._expensiveBlur = true;
  114770. /**
  114771. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 2.0
  114772. */
  114773. _this.radius = 2.0;
  114774. /**
  114775. * The base color of the SSAO post-process
  114776. * The final result is "base + ssao" between [0, 1]
  114777. */
  114778. _this.base = 0;
  114779. _this._firstUpdate = true;
  114780. _this._bits = new Uint32Array(1);
  114781. _this._scene = scene;
  114782. _this._ratio = ratio;
  114783. if (!_this.isSupported) {
  114784. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Error("SSAO 2 needs WebGL 2 support.");
  114785. return _this;
  114786. }
  114787. var ssaoRatio = _this._ratio.ssaoRatio || ratio;
  114788. var blurRatio = _this._ratio.blurRatio || ratio;
  114789. // Set up assets
  114790. var geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  114791. _this._createRandomTexture();
  114792. _this._depthTexture = geometryBufferRenderer.getGBuffer().textures[0];
  114793. _this._normalTexture = geometryBufferRenderer.getGBuffer().textures[1];
  114794. _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);
  114795. _this._originalColorPostProcess.samples = _this.textureSamples;
  114796. _this._createSSAOPostProcess(1.0);
  114797. _this._createBlurPostProcess(ssaoRatio, blurRatio);
  114798. _this._createSSAOCombinePostProcess(blurRatio);
  114799. // Set up pipeline
  114800. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  114801. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  114802. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  114803. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  114804. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  114805. // Finish
  114806. scene.postProcessRenderPipelineManager.addPipeline(_this);
  114807. if (cameras) {
  114808. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  114809. }
  114810. return _this;
  114811. }
  114812. Object.defineProperty(SSAO2RenderingPipeline.prototype, "samples", {
  114813. get: function () {
  114814. return this._samples;
  114815. },
  114816. /**
  114817. * Number of samples used for the SSAO calculations. Default value is 8
  114818. */
  114819. set: function (n) {
  114820. this._ssaoPostProcess.updateEffect("#define SAMPLES " + n + "\n#define SSAO");
  114821. this._samples = n;
  114822. this._sampleSphere = this._generateHemisphere();
  114823. this._firstUpdate = true;
  114824. },
  114825. enumerable: true,
  114826. configurable: true
  114827. });
  114828. Object.defineProperty(SSAO2RenderingPipeline.prototype, "textureSamples", {
  114829. get: function () {
  114830. return this._textureSamples;
  114831. },
  114832. /**
  114833. * Number of samples to use for antialiasing
  114834. */
  114835. set: function (n) {
  114836. this._textureSamples = n;
  114837. this._originalColorPostProcess.samples = n;
  114838. this._blurHPostProcess.samples = n;
  114839. this._blurVPostProcess.samples = n;
  114840. this._ssaoPostProcess.samples = n;
  114841. this._ssaoCombinePostProcess.samples = n;
  114842. },
  114843. enumerable: true,
  114844. configurable: true
  114845. });
  114846. Object.defineProperty(SSAO2RenderingPipeline.prototype, "expensiveBlur", {
  114847. get: function () {
  114848. return this._expensiveBlur;
  114849. },
  114850. /**
  114851. * If bilateral blur should be used
  114852. */
  114853. set: function (b) {
  114854. 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"]);
  114855. this._blurVPostProcess.updateEffect("#define BILATERAL_BLUR\n#define SAMPLES 16\n#define EXPENSIVE " + (b ? "1" : "0") + "\n", null, ["textureSampler", "depthSampler"]);
  114856. this._expensiveBlur = b;
  114857. this._firstUpdate = true;
  114858. },
  114859. enumerable: true,
  114860. configurable: true
  114861. });
  114862. Object.defineProperty(SSAO2RenderingPipeline, "IsSupported", {
  114863. /**
  114864. * Support test.
  114865. */
  114866. get: function () {
  114867. var engine = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_11__["EngineStore"].LastCreatedEngine;
  114868. if (!engine) {
  114869. return false;
  114870. }
  114871. return engine.getCaps().drawBuffersExtension;
  114872. },
  114873. enumerable: true,
  114874. configurable: true
  114875. });
  114876. Object.defineProperty(SSAO2RenderingPipeline.prototype, "scene", {
  114877. /**
  114878. * Gets active scene
  114879. */
  114880. get: function () {
  114881. return this._scene;
  114882. },
  114883. enumerable: true,
  114884. configurable: true
  114885. });
  114886. // Public Methods
  114887. /**
  114888. * Get the class name
  114889. * @returns "SSAO2RenderingPipeline"
  114890. */
  114891. SSAO2RenderingPipeline.prototype.getClassName = function () {
  114892. return "SSAO2RenderingPipeline";
  114893. };
  114894. /**
  114895. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  114896. */
  114897. SSAO2RenderingPipeline.prototype.dispose = function (disableGeometryBufferRenderer) {
  114898. if (disableGeometryBufferRenderer === void 0) { disableGeometryBufferRenderer = false; }
  114899. for (var i = 0; i < this._scene.cameras.length; i++) {
  114900. var camera = this._scene.cameras[i];
  114901. this._originalColorPostProcess.dispose(camera);
  114902. this._ssaoPostProcess.dispose(camera);
  114903. this._blurHPostProcess.dispose(camera);
  114904. this._blurVPostProcess.dispose(camera);
  114905. this._ssaoCombinePostProcess.dispose(camera);
  114906. }
  114907. this._randomTexture.dispose();
  114908. if (disableGeometryBufferRenderer) {
  114909. this._scene.disableGeometryBufferRenderer();
  114910. }
  114911. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  114912. _super.prototype.dispose.call(this);
  114913. };
  114914. // Private Methods
  114915. SSAO2RenderingPipeline.prototype._createBlurPostProcess = function (ssaoRatio, blurRatio) {
  114916. var _this = this;
  114917. this._samplerOffsets = [];
  114918. var expensive = this.expensiveBlur;
  114919. for (var i = -8; i < 8; i++) {
  114920. this._samplerOffsets.push(i * 2 + 0.5);
  114921. }
  114922. 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");
  114923. this._blurHPostProcess.onApply = function (effect) {
  114924. if (!_this._scene.activeCamera) {
  114925. return;
  114926. }
  114927. effect.setFloat("outSize", _this._ssaoCombinePostProcess.width > 0 ? _this._ssaoCombinePostProcess.width : _this._originalColorPostProcess.width);
  114928. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114929. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114930. effect.setFloat("radius", _this.radius);
  114931. effect.setTexture("depthSampler", _this._depthTexture);
  114932. if (_this._firstUpdate) {
  114933. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114934. }
  114935. };
  114936. 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");
  114937. this._blurVPostProcess.onApply = function (effect) {
  114938. if (!_this._scene.activeCamera) {
  114939. return;
  114940. }
  114941. effect.setFloat("outSize", _this._ssaoCombinePostProcess.height > 0 ? _this._ssaoCombinePostProcess.height : _this._originalColorPostProcess.height);
  114942. effect.setFloat("near", _this._scene.activeCamera.minZ);
  114943. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  114944. effect.setFloat("radius", _this.radius);
  114945. effect.setTexture("depthSampler", _this._depthTexture);
  114946. if (_this._firstUpdate) {
  114947. effect.setArray("samplerOffsets", _this._samplerOffsets);
  114948. _this._firstUpdate = false;
  114949. }
  114950. };
  114951. this._blurHPostProcess.samples = this.textureSamples;
  114952. this._blurVPostProcess.samples = this.textureSamples;
  114953. };
  114954. /** @hidden */
  114955. SSAO2RenderingPipeline.prototype._rebuild = function () {
  114956. this._firstUpdate = true;
  114957. _super.prototype._rebuild.call(this);
  114958. };
  114959. //Van der Corput radical inverse
  114960. SSAO2RenderingPipeline.prototype._radicalInverse_VdC = function (i) {
  114961. this._bits[0] = i;
  114962. this._bits[0] = ((this._bits[0] << 16) | (this._bits[0] >> 16)) >>> 0;
  114963. this._bits[0] = ((this._bits[0] & 0x55555555) << 1) | ((this._bits[0] & 0xAAAAAAAA) >>> 1) >>> 0;
  114964. this._bits[0] = ((this._bits[0] & 0x33333333) << 2) | ((this._bits[0] & 0xCCCCCCCC) >>> 2) >>> 0;
  114965. this._bits[0] = ((this._bits[0] & 0x0F0F0F0F) << 4) | ((this._bits[0] & 0xF0F0F0F0) >>> 4) >>> 0;
  114966. this._bits[0] = ((this._bits[0] & 0x00FF00FF) << 8) | ((this._bits[0] & 0xFF00FF00) >>> 8) >>> 0;
  114967. return this._bits[0] * 2.3283064365386963e-10; // / 0x100000000 or / 4294967296
  114968. };
  114969. SSAO2RenderingPipeline.prototype._hammersley = function (i, n) {
  114970. return [i / n, this._radicalInverse_VdC(i)];
  114971. };
  114972. SSAO2RenderingPipeline.prototype._hemisphereSample_uniform = function (u, v) {
  114973. var phi = v * 2.0 * Math.PI;
  114974. // rejecting samples that are close to tangent plane to avoid z-fighting artifacts
  114975. var cosTheta = 1.0 - (u * 0.85 + 0.15);
  114976. var sinTheta = Math.sqrt(1.0 - cosTheta * cosTheta);
  114977. return new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"](Math.cos(phi) * sinTheta, Math.sin(phi) * sinTheta, cosTheta);
  114978. };
  114979. SSAO2RenderingPipeline.prototype._generateHemisphere = function () {
  114980. var numSamples = this.samples;
  114981. var result = [];
  114982. var vector;
  114983. var i = 0;
  114984. while (i < numSamples) {
  114985. if (numSamples < 16) {
  114986. vector = this._hemisphereSample_uniform(Math.random(), Math.random());
  114987. }
  114988. else {
  114989. var rand = this._hammersley(i, numSamples);
  114990. vector = this._hemisphereSample_uniform(rand[0], rand[1]);
  114991. }
  114992. result.push(vector.x, vector.y, vector.z);
  114993. i++;
  114994. }
  114995. return result;
  114996. };
  114997. SSAO2RenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  114998. var _this = this;
  114999. var numSamples = this.samples;
  115000. this._sampleSphere = this._generateHemisphere();
  115001. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("ssao2", "ssao2", [
  115002. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  115003. "base", "range", "projection", "near", "far", "texelSize",
  115004. "xViewport", "yViewport", "maxZ", "minZAspect"
  115005. ], ["randomSampler", "normalSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  115006. this._ssaoPostProcess.onApply = function (effect) {
  115007. if (_this._firstUpdate) {
  115008. effect.setArray3("sampleSphere", _this._sampleSphere);
  115009. effect.setFloat("randTextureTiles", 32.0);
  115010. }
  115011. if (!_this._scene.activeCamera) {
  115012. return;
  115013. }
  115014. effect.setFloat("samplesFactor", 1 / _this.samples);
  115015. effect.setFloat("totalStrength", _this.totalStrength);
  115016. effect.setFloat2("texelSize", 1 / _this._ssaoPostProcess.width, 1 / _this._ssaoPostProcess.height);
  115017. effect.setFloat("radius", _this.radius);
  115018. effect.setFloat("maxZ", _this.maxZ);
  115019. effect.setFloat("minZAspect", _this.minZAspect);
  115020. effect.setFloat("base", _this.base);
  115021. effect.setFloat("near", _this._scene.activeCamera.minZ);
  115022. effect.setFloat("far", _this._scene.activeCamera.maxZ);
  115023. effect.setFloat("xViewport", Math.tan(_this._scene.activeCamera.fov / 2) * _this._scene.getEngine().getAspectRatio(_this._scene.activeCamera, true));
  115024. effect.setFloat("yViewport", Math.tan(_this._scene.activeCamera.fov / 2));
  115025. effect.setMatrix("projection", _this._scene.getProjectionMatrix());
  115026. effect.setTexture("textureSampler", _this._depthTexture);
  115027. effect.setTexture("normalSampler", _this._normalTexture);
  115028. effect.setTexture("randomSampler", _this._randomTexture);
  115029. };
  115030. this._ssaoPostProcess.samples = this.textureSamples;
  115031. };
  115032. SSAO2RenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  115033. var _this = this;
  115034. 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);
  115035. this._ssaoCombinePostProcess.onApply = function (effect) {
  115036. var viewport = _this._scene.activeCamera.viewport;
  115037. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Tmp"].Vector4[0].copyFromFloats(viewport.x, viewport.y, viewport.width, viewport.height));
  115038. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  115039. };
  115040. this._ssaoCombinePostProcess.samples = this.textureSamples;
  115041. };
  115042. SSAO2RenderingPipeline.prototype._createRandomTexture = function () {
  115043. var size = 128;
  115044. 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);
  115045. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  115046. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_4__["Texture"].WRAP_ADDRESSMODE;
  115047. var context = this._randomTexture.getContext();
  115048. var rand = function (min, max) {
  115049. return Math.random() * (max - min) + min;
  115050. };
  115051. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  115052. for (var x = 0; x < size; x++) {
  115053. for (var y = 0; y < size; y++) {
  115054. randVector.x = rand(0.0, 1.0);
  115055. randVector.y = rand(0.0, 1.0);
  115056. randVector.z = 0.0;
  115057. randVector.normalize();
  115058. randVector.scaleInPlace(255);
  115059. randVector.x = Math.floor(randVector.x);
  115060. randVector.y = Math.floor(randVector.y);
  115061. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  115062. context.fillRect(x, y, 1, 1);
  115063. }
  115064. }
  115065. this._randomTexture.update(false);
  115066. };
  115067. /**
  115068. * Serialize the rendering pipeline (Used when exporting)
  115069. * @returns the serialized object
  115070. */
  115071. SSAO2RenderingPipeline.prototype.serialize = function () {
  115072. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Serialize(this);
  115073. serializationObject.customType = "SSAO2RenderingPipeline";
  115074. return serializationObject;
  115075. };
  115076. /**
  115077. * Parse the serialized pipeline
  115078. * @param source Source pipeline.
  115079. * @param scene The scene to load the pipeline to.
  115080. * @param rootUrl The URL of the serialized pipeline.
  115081. * @returns An instantiated pipeline from the serialized object.
  115082. */
  115083. SSAO2RenderingPipeline.Parse = function (source, scene, rootUrl) {
  115084. return _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["SerializationHelper"].Parse(function () { return new SSAO2RenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  115085. };
  115086. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115087. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115088. ], SSAO2RenderingPipeline.prototype, "totalStrength", void 0);
  115089. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115090. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115091. ], SSAO2RenderingPipeline.prototype, "maxZ", void 0);
  115092. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115093. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115094. ], SSAO2RenderingPipeline.prototype, "minZAspect", void 0);
  115095. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115096. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("samples")
  115097. ], SSAO2RenderingPipeline.prototype, "_samples", void 0);
  115098. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115099. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("textureSamples")
  115100. ], SSAO2RenderingPipeline.prototype, "_textureSamples", void 0);
  115101. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115102. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115103. ], SSAO2RenderingPipeline.prototype, "_ratio", void 0);
  115104. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115105. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])("expensiveBlur")
  115106. ], SSAO2RenderingPipeline.prototype, "_expensiveBlur", void 0);
  115107. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115108. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115109. ], SSAO2RenderingPipeline.prototype, "radius", void 0);
  115110. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115111. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  115112. ], SSAO2RenderingPipeline.prototype, "base", void 0);
  115113. return SSAO2RenderingPipeline;
  115114. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  115115. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_10__["_TypeStore"].RegisteredTypes["BABYLON.SSAO2RenderingPipeline"] = SSAO2RenderingPipeline;
  115116. /***/ }),
  115117. /***/ "./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts":
  115118. /*!*************************************************************************!*\
  115119. !*** ./PostProcesses/RenderPipeline/Pipelines/ssaoRenderingPipeline.ts ***!
  115120. \*************************************************************************/
  115121. /*! exports provided: SSAORenderingPipeline */
  115122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115123. "use strict";
  115124. __webpack_require__.r(__webpack_exports__);
  115125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return SSAORenderingPipeline; });
  115126. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115127. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  115128. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115129. /* harmony import */ var _Materials_Textures_dynamicTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Materials/Textures/dynamicTexture */ "./Materials/Textures/dynamicTexture.ts");
  115130. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  115131. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115132. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115133. /* harmony import */ var _PostProcesses_passPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/passPostProcess */ "./PostProcesses/passPostProcess.ts");
  115134. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115135. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  115136. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  115137. /* harmony import */ var _Shaders_ssao_fragment__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Shaders/ssao.fragment */ "./Shaders/ssao.fragment.ts");
  115138. /* harmony import */ var _Shaders_ssaoCombine_fragment__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Shaders/ssaoCombine.fragment */ "./Shaders/ssaoCombine.fragment.ts");
  115139. /**
  115140. * Render pipeline to produce ssao effect
  115141. */
  115142. var SSAORenderingPipeline = /** @class */ (function (_super) {
  115143. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SSAORenderingPipeline, _super);
  115144. /**
  115145. * @constructor
  115146. * @param name - The rendering pipeline name
  115147. * @param scene - The scene linked to this pipeline
  115148. * @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 }
  115149. * @param cameras - The array of cameras that the rendering pipeline will be attached to
  115150. */
  115151. function SSAORenderingPipeline(name, scene, ratio, cameras) {
  115152. var _this = _super.call(this, scene.getEngine(), name) || this;
  115153. // Members
  115154. /**
  115155. * @ignore
  115156. * The PassPostProcess id in the pipeline that contains the original scene color
  115157. */
  115158. _this.SSAOOriginalSceneColorEffect = "SSAOOriginalSceneColorEffect";
  115159. /**
  115160. * @ignore
  115161. * The SSAO PostProcess id in the pipeline
  115162. */
  115163. _this.SSAORenderEffect = "SSAORenderEffect";
  115164. /**
  115165. * @ignore
  115166. * The horizontal blur PostProcess id in the pipeline
  115167. */
  115168. _this.SSAOBlurHRenderEffect = "SSAOBlurHRenderEffect";
  115169. /**
  115170. * @ignore
  115171. * The vertical blur PostProcess id in the pipeline
  115172. */
  115173. _this.SSAOBlurVRenderEffect = "SSAOBlurVRenderEffect";
  115174. /**
  115175. * @ignore
  115176. * The PostProcess id in the pipeline that combines the SSAO-Blur output with the original scene color (SSAOOriginalSceneColorEffect)
  115177. */
  115178. _this.SSAOCombineRenderEffect = "SSAOCombineRenderEffect";
  115179. /**
  115180. * The output strength of the SSAO post-process. Default value is 1.0.
  115181. */
  115182. _this.totalStrength = 1.0;
  115183. /**
  115184. * The radius around the analyzed pixel used by the SSAO post-process. Default value is 0.0006
  115185. */
  115186. _this.radius = 0.0001;
  115187. /**
  115188. * Related to fallOff, used to interpolate SSAO samples (first interpolate function input) based on the occlusion difference of each pixel
  115189. * Must not be equal to fallOff and superior to fallOff.
  115190. * Default value is 0.0075
  115191. */
  115192. _this.area = 0.0075;
  115193. /**
  115194. * Related to area, used to interpolate SSAO samples (second interpolate function input) based on the occlusion difference of each pixel
  115195. * Must not be equal to area and inferior to area.
  115196. * Default value is 0.000001
  115197. */
  115198. _this.fallOff = 0.000001;
  115199. /**
  115200. * The base color of the SSAO post-process
  115201. * The final result is "base + ssao" between [0, 1]
  115202. */
  115203. _this.base = 0.5;
  115204. _this._firstUpdate = true;
  115205. _this._scene = scene;
  115206. // Set up assets
  115207. _this._createRandomTexture();
  115208. _this._depthTexture = scene.enableDepthRenderer().getDepthMap(); // Force depth renderer "on"
  115209. var ssaoRatio = ratio.ssaoRatio || ratio;
  115210. var combineRatio = ratio.combineRatio || ratio;
  115211. _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);
  115212. _this._createSSAOPostProcess(ssaoRatio);
  115213. _this._createBlurPostProcess(ssaoRatio);
  115214. _this._createSSAOCombinePostProcess(combineRatio);
  115215. // Set up pipeline
  115216. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOOriginalSceneColorEffect, function () { return _this._originalColorPostProcess; }, true));
  115217. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAORenderEffect, function () { return _this._ssaoPostProcess; }, true));
  115218. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurHRenderEffect, function () { return _this._blurHPostProcess; }, true));
  115219. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOBlurVRenderEffect, function () { return _this._blurVPostProcess; }, true));
  115220. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_6__["PostProcessRenderEffect"](scene.getEngine(), _this.SSAOCombineRenderEffect, function () { return _this._ssaoCombinePostProcess; }, true));
  115221. // Finish
  115222. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115223. if (cameras) {
  115224. scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(name, cameras);
  115225. }
  115226. return _this;
  115227. }
  115228. Object.defineProperty(SSAORenderingPipeline.prototype, "scene", {
  115229. /**
  115230. * Gets active scene
  115231. */
  115232. get: function () {
  115233. return this._scene;
  115234. },
  115235. enumerable: true,
  115236. configurable: true
  115237. });
  115238. // Public Methods
  115239. /**
  115240. * Get the class name
  115241. * @returns "SSAORenderingPipeline"
  115242. */
  115243. SSAORenderingPipeline.prototype.getClassName = function () {
  115244. return "SSAORenderingPipeline";
  115245. };
  115246. /**
  115247. * Removes the internal pipeline assets and detatches the pipeline from the scene cameras
  115248. */
  115249. SSAORenderingPipeline.prototype.dispose = function (disableDepthRender) {
  115250. if (disableDepthRender === void 0) { disableDepthRender = false; }
  115251. for (var i = 0; i < this._scene.cameras.length; i++) {
  115252. var camera = this._scene.cameras[i];
  115253. this._originalColorPostProcess.dispose(camera);
  115254. this._ssaoPostProcess.dispose(camera);
  115255. this._blurHPostProcess.dispose(camera);
  115256. this._blurVPostProcess.dispose(camera);
  115257. this._ssaoCombinePostProcess.dispose(camera);
  115258. }
  115259. this._randomTexture.dispose();
  115260. if (disableDepthRender) {
  115261. this._scene.disableDepthRenderer();
  115262. }
  115263. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._scene.cameras);
  115264. _super.prototype.dispose.call(this);
  115265. };
  115266. // Private Methods
  115267. SSAORenderingPipeline.prototype._createBlurPostProcess = function (ratio) {
  115268. var _this = this;
  115269. var size = 16;
  115270. 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);
  115271. 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);
  115272. this._blurHPostProcess.onActivateObservable.add(function () {
  115273. var dw = _this._blurHPostProcess.width / _this._scene.getEngine().getRenderWidth();
  115274. _this._blurHPostProcess.kernel = size * dw;
  115275. });
  115276. this._blurVPostProcess.onActivateObservable.add(function () {
  115277. var dw = _this._blurVPostProcess.height / _this._scene.getEngine().getRenderHeight();
  115278. _this._blurVPostProcess.kernel = size * dw;
  115279. });
  115280. };
  115281. /** @hidden */
  115282. SSAORenderingPipeline.prototype._rebuild = function () {
  115283. this._firstUpdate = true;
  115284. _super.prototype._rebuild.call(this);
  115285. };
  115286. SSAORenderingPipeline.prototype._createSSAOPostProcess = function (ratio) {
  115287. var _this = this;
  115288. var numSamples = 16;
  115289. var sampleSphere = [
  115290. 0.5381, 0.1856, -0.4319,
  115291. 0.1379, 0.2486, 0.4430,
  115292. 0.3371, 0.5679, -0.0057,
  115293. -0.6999, -0.0451, -0.0019,
  115294. 0.0689, -0.1598, -0.8547,
  115295. 0.0560, 0.0069, -0.1843,
  115296. -0.0146, 0.1402, 0.0762,
  115297. 0.0100, -0.1924, -0.0344,
  115298. -0.3577, -0.5301, -0.4358,
  115299. -0.3169, 0.1063, 0.0158,
  115300. 0.0103, -0.5869, 0.0046,
  115301. -0.0897, -0.4940, 0.3287,
  115302. 0.7119, -0.0154, -0.0918,
  115303. -0.0533, 0.0596, -0.5411,
  115304. 0.0352, -0.0631, 0.5460,
  115305. -0.4776, 0.2847, -0.0271
  115306. ];
  115307. var samplesFactor = 1.0 / numSamples;
  115308. this._ssaoPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_4__["PostProcess"]("ssao", "ssao", [
  115309. "sampleSphere", "samplesFactor", "randTextureTiles", "totalStrength", "radius",
  115310. "area", "fallOff", "base", "range", "viewport"
  115311. ], ["randomSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE, this._scene.getEngine(), false, "#define SAMPLES " + numSamples + "\n#define SSAO");
  115312. this._ssaoPostProcess.onApply = function (effect) {
  115313. if (_this._firstUpdate) {
  115314. effect.setArray3("sampleSphere", sampleSphere);
  115315. effect.setFloat("samplesFactor", samplesFactor);
  115316. effect.setFloat("randTextureTiles", 4.0);
  115317. }
  115318. effect.setFloat("totalStrength", _this.totalStrength);
  115319. effect.setFloat("radius", _this.radius);
  115320. effect.setFloat("area", _this.area);
  115321. effect.setFloat("fallOff", _this.fallOff);
  115322. effect.setFloat("base", _this.base);
  115323. effect.setTexture("textureSampler", _this._depthTexture);
  115324. effect.setTexture("randomSampler", _this._randomTexture);
  115325. };
  115326. };
  115327. SSAORenderingPipeline.prototype._createSSAOCombinePostProcess = function (ratio) {
  115328. var _this = this;
  115329. 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);
  115330. this._ssaoCombinePostProcess.onApply = function (effect) {
  115331. effect.setVector4("viewport", _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Tmp"].Vector4[0].copyFromFloats(0, 0, 1.0, 1.0));
  115332. effect.setTextureFromPostProcess("originalColor", _this._originalColorPostProcess);
  115333. };
  115334. };
  115335. SSAORenderingPipeline.prototype._createRandomTexture = function () {
  115336. var size = 512;
  115337. 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);
  115338. this._randomTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  115339. this._randomTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].WRAP_ADDRESSMODE;
  115340. var context = this._randomTexture.getContext();
  115341. var rand = function (min, max) {
  115342. return Math.random() * (max - min) + min;
  115343. };
  115344. var randVector = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  115345. for (var x = 0; x < size; x++) {
  115346. for (var y = 0; y < size; y++) {
  115347. randVector.x = Math.floor(rand(-1.0, 1.0) * 255);
  115348. randVector.y = Math.floor(rand(-1.0, 1.0) * 255);
  115349. randVector.z = Math.floor(rand(-1.0, 1.0) * 255);
  115350. context.fillStyle = 'rgb(' + randVector.x + ', ' + randVector.y + ', ' + randVector.z + ')';
  115351. context.fillRect(x, y, 1, 1);
  115352. }
  115353. }
  115354. this._randomTexture.update(false);
  115355. };
  115356. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115357. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  115358. ], SSAORenderingPipeline.prototype, "totalStrength", void 0);
  115359. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115360. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  115361. ], SSAORenderingPipeline.prototype, "radius", void 0);
  115362. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115363. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  115364. ], SSAORenderingPipeline.prototype, "area", void 0);
  115365. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115366. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  115367. ], SSAORenderingPipeline.prototype, "fallOff", void 0);
  115368. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  115369. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_10__["serialize"])()
  115370. ], SSAORenderingPipeline.prototype, "base", void 0);
  115371. return SSAORenderingPipeline;
  115372. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_5__["PostProcessRenderPipeline"]));
  115373. /***/ }),
  115374. /***/ "./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts":
  115375. /*!*****************************************************************************!*\
  115376. !*** ./PostProcesses/RenderPipeline/Pipelines/standardRenderingPipeline.ts ***!
  115377. \*****************************************************************************/
  115378. /*! exports provided: StandardRenderingPipeline */
  115379. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  115380. "use strict";
  115381. __webpack_require__.r(__webpack_exports__);
  115382. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return StandardRenderingPipeline; });
  115383. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  115384. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../../Misc/decorators */ "./Misc/decorators.ts");
  115385. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../../Misc/logger */ "./Misc/logger.ts");
  115386. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../../../Maths/math */ "./Maths/math.ts");
  115387. /* harmony import */ var _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../../../Maths/math.scalar */ "./Maths/math.scalar.ts");
  115388. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../../../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  115389. /* harmony import */ var _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../../../PostProcesses/postProcess */ "./PostProcesses/postProcess.ts");
  115390. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  115391. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  115392. /* harmony import */ var _PostProcesses_blurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../../PostProcesses/blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  115393. /* harmony import */ var _PostProcesses_fxaaPostProcess__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../../PostProcesses/fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  115394. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../../Engines/constants */ "./Engines/constants.ts");
  115395. /* harmony import */ var _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../../Misc/typeStore */ "./Misc/typeStore.ts");
  115396. /* harmony import */ var _Shaders_standard_fragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../../Shaders/standard.fragment */ "./Shaders/standard.fragment.ts");
  115397. /**
  115398. * Standard rendering pipeline
  115399. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  115400. * @see https://doc.babylonjs.com/how_to/using_standard_rendering_pipeline
  115401. */
  115402. var StandardRenderingPipeline = /** @class */ (function (_super) {
  115403. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StandardRenderingPipeline, _super);
  115404. /**
  115405. * Default pipeline should be used going forward but the standard pipeline will be kept for backwards compatibility.
  115406. * @constructor
  115407. * @param name The rendering pipeline name
  115408. * @param scene The scene linked to this pipeline
  115409. * @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)
  115410. * @param originalPostProcess the custom original color post-process. Must be "reusable". Can be null.
  115411. * @param cameras The array of cameras that the rendering pipeline will be attached to
  115412. */
  115413. function StandardRenderingPipeline(name, scene, ratio, originalPostProcess, cameras) {
  115414. if (originalPostProcess === void 0) { originalPostProcess = null; }
  115415. var _this = _super.call(this, scene.getEngine(), name) || this;
  115416. /**
  115417. * Post-process used to down scale an image x4
  115418. */
  115419. _this.downSampleX4PostProcess = null;
  115420. /**
  115421. * Post-process used to calculate the illuminated surfaces controlled by a threshold
  115422. */
  115423. _this.brightPassPostProcess = null;
  115424. /**
  115425. * Post-process array storing all the horizontal blur post-processes used by the pipeline
  115426. */
  115427. _this.blurHPostProcesses = [];
  115428. /**
  115429. * Post-process array storing all the vertical blur post-processes used by the pipeline
  115430. */
  115431. _this.blurVPostProcesses = [];
  115432. /**
  115433. * Post-process used to add colors of 2 textures (typically brightness + real scene color)
  115434. */
  115435. _this.textureAdderPostProcess = null;
  115436. /**
  115437. * Post-process used to create volumetric lighting effect
  115438. */
  115439. _this.volumetricLightPostProcess = null;
  115440. /**
  115441. * Post-process used to smooth the previous volumetric light post-process on the X axis
  115442. */
  115443. _this.volumetricLightSmoothXPostProcess = null;
  115444. /**
  115445. * Post-process used to smooth the previous volumetric light post-process on the Y axis
  115446. */
  115447. _this.volumetricLightSmoothYPostProcess = null;
  115448. /**
  115449. * Post-process used to merge the volumetric light effect and the real scene color
  115450. */
  115451. _this.volumetricLightMergePostProces = null;
  115452. /**
  115453. * Post-process used to store the final volumetric light post-process (attach/detach for debug purpose)
  115454. */
  115455. _this.volumetricLightFinalPostProcess = null;
  115456. /**
  115457. * Base post-process used to calculate the average luminance of the final image for HDR
  115458. */
  115459. _this.luminancePostProcess = null;
  115460. /**
  115461. * Post-processes used to create down sample post-processes in order to get
  115462. * the average luminance of the final image for HDR
  115463. * Array of length "StandardRenderingPipeline.LuminanceSteps"
  115464. */
  115465. _this.luminanceDownSamplePostProcesses = [];
  115466. /**
  115467. * Post-process used to create a HDR effect (light adaptation)
  115468. */
  115469. _this.hdrPostProcess = null;
  115470. /**
  115471. * Post-process used to store the final texture adder post-process (attach/detach for debug purpose)
  115472. */
  115473. _this.textureAdderFinalPostProcess = null;
  115474. /**
  115475. * Post-process used to store the final lens flare post-process (attach/detach for debug purpose)
  115476. */
  115477. _this.lensFlareFinalPostProcess = null;
  115478. /**
  115479. * Post-process used to merge the final HDR post-process and the real scene color
  115480. */
  115481. _this.hdrFinalPostProcess = null;
  115482. /**
  115483. * Post-process used to create a lens flare effect
  115484. */
  115485. _this.lensFlarePostProcess = null;
  115486. /**
  115487. * Post-process that merges the result of the lens flare post-process and the real scene color
  115488. */
  115489. _this.lensFlareComposePostProcess = null;
  115490. /**
  115491. * Post-process used to create a motion blur effect
  115492. */
  115493. _this.motionBlurPostProcess = null;
  115494. /**
  115495. * Post-process used to create a depth of field effect
  115496. */
  115497. _this.depthOfFieldPostProcess = null;
  115498. /**
  115499. * The Fast Approximate Anti-Aliasing post process which attemps to remove aliasing from an image.
  115500. */
  115501. _this.fxaaPostProcess = null;
  115502. // Values
  115503. /**
  115504. * Represents the brightness threshold in order to configure the illuminated surfaces
  115505. */
  115506. _this.brightThreshold = 1.0;
  115507. /**
  115508. * Configures the blur intensity used for surexposed surfaces are highlighted surfaces (light halo)
  115509. */
  115510. _this.blurWidth = 512.0;
  115511. /**
  115512. * Sets if the blur for highlighted surfaces must be only horizontal
  115513. */
  115514. _this.horizontalBlur = false;
  115515. /**
  115516. * Sets the overall exposure used by the pipeline
  115517. */
  115518. _this.exposure = 1.0;
  115519. /**
  115520. * Texture used typically to simulate "dirty" on camera lens
  115521. */
  115522. _this.lensTexture = null;
  115523. /**
  115524. * Represents the offset coefficient based on Rayleigh principle. Typically in interval [-0.2, 0.2]
  115525. */
  115526. _this.volumetricLightCoefficient = 0.2;
  115527. /**
  115528. * The overall power of volumetric lights, typically in interval [0, 10] maximum
  115529. */
  115530. _this.volumetricLightPower = 4.0;
  115531. /**
  115532. * Used the set the blur intensity to smooth the volumetric lights
  115533. */
  115534. _this.volumetricLightBlurScale = 64.0;
  115535. /**
  115536. * Light (spot or directional) used to generate the volumetric lights rays
  115537. * The source light must have a shadow generate so the pipeline can get its
  115538. * depth map
  115539. */
  115540. _this.sourceLight = null;
  115541. /**
  115542. * For eye adaptation, represents the minimum luminance the eye can see
  115543. */
  115544. _this.hdrMinimumLuminance = 1.0;
  115545. /**
  115546. * For eye adaptation, represents the decrease luminance speed
  115547. */
  115548. _this.hdrDecreaseRate = 0.5;
  115549. /**
  115550. * For eye adaptation, represents the increase luminance speed
  115551. */
  115552. _this.hdrIncreaseRate = 0.5;
  115553. /**
  115554. * Lens color texture used by the lens flare effect. Mandatory if lens flare effect enabled
  115555. */
  115556. _this.lensColorTexture = null;
  115557. /**
  115558. * The overall strengh for the lens flare effect
  115559. */
  115560. _this.lensFlareStrength = 20.0;
  115561. /**
  115562. * Dispersion coefficient for lens flare ghosts
  115563. */
  115564. _this.lensFlareGhostDispersal = 1.4;
  115565. /**
  115566. * Main lens flare halo width
  115567. */
  115568. _this.lensFlareHaloWidth = 0.7;
  115569. /**
  115570. * Based on the lens distortion effect, defines how much the lens flare result
  115571. * is distorted
  115572. */
  115573. _this.lensFlareDistortionStrength = 16.0;
  115574. /**
  115575. * Lens star texture must be used to simulate rays on the flares and is available
  115576. * in the documentation
  115577. */
  115578. _this.lensStarTexture = null;
  115579. /**
  115580. * As the "lensTexture" (can be the same texture or different), it is used to apply the lens
  115581. * flare effect by taking account of the dirt texture
  115582. */
  115583. _this.lensFlareDirtTexture = null;
  115584. /**
  115585. * Represents the focal length for the depth of field effect
  115586. */
  115587. _this.depthOfFieldDistance = 10.0;
  115588. /**
  115589. * Represents the blur intensity for the blurred part of the depth of field effect
  115590. */
  115591. _this.depthOfFieldBlurWidth = 64.0;
  115592. /**
  115593. * For motion blur, defines how much the image is blurred by the movement
  115594. */
  115595. _this.motionStrength = 1.0;
  115596. /**
  115597. * List of animations for the pipeline (IAnimatable implementation)
  115598. */
  115599. _this.animations = [];
  115600. _this._currentDepthOfFieldSource = null;
  115601. _this._hdrCurrentLuminance = 1.0;
  115602. // Getters and setters
  115603. _this._bloomEnabled = false;
  115604. _this._depthOfFieldEnabled = false;
  115605. _this._vlsEnabled = false;
  115606. _this._lensFlareEnabled = false;
  115607. _this._hdrEnabled = false;
  115608. _this._motionBlurEnabled = false;
  115609. _this._fxaaEnabled = false;
  115610. _this._motionBlurSamples = 64.0;
  115611. _this._volumetricLightStepsCount = 50.0;
  115612. _this._samples = 1;
  115613. _this._cameras = cameras || [];
  115614. // Initialize
  115615. _this._scene = scene;
  115616. _this._basePostProcess = originalPostProcess;
  115617. _this._ratio = ratio;
  115618. // Misc
  115619. _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;
  115620. // Finish
  115621. scene.postProcessRenderPipelineManager.addPipeline(_this);
  115622. _this._buildPipeline();
  115623. return _this;
  115624. }
  115625. Object.defineProperty(StandardRenderingPipeline.prototype, "BloomEnabled", {
  115626. /**
  115627. * @ignore
  115628. * Specifies if the bloom pipeline is enabled
  115629. */
  115630. get: function () {
  115631. return this._bloomEnabled;
  115632. },
  115633. set: function (enabled) {
  115634. if (this._bloomEnabled === enabled) {
  115635. return;
  115636. }
  115637. this._bloomEnabled = enabled;
  115638. this._buildPipeline();
  115639. },
  115640. enumerable: true,
  115641. configurable: true
  115642. });
  115643. Object.defineProperty(StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", {
  115644. /**
  115645. * @ignore
  115646. * Specifies if the depth of field pipeline is enabed
  115647. */
  115648. get: function () {
  115649. return this._depthOfFieldEnabled;
  115650. },
  115651. set: function (enabled) {
  115652. if (this._depthOfFieldEnabled === enabled) {
  115653. return;
  115654. }
  115655. this._depthOfFieldEnabled = enabled;
  115656. this._buildPipeline();
  115657. },
  115658. enumerable: true,
  115659. configurable: true
  115660. });
  115661. Object.defineProperty(StandardRenderingPipeline.prototype, "LensFlareEnabled", {
  115662. /**
  115663. * @ignore
  115664. * Specifies if the lens flare pipeline is enabed
  115665. */
  115666. get: function () {
  115667. return this._lensFlareEnabled;
  115668. },
  115669. set: function (enabled) {
  115670. if (this._lensFlareEnabled === enabled) {
  115671. return;
  115672. }
  115673. this._lensFlareEnabled = enabled;
  115674. this._buildPipeline();
  115675. },
  115676. enumerable: true,
  115677. configurable: true
  115678. });
  115679. Object.defineProperty(StandardRenderingPipeline.prototype, "HDREnabled", {
  115680. /**
  115681. * @ignore
  115682. * Specifies if the HDR pipeline is enabled
  115683. */
  115684. get: function () {
  115685. return this._hdrEnabled;
  115686. },
  115687. set: function (enabled) {
  115688. if (this._hdrEnabled === enabled) {
  115689. return;
  115690. }
  115691. this._hdrEnabled = enabled;
  115692. this._buildPipeline();
  115693. },
  115694. enumerable: true,
  115695. configurable: true
  115696. });
  115697. Object.defineProperty(StandardRenderingPipeline.prototype, "VLSEnabled", {
  115698. /**
  115699. * @ignore
  115700. * Specifies if the volumetric lights scattering effect is enabled
  115701. */
  115702. get: function () {
  115703. return this._vlsEnabled;
  115704. },
  115705. set: function (enabled) {
  115706. if (this._vlsEnabled === enabled) {
  115707. return;
  115708. }
  115709. if (enabled) {
  115710. var geometry = this._scene.enableGeometryBufferRenderer();
  115711. if (!geometry) {
  115712. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("Geometry renderer is not supported, cannot create volumetric lights in Standard Rendering Pipeline");
  115713. return;
  115714. }
  115715. }
  115716. this._vlsEnabled = enabled;
  115717. this._buildPipeline();
  115718. },
  115719. enumerable: true,
  115720. configurable: true
  115721. });
  115722. Object.defineProperty(StandardRenderingPipeline.prototype, "MotionBlurEnabled", {
  115723. /**
  115724. * @ignore
  115725. * Specifies if the motion blur effect is enabled
  115726. */
  115727. get: function () {
  115728. return this._motionBlurEnabled;
  115729. },
  115730. set: function (enabled) {
  115731. if (this._motionBlurEnabled === enabled) {
  115732. return;
  115733. }
  115734. this._motionBlurEnabled = enabled;
  115735. this._buildPipeline();
  115736. },
  115737. enumerable: true,
  115738. configurable: true
  115739. });
  115740. Object.defineProperty(StandardRenderingPipeline.prototype, "fxaaEnabled", {
  115741. /**
  115742. * Specifies if anti-aliasing is enabled
  115743. */
  115744. get: function () {
  115745. return this._fxaaEnabled;
  115746. },
  115747. set: function (enabled) {
  115748. if (this._fxaaEnabled === enabled) {
  115749. return;
  115750. }
  115751. this._fxaaEnabled = enabled;
  115752. this._buildPipeline();
  115753. },
  115754. enumerable: true,
  115755. configurable: true
  115756. });
  115757. Object.defineProperty(StandardRenderingPipeline.prototype, "volumetricLightStepsCount", {
  115758. /**
  115759. * Specifies the number of steps used to calculate the volumetric lights
  115760. * Typically in interval [50, 200]
  115761. */
  115762. get: function () {
  115763. return this._volumetricLightStepsCount;
  115764. },
  115765. set: function (count) {
  115766. if (this.volumetricLightPostProcess) {
  115767. this.volumetricLightPostProcess.updateEffect("#define VLS\n#define NB_STEPS " + count.toFixed(1));
  115768. }
  115769. this._volumetricLightStepsCount = count;
  115770. },
  115771. enumerable: true,
  115772. configurable: true
  115773. });
  115774. Object.defineProperty(StandardRenderingPipeline.prototype, "motionBlurSamples", {
  115775. /**
  115776. * Specifies the number of samples used for the motion blur effect
  115777. * Typically in interval [16, 64]
  115778. */
  115779. get: function () {
  115780. return this._motionBlurSamples;
  115781. },
  115782. set: function (samples) {
  115783. if (this.motionBlurPostProcess) {
  115784. this.motionBlurPostProcess.updateEffect("#define MOTION_BLUR\n#define MAX_MOTION_SAMPLES " + samples.toFixed(1));
  115785. }
  115786. this._motionBlurSamples = samples;
  115787. },
  115788. enumerable: true,
  115789. configurable: true
  115790. });
  115791. Object.defineProperty(StandardRenderingPipeline.prototype, "samples", {
  115792. /**
  115793. * Specifies MSAA sample count, setting this to 4 will provide 4x anti aliasing. (default: 1)
  115794. */
  115795. get: function () {
  115796. return this._samples;
  115797. },
  115798. set: function (sampleCount) {
  115799. if (this._samples === sampleCount) {
  115800. return;
  115801. }
  115802. this._samples = sampleCount;
  115803. this._buildPipeline();
  115804. },
  115805. enumerable: true,
  115806. configurable: true
  115807. });
  115808. StandardRenderingPipeline.prototype._buildPipeline = function () {
  115809. var _this = this;
  115810. var ratio = this._ratio;
  115811. var scene = this._scene;
  115812. this._disposePostProcesses();
  115813. this._reset();
  115814. // Create pass post-process
  115815. if (!this._basePostProcess) {
  115816. 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);
  115817. this.originalPostProcess.onApply = function () {
  115818. _this._currentDepthOfFieldSource = _this.originalPostProcess;
  115819. };
  115820. }
  115821. else {
  115822. this.originalPostProcess = this._basePostProcess;
  115823. }
  115824. if (this._bloomEnabled || this._vlsEnabled || this._lensFlareEnabled || this._depthOfFieldEnabled || this._motionBlurEnabled) {
  115825. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPassPostProcess", function () { return _this.originalPostProcess; }, true));
  115826. }
  115827. this._currentDepthOfFieldSource = this.originalPostProcess;
  115828. if (this._bloomEnabled) {
  115829. // Create down sample X4 post-process
  115830. this._createDownSampleX4PostProcess(scene, ratio / 2);
  115831. // Create bright pass post-process
  115832. this._createBrightPassPostProcess(scene, ratio / 2);
  115833. // Create gaussian blur post-processes (down sampling blurs)
  115834. this._createBlurPostProcesses(scene, ratio / 4, 1);
  115835. // Create texture adder post-process
  115836. this._createTextureAdderPostProcess(scene, ratio);
  115837. // Create depth-of-field source post-process
  115838. 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);
  115839. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBaseDepthOfFieldSource", function () { return _this.textureAdderFinalPostProcess; }, true));
  115840. }
  115841. if (this._vlsEnabled) {
  115842. // Create volumetric light
  115843. this._createVolumetricLightPostProcess(scene, ratio);
  115844. // Create volumetric light final post-process
  115845. 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);
  115846. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSFinal", function () { return _this.volumetricLightFinalPostProcess; }, true));
  115847. }
  115848. if (this._lensFlareEnabled) {
  115849. // Create lens flare post-process
  115850. this._createLensFlarePostProcess(scene, ratio);
  115851. // Create depth-of-field source post-process post lens-flare and disable it now
  115852. 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);
  115853. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostLensFlareDepthOfFieldSource", function () { return _this.lensFlareFinalPostProcess; }, true));
  115854. }
  115855. if (this._hdrEnabled) {
  115856. // Create luminance
  115857. this._createLuminancePostProcesses(scene, this._floatTextureType);
  115858. // Create HDR
  115859. this._createHdrPostProcess(scene, ratio);
  115860. // Create depth-of-field source post-process post hdr and disable it now
  115861. 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);
  115862. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRPostHDReDepthOfFieldSource", function () { return _this.hdrFinalPostProcess; }, true));
  115863. }
  115864. if (this._depthOfFieldEnabled) {
  115865. // Create gaussian blur used by depth-of-field
  115866. this._createBlurPostProcesses(scene, ratio / 2, 3, "depthOfFieldBlurWidth");
  115867. // Create depth-of-field post-process
  115868. this._createDepthOfFieldPostProcess(scene, ratio);
  115869. }
  115870. if (this._motionBlurEnabled) {
  115871. // Create motion blur post-process
  115872. this._createMotionBlurPostProcess(scene, ratio);
  115873. }
  115874. if (this._fxaaEnabled) {
  115875. // Create fxaa post-process
  115876. 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);
  115877. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRFxaa", function () { return _this.fxaaPostProcess; }, true));
  115878. }
  115879. if (this._cameras !== null) {
  115880. this._scene.postProcessRenderPipelineManager.attachCamerasToRenderPipeline(this._name, this._cameras);
  115881. }
  115882. if (!this._enableMSAAOnFirstPostProcess(this._samples) && this._samples > 1) {
  115883. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("MSAA failed to enable, MSAA is only supported in browsers that support webGL >= 2.0");
  115884. }
  115885. };
  115886. // Down Sample X4 Post-Processs
  115887. StandardRenderingPipeline.prototype._createDownSampleX4PostProcess = function (scene, ratio) {
  115888. var _this = this;
  115889. var downSampleX4Offsets = new Array(32);
  115890. 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);
  115891. this.downSampleX4PostProcess.onApply = function (effect) {
  115892. var id = 0;
  115893. var width = _this.downSampleX4PostProcess.width;
  115894. var height = _this.downSampleX4PostProcess.height;
  115895. for (var i = -2; i < 2; i++) {
  115896. for (var j = -2; j < 2; j++) {
  115897. downSampleX4Offsets[id] = (i + 0.5) * (1.0 / width);
  115898. downSampleX4Offsets[id + 1] = (j + 0.5) * (1.0 / height);
  115899. id += 2;
  115900. }
  115901. }
  115902. effect.setArray2("dsOffsets", downSampleX4Offsets);
  115903. };
  115904. // Add to pipeline
  115905. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDownSampleX4", function () { return _this.downSampleX4PostProcess; }, true));
  115906. };
  115907. // Brightpass Post-Process
  115908. StandardRenderingPipeline.prototype._createBrightPassPostProcess = function (scene, ratio) {
  115909. var _this = this;
  115910. var brightOffsets = new Array(8);
  115911. 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);
  115912. this.brightPassPostProcess.onApply = function (effect) {
  115913. var sU = (1.0 / _this.brightPassPostProcess.width);
  115914. var sV = (1.0 / _this.brightPassPostProcess.height);
  115915. brightOffsets[0] = -0.5 * sU;
  115916. brightOffsets[1] = 0.5 * sV;
  115917. brightOffsets[2] = 0.5 * sU;
  115918. brightOffsets[3] = 0.5 * sV;
  115919. brightOffsets[4] = -0.5 * sU;
  115920. brightOffsets[5] = -0.5 * sV;
  115921. brightOffsets[6] = 0.5 * sU;
  115922. brightOffsets[7] = -0.5 * sV;
  115923. effect.setArray2("dsOffsets", brightOffsets);
  115924. effect.setFloat("brightThreshold", _this.brightThreshold);
  115925. };
  115926. // Add to pipeline
  115927. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBrightPass", function () { return _this.brightPassPostProcess; }, true));
  115928. };
  115929. // Create blur H&V post-processes
  115930. StandardRenderingPipeline.prototype._createBlurPostProcesses = function (scene, ratio, indice, blurWidthKey) {
  115931. var _this = this;
  115932. if (blurWidthKey === void 0) { blurWidthKey = "blurWidth"; }
  115933. var engine = scene.getEngine();
  115934. 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);
  115935. 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);
  115936. blurX.onActivateObservable.add(function () {
  115937. var dw = blurX.width / engine.getRenderWidth();
  115938. blurX.kernel = _this[blurWidthKey] * dw;
  115939. });
  115940. blurY.onActivateObservable.add(function () {
  115941. var dw = blurY.height / engine.getRenderHeight();
  115942. blurY.kernel = _this.horizontalBlur ? 64 * dw : _this[blurWidthKey] * dw;
  115943. });
  115944. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurH" + indice, function () { return blurX; }, true));
  115945. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRBlurV" + indice, function () { return blurY; }, true));
  115946. this.blurHPostProcesses.push(blurX);
  115947. this.blurVPostProcesses.push(blurY);
  115948. };
  115949. // Create texture adder post-process
  115950. StandardRenderingPipeline.prototype._createTextureAdderPostProcess = function (scene, ratio) {
  115951. var _this = this;
  115952. 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);
  115953. this.textureAdderPostProcess.onApply = function (effect) {
  115954. effect.setTextureFromPostProcess("otherSampler", _this._vlsEnabled ? _this._currentDepthOfFieldSource : _this.originalPostProcess);
  115955. effect.setTexture("lensSampler", _this.lensTexture);
  115956. effect.setFloat("exposure", _this.exposure);
  115957. _this._currentDepthOfFieldSource = _this.textureAdderFinalPostProcess;
  115958. };
  115959. // Add to pipeline
  115960. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRTextureAdder", function () { return _this.textureAdderPostProcess; }, true));
  115961. };
  115962. StandardRenderingPipeline.prototype._createVolumetricLightPostProcess = function (scene, ratio) {
  115963. var _this = this;
  115964. var geometryRenderer = scene.enableGeometryBufferRenderer();
  115965. geometryRenderer.enablePosition = true;
  115966. var geometry = geometryRenderer.getGBuffer();
  115967. // Base post-process
  115968. 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));
  115969. var depthValues = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  115970. this.volumetricLightPostProcess.onApply = function (effect) {
  115971. if (_this.sourceLight && _this.sourceLight.getShadowGenerator() && _this._scene.activeCamera) {
  115972. var generator = _this.sourceLight.getShadowGenerator();
  115973. effect.setTexture("shadowMapSampler", generator.getShadowMap());
  115974. effect.setTexture("positionSampler", geometry.textures[2]);
  115975. effect.setColor3("sunColor", _this.sourceLight.diffuse);
  115976. effect.setVector3("sunDirection", _this.sourceLight.getShadowDirection());
  115977. effect.setVector3("cameraPosition", _this._scene.activeCamera.globalPosition);
  115978. effect.setMatrix("shadowViewProjection", generator.getTransformMatrix());
  115979. effect.setFloat("scatteringCoefficient", _this.volumetricLightCoefficient);
  115980. effect.setFloat("scatteringPower", _this.volumetricLightPower);
  115981. depthValues.x = _this.sourceLight.getDepthMinZ(_this._scene.activeCamera);
  115982. depthValues.y = _this.sourceLight.getDepthMaxZ(_this._scene.activeCamera);
  115983. effect.setVector2("depthValues", depthValues);
  115984. }
  115985. };
  115986. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLS", function () { return _this.volumetricLightPostProcess; }, true));
  115987. // Smooth
  115988. this._createBlurPostProcesses(scene, ratio / 4, 0, "volumetricLightBlurScale");
  115989. // Merge
  115990. 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");
  115991. this.volumetricLightMergePostProces.onApply = function (effect) {
  115992. effect.setTextureFromPostProcess("originalSampler", _this._bloomEnabled ? _this.textureAdderFinalPostProcess : _this.originalPostProcess);
  115993. _this._currentDepthOfFieldSource = _this.volumetricLightFinalPostProcess;
  115994. };
  115995. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRVLSMerge", function () { return _this.volumetricLightMergePostProces; }, true));
  115996. };
  115997. // Create luminance
  115998. StandardRenderingPipeline.prototype._createLuminancePostProcesses = function (scene, textureType) {
  115999. var _this = this;
  116000. // Create luminance
  116001. var size = Math.pow(3, StandardRenderingPipeline.LuminanceSteps);
  116002. 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);
  116003. var offsets = [];
  116004. this.luminancePostProcess.onApply = function (effect) {
  116005. var sU = (1.0 / _this.luminancePostProcess.width);
  116006. var sV = (1.0 / _this.luminancePostProcess.height);
  116007. offsets[0] = -0.5 * sU;
  116008. offsets[1] = 0.5 * sV;
  116009. offsets[2] = 0.5 * sU;
  116010. offsets[3] = 0.5 * sV;
  116011. offsets[4] = -0.5 * sU;
  116012. offsets[5] = -0.5 * sV;
  116013. offsets[6] = 0.5 * sU;
  116014. offsets[7] = -0.5 * sV;
  116015. effect.setArray2("lumOffsets", offsets);
  116016. };
  116017. // Add to pipeline
  116018. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminance", function () { return _this.luminancePostProcess; }, true));
  116019. // Create down sample luminance
  116020. for (var i = StandardRenderingPipeline.LuminanceSteps - 1; i >= 0; i--) {
  116021. var size = Math.pow(3, i);
  116022. var defines = "#define LUMINANCE_DOWN_SAMPLE\n";
  116023. if (i === 0) {
  116024. defines += "#define FINAL_DOWN_SAMPLER";
  116025. }
  116026. 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);
  116027. this.luminanceDownSamplePostProcesses.push(postProcess);
  116028. }
  116029. // Create callbacks and add effects
  116030. var lastLuminance = this.luminancePostProcess;
  116031. this.luminanceDownSamplePostProcesses.forEach(function (pp, index) {
  116032. var downSampleOffsets = new Array(18);
  116033. pp.onApply = function (effect) {
  116034. if (!lastLuminance) {
  116035. return;
  116036. }
  116037. var id = 0;
  116038. for (var x = -1; x < 2; x++) {
  116039. for (var y = -1; y < 2; y++) {
  116040. downSampleOffsets[id] = x / lastLuminance.width;
  116041. downSampleOffsets[id + 1] = y / lastLuminance.height;
  116042. id += 2;
  116043. }
  116044. }
  116045. effect.setArray2("dsOffsets", downSampleOffsets);
  116046. effect.setFloat("halfDestPixelSize", 0.5 / lastLuminance.width);
  116047. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  116048. lastLuminance = _this.luminancePostProcess;
  116049. }
  116050. else {
  116051. lastLuminance = pp;
  116052. }
  116053. };
  116054. if (index === _this.luminanceDownSamplePostProcesses.length - 1) {
  116055. pp.onAfterRender = function () {
  116056. var pixel = scene.getEngine().readPixels(0, 0, 1, 1);
  116057. 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);
  116058. _this._hdrCurrentLuminance = (pixel[0] * bit_shift.x + pixel[1] * bit_shift.y + pixel[2] * bit_shift.z + pixel[3] * bit_shift.w) / 100.0;
  116059. };
  116060. }
  116061. _this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLuminanceDownSample" + index, function () { return pp; }, true));
  116062. });
  116063. };
  116064. // Create HDR post-process
  116065. StandardRenderingPipeline.prototype._createHdrPostProcess = function (scene, ratio) {
  116066. var _this = this;
  116067. this.hdrPostProcess = new _PostProcesses_postProcess__WEBPACK_IMPORTED_MODULE_6__["PostProcess"]("HDR", "standard", ["averageLuminance"], ["textureAdderSampler"], ratio, null, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_5__["Texture"].BILINEAR_SAMPLINGMODE, scene.getEngine(), false, "#define HDR", _Engines_constants__WEBPACK_IMPORTED_MODULE_11__["Constants"].TEXTURETYPE_UNSIGNED_INT);
  116068. var outputLiminance = 1;
  116069. var time = 0;
  116070. var lastTime = 0;
  116071. this.hdrPostProcess.onApply = function (effect) {
  116072. effect.setTextureFromPostProcess("textureAdderSampler", _this._currentDepthOfFieldSource);
  116073. time += scene.getEngine().getDeltaTime();
  116074. if (outputLiminance < 0) {
  116075. outputLiminance = _this._hdrCurrentLuminance;
  116076. }
  116077. else {
  116078. var dt = (lastTime - time) / 1000.0;
  116079. if (_this._hdrCurrentLuminance < outputLiminance + _this.hdrDecreaseRate * dt) {
  116080. outputLiminance += _this.hdrDecreaseRate * dt;
  116081. }
  116082. else if (_this._hdrCurrentLuminance > outputLiminance - _this.hdrIncreaseRate * dt) {
  116083. outputLiminance -= _this.hdrIncreaseRate * dt;
  116084. }
  116085. else {
  116086. outputLiminance = _this._hdrCurrentLuminance;
  116087. }
  116088. }
  116089. outputLiminance = _Maths_math_scalar__WEBPACK_IMPORTED_MODULE_4__["Scalar"].Clamp(outputLiminance, _this.hdrMinimumLuminance, 1e20);
  116090. effect.setFloat("averageLuminance", outputLiminance);
  116091. lastTime = time;
  116092. _this._currentDepthOfFieldSource = _this.hdrFinalPostProcess;
  116093. };
  116094. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDR", function () { return _this.hdrPostProcess; }, true));
  116095. };
  116096. // Create lens flare post-process
  116097. StandardRenderingPipeline.prototype._createLensFlarePostProcess = function (scene, ratio) {
  116098. var _this = this;
  116099. 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);
  116100. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlare", function () { return _this.lensFlarePostProcess; }, true));
  116101. this._createBlurPostProcesses(scene, ratio / 4, 2);
  116102. 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);
  116103. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRLensFlareCompose", function () { return _this.lensFlareComposePostProcess; }, true));
  116104. var resolution = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](0, 0);
  116105. // Lens flare
  116106. this.lensFlarePostProcess.onApply = function (effect) {
  116107. effect.setTextureFromPostProcess("textureSampler", _this._bloomEnabled ? _this.blurHPostProcesses[0] : _this.originalPostProcess);
  116108. effect.setTexture("lensColorSampler", _this.lensColorTexture);
  116109. effect.setFloat("strength", _this.lensFlareStrength);
  116110. effect.setFloat("ghostDispersal", _this.lensFlareGhostDispersal);
  116111. effect.setFloat("haloWidth", _this.lensFlareHaloWidth);
  116112. // Shift
  116113. resolution.x = _this.lensFlarePostProcess.width;
  116114. resolution.y = _this.lensFlarePostProcess.height;
  116115. effect.setVector2("resolution", resolution);
  116116. effect.setFloat("distortionStrength", _this.lensFlareDistortionStrength);
  116117. };
  116118. // Compose
  116119. 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);
  116120. 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);
  116121. this.lensFlareComposePostProcess.onApply = function (effect) {
  116122. if (!_this._scene.activeCamera) {
  116123. return;
  116124. }
  116125. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  116126. effect.setTexture("lensDirtSampler", _this.lensFlareDirtTexture);
  116127. effect.setTexture("lensStarSampler", _this.lensStarTexture);
  116128. // Lens start rotation matrix
  116129. var camerax = _this._scene.activeCamera.getViewMatrix().getRow(0);
  116130. var cameraz = _this._scene.activeCamera.getViewMatrix().getRow(2);
  116131. 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));
  116132. camRot *= 4.0;
  116133. 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);
  116134. var lensStarMatrix = scaleBias2.multiply(starRotation).multiply(scaleBias1);
  116135. effect.setMatrix("lensStarMatrix", lensStarMatrix);
  116136. _this._currentDepthOfFieldSource = _this.lensFlareFinalPostProcess;
  116137. };
  116138. };
  116139. // Create depth-of-field post-process
  116140. StandardRenderingPipeline.prototype._createDepthOfFieldPostProcess = function (scene, ratio) {
  116141. var _this = this;
  116142. 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);
  116143. this.depthOfFieldPostProcess.onApply = function (effect) {
  116144. effect.setTextureFromPostProcess("otherSampler", _this._currentDepthOfFieldSource);
  116145. effect.setTexture("depthSampler", _this._getDepthTexture());
  116146. effect.setFloat("distance", _this.depthOfFieldDistance);
  116147. };
  116148. // Add to pipeline
  116149. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRDepthOfField", function () { return _this.depthOfFieldPostProcess; }, true));
  116150. };
  116151. // Create motion blur post-process
  116152. StandardRenderingPipeline.prototype._createMotionBlurPostProcess = function (scene, ratio) {
  116153. var _this = this;
  116154. 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);
  116155. var motionScale = 0;
  116156. var prevViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  116157. var invViewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  116158. var viewProjection = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  116159. var screenSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  116160. this.motionBlurPostProcess.onApply = function (effect) {
  116161. viewProjection = scene.getProjectionMatrix().multiply(scene.getViewMatrix());
  116162. viewProjection.invertToRef(invViewProjection);
  116163. effect.setMatrix("inverseViewProjection", invViewProjection);
  116164. effect.setMatrix("prevViewProjection", prevViewProjection);
  116165. prevViewProjection = viewProjection;
  116166. screenSize.x = _this.motionBlurPostProcess.width;
  116167. screenSize.y = _this.motionBlurPostProcess.height;
  116168. effect.setVector2("screenSize", screenSize);
  116169. motionScale = scene.getEngine().getFps() / 60.0;
  116170. effect.setFloat("motionScale", motionScale);
  116171. effect.setFloat("motionStrength", _this.motionStrength);
  116172. effect.setTexture("depthSampler", _this._getDepthTexture());
  116173. };
  116174. this.addEffect(new _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_8__["PostProcessRenderEffect"](scene.getEngine(), "HDRMotionBlur", function () { return _this.motionBlurPostProcess; }, true));
  116175. };
  116176. StandardRenderingPipeline.prototype._getDepthTexture = function () {
  116177. if (this._scene.getEngine().getCaps().drawBuffersExtension) {
  116178. var renderer = this._scene.enableGeometryBufferRenderer();
  116179. return renderer.getGBuffer().textures[0];
  116180. }
  116181. return this._scene.enableDepthRenderer().getDepthMap();
  116182. };
  116183. StandardRenderingPipeline.prototype._disposePostProcesses = function () {
  116184. for (var i = 0; i < this._cameras.length; i++) {
  116185. var camera = this._cameras[i];
  116186. if (this.originalPostProcess) {
  116187. this.originalPostProcess.dispose(camera);
  116188. }
  116189. if (this.downSampleX4PostProcess) {
  116190. this.downSampleX4PostProcess.dispose(camera);
  116191. }
  116192. if (this.brightPassPostProcess) {
  116193. this.brightPassPostProcess.dispose(camera);
  116194. }
  116195. if (this.textureAdderPostProcess) {
  116196. this.textureAdderPostProcess.dispose(camera);
  116197. }
  116198. if (this.textureAdderFinalPostProcess) {
  116199. this.textureAdderFinalPostProcess.dispose(camera);
  116200. }
  116201. if (this.volumetricLightPostProcess) {
  116202. this.volumetricLightPostProcess.dispose(camera);
  116203. }
  116204. if (this.volumetricLightSmoothXPostProcess) {
  116205. this.volumetricLightSmoothXPostProcess.dispose(camera);
  116206. }
  116207. if (this.volumetricLightSmoothYPostProcess) {
  116208. this.volumetricLightSmoothYPostProcess.dispose(camera);
  116209. }
  116210. if (this.volumetricLightMergePostProces) {
  116211. this.volumetricLightMergePostProces.dispose(camera);
  116212. }
  116213. if (this.volumetricLightFinalPostProcess) {
  116214. this.volumetricLightFinalPostProcess.dispose(camera);
  116215. }
  116216. if (this.lensFlarePostProcess) {
  116217. this.lensFlarePostProcess.dispose(camera);
  116218. }
  116219. if (this.lensFlareComposePostProcess) {
  116220. this.lensFlareComposePostProcess.dispose(camera);
  116221. }
  116222. for (var j = 0; j < this.luminanceDownSamplePostProcesses.length; j++) {
  116223. this.luminanceDownSamplePostProcesses[j].dispose(camera);
  116224. }
  116225. if (this.luminancePostProcess) {
  116226. this.luminancePostProcess.dispose(camera);
  116227. }
  116228. if (this.hdrPostProcess) {
  116229. this.hdrPostProcess.dispose(camera);
  116230. }
  116231. if (this.hdrFinalPostProcess) {
  116232. this.hdrFinalPostProcess.dispose(camera);
  116233. }
  116234. if (this.depthOfFieldPostProcess) {
  116235. this.depthOfFieldPostProcess.dispose(camera);
  116236. }
  116237. if (this.motionBlurPostProcess) {
  116238. this.motionBlurPostProcess.dispose(camera);
  116239. }
  116240. if (this.fxaaPostProcess) {
  116241. this.fxaaPostProcess.dispose(camera);
  116242. }
  116243. for (var j = 0; j < this.blurHPostProcesses.length; j++) {
  116244. this.blurHPostProcesses[j].dispose(camera);
  116245. }
  116246. for (var j = 0; j < this.blurVPostProcesses.length; j++) {
  116247. this.blurVPostProcesses[j].dispose(camera);
  116248. }
  116249. }
  116250. this.originalPostProcess = null;
  116251. this.downSampleX4PostProcess = null;
  116252. this.brightPassPostProcess = null;
  116253. this.textureAdderPostProcess = null;
  116254. this.textureAdderFinalPostProcess = null;
  116255. this.volumetricLightPostProcess = null;
  116256. this.volumetricLightSmoothXPostProcess = null;
  116257. this.volumetricLightSmoothYPostProcess = null;
  116258. this.volumetricLightMergePostProces = null;
  116259. this.volumetricLightFinalPostProcess = null;
  116260. this.lensFlarePostProcess = null;
  116261. this.lensFlareComposePostProcess = null;
  116262. this.luminancePostProcess = null;
  116263. this.hdrPostProcess = null;
  116264. this.hdrFinalPostProcess = null;
  116265. this.depthOfFieldPostProcess = null;
  116266. this.motionBlurPostProcess = null;
  116267. this.fxaaPostProcess = null;
  116268. this.luminanceDownSamplePostProcesses = [];
  116269. this.blurHPostProcesses = [];
  116270. this.blurVPostProcesses = [];
  116271. };
  116272. /**
  116273. * Dispose of the pipeline and stop all post processes
  116274. */
  116275. StandardRenderingPipeline.prototype.dispose = function () {
  116276. this._disposePostProcesses();
  116277. this._scene.postProcessRenderPipelineManager.detachCamerasFromRenderPipeline(this._name, this._cameras);
  116278. _super.prototype.dispose.call(this);
  116279. };
  116280. /**
  116281. * Serialize the rendering pipeline (Used when exporting)
  116282. * @returns the serialized object
  116283. */
  116284. StandardRenderingPipeline.prototype.serialize = function () {
  116285. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this);
  116286. if (this.sourceLight) {
  116287. serializationObject.sourceLightId = this.sourceLight.id;
  116288. }
  116289. serializationObject.customType = "StandardRenderingPipeline";
  116290. return serializationObject;
  116291. };
  116292. /**
  116293. * Parse the serialized pipeline
  116294. * @param source Source pipeline.
  116295. * @param scene The scene to load the pipeline to.
  116296. * @param rootUrl The URL of the serialized pipeline.
  116297. * @returns An instantiated pipeline from the serialized object.
  116298. */
  116299. StandardRenderingPipeline.Parse = function (source, scene, rootUrl) {
  116300. var p = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return new StandardRenderingPipeline(source._name, scene, source._ratio); }, source, scene, rootUrl);
  116301. if (source.sourceLightId) {
  116302. p.sourceLight = scene.getLightByID(source.sourceLightId);
  116303. }
  116304. return p;
  116305. };
  116306. /**
  116307. * Luminance steps
  116308. */
  116309. StandardRenderingPipeline.LuminanceSteps = 6;
  116310. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116311. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116312. ], StandardRenderingPipeline.prototype, "brightThreshold", void 0);
  116313. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116314. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116315. ], StandardRenderingPipeline.prototype, "blurWidth", void 0);
  116316. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116317. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116318. ], StandardRenderingPipeline.prototype, "horizontalBlur", void 0);
  116319. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116320. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116321. ], StandardRenderingPipeline.prototype, "exposure", void 0);
  116322. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116323. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensTexture")
  116324. ], StandardRenderingPipeline.prototype, "lensTexture", void 0);
  116325. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116326. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116327. ], StandardRenderingPipeline.prototype, "volumetricLightCoefficient", void 0);
  116328. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116329. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116330. ], StandardRenderingPipeline.prototype, "volumetricLightPower", void 0);
  116331. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116332. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116333. ], StandardRenderingPipeline.prototype, "volumetricLightBlurScale", void 0);
  116334. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116335. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116336. ], StandardRenderingPipeline.prototype, "hdrMinimumLuminance", void 0);
  116337. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116338. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116339. ], StandardRenderingPipeline.prototype, "hdrDecreaseRate", void 0);
  116340. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116341. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116342. ], StandardRenderingPipeline.prototype, "hdrIncreaseRate", void 0);
  116343. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116344. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensColorTexture")
  116345. ], StandardRenderingPipeline.prototype, "lensColorTexture", void 0);
  116346. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116347. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116348. ], StandardRenderingPipeline.prototype, "lensFlareStrength", void 0);
  116349. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116350. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116351. ], StandardRenderingPipeline.prototype, "lensFlareGhostDispersal", void 0);
  116352. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116353. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116354. ], StandardRenderingPipeline.prototype, "lensFlareHaloWidth", void 0);
  116355. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116356. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116357. ], StandardRenderingPipeline.prototype, "lensFlareDistortionStrength", void 0);
  116358. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116359. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensStarTexture")
  116360. ], StandardRenderingPipeline.prototype, "lensStarTexture", void 0);
  116361. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116362. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsTexture"])("lensFlareDirtTexture")
  116363. ], StandardRenderingPipeline.prototype, "lensFlareDirtTexture", void 0);
  116364. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116365. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116366. ], StandardRenderingPipeline.prototype, "depthOfFieldDistance", void 0);
  116367. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116368. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116369. ], StandardRenderingPipeline.prototype, "depthOfFieldBlurWidth", void 0);
  116370. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116371. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116372. ], StandardRenderingPipeline.prototype, "motionStrength", void 0);
  116373. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116374. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116375. ], StandardRenderingPipeline.prototype, "_ratio", void 0);
  116376. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116377. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116378. ], StandardRenderingPipeline.prototype, "BloomEnabled", null);
  116379. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116380. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116381. ], StandardRenderingPipeline.prototype, "DepthOfFieldEnabled", null);
  116382. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116383. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116384. ], StandardRenderingPipeline.prototype, "LensFlareEnabled", null);
  116385. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116386. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116387. ], StandardRenderingPipeline.prototype, "HDREnabled", null);
  116388. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116389. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116390. ], StandardRenderingPipeline.prototype, "VLSEnabled", null);
  116391. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116392. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116393. ], StandardRenderingPipeline.prototype, "MotionBlurEnabled", null);
  116394. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116395. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116396. ], StandardRenderingPipeline.prototype, "fxaaEnabled", null);
  116397. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116398. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116399. ], StandardRenderingPipeline.prototype, "volumetricLightStepsCount", null);
  116400. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116401. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116402. ], StandardRenderingPipeline.prototype, "motionBlurSamples", null);
  116403. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116404. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  116405. ], StandardRenderingPipeline.prototype, "samples", null);
  116406. return StandardRenderingPipeline;
  116407. }(_PostProcesses_RenderPipeline_postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_7__["PostProcessRenderPipeline"]));
  116408. _Misc_typeStore__WEBPACK_IMPORTED_MODULE_12__["_TypeStore"].RegisteredTypes["BABYLON.StandardRenderingPipeline"] = StandardRenderingPipeline;
  116409. /***/ }),
  116410. /***/ "./PostProcesses/RenderPipeline/index.ts":
  116411. /*!***********************************************!*\
  116412. !*** ./PostProcesses/RenderPipeline/index.ts ***!
  116413. \***********************************************/
  116414. /*! exports provided: PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  116415. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116416. "use strict";
  116417. __webpack_require__.r(__webpack_exports__);
  116418. /* harmony import */ var _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Pipelines/index */ "./PostProcesses/RenderPipeline/Pipelines/index.ts");
  116419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["DefaultRenderingPipeline"]; });
  116420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["LensRenderingPipeline"]; });
  116421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAO2RenderingPipeline"]; });
  116422. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["SSAORenderingPipeline"]; });
  116423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _Pipelines_index__WEBPACK_IMPORTED_MODULE_0__["StandardRenderingPipeline"]; });
  116424. /* harmony import */ var _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  116425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]; });
  116426. /* harmony import */ var _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcessRenderPipeline */ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts");
  116427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _postProcessRenderPipeline__WEBPACK_IMPORTED_MODULE_2__["PostProcessRenderPipeline"]; });
  116428. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderPipelineManager"]; });
  116430. /* harmony import */ var _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./postProcessRenderPipelineManagerSceneComponent */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts");
  116431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _postProcessRenderPipelineManagerSceneComponent__WEBPACK_IMPORTED_MODULE_4__["PostProcessRenderPipelineManagerSceneComponent"]; });
  116432. /***/ }),
  116433. /***/ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts":
  116434. /*!*****************************************************************!*\
  116435. !*** ./PostProcesses/RenderPipeline/postProcessRenderEffect.ts ***!
  116436. \*****************************************************************/
  116437. /*! exports provided: PostProcessRenderEffect */
  116438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116439. "use strict";
  116440. __webpack_require__.r(__webpack_exports__);
  116441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return PostProcessRenderEffect; });
  116442. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  116443. /**
  116444. * This represents a set of one or more post processes in Babylon.
  116445. * A post process can be used to apply a shader to a texture after it is rendered.
  116446. * @example https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116447. */
  116448. var PostProcessRenderEffect = /** @class */ (function () {
  116449. /**
  116450. * Instantiates a post process render effect.
  116451. * A post process can be used to apply a shader to a texture after it is rendered.
  116452. * @param engine The engine the effect is tied to
  116453. * @param name The name of the effect
  116454. * @param getPostProcesses A function that returns a set of post processes which the effect will run in order to be run.
  116455. * @param singleInstance False if this post process can be run on multiple cameras. (default: true)
  116456. */
  116457. function PostProcessRenderEffect(engine, name, getPostProcesses, singleInstance) {
  116458. this._name = name;
  116459. this._singleInstance = singleInstance || true;
  116460. this._getPostProcesses = getPostProcesses;
  116461. this._cameras = {};
  116462. this._indicesForCamera = {};
  116463. this._postProcesses = {};
  116464. }
  116465. Object.defineProperty(PostProcessRenderEffect.prototype, "isSupported", {
  116466. /**
  116467. * Checks if all the post processes in the effect are supported.
  116468. */
  116469. get: function () {
  116470. for (var index in this._postProcesses) {
  116471. if (this._postProcesses.hasOwnProperty(index)) {
  116472. var pps = this._postProcesses[index];
  116473. for (var ppIndex = 0; ppIndex < pps.length; ppIndex++) {
  116474. if (!pps[ppIndex].isSupported) {
  116475. return false;
  116476. }
  116477. }
  116478. }
  116479. }
  116480. return true;
  116481. },
  116482. enumerable: true,
  116483. configurable: true
  116484. });
  116485. /**
  116486. * Updates the current state of the effect
  116487. * @hidden
  116488. */
  116489. PostProcessRenderEffect.prototype._update = function () {
  116490. };
  116491. /**
  116492. * Attaches the effect on cameras
  116493. * @param cameras The camera to attach to.
  116494. * @hidden
  116495. */
  116496. PostProcessRenderEffect.prototype._attachCameras = function (cameras) {
  116497. var _this = this;
  116498. var cameraKey;
  116499. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  116500. if (!cams) {
  116501. return;
  116502. }
  116503. for (var i = 0; i < cams.length; i++) {
  116504. var camera = cams[i];
  116505. var cameraName = camera.name;
  116506. if (this._singleInstance) {
  116507. cameraKey = 0;
  116508. }
  116509. else {
  116510. cameraKey = cameraName;
  116511. }
  116512. if (!this._postProcesses[cameraKey]) {
  116513. var postProcess = this._getPostProcesses();
  116514. if (postProcess) {
  116515. this._postProcesses[cameraKey] = Array.isArray(postProcess) ? postProcess : [postProcess];
  116516. }
  116517. }
  116518. if (!this._indicesForCamera[cameraName]) {
  116519. this._indicesForCamera[cameraName] = [];
  116520. }
  116521. this._postProcesses[cameraKey].forEach(function (postProcess) {
  116522. var index = camera.attachPostProcess(postProcess);
  116523. _this._indicesForCamera[cameraName].push(index);
  116524. });
  116525. if (!this._cameras[cameraName]) {
  116526. this._cameras[cameraName] = camera;
  116527. }
  116528. }
  116529. };
  116530. /**
  116531. * Detatches the effect on cameras
  116532. * @param cameras The camera to detatch from.
  116533. * @hidden
  116534. */
  116535. PostProcessRenderEffect.prototype._detachCameras = function (cameras) {
  116536. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  116537. if (!cams) {
  116538. return;
  116539. }
  116540. for (var i = 0; i < cams.length; i++) {
  116541. var camera = cams[i];
  116542. var cameraName = camera.name;
  116543. var postProcesses = this._postProcesses[this._singleInstance ? 0 : cameraName];
  116544. if (postProcesses) {
  116545. postProcesses.forEach(function (postProcess) {
  116546. camera.detachPostProcess(postProcess);
  116547. });
  116548. }
  116549. if (this._cameras[cameraName]) {
  116550. this._cameras[cameraName] = null;
  116551. }
  116552. }
  116553. };
  116554. /**
  116555. * Enables the effect on given cameras
  116556. * @param cameras The camera to enable.
  116557. * @hidden
  116558. */
  116559. PostProcessRenderEffect.prototype._enable = function (cameras) {
  116560. var _this = this;
  116561. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  116562. if (!cams) {
  116563. return;
  116564. }
  116565. for (var i = 0; i < cams.length; i++) {
  116566. var camera = cams[i];
  116567. var cameraName = camera.name;
  116568. for (var j = 0; j < this._indicesForCamera[cameraName].length; j++) {
  116569. if (camera._postProcesses[this._indicesForCamera[cameraName][j]] === undefined || camera._postProcesses[this._indicesForCamera[cameraName][j]] === null) {
  116570. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  116571. cams[i].attachPostProcess(postProcess, _this._indicesForCamera[cameraName][j]);
  116572. });
  116573. }
  116574. }
  116575. }
  116576. };
  116577. /**
  116578. * Disables the effect on the given cameras
  116579. * @param cameras The camera to disable.
  116580. * @hidden
  116581. */
  116582. PostProcessRenderEffect.prototype._disable = function (cameras) {
  116583. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].MakeArray(cameras || this._cameras);
  116584. if (!cams) {
  116585. return;
  116586. }
  116587. for (var i = 0; i < cams.length; i++) {
  116588. var camera = cams[i];
  116589. var cameraName = camera.name;
  116590. this._postProcesses[this._singleInstance ? 0 : cameraName].forEach(function (postProcess) {
  116591. camera.detachPostProcess(postProcess);
  116592. });
  116593. }
  116594. };
  116595. /**
  116596. * Gets a list of the post processes contained in the effect.
  116597. * @param camera The camera to get the post processes on.
  116598. * @returns The list of the post processes in the effect.
  116599. */
  116600. PostProcessRenderEffect.prototype.getPostProcesses = function (camera) {
  116601. if (this._singleInstance) {
  116602. return this._postProcesses[0];
  116603. }
  116604. else {
  116605. if (!camera) {
  116606. return null;
  116607. }
  116608. return this._postProcesses[camera.name];
  116609. }
  116610. };
  116611. return PostProcessRenderEffect;
  116612. }());
  116613. /***/ }),
  116614. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts":
  116615. /*!*******************************************************************!*\
  116616. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipeline.ts ***!
  116617. \*******************************************************************/
  116618. /*! exports provided: PostProcessRenderPipeline */
  116619. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116620. "use strict";
  116621. __webpack_require__.r(__webpack_exports__);
  116622. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return PostProcessRenderPipeline; });
  116623. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  116624. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../../Misc/tools */ "./Misc/tools.ts");
  116625. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../Misc/decorators */ "./Misc/decorators.ts");
  116626. /**
  116627. * PostProcessRenderPipeline
  116628. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116629. */
  116630. var PostProcessRenderPipeline = /** @class */ (function () {
  116631. /**
  116632. * Initializes a PostProcessRenderPipeline
  116633. * @param engine engine to add the pipeline to
  116634. * @param name name of the pipeline
  116635. */
  116636. function PostProcessRenderPipeline(engine, name) {
  116637. this.engine = engine;
  116638. this._name = name;
  116639. this._renderEffects = {};
  116640. this._renderEffectsForIsolatedPass = new Array();
  116641. this._cameras = [];
  116642. }
  116643. Object.defineProperty(PostProcessRenderPipeline.prototype, "name", {
  116644. /**
  116645. * Gets pipeline name
  116646. */
  116647. get: function () {
  116648. return this._name;
  116649. },
  116650. enumerable: true,
  116651. configurable: true
  116652. });
  116653. /**
  116654. * Gets the class name
  116655. * @returns "PostProcessRenderPipeline"
  116656. */
  116657. PostProcessRenderPipeline.prototype.getClassName = function () {
  116658. return "PostProcessRenderPipeline";
  116659. };
  116660. Object.defineProperty(PostProcessRenderPipeline.prototype, "isSupported", {
  116661. /**
  116662. * If all the render effects in the pipeline are supported
  116663. */
  116664. get: function () {
  116665. for (var renderEffectName in this._renderEffects) {
  116666. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116667. if (!this._renderEffects[renderEffectName].isSupported) {
  116668. return false;
  116669. }
  116670. }
  116671. }
  116672. return true;
  116673. },
  116674. enumerable: true,
  116675. configurable: true
  116676. });
  116677. /**
  116678. * Adds an effect to the pipeline
  116679. * @param renderEffect the effect to add
  116680. */
  116681. PostProcessRenderPipeline.prototype.addEffect = function (renderEffect) {
  116682. this._renderEffects[renderEffect._name] = renderEffect;
  116683. };
  116684. // private
  116685. /** @hidden */
  116686. PostProcessRenderPipeline.prototype._rebuild = function () {
  116687. };
  116688. /** @hidden */
  116689. PostProcessRenderPipeline.prototype._enableEffect = function (renderEffectName, cameras) {
  116690. var renderEffects = this._renderEffects[renderEffectName];
  116691. if (!renderEffects) {
  116692. return;
  116693. }
  116694. renderEffects._enable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  116695. };
  116696. /** @hidden */
  116697. PostProcessRenderPipeline.prototype._disableEffect = function (renderEffectName, cameras) {
  116698. var renderEffects = this._renderEffects[renderEffectName];
  116699. if (!renderEffects) {
  116700. return;
  116701. }
  116702. renderEffects._disable(_Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras));
  116703. };
  116704. /** @hidden */
  116705. PostProcessRenderPipeline.prototype._attachCameras = function (cameras, unique) {
  116706. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116707. if (!cams) {
  116708. return;
  116709. }
  116710. var indicesToDelete = [];
  116711. var i;
  116712. for (i = 0; i < cams.length; i++) {
  116713. var camera = cams[i];
  116714. var cameraName = camera.name;
  116715. if (this._cameras.indexOf(camera) === -1) {
  116716. this._cameras[cameraName] = camera;
  116717. }
  116718. else if (unique) {
  116719. indicesToDelete.push(i);
  116720. }
  116721. }
  116722. for (i = 0; i < indicesToDelete.length; i++) {
  116723. cameras.splice(indicesToDelete[i], 1);
  116724. }
  116725. for (var renderEffectName in this._renderEffects) {
  116726. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116727. this._renderEffects[renderEffectName]._attachCameras(cams);
  116728. }
  116729. }
  116730. };
  116731. /** @hidden */
  116732. PostProcessRenderPipeline.prototype._detachCameras = function (cameras) {
  116733. var cams = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].MakeArray(cameras || this._cameras);
  116734. if (!cams) {
  116735. return;
  116736. }
  116737. for (var renderEffectName in this._renderEffects) {
  116738. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116739. this._renderEffects[renderEffectName]._detachCameras(cams);
  116740. }
  116741. }
  116742. for (var i = 0; i < cams.length; i++) {
  116743. this._cameras.splice(this._cameras.indexOf(cams[i]), 1);
  116744. }
  116745. };
  116746. /** @hidden */
  116747. PostProcessRenderPipeline.prototype._update = function () {
  116748. for (var renderEffectName in this._renderEffects) {
  116749. if (this._renderEffects.hasOwnProperty(renderEffectName)) {
  116750. this._renderEffects[renderEffectName]._update();
  116751. }
  116752. }
  116753. for (var i = 0; i < this._cameras.length; i++) {
  116754. var cameraName = this._cameras[i].name;
  116755. if (this._renderEffectsForIsolatedPass[cameraName]) {
  116756. this._renderEffectsForIsolatedPass[cameraName]._update();
  116757. }
  116758. }
  116759. };
  116760. /** @hidden */
  116761. PostProcessRenderPipeline.prototype._reset = function () {
  116762. this._renderEffects = {};
  116763. this._renderEffectsForIsolatedPass = new Array();
  116764. };
  116765. PostProcessRenderPipeline.prototype._enableMSAAOnFirstPostProcess = function (sampleCount) {
  116766. // 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)
  116767. var effectKeys = Object.keys(this._renderEffects);
  116768. if (this.engine.webGLVersion >= 2 && effectKeys.length > 0) {
  116769. var postProcesses = this._renderEffects[effectKeys[0]].getPostProcesses();
  116770. if (postProcesses) {
  116771. postProcesses[0].samples = sampleCount;
  116772. return true;
  116773. }
  116774. }
  116775. return false;
  116776. };
  116777. /**
  116778. * Disposes of the pipeline
  116779. */
  116780. PostProcessRenderPipeline.prototype.dispose = function () {
  116781. // Must be implemented by children
  116782. };
  116783. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  116784. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  116785. ], PostProcessRenderPipeline.prototype, "_name", void 0);
  116786. return PostProcessRenderPipeline;
  116787. }());
  116788. /***/ }),
  116789. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts":
  116790. /*!**************************************************************************!*\
  116791. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts ***!
  116792. \**************************************************************************/
  116793. /*! exports provided: PostProcessRenderPipelineManager */
  116794. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116795. "use strict";
  116796. __webpack_require__.r(__webpack_exports__);
  116797. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return PostProcessRenderPipelineManager; });
  116798. /**
  116799. * PostProcessRenderPipelineManager class
  116800. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116801. */
  116802. var PostProcessRenderPipelineManager = /** @class */ (function () {
  116803. /**
  116804. * Initializes a PostProcessRenderPipelineManager
  116805. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocessrenderpipeline
  116806. */
  116807. function PostProcessRenderPipelineManager() {
  116808. this._renderPipelines = {};
  116809. }
  116810. Object.defineProperty(PostProcessRenderPipelineManager.prototype, "supportedPipelines", {
  116811. /**
  116812. * Gets the list of supported render pipelines
  116813. */
  116814. get: function () {
  116815. var result = [];
  116816. for (var renderPipelineName in this._renderPipelines) {
  116817. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116818. var pipeline = this._renderPipelines[renderPipelineName];
  116819. if (pipeline.isSupported) {
  116820. result.push(pipeline);
  116821. }
  116822. }
  116823. }
  116824. return result;
  116825. },
  116826. enumerable: true,
  116827. configurable: true
  116828. });
  116829. /**
  116830. * Adds a pipeline to the manager
  116831. * @param renderPipeline The pipeline to add
  116832. */
  116833. PostProcessRenderPipelineManager.prototype.addPipeline = function (renderPipeline) {
  116834. this._renderPipelines[renderPipeline._name] = renderPipeline;
  116835. };
  116836. /**
  116837. * Attaches a camera to the pipeline
  116838. * @param renderPipelineName The name of the pipeline to attach to
  116839. * @param cameras the camera to attach
  116840. * @param unique if the camera can be attached multiple times to the pipeline
  116841. */
  116842. PostProcessRenderPipelineManager.prototype.attachCamerasToRenderPipeline = function (renderPipelineName, cameras, unique) {
  116843. if (unique === void 0) { unique = false; }
  116844. var renderPipeline = this._renderPipelines[renderPipelineName];
  116845. if (!renderPipeline) {
  116846. return;
  116847. }
  116848. renderPipeline._attachCameras(cameras, unique);
  116849. };
  116850. /**
  116851. * Detaches a camera from the pipeline
  116852. * @param renderPipelineName The name of the pipeline to detach from
  116853. * @param cameras the camera to detach
  116854. */
  116855. PostProcessRenderPipelineManager.prototype.detachCamerasFromRenderPipeline = function (renderPipelineName, cameras) {
  116856. var renderPipeline = this._renderPipelines[renderPipelineName];
  116857. if (!renderPipeline) {
  116858. return;
  116859. }
  116860. renderPipeline._detachCameras(cameras);
  116861. };
  116862. /**
  116863. * Enables an effect by name on a pipeline
  116864. * @param renderPipelineName the name of the pipeline to enable the effect in
  116865. * @param renderEffectName the name of the effect to enable
  116866. * @param cameras the cameras that the effect should be enabled on
  116867. */
  116868. PostProcessRenderPipelineManager.prototype.enableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116869. var renderPipeline = this._renderPipelines[renderPipelineName];
  116870. if (!renderPipeline) {
  116871. return;
  116872. }
  116873. renderPipeline._enableEffect(renderEffectName, cameras);
  116874. };
  116875. /**
  116876. * Disables an effect by name on a pipeline
  116877. * @param renderPipelineName the name of the pipeline to disable the effect in
  116878. * @param renderEffectName the name of the effect to disable
  116879. * @param cameras the cameras that the effect should be disabled on
  116880. */
  116881. PostProcessRenderPipelineManager.prototype.disableEffectInPipeline = function (renderPipelineName, renderEffectName, cameras) {
  116882. var renderPipeline = this._renderPipelines[renderPipelineName];
  116883. if (!renderPipeline) {
  116884. return;
  116885. }
  116886. renderPipeline._disableEffect(renderEffectName, cameras);
  116887. };
  116888. /**
  116889. * Updates the state of all contained render pipelines and disposes of any non supported pipelines
  116890. */
  116891. PostProcessRenderPipelineManager.prototype.update = function () {
  116892. for (var renderPipelineName in this._renderPipelines) {
  116893. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116894. var pipeline = this._renderPipelines[renderPipelineName];
  116895. if (!pipeline.isSupported) {
  116896. pipeline.dispose();
  116897. delete this._renderPipelines[renderPipelineName];
  116898. }
  116899. else {
  116900. pipeline._update();
  116901. }
  116902. }
  116903. }
  116904. };
  116905. /** @hidden */
  116906. PostProcessRenderPipelineManager.prototype._rebuild = function () {
  116907. for (var renderPipelineName in this._renderPipelines) {
  116908. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116909. var pipeline = this._renderPipelines[renderPipelineName];
  116910. pipeline._rebuild();
  116911. }
  116912. }
  116913. };
  116914. /**
  116915. * Disposes of the manager and pipelines
  116916. */
  116917. PostProcessRenderPipelineManager.prototype.dispose = function () {
  116918. for (var renderPipelineName in this._renderPipelines) {
  116919. if (this._renderPipelines.hasOwnProperty(renderPipelineName)) {
  116920. var pipeline = this._renderPipelines[renderPipelineName];
  116921. pipeline.dispose();
  116922. }
  116923. }
  116924. };
  116925. return PostProcessRenderPipelineManager;
  116926. }());
  116927. /***/ }),
  116928. /***/ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts":
  116929. /*!****************************************************************************************!*\
  116930. !*** ./PostProcesses/RenderPipeline/postProcessRenderPipelineManagerSceneComponent.ts ***!
  116931. \****************************************************************************************/
  116932. /*! exports provided: PostProcessRenderPipelineManagerSceneComponent */
  116933. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  116934. "use strict";
  116935. __webpack_require__.r(__webpack_exports__);
  116936. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return PostProcessRenderPipelineManagerSceneComponent; });
  116937. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../sceneComponent */ "./sceneComponent.ts");
  116938. /* harmony import */ var _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcessRenderPipelineManager */ "./PostProcesses/RenderPipeline/postProcessRenderPipelineManager.ts");
  116939. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../../scene */ "./scene.ts");
  116940. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype, "postProcessRenderPipelineManager", {
  116941. get: function () {
  116942. if (!this._postProcessRenderPipelineManager) {
  116943. // Register the G Buffer component to the scene.
  116944. var component = this._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER);
  116945. if (!component) {
  116946. component = new PostProcessRenderPipelineManagerSceneComponent(this);
  116947. this._addComponent(component);
  116948. }
  116949. this._postProcessRenderPipelineManager = new _postProcessRenderPipelineManager__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderPipelineManager"]();
  116950. }
  116951. return this._postProcessRenderPipelineManager;
  116952. },
  116953. enumerable: true,
  116954. configurable: true
  116955. });
  116956. /**
  116957. * Defines the Render Pipeline scene component responsible to rendering pipelines
  116958. */
  116959. var PostProcessRenderPipelineManagerSceneComponent = /** @class */ (function () {
  116960. /**
  116961. * Creates a new instance of the component for the given scene
  116962. * @param scene Defines the scene to register the component in
  116963. */
  116964. function PostProcessRenderPipelineManagerSceneComponent(scene) {
  116965. /**
  116966. * The component name helpfull to identify the component in the list of scene components.
  116967. */
  116968. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].NAME_POSTPROCESSRENDERPIPELINEMANAGER;
  116969. this.scene = scene;
  116970. }
  116971. /**
  116972. * Registers the component in a given scene
  116973. */
  116974. PostProcessRenderPipelineManagerSceneComponent.prototype.register = function () {
  116975. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_0__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER, this, this._gatherRenderTargets);
  116976. };
  116977. /**
  116978. * Rebuilds the elements related to this component in case of
  116979. * context lost for instance.
  116980. */
  116981. PostProcessRenderPipelineManagerSceneComponent.prototype.rebuild = function () {
  116982. if (this.scene._postProcessRenderPipelineManager) {
  116983. this.scene._postProcessRenderPipelineManager._rebuild();
  116984. }
  116985. };
  116986. /**
  116987. * Disposes the component and the associated ressources
  116988. */
  116989. PostProcessRenderPipelineManagerSceneComponent.prototype.dispose = function () {
  116990. if (this.scene._postProcessRenderPipelineManager) {
  116991. this.scene._postProcessRenderPipelineManager.dispose();
  116992. }
  116993. };
  116994. PostProcessRenderPipelineManagerSceneComponent.prototype._gatherRenderTargets = function () {
  116995. if (this.scene._postProcessRenderPipelineManager) {
  116996. this.scene._postProcessRenderPipelineManager.update();
  116997. }
  116998. };
  116999. return PostProcessRenderPipelineManagerSceneComponent;
  117000. }());
  117001. /***/ }),
  117002. /***/ "./PostProcesses/anaglyphPostProcess.ts":
  117003. /*!**********************************************!*\
  117004. !*** ./PostProcesses/anaglyphPostProcess.ts ***!
  117005. \**********************************************/
  117006. /*! exports provided: AnaglyphPostProcess */
  117007. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117008. "use strict";
  117009. __webpack_require__.r(__webpack_exports__);
  117010. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return AnaglyphPostProcess; });
  117011. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117012. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117013. /* harmony import */ var _Shaders_anaglyph_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/anaglyph.fragment */ "./Shaders/anaglyph.fragment.ts");
  117014. /**
  117015. * Postprocess used to generate anaglyphic rendering
  117016. */
  117017. var AnaglyphPostProcess = /** @class */ (function (_super) {
  117018. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AnaglyphPostProcess, _super);
  117019. /**
  117020. * Creates a new AnaglyphPostProcess
  117021. * @param name defines postprocess name
  117022. * @param options defines creation options or target ratio scale
  117023. * @param rigCameras defines cameras using this postprocess
  117024. * @param samplingMode defines required sampling mode (BABYLON.Texture.NEAREST_SAMPLINGMODE by default)
  117025. * @param engine defines hosting engine
  117026. * @param reusable defines if the postprocess will be reused multiple times per frame
  117027. */
  117028. function AnaglyphPostProcess(name, options, rigCameras, samplingMode, engine, reusable) {
  117029. var _this = _super.call(this, name, "anaglyph", null, ["leftSampler"], options, rigCameras[1], samplingMode, engine, reusable) || this;
  117030. _this._passedProcess = rigCameras[0]._rigPostProcess;
  117031. _this.onApplyObservable.add(function (effect) {
  117032. effect.setTextureFromPostProcess("leftSampler", _this._passedProcess);
  117033. });
  117034. return _this;
  117035. }
  117036. return AnaglyphPostProcess;
  117037. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117038. /***/ }),
  117039. /***/ "./PostProcesses/blackAndWhitePostProcess.ts":
  117040. /*!***************************************************!*\
  117041. !*** ./PostProcesses/blackAndWhitePostProcess.ts ***!
  117042. \***************************************************/
  117043. /*! exports provided: BlackAndWhitePostProcess */
  117044. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117045. "use strict";
  117046. __webpack_require__.r(__webpack_exports__);
  117047. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return BlackAndWhitePostProcess; });
  117048. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117049. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117050. /* harmony import */ var _Shaders_blackAndWhite_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/blackAndWhite.fragment */ "./Shaders/blackAndWhite.fragment.ts");
  117051. /**
  117052. * Post process used to render in black and white
  117053. */
  117054. var BlackAndWhitePostProcess = /** @class */ (function (_super) {
  117055. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlackAndWhitePostProcess, _super);
  117056. /**
  117057. * Creates a black and white post process
  117058. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#black-and-white
  117059. * @param name The name of the effect.
  117060. * @param options The required width/height ratio to downsize to before computing the render pass.
  117061. * @param camera The camera to apply the render pass to.
  117062. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117063. * @param engine The engine which the post process will be applied. (default: current engine)
  117064. * @param reusable If the post process can be reused on the same frame. (default: false)
  117065. */
  117066. function BlackAndWhitePostProcess(name, options, camera, samplingMode, engine, reusable) {
  117067. var _this = _super.call(this, name, "blackAndWhite", ["degree"], null, options, camera, samplingMode, engine, reusable) || this;
  117068. /**
  117069. * Linear about to convert he result to black and white (default: 1)
  117070. */
  117071. _this.degree = 1;
  117072. _this.onApplyObservable.add(function (effect) {
  117073. effect.setFloat("degree", _this.degree);
  117074. });
  117075. return _this;
  117076. }
  117077. return BlackAndWhitePostProcess;
  117078. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117079. /***/ }),
  117080. /***/ "./PostProcesses/bloomEffect.ts":
  117081. /*!**************************************!*\
  117082. !*** ./PostProcesses/bloomEffect.ts ***!
  117083. \**************************************/
  117084. /*! exports provided: BloomEffect */
  117085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117086. "use strict";
  117087. __webpack_require__.r(__webpack_exports__);
  117088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return BloomEffect; });
  117089. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117090. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117091. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  117092. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117093. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  117094. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117095. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117096. /**
  117097. * The bloom effect spreads bright areas of an image to simulate artifacts seen in cameras
  117098. */
  117099. var BloomEffect = /** @class */ (function (_super) {
  117100. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomEffect, _super);
  117101. /**
  117102. * Creates a new instance of @see BloomEffect
  117103. * @param scene The scene the effect belongs to.
  117104. * @param bloomScale The ratio of the blur texture to the input texture that should be used to compute the bloom.
  117105. * @param bloomKernel The size of the kernel to be used when applying the blur.
  117106. * @param bloomWeight The the strength of bloom.
  117107. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117108. * @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)
  117109. */
  117110. function BloomEffect(scene, bloomScale, bloomWeight, bloomKernel, pipelineTextureType, blockCompilation) {
  117111. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  117112. if (blockCompilation === void 0) { blockCompilation = false; }
  117113. var _this = _super.call(this, scene.getEngine(), "bloom", function () {
  117114. return _this._effects;
  117115. }, true) || this;
  117116. _this.bloomScale = bloomScale;
  117117. /**
  117118. * @hidden Internal
  117119. */
  117120. _this._effects = [];
  117121. _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);
  117122. _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);
  117123. _this._blurX.alwaysForcePOT = true;
  117124. _this._blurX.autoClear = false;
  117125. _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);
  117126. _this._blurY.alwaysForcePOT = true;
  117127. _this._blurY.autoClear = false;
  117128. _this.kernel = bloomKernel;
  117129. _this._effects = [_this._downscale, _this._blurX, _this._blurY];
  117130. _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);
  117131. _this._merge.autoClear = false;
  117132. _this._effects.push(_this._merge);
  117133. return _this;
  117134. }
  117135. Object.defineProperty(BloomEffect.prototype, "threshold", {
  117136. /**
  117137. * The luminance threshold to find bright areas of the image to bloom.
  117138. */
  117139. get: function () {
  117140. return this._downscale.threshold;
  117141. },
  117142. set: function (value) {
  117143. this._downscale.threshold = value;
  117144. },
  117145. enumerable: true,
  117146. configurable: true
  117147. });
  117148. Object.defineProperty(BloomEffect.prototype, "weight", {
  117149. /**
  117150. * The strength of the bloom.
  117151. */
  117152. get: function () {
  117153. return this._merge.weight;
  117154. },
  117155. set: function (value) {
  117156. this._merge.weight = value;
  117157. },
  117158. enumerable: true,
  117159. configurable: true
  117160. });
  117161. Object.defineProperty(BloomEffect.prototype, "kernel", {
  117162. /**
  117163. * Specifies the size of the bloom blur kernel, relative to the final output size
  117164. */
  117165. get: function () {
  117166. return this._blurX.kernel / this.bloomScale;
  117167. },
  117168. set: function (value) {
  117169. this._blurX.kernel = value * this.bloomScale;
  117170. this._blurY.kernel = value * this.bloomScale;
  117171. },
  117172. enumerable: true,
  117173. configurable: true
  117174. });
  117175. /**
  117176. * Disposes each of the internal effects for a given camera.
  117177. * @param camera The camera to dispose the effect on.
  117178. */
  117179. BloomEffect.prototype.disposeEffects = function (camera) {
  117180. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117181. this._effects[effectIndex].dispose(camera);
  117182. }
  117183. };
  117184. /**
  117185. * @hidden Internal
  117186. */
  117187. BloomEffect.prototype._updateEffects = function () {
  117188. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117189. this._effects[effectIndex].updateEffect();
  117190. }
  117191. };
  117192. /**
  117193. * Internal
  117194. * @returns if all the contained post processes are ready.
  117195. * @hidden
  117196. */
  117197. BloomEffect.prototype._isReady = function () {
  117198. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  117199. if (!this._effects[effectIndex].isReady()) {
  117200. return false;
  117201. }
  117202. }
  117203. return true;
  117204. };
  117205. return BloomEffect;
  117206. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_1__["PostProcessRenderEffect"]));
  117207. /***/ }),
  117208. /***/ "./PostProcesses/bloomMergePostProcess.ts":
  117209. /*!************************************************!*\
  117210. !*** ./PostProcesses/bloomMergePostProcess.ts ***!
  117211. \************************************************/
  117212. /*! exports provided: BloomMergePostProcess */
  117213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117214. "use strict";
  117215. __webpack_require__.r(__webpack_exports__);
  117216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return BloomMergePostProcess; });
  117217. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117218. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117219. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117220. /* harmony import */ var _Shaders_bloomMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/bloomMerge.fragment */ "./Shaders/bloomMerge.fragment.ts");
  117221. /**
  117222. * The BloomMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  117223. */
  117224. var BloomMergePostProcess = /** @class */ (function (_super) {
  117225. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BloomMergePostProcess, _super);
  117226. /**
  117227. * Creates a new instance of @see BloomMergePostProcess
  117228. * @param name The name of the effect.
  117229. * @param originalFromInput Post process which's input will be used for the merge.
  117230. * @param blurred Blurred highlights post process which's output will be used.
  117231. * @param weight Weight of the bloom to be added to the original input.
  117232. * @param options The required width/height ratio to downsize to before computing the render pass.
  117233. * @param camera The camera to apply the render pass to.
  117234. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117235. * @param engine The engine which the post process will be applied. (default: current engine)
  117236. * @param reusable If the post process can be reused on the same frame. (default: false)
  117237. * @param textureType Type of textures used when performing the post process. (default: 0)
  117238. * @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)
  117239. */
  117240. function BloomMergePostProcess(name, originalFromInput, blurred,
  117241. /** Weight of the bloom to be added to the original input. */
  117242. weight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117243. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117244. if (blockCompilation === void 0) { blockCompilation = false; }
  117245. var _this = _super.call(this, name, "bloomMerge", ["bloomWeight"], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2", "bloomBlur"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  117246. _this.weight = weight;
  117247. _this.onApplyObservable.add(function (effect) {
  117248. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  117249. effect.setTextureFromPostProcessOutput("bloomBlur", blurred);
  117250. effect.setFloat("bloomWeight", _this.weight);
  117251. });
  117252. if (!blockCompilation) {
  117253. _this.updateEffect();
  117254. }
  117255. return _this;
  117256. }
  117257. return BloomMergePostProcess;
  117258. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117259. /***/ }),
  117260. /***/ "./PostProcesses/blurPostProcess.ts":
  117261. /*!******************************************!*\
  117262. !*** ./PostProcesses/blurPostProcess.ts ***!
  117263. \******************************************/
  117264. /*! exports provided: BlurPostProcess */
  117265. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117266. "use strict";
  117267. __webpack_require__.r(__webpack_exports__);
  117268. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return BlurPostProcess; });
  117269. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117270. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117271. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117272. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117273. /* harmony import */ var _Shaders_kernelBlur_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/kernelBlur.fragment */ "./Shaders/kernelBlur.fragment.ts");
  117274. /* harmony import */ var _Shaders_kernelBlur_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/kernelBlur.vertex */ "./Shaders/kernelBlur.vertex.ts");
  117275. /**
  117276. * The Blur Post Process which blurs an image based on a kernel and direction.
  117277. * Can be used twice in x and y directions to perform a guassian blur in two passes.
  117278. */
  117279. var BlurPostProcess = /** @class */ (function (_super) {
  117280. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](BlurPostProcess, _super);
  117281. /**
  117282. * Creates a new instance BlurPostProcess
  117283. * @param name The name of the effect.
  117284. * @param direction The direction in which to blur the image.
  117285. * @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.
  117286. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  117287. * @param camera The camera to apply the render pass to.
  117288. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117289. * @param engine The engine which the post process will be applied. (default: current engine)
  117290. * @param reusable If the post process can be reused on the same frame. (default: false)
  117291. * @param textureType Type of textures used when performing the post process. (default: 0)
  117292. * @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)
  117293. */
  117294. function BlurPostProcess(name,
  117295. /** The direction in which to blur the image. */
  117296. direction, kernel, options, camera, samplingMode, engine, reusable, textureType, defines, blockCompilation) {
  117297. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE; }
  117298. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117299. if (defines === void 0) { defines = ""; }
  117300. if (blockCompilation === void 0) { blockCompilation = false; }
  117301. 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;
  117302. _this.direction = direction;
  117303. _this.blockCompilation = blockCompilation;
  117304. _this._packedFloat = false;
  117305. _this._staticDefines = "";
  117306. _this._staticDefines = defines;
  117307. _this.onApplyObservable.add(function (effect) {
  117308. if (_this._outputTexture) {
  117309. effect.setFloat2('delta', (1 / _this._outputTexture.width) * _this.direction.x, (1 / _this._outputTexture.height) * _this.direction.y);
  117310. }
  117311. else {
  117312. effect.setFloat2('delta', (1 / _this.width) * _this.direction.x, (1 / _this.height) * _this.direction.y);
  117313. }
  117314. });
  117315. _this.kernel = kernel;
  117316. return _this;
  117317. }
  117318. Object.defineProperty(BlurPostProcess.prototype, "kernel", {
  117319. /**
  117320. * Gets the length in pixels of the blur sample region
  117321. */
  117322. get: function () {
  117323. return this._idealKernel;
  117324. },
  117325. /**
  117326. * Sets the length in pixels of the blur sample region
  117327. */
  117328. set: function (v) {
  117329. if (this._idealKernel === v) {
  117330. return;
  117331. }
  117332. v = Math.max(v, 1);
  117333. this._idealKernel = v;
  117334. this._kernel = this._nearestBestKernel(v);
  117335. if (!this.blockCompilation) {
  117336. this._updateParameters();
  117337. }
  117338. },
  117339. enumerable: true,
  117340. configurable: true
  117341. });
  117342. Object.defineProperty(BlurPostProcess.prototype, "packedFloat", {
  117343. /**
  117344. * Gets wether or not the blur is unpacking/repacking floats
  117345. */
  117346. get: function () {
  117347. return this._packedFloat;
  117348. },
  117349. /**
  117350. * Sets wether or not the blur needs to unpack/repack floats
  117351. */
  117352. set: function (v) {
  117353. if (this._packedFloat === v) {
  117354. return;
  117355. }
  117356. this._packedFloat = v;
  117357. if (!this.blockCompilation) {
  117358. this._updateParameters();
  117359. }
  117360. },
  117361. enumerable: true,
  117362. configurable: true
  117363. });
  117364. /**
  117365. * Updates the effect with the current post process compile time values and recompiles the shader.
  117366. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  117367. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  117368. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  117369. * @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
  117370. * @param onCompiled Called when the shader has been compiled.
  117371. * @param onError Called if there is an error when compiling a shader.
  117372. */
  117373. BlurPostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  117374. if (defines === void 0) { defines = null; }
  117375. if (uniforms === void 0) { uniforms = null; }
  117376. if (samplers === void 0) { samplers = null; }
  117377. this._updateParameters(onCompiled, onError);
  117378. };
  117379. BlurPostProcess.prototype._updateParameters = function (onCompiled, onError) {
  117380. // Generate sampling offsets and weights
  117381. var N = this._kernel;
  117382. var centerIndex = (N - 1) / 2;
  117383. // Generate Gaussian sampling weights over kernel
  117384. var offsets = [];
  117385. var weights = [];
  117386. var totalWeight = 0;
  117387. for (var i = 0; i < N; i++) {
  117388. var u = i / (N - 1);
  117389. var w = this._gaussianWeight(u * 2.0 - 1);
  117390. offsets[i] = (i - centerIndex);
  117391. weights[i] = w;
  117392. totalWeight += w;
  117393. }
  117394. // Normalize weights
  117395. for (var i = 0; i < weights.length; i++) {
  117396. weights[i] /= totalWeight;
  117397. }
  117398. // Optimize: combine samples to take advantage of hardware linear sampling
  117399. // Walk from left to center, combining pairs (symmetrically)
  117400. var linearSamplingWeights = [];
  117401. var linearSamplingOffsets = [];
  117402. var linearSamplingMap = [];
  117403. for (var i = 0; i <= centerIndex; i += 2) {
  117404. var j = Math.min(i + 1, Math.floor(centerIndex));
  117405. var singleCenterSample = i === j;
  117406. if (singleCenterSample) {
  117407. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  117408. }
  117409. else {
  117410. var sharedCell = j === centerIndex;
  117411. var weightLinear = (weights[i] + weights[j] * (sharedCell ? .5 : 1.));
  117412. var offsetLinear = offsets[i] + 1 / (1 + weights[i] / weights[j]);
  117413. if (offsetLinear === 0) {
  117414. linearSamplingMap.push({ o: offsets[i], w: weights[i] });
  117415. linearSamplingMap.push({ o: offsets[i + 1], w: weights[i + 1] });
  117416. }
  117417. else {
  117418. linearSamplingMap.push({ o: offsetLinear, w: weightLinear });
  117419. linearSamplingMap.push({ o: -offsetLinear, w: weightLinear });
  117420. }
  117421. }
  117422. }
  117423. for (var i = 0; i < linearSamplingMap.length; i++) {
  117424. linearSamplingOffsets[i] = linearSamplingMap[i].o;
  117425. linearSamplingWeights[i] = linearSamplingMap[i].w;
  117426. }
  117427. // Replace with optimized
  117428. offsets = linearSamplingOffsets;
  117429. weights = linearSamplingWeights;
  117430. // Generate shaders
  117431. var maxVaryingRows = this.getEngine().getCaps().maxVaryingVectors;
  117432. var freeVaryingVec2 = Math.max(maxVaryingRows, 0.) - 1; // Because of sampleCenter
  117433. var varyingCount = Math.min(offsets.length, freeVaryingVec2);
  117434. var defines = "";
  117435. defines += this._staticDefines;
  117436. // The DOF fragment should ignore the center pixel when looping as it is handled manualy in the fragment shader.
  117437. if (this._staticDefines.indexOf("DOF") != -1) {
  117438. defines += "#define CENTER_WEIGHT " + this._glslFloat(weights[varyingCount - 1]) + "\r\n";
  117439. varyingCount--;
  117440. }
  117441. for (var i = 0; i < varyingCount; i++) {
  117442. defines += "#define KERNEL_OFFSET" + i + " " + this._glslFloat(offsets[i]) + "\r\n";
  117443. defines += "#define KERNEL_WEIGHT" + i + " " + this._glslFloat(weights[i]) + "\r\n";
  117444. }
  117445. var depCount = 0;
  117446. for (var i = freeVaryingVec2; i < offsets.length; i++) {
  117447. defines += "#define KERNEL_DEP_OFFSET" + depCount + " " + this._glslFloat(offsets[i]) + "\r\n";
  117448. defines += "#define KERNEL_DEP_WEIGHT" + depCount + " " + this._glslFloat(weights[i]) + "\r\n";
  117449. depCount++;
  117450. }
  117451. if (this.packedFloat) {
  117452. defines += "#define PACKEDFLOAT 1";
  117453. }
  117454. this.blockCompilation = false;
  117455. _super.prototype.updateEffect.call(this, defines, null, null, {
  117456. varyingCount: varyingCount,
  117457. depCount: depCount
  117458. }, onCompiled, onError);
  117459. };
  117460. /**
  117461. * Best kernels are odd numbers that when divided by 2, their integer part is even, so 5, 9 or 13.
  117462. * Other odd kernels optimize correctly but require proportionally more samples, even kernels are
  117463. * possible but will produce minor visual artifacts. Since each new kernel requires a new shader we
  117464. * want to minimize kernel changes, having gaps between physical kernels is helpful in that regard.
  117465. * The gaps between physical kernels are compensated for in the weighting of the samples
  117466. * @param idealKernel Ideal blur kernel.
  117467. * @return Nearest best kernel.
  117468. */
  117469. BlurPostProcess.prototype._nearestBestKernel = function (idealKernel) {
  117470. var v = Math.round(idealKernel);
  117471. for (var _i = 0, _a = [v, v - 1, v + 1, v - 2, v + 2]; _i < _a.length; _i++) {
  117472. var k = _a[_i];
  117473. if (((k % 2) !== 0) && ((Math.floor(k / 2) % 2) === 0) && k > 0) {
  117474. return Math.max(k, 3);
  117475. }
  117476. }
  117477. return Math.max(v, 3);
  117478. };
  117479. /**
  117480. * Calculates the value of a Gaussian distribution with sigma 3 at a given point.
  117481. * @param x The point on the Gaussian distribution to sample.
  117482. * @return the value of the Gaussian function at x.
  117483. */
  117484. BlurPostProcess.prototype._gaussianWeight = function (x) {
  117485. //reference: Engines/ImageProcessingBlur.cpp #dcc760
  117486. // We are evaluating the Gaussian (normal) distribution over a kernel parameter space of [-1,1],
  117487. // so we truncate at three standard deviations by setting stddev (sigma) to 1/3.
  117488. // The choice of 3-sigma truncation is common but arbitrary, and means that the signal is
  117489. // truncated at around 1.3% of peak strength.
  117490. //the distribution is scaled to account for the difference between the actual kernel size and the requested kernel size
  117491. var sigma = (1 / 3);
  117492. var denominator = Math.sqrt(2.0 * Math.PI) * sigma;
  117493. var exponent = -((x * x) / (2.0 * sigma * sigma));
  117494. var weight = (1.0 / denominator) * Math.exp(exponent);
  117495. return weight;
  117496. };
  117497. /**
  117498. * Generates a string that can be used as a floating point number in GLSL.
  117499. * @param x Value to print.
  117500. * @param decimalFigures Number of decimal places to print the number to (excluding trailing 0s).
  117501. * @return GLSL float string.
  117502. */
  117503. BlurPostProcess.prototype._glslFloat = function (x, decimalFigures) {
  117504. if (decimalFigures === void 0) { decimalFigures = 8; }
  117505. return x.toFixed(decimalFigures).replace(/0+$/, '');
  117506. };
  117507. return BlurPostProcess;
  117508. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117509. /***/ }),
  117510. /***/ "./PostProcesses/chromaticAberrationPostProcess.ts":
  117511. /*!*********************************************************!*\
  117512. !*** ./PostProcesses/chromaticAberrationPostProcess.ts ***!
  117513. \*********************************************************/
  117514. /*! exports provided: ChromaticAberrationPostProcess */
  117515. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117516. "use strict";
  117517. __webpack_require__.r(__webpack_exports__);
  117518. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return ChromaticAberrationPostProcess; });
  117519. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117520. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117521. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117522. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117523. /* harmony import */ var _Shaders_chromaticAberration_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/chromaticAberration.fragment */ "./Shaders/chromaticAberration.fragment.ts");
  117524. /**
  117525. * The ChromaticAberrationPostProcess separates the rgb channels in an image to produce chromatic distortion around the edges of the screen
  117526. */
  117527. var ChromaticAberrationPostProcess = /** @class */ (function (_super) {
  117528. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ChromaticAberrationPostProcess, _super);
  117529. /**
  117530. * Creates a new instance ChromaticAberrationPostProcess
  117531. * @param name The name of the effect.
  117532. * @param screenWidth The width of the screen to apply the effect on.
  117533. * @param screenHeight The height of the screen to apply the effect on.
  117534. * @param options The required width/height ratio to downsize to before computing the render pass.
  117535. * @param camera The camera to apply the render pass to.
  117536. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117537. * @param engine The engine which the post process will be applied. (default: current engine)
  117538. * @param reusable If the post process can be reused on the same frame. (default: false)
  117539. * @param textureType Type of textures used when performing the post process. (default: 0)
  117540. * @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)
  117541. */
  117542. function ChromaticAberrationPostProcess(name, screenWidth, screenHeight, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117543. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117544. if (blockCompilation === void 0) { blockCompilation = false; }
  117545. 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;
  117546. /**
  117547. * The amount of seperation of rgb channels (default: 30)
  117548. */
  117549. _this.aberrationAmount = 30;
  117550. /**
  117551. * The amount the effect will increase for pixels closer to the edge of the screen. (default: 0)
  117552. */
  117553. _this.radialIntensity = 0;
  117554. /**
  117555. * 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))
  117556. */
  117557. _this.direction = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.707, 0.707);
  117558. /**
  117559. * 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))
  117560. */
  117561. _this.centerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](0.5, 0.5);
  117562. _this.onApplyObservable.add(function (effect) {
  117563. effect.setFloat('chromatic_aberration', _this.aberrationAmount);
  117564. effect.setFloat('screen_width', screenWidth);
  117565. effect.setFloat('screen_height', screenHeight);
  117566. effect.setFloat('radialIntensity', _this.radialIntensity);
  117567. effect.setFloat2('direction', _this.direction.x, _this.direction.y);
  117568. effect.setFloat2('centerPosition', _this.centerPosition.x, _this.centerPosition.y);
  117569. });
  117570. return _this;
  117571. }
  117572. return ChromaticAberrationPostProcess;
  117573. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  117574. /***/ }),
  117575. /***/ "./PostProcesses/circleOfConfusionPostProcess.ts":
  117576. /*!*******************************************************!*\
  117577. !*** ./PostProcesses/circleOfConfusionPostProcess.ts ***!
  117578. \*******************************************************/
  117579. /*! exports provided: CircleOfConfusionPostProcess */
  117580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117581. "use strict";
  117582. __webpack_require__.r(__webpack_exports__);
  117583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return CircleOfConfusionPostProcess; });
  117584. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117585. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117586. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  117587. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117588. /* harmony import */ var _Shaders_circleOfConfusion_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/circleOfConfusion.fragment */ "./Shaders/circleOfConfusion.fragment.ts");
  117589. /**
  117590. * The CircleOfConfusionPostProcess computes the circle of confusion value for each pixel given required lens parameters. See https://en.wikipedia.org/wiki/Circle_of_confusion
  117591. */
  117592. var CircleOfConfusionPostProcess = /** @class */ (function (_super) {
  117593. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](CircleOfConfusionPostProcess, _super);
  117594. /**
  117595. * Creates a new instance CircleOfConfusionPostProcess
  117596. * @param name The name of the effect.
  117597. * @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.
  117598. * @param options The required width/height ratio to downsize to before computing the render pass.
  117599. * @param camera The camera to apply the render pass to.
  117600. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117601. * @param engine The engine which the post process will be applied. (default: current engine)
  117602. * @param reusable If the post process can be reused on the same frame. (default: false)
  117603. * @param textureType Type of textures used when performing the post process. (default: 0)
  117604. * @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)
  117605. */
  117606. function CircleOfConfusionPostProcess(name, depthTexture, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  117607. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117608. if (blockCompilation === void 0) { blockCompilation = false; }
  117609. var _this = _super.call(this, name, "circleOfConfusion", ["cameraMinMaxZ", "focusDistance", "cocPrecalculation"], ["depthSampler"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  117610. /**
  117611. * 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.
  117612. */
  117613. _this.lensSize = 50;
  117614. /**
  117615. * F-Stop of the effect's camera. The diamater of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117616. */
  117617. _this.fStop = 1.4;
  117618. /**
  117619. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117620. */
  117621. _this.focusDistance = 2000;
  117622. /**
  117623. * Focal length of the effect's camera in scene units/1000 (eg. millimeter). (default: 50)
  117624. */
  117625. _this.focalLength = 50;
  117626. _this._depthTexture = null;
  117627. _this._depthTexture = depthTexture;
  117628. _this.onApplyObservable.add(function (effect) {
  117629. if (!_this._depthTexture) {
  117630. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("No depth texture set on CircleOfConfusionPostProcess");
  117631. return;
  117632. }
  117633. effect.setTexture("depthSampler", _this._depthTexture);
  117634. // Circle of confusion calculation, See https://developer.nvidia.com/gpugems/GPUGems/gpugems_ch23.html
  117635. var aperture = _this.lensSize / _this.fStop;
  117636. var cocPrecalculation = ((aperture * _this.focalLength) / ((_this.focusDistance - _this.focalLength))); // * ((this.focusDistance - pixelDistance)/pixelDistance) [This part is done in shader]
  117637. effect.setFloat('focusDistance', _this.focusDistance);
  117638. effect.setFloat('cocPrecalculation', cocPrecalculation);
  117639. effect.setFloat2('cameraMinMaxZ', _this._depthTexture.activeCamera.minZ, _this._depthTexture.activeCamera.maxZ);
  117640. });
  117641. return _this;
  117642. }
  117643. Object.defineProperty(CircleOfConfusionPostProcess.prototype, "depthTexture", {
  117644. /**
  117645. * 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.
  117646. */
  117647. set: function (value) {
  117648. this._depthTexture = value;
  117649. },
  117650. enumerable: true,
  117651. configurable: true
  117652. });
  117653. return CircleOfConfusionPostProcess;
  117654. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117655. /***/ }),
  117656. /***/ "./PostProcesses/colorCorrectionPostProcess.ts":
  117657. /*!*****************************************************!*\
  117658. !*** ./PostProcesses/colorCorrectionPostProcess.ts ***!
  117659. \*****************************************************/
  117660. /*! exports provided: ColorCorrectionPostProcess */
  117661. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117662. "use strict";
  117663. __webpack_require__.r(__webpack_exports__);
  117664. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return ColorCorrectionPostProcess; });
  117665. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117666. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117667. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117668. /* harmony import */ var _Shaders_colorCorrection_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/colorCorrection.fragment */ "./Shaders/colorCorrection.fragment.ts");
  117669. /**
  117670. *
  117671. * This post-process allows the modification of rendered colors by using
  117672. * a 'look-up table' (LUT). This effect is also called Color Grading.
  117673. *
  117674. * The object needs to be provided an url to a texture containing the color
  117675. * look-up table: the texture must be 256 pixels wide and 16 pixels high.
  117676. * Use an image editing software to tweak the LUT to match your needs.
  117677. *
  117678. * For an example of a color LUT, see here:
  117679. * @see http://udn.epicgames.com/Three/rsrc/Three/ColorGrading/RGBTable16x1.png
  117680. * For explanations on color grading, see here:
  117681. * @see http://udn.epicgames.com/Three/ColorGrading.html
  117682. *
  117683. */
  117684. var ColorCorrectionPostProcess = /** @class */ (function (_super) {
  117685. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ColorCorrectionPostProcess, _super);
  117686. function ColorCorrectionPostProcess(name, colorTableUrl, options, camera, samplingMode, engine, reusable) {
  117687. var _this = _super.call(this, name, 'colorCorrection', null, ['colorTable'], options, camera, samplingMode, engine, reusable) || this;
  117688. _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);
  117689. _this._colorTableTexture.anisotropicFilteringLevel = 1;
  117690. _this._colorTableTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  117691. _this._colorTableTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  117692. _this.onApply = function (effect) {
  117693. effect.setTexture("colorTable", _this._colorTableTexture);
  117694. };
  117695. return _this;
  117696. }
  117697. return ColorCorrectionPostProcess;
  117698. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117699. /***/ }),
  117700. /***/ "./PostProcesses/convolutionPostProcess.ts":
  117701. /*!*************************************************!*\
  117702. !*** ./PostProcesses/convolutionPostProcess.ts ***!
  117703. \*************************************************/
  117704. /*! exports provided: ConvolutionPostProcess */
  117705. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117706. "use strict";
  117707. __webpack_require__.r(__webpack_exports__);
  117708. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return ConvolutionPostProcess; });
  117709. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117710. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  117711. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117712. /* harmony import */ var _Shaders_convolution_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/convolution.fragment */ "./Shaders/convolution.fragment.ts");
  117713. /**
  117714. * The ConvolutionPostProcess applies a 3x3 kernel to every pixel of the
  117715. * input texture to perform effects such as edge detection or sharpening
  117716. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  117717. */
  117718. var ConvolutionPostProcess = /** @class */ (function (_super) {
  117719. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ConvolutionPostProcess, _super);
  117720. /**
  117721. * Creates a new instance ConvolutionPostProcess
  117722. * @param name The name of the effect.
  117723. * @param kernel Array of 9 values corrisponding to the 3x3 kernel to be applied
  117724. * @param options The required width/height ratio to downsize to before computing the render pass.
  117725. * @param camera The camera to apply the render pass to.
  117726. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117727. * @param engine The engine which the post process will be applied. (default: current engine)
  117728. * @param reusable If the post process can be reused on the same frame. (default: false)
  117729. * @param textureType Type of textures used when performing the post process. (default: 0)
  117730. */
  117731. function ConvolutionPostProcess(name,
  117732. /** Array of 9 values corrisponding to the 3x3 kernel to be applied */
  117733. kernel, options, camera, samplingMode, engine, reusable, textureType) {
  117734. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117735. var _this = _super.call(this, name, "convolution", ["kernel", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  117736. _this.kernel = kernel;
  117737. _this.onApply = function (effect) {
  117738. effect.setFloat2("screenSize", _this.width, _this.height);
  117739. effect.setArray("kernel", _this.kernel);
  117740. };
  117741. return _this;
  117742. }
  117743. // Statics
  117744. /**
  117745. * Edge detection 0 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117746. */
  117747. ConvolutionPostProcess.EdgeDetect0Kernel = [1, 0, -1, 0, 0, 0, -1, 0, 1];
  117748. /**
  117749. * Edge detection 1 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117750. */
  117751. ConvolutionPostProcess.EdgeDetect1Kernel = [0, 1, 0, 1, -4, 1, 0, 1, 0];
  117752. /**
  117753. * Edge detection 2 see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117754. */
  117755. ConvolutionPostProcess.EdgeDetect2Kernel = [-1, -1, -1, -1, 8, -1, -1, -1, -1];
  117756. /**
  117757. * Kernel to sharpen an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117758. */
  117759. ConvolutionPostProcess.SharpenKernel = [0, -1, 0, -1, 5, -1, 0, -1, 0];
  117760. /**
  117761. * Kernel to emboss an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117762. */
  117763. ConvolutionPostProcess.EmbossKernel = [-2, -1, 0, -1, 1, 1, 0, 1, 2];
  117764. /**
  117765. * Kernel to blur an image see https://en.wikipedia.org/wiki/Kernel_(image_processing)
  117766. */
  117767. ConvolutionPostProcess.GaussianKernel = [0, 1, 0, 1, 1, 1, 0, 1, 0];
  117768. return ConvolutionPostProcess;
  117769. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  117770. /***/ }),
  117771. /***/ "./PostProcesses/depthOfFieldBlurPostProcess.ts":
  117772. /*!******************************************************!*\
  117773. !*** ./PostProcesses/depthOfFieldBlurPostProcess.ts ***!
  117774. \******************************************************/
  117775. /*! exports provided: DepthOfFieldBlurPostProcess */
  117776. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117777. "use strict";
  117778. __webpack_require__.r(__webpack_exports__);
  117779. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return DepthOfFieldBlurPostProcess; });
  117780. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117781. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117782. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  117783. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  117784. /**
  117785. * The DepthOfFieldBlurPostProcess applied a blur in a give direction.
  117786. * This blur differs from the standard BlurPostProcess as it attempts to avoid blurring pixels
  117787. * based on samples that have a large difference in distance than the center pixel.
  117788. * See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117789. */
  117790. var DepthOfFieldBlurPostProcess = /** @class */ (function (_super) {
  117791. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldBlurPostProcess, _super);
  117792. /**
  117793. * Creates a new instance CircleOfConfusionPostProcess
  117794. * @param name The name of the effect.
  117795. * @param scene The scene the effect belongs to.
  117796. * @param direction The direction the blur should be applied.
  117797. * @param kernel The size of the kernel used to blur.
  117798. * @param options The required width/height ratio to downsize to before computing the render pass.
  117799. * @param camera The camera to apply the render pass to.
  117800. * @param circleOfConfusion The circle of confusion + depth map to be used to avoid blurring accross edges
  117801. * @param imageToBlur The image to apply the blur to (default: Current rendered frame)
  117802. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  117803. * @param engine The engine which the post process will be applied. (default: current engine)
  117804. * @param reusable If the post process can be reused on the same frame. (default: false)
  117805. * @param textureType Type of textures used when performing the post process. (default: 0)
  117806. * @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)
  117807. */
  117808. function DepthOfFieldBlurPostProcess(name, scene, direction, kernel, options, camera, circleOfConfusion, imageToBlur, samplingMode, engine, reusable, textureType, blockCompilation) {
  117809. if (imageToBlur === void 0) { imageToBlur = null; }
  117810. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"].BILINEAR_SAMPLINGMODE; }
  117811. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  117812. if (blockCompilation === void 0) { blockCompilation = false; }
  117813. 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;
  117814. _this.direction = direction;
  117815. _this.onApplyObservable.add(function (effect) {
  117816. if (imageToBlur != null) {
  117817. effect.setTextureFromPostProcess("textureSampler", imageToBlur);
  117818. }
  117819. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  117820. if (scene.activeCamera) {
  117821. effect.setFloat2('cameraMinMaxZ', scene.activeCamera.minZ, scene.activeCamera.maxZ);
  117822. }
  117823. });
  117824. return _this;
  117825. }
  117826. return DepthOfFieldBlurPostProcess;
  117827. }(_blurPostProcess__WEBPACK_IMPORTED_MODULE_2__["BlurPostProcess"]));
  117828. /***/ }),
  117829. /***/ "./PostProcesses/depthOfFieldEffect.ts":
  117830. /*!*********************************************!*\
  117831. !*** ./PostProcesses/depthOfFieldEffect.ts ***!
  117832. \*********************************************/
  117833. /*! exports provided: DepthOfFieldEffectBlurLevel, DepthOfFieldEffect */
  117834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  117835. "use strict";
  117836. __webpack_require__.r(__webpack_exports__);
  117837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return DepthOfFieldEffectBlurLevel; });
  117838. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return DepthOfFieldEffect; });
  117839. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  117840. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  117841. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  117842. /* harmony import */ var _PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../PostProcesses/RenderPipeline/postProcessRenderEffect */ "./PostProcesses/RenderPipeline/postProcessRenderEffect.ts");
  117843. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  117844. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  117845. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  117846. /**
  117847. * Specifies the level of max blur that should be applied when using the depth of field effect
  117848. */
  117849. var DepthOfFieldEffectBlurLevel;
  117850. (function (DepthOfFieldEffectBlurLevel) {
  117851. /**
  117852. * Subtle blur
  117853. */
  117854. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Low"] = 0] = "Low";
  117855. /**
  117856. * Medium blur
  117857. */
  117858. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["Medium"] = 1] = "Medium";
  117859. /**
  117860. * Large blur
  117861. */
  117862. DepthOfFieldEffectBlurLevel[DepthOfFieldEffectBlurLevel["High"] = 2] = "High";
  117863. })(DepthOfFieldEffectBlurLevel || (DepthOfFieldEffectBlurLevel = {}));
  117864. /**
  117865. * The depth of field effect applies a blur to objects that are closer or further from where the camera is focusing.
  117866. */
  117867. var DepthOfFieldEffect = /** @class */ (function (_super) {
  117868. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldEffect, _super);
  117869. /**
  117870. * Creates a new instance DepthOfFieldEffect
  117871. * @param scene The scene the effect belongs to.
  117872. * @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.
  117873. * @param pipelineTextureType The type of texture to be used when performing the post processing.
  117874. * @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)
  117875. */
  117876. function DepthOfFieldEffect(scene, depthTexture, blurLevel, pipelineTextureType, blockCompilation) {
  117877. if (blurLevel === void 0) { blurLevel = DepthOfFieldEffectBlurLevel.Low; }
  117878. if (pipelineTextureType === void 0) { pipelineTextureType = 0; }
  117879. if (blockCompilation === void 0) { blockCompilation = false; }
  117880. var _this = _super.call(this, scene.getEngine(), "depth of field", function () {
  117881. return _this._effects;
  117882. }, true) || this;
  117883. /**
  117884. * @hidden Internal post processes in depth of field effect
  117885. */
  117886. _this._effects = [];
  117887. // Circle of confusion value for each pixel is used to determine how much to blur that pixel
  117888. _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);
  117889. // 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)
  117890. // Blur the image but do not blur on sharp far to near distance changes to avoid bleeding artifacts
  117891. // See section 2.6.2 http://fileadmin.cs.lth.se/cs/education/edan35/lectures/12dof.pdf
  117892. _this._depthOfFieldBlurY = [];
  117893. _this._depthOfFieldBlurX = [];
  117894. var blurCount = 1;
  117895. var kernelSize = 15;
  117896. switch (blurLevel) {
  117897. case DepthOfFieldEffectBlurLevel.High: {
  117898. blurCount = 3;
  117899. kernelSize = 51;
  117900. break;
  117901. }
  117902. case DepthOfFieldEffectBlurLevel.Medium: {
  117903. blurCount = 2;
  117904. kernelSize = 31;
  117905. break;
  117906. }
  117907. default: {
  117908. kernelSize = 15;
  117909. blurCount = 1;
  117910. break;
  117911. }
  117912. }
  117913. var adjustedKernelSize = kernelSize / Math.pow(2, blurCount - 1);
  117914. var ratio = 1.0;
  117915. for (var i = 0; i < blurCount; i++) {
  117916. 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);
  117917. blurY.autoClear = false;
  117918. ratio = 0.75 / Math.pow(2, i);
  117919. 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);
  117920. blurX.autoClear = false;
  117921. _this._depthOfFieldBlurY.push(blurY);
  117922. _this._depthOfFieldBlurX.push(blurX);
  117923. }
  117924. // Set all post processes on the effect.
  117925. _this._effects = [_this._circleOfConfusion];
  117926. for (var i = 0; i < _this._depthOfFieldBlurX.length; i++) {
  117927. _this._effects.push(_this._depthOfFieldBlurY[i]);
  117928. _this._effects.push(_this._depthOfFieldBlurX[i]);
  117929. }
  117930. // Merge blurred images with original image based on circleOfConfusion
  117931. _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);
  117932. _this._dofMerge.autoClear = false;
  117933. _this._effects.push(_this._dofMerge);
  117934. return _this;
  117935. }
  117936. Object.defineProperty(DepthOfFieldEffect.prototype, "focalLength", {
  117937. get: function () {
  117938. return this._circleOfConfusion.focalLength;
  117939. },
  117940. /**
  117941. * The focal the length of the camera used in the effect in scene units/1000 (eg. millimeter)
  117942. */
  117943. set: function (value) {
  117944. this._circleOfConfusion.focalLength = value;
  117945. },
  117946. enumerable: true,
  117947. configurable: true
  117948. });
  117949. Object.defineProperty(DepthOfFieldEffect.prototype, "fStop", {
  117950. get: function () {
  117951. return this._circleOfConfusion.fStop;
  117952. },
  117953. /**
  117954. * F-Stop of the effect's camera. The diameter of the resulting aperture can be computed by lensSize/fStop. (default: 1.4)
  117955. */
  117956. set: function (value) {
  117957. this._circleOfConfusion.fStop = value;
  117958. },
  117959. enumerable: true,
  117960. configurable: true
  117961. });
  117962. Object.defineProperty(DepthOfFieldEffect.prototype, "focusDistance", {
  117963. get: function () {
  117964. return this._circleOfConfusion.focusDistance;
  117965. },
  117966. /**
  117967. * Distance away from the camera to focus on in scene units/1000 (eg. millimeter). (default: 2000)
  117968. */
  117969. set: function (value) {
  117970. this._circleOfConfusion.focusDistance = value;
  117971. },
  117972. enumerable: true,
  117973. configurable: true
  117974. });
  117975. Object.defineProperty(DepthOfFieldEffect.prototype, "lensSize", {
  117976. get: function () {
  117977. return this._circleOfConfusion.lensSize;
  117978. },
  117979. /**
  117980. * 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.
  117981. */
  117982. set: function (value) {
  117983. this._circleOfConfusion.lensSize = value;
  117984. },
  117985. enumerable: true,
  117986. configurable: true
  117987. });
  117988. Object.defineProperty(DepthOfFieldEffect.prototype, "depthTexture", {
  117989. /**
  117990. * 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.
  117991. */
  117992. set: function (value) {
  117993. this._circleOfConfusion.depthTexture = value;
  117994. },
  117995. enumerable: true,
  117996. configurable: true
  117997. });
  117998. /**
  117999. * Disposes each of the internal effects for a given camera.
  118000. * @param camera The camera to dispose the effect on.
  118001. */
  118002. DepthOfFieldEffect.prototype.disposeEffects = function (camera) {
  118003. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118004. this._effects[effectIndex].dispose(camera);
  118005. }
  118006. };
  118007. /**
  118008. * @hidden Internal
  118009. */
  118010. DepthOfFieldEffect.prototype._updateEffects = function () {
  118011. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118012. this._effects[effectIndex].updateEffect();
  118013. }
  118014. };
  118015. /**
  118016. * Internal
  118017. * @returns if all the contained post processes are ready.
  118018. * @hidden
  118019. */
  118020. DepthOfFieldEffect.prototype._isReady = function () {
  118021. for (var effectIndex = 0; effectIndex < this._effects.length; effectIndex++) {
  118022. if (!this._effects[effectIndex].isReady()) {
  118023. return false;
  118024. }
  118025. }
  118026. return true;
  118027. };
  118028. return DepthOfFieldEffect;
  118029. }(_PostProcesses_RenderPipeline_postProcessRenderEffect__WEBPACK_IMPORTED_MODULE_3__["PostProcessRenderEffect"]));
  118030. /***/ }),
  118031. /***/ "./PostProcesses/depthOfFieldMergePostProcess.ts":
  118032. /*!*******************************************************!*\
  118033. !*** ./PostProcesses/depthOfFieldMergePostProcess.ts ***!
  118034. \*******************************************************/
  118035. /*! exports provided: DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess */
  118036. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118037. "use strict";
  118038. __webpack_require__.r(__webpack_exports__);
  118039. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return DepthOfFieldMergePostProcessOptions; });
  118040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return DepthOfFieldMergePostProcess; });
  118041. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118042. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118043. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118044. /* harmony import */ var _Shaders_depthOfFieldMerge_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/depthOfFieldMerge.fragment */ "./Shaders/depthOfFieldMerge.fragment.ts");
  118045. /**
  118046. * Options to be set when merging outputs from the default pipeline.
  118047. */
  118048. var DepthOfFieldMergePostProcessOptions = /** @class */ (function () {
  118049. function DepthOfFieldMergePostProcessOptions() {
  118050. }
  118051. return DepthOfFieldMergePostProcessOptions;
  118052. }());
  118053. /**
  118054. * The DepthOfFieldMergePostProcess merges blurred images with the original based on the values of the circle of confusion.
  118055. */
  118056. var DepthOfFieldMergePostProcess = /** @class */ (function (_super) {
  118057. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DepthOfFieldMergePostProcess, _super);
  118058. /**
  118059. * Creates a new instance of DepthOfFieldMergePostProcess
  118060. * @param name The name of the effect.
  118061. * @param originalFromInput Post process which's input will be used for the merge.
  118062. * @param circleOfConfusion Circle of confusion post process which's output will be used to blur each pixel.
  118063. * @param blurSteps Blur post processes from low to high which will be mixed with the original image.
  118064. * @param options The required width/height ratio to downsize to before computing the render pass.
  118065. * @param camera The camera to apply the render pass to.
  118066. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118067. * @param engine The engine which the post process will be applied. (default: current engine)
  118068. * @param reusable If the post process can be reused on the same frame. (default: false)
  118069. * @param textureType Type of textures used when performing the post process. (default: 0)
  118070. * @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)
  118071. */
  118072. function DepthOfFieldMergePostProcess(name, originalFromInput, circleOfConfusion, blurSteps, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118073. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118074. if (blockCompilation === void 0) { blockCompilation = false; }
  118075. var _this = _super.call(this, name, "depthOfFieldMerge", [], ["circleOfConfusionSampler", "blurStep0", "blurStep1", "blurStep2"], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, true) || this;
  118076. _this.blurSteps = blurSteps;
  118077. _this.onApplyObservable.add(function (effect) {
  118078. effect.setTextureFromPostProcess("textureSampler", originalFromInput);
  118079. effect.setTextureFromPostProcessOutput("circleOfConfusionSampler", circleOfConfusion);
  118080. blurSteps.forEach(function (step, index) {
  118081. effect.setTextureFromPostProcessOutput("blurStep" + (blurSteps.length - index - 1), step);
  118082. });
  118083. });
  118084. if (!blockCompilation) {
  118085. _this.updateEffect();
  118086. }
  118087. return _this;
  118088. }
  118089. /**
  118090. * Updates the effect with the current post process compile time values and recompiles the shader.
  118091. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  118092. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  118093. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  118094. * @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
  118095. * @param onCompiled Called when the shader has been compiled.
  118096. * @param onError Called if there is an error when compiling a shader.
  118097. */
  118098. DepthOfFieldMergePostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  118099. if (defines === void 0) { defines = null; }
  118100. if (uniforms === void 0) { uniforms = null; }
  118101. if (samplers === void 0) { samplers = null; }
  118102. if (!defines) {
  118103. defines = "";
  118104. defines += "#define BLUR_LEVEL " + (this.blurSteps.length - 1) + "\n";
  118105. }
  118106. _super.prototype.updateEffect.call(this, defines, uniforms, samplers, indexParameters, onCompiled, onError);
  118107. };
  118108. return DepthOfFieldMergePostProcess;
  118109. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118110. /***/ }),
  118111. /***/ "./PostProcesses/displayPassPostProcess.ts":
  118112. /*!*************************************************!*\
  118113. !*** ./PostProcesses/displayPassPostProcess.ts ***!
  118114. \*************************************************/
  118115. /*! exports provided: DisplayPassPostProcess */
  118116. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118117. "use strict";
  118118. __webpack_require__.r(__webpack_exports__);
  118119. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return DisplayPassPostProcess; });
  118120. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118121. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118122. /* harmony import */ var _Shaders_displayPass_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/displayPass.fragment */ "./Shaders/displayPass.fragment.ts");
  118123. /**
  118124. * DisplayPassPostProcess which produces an output the same as it's input
  118125. */
  118126. var DisplayPassPostProcess = /** @class */ (function (_super) {
  118127. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](DisplayPassPostProcess, _super);
  118128. /**
  118129. * Creates the DisplayPassPostProcess
  118130. * @param name The name of the effect.
  118131. * @param options The required width/height ratio to downsize to before computing the render pass.
  118132. * @param camera The camera to apply the render pass to.
  118133. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118134. * @param engine The engine which the post process will be applied. (default: current engine)
  118135. * @param reusable If the post process can be reused on the same frame. (default: false)
  118136. */
  118137. function DisplayPassPostProcess(name, options, camera, samplingMode, engine, reusable) {
  118138. return _super.call(this, name, "displayPass", ["passSampler"], ["passSampler"], options, camera, samplingMode, engine, reusable) || this;
  118139. }
  118140. return DisplayPassPostProcess;
  118141. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118142. /***/ }),
  118143. /***/ "./PostProcesses/extractHighlightsPostProcess.ts":
  118144. /*!*******************************************************!*\
  118145. !*** ./PostProcesses/extractHighlightsPostProcess.ts ***!
  118146. \*******************************************************/
  118147. /*! exports provided: ExtractHighlightsPostProcess */
  118148. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118149. "use strict";
  118150. __webpack_require__.r(__webpack_exports__);
  118151. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return ExtractHighlightsPostProcess; });
  118152. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118153. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118154. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118155. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118156. /* harmony import */ var _Shaders_extractHighlights_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/extractHighlights.fragment */ "./Shaders/extractHighlights.fragment.ts");
  118157. /**
  118158. * 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.
  118159. */
  118160. var ExtractHighlightsPostProcess = /** @class */ (function (_super) {
  118161. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ExtractHighlightsPostProcess, _super);
  118162. function ExtractHighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118163. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118164. if (blockCompilation === void 0) { blockCompilation = false; }
  118165. var _this = _super.call(this, name, "extractHighlights", ["threshold", "exposure"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118166. /**
  118167. * The luminance threshold, pixels below this value will be set to black.
  118168. */
  118169. _this.threshold = 0.9;
  118170. /** @hidden */
  118171. _this._exposure = 1;
  118172. /**
  118173. * Post process which has the input texture to be used when performing highlight extraction
  118174. * @hidden
  118175. */
  118176. _this._inputPostProcess = null;
  118177. _this.onApplyObservable.add(function (effect) {
  118178. if (_this._inputPostProcess) {
  118179. effect.setTextureFromPostProcess("textureSampler", _this._inputPostProcess);
  118180. }
  118181. effect.setFloat('threshold', Math.pow(_this.threshold, _Maths_math__WEBPACK_IMPORTED_MODULE_2__["ToGammaSpace"]));
  118182. effect.setFloat('exposure', _this._exposure);
  118183. });
  118184. return _this;
  118185. }
  118186. return ExtractHighlightsPostProcess;
  118187. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118188. /***/ }),
  118189. /***/ "./PostProcesses/filterPostProcess.ts":
  118190. /*!********************************************!*\
  118191. !*** ./PostProcesses/filterPostProcess.ts ***!
  118192. \********************************************/
  118193. /*! exports provided: FilterPostProcess */
  118194. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118195. "use strict";
  118196. __webpack_require__.r(__webpack_exports__);
  118197. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return FilterPostProcess; });
  118198. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118199. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118200. /* harmony import */ var _Shaders_filter_fragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Shaders/filter.fragment */ "./Shaders/filter.fragment.ts");
  118201. /**
  118202. * Applies a kernel filter to the image
  118203. */
  118204. var FilterPostProcess = /** @class */ (function (_super) {
  118205. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FilterPostProcess, _super);
  118206. /**
  118207. *
  118208. * @param name The name of the effect.
  118209. * @param kernelMatrix The matrix to be applied to the image
  118210. * @param options The required width/height ratio to downsize to before computing the render pass.
  118211. * @param camera The camera to apply the render pass to.
  118212. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118213. * @param engine The engine which the post process will be applied. (default: current engine)
  118214. * @param reusable If the post process can be reused on the same frame. (default: false)
  118215. */
  118216. function FilterPostProcess(name,
  118217. /** The matrix to be applied to the image */
  118218. kernelMatrix, options, camera, samplingMode, engine, reusable) {
  118219. var _this = _super.call(this, name, "filter", ["kernelMatrix"], null, options, camera, samplingMode, engine, reusable) || this;
  118220. _this.kernelMatrix = kernelMatrix;
  118221. _this.onApply = function (effect) {
  118222. effect.setMatrix("kernelMatrix", _this.kernelMatrix);
  118223. };
  118224. return _this;
  118225. }
  118226. return FilterPostProcess;
  118227. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118228. /***/ }),
  118229. /***/ "./PostProcesses/fxaaPostProcess.ts":
  118230. /*!******************************************!*\
  118231. !*** ./PostProcesses/fxaaPostProcess.ts ***!
  118232. \******************************************/
  118233. /*! exports provided: FxaaPostProcess */
  118234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118235. "use strict";
  118236. __webpack_require__.r(__webpack_exports__);
  118237. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return FxaaPostProcess; });
  118238. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118239. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  118240. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118241. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118242. /* harmony import */ var _Shaders_fxaa_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/fxaa.fragment */ "./Shaders/fxaa.fragment.ts");
  118243. /* harmony import */ var _Shaders_fxaa_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/fxaa.vertex */ "./Shaders/fxaa.vertex.ts");
  118244. /**
  118245. * Fxaa post process
  118246. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#fxaa
  118247. */
  118248. var FxaaPostProcess = /** @class */ (function (_super) {
  118249. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](FxaaPostProcess, _super);
  118250. function FxaaPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  118251. if (camera === void 0) { camera = null; }
  118252. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118253. 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;
  118254. var defines = _this._getDefines();
  118255. _this.updateEffect(defines);
  118256. _this.onApplyObservable.add(function (effect) {
  118257. var texelSize = _this.texelSize;
  118258. effect.setFloat2("texelSize", texelSize.x, texelSize.y);
  118259. });
  118260. return _this;
  118261. }
  118262. FxaaPostProcess.prototype._getDefines = function () {
  118263. var engine = this.getEngine();
  118264. if (!engine) {
  118265. return null;
  118266. }
  118267. var glInfo = engine.getGlInfo();
  118268. if (glInfo && glInfo.renderer && glInfo.renderer.toLowerCase().indexOf("mali") > -1) {
  118269. return "#define MALI 1\n";
  118270. }
  118271. return null;
  118272. };
  118273. return FxaaPostProcess;
  118274. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  118275. /***/ }),
  118276. /***/ "./PostProcesses/grainPostProcess.ts":
  118277. /*!*******************************************!*\
  118278. !*** ./PostProcesses/grainPostProcess.ts ***!
  118279. \*******************************************/
  118280. /*! exports provided: GrainPostProcess */
  118281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118282. "use strict";
  118283. __webpack_require__.r(__webpack_exports__);
  118284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return GrainPostProcess; });
  118285. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118286. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118287. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118288. /* harmony import */ var _Shaders_grain_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/grain.fragment */ "./Shaders/grain.fragment.ts");
  118289. /**
  118290. * The GrainPostProcess adds noise to the image at mid luminance levels
  118291. */
  118292. var GrainPostProcess = /** @class */ (function (_super) {
  118293. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](GrainPostProcess, _super);
  118294. /**
  118295. * Creates a new instance of @see GrainPostProcess
  118296. * @param name The name of the effect.
  118297. * @param options The required width/height ratio to downsize to before computing the render pass.
  118298. * @param camera The camera to apply the render pass to.
  118299. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118300. * @param engine The engine which the post process will be applied. (default: current engine)
  118301. * @param reusable If the post process can be reused on the same frame. (default: false)
  118302. * @param textureType Type of textures used when performing the post process. (default: 0)
  118303. * @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)
  118304. */
  118305. function GrainPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118306. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118307. if (blockCompilation === void 0) { blockCompilation = false; }
  118308. var _this = _super.call(this, name, "grain", ["intensity", "animatedSeed"], [], options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  118309. /**
  118310. * The intensity of the grain added (default: 30)
  118311. */
  118312. _this.intensity = 30;
  118313. /**
  118314. * If the grain should be randomized on every frame
  118315. */
  118316. _this.animated = false;
  118317. _this.onApplyObservable.add(function (effect) {
  118318. effect.setFloat('intensity', _this.intensity);
  118319. effect.setFloat('animatedSeed', _this.animated ? Math.random() + 1 : 1);
  118320. });
  118321. return _this;
  118322. }
  118323. return GrainPostProcess;
  118324. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118325. /***/ }),
  118326. /***/ "./PostProcesses/highlightsPostProcess.ts":
  118327. /*!************************************************!*\
  118328. !*** ./PostProcesses/highlightsPostProcess.ts ***!
  118329. \************************************************/
  118330. /*! exports provided: HighlightsPostProcess */
  118331. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118332. "use strict";
  118333. __webpack_require__.r(__webpack_exports__);
  118334. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return HighlightsPostProcess; });
  118335. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118336. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118337. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118338. /* harmony import */ var _Shaders_highlights_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/highlights.fragment */ "./Shaders/highlights.fragment.ts");
  118339. /**
  118340. * Extracts highlights from the image
  118341. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118342. */
  118343. var HighlightsPostProcess = /** @class */ (function (_super) {
  118344. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](HighlightsPostProcess, _super);
  118345. /**
  118346. * Extracts highlights from the image
  118347. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  118348. * @param name The name of the effect.
  118349. * @param options The required width/height ratio to downsize to before computing the render pass.
  118350. * @param camera The camera to apply the render pass to.
  118351. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118352. * @param engine The engine which the post process will be applied. (default: current engine)
  118353. * @param reusable If the post process can be reused on the same frame. (default: false)
  118354. * @param textureType Type of texture for the post process (default: Engine.TEXTURETYPE_UNSIGNED_INT)
  118355. */
  118356. function HighlightsPostProcess(name, options, camera, samplingMode, engine, reusable, textureType) {
  118357. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118358. return _super.call(this, name, "highlights", null, null, options, camera, samplingMode, engine, reusable, null, textureType) || this;
  118359. }
  118360. return HighlightsPostProcess;
  118361. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  118362. /***/ }),
  118363. /***/ "./PostProcesses/imageProcessingPostProcess.ts":
  118364. /*!*****************************************************!*\
  118365. !*** ./PostProcesses/imageProcessingPostProcess.ts ***!
  118366. \*****************************************************/
  118367. /*! exports provided: ImageProcessingPostProcess */
  118368. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118369. "use strict";
  118370. __webpack_require__.r(__webpack_exports__);
  118371. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return ImageProcessingPostProcess; });
  118372. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118373. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  118374. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  118375. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118376. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  118377. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118378. /* harmony import */ var _Shaders_imageProcessing_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/imageProcessing.fragment */ "./Shaders/imageProcessing.fragment.ts");
  118379. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  118380. /**
  118381. * ImageProcessingPostProcess
  118382. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#imageprocessing
  118383. */
  118384. var ImageProcessingPostProcess = /** @class */ (function (_super) {
  118385. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](ImageProcessingPostProcess, _super);
  118386. function ImageProcessingPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, imageProcessingConfiguration) {
  118387. if (camera === void 0) { camera = null; }
  118388. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118389. var _this = _super.call(this, name, "imageProcessing", [], [], options, camera, samplingMode, engine, reusable, null, textureType, "postprocess", null, true) || this;
  118390. _this._fromLinearSpace = true;
  118391. /**
  118392. * Defines cache preventing GC.
  118393. */
  118394. _this._defines = {
  118395. IMAGEPROCESSING: false,
  118396. VIGNETTE: false,
  118397. VIGNETTEBLENDMODEMULTIPLY: false,
  118398. VIGNETTEBLENDMODEOPAQUE: false,
  118399. TONEMAPPING: false,
  118400. TONEMAPPING_ACES: false,
  118401. CONTRAST: false,
  118402. COLORCURVES: false,
  118403. COLORGRADING: false,
  118404. COLORGRADING3D: false,
  118405. FROMLINEARSPACE: false,
  118406. SAMPLER3DGREENDEPTH: false,
  118407. SAMPLER3DBGRMAP: false,
  118408. IMAGEPROCESSINGPOSTPROCESS: false,
  118409. EXPOSURE: false,
  118410. };
  118411. // Setup the configuration as forced by the constructor. This would then not force the
  118412. // scene materials output in linear space and let untouched the default forward pass.
  118413. if (imageProcessingConfiguration) {
  118414. imageProcessingConfiguration.applyByPostProcess = true;
  118415. _this._attachImageProcessingConfiguration(imageProcessingConfiguration, true);
  118416. // This will cause the shader to be compiled
  118417. _this.fromLinearSpace = false;
  118418. }
  118419. // Setup the default processing configuration to the scene.
  118420. else {
  118421. _this._attachImageProcessingConfiguration(null, true);
  118422. _this.imageProcessingConfiguration.applyByPostProcess = true;
  118423. }
  118424. _this.onApply = function (effect) {
  118425. _this.imageProcessingConfiguration.bind(effect, _this.aspectRatio);
  118426. };
  118427. return _this;
  118428. }
  118429. Object.defineProperty(ImageProcessingPostProcess.prototype, "imageProcessingConfiguration", {
  118430. /**
  118431. * Gets the image processing configuration used either in this material.
  118432. */
  118433. get: function () {
  118434. return this._imageProcessingConfiguration;
  118435. },
  118436. /**
  118437. * Sets the Default image processing configuration used either in the this material.
  118438. *
  118439. * If sets to null, the scene one is in use.
  118440. */
  118441. set: function (value) {
  118442. this._attachImageProcessingConfiguration(value);
  118443. },
  118444. enumerable: true,
  118445. configurable: true
  118446. });
  118447. /**
  118448. * Attaches a new image processing configuration to the PBR Material.
  118449. * @param configuration
  118450. */
  118451. ImageProcessingPostProcess.prototype._attachImageProcessingConfiguration = function (configuration, doNotBuild) {
  118452. var _this = this;
  118453. if (doNotBuild === void 0) { doNotBuild = false; }
  118454. if (configuration === this._imageProcessingConfiguration) {
  118455. return;
  118456. }
  118457. // Detaches observer.
  118458. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  118459. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  118460. }
  118461. // Pick the scene configuration if needed.
  118462. if (!configuration) {
  118463. var scene = null;
  118464. var engine = this.getEngine();
  118465. var camera = this.getCamera();
  118466. if (camera) {
  118467. scene = camera.getScene();
  118468. }
  118469. else if (engine && engine.scenes) {
  118470. var scenes = engine.scenes;
  118471. scene = scenes[scenes.length - 1];
  118472. }
  118473. else {
  118474. scene = _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene;
  118475. }
  118476. this._imageProcessingConfiguration = scene.imageProcessingConfiguration;
  118477. }
  118478. else {
  118479. this._imageProcessingConfiguration = configuration;
  118480. }
  118481. // Attaches observer.
  118482. if (this._imageProcessingConfiguration) {
  118483. this._imageProcessingObserver = this._imageProcessingConfiguration.onUpdateParameters.add(function () {
  118484. _this._updateParameters();
  118485. });
  118486. }
  118487. // Ensure the effect will be rebuilt.
  118488. if (!doNotBuild) {
  118489. this._updateParameters();
  118490. }
  118491. };
  118492. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurves", {
  118493. /**
  118494. * Gets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118495. */
  118496. get: function () {
  118497. return this.imageProcessingConfiguration.colorCurves;
  118498. },
  118499. /**
  118500. * Sets Color curves setup used in the effect if colorCurvesEnabled is set to true .
  118501. */
  118502. set: function (value) {
  118503. this.imageProcessingConfiguration.colorCurves = value;
  118504. },
  118505. enumerable: true,
  118506. configurable: true
  118507. });
  118508. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorCurvesEnabled", {
  118509. /**
  118510. * Gets wether the color curves effect is enabled.
  118511. */
  118512. get: function () {
  118513. return this.imageProcessingConfiguration.colorCurvesEnabled;
  118514. },
  118515. /**
  118516. * Sets wether the color curves effect is enabled.
  118517. */
  118518. set: function (value) {
  118519. this.imageProcessingConfiguration.colorCurvesEnabled = value;
  118520. },
  118521. enumerable: true,
  118522. configurable: true
  118523. });
  118524. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingTexture", {
  118525. /**
  118526. * Gets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118527. */
  118528. get: function () {
  118529. return this.imageProcessingConfiguration.colorGradingTexture;
  118530. },
  118531. /**
  118532. * Sets Color grading LUT texture used in the effect if colorGradingEnabled is set to true.
  118533. */
  118534. set: function (value) {
  118535. this.imageProcessingConfiguration.colorGradingTexture = value;
  118536. },
  118537. enumerable: true,
  118538. configurable: true
  118539. });
  118540. Object.defineProperty(ImageProcessingPostProcess.prototype, "colorGradingEnabled", {
  118541. /**
  118542. * Gets wether the color grading effect is enabled.
  118543. */
  118544. get: function () {
  118545. return this.imageProcessingConfiguration.colorGradingEnabled;
  118546. },
  118547. /**
  118548. * Gets wether the color grading effect is enabled.
  118549. */
  118550. set: function (value) {
  118551. this.imageProcessingConfiguration.colorGradingEnabled = value;
  118552. },
  118553. enumerable: true,
  118554. configurable: true
  118555. });
  118556. Object.defineProperty(ImageProcessingPostProcess.prototype, "exposure", {
  118557. /**
  118558. * Gets exposure used in the effect.
  118559. */
  118560. get: function () {
  118561. return this.imageProcessingConfiguration.exposure;
  118562. },
  118563. /**
  118564. * Sets exposure used in the effect.
  118565. */
  118566. set: function (value) {
  118567. this.imageProcessingConfiguration.exposure = value;
  118568. },
  118569. enumerable: true,
  118570. configurable: true
  118571. });
  118572. Object.defineProperty(ImageProcessingPostProcess.prototype, "toneMappingEnabled", {
  118573. /**
  118574. * Gets wether tonemapping is enabled or not.
  118575. */
  118576. get: function () {
  118577. return this._imageProcessingConfiguration.toneMappingEnabled;
  118578. },
  118579. /**
  118580. * Sets wether tonemapping is enabled or not
  118581. */
  118582. set: function (value) {
  118583. this._imageProcessingConfiguration.toneMappingEnabled = value;
  118584. },
  118585. enumerable: true,
  118586. configurable: true
  118587. });
  118588. Object.defineProperty(ImageProcessingPostProcess.prototype, "contrast", {
  118589. /**
  118590. * Gets contrast used in the effect.
  118591. */
  118592. get: function () {
  118593. return this.imageProcessingConfiguration.contrast;
  118594. },
  118595. /**
  118596. * Sets contrast used in the effect.
  118597. */
  118598. set: function (value) {
  118599. this.imageProcessingConfiguration.contrast = value;
  118600. },
  118601. enumerable: true,
  118602. configurable: true
  118603. });
  118604. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteStretch", {
  118605. /**
  118606. * Gets Vignette stretch size.
  118607. */
  118608. get: function () {
  118609. return this.imageProcessingConfiguration.vignetteStretch;
  118610. },
  118611. /**
  118612. * Sets Vignette stretch size.
  118613. */
  118614. set: function (value) {
  118615. this.imageProcessingConfiguration.vignetteStretch = value;
  118616. },
  118617. enumerable: true,
  118618. configurable: true
  118619. });
  118620. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreX", {
  118621. /**
  118622. * Gets Vignette centre X Offset.
  118623. */
  118624. get: function () {
  118625. return this.imageProcessingConfiguration.vignetteCentreX;
  118626. },
  118627. /**
  118628. * Sets Vignette centre X Offset.
  118629. */
  118630. set: function (value) {
  118631. this.imageProcessingConfiguration.vignetteCentreX = value;
  118632. },
  118633. enumerable: true,
  118634. configurable: true
  118635. });
  118636. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCentreY", {
  118637. /**
  118638. * Gets Vignette centre Y Offset.
  118639. */
  118640. get: function () {
  118641. return this.imageProcessingConfiguration.vignetteCentreY;
  118642. },
  118643. /**
  118644. * Sets Vignette centre Y Offset.
  118645. */
  118646. set: function (value) {
  118647. this.imageProcessingConfiguration.vignetteCentreY = value;
  118648. },
  118649. enumerable: true,
  118650. configurable: true
  118651. });
  118652. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteWeight", {
  118653. /**
  118654. * Gets Vignette weight or intensity of the vignette effect.
  118655. */
  118656. get: function () {
  118657. return this.imageProcessingConfiguration.vignetteWeight;
  118658. },
  118659. /**
  118660. * Sets Vignette weight or intensity of the vignette effect.
  118661. */
  118662. set: function (value) {
  118663. this.imageProcessingConfiguration.vignetteWeight = value;
  118664. },
  118665. enumerable: true,
  118666. configurable: true
  118667. });
  118668. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteColor", {
  118669. /**
  118670. * Gets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118671. * if vignetteEnabled is set to true.
  118672. */
  118673. get: function () {
  118674. return this.imageProcessingConfiguration.vignetteColor;
  118675. },
  118676. /**
  118677. * Sets Color of the vignette applied on the screen through the chosen blend mode (vignetteBlendMode)
  118678. * if vignetteEnabled is set to true.
  118679. */
  118680. set: function (value) {
  118681. this.imageProcessingConfiguration.vignetteColor = value;
  118682. },
  118683. enumerable: true,
  118684. configurable: true
  118685. });
  118686. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteCameraFov", {
  118687. /**
  118688. * Gets Camera field of view used by the Vignette effect.
  118689. */
  118690. get: function () {
  118691. return this.imageProcessingConfiguration.vignetteCameraFov;
  118692. },
  118693. /**
  118694. * Sets Camera field of view used by the Vignette effect.
  118695. */
  118696. set: function (value) {
  118697. this.imageProcessingConfiguration.vignetteCameraFov = value;
  118698. },
  118699. enumerable: true,
  118700. configurable: true
  118701. });
  118702. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteBlendMode", {
  118703. /**
  118704. * Gets the vignette blend mode allowing different kind of effect.
  118705. */
  118706. get: function () {
  118707. return this.imageProcessingConfiguration.vignetteBlendMode;
  118708. },
  118709. /**
  118710. * Sets the vignette blend mode allowing different kind of effect.
  118711. */
  118712. set: function (value) {
  118713. this.imageProcessingConfiguration.vignetteBlendMode = value;
  118714. },
  118715. enumerable: true,
  118716. configurable: true
  118717. });
  118718. Object.defineProperty(ImageProcessingPostProcess.prototype, "vignetteEnabled", {
  118719. /**
  118720. * Gets wether the vignette effect is enabled.
  118721. */
  118722. get: function () {
  118723. return this.imageProcessingConfiguration.vignetteEnabled;
  118724. },
  118725. /**
  118726. * Sets wether the vignette effect is enabled.
  118727. */
  118728. set: function (value) {
  118729. this.imageProcessingConfiguration.vignetteEnabled = value;
  118730. },
  118731. enumerable: true,
  118732. configurable: true
  118733. });
  118734. Object.defineProperty(ImageProcessingPostProcess.prototype, "fromLinearSpace", {
  118735. /**
  118736. * Gets wether the input of the processing is in Gamma or Linear Space.
  118737. */
  118738. get: function () {
  118739. return this._fromLinearSpace;
  118740. },
  118741. /**
  118742. * Sets wether the input of the processing is in Gamma or Linear Space.
  118743. */
  118744. set: function (value) {
  118745. if (this._fromLinearSpace === value) {
  118746. return;
  118747. }
  118748. this._fromLinearSpace = value;
  118749. this._updateParameters();
  118750. },
  118751. enumerable: true,
  118752. configurable: true
  118753. });
  118754. /**
  118755. * "ImageProcessingPostProcess"
  118756. * @returns "ImageProcessingPostProcess"
  118757. */
  118758. ImageProcessingPostProcess.prototype.getClassName = function () {
  118759. return "ImageProcessingPostProcess";
  118760. };
  118761. ImageProcessingPostProcess.prototype._updateParameters = function () {
  118762. this._defines.FROMLINEARSPACE = this._fromLinearSpace;
  118763. this.imageProcessingConfiguration.prepareDefines(this._defines, true);
  118764. var defines = "";
  118765. for (var define in this._defines) {
  118766. if (this._defines[define]) {
  118767. defines += "#define " + define + ";\r\n";
  118768. }
  118769. }
  118770. var samplers = ["textureSampler"];
  118771. var uniforms = ["scale"];
  118772. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"]) {
  118773. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareSamplers(samplers, this._defines);
  118774. _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_2__["ImageProcessingConfiguration"].PrepareUniforms(uniforms, this._defines);
  118775. }
  118776. this.updateEffect(defines, uniforms, samplers);
  118777. };
  118778. ImageProcessingPostProcess.prototype.dispose = function (camera) {
  118779. _super.prototype.dispose.call(this, camera);
  118780. if (this._imageProcessingConfiguration && this._imageProcessingObserver) {
  118781. this._imageProcessingConfiguration.onUpdateParameters.remove(this._imageProcessingObserver);
  118782. }
  118783. if (this._imageProcessingConfiguration) {
  118784. this.imageProcessingConfiguration.applyByPostProcess = false;
  118785. }
  118786. };
  118787. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  118788. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  118789. ], ImageProcessingPostProcess.prototype, "_fromLinearSpace", void 0);
  118790. return ImageProcessingPostProcess;
  118791. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118792. /***/ }),
  118793. /***/ "./PostProcesses/index.ts":
  118794. /*!********************************!*\
  118795. !*** ./PostProcesses/index.ts ***!
  118796. \********************************/
  118797. /*! exports provided: AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  118798. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118799. "use strict";
  118800. __webpack_require__.r(__webpack_exports__);
  118801. /* harmony import */ var _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./anaglyphPostProcess */ "./PostProcesses/anaglyphPostProcess.ts");
  118802. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _anaglyphPostProcess__WEBPACK_IMPORTED_MODULE_0__["AnaglyphPostProcess"]; });
  118803. /* harmony import */ var _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./blackAndWhitePostProcess */ "./PostProcesses/blackAndWhitePostProcess.ts");
  118804. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _blackAndWhitePostProcess__WEBPACK_IMPORTED_MODULE_1__["BlackAndWhitePostProcess"]; });
  118805. /* harmony import */ var _bloomEffect__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./bloomEffect */ "./PostProcesses/bloomEffect.ts");
  118806. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _bloomEffect__WEBPACK_IMPORTED_MODULE_2__["BloomEffect"]; });
  118807. /* harmony import */ var _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./bloomMergePostProcess */ "./PostProcesses/bloomMergePostProcess.ts");
  118808. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _bloomMergePostProcess__WEBPACK_IMPORTED_MODULE_3__["BloomMergePostProcess"]; });
  118809. /* harmony import */ var _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./blurPostProcess */ "./PostProcesses/blurPostProcess.ts");
  118810. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _blurPostProcess__WEBPACK_IMPORTED_MODULE_4__["BlurPostProcess"]; });
  118811. /* harmony import */ var _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./chromaticAberrationPostProcess */ "./PostProcesses/chromaticAberrationPostProcess.ts");
  118812. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _chromaticAberrationPostProcess__WEBPACK_IMPORTED_MODULE_5__["ChromaticAberrationPostProcess"]; });
  118813. /* harmony import */ var _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./circleOfConfusionPostProcess */ "./PostProcesses/circleOfConfusionPostProcess.ts");
  118814. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _circleOfConfusionPostProcess__WEBPACK_IMPORTED_MODULE_6__["CircleOfConfusionPostProcess"]; });
  118815. /* harmony import */ var _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./colorCorrectionPostProcess */ "./PostProcesses/colorCorrectionPostProcess.ts");
  118816. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _colorCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_7__["ColorCorrectionPostProcess"]; });
  118817. /* harmony import */ var _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./convolutionPostProcess */ "./PostProcesses/convolutionPostProcess.ts");
  118818. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _convolutionPostProcess__WEBPACK_IMPORTED_MODULE_8__["ConvolutionPostProcess"]; });
  118819. /* harmony import */ var _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./depthOfFieldBlurPostProcess */ "./PostProcesses/depthOfFieldBlurPostProcess.ts");
  118820. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _depthOfFieldBlurPostProcess__WEBPACK_IMPORTED_MODULE_9__["DepthOfFieldBlurPostProcess"]; });
  118821. /* harmony import */ var _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./depthOfFieldEffect */ "./PostProcesses/depthOfFieldEffect.ts");
  118822. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffectBlurLevel"]; });
  118823. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _depthOfFieldEffect__WEBPACK_IMPORTED_MODULE_10__["DepthOfFieldEffect"]; });
  118824. /* harmony import */ var _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./depthOfFieldMergePostProcess */ "./PostProcesses/depthOfFieldMergePostProcess.ts");
  118825. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcessOptions"]; });
  118826. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _depthOfFieldMergePostProcess__WEBPACK_IMPORTED_MODULE_11__["DepthOfFieldMergePostProcess"]; });
  118827. /* harmony import */ var _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./displayPassPostProcess */ "./PostProcesses/displayPassPostProcess.ts");
  118828. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _displayPassPostProcess__WEBPACK_IMPORTED_MODULE_12__["DisplayPassPostProcess"]; });
  118829. /* harmony import */ var _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./extractHighlightsPostProcess */ "./PostProcesses/extractHighlightsPostProcess.ts");
  118830. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _extractHighlightsPostProcess__WEBPACK_IMPORTED_MODULE_13__["ExtractHighlightsPostProcess"]; });
  118831. /* harmony import */ var _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./filterPostProcess */ "./PostProcesses/filterPostProcess.ts");
  118832. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _filterPostProcess__WEBPACK_IMPORTED_MODULE_14__["FilterPostProcess"]; });
  118833. /* harmony import */ var _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./fxaaPostProcess */ "./PostProcesses/fxaaPostProcess.ts");
  118834. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _fxaaPostProcess__WEBPACK_IMPORTED_MODULE_15__["FxaaPostProcess"]; });
  118835. /* harmony import */ var _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./grainPostProcess */ "./PostProcesses/grainPostProcess.ts");
  118836. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _grainPostProcess__WEBPACK_IMPORTED_MODULE_16__["GrainPostProcess"]; });
  118837. /* harmony import */ var _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./highlightsPostProcess */ "./PostProcesses/highlightsPostProcess.ts");
  118838. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _highlightsPostProcess__WEBPACK_IMPORTED_MODULE_17__["HighlightsPostProcess"]; });
  118839. /* harmony import */ var _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./imageProcessingPostProcess */ "./PostProcesses/imageProcessingPostProcess.ts");
  118840. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _imageProcessingPostProcess__WEBPACK_IMPORTED_MODULE_18__["ImageProcessingPostProcess"]; });
  118841. /* harmony import */ var _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./motionBlurPostProcess */ "./PostProcesses/motionBlurPostProcess.ts");
  118842. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _motionBlurPostProcess__WEBPACK_IMPORTED_MODULE_19__["MotionBlurPostProcess"]; });
  118843. /* harmony import */ var _passPostProcess__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./passPostProcess */ "./PostProcesses/passPostProcess.ts");
  118844. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassPostProcess"]; });
  118845. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _passPostProcess__WEBPACK_IMPORTED_MODULE_20__["PassCubePostProcess"]; });
  118846. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118847. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _postProcess__WEBPACK_IMPORTED_MODULE_21__["PostProcess"]; });
  118848. /* harmony import */ var _postProcessManager__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./postProcessManager */ "./PostProcesses/postProcessManager.ts");
  118849. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _postProcessManager__WEBPACK_IMPORTED_MODULE_22__["PostProcessManager"]; });
  118850. /* harmony import */ var _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./refractionPostProcess */ "./PostProcesses/refractionPostProcess.ts");
  118851. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _refractionPostProcess__WEBPACK_IMPORTED_MODULE_23__["RefractionPostProcess"]; });
  118852. /* harmony import */ var _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./RenderPipeline/index */ "./PostProcesses/RenderPipeline/index.ts");
  118853. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderEffect"]; });
  118854. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipeline"]; });
  118855. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManager"]; });
  118856. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["PostProcessRenderPipelineManagerSceneComponent"]; });
  118857. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["DefaultRenderingPipeline"]; });
  118858. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["LensRenderingPipeline"]; });
  118859. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAO2RenderingPipeline"]; });
  118860. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["SSAORenderingPipeline"]; });
  118861. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _RenderPipeline_index__WEBPACK_IMPORTED_MODULE_24__["StandardRenderingPipeline"]; });
  118862. /* harmony import */ var _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./sharpenPostProcess */ "./PostProcesses/sharpenPostProcess.ts");
  118863. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _sharpenPostProcess__WEBPACK_IMPORTED_MODULE_25__["SharpenPostProcess"]; });
  118864. /* harmony import */ var _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./stereoscopicInterlacePostProcess */ "./PostProcesses/stereoscopicInterlacePostProcess.ts");
  118865. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _stereoscopicInterlacePostProcess__WEBPACK_IMPORTED_MODULE_26__["StereoscopicInterlacePostProcess"]; });
  118866. /* harmony import */ var _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./tonemapPostProcess */ "./PostProcesses/tonemapPostProcess.ts");
  118867. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemappingOperator"]; });
  118868. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _tonemapPostProcess__WEBPACK_IMPORTED_MODULE_27__["TonemapPostProcess"]; });
  118869. /* harmony import */ var _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./volumetricLightScatteringPostProcess */ "./PostProcesses/volumetricLightScatteringPostProcess.ts");
  118870. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _volumetricLightScatteringPostProcess__WEBPACK_IMPORTED_MODULE_28__["VolumetricLightScatteringPostProcess"]; });
  118871. /* harmony import */ var _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./vrDistortionCorrectionPostProcess */ "./PostProcesses/vrDistortionCorrectionPostProcess.ts");
  118872. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _vrDistortionCorrectionPostProcess__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  118873. /***/ }),
  118874. /***/ "./PostProcesses/motionBlurPostProcess.ts":
  118875. /*!************************************************!*\
  118876. !*** ./PostProcesses/motionBlurPostProcess.ts ***!
  118877. \************************************************/
  118878. /*! exports provided: MotionBlurPostProcess */
  118879. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118880. "use strict";
  118881. __webpack_require__.r(__webpack_exports__);
  118882. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return MotionBlurPostProcess; });
  118883. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118884. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  118885. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  118886. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118887. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118888. /* harmony import */ var _Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Rendering/geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  118889. /* harmony import */ var _Shaders_motionBlur_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/motionBlur.fragment */ "./Shaders/motionBlur.fragment.ts");
  118890. /**
  118891. * The Motion Blur Post Process which blurs an image based on the objects velocity in scene.
  118892. * Velocity can be affected by each object's rotation, position and scale depending on the transformation speed.
  118893. * As an example, all you have to do is to create the post-process:
  118894. * var mb = new BABYLON.MotionBlurPostProcess(
  118895. * 'mb', // The name of the effect.
  118896. * scene, // The scene containing the objects to blur according to their velocity.
  118897. * 1.0, // The required width/height ratio to downsize to before computing the render pass.
  118898. * camera // The camera to apply the render pass to.
  118899. * );
  118900. * Then, all objects moving, rotating and/or scaling will be blurred depending on the transformation speed.
  118901. */
  118902. var MotionBlurPostProcess = /** @class */ (function (_super) {
  118903. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](MotionBlurPostProcess, _super);
  118904. /**
  118905. * Creates a new instance MotionBlurPostProcess
  118906. * @param name The name of the effect.
  118907. * @param scene The scene containing the objects to blur according to their velocity.
  118908. * @param options The required width/height ratio to downsize to before computing the render pass.
  118909. * @param camera The camera to apply the render pass to.
  118910. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  118911. * @param engine The engine which the post process will be applied. (default: current engine)
  118912. * @param reusable If the post process can be reused on the same frame. (default: false)
  118913. * @param textureType Type of textures used when performing the post process. (default: 0)
  118914. * @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)
  118915. */
  118916. function MotionBlurPostProcess(name, scene, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  118917. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  118918. if (blockCompilation === void 0) { blockCompilation = false; }
  118919. 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;
  118920. /**
  118921. * Defines how much the image is blurred by the movement. Default value is equal to 1
  118922. */
  118923. _this.motionStrength = 1;
  118924. _this._motionBlurSamples = 32;
  118925. _this._geometryBufferRenderer = scene.enableGeometryBufferRenderer();
  118926. if (!_this._geometryBufferRenderer) {
  118927. // Geometry buffer renderer is not supported. So, work as a passthrough.
  118928. _Misc_logger__WEBPACK_IMPORTED_MODULE_1__["Logger"].Warn("Multiple Render Target support needed to compute object based motion blur");
  118929. _this.updateEffect();
  118930. }
  118931. else {
  118932. // Geometry buffer renderer is supported.
  118933. _this._geometryBufferRenderer.enableVelocity = true;
  118934. _this.onApply = function (effect) {
  118935. effect.setVector2("screenSize", new _Maths_math__WEBPACK_IMPORTED_MODULE_2__["Vector2"](_this.width, _this.height));
  118936. effect.setFloat("motionScale", scene.getAnimationRatio());
  118937. effect.setFloat("motionStrength", _this.motionStrength);
  118938. if (_this._geometryBufferRenderer) {
  118939. var velocityIndex = _this._geometryBufferRenderer.getTextureIndex(_Rendering_geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRenderer"].VELOCITY_TEXTURE_TYPE);
  118940. effect.setTexture("velocitySampler", _this._geometryBufferRenderer.getGBuffer().textures[velocityIndex]);
  118941. }
  118942. };
  118943. }
  118944. return _this;
  118945. }
  118946. Object.defineProperty(MotionBlurPostProcess.prototype, "motionBlurSamples", {
  118947. /**
  118948. * Gets the number of iterations are used for motion blur quality. Default value is equal to 32
  118949. */
  118950. get: function () {
  118951. return this._motionBlurSamples;
  118952. },
  118953. /**
  118954. * Sets the number of iterations to be used for motion blur quality
  118955. */
  118956. set: function (samples) {
  118957. this._motionBlurSamples = samples;
  118958. if (this._geometryBufferRenderer) {
  118959. this.updateEffect("#define GEOMETRY_SUPPORTED\n#define SAMPLES " + samples.toFixed(1));
  118960. }
  118961. },
  118962. enumerable: true,
  118963. configurable: true
  118964. });
  118965. /**
  118966. * Disposes the post process.
  118967. * @param camera The camera to dispose the post process on.
  118968. */
  118969. MotionBlurPostProcess.prototype.dispose = function (camera) {
  118970. if (this._geometryBufferRenderer) {
  118971. // Clear previous transformation matrices dictionary used to compute objects velocities
  118972. this._geometryBufferRenderer._previousTransformationMatrices = {};
  118973. }
  118974. _super.prototype.dispose.call(this, camera);
  118975. };
  118976. return MotionBlurPostProcess;
  118977. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  118978. /***/ }),
  118979. /***/ "./PostProcesses/passPostProcess.ts":
  118980. /*!******************************************!*\
  118981. !*** ./PostProcesses/passPostProcess.ts ***!
  118982. \******************************************/
  118983. /*! exports provided: PassPostProcess, PassCubePostProcess */
  118984. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  118985. "use strict";
  118986. __webpack_require__.r(__webpack_exports__);
  118987. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return PassPostProcess; });
  118988. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return PassCubePostProcess; });
  118989. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  118990. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  118991. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  118992. /* harmony import */ var _Engines_engine__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engine */ "./Engines/engine.ts");
  118993. /* harmony import */ var _Shaders_pass_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/pass.fragment */ "./Shaders/pass.fragment.ts");
  118994. /* harmony import */ var _Shaders_passCube_fragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/passCube.fragment */ "./Shaders/passCube.fragment.ts");
  118995. /**
  118996. * PassPostProcess which produces an output the same as it's input
  118997. */
  118998. var PassPostProcess = /** @class */ (function (_super) {
  118999. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassPostProcess, _super);
  119000. /**
  119001. * Creates the PassPostProcess
  119002. * @param name The name of the effect.
  119003. * @param options The required width/height ratio to downsize to before computing the render pass.
  119004. * @param camera The camera to apply the render pass to.
  119005. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119006. * @param engine The engine which the post process will be applied. (default: current engine)
  119007. * @param reusable If the post process can be reused on the same frame. (default: false)
  119008. * @param textureType The type of texture to be used when performing the post processing.
  119009. * @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)
  119010. */
  119011. function PassPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119012. if (camera === void 0) { camera = null; }
  119013. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119014. if (blockCompilation === void 0) { blockCompilation = false; }
  119015. return _super.call(this, name, "pass", null, null, options, camera, samplingMode, engine, reusable, undefined, textureType, undefined, null, blockCompilation) || this;
  119016. }
  119017. return PassPostProcess;
  119018. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119019. /**
  119020. * PassCubePostProcess which produces an output the same as it's input (which must be a cube texture)
  119021. */
  119022. var PassCubePostProcess = /** @class */ (function (_super) {
  119023. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](PassCubePostProcess, _super);
  119024. /**
  119025. * Creates the PassCubePostProcess
  119026. * @param name The name of the effect.
  119027. * @param options The required width/height ratio to downsize to before computing the render pass.
  119028. * @param camera The camera to apply the render pass to.
  119029. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119030. * @param engine The engine which the post process will be applied. (default: current engine)
  119031. * @param reusable If the post process can be reused on the same frame. (default: false)
  119032. * @param textureType The type of texture to be used when performing the post processing.
  119033. * @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)
  119034. */
  119035. function PassCubePostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119036. if (camera === void 0) { camera = null; }
  119037. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_1__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119038. if (blockCompilation === void 0) { blockCompilation = false; }
  119039. var _this = _super.call(this, name, "passCube", null, null, options, camera, samplingMode, engine, reusable, "#define POSITIVEX", textureType, undefined, null, blockCompilation) || this;
  119040. _this._face = 0;
  119041. return _this;
  119042. }
  119043. Object.defineProperty(PassCubePostProcess.prototype, "face", {
  119044. /**
  119045. * Gets or sets the cube face to display.
  119046. * * 0 is +X
  119047. * * 1 is -X
  119048. * * 2 is +Y
  119049. * * 3 is -Y
  119050. * * 4 is +Z
  119051. * * 5 is -Z
  119052. */
  119053. get: function () {
  119054. return this._face;
  119055. },
  119056. set: function (value) {
  119057. if (value < 0 || value > 5) {
  119058. return;
  119059. }
  119060. this._face = value;
  119061. switch (this._face) {
  119062. case 0:
  119063. this.updateEffect("#define POSITIVEX");
  119064. break;
  119065. case 1:
  119066. this.updateEffect("#define NEGATIVEX");
  119067. break;
  119068. case 2:
  119069. this.updateEffect("#define POSITIVEY");
  119070. break;
  119071. case 3:
  119072. this.updateEffect("#define NEGATIVEY");
  119073. break;
  119074. case 4:
  119075. this.updateEffect("#define POSITIVEZ");
  119076. break;
  119077. case 5:
  119078. this.updateEffect("#define NEGATIVEZ");
  119079. break;
  119080. }
  119081. },
  119082. enumerable: true,
  119083. configurable: true
  119084. });
  119085. return PassCubePostProcess;
  119086. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119087. _Engines_engine__WEBPACK_IMPORTED_MODULE_3__["Engine"]._RescalePostProcessFactory = function (engine) {
  119088. 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);
  119089. };
  119090. /***/ }),
  119091. /***/ "./PostProcesses/postProcess.ts":
  119092. /*!**************************************!*\
  119093. !*** ./PostProcesses/postProcess.ts ***!
  119094. \**************************************/
  119095. /*! exports provided: PostProcess */
  119096. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119097. "use strict";
  119098. __webpack_require__.r(__webpack_exports__);
  119099. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return PostProcess; });
  119100. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/tools */ "./Misc/tools.ts");
  119101. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  119102. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  119103. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  119104. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119105. /* harmony import */ var _Shaders_postprocess_vertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Shaders/postprocess.vertex */ "./Shaders/postprocess.vertex.ts");
  119106. /**
  119107. * PostProcess can be used to apply a shader to a texture after it has been rendered
  119108. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119109. */
  119110. var PostProcess = /** @class */ (function () {
  119111. /**
  119112. * Creates a new instance PostProcess
  119113. * @param name The name of the PostProcess.
  119114. * @param fragmentUrl The url of the fragment shader to be used.
  119115. * @param parameters Array of the names of uniform non-sampler2D variables that will be passed to the shader.
  119116. * @param samplers Array of the names of uniform sampler2D variables that will be passed to the shader.
  119117. * @param options The required width/height ratio to downsize to before computing the render pass. (Use 1.0 for full size)
  119118. * @param camera The camera to apply the render pass to.
  119119. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119120. * @param engine The engine which the post process will be applied. (default: current engine)
  119121. * @param reusable If the post process can be reused on the same frame. (default: false)
  119122. * @param defines String of defines that will be set when running the fragment shader. (default: null)
  119123. * @param textureType Type of textures used when performing the post process. (default: 0)
  119124. * @param vertexUrl The url of the vertex shader to be used. (default: "postprocess")
  119125. * @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
  119126. * @param blockCompilation If the shader should not be compiled imediatly. (default: false)
  119127. */
  119128. function PostProcess(
  119129. /** Name of the PostProcess. */
  119130. name, fragmentUrl, parameters, samplers, options, camera, samplingMode, engine, reusable, defines, textureType, vertexUrl, indexParameters, blockCompilation) {
  119131. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE; }
  119132. if (defines === void 0) { defines = null; }
  119133. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119134. if (vertexUrl === void 0) { vertexUrl = "postprocess"; }
  119135. if (blockCompilation === void 0) { blockCompilation = false; }
  119136. this.name = name;
  119137. /**
  119138. * Width of the texture to apply the post process on
  119139. */
  119140. this.width = -1;
  119141. /**
  119142. * Height of the texture to apply the post process on
  119143. */
  119144. this.height = -1;
  119145. /**
  119146. * Internal, reference to the location where this postprocess was output to. (Typically the texture on the next postprocess in the chain)
  119147. * @hidden
  119148. */
  119149. this._outputTexture = null;
  119150. /**
  119151. * If the buffer needs to be cleared before applying the post process. (default: true)
  119152. * Should be set to false if shader will overwrite all previous pixels.
  119153. */
  119154. this.autoClear = true;
  119155. /**
  119156. * Type of alpha mode to use when performing the post process (default: Engine.ALPHA_DISABLE)
  119157. */
  119158. this.alphaMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE;
  119159. /**
  119160. * Animations to be used for the post processing
  119161. */
  119162. this.animations = new Array();
  119163. /**
  119164. * Enable Pixel Perfect mode where texture is not scaled to be power of 2.
  119165. * Can only be used on a single postprocess or on the last one of a chain. (default: false)
  119166. */
  119167. this.enablePixelPerfectMode = false;
  119168. /**
  119169. * Force the postprocess to be applied without taking in account viewport
  119170. */
  119171. this.forceFullscreenViewport = true;
  119172. /**
  119173. * Scale mode for the post process (default: Engine.SCALEMODE_FLOOR)
  119174. *
  119175. * | Value | Type | Description |
  119176. * | ----- | ----------------------------------- | ----------- |
  119177. * | 1 | SCALEMODE_FLOOR | [engine.scalemode_floor](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_floor) |
  119178. * | 2 | SCALEMODE_NEAREST | [engine.scalemode_nearest](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_nearest) |
  119179. * | 3 | SCALEMODE_CEILING | [engine.scalemode_ceiling](http://doc.babylonjs.com/api/classes/babylon.engine#scalemode_ceiling) |
  119180. *
  119181. */
  119182. this.scaleMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].SCALEMODE_FLOOR;
  119183. /**
  119184. * Force textures to be a power of two (default: false)
  119185. */
  119186. this.alwaysForcePOT = false;
  119187. this._samples = 1;
  119188. /**
  119189. * Modify the scale of the post process to be the same as the viewport (default: false)
  119190. */
  119191. this.adaptScaleToCurrentViewport = false;
  119192. this._reusable = false;
  119193. /**
  119194. * Smart array of input and output textures for the post process.
  119195. * @hidden
  119196. */
  119197. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  119198. /**
  119199. * The index in _textures that corresponds to the output texture.
  119200. * @hidden
  119201. */
  119202. this._currentRenderTextureInd = 0;
  119203. this._scaleRatio = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"](1, 1);
  119204. this._texelSize = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  119205. // Events
  119206. /**
  119207. * An event triggered when the postprocess is activated.
  119208. */
  119209. this.onActivateObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  119210. /**
  119211. * An event triggered when the postprocess changes its size.
  119212. */
  119213. this.onSizeChangedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  119214. /**
  119215. * An event triggered when the postprocess applies its effect.
  119216. */
  119217. this.onApplyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  119218. /**
  119219. * An event triggered before rendering the postprocess
  119220. */
  119221. this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  119222. /**
  119223. * An event triggered after rendering the postprocess
  119224. */
  119225. this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_2__["Observable"]();
  119226. if (camera != null) {
  119227. this._camera = camera;
  119228. this._scene = camera.getScene();
  119229. camera.attachPostProcess(this);
  119230. this._engine = this._scene.getEngine();
  119231. this._scene.postProcesses.push(this);
  119232. this.uniqueId = this._scene.getUniqueId();
  119233. }
  119234. else if (engine) {
  119235. this._engine = engine;
  119236. this._engine.postProcesses.push(this);
  119237. }
  119238. this._options = options;
  119239. this.renderTargetSamplingMode = samplingMode ? samplingMode : _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_NEAREST_SAMPLINGMODE;
  119240. this._reusable = reusable || false;
  119241. this._textureType = textureType;
  119242. this._samplers = samplers || [];
  119243. this._samplers.push("textureSampler");
  119244. this._fragmentUrl = fragmentUrl;
  119245. this._vertexUrl = vertexUrl;
  119246. this._parameters = parameters || [];
  119247. this._parameters.push("scale");
  119248. this._indexParameters = indexParameters;
  119249. if (!blockCompilation) {
  119250. this.updateEffect(defines);
  119251. }
  119252. }
  119253. Object.defineProperty(PostProcess.prototype, "samples", {
  119254. /**
  119255. * Number of sample textures (default: 1)
  119256. */
  119257. get: function () {
  119258. return this._samples;
  119259. },
  119260. set: function (n) {
  119261. var _this = this;
  119262. this._samples = n;
  119263. this._textures.forEach(function (texture) {
  119264. if (texture.samples !== _this._samples) {
  119265. _this._engine.updateRenderTargetTextureSampleCount(texture, _this._samples);
  119266. }
  119267. });
  119268. },
  119269. enumerable: true,
  119270. configurable: true
  119271. });
  119272. /**
  119273. * Returns the fragment url or shader name used in the post process.
  119274. * @returns the fragment url or name in the shader store.
  119275. */
  119276. PostProcess.prototype.getEffectName = function () {
  119277. return this._fragmentUrl;
  119278. };
  119279. Object.defineProperty(PostProcess.prototype, "onActivate", {
  119280. /**
  119281. * A function that is added to the onActivateObservable
  119282. */
  119283. set: function (callback) {
  119284. if (this._onActivateObserver) {
  119285. this.onActivateObservable.remove(this._onActivateObserver);
  119286. }
  119287. if (callback) {
  119288. this._onActivateObserver = this.onActivateObservable.add(callback);
  119289. }
  119290. },
  119291. enumerable: true,
  119292. configurable: true
  119293. });
  119294. Object.defineProperty(PostProcess.prototype, "onSizeChanged", {
  119295. /**
  119296. * A function that is added to the onSizeChangedObservable
  119297. */
  119298. set: function (callback) {
  119299. if (this._onSizeChangedObserver) {
  119300. this.onSizeChangedObservable.remove(this._onSizeChangedObserver);
  119301. }
  119302. this._onSizeChangedObserver = this.onSizeChangedObservable.add(callback);
  119303. },
  119304. enumerable: true,
  119305. configurable: true
  119306. });
  119307. Object.defineProperty(PostProcess.prototype, "onApply", {
  119308. /**
  119309. * A function that is added to the onApplyObservable
  119310. */
  119311. set: function (callback) {
  119312. if (this._onApplyObserver) {
  119313. this.onApplyObservable.remove(this._onApplyObserver);
  119314. }
  119315. this._onApplyObserver = this.onApplyObservable.add(callback);
  119316. },
  119317. enumerable: true,
  119318. configurable: true
  119319. });
  119320. Object.defineProperty(PostProcess.prototype, "onBeforeRender", {
  119321. /**
  119322. * A function that is added to the onBeforeRenderObservable
  119323. */
  119324. set: function (callback) {
  119325. if (this._onBeforeRenderObserver) {
  119326. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  119327. }
  119328. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  119329. },
  119330. enumerable: true,
  119331. configurable: true
  119332. });
  119333. Object.defineProperty(PostProcess.prototype, "onAfterRender", {
  119334. /**
  119335. * A function that is added to the onAfterRenderObservable
  119336. */
  119337. set: function (callback) {
  119338. if (this._onAfterRenderObserver) {
  119339. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  119340. }
  119341. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  119342. },
  119343. enumerable: true,
  119344. configurable: true
  119345. });
  119346. Object.defineProperty(PostProcess.prototype, "inputTexture", {
  119347. /**
  119348. * 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
  119349. * render it's output into this texture and this texture will be used as textureSampler in the fragment shader of this post process.
  119350. */
  119351. get: function () {
  119352. return this._textures.data[this._currentRenderTextureInd];
  119353. },
  119354. set: function (value) {
  119355. this._forcedOutputTexture = value;
  119356. },
  119357. enumerable: true,
  119358. configurable: true
  119359. });
  119360. /**
  119361. * Gets the camera which post process is applied to.
  119362. * @returns The camera the post process is applied to.
  119363. */
  119364. PostProcess.prototype.getCamera = function () {
  119365. return this._camera;
  119366. };
  119367. Object.defineProperty(PostProcess.prototype, "texelSize", {
  119368. /**
  119369. * Gets the texel size of the postprocess.
  119370. * See https://en.wikipedia.org/wiki/Texel_(graphics)
  119371. */
  119372. get: function () {
  119373. if (this._shareOutputWithPostProcess) {
  119374. return this._shareOutputWithPostProcess.texelSize;
  119375. }
  119376. if (this._forcedOutputTexture) {
  119377. this._texelSize.copyFromFloats(1.0 / this._forcedOutputTexture.width, 1.0 / this._forcedOutputTexture.height);
  119378. }
  119379. return this._texelSize;
  119380. },
  119381. enumerable: true,
  119382. configurable: true
  119383. });
  119384. /**
  119385. * Gets a string idenfifying the name of the class
  119386. * @returns "PostProcess" string
  119387. */
  119388. PostProcess.prototype.getClassName = function () {
  119389. return "PostProcess";
  119390. };
  119391. /**
  119392. * Gets the engine which this post process belongs to.
  119393. * @returns The engine the post process was enabled with.
  119394. */
  119395. PostProcess.prototype.getEngine = function () {
  119396. return this._engine;
  119397. };
  119398. /**
  119399. * The effect that is created when initializing the post process.
  119400. * @returns The created effect corrisponding the the postprocess.
  119401. */
  119402. PostProcess.prototype.getEffect = function () {
  119403. return this._effect;
  119404. };
  119405. /**
  119406. * To avoid multiple redundant textures for multiple post process, the output the output texture for this post process can be shared with another.
  119407. * @param postProcess The post process to share the output with.
  119408. * @returns This post process.
  119409. */
  119410. PostProcess.prototype.shareOutputWith = function (postProcess) {
  119411. this._disposeTextures();
  119412. this._shareOutputWithPostProcess = postProcess;
  119413. return this;
  119414. };
  119415. /**
  119416. * Reverses the effect of calling shareOutputWith and returns the post process back to its original state.
  119417. * This should be called if the post process that shares output with this post process is disabled/disposed.
  119418. */
  119419. PostProcess.prototype.useOwnOutput = function () {
  119420. if (this._textures.length == 0) {
  119421. this._textures = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_1__["SmartArray"](2);
  119422. }
  119423. this._shareOutputWithPostProcess = null;
  119424. };
  119425. /**
  119426. * Updates the effect with the current post process compile time values and recompiles the shader.
  119427. * @param defines Define statements that should be added at the beginning of the shader. (default: null)
  119428. * @param uniforms Set of uniform variables that will be passed to the shader. (default: null)
  119429. * @param samplers Set of Texture2D variables that will be passed to the shader. (default: null)
  119430. * @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
  119431. * @param onCompiled Called when the shader has been compiled.
  119432. * @param onError Called if there is an error when compiling a shader.
  119433. */
  119434. PostProcess.prototype.updateEffect = function (defines, uniforms, samplers, indexParameters, onCompiled, onError) {
  119435. if (defines === void 0) { defines = null; }
  119436. if (uniforms === void 0) { uniforms = null; }
  119437. if (samplers === void 0) { samplers = null; }
  119438. 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);
  119439. };
  119440. /**
  119441. * The post process is reusable if it can be used multiple times within one frame.
  119442. * @returns If the post process is reusable
  119443. */
  119444. PostProcess.prototype.isReusable = function () {
  119445. return this._reusable;
  119446. };
  119447. /** invalidate frameBuffer to hint the postprocess to create a depth buffer */
  119448. PostProcess.prototype.markTextureDirty = function () {
  119449. this.width = -1;
  119450. };
  119451. /**
  119452. * Activates the post process by intializing the textures to be used when executed. Notifies onActivateObservable.
  119453. * 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.
  119454. * @param camera The camera that will be used in the post process. This camera will be used when calling onActivateObservable.
  119455. * @param sourceTexture The source texture to be inspected to get the width and height if not specified in the post process constructor. (default: null)
  119456. * @param forceDepthStencil If true, a depth and stencil buffer will be generated. (default: false)
  119457. * @returns The target texture that was bound to be written to.
  119458. */
  119459. PostProcess.prototype.activate = function (camera, sourceTexture, forceDepthStencil) {
  119460. var _this = this;
  119461. if (sourceTexture === void 0) { sourceTexture = null; }
  119462. camera = camera || this._camera;
  119463. var scene = camera.getScene();
  119464. var engine = scene.getEngine();
  119465. var maxSize = engine.getCaps().maxTextureSize;
  119466. var requiredWidth = ((sourceTexture ? sourceTexture.width : this._engine.getRenderWidth(true)) * this._options) | 0;
  119467. var requiredHeight = ((sourceTexture ? sourceTexture.height : this._engine.getRenderHeight(true)) * this._options) | 0;
  119468. // 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
  119469. var webVRCamera = camera.parent;
  119470. if (webVRCamera && (webVRCamera.leftCamera == camera || webVRCamera.rightCamera == camera)) {
  119471. requiredWidth /= 2;
  119472. }
  119473. var desiredWidth = (this._options.width || requiredWidth);
  119474. var desiredHeight = this._options.height || requiredHeight;
  119475. if (!this._shareOutputWithPostProcess && !this._forcedOutputTexture) {
  119476. if (this.adaptScaleToCurrentViewport) {
  119477. var currentViewport = engine.currentViewport;
  119478. if (currentViewport) {
  119479. desiredWidth *= currentViewport.width;
  119480. desiredHeight *= currentViewport.height;
  119481. }
  119482. }
  119483. if (this.renderTargetSamplingMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].TEXTURE_TRILINEAR_SAMPLINGMODE || this.alwaysForcePOT) {
  119484. if (!this._options.width) {
  119485. desiredWidth = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredWidth, maxSize, this.scaleMode) : desiredWidth;
  119486. }
  119487. if (!this._options.height) {
  119488. desiredHeight = engine.needPOTTextures ? _Misc_tools__WEBPACK_IMPORTED_MODULE_0__["Tools"].GetExponentOfTwo(desiredHeight, maxSize, this.scaleMode) : desiredHeight;
  119489. }
  119490. }
  119491. if (this.width !== desiredWidth || this.height !== desiredHeight) {
  119492. if (this._textures.length > 0) {
  119493. for (var i = 0; i < this._textures.length; i++) {
  119494. this._engine._releaseTexture(this._textures.data[i]);
  119495. }
  119496. this._textures.reset();
  119497. }
  119498. this.width = desiredWidth;
  119499. this.height = desiredHeight;
  119500. var textureSize = { width: this.width, height: this.height };
  119501. var textureOptions = {
  119502. generateMipMaps: false,
  119503. generateDepthBuffer: forceDepthStencil || camera._postProcesses.indexOf(this) === 0,
  119504. generateStencilBuffer: (forceDepthStencil || camera._postProcesses.indexOf(this) === 0) && this._engine.isStencilEnable,
  119505. samplingMode: this.renderTargetSamplingMode,
  119506. type: this._textureType
  119507. };
  119508. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  119509. if (this._reusable) {
  119510. this._textures.push(this._engine.createRenderTargetTexture(textureSize, textureOptions));
  119511. }
  119512. this._texelSize.copyFromFloats(1.0 / this.width, 1.0 / this.height);
  119513. this.onSizeChangedObservable.notifyObservers(this);
  119514. }
  119515. this._textures.forEach(function (texture) {
  119516. if (texture.samples !== _this.samples) {
  119517. _this._engine.updateRenderTargetTextureSampleCount(texture, _this.samples);
  119518. }
  119519. });
  119520. }
  119521. var target;
  119522. if (this._shareOutputWithPostProcess) {
  119523. target = this._shareOutputWithPostProcess.inputTexture;
  119524. }
  119525. else if (this._forcedOutputTexture) {
  119526. target = this._forcedOutputTexture;
  119527. this.width = this._forcedOutputTexture.width;
  119528. this.height = this._forcedOutputTexture.height;
  119529. }
  119530. else {
  119531. target = this.inputTexture;
  119532. }
  119533. // Bind the input of this post process to be used as the output of the previous post process.
  119534. if (this.enablePixelPerfectMode) {
  119535. this._scaleRatio.copyFromFloats(requiredWidth / desiredWidth, requiredHeight / desiredHeight);
  119536. this._engine.bindFramebuffer(target, 0, requiredWidth, requiredHeight, this.forceFullscreenViewport);
  119537. }
  119538. else {
  119539. this._scaleRatio.copyFromFloats(1, 1);
  119540. this._engine.bindFramebuffer(target, 0, undefined, undefined, this.forceFullscreenViewport);
  119541. }
  119542. this.onActivateObservable.notifyObservers(camera);
  119543. // Clear
  119544. if (this.autoClear && this.alphaMode === _Engines_constants__WEBPACK_IMPORTED_MODULE_4__["Constants"].ALPHA_DISABLE) {
  119545. this._engine.clear(this.clearColor ? this.clearColor : scene.clearColor, scene._allowPostProcessClearColor, true, true);
  119546. }
  119547. if (this._reusable) {
  119548. this._currentRenderTextureInd = (this._currentRenderTextureInd + 1) % 2;
  119549. }
  119550. return target;
  119551. };
  119552. Object.defineProperty(PostProcess.prototype, "isSupported", {
  119553. /**
  119554. * If the post process is supported.
  119555. */
  119556. get: function () {
  119557. return this._effect.isSupported;
  119558. },
  119559. enumerable: true,
  119560. configurable: true
  119561. });
  119562. Object.defineProperty(PostProcess.prototype, "aspectRatio", {
  119563. /**
  119564. * The aspect ratio of the output texture.
  119565. */
  119566. get: function () {
  119567. if (this._shareOutputWithPostProcess) {
  119568. return this._shareOutputWithPostProcess.aspectRatio;
  119569. }
  119570. if (this._forcedOutputTexture) {
  119571. return this._forcedOutputTexture.width / this._forcedOutputTexture.height;
  119572. }
  119573. return this.width / this.height;
  119574. },
  119575. enumerable: true,
  119576. configurable: true
  119577. });
  119578. /**
  119579. * Get a value indicating if the post-process is ready to be used
  119580. * @returns true if the post-process is ready (shader is compiled)
  119581. */
  119582. PostProcess.prototype.isReady = function () {
  119583. return this._effect && this._effect.isReady();
  119584. };
  119585. /**
  119586. * Binds all textures and uniforms to the shader, this will be run on every pass.
  119587. * @returns the effect corrisponding to this post process. Null if not compiled or not ready.
  119588. */
  119589. PostProcess.prototype.apply = function () {
  119590. // Check
  119591. if (!this._effect || !this._effect.isReady()) {
  119592. return null;
  119593. }
  119594. // States
  119595. this._engine.enableEffect(this._effect);
  119596. this._engine.setState(false);
  119597. this._engine.setDepthBuffer(false);
  119598. this._engine.setDepthWrite(false);
  119599. // Alpha
  119600. this._engine.setAlphaMode(this.alphaMode);
  119601. if (this.alphaConstants) {
  119602. this.getEngine().setAlphaConstants(this.alphaConstants.r, this.alphaConstants.g, this.alphaConstants.b, this.alphaConstants.a);
  119603. }
  119604. // Bind the output texture of the preivous post process as the input to this post process.
  119605. var source;
  119606. if (this._shareOutputWithPostProcess) {
  119607. source = this._shareOutputWithPostProcess.inputTexture;
  119608. }
  119609. else if (this._forcedOutputTexture) {
  119610. source = this._forcedOutputTexture;
  119611. }
  119612. else {
  119613. source = this.inputTexture;
  119614. }
  119615. this._effect._bindTexture("textureSampler", source);
  119616. // Parameters
  119617. this._effect.setVector2("scale", this._scaleRatio);
  119618. this.onApplyObservable.notifyObservers(this._effect);
  119619. return this._effect;
  119620. };
  119621. PostProcess.prototype._disposeTextures = function () {
  119622. if (this._shareOutputWithPostProcess || this._forcedOutputTexture) {
  119623. return;
  119624. }
  119625. if (this._textures.length > 0) {
  119626. for (var i = 0; i < this._textures.length; i++) {
  119627. this._engine._releaseTexture(this._textures.data[i]);
  119628. }
  119629. }
  119630. this._textures.dispose();
  119631. };
  119632. /**
  119633. * Disposes the post process.
  119634. * @param camera The camera to dispose the post process on.
  119635. */
  119636. PostProcess.prototype.dispose = function (camera) {
  119637. camera = camera || this._camera;
  119638. this._disposeTextures();
  119639. if (this._scene) {
  119640. var index_1 = this._scene.postProcesses.indexOf(this);
  119641. if (index_1 !== -1) {
  119642. this._scene.postProcesses.splice(index_1, 1);
  119643. }
  119644. }
  119645. else {
  119646. var index_2 = this._engine.postProcesses.indexOf(this);
  119647. if (index_2 !== -1) {
  119648. this._engine.postProcesses.splice(index_2, 1);
  119649. }
  119650. }
  119651. if (!camera) {
  119652. return;
  119653. }
  119654. camera.detachPostProcess(this);
  119655. var index = camera._postProcesses.indexOf(this);
  119656. if (index === 0 && camera._postProcesses.length > 0) {
  119657. var firstPostProcess = this._camera._getFirstPostProcess();
  119658. if (firstPostProcess) {
  119659. firstPostProcess.markTextureDirty();
  119660. }
  119661. }
  119662. this.onActivateObservable.clear();
  119663. this.onAfterRenderObservable.clear();
  119664. this.onApplyObservable.clear();
  119665. this.onBeforeRenderObservable.clear();
  119666. this.onSizeChangedObservable.clear();
  119667. };
  119668. return PostProcess;
  119669. }());
  119670. /***/ }),
  119671. /***/ "./PostProcesses/postProcessManager.ts":
  119672. /*!*********************************************!*\
  119673. !*** ./PostProcesses/postProcessManager.ts ***!
  119674. \*********************************************/
  119675. /*! exports provided: PostProcessManager */
  119676. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119677. "use strict";
  119678. __webpack_require__.r(__webpack_exports__);
  119679. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return PostProcessManager; });
  119680. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  119681. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  119682. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119683. /**
  119684. * PostProcessManager is used to manage one or more post processes or post process pipelines
  119685. * See https://doc.babylonjs.com/how_to/how_to_use_postprocesses
  119686. */
  119687. var PostProcessManager = /** @class */ (function () {
  119688. /**
  119689. * Creates a new instance PostProcess
  119690. * @param scene The scene that the post process is associated with.
  119691. */
  119692. function PostProcessManager(scene) {
  119693. this._vertexBuffers = {};
  119694. this._scene = scene;
  119695. }
  119696. PostProcessManager.prototype._prepareBuffers = function () {
  119697. if (this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind]) {
  119698. return;
  119699. }
  119700. // VBO
  119701. var vertices = [];
  119702. vertices.push(1, 1);
  119703. vertices.push(-1, 1);
  119704. vertices.push(-1, -1);
  119705. vertices.push(1, -1);
  119706. 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);
  119707. this._buildIndexBuffer();
  119708. };
  119709. PostProcessManager.prototype._buildIndexBuffer = function () {
  119710. // Indices
  119711. var indices = [];
  119712. indices.push(0);
  119713. indices.push(1);
  119714. indices.push(2);
  119715. indices.push(0);
  119716. indices.push(2);
  119717. indices.push(3);
  119718. this._indexBuffer = this._scene.getEngine().createIndexBuffer(indices);
  119719. };
  119720. /**
  119721. * Rebuilds the vertex buffers of the manager.
  119722. * @hidden
  119723. */
  119724. PostProcessManager.prototype._rebuild = function () {
  119725. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119726. if (!vb) {
  119727. return;
  119728. }
  119729. vb._rebuild();
  119730. this._buildIndexBuffer();
  119731. };
  119732. // Methods
  119733. /**
  119734. * Prepares a frame to be run through a post process.
  119735. * @param sourceTexture The input texture to the post procesess. (default: null)
  119736. * @param postProcesses An array of post processes to be run. (default: null)
  119737. * @returns True if the post processes were able to be run.
  119738. * @hidden
  119739. */
  119740. PostProcessManager.prototype._prepareFrame = function (sourceTexture, postProcesses) {
  119741. if (sourceTexture === void 0) { sourceTexture = null; }
  119742. if (postProcesses === void 0) { postProcesses = null; }
  119743. var camera = this._scene.activeCamera;
  119744. if (!camera) {
  119745. return false;
  119746. }
  119747. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119748. if (!postProcesses || postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119749. return false;
  119750. }
  119751. postProcesses[0].activate(camera, sourceTexture, postProcesses !== null && postProcesses !== undefined);
  119752. return true;
  119753. };
  119754. /**
  119755. * Manually render a set of post processes to a texture.
  119756. * @param postProcesses An array of post processes to be run.
  119757. * @param targetTexture The target texture to render to.
  119758. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight
  119759. * @param faceIndex defines the face to render to if a cubemap is defined as the target
  119760. * @param lodLevel defines which lod of the texture to render to
  119761. */
  119762. PostProcessManager.prototype.directRender = function (postProcesses, targetTexture, forceFullscreenViewport, faceIndex, lodLevel) {
  119763. if (targetTexture === void 0) { targetTexture = null; }
  119764. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119765. if (faceIndex === void 0) { faceIndex = 0; }
  119766. if (lodLevel === void 0) { lodLevel = 0; }
  119767. var engine = this._scene.getEngine();
  119768. for (var index = 0; index < postProcesses.length; index++) {
  119769. if (index < postProcesses.length - 1) {
  119770. postProcesses[index + 1].activate(this._scene.activeCamera, targetTexture);
  119771. }
  119772. else {
  119773. if (targetTexture) {
  119774. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport, undefined, lodLevel);
  119775. }
  119776. else {
  119777. engine.restoreDefaultFramebuffer();
  119778. }
  119779. }
  119780. var pp = postProcesses[index];
  119781. var effect = pp.apply();
  119782. if (effect) {
  119783. pp.onBeforeRenderObservable.notifyObservers(effect);
  119784. // VBOs
  119785. this._prepareBuffers();
  119786. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119787. // Draw order
  119788. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119789. pp.onAfterRenderObservable.notifyObservers(effect);
  119790. }
  119791. }
  119792. // Restore depth buffer
  119793. engine.setDepthBuffer(true);
  119794. engine.setDepthWrite(true);
  119795. };
  119796. /**
  119797. * Finalize the result of the output of the postprocesses.
  119798. * @param doNotPresent If true the result will not be displayed to the screen.
  119799. * @param targetTexture The target texture to render to.
  119800. * @param faceIndex The index of the face to bind the target texture to.
  119801. * @param postProcesses The array of post processes to render.
  119802. * @param forceFullscreenViewport force gl.viewport to be full screen eg. 0,0,textureWidth,textureHeight (default: false)
  119803. * @hidden
  119804. */
  119805. PostProcessManager.prototype._finalizeFrame = function (doNotPresent, targetTexture, faceIndex, postProcesses, forceFullscreenViewport) {
  119806. if (forceFullscreenViewport === void 0) { forceFullscreenViewport = false; }
  119807. var camera = this._scene.activeCamera;
  119808. if (!camera) {
  119809. return;
  119810. }
  119811. postProcesses = postProcesses || camera._postProcesses.filter(function (pp) { return pp != null; });
  119812. if (postProcesses.length === 0 || !this._scene.postProcessesEnabled) {
  119813. return;
  119814. }
  119815. var engine = this._scene.getEngine();
  119816. for (var index = 0, len = postProcesses.length; index < len; index++) {
  119817. var pp = postProcesses[index];
  119818. if (index < len - 1) {
  119819. pp._outputTexture = postProcesses[index + 1].activate(camera, targetTexture);
  119820. }
  119821. else {
  119822. if (targetTexture) {
  119823. engine.bindFramebuffer(targetTexture, faceIndex, undefined, undefined, forceFullscreenViewport);
  119824. pp._outputTexture = targetTexture;
  119825. }
  119826. else {
  119827. engine.restoreDefaultFramebuffer();
  119828. pp._outputTexture = null;
  119829. }
  119830. }
  119831. if (doNotPresent) {
  119832. break;
  119833. }
  119834. var effect = pp.apply();
  119835. if (effect) {
  119836. pp.onBeforeRenderObservable.notifyObservers(effect);
  119837. // VBOs
  119838. this._prepareBuffers();
  119839. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  119840. // Draw order
  119841. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_0__["Material"].TriangleFillMode, 0, 6);
  119842. pp.onAfterRenderObservable.notifyObservers(effect);
  119843. }
  119844. }
  119845. // Restore states
  119846. engine.setDepthBuffer(true);
  119847. engine.setDepthWrite(true);
  119848. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  119849. };
  119850. /**
  119851. * Disposes of the post process manager.
  119852. */
  119853. PostProcessManager.prototype.dispose = function () {
  119854. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  119855. if (buffer) {
  119856. buffer.dispose();
  119857. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  119858. }
  119859. if (this._indexBuffer) {
  119860. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  119861. this._indexBuffer = null;
  119862. }
  119863. };
  119864. return PostProcessManager;
  119865. }());
  119866. /***/ }),
  119867. /***/ "./PostProcesses/refractionPostProcess.ts":
  119868. /*!************************************************!*\
  119869. !*** ./PostProcesses/refractionPostProcess.ts ***!
  119870. \************************************************/
  119871. /*! exports provided: RefractionPostProcess */
  119872. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119873. "use strict";
  119874. __webpack_require__.r(__webpack_exports__);
  119875. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return RefractionPostProcess; });
  119876. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119877. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  119878. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119879. /* harmony import */ var _Shaders_refraction_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/refraction.fragment */ "./Shaders/refraction.fragment.ts");
  119880. /**
  119881. * Post process which applies a refractin texture
  119882. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119883. */
  119884. var RefractionPostProcess = /** @class */ (function (_super) {
  119885. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](RefractionPostProcess, _super);
  119886. /**
  119887. * Initializes the RefractionPostProcess
  119888. * @see https://doc.babylonjs.com/how_to/how_to_use_postprocesses#refraction
  119889. * @param name The name of the effect.
  119890. * @param refractionTextureUrl Url of the refraction texture to use
  119891. * @param color the base color of the refraction (used to taint the rendering)
  119892. * @param depth simulated refraction depth
  119893. * @param colorLevel the coefficient of the base color (0 to remove base color tainting)
  119894. * @param camera The camera to apply the render pass to.
  119895. * @param options The required width/height ratio to downsize to before computing the render pass.
  119896. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119897. * @param engine The engine which the post process will be applied. (default: current engine)
  119898. * @param reusable If the post process can be reused on the same frame. (default: false)
  119899. */
  119900. function RefractionPostProcess(name, refractionTextureUrl,
  119901. /** the base color of the refraction (used to taint the rendering) */
  119902. color,
  119903. /** simulated refraction depth */
  119904. depth,
  119905. /** the coefficient of the base color (0 to remove base color tainting) */
  119906. colorLevel, options, camera, samplingMode, engine, reusable) {
  119907. var _this = _super.call(this, name, "refraction", ["baseColor", "depth", "colorLevel"], ["refractionSampler"], options, camera, samplingMode, engine, reusable) || this;
  119908. _this.color = color;
  119909. _this.depth = depth;
  119910. _this.colorLevel = colorLevel;
  119911. _this._ownRefractionTexture = true;
  119912. _this.onActivateObservable.add(function (cam) {
  119913. _this._refTexture = _this._refTexture || new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_1__["Texture"](refractionTextureUrl, cam.getScene());
  119914. });
  119915. _this.onApplyObservable.add(function (effect) {
  119916. effect.setColor3("baseColor", _this.color);
  119917. effect.setFloat("depth", _this.depth);
  119918. effect.setFloat("colorLevel", _this.colorLevel);
  119919. effect.setTexture("refractionSampler", _this._refTexture);
  119920. });
  119921. return _this;
  119922. }
  119923. Object.defineProperty(RefractionPostProcess.prototype, "refractionTexture", {
  119924. /**
  119925. * Gets or sets the refraction texture
  119926. * Please note that you are responsible for disposing the texture if you set it manually
  119927. */
  119928. get: function () {
  119929. return this._refTexture;
  119930. },
  119931. set: function (value) {
  119932. if (this._refTexture && this._ownRefractionTexture) {
  119933. this._refTexture.dispose();
  119934. }
  119935. this._refTexture = value;
  119936. this._ownRefractionTexture = false;
  119937. },
  119938. enumerable: true,
  119939. configurable: true
  119940. });
  119941. // Methods
  119942. /**
  119943. * Disposes of the post process
  119944. * @param camera Camera to dispose post process on
  119945. */
  119946. RefractionPostProcess.prototype.dispose = function (camera) {
  119947. if (this._refTexture && this._ownRefractionTexture) {
  119948. this._refTexture.dispose();
  119949. this._refTexture = null;
  119950. }
  119951. _super.prototype.dispose.call(this, camera);
  119952. };
  119953. return RefractionPostProcess;
  119954. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  119955. /***/ }),
  119956. /***/ "./PostProcesses/sharpenPostProcess.ts":
  119957. /*!*********************************************!*\
  119958. !*** ./PostProcesses/sharpenPostProcess.ts ***!
  119959. \*********************************************/
  119960. /*! exports provided: SharpenPostProcess */
  119961. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  119962. "use strict";
  119963. __webpack_require__.r(__webpack_exports__);
  119964. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return SharpenPostProcess; });
  119965. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  119966. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  119967. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  119968. /* harmony import */ var _Shaders_sharpen_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/sharpen.fragment */ "./Shaders/sharpen.fragment.ts");
  119969. /**
  119970. * The SharpenPostProcess applies a sharpen kernel to every pixel
  119971. * See http://en.wikipedia.org/wiki/Kernel_(image_processing)
  119972. */
  119973. var SharpenPostProcess = /** @class */ (function (_super) {
  119974. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](SharpenPostProcess, _super);
  119975. /**
  119976. * Creates a new instance ConvolutionPostProcess
  119977. * @param name The name of the effect.
  119978. * @param options The required width/height ratio to downsize to before computing the render pass.
  119979. * @param camera The camera to apply the render pass to.
  119980. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  119981. * @param engine The engine which the post process will be applied. (default: current engine)
  119982. * @param reusable If the post process can be reused on the same frame. (default: false)
  119983. * @param textureType Type of textures used when performing the post process. (default: 0)
  119984. * @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)
  119985. */
  119986. function SharpenPostProcess(name, options, camera, samplingMode, engine, reusable, textureType, blockCompilation) {
  119987. if (textureType === void 0) { textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  119988. if (blockCompilation === void 0) { blockCompilation = false; }
  119989. var _this = _super.call(this, name, "sharpen", ["sharpnessAmounts", "screenSize"], null, options, camera, samplingMode, engine, reusable, null, textureType, undefined, null, blockCompilation) || this;
  119990. /**
  119991. * How much of the original color should be applied. Setting this to 0 will display edge detection. (default: 1)
  119992. */
  119993. _this.colorAmount = 1.0;
  119994. /**
  119995. * How much sharpness should be applied (default: 0.3)
  119996. */
  119997. _this.edgeAmount = 0.3;
  119998. _this.onApply = function (effect) {
  119999. effect.setFloat2("screenSize", _this.width, _this.height);
  120000. effect.setFloat2("sharpnessAmounts", _this.edgeAmount, _this.colorAmount);
  120001. };
  120002. return _this;
  120003. }
  120004. return SharpenPostProcess;
  120005. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120006. /***/ }),
  120007. /***/ "./PostProcesses/stereoscopicInterlacePostProcess.ts":
  120008. /*!***********************************************************!*\
  120009. !*** ./PostProcesses/stereoscopicInterlacePostProcess.ts ***!
  120010. \***********************************************************/
  120011. /*! exports provided: StereoscopicInterlacePostProcess */
  120012. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120013. "use strict";
  120014. __webpack_require__.r(__webpack_exports__);
  120015. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return StereoscopicInterlacePostProcess; });
  120016. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120017. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120018. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120019. /* harmony import */ var _Shaders_stereoscopicInterlace_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/stereoscopicInterlace.fragment */ "./Shaders/stereoscopicInterlace.fragment.ts");
  120020. /**
  120021. * StereoscopicInterlacePostProcess used to render stereo views from a rigged camera
  120022. */
  120023. var StereoscopicInterlacePostProcess = /** @class */ (function (_super) {
  120024. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](StereoscopicInterlacePostProcess, _super);
  120025. /**
  120026. * Initializes a StereoscopicInterlacePostProcess
  120027. * @param name The name of the effect.
  120028. * @param rigCameras The rig cameras to be appled to the post process
  120029. * @param isStereoscopicHoriz If the rendered results are horizontal or verticle
  120030. * @param samplingMode The sampling mode to be used when computing the pass. (default: 0)
  120031. * @param engine The engine which the post process will be applied. (default: current engine)
  120032. * @param reusable If the post process can be reused on the same frame. (default: false)
  120033. */
  120034. function StereoscopicInterlacePostProcess(name, rigCameras, isStereoscopicHoriz, samplingMode, engine, reusable) {
  120035. var _this = _super.call(this, name, "stereoscopicInterlace", ['stepSize'], ['camASampler'], 1, rigCameras[1], samplingMode, engine, reusable, isStereoscopicHoriz ? "#define IS_STEREOSCOPIC_HORIZ 1" : undefined) || this;
  120036. _this._passedProcess = rigCameras[0]._rigPostProcess;
  120037. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  120038. _this.onSizeChangedObservable.add(function () {
  120039. _this._stepSize = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](1 / _this.width, 1 / _this.height);
  120040. });
  120041. _this.onApplyObservable.add(function (effect) {
  120042. effect.setTextureFromPostProcess("camASampler", _this._passedProcess);
  120043. effect.setFloat2("stepSize", _this._stepSize.x, _this._stepSize.y);
  120044. });
  120045. return _this;
  120046. }
  120047. return StereoscopicInterlacePostProcess;
  120048. }(_postProcess__WEBPACK_IMPORTED_MODULE_2__["PostProcess"]));
  120049. /***/ }),
  120050. /***/ "./PostProcesses/tonemapPostProcess.ts":
  120051. /*!*********************************************!*\
  120052. !*** ./PostProcesses/tonemapPostProcess.ts ***!
  120053. \*********************************************/
  120054. /*! exports provided: TonemappingOperator, TonemapPostProcess */
  120055. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120056. "use strict";
  120057. __webpack_require__.r(__webpack_exports__);
  120058. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return TonemappingOperator; });
  120059. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return TonemapPostProcess; });
  120060. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120061. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120062. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120063. /* harmony import */ var _Shaders_tonemap_fragment__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Shaders/tonemap.fragment */ "./Shaders/tonemap.fragment.ts");
  120064. /** Defines operator used for tonemapping */
  120065. var TonemappingOperator;
  120066. (function (TonemappingOperator) {
  120067. /** Hable */
  120068. TonemappingOperator[TonemappingOperator["Hable"] = 0] = "Hable";
  120069. /** Reinhard */
  120070. TonemappingOperator[TonemappingOperator["Reinhard"] = 1] = "Reinhard";
  120071. /** HejiDawson */
  120072. TonemappingOperator[TonemappingOperator["HejiDawson"] = 2] = "HejiDawson";
  120073. /** Photographic */
  120074. TonemappingOperator[TonemappingOperator["Photographic"] = 3] = "Photographic";
  120075. })(TonemappingOperator || (TonemappingOperator = {}));
  120076. /**
  120077. * Defines a post process to apply tone mapping
  120078. */
  120079. var TonemapPostProcess = /** @class */ (function (_super) {
  120080. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](TonemapPostProcess, _super);
  120081. /**
  120082. * Creates a new TonemapPostProcess
  120083. * @param name defines the name of the postprocess
  120084. * @param _operator defines the operator to use
  120085. * @param exposureAdjustment defines the required exposure adjustement
  120086. * @param camera defines the camera to use (can be null)
  120087. * @param samplingMode defines the required sampling mode (BABYLON.Texture.BILINEAR_SAMPLINGMODE by default)
  120088. * @param engine defines the hosting engine (can be ignore if camera is set)
  120089. * @param textureFormat defines the texture format to use (BABYLON.Engine.TEXTURETYPE_UNSIGNED_INT by default)
  120090. */
  120091. function TonemapPostProcess(name, _operator,
  120092. /** Defines the required exposure adjustement */
  120093. exposureAdjustment, camera, samplingMode, engine, textureFormat) {
  120094. if (samplingMode === void 0) { samplingMode = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURE_BILINEAR_SAMPLINGMODE; }
  120095. if (textureFormat === void 0) { textureFormat = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_UNSIGNED_INT; }
  120096. var _this = _super.call(this, name, "tonemap", ["_ExposureAdjustment"], null, 1.0, camera, samplingMode, engine, true, null, textureFormat) || this;
  120097. _this._operator = _operator;
  120098. _this.exposureAdjustment = exposureAdjustment;
  120099. var defines = "#define ";
  120100. if (_this._operator === TonemappingOperator.Hable) {
  120101. defines += "HABLE_TONEMAPPING";
  120102. }
  120103. else if (_this._operator === TonemappingOperator.Reinhard) {
  120104. defines += "REINHARD_TONEMAPPING";
  120105. }
  120106. else if (_this._operator === TonemappingOperator.HejiDawson) {
  120107. defines += "OPTIMIZED_HEJIDAWSON_TONEMAPPING";
  120108. }
  120109. else if (_this._operator === TonemappingOperator.Photographic) {
  120110. defines += "PHOTOGRAPHIC_TONEMAPPING";
  120111. }
  120112. //sadly a second call to create the effect.
  120113. _this.updateEffect(defines);
  120114. _this.onApply = function (effect) {
  120115. effect.setFloat("_ExposureAdjustment", _this.exposureAdjustment);
  120116. };
  120117. return _this;
  120118. }
  120119. return TonemapPostProcess;
  120120. }(_postProcess__WEBPACK_IMPORTED_MODULE_1__["PostProcess"]));
  120121. /***/ }),
  120122. /***/ "./PostProcesses/volumetricLightScatteringPostProcess.ts":
  120123. /*!***************************************************************!*\
  120124. !*** ./PostProcesses/volumetricLightScatteringPostProcess.ts ***!
  120125. \***************************************************************/
  120126. /*! exports provided: VolumetricLightScatteringPostProcess */
  120127. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120128. "use strict";
  120129. __webpack_require__.r(__webpack_exports__);
  120130. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return VolumetricLightScatteringPostProcess; });
  120131. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120132. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  120133. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Misc/logger */ "./Misc/logger.ts");
  120134. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120135. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120136. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120137. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Meshes/mesh */ "./Meshes/mesh.ts");
  120138. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120139. /* harmony import */ var _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/standardMaterial */ "./Materials/standardMaterial.ts");
  120140. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120141. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120142. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120143. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120144. /* harmony import */ var _Meshes_Builders_planeBuilder__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Meshes/Builders/planeBuilder */ "./Meshes/Builders/planeBuilder.ts");
  120145. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  120146. /* harmony import */ var _Shaders_volumetricLightScattering_fragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../Shaders/volumetricLightScattering.fragment */ "./Shaders/volumetricLightScattering.fragment.ts");
  120147. /* harmony import */ var _Shaders_volumetricLightScatteringPass_fragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../Shaders/volumetricLightScatteringPass.fragment */ "./Shaders/volumetricLightScatteringPass.fragment.ts");
  120148. /**
  120149. * Inspired by http://http.developer.nvidia.com/GPUGems3/gpugems3_ch13.html
  120150. */
  120151. var VolumetricLightScatteringPostProcess = /** @class */ (function (_super) {
  120152. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VolumetricLightScatteringPostProcess, _super);
  120153. /**
  120154. * @constructor
  120155. * @param name The post-process name
  120156. * @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)
  120157. * @param camera The camera that the post-process will be attached to
  120158. * @param mesh The mesh used to create the light scattering
  120159. * @param samples The post-process quality, default 100
  120160. * @param samplingModeThe post-process filtering mode
  120161. * @param engine The babylon engine
  120162. * @param reusable If the post-process is reusable
  120163. * @param scene The constructor needs a scene reference to initialize internal components. If "camera" is null a "scene" must be provided
  120164. */
  120165. function VolumetricLightScatteringPostProcess(name, ratio, camera, mesh, samples, samplingMode, engine, reusable, scene) {
  120166. if (samples === void 0) { samples = 100; }
  120167. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].BILINEAR_SAMPLINGMODE; }
  120168. 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;
  120169. _this._screenCoordinates = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector2"].Zero();
  120170. /**
  120171. * Custom position of the mesh. Used if "useCustomMeshPosition" is set to "true"
  120172. */
  120173. _this.customMeshPosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120174. /**
  120175. * Set if the post-process should use a custom position for the light source (true) or the internal mesh position (false)
  120176. */
  120177. _this.useCustomMeshPosition = false;
  120178. /**
  120179. * If the post-process should inverse the light scattering direction
  120180. */
  120181. _this.invert = true;
  120182. /**
  120183. * Array containing the excluded meshes not rendered in the internal pass
  120184. */
  120185. _this.excludedMeshes = new Array();
  120186. /**
  120187. * Controls the overall intensity of the post-process
  120188. */
  120189. _this.exposure = 0.3;
  120190. /**
  120191. * Dissipates each sample's contribution in range [0, 1]
  120192. */
  120193. _this.decay = 0.96815;
  120194. /**
  120195. * Controls the overall intensity of each sample
  120196. */
  120197. _this.weight = 0.58767;
  120198. /**
  120199. * Controls the density of each sample
  120200. */
  120201. _this.density = 0.926;
  120202. scene = ((camera === null) ? scene : camera.getScene()); // parameter "scene" can be null.
  120203. engine = scene.getEngine();
  120204. _this._viewPort = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Viewport"](0, 0, 1, 1).toGlobal(engine.getRenderWidth(), engine.getRenderHeight());
  120205. // Configure mesh
  120206. _this.mesh = ((mesh !== null) ? mesh : VolumetricLightScatteringPostProcess.CreateDefaultMesh("VolumetricLightScatteringMesh", scene));
  120207. // Configure
  120208. _this._createPass(scene, ratio.passRatio || ratio);
  120209. _this.onActivate = function (camera) {
  120210. if (!_this.isSupported) {
  120211. _this.dispose(camera);
  120212. }
  120213. _this.onActivate = null;
  120214. };
  120215. _this.onApplyObservable.add(function (effect) {
  120216. _this._updateMeshScreenCoordinates(scene);
  120217. effect.setTexture("lightScatteringSampler", _this._volumetricLightScatteringRTT);
  120218. effect.setFloat("exposure", _this.exposure);
  120219. effect.setFloat("decay", _this.decay);
  120220. effect.setFloat("weight", _this.weight);
  120221. effect.setFloat("density", _this.density);
  120222. effect.setVector2("meshPositionOnScreen", _this._screenCoordinates);
  120223. });
  120224. return _this;
  120225. }
  120226. Object.defineProperty(VolumetricLightScatteringPostProcess.prototype, "useDiffuseColor", {
  120227. /**
  120228. * @hidden
  120229. * VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead
  120230. */
  120231. get: function () {
  120232. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  120233. return false;
  120234. },
  120235. set: function (useDiffuseColor) {
  120236. _Misc_logger__WEBPACK_IMPORTED_MODULE_2__["Logger"].Warn("VolumetricLightScatteringPostProcess.useDiffuseColor is no longer used, use the mesh material directly instead");
  120237. },
  120238. enumerable: true,
  120239. configurable: true
  120240. });
  120241. /**
  120242. * Returns the string "VolumetricLightScatteringPostProcess"
  120243. * @returns "VolumetricLightScatteringPostProcess"
  120244. */
  120245. VolumetricLightScatteringPostProcess.prototype.getClassName = function () {
  120246. return "VolumetricLightScatteringPostProcess";
  120247. };
  120248. VolumetricLightScatteringPostProcess.prototype._isReady = function (subMesh, useInstances) {
  120249. var mesh = subMesh.getMesh();
  120250. // Render this.mesh as default
  120251. if (mesh === this.mesh && mesh.material) {
  120252. return mesh.material.isReady(mesh);
  120253. }
  120254. var defines = [];
  120255. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].PositionKind];
  120256. var material = subMesh.getMaterial();
  120257. // Alpha test
  120258. if (material) {
  120259. if (material.needAlphaTesting()) {
  120260. defines.push("#define ALPHATEST");
  120261. }
  120262. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind)) {
  120263. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UVKind);
  120264. defines.push("#define UV1");
  120265. }
  120266. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind)) {
  120267. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].UV2Kind);
  120268. defines.push("#define UV2");
  120269. }
  120270. }
  120271. // Bones
  120272. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  120273. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesIndicesKind);
  120274. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_4__["VertexBuffer"].MatricesWeightsKind);
  120275. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  120276. defines.push("#define BonesPerMesh " + (mesh.skeleton ? (mesh.skeleton.bones.length + 1) : 0));
  120277. }
  120278. else {
  120279. defines.push("#define NUM_BONE_INFLUENCERS 0");
  120280. }
  120281. // Instances
  120282. if (useInstances) {
  120283. defines.push("#define INSTANCES");
  120284. attribs.push("world0");
  120285. attribs.push("world1");
  120286. attribs.push("world2");
  120287. attribs.push("world3");
  120288. }
  120289. // Get correct effect
  120290. var join = defines.join("\n");
  120291. if (this._cachedDefines !== join) {
  120292. this._cachedDefines = join;
  120293. this._volumetricLightScatteringPass = mesh.getScene().getEngine().createEffect({ vertexElement: "depth", fragmentElement: "volumetricLightScatteringPass" }, attribs, ["world", "mBones", "viewProjection", "diffuseMatrix"], ["diffuseSampler"], join);
  120294. }
  120295. return this._volumetricLightScatteringPass.isReady();
  120296. };
  120297. /**
  120298. * Sets the new light position for light scattering effect
  120299. * @param position The new custom light position
  120300. */
  120301. VolumetricLightScatteringPostProcess.prototype.setCustomMeshPosition = function (position) {
  120302. this.customMeshPosition = position;
  120303. };
  120304. /**
  120305. * Returns the light position for light scattering effect
  120306. * @return Vector3 The custom light position
  120307. */
  120308. VolumetricLightScatteringPostProcess.prototype.getCustomMeshPosition = function () {
  120309. return this.customMeshPosition;
  120310. };
  120311. /**
  120312. * Disposes the internal assets and detaches the post-process from the camera
  120313. */
  120314. VolumetricLightScatteringPostProcess.prototype.dispose = function (camera) {
  120315. var rttIndex = camera.getScene().customRenderTargets.indexOf(this._volumetricLightScatteringRTT);
  120316. if (rttIndex !== -1) {
  120317. camera.getScene().customRenderTargets.splice(rttIndex, 1);
  120318. }
  120319. this._volumetricLightScatteringRTT.dispose();
  120320. _super.prototype.dispose.call(this, camera);
  120321. };
  120322. /**
  120323. * Returns the render target texture used by the post-process
  120324. * @return the render target texture used by the post-process
  120325. */
  120326. VolumetricLightScatteringPostProcess.prototype.getPass = function () {
  120327. return this._volumetricLightScatteringRTT;
  120328. };
  120329. // Private methods
  120330. VolumetricLightScatteringPostProcess.prototype._meshExcluded = function (mesh) {
  120331. if (this.excludedMeshes.length > 0 && this.excludedMeshes.indexOf(mesh) !== -1) {
  120332. return true;
  120333. }
  120334. return false;
  120335. };
  120336. VolumetricLightScatteringPostProcess.prototype._createPass = function (scene, ratio) {
  120337. var _this = this;
  120338. var engine = scene.getEngine();
  120339. 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);
  120340. this._volumetricLightScatteringRTT.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  120341. this._volumetricLightScatteringRTT.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_9__["Texture"].CLAMP_ADDRESSMODE;
  120342. this._volumetricLightScatteringRTT.renderList = null;
  120343. this._volumetricLightScatteringRTT.renderParticles = false;
  120344. this._volumetricLightScatteringRTT.ignoreCameraViewport = true;
  120345. var camera = this.getCamera();
  120346. if (camera) {
  120347. camera.customRenderTargets.push(this._volumetricLightScatteringRTT);
  120348. }
  120349. else {
  120350. scene.customRenderTargets.push(this._volumetricLightScatteringRTT);
  120351. }
  120352. // Custom render function for submeshes
  120353. var renderSubMesh = function (subMesh) {
  120354. var mesh = subMesh.getRenderingMesh();
  120355. if (_this._meshExcluded(mesh)) {
  120356. return;
  120357. }
  120358. var material = subMesh.getMaterial();
  120359. if (!material) {
  120360. return;
  120361. }
  120362. var scene = mesh.getScene();
  120363. var engine = scene.getEngine();
  120364. // Culling
  120365. engine.setState(material.backFaceCulling);
  120366. // Managing instances
  120367. var batch = mesh._getInstancesRenderList(subMesh._id);
  120368. if (batch.mustReturn) {
  120369. return;
  120370. }
  120371. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  120372. if (_this._isReady(subMesh, hardwareInstancedRendering)) {
  120373. var effect = _this._volumetricLightScatteringPass;
  120374. if (mesh === _this.mesh) {
  120375. if (subMesh.effect) {
  120376. effect = subMesh.effect;
  120377. }
  120378. else {
  120379. effect = material.getEffect();
  120380. }
  120381. }
  120382. engine.enableEffect(effect);
  120383. mesh._bind(subMesh, effect, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode);
  120384. if (mesh === _this.mesh) {
  120385. material.bind(mesh.getWorldMatrix(), mesh);
  120386. }
  120387. else {
  120388. _this._volumetricLightScatteringPass.setMatrix("viewProjection", scene.getTransformMatrix());
  120389. // Alpha test
  120390. if (material && material.needAlphaTesting()) {
  120391. var alphaTexture = material.getAlphaTestTexture();
  120392. _this._volumetricLightScatteringPass.setTexture("diffuseSampler", alphaTexture);
  120393. if (alphaTexture) {
  120394. _this._volumetricLightScatteringPass.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  120395. }
  120396. }
  120397. // Bones
  120398. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  120399. _this._volumetricLightScatteringPass.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  120400. }
  120401. }
  120402. // Draw
  120403. mesh._processRendering(subMesh, _this._volumetricLightScatteringPass, _Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return effect.setMatrix("world", world); });
  120404. }
  120405. };
  120406. // Render target texture callbacks
  120407. var savedSceneClearColor;
  120408. var sceneClearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color4"](0.0, 0.0, 0.0, 1.0);
  120409. this._volumetricLightScatteringRTT.onBeforeRenderObservable.add(function () {
  120410. savedSceneClearColor = scene.clearColor;
  120411. scene.clearColor = sceneClearColor;
  120412. });
  120413. this._volumetricLightScatteringRTT.onAfterRenderObservable.add(function () {
  120414. scene.clearColor = savedSceneClearColor;
  120415. });
  120416. this._volumetricLightScatteringRTT.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  120417. var engine = scene.getEngine();
  120418. var index;
  120419. if (depthOnlySubMeshes.length) {
  120420. engine.setColorWrite(false);
  120421. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  120422. renderSubMesh(depthOnlySubMeshes.data[index]);
  120423. }
  120424. engine.setColorWrite(true);
  120425. }
  120426. for (index = 0; index < opaqueSubMeshes.length; index++) {
  120427. renderSubMesh(opaqueSubMeshes.data[index]);
  120428. }
  120429. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  120430. renderSubMesh(alphaTestSubMeshes.data[index]);
  120431. }
  120432. if (transparentSubMeshes.length) {
  120433. // Sort sub meshes
  120434. for (index = 0; index < transparentSubMeshes.length; index++) {
  120435. var submesh = transparentSubMeshes.data[index];
  120436. var boundingInfo = submesh.getBoundingInfo();
  120437. if (boundingInfo && scene.activeCamera) {
  120438. submesh._alphaIndex = submesh.getMesh().alphaIndex;
  120439. submesh._distanceToCamera = boundingInfo.boundingSphere.centerWorld.subtract(scene.activeCamera.position).length();
  120440. }
  120441. }
  120442. var sortedArray = transparentSubMeshes.data.slice(0, transparentSubMeshes.length);
  120443. sortedArray.sort(function (a, b) {
  120444. // Alpha index first
  120445. if (a._alphaIndex > b._alphaIndex) {
  120446. return 1;
  120447. }
  120448. if (a._alphaIndex < b._alphaIndex) {
  120449. return -1;
  120450. }
  120451. // Then distance to camera
  120452. if (a._distanceToCamera < b._distanceToCamera) {
  120453. return 1;
  120454. }
  120455. if (a._distanceToCamera > b._distanceToCamera) {
  120456. return -1;
  120457. }
  120458. return 0;
  120459. });
  120460. // Render sub meshes
  120461. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_COMBINE);
  120462. for (index = 0; index < sortedArray.length; index++) {
  120463. renderSubMesh(sortedArray[index]);
  120464. }
  120465. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_12__["Constants"].ALPHA_DISABLE);
  120466. }
  120467. };
  120468. };
  120469. VolumetricLightScatteringPostProcess.prototype._updateMeshScreenCoordinates = function (scene) {
  120470. var transform = scene.getTransformMatrix();
  120471. var meshPosition;
  120472. if (this.useCustomMeshPosition) {
  120473. meshPosition = this.customMeshPosition;
  120474. }
  120475. else if (this.attachedNode) {
  120476. meshPosition = this.attachedNode.position;
  120477. }
  120478. else {
  120479. meshPosition = this.mesh.parent ? this.mesh.getAbsolutePosition() : this.mesh.position;
  120480. }
  120481. var pos = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Project(meshPosition, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity(), transform, this._viewPort);
  120482. this._screenCoordinates.x = pos.x / this._viewPort.width;
  120483. this._screenCoordinates.y = pos.y / this._viewPort.height;
  120484. if (this.invert) {
  120485. this._screenCoordinates.y = 1.0 - this._screenCoordinates.y;
  120486. }
  120487. };
  120488. // Static methods
  120489. /**
  120490. * Creates a default mesh for the Volumeric Light Scattering post-process
  120491. * @param name The mesh name
  120492. * @param scene The scene where to create the mesh
  120493. * @return the default mesh
  120494. */
  120495. VolumetricLightScatteringPostProcess.CreateDefaultMesh = function (name, scene) {
  120496. var mesh = _Meshes_mesh__WEBPACK_IMPORTED_MODULE_6__["Mesh"].CreatePlane(name, 1, scene);
  120497. mesh.billboardMode = _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_5__["AbstractMesh"].BILLBOARDMODE_ALL;
  120498. var material = new _Materials_standardMaterial__WEBPACK_IMPORTED_MODULE_8__["StandardMaterial"](name + "Material", scene);
  120499. material.emissiveColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Color3"](1, 1, 1);
  120500. mesh.material = material;
  120501. return mesh;
  120502. };
  120503. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120504. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  120505. ], VolumetricLightScatteringPostProcess.prototype, "customMeshPosition", void 0);
  120506. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120507. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120508. ], VolumetricLightScatteringPostProcess.prototype, "useCustomMeshPosition", void 0);
  120509. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120510. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120511. ], VolumetricLightScatteringPostProcess.prototype, "invert", void 0);
  120512. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120513. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  120514. ], VolumetricLightScatteringPostProcess.prototype, "mesh", void 0);
  120515. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120516. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120517. ], VolumetricLightScatteringPostProcess.prototype, "excludedMeshes", void 0);
  120518. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120519. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120520. ], VolumetricLightScatteringPostProcess.prototype, "exposure", void 0);
  120521. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120522. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120523. ], VolumetricLightScatteringPostProcess.prototype, "decay", void 0);
  120524. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120525. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120526. ], VolumetricLightScatteringPostProcess.prototype, "weight", void 0);
  120527. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120528. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serialize"])()
  120529. ], VolumetricLightScatteringPostProcess.prototype, "density", void 0);
  120530. return VolumetricLightScatteringPostProcess;
  120531. }(_postProcess__WEBPACK_IMPORTED_MODULE_11__["PostProcess"]));
  120532. /***/ }),
  120533. /***/ "./PostProcesses/vrDistortionCorrectionPostProcess.ts":
  120534. /*!************************************************************!*\
  120535. !*** ./PostProcesses/vrDistortionCorrectionPostProcess.ts ***!
  120536. \************************************************************/
  120537. /*! exports provided: VRDistortionCorrectionPostProcess */
  120538. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120539. "use strict";
  120540. __webpack_require__.r(__webpack_exports__);
  120541. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return VRDistortionCorrectionPostProcess; });
  120542. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120543. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120544. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  120545. /* harmony import */ var _postProcess__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./postProcess */ "./PostProcesses/postProcess.ts");
  120546. /* harmony import */ var _Shaders_vrDistortionCorrection_fragment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Shaders/vrDistortionCorrection.fragment */ "./Shaders/vrDistortionCorrection.fragment.ts");
  120547. /**
  120548. * VRDistortionCorrectionPostProcess used for mobile VR
  120549. */
  120550. var VRDistortionCorrectionPostProcess = /** @class */ (function (_super) {
  120551. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](VRDistortionCorrectionPostProcess, _super);
  120552. /**
  120553. * Initializes the VRDistortionCorrectionPostProcess
  120554. * @param name The name of the effect.
  120555. * @param camera The camera to apply the render pass to.
  120556. * @param isRightEye If this is for the right eye distortion
  120557. * @param vrMetrics All the required metrics for the VR camera
  120558. */
  120559. function VRDistortionCorrectionPostProcess(name, camera, isRightEye, vrMetrics) {
  120560. var _this = _super.call(this, name, "vrDistortionCorrection", [
  120561. 'LensCenter',
  120562. 'Scale',
  120563. 'ScaleIn',
  120564. 'HmdWarpParam'
  120565. ], null, vrMetrics.postProcessScaleFactor, camera, _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].BILINEAR_SAMPLINGMODE) || this;
  120566. _this._isRightEye = isRightEye;
  120567. _this._distortionFactors = vrMetrics.distortionK;
  120568. _this._postProcessScaleFactor = vrMetrics.postProcessScaleFactor;
  120569. _this._lensCenterOffset = vrMetrics.lensCenterOffset;
  120570. _this.adaptScaleToCurrentViewport = true;
  120571. _this.onSizeChangedObservable.add(function () {
  120572. _this._scaleIn = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](2, 2 / _this.aspectRatio);
  120573. _this._scaleFactor = new _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector2"](.5 * (1 / _this._postProcessScaleFactor), .5 * (1 / _this._postProcessScaleFactor) * _this.aspectRatio);
  120574. _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);
  120575. });
  120576. _this.onApplyObservable.add(function (effect) {
  120577. effect.setFloat2("LensCenter", _this._lensCenter.x, _this._lensCenter.y);
  120578. effect.setFloat2("Scale", _this._scaleFactor.x, _this._scaleFactor.y);
  120579. effect.setFloat2("ScaleIn", _this._scaleIn.x, _this._scaleIn.y);
  120580. effect.setFloat4("HmdWarpParam", _this._distortionFactors[0], _this._distortionFactors[1], _this._distortionFactors[2], _this._distortionFactors[3]);
  120581. });
  120582. return _this;
  120583. }
  120584. return VRDistortionCorrectionPostProcess;
  120585. }(_postProcess__WEBPACK_IMPORTED_MODULE_3__["PostProcess"]));
  120586. /***/ }),
  120587. /***/ "./Probes/index.ts":
  120588. /*!*************************!*\
  120589. !*** ./Probes/index.ts ***!
  120590. \*************************/
  120591. /*! exports provided: ReflectionProbe */
  120592. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120593. "use strict";
  120594. __webpack_require__.r(__webpack_exports__);
  120595. /* harmony import */ var _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./reflectionProbe */ "./Probes/reflectionProbe.ts");
  120596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _reflectionProbe__WEBPACK_IMPORTED_MODULE_0__["ReflectionProbe"]; });
  120597. /***/ }),
  120598. /***/ "./Probes/reflectionProbe.ts":
  120599. /*!***********************************!*\
  120600. !*** ./Probes/reflectionProbe.ts ***!
  120601. \***********************************/
  120602. /*! exports provided: ReflectionProbe */
  120603. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120604. "use strict";
  120605. __webpack_require__.r(__webpack_exports__);
  120606. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return ReflectionProbe; });
  120607. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  120608. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/decorators */ "./Misc/decorators.ts");
  120609. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  120610. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120611. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../abstractScene */ "./abstractScene.ts");
  120612. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  120613. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.removeReflectionProbe = function (toRemove) {
  120614. if (!this.reflectionProbes) {
  120615. return -1;
  120616. }
  120617. var index = this.reflectionProbes.indexOf(toRemove);
  120618. if (index !== -1) {
  120619. this.reflectionProbes.splice(index, 1);
  120620. }
  120621. return index;
  120622. };
  120623. _abstractScene__WEBPACK_IMPORTED_MODULE_4__["AbstractScene"].prototype.addReflectionProbe = function (newReflectionProbe) {
  120624. if (!this.reflectionProbes) {
  120625. this.reflectionProbes = [];
  120626. }
  120627. this.reflectionProbes.push(newReflectionProbe);
  120628. };
  120629. /**
  120630. * Class used to generate realtime reflection / refraction cube textures
  120631. * @see http://doc.babylonjs.com/how_to/how_to_use_reflection_probes
  120632. */
  120633. var ReflectionProbe = /** @class */ (function () {
  120634. /**
  120635. * Creates a new reflection probe
  120636. * @param name defines the name of the probe
  120637. * @param size defines the texture resolution (for each face)
  120638. * @param scene defines the hosting scene
  120639. * @param generateMipMaps defines if mip maps should be generated automatically (true by default)
  120640. * @param useFloat defines if HDR data (flaot data) should be used to store colors (false by default)
  120641. */
  120642. function ReflectionProbe(
  120643. /** defines the name of the probe */
  120644. name, size, scene, generateMipMaps, useFloat) {
  120645. if (generateMipMaps === void 0) { generateMipMaps = true; }
  120646. if (useFloat === void 0) { useFloat = false; }
  120647. var _this = this;
  120648. this.name = name;
  120649. this._viewMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].Identity();
  120650. this._target = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120651. this._add = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120652. this._invertYAxis = false;
  120653. /** Gets or sets probe position (center of the cube map) */
  120654. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  120655. this._scene = scene;
  120656. // Create the scene field if not exist.
  120657. if (!this._scene.reflectionProbes) {
  120658. this._scene.reflectionProbes = new Array();
  120659. }
  120660. this._scene.reflectionProbes.push(this);
  120661. 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);
  120662. this._renderTargetTexture.onBeforeRenderObservable.add(function (faceIndex) {
  120663. switch (faceIndex) {
  120664. case 0:
  120665. _this._add.copyFromFloats(1, 0, 0);
  120666. break;
  120667. case 1:
  120668. _this._add.copyFromFloats(-1, 0, 0);
  120669. break;
  120670. case 2:
  120671. _this._add.copyFromFloats(0, _this._invertYAxis ? 1 : -1, 0);
  120672. break;
  120673. case 3:
  120674. _this._add.copyFromFloats(0, _this._invertYAxis ? -1 : 1, 0);
  120675. break;
  120676. case 4:
  120677. _this._add.copyFromFloats(0, 0, 1);
  120678. break;
  120679. case 5:
  120680. _this._add.copyFromFloats(0, 0, -1);
  120681. break;
  120682. }
  120683. if (_this._attachedMesh) {
  120684. _this.position.copyFrom(_this._attachedMesh.getAbsolutePosition());
  120685. }
  120686. _this.position.addToRef(_this._add, _this._target);
  120687. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].LookAtLHToRef(_this.position, _this._target, _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Up(), _this._viewMatrix);
  120688. if (scene.activeCamera) {
  120689. _this._projectionMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Matrix"].PerspectiveFovLH(Math.PI / 2, 1, scene.activeCamera.minZ, scene.activeCamera.maxZ);
  120690. scene.setTransformMatrix(_this._viewMatrix, _this._projectionMatrix);
  120691. }
  120692. scene._forcedViewPosition = _this.position;
  120693. });
  120694. this._renderTargetTexture.onAfterUnbindObservable.add(function () {
  120695. scene._forcedViewPosition = null;
  120696. scene.updateTransformMatrix(true);
  120697. });
  120698. }
  120699. Object.defineProperty(ReflectionProbe.prototype, "samples", {
  120700. /** Gets or sets the number of samples to use for multi-sampling (0 by default). Required WebGL2 */
  120701. get: function () {
  120702. return this._renderTargetTexture.samples;
  120703. },
  120704. set: function (value) {
  120705. this._renderTargetTexture.samples = value;
  120706. },
  120707. enumerable: true,
  120708. configurable: true
  120709. });
  120710. Object.defineProperty(ReflectionProbe.prototype, "refreshRate", {
  120711. /** Gets or sets the refresh rate to use (on every frame by default) */
  120712. get: function () {
  120713. return this._renderTargetTexture.refreshRate;
  120714. },
  120715. set: function (value) {
  120716. this._renderTargetTexture.refreshRate = value;
  120717. },
  120718. enumerable: true,
  120719. configurable: true
  120720. });
  120721. /**
  120722. * Gets the hosting scene
  120723. * @returns a Scene
  120724. */
  120725. ReflectionProbe.prototype.getScene = function () {
  120726. return this._scene;
  120727. };
  120728. Object.defineProperty(ReflectionProbe.prototype, "cubeTexture", {
  120729. /** Gets the internal CubeTexture used to render to */
  120730. get: function () {
  120731. return this._renderTargetTexture;
  120732. },
  120733. enumerable: true,
  120734. configurable: true
  120735. });
  120736. Object.defineProperty(ReflectionProbe.prototype, "renderList", {
  120737. /** Gets the list of meshes to render */
  120738. get: function () {
  120739. return this._renderTargetTexture.renderList;
  120740. },
  120741. enumerable: true,
  120742. configurable: true
  120743. });
  120744. /**
  120745. * Attach the probe to a specific mesh (Rendering will be done from attached mesh's position)
  120746. * @param mesh defines the mesh to attach to
  120747. */
  120748. ReflectionProbe.prototype.attachToMesh = function (mesh) {
  120749. this._attachedMesh = mesh;
  120750. };
  120751. /**
  120752. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups
  120753. * @param renderingGroupId The rendering group id corresponding to its index
  120754. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  120755. */
  120756. ReflectionProbe.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil) {
  120757. this._renderTargetTexture.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil);
  120758. };
  120759. /**
  120760. * Clean all associated resources
  120761. */
  120762. ReflectionProbe.prototype.dispose = function () {
  120763. var index = this._scene.reflectionProbes.indexOf(this);
  120764. if (index !== -1) {
  120765. // Remove from the scene if found
  120766. this._scene.reflectionProbes.splice(index, 1);
  120767. }
  120768. if (this._renderTargetTexture) {
  120769. this._renderTargetTexture.dispose();
  120770. this._renderTargetTexture = null;
  120771. }
  120772. };
  120773. /**
  120774. * Converts the reflection probe information to a readable string for debug purpose.
  120775. * @param fullDetails Supports for multiple levels of logging within scene loading
  120776. * @returns the human readable reflection probe info
  120777. */
  120778. ReflectionProbe.prototype.toString = function (fullDetails) {
  120779. var ret = "Name: " + this.name;
  120780. if (fullDetails) {
  120781. ret += ", position: " + this.position.toString();
  120782. if (this._attachedMesh) {
  120783. ret += ", attached mesh: " + this._attachedMesh.name;
  120784. }
  120785. }
  120786. return ret;
  120787. };
  120788. /**
  120789. * Get the class name of the relfection probe.
  120790. * @returns "ReflectionProbe"
  120791. */
  120792. ReflectionProbe.prototype.getClassName = function () {
  120793. return "ReflectionProbe";
  120794. };
  120795. /**
  120796. * Serialize the reflection probe to a JSON representation we can easily use in the resepective Parse function.
  120797. * @returns The JSON representation of the texture
  120798. */
  120799. ReflectionProbe.prototype.serialize = function () {
  120800. var serializationObject = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Serialize(this, this._renderTargetTexture.serialize());
  120801. serializationObject.isReflectionProbe = true;
  120802. return serializationObject;
  120803. };
  120804. /**
  120805. * Parse the JSON representation of a reflection probe in order to recreate the reflection probe in the given scene.
  120806. * @param parsedReflectionProbe Define the JSON representation of the reflection probe
  120807. * @param scene Define the scene the parsed reflection probe should be instantiated in
  120808. * @param rootUrl Define the root url of the parsing sequence in the case of relative dependencies
  120809. * @returns The parsed reflection probe if successful
  120810. */
  120811. ReflectionProbe.Parse = function (parsedReflectionProbe, scene, rootUrl) {
  120812. var reflectionProbe = null;
  120813. if (scene.reflectionProbes) {
  120814. for (var index = 0; index < scene.reflectionProbes.length; index++) {
  120815. var rp = scene.reflectionProbes[index];
  120816. if (rp.name === parsedReflectionProbe.name) {
  120817. reflectionProbe = rp;
  120818. break;
  120819. }
  120820. }
  120821. }
  120822. reflectionProbe = _Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["SerializationHelper"].Parse(function () { return reflectionProbe || new ReflectionProbe(parsedReflectionProbe.name, parsedReflectionProbe.renderTargetSize, scene, parsedReflectionProbe._generateMipMaps); }, parsedReflectionProbe, scene, rootUrl);
  120823. reflectionProbe.cubeTexture._waitingRenderList = parsedReflectionProbe.renderList;
  120824. if (parsedReflectionProbe._attachedMesh) {
  120825. reflectionProbe.attachToMesh(scene.getMeshByID(parsedReflectionProbe._attachedMesh));
  120826. }
  120827. return reflectionProbe;
  120828. };
  120829. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120830. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsMeshReference"])()
  120831. ], ReflectionProbe.prototype, "_attachedMesh", void 0);
  120832. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  120833. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_1__["serializeAsVector3"])()
  120834. ], ReflectionProbe.prototype, "position", void 0);
  120835. return ReflectionProbe;
  120836. }());
  120837. /***/ }),
  120838. /***/ "./Rendering/boundingBoxRenderer.ts":
  120839. /*!******************************************!*\
  120840. !*** ./Rendering/boundingBoxRenderer.ts ***!
  120841. \******************************************/
  120842. /*! exports provided: BoundingBoxRenderer */
  120843. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  120844. "use strict";
  120845. __webpack_require__.r(__webpack_exports__);
  120846. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return BoundingBoxRenderer; });
  120847. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  120848. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  120849. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  120850. /* harmony import */ var _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/mesh.vertexData */ "./Meshes/mesh.vertexData.ts");
  120851. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  120852. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  120853. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  120854. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  120855. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  120856. /* harmony import */ var _Meshes_Builders_boxBuilder__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Meshes/Builders/boxBuilder */ "./Meshes/Builders/boxBuilder.ts");
  120857. /* harmony import */ var _Shaders_color_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/color.fragment */ "./Shaders/color.fragment.ts");
  120858. /* harmony import */ var _Shaders_color_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/color.vertex */ "./Shaders/color.vertex.ts");
  120859. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "forceShowBoundingBoxes", {
  120860. get: function () {
  120861. return this._forceShowBoundingBoxes || false;
  120862. },
  120863. set: function (value) {
  120864. this._forceShowBoundingBoxes = value;
  120865. // Lazyly creates a BB renderer if needed.
  120866. if (value) {
  120867. this.getBoundingBoxRenderer();
  120868. }
  120869. },
  120870. enumerable: true,
  120871. configurable: true
  120872. });
  120873. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.getBoundingBoxRenderer = function () {
  120874. if (!this._boundingBoxRenderer) {
  120875. this._boundingBoxRenderer = new BoundingBoxRenderer(this);
  120876. }
  120877. return this._boundingBoxRenderer;
  120878. };
  120879. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "showBoundingBox", {
  120880. get: function () {
  120881. return this._showBoundingBox || false;
  120882. },
  120883. set: function (value) {
  120884. this._showBoundingBox = value;
  120885. // Lazyly creates a BB renderer if needed.
  120886. if (value) {
  120887. this.getScene().getBoundingBoxRenderer();
  120888. }
  120889. },
  120890. enumerable: true,
  120891. configurable: true
  120892. });
  120893. /**
  120894. * Component responsible of rendering the bounding box of the meshes in a scene.
  120895. * This is usually used through the mesh.showBoundingBox or the scene.forceShowBoundingBoxes properties
  120896. */
  120897. var BoundingBoxRenderer = /** @class */ (function () {
  120898. /**
  120899. * Instantiates a new bounding box renderer in a scene.
  120900. * @param scene the scene the renderer renders in
  120901. */
  120902. function BoundingBoxRenderer(scene) {
  120903. /**
  120904. * The component name helpfull to identify the component in the list of scene components.
  120905. */
  120906. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].NAME_BOUNDINGBOXRENDERER;
  120907. /**
  120908. * Color of the bounding box lines placed in front of an object
  120909. */
  120910. this.frontColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](1, 1, 1);
  120911. /**
  120912. * Color of the bounding box lines placed behind an object
  120913. */
  120914. this.backColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Color3"](0.1, 0.1, 0.1);
  120915. /**
  120916. * Defines if the renderer should show the back lines or not
  120917. */
  120918. this.showBackLines = true;
  120919. /**
  120920. * @hidden
  120921. */
  120922. this.renderList = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_5__["SmartArray"](32);
  120923. this._vertexBuffers = {};
  120924. this.scene = scene;
  120925. scene._addComponent(this);
  120926. }
  120927. /**
  120928. * Registers the component in a given scene
  120929. */
  120930. BoundingBoxRenderer.prototype.register = function () {
  120931. this.scene._beforeEvaluateActiveMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER, this, this.reset);
  120932. this.scene._activeMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_ACTIVEMESH_BOUNDINGBOXRENDERER, this, this._activeMesh);
  120933. this.scene._evaluateSubMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER, this, this._evaluateSubMesh);
  120934. this.scene._afterRenderingGroupDrawStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_6__["SceneComponentConstants"].STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER, this, this.render);
  120935. };
  120936. BoundingBoxRenderer.prototype._evaluateSubMesh = function (mesh, subMesh) {
  120937. if (mesh.showSubMeshesBoundingBox) {
  120938. var boundingInfo = subMesh.getBoundingInfo();
  120939. if (boundingInfo !== null && boundingInfo !== undefined) {
  120940. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120941. this.renderList.push(boundingInfo.boundingBox);
  120942. }
  120943. }
  120944. };
  120945. BoundingBoxRenderer.prototype._activeMesh = function (sourceMesh, mesh) {
  120946. if (sourceMesh.showBoundingBox || this.scene.forceShowBoundingBoxes) {
  120947. var boundingInfo = sourceMesh.getBoundingInfo();
  120948. boundingInfo.boundingBox._tag = mesh.renderingGroupId;
  120949. this.renderList.push(boundingInfo.boundingBox);
  120950. }
  120951. };
  120952. BoundingBoxRenderer.prototype._prepareRessources = function () {
  120953. if (this._colorShader) {
  120954. return;
  120955. }
  120956. this._colorShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_8__["ShaderMaterial"]("colorShader", this.scene, "color", {
  120957. attributes: [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind],
  120958. uniforms: ["world", "viewProjection", "color"]
  120959. });
  120960. var engine = this.scene.getEngine();
  120961. var boxdata = _Meshes_mesh_vertexData__WEBPACK_IMPORTED_MODULE_3__["VertexData"].CreateBox({ size: 1.0 });
  120962. 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);
  120963. this._createIndexBuffer();
  120964. };
  120965. BoundingBoxRenderer.prototype._createIndexBuffer = function () {
  120966. var engine = this.scene.getEngine();
  120967. 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]);
  120968. };
  120969. /**
  120970. * Rebuilds the elements related to this component in case of
  120971. * context lost for instance.
  120972. */
  120973. BoundingBoxRenderer.prototype.rebuild = function () {
  120974. var vb = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  120975. if (vb) {
  120976. vb._rebuild();
  120977. }
  120978. this._createIndexBuffer();
  120979. };
  120980. /**
  120981. * @hidden
  120982. */
  120983. BoundingBoxRenderer.prototype.reset = function () {
  120984. this.renderList.reset();
  120985. };
  120986. /**
  120987. * Render the bounding boxes of a specific rendering group
  120988. * @param renderingGroupId defines the rendering group to render
  120989. */
  120990. BoundingBoxRenderer.prototype.render = function (renderingGroupId) {
  120991. if (this.renderList.length === 0) {
  120992. return;
  120993. }
  120994. this._prepareRessources();
  120995. if (!this._colorShader.isReady()) {
  120996. return;
  120997. }
  120998. var engine = this.scene.getEngine();
  120999. engine.setDepthWrite(false);
  121000. this._colorShader._preBind();
  121001. for (var boundingBoxIndex = 0; boundingBoxIndex < this.renderList.length; boundingBoxIndex++) {
  121002. var boundingBox = this.renderList.data[boundingBoxIndex];
  121003. if (boundingBox._tag !== renderingGroupId) {
  121004. continue;
  121005. }
  121006. var min = boundingBox.minimum;
  121007. var max = boundingBox.maximum;
  121008. var diff = max.subtract(min);
  121009. var median = min.add(diff.scale(0.5));
  121010. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  121011. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  121012. .multiply(boundingBox.getWorldMatrix());
  121013. // VBOs
  121014. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  121015. if (this.showBackLines) {
  121016. // Back
  121017. engine.setDepthFunctionToGreaterOrEqual();
  121018. this.scene.resetCachedMaterial();
  121019. this._colorShader.setColor4("color", this.backColor.toColor4());
  121020. this._colorShader.bind(worldMatrix);
  121021. // Draw order
  121022. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121023. }
  121024. // Front
  121025. engine.setDepthFunctionToLess();
  121026. this.scene.resetCachedMaterial();
  121027. this._colorShader.setColor4("color", this.frontColor.toColor4());
  121028. this._colorShader.bind(worldMatrix);
  121029. // Draw order
  121030. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121031. }
  121032. this._colorShader.unbind();
  121033. engine.setDepthFunctionToLessOrEqual();
  121034. engine.setDepthWrite(true);
  121035. };
  121036. /**
  121037. * In case of occlusion queries, we can render the occlusion bounding box through this method
  121038. * @param mesh Define the mesh to render the occlusion bounding box for
  121039. */
  121040. BoundingBoxRenderer.prototype.renderOcclusionBoundingBox = function (mesh) {
  121041. this._prepareRessources();
  121042. if (!this._colorShader.isReady() || !mesh._boundingInfo) {
  121043. return;
  121044. }
  121045. var engine = this.scene.getEngine();
  121046. engine.setDepthWrite(false);
  121047. engine.setColorWrite(false);
  121048. this._colorShader._preBind();
  121049. var boundingBox = mesh._boundingInfo.boundingBox;
  121050. var min = boundingBox.minimum;
  121051. var max = boundingBox.maximum;
  121052. var diff = max.subtract(min);
  121053. var median = min.add(diff.scale(0.5));
  121054. var worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Scaling(diff.x, diff.y, diff.z)
  121055. .multiply(_Maths_math__WEBPACK_IMPORTED_MODULE_4__["Matrix"].Translation(median.x, median.y, median.z))
  121056. .multiply(boundingBox.getWorldMatrix());
  121057. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, this._colorShader.getEffect());
  121058. engine.setDepthFunctionToLess();
  121059. this.scene.resetCachedMaterial();
  121060. this._colorShader.bind(worldMatrix);
  121061. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].LineListDrawMode, 0, 24);
  121062. this._colorShader.unbind();
  121063. engine.setDepthFunctionToLessOrEqual();
  121064. engine.setDepthWrite(true);
  121065. engine.setColorWrite(true);
  121066. };
  121067. /**
  121068. * Dispose and release the resources attached to this renderer.
  121069. */
  121070. BoundingBoxRenderer.prototype.dispose = function () {
  121071. if (!this._colorShader) {
  121072. return;
  121073. }
  121074. this.renderList.dispose();
  121075. this._colorShader.dispose();
  121076. var buffer = this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121077. if (buffer) {
  121078. buffer.dispose();
  121079. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  121080. }
  121081. this.scene.getEngine()._releaseBuffer(this._indexBuffer);
  121082. };
  121083. return BoundingBoxRenderer;
  121084. }());
  121085. /***/ }),
  121086. /***/ "./Rendering/depthRenderer.ts":
  121087. /*!************************************!*\
  121088. !*** ./Rendering/depthRenderer.ts ***!
  121089. \************************************/
  121090. /*! exports provided: DepthRenderer */
  121091. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121092. "use strict";
  121093. __webpack_require__.r(__webpack_exports__);
  121094. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return DepthRenderer; });
  121095. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121096. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121097. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121098. /* harmony import */ var _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/renderTargetTexture */ "./Materials/Textures/renderTargetTexture.ts");
  121099. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121100. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121101. /* harmony import */ var _Shaders_depth_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/depth.fragment */ "./Shaders/depth.fragment.ts");
  121102. /* harmony import */ var _Shaders_depth_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/depth.vertex */ "./Shaders/depth.vertex.ts");
  121103. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  121104. /**
  121105. * This represents a depth renderer in Babylon.
  121106. * A depth renderer will render to it's depth map every frame which can be displayed or used in post processing
  121107. */
  121108. var DepthRenderer = /** @class */ (function () {
  121109. /**
  121110. * Instantiates a depth renderer
  121111. * @param scene The scene the renderer belongs to
  121112. * @param type The texture type of the depth map (default: Engine.TEXTURETYPE_FLOAT)
  121113. * @param camera The camera to be used to render the depth map (default: scene's active camera)
  121114. */
  121115. function DepthRenderer(scene, type, camera) {
  121116. if (type === void 0) { type = _Engines_constants__WEBPACK_IMPORTED_MODULE_5__["Constants"].TEXTURETYPE_FLOAT; }
  121117. if (camera === void 0) { camera = null; }
  121118. var _this = this;
  121119. /**
  121120. * Specifiess that the depth renderer will only be used within
  121121. * the camera it is created for.
  121122. * This can help forcing its rendering during the camera processing.
  121123. */
  121124. this.useOnlyInActiveCamera = false;
  121125. this._scene = scene;
  121126. DepthRenderer._SceneComponentInitialization(this._scene);
  121127. this._camera = camera;
  121128. var engine = scene.getEngine();
  121129. // Render target
  121130. this._depthMap = new _Materials_Textures_renderTargetTexture__WEBPACK_IMPORTED_MODULE_3__["RenderTargetTexture"]("depthMap", { width: engine.getRenderWidth(), height: engine.getRenderHeight() }, this._scene, false, true, type);
  121131. this._depthMap.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121132. this._depthMap.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_2__["Texture"].CLAMP_ADDRESSMODE;
  121133. this._depthMap.refreshRate = 1;
  121134. this._depthMap.renderParticles = false;
  121135. this._depthMap.renderList = null;
  121136. // Camera to get depth map from to support multiple concurrent cameras
  121137. this._depthMap.activeCamera = this._camera;
  121138. this._depthMap.ignoreCameraViewport = true;
  121139. this._depthMap.useCameraPostProcesses = false;
  121140. // set default depth value to 1.0 (far away)
  121141. this._depthMap.onClearObservable.add(function (engine) {
  121142. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0), true, true, true);
  121143. });
  121144. // Custom render function
  121145. var renderSubMesh = function (subMesh) {
  121146. var mesh = subMesh.getRenderingMesh();
  121147. var scene = _this._scene;
  121148. var engine = scene.getEngine();
  121149. var material = subMesh.getMaterial();
  121150. if (!material) {
  121151. return;
  121152. }
  121153. // Culling and reverse (right handed system)
  121154. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  121155. // Managing instances
  121156. var batch = mesh._getInstancesRenderList(subMesh._id);
  121157. if (batch.mustReturn) {
  121158. return;
  121159. }
  121160. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  121161. var camera = _this._camera || scene.activeCamera;
  121162. if (_this.isReady(subMesh, hardwareInstancedRendering) && camera) {
  121163. engine.enableEffect(_this._effect);
  121164. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode);
  121165. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  121166. _this._effect.setFloat2("depthValues", camera.minZ, camera.minZ + camera.maxZ);
  121167. // Alpha test
  121168. if (material && material.needAlphaTesting()) {
  121169. var alphaTexture = material.getAlphaTestTexture();
  121170. if (alphaTexture) {
  121171. _this._effect.setTexture("diffuseSampler", alphaTexture);
  121172. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  121173. }
  121174. }
  121175. // Bones
  121176. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  121177. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  121178. }
  121179. // Draw
  121180. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_4__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  121181. }
  121182. };
  121183. this._depthMap.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  121184. var index;
  121185. if (depthOnlySubMeshes.length) {
  121186. engine.setColorWrite(false);
  121187. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  121188. renderSubMesh(depthOnlySubMeshes.data[index]);
  121189. }
  121190. engine.setColorWrite(true);
  121191. }
  121192. for (index = 0; index < opaqueSubMeshes.length; index++) {
  121193. renderSubMesh(opaqueSubMeshes.data[index]);
  121194. }
  121195. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  121196. renderSubMesh(alphaTestSubMeshes.data[index]);
  121197. }
  121198. };
  121199. }
  121200. /**
  121201. * Creates the depth rendering effect and checks if the effect is ready.
  121202. * @param subMesh The submesh to be used to render the depth map of
  121203. * @param useInstances If multiple world instances should be used
  121204. * @returns if the depth renderer is ready to render the depth map
  121205. */
  121206. DepthRenderer.prototype.isReady = function (subMesh, useInstances) {
  121207. var material = subMesh.getMaterial();
  121208. if (material.disableDepthWrite) {
  121209. return false;
  121210. }
  121211. var defines = [];
  121212. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121213. var mesh = subMesh.getMesh();
  121214. // Alpha test
  121215. if (material && material.needAlphaTesting() && material.getAlphaTestTexture()) {
  121216. defines.push("#define ALPHATEST");
  121217. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121218. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121219. defines.push("#define UV1");
  121220. }
  121221. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121222. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121223. defines.push("#define UV2");
  121224. }
  121225. }
  121226. // Bones
  121227. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121228. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121229. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121230. if (mesh.numBoneInfluencers > 4) {
  121231. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121232. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121233. }
  121234. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121235. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121236. }
  121237. else {
  121238. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121239. }
  121240. // Instances
  121241. if (useInstances) {
  121242. defines.push("#define INSTANCES");
  121243. attribs.push("world0");
  121244. attribs.push("world1");
  121245. attribs.push("world2");
  121246. attribs.push("world3");
  121247. }
  121248. // Get correct effect
  121249. var join = defines.join("\n");
  121250. if (this._cachedDefines !== join) {
  121251. this._cachedDefines = join;
  121252. this._effect = this._scene.getEngine().createEffect("depth", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "depthValues"], ["diffuseSampler"], join);
  121253. }
  121254. return this._effect.isReady();
  121255. };
  121256. /**
  121257. * Gets the texture which the depth map will be written to.
  121258. * @returns The depth map texture
  121259. */
  121260. DepthRenderer.prototype.getDepthMap = function () {
  121261. return this._depthMap;
  121262. };
  121263. /**
  121264. * Disposes of the depth renderer.
  121265. */
  121266. DepthRenderer.prototype.dispose = function () {
  121267. this._depthMap.dispose();
  121268. };
  121269. /** @hidden */
  121270. DepthRenderer._SceneComponentInitialization = function (_) {
  121271. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("DepthRendererSceneComponent");
  121272. };
  121273. return DepthRenderer;
  121274. }());
  121275. /***/ }),
  121276. /***/ "./Rendering/depthRendererSceneComponent.ts":
  121277. /*!**************************************************!*\
  121278. !*** ./Rendering/depthRendererSceneComponent.ts ***!
  121279. \**************************************************/
  121280. /*! exports provided: DepthRendererSceneComponent */
  121281. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121282. "use strict";
  121283. __webpack_require__.r(__webpack_exports__);
  121284. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return DepthRendererSceneComponent; });
  121285. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  121286. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  121287. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121288. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  121289. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableDepthRenderer = function (camera) {
  121290. camera = camera || this.activeCamera;
  121291. if (!camera) {
  121292. throw "No camera available to enable depth renderer";
  121293. }
  121294. if (!this._depthRenderer) {
  121295. this._depthRenderer = {};
  121296. }
  121297. if (!this._depthRenderer[camera.id]) {
  121298. var textureType = 0;
  121299. if (this.getEngine().getCaps().textureHalfFloatRender) {
  121300. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_HALF_FLOAT;
  121301. }
  121302. else if (this.getEngine().getCaps().textureFloatRender) {
  121303. textureType = _Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].TEXTURETYPE_FLOAT;
  121304. }
  121305. else {
  121306. throw "Depth renderer does not support int texture type";
  121307. }
  121308. this._depthRenderer[camera.id] = new _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"](this, textureType, camera);
  121309. }
  121310. return this._depthRenderer[camera.id];
  121311. };
  121312. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableDepthRenderer = function (camera) {
  121313. camera = camera || this.activeCamera;
  121314. if (!camera || !this._depthRenderer || !this._depthRenderer[camera.id]) {
  121315. return;
  121316. }
  121317. this._depthRenderer[camera.id].dispose();
  121318. delete this._depthRenderer[camera.id];
  121319. };
  121320. /**
  121321. * Defines the Depth Renderer scene component responsible to manage a depth buffer useful
  121322. * in several rendering techniques.
  121323. */
  121324. var DepthRendererSceneComponent = /** @class */ (function () {
  121325. /**
  121326. * Creates a new instance of the component for the given scene
  121327. * @param scene Defines the scene to register the component in
  121328. */
  121329. function DepthRendererSceneComponent(scene) {
  121330. /**
  121331. * The component name helpfull to identify the component in the list of scene components.
  121332. */
  121333. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER;
  121334. this.scene = scene;
  121335. }
  121336. /**
  121337. * Registers the component in a given scene
  121338. */
  121339. DepthRendererSceneComponent.prototype.register = function () {
  121340. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_DEPTHRENDERER, this, this._gatherRenderTargets);
  121341. this.scene._gatherActiveCameraRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER, this, this._gatherActiveCameraRenderTargets);
  121342. };
  121343. /**
  121344. * Rebuilds the elements related to this component in case of
  121345. * context lost for instance.
  121346. */
  121347. DepthRendererSceneComponent.prototype.rebuild = function () {
  121348. // Nothing to do for this component
  121349. };
  121350. /**
  121351. * Disposes the component and the associated ressources
  121352. */
  121353. DepthRendererSceneComponent.prototype.dispose = function () {
  121354. for (var key in this.scene._depthRenderer) {
  121355. this.scene._depthRenderer[key].dispose();
  121356. }
  121357. };
  121358. DepthRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  121359. if (this.scene._depthRenderer) {
  121360. for (var key in this.scene._depthRenderer) {
  121361. var depthRenderer = this.scene._depthRenderer[key];
  121362. if (!depthRenderer.useOnlyInActiveCamera) {
  121363. renderTargets.push(depthRenderer.getDepthMap());
  121364. }
  121365. }
  121366. }
  121367. };
  121368. DepthRendererSceneComponent.prototype._gatherActiveCameraRenderTargets = function (renderTargets) {
  121369. if (this.scene._depthRenderer) {
  121370. for (var key in this.scene._depthRenderer) {
  121371. var depthRenderer = this.scene._depthRenderer[key];
  121372. if (depthRenderer.useOnlyInActiveCamera && this.scene.activeCamera.id === key) {
  121373. renderTargets.push(depthRenderer.getDepthMap());
  121374. }
  121375. }
  121376. }
  121377. };
  121378. return DepthRendererSceneComponent;
  121379. }());
  121380. _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]._SceneComponentInitialization = function (scene) {
  121381. // Register the G Buffer component to the scene.
  121382. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_3__["SceneComponentConstants"].NAME_DEPTHRENDERER);
  121383. if (!component) {
  121384. component = new DepthRendererSceneComponent(scene);
  121385. scene._addComponent(component);
  121386. }
  121387. };
  121388. /***/ }),
  121389. /***/ "./Rendering/edgesRenderer.ts":
  121390. /*!************************************!*\
  121391. !*** ./Rendering/edgesRenderer.ts ***!
  121392. \************************************/
  121393. /*! exports provided: EdgesRenderer, LineEdgesRenderer */
  121394. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121395. "use strict";
  121396. __webpack_require__.r(__webpack_exports__);
  121397. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return EdgesRenderer; });
  121398. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return LineEdgesRenderer; });
  121399. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  121400. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121401. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  121402. /* harmony import */ var _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Meshes/linesMesh */ "./Meshes/linesMesh.ts");
  121403. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121404. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121405. /* harmony import */ var _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/shaderMaterial */ "./Materials/shaderMaterial.ts");
  121406. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Cameras/camera */ "./Cameras/camera.ts");
  121407. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121408. /* harmony import */ var _Shaders_line_fragment__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Shaders/line.fragment */ "./Shaders/line.fragment.ts");
  121409. /* harmony import */ var _Shaders_line_vertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/line.vertex */ "./Shaders/line.vertex.ts");
  121410. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.disableEdgesRendering = function () {
  121411. if (this._edgesRenderer) {
  121412. this._edgesRenderer.dispose();
  121413. this._edgesRenderer = null;
  121414. }
  121415. return this;
  121416. };
  121417. _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  121418. if (epsilon === void 0) { epsilon = 0.95; }
  121419. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121420. this.disableEdgesRendering();
  121421. this._edgesRenderer = new EdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  121422. return this;
  121423. };
  121424. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_2__["AbstractMesh"].prototype, "edgesRenderer", {
  121425. get: function () {
  121426. return this._edgesRenderer;
  121427. },
  121428. enumerable: true,
  121429. configurable: true
  121430. });
  121431. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  121432. if (epsilon === void 0) { epsilon = 0.95; }
  121433. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121434. this.disableEdgesRendering();
  121435. this._edgesRenderer = new LineEdgesRenderer(this, epsilon, checkVerticesInsteadOfIndices);
  121436. return this;
  121437. };
  121438. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["InstancedLinesMesh"].prototype.enableEdgesRendering = function (epsilon, checkVerticesInsteadOfIndices) {
  121439. if (epsilon === void 0) { epsilon = 0.95; }
  121440. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121441. _Meshes_linesMesh__WEBPACK_IMPORTED_MODULE_3__["LinesMesh"].prototype.enableEdgesRendering.apply(this, arguments);
  121442. return this;
  121443. };
  121444. /**
  121445. * FaceAdjacencies Helper class to generate edges
  121446. */
  121447. var FaceAdjacencies = /** @class */ (function () {
  121448. function FaceAdjacencies() {
  121449. this.edges = new Array();
  121450. this.edgesConnectedCount = 0;
  121451. }
  121452. return FaceAdjacencies;
  121453. }());
  121454. /**
  121455. * This class is used to generate edges of the mesh that could then easily be rendered in a scene.
  121456. */
  121457. var EdgesRenderer = /** @class */ (function () {
  121458. /**
  121459. * Creates an instance of the EdgesRenderer. It is primarily use to display edges of a mesh.
  121460. * Beware when you use this class with complex objects as the adjacencies computation can be really long
  121461. * @param source Mesh used to create edges
  121462. * @param epsilon sum of angles in adjacency to check for edge
  121463. * @param checkVerticesInsteadOfIndices bases the edges detection on vertices vs indices
  121464. * @param generateEdgesLines - should generate Lines or only prepare resources.
  121465. */
  121466. function EdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices, generateEdgesLines) {
  121467. if (epsilon === void 0) { epsilon = 0.95; }
  121468. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121469. if (generateEdgesLines === void 0) { generateEdgesLines = true; }
  121470. var _this = this;
  121471. /**
  121472. * Define the size of the edges with an orthographic camera
  121473. */
  121474. this.edgesWidthScalerForOrthographic = 1000.0;
  121475. /**
  121476. * Define the size of the edges with a perspective camera
  121477. */
  121478. this.edgesWidthScalerForPerspective = 50.0;
  121479. this._linesPositions = new Array();
  121480. this._linesNormals = new Array();
  121481. this._linesIndices = new Array();
  121482. this._buffers = {};
  121483. this._checkVerticesInsteadOfIndices = false;
  121484. /** Gets or sets a boolean indicating if the edgesRenderer is active */
  121485. this.isEnabled = true;
  121486. this._source = source;
  121487. this._checkVerticesInsteadOfIndices = checkVerticesInsteadOfIndices;
  121488. this._epsilon = epsilon;
  121489. this._prepareRessources();
  121490. if (generateEdgesLines) {
  121491. this._generateEdgesLines();
  121492. }
  121493. this._meshRebuildObserver = this._source.onRebuildObservable.add(function () {
  121494. _this._rebuild();
  121495. });
  121496. this._meshDisposeObserver = this._source.onDisposeObservable.add(function () {
  121497. _this.dispose();
  121498. });
  121499. }
  121500. EdgesRenderer.prototype._prepareRessources = function () {
  121501. if (this._lineShader) {
  121502. return;
  121503. }
  121504. this._lineShader = new _Materials_shaderMaterial__WEBPACK_IMPORTED_MODULE_6__["ShaderMaterial"]("lineShader", this._source.getScene(), "line", {
  121505. attributes: ["position", "normal"],
  121506. uniforms: ["worldViewProjection", "color", "width", "aspectRatio"]
  121507. });
  121508. this._lineShader.disableDepthWrite = true;
  121509. this._lineShader.backFaceCulling = false;
  121510. };
  121511. /** @hidden */
  121512. EdgesRenderer.prototype._rebuild = function () {
  121513. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121514. if (buffer) {
  121515. buffer._rebuild();
  121516. }
  121517. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121518. if (buffer) {
  121519. buffer._rebuild();
  121520. }
  121521. var scene = this._source.getScene();
  121522. var engine = scene.getEngine();
  121523. this._ib = engine.createIndexBuffer(this._linesIndices);
  121524. };
  121525. /**
  121526. * Releases the required resources for the edges renderer
  121527. */
  121528. EdgesRenderer.prototype.dispose = function () {
  121529. this._source.onRebuildObservable.remove(this._meshRebuildObserver);
  121530. this._source.onDisposeObservable.remove(this._meshDisposeObserver);
  121531. var buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind];
  121532. if (buffer) {
  121533. buffer.dispose();
  121534. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind] = null;
  121535. }
  121536. buffer = this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121537. if (buffer) {
  121538. buffer.dispose();
  121539. this._buffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind] = null;
  121540. }
  121541. this._source.getScene().getEngine()._releaseBuffer(this._ib);
  121542. this._lineShader.dispose();
  121543. };
  121544. EdgesRenderer.prototype._processEdgeForAdjacencies = function (pa, pb, p0, p1, p2) {
  121545. if (pa === p0 && pb === p1 || pa === p1 && pb === p0) {
  121546. return 0;
  121547. }
  121548. if (pa === p1 && pb === p2 || pa === p2 && pb === p1) {
  121549. return 1;
  121550. }
  121551. if (pa === p2 && pb === p0 || pa === p0 && pb === p2) {
  121552. return 2;
  121553. }
  121554. return -1;
  121555. };
  121556. EdgesRenderer.prototype._processEdgeForAdjacenciesWithVertices = function (pa, pb, p0, p1, p2) {
  121557. if (pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p1) || pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p0)) {
  121558. return 0;
  121559. }
  121560. if (pa.equalsWithEpsilon(p1) && pb.equalsWithEpsilon(p2) || pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p1)) {
  121561. return 1;
  121562. }
  121563. if (pa.equalsWithEpsilon(p2) && pb.equalsWithEpsilon(p0) || pa.equalsWithEpsilon(p0) && pb.equalsWithEpsilon(p2)) {
  121564. return 2;
  121565. }
  121566. return -1;
  121567. };
  121568. /**
  121569. * Checks if the pair of p0 and p1 is en edge
  121570. * @param faceIndex
  121571. * @param edge
  121572. * @param faceNormals
  121573. * @param p0
  121574. * @param p1
  121575. * @private
  121576. */
  121577. EdgesRenderer.prototype._checkEdge = function (faceIndex, edge, faceNormals, p0, p1) {
  121578. var needToCreateLine;
  121579. if (edge === undefined) {
  121580. needToCreateLine = true;
  121581. }
  121582. else {
  121583. var dotProduct = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Dot(faceNormals[faceIndex], faceNormals[edge]);
  121584. needToCreateLine = dotProduct < this._epsilon;
  121585. }
  121586. if (needToCreateLine) {
  121587. this.createLine(p0, p1, this._linesPositions.length / 3);
  121588. }
  121589. };
  121590. /**
  121591. * push line into the position, normal and index buffer
  121592. * @protected
  121593. */
  121594. EdgesRenderer.prototype.createLine = function (p0, p1, offset) {
  121595. // Positions
  121596. 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);
  121597. // Normals
  121598. 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);
  121599. // Indices
  121600. this._linesIndices.push(offset, offset + 1, offset + 2, offset, offset + 2, offset + 3);
  121601. };
  121602. /**
  121603. * Generates lines edges from adjacencjes
  121604. * @private
  121605. */
  121606. EdgesRenderer.prototype._generateEdgesLines = function () {
  121607. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  121608. var indices = this._source.getIndices();
  121609. if (!indices || !positions) {
  121610. return;
  121611. }
  121612. // First let's find adjacencies
  121613. var adjacencies = new Array();
  121614. var faceNormals = new Array();
  121615. var index;
  121616. var faceAdjacencies;
  121617. // Prepare faces
  121618. for (index = 0; index < indices.length; index += 3) {
  121619. faceAdjacencies = new FaceAdjacencies();
  121620. var p0Index = indices[index];
  121621. var p1Index = indices[index + 1];
  121622. var p2Index = indices[index + 2];
  121623. faceAdjacencies.p0 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p0Index * 3], positions[p0Index * 3 + 1], positions[p0Index * 3 + 2]);
  121624. faceAdjacencies.p1 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p1Index * 3], positions[p1Index * 3 + 1], positions[p1Index * 3 + 2]);
  121625. faceAdjacencies.p2 = new _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"](positions[p2Index * 3], positions[p2Index * 3 + 1], positions[p2Index * 3 + 2]);
  121626. var faceNormal = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].Cross(faceAdjacencies.p1.subtract(faceAdjacencies.p0), faceAdjacencies.p2.subtract(faceAdjacencies.p1));
  121627. faceNormal.normalize();
  121628. faceNormals.push(faceNormal);
  121629. adjacencies.push(faceAdjacencies);
  121630. }
  121631. // Scan
  121632. for (index = 0; index < adjacencies.length; index++) {
  121633. faceAdjacencies = adjacencies[index];
  121634. for (var otherIndex = index + 1; otherIndex < adjacencies.length; otherIndex++) {
  121635. var otherFaceAdjacencies = adjacencies[otherIndex];
  121636. if (faceAdjacencies.edgesConnectedCount === 3) { // Full
  121637. break;
  121638. }
  121639. if (otherFaceAdjacencies.edgesConnectedCount === 3) { // Full
  121640. continue;
  121641. }
  121642. var otherP0 = indices[otherIndex * 3];
  121643. var otherP1 = indices[otherIndex * 3 + 1];
  121644. var otherP2 = indices[otherIndex * 3 + 2];
  121645. for (var edgeIndex = 0; edgeIndex < 3; edgeIndex++) {
  121646. var otherEdgeIndex = 0;
  121647. if (faceAdjacencies.edges[edgeIndex] !== undefined) {
  121648. continue;
  121649. }
  121650. switch (edgeIndex) {
  121651. case 0:
  121652. if (this._checkVerticesInsteadOfIndices) {
  121653. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p0, faceAdjacencies.p1, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121654. }
  121655. else {
  121656. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3], indices[index * 3 + 1], otherP0, otherP1, otherP2);
  121657. }
  121658. break;
  121659. case 1:
  121660. if (this._checkVerticesInsteadOfIndices) {
  121661. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p1, faceAdjacencies.p2, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121662. }
  121663. else {
  121664. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 1], indices[index * 3 + 2], otherP0, otherP1, otherP2);
  121665. }
  121666. break;
  121667. case 2:
  121668. if (this._checkVerticesInsteadOfIndices) {
  121669. otherEdgeIndex = this._processEdgeForAdjacenciesWithVertices(faceAdjacencies.p2, faceAdjacencies.p0, otherFaceAdjacencies.p0, otherFaceAdjacencies.p1, otherFaceAdjacencies.p2);
  121670. }
  121671. else {
  121672. otherEdgeIndex = this._processEdgeForAdjacencies(indices[index * 3 + 2], indices[index * 3], otherP0, otherP1, otherP2);
  121673. }
  121674. break;
  121675. }
  121676. if (otherEdgeIndex === -1) {
  121677. continue;
  121678. }
  121679. faceAdjacencies.edges[edgeIndex] = otherIndex;
  121680. otherFaceAdjacencies.edges[otherEdgeIndex] = index;
  121681. faceAdjacencies.edgesConnectedCount++;
  121682. otherFaceAdjacencies.edgesConnectedCount++;
  121683. if (faceAdjacencies.edgesConnectedCount === 3) {
  121684. break;
  121685. }
  121686. }
  121687. }
  121688. }
  121689. // Create lines
  121690. for (index = 0; index < adjacencies.length; index++) {
  121691. // 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
  121692. var current = adjacencies[index];
  121693. this._checkEdge(index, current.edges[0], faceNormals, current.p0, current.p1);
  121694. this._checkEdge(index, current.edges[1], faceNormals, current.p1, current.p2);
  121695. this._checkEdge(index, current.edges[2], faceNormals, current.p2, current.p0);
  121696. }
  121697. // Merge into a single mesh
  121698. var engine = this._source.getScene().getEngine();
  121699. 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);
  121700. 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);
  121701. this._ib = engine.createIndexBuffer(this._linesIndices);
  121702. this._indicesCount = this._linesIndices.length;
  121703. };
  121704. /**
  121705. * Checks wether or not the edges renderer is ready to render.
  121706. * @return true if ready, otherwise false.
  121707. */
  121708. EdgesRenderer.prototype.isReady = function () {
  121709. return this._lineShader.isReady();
  121710. };
  121711. /**
  121712. * Renders the edges of the attached mesh,
  121713. */
  121714. EdgesRenderer.prototype.render = function () {
  121715. var scene = this._source.getScene();
  121716. if (!this.isReady() || !scene.activeCamera) {
  121717. return;
  121718. }
  121719. var engine = scene.getEngine();
  121720. this._lineShader._preBind();
  121721. if (this._source.edgesColor.a !== 1) {
  121722. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_COMBINE);
  121723. }
  121724. else {
  121725. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_8__["Constants"].ALPHA_DISABLE);
  121726. }
  121727. // VBOs
  121728. engine.bindBuffers(this._buffers, this._ib, this._lineShader.getEffect());
  121729. scene.resetCachedMaterial();
  121730. this._lineShader.setColor4("color", this._source.edgesColor);
  121731. if (scene.activeCamera.mode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_7__["Camera"].ORTHOGRAPHIC_CAMERA) {
  121732. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForOrthographic);
  121733. }
  121734. else {
  121735. this._lineShader.setFloat("width", this._source.edgesWidth / this.edgesWidthScalerForPerspective);
  121736. }
  121737. this._lineShader.setFloat("aspectRatio", engine.getAspectRatio(scene.activeCamera));
  121738. this._lineShader.bind(this._source.getWorldMatrix());
  121739. // Draw order
  121740. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, 0, this._indicesCount);
  121741. this._lineShader.unbind();
  121742. };
  121743. return EdgesRenderer;
  121744. }());
  121745. /**
  121746. * LineEdgesRenderer for LineMeshes to remove unnecessary triangulation
  121747. */
  121748. var LineEdgesRenderer = /** @class */ (function (_super) {
  121749. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](LineEdgesRenderer, _super);
  121750. /**
  121751. * This constructor turns off auto generating edges line in Edges Renderer to make it here.
  121752. * @param source LineMesh used to generate edges
  121753. * @param epsilon not important (specified angle for edge detection)
  121754. * @param checkVerticesInsteadOfIndices not important for LineMesh
  121755. */
  121756. function LineEdgesRenderer(source, epsilon, checkVerticesInsteadOfIndices) {
  121757. if (epsilon === void 0) { epsilon = 0.95; }
  121758. if (checkVerticesInsteadOfIndices === void 0) { checkVerticesInsteadOfIndices = false; }
  121759. var _this = _super.call(this, source, epsilon, checkVerticesInsteadOfIndices, false) || this;
  121760. _this._generateEdgesLines();
  121761. return _this;
  121762. }
  121763. /**
  121764. * Generate edges for each line in LinesMesh. Every Line should be rendered as edge.
  121765. */
  121766. LineEdgesRenderer.prototype._generateEdgesLines = function () {
  121767. var positions = this._source.getVerticesData(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind);
  121768. var indices = this._source.getIndices();
  121769. if (!indices || !positions) {
  121770. return;
  121771. }
  121772. var p0 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[0];
  121773. var p1 = _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Tmp"].Vector3[1];
  121774. var len = indices.length - 1;
  121775. for (var i = 0, offset = 0; i < len; i += 2, offset += 4) {
  121776. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i], p0);
  121777. _Maths_math__WEBPACK_IMPORTED_MODULE_4__["Vector3"].FromArrayToRef(positions, 3 * indices[i + 1], p1);
  121778. this.createLine(p0, p1, offset);
  121779. }
  121780. // Merge into a single mesh
  121781. var engine = this._source.getScene().getEngine();
  121782. 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);
  121783. 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);
  121784. this._ib = engine.createIndexBuffer(this._linesIndices);
  121785. this._indicesCount = this._linesIndices.length;
  121786. };
  121787. return LineEdgesRenderer;
  121788. }(EdgesRenderer));
  121789. /***/ }),
  121790. /***/ "./Rendering/geometryBufferRenderer.ts":
  121791. /*!*********************************************!*\
  121792. !*** ./Rendering/geometryBufferRenderer.ts ***!
  121793. \*********************************************/
  121794. /*! exports provided: GeometryBufferRenderer */
  121795. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  121796. "use strict";
  121797. __webpack_require__.r(__webpack_exports__);
  121798. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return GeometryBufferRenderer; });
  121799. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  121800. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  121801. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  121802. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  121803. /* harmony import */ var _Materials_Textures_multiRenderTarget__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Materials/Textures/multiRenderTarget */ "./Materials/Textures/multiRenderTarget.ts");
  121804. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  121805. /* harmony import */ var _Shaders_geometry_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/geometry.fragment */ "./Shaders/geometry.fragment.ts");
  121806. /* harmony import */ var _Shaders_geometry_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/geometry.vertex */ "./Shaders/geometry.vertex.ts");
  121807. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../Misc/devTools */ "./Misc/devTools.ts");
  121808. /**
  121809. * This renderer is helpfull to fill one of the render target with a geometry buffer.
  121810. */
  121811. var GeometryBufferRenderer = /** @class */ (function () {
  121812. /**
  121813. * Creates a new G Buffer for the scene
  121814. * @param scene The scene the buffer belongs to
  121815. * @param ratio How big is the buffer related to the main canvas.
  121816. */
  121817. function GeometryBufferRenderer(scene, ratio) {
  121818. if (ratio === void 0) { ratio = 1; }
  121819. /**
  121820. * Dictionary used to store the previous transformation matrices of each rendered mesh
  121821. * in order to compute objects velocities when enableVelocity is set to "true"
  121822. * @hidden
  121823. */
  121824. this._previousTransformationMatrices = {};
  121825. this._enablePosition = false;
  121826. this._enableVelocity = false;
  121827. this._positionIndex = -1;
  121828. this._velocityIndex = -1;
  121829. this._scene = scene;
  121830. this._ratio = ratio;
  121831. GeometryBufferRenderer._SceneComponentInitialization(this._scene);
  121832. // Render target
  121833. this._createRenderTargets();
  121834. }
  121835. Object.defineProperty(GeometryBufferRenderer.prototype, "renderList", {
  121836. /**
  121837. * Set the render list (meshes to be rendered) used in the G buffer.
  121838. */
  121839. set: function (meshes) {
  121840. this._multiRenderTarget.renderList = meshes;
  121841. },
  121842. enumerable: true,
  121843. configurable: true
  121844. });
  121845. Object.defineProperty(GeometryBufferRenderer.prototype, "isSupported", {
  121846. /**
  121847. * Gets wether or not G buffer are supported by the running hardware.
  121848. * This requires draw buffer supports
  121849. */
  121850. get: function () {
  121851. return this._multiRenderTarget.isSupported;
  121852. },
  121853. enumerable: true,
  121854. configurable: true
  121855. });
  121856. /**
  121857. * Returns the index of the given texture type in the G-Buffer textures array
  121858. * @param textureType The texture type constant. For example GeometryBufferRenderer.POSITION_TEXTURE_INDEX
  121859. * @returns the index of the given texture type in the G-Buffer textures array
  121860. */
  121861. GeometryBufferRenderer.prototype.getTextureIndex = function (textureType) {
  121862. switch (textureType) {
  121863. case GeometryBufferRenderer.POSITION_TEXTURE_TYPE: return this._positionIndex;
  121864. case GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE: return this._velocityIndex;
  121865. default: return -1;
  121866. }
  121867. };
  121868. Object.defineProperty(GeometryBufferRenderer.prototype, "enablePosition", {
  121869. /**
  121870. * Gets a boolean indicating if objects positions are enabled for the G buffer.
  121871. */
  121872. get: function () {
  121873. return this._enablePosition;
  121874. },
  121875. /**
  121876. * Sets whether or not objects positions are enabled for the G buffer.
  121877. */
  121878. set: function (enable) {
  121879. this._enablePosition = enable;
  121880. this.dispose();
  121881. this._createRenderTargets();
  121882. },
  121883. enumerable: true,
  121884. configurable: true
  121885. });
  121886. Object.defineProperty(GeometryBufferRenderer.prototype, "enableVelocity", {
  121887. /**
  121888. * Gets a boolean indicating if objects velocities are enabled for the G buffer.
  121889. */
  121890. get: function () {
  121891. return this._enableVelocity;
  121892. },
  121893. /**
  121894. * Sets wether or not objects velocities are enabled for the G buffer.
  121895. */
  121896. set: function (enable) {
  121897. this._enableVelocity = enable;
  121898. this.dispose();
  121899. this._createRenderTargets();
  121900. },
  121901. enumerable: true,
  121902. configurable: true
  121903. });
  121904. Object.defineProperty(GeometryBufferRenderer.prototype, "scene", {
  121905. /**
  121906. * Gets the scene associated with the buffer.
  121907. */
  121908. get: function () {
  121909. return this._scene;
  121910. },
  121911. enumerable: true,
  121912. configurable: true
  121913. });
  121914. Object.defineProperty(GeometryBufferRenderer.prototype, "ratio", {
  121915. /**
  121916. * Gets the ratio used by the buffer during its creation.
  121917. * How big is the buffer related to the main canvas.
  121918. */
  121919. get: function () {
  121920. return this._ratio;
  121921. },
  121922. enumerable: true,
  121923. configurable: true
  121924. });
  121925. /**
  121926. * Checks wether everything is ready to render a submesh to the G buffer.
  121927. * @param subMesh the submesh to check readiness for
  121928. * @param useInstances is the mesh drawn using instance or not
  121929. * @returns true if ready otherwise false
  121930. */
  121931. GeometryBufferRenderer.prototype.isReady = function (subMesh, useInstances) {
  121932. var material = subMesh.getMaterial();
  121933. if (material && material.disableDepthWrite) {
  121934. return false;
  121935. }
  121936. var defines = [];
  121937. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].NormalKind];
  121938. var mesh = subMesh.getMesh();
  121939. // Alpha test
  121940. if (material && material.needAlphaTesting()) {
  121941. defines.push("#define ALPHATEST");
  121942. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind)) {
  121943. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UVKind);
  121944. defines.push("#define UV1");
  121945. }
  121946. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind)) {
  121947. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].UV2Kind);
  121948. defines.push("#define UV2");
  121949. }
  121950. }
  121951. // Buffers
  121952. if (this._enablePosition) {
  121953. defines.push("#define POSITION");
  121954. defines.push("#define POSITION_INDEX " + this._positionIndex);
  121955. }
  121956. if (this._enableVelocity) {
  121957. defines.push("#define VELOCITY");
  121958. defines.push("#define VELOCITY_INDEX " + this._velocityIndex);
  121959. }
  121960. // Bones
  121961. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  121962. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesKind);
  121963. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsKind);
  121964. if (mesh.numBoneInfluencers > 4) {
  121965. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesIndicesExtraKind);
  121966. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_1__["VertexBuffer"].MatricesWeightsExtraKind);
  121967. }
  121968. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  121969. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  121970. }
  121971. else {
  121972. defines.push("#define NUM_BONE_INFLUENCERS 0");
  121973. }
  121974. // Instances
  121975. if (useInstances) {
  121976. defines.push("#define INSTANCES");
  121977. attribs.push("world0");
  121978. attribs.push("world1");
  121979. attribs.push("world2");
  121980. attribs.push("world3");
  121981. }
  121982. // Setup textures count
  121983. defines.push("#define RENDER_TARGET_COUNT " + this._multiRenderTarget.textures.length);
  121984. // Get correct effect
  121985. var join = defines.join("\n");
  121986. if (this._cachedDefines !== join) {
  121987. this._cachedDefines = join;
  121988. this._effect = this._scene.getEngine().createEffect("geometry", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "view", "previousWorldViewProjection"], ["diffuseSampler"], join, undefined, undefined, undefined, { buffersCount: this._enablePosition ? 3 : 2 });
  121989. }
  121990. return this._effect.isReady();
  121991. };
  121992. /**
  121993. * Gets the current underlying G Buffer.
  121994. * @returns the buffer
  121995. */
  121996. GeometryBufferRenderer.prototype.getGBuffer = function () {
  121997. return this._multiRenderTarget;
  121998. };
  121999. Object.defineProperty(GeometryBufferRenderer.prototype, "samples", {
  122000. /**
  122001. * Gets the number of samples used to render the buffer (anti aliasing).
  122002. */
  122003. get: function () {
  122004. return this._multiRenderTarget.samples;
  122005. },
  122006. /**
  122007. * Sets the number of samples used to render the buffer (anti aliasing).
  122008. */
  122009. set: function (value) {
  122010. this._multiRenderTarget.samples = value;
  122011. },
  122012. enumerable: true,
  122013. configurable: true
  122014. });
  122015. /**
  122016. * Disposes the renderer and frees up associated resources.
  122017. */
  122018. GeometryBufferRenderer.prototype.dispose = function () {
  122019. this.getGBuffer().dispose();
  122020. };
  122021. GeometryBufferRenderer.prototype._createRenderTargets = function () {
  122022. var _this = this;
  122023. var engine = this._scene.getEngine();
  122024. var count = 2;
  122025. if (this._enablePosition) {
  122026. this._positionIndex = count;
  122027. count++;
  122028. }
  122029. if (this._enableVelocity) {
  122030. this._velocityIndex = count;
  122031. count++;
  122032. }
  122033. 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 });
  122034. if (!this.isSupported) {
  122035. return;
  122036. }
  122037. this._multiRenderTarget.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  122038. this._multiRenderTarget.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_3__["Texture"].CLAMP_ADDRESSMODE;
  122039. this._multiRenderTarget.refreshRate = 1;
  122040. this._multiRenderTarget.renderParticles = false;
  122041. this._multiRenderTarget.renderList = null;
  122042. // set default depth value to 1.0 (far away)
  122043. this._multiRenderTarget.onClearObservable.add(function (engine) {
  122044. engine.clear(new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](0.0, 0.0, 0.0, 1.0), true, true, true);
  122045. });
  122046. // Custom render function
  122047. var renderSubMesh = function (subMesh) {
  122048. var mesh = subMesh.getRenderingMesh();
  122049. var scene = _this._scene;
  122050. var engine = scene.getEngine();
  122051. var material = subMesh.getMaterial();
  122052. if (!material) {
  122053. return;
  122054. }
  122055. // Velocity
  122056. if (!_this._previousTransformationMatrices[mesh.uniqueId]) {
  122057. _this._previousTransformationMatrices[mesh.uniqueId] = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Matrix"].Identity();
  122058. }
  122059. // Culling
  122060. engine.setState(material.backFaceCulling, 0, false, scene.useRightHandedSystem);
  122061. // Managing instances
  122062. var batch = mesh._getInstancesRenderList(subMesh._id);
  122063. if (batch.mustReturn) {
  122064. return;
  122065. }
  122066. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null);
  122067. if (_this.isReady(subMesh, hardwareInstancedRendering)) {
  122068. engine.enableEffect(_this._effect);
  122069. mesh._bind(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  122070. _this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  122071. _this._effect.setMatrix("view", scene.getViewMatrix());
  122072. // Alpha test
  122073. if (material && material.needAlphaTesting()) {
  122074. var alphaTexture = material.getAlphaTestTexture();
  122075. if (alphaTexture) {
  122076. _this._effect.setTexture("diffuseSampler", alphaTexture);
  122077. _this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  122078. }
  122079. }
  122080. // Bones
  122081. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  122082. _this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  122083. }
  122084. // Velocity
  122085. _this._effect.setMatrix("previousWorldViewProjection", _this._previousTransformationMatrices[mesh.uniqueId]);
  122086. // Draw
  122087. mesh._processRendering(subMesh, _this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { return _this._effect.setMatrix("world", world); });
  122088. }
  122089. // Velocity
  122090. _this._previousTransformationMatrices[mesh.uniqueId] = mesh.getWorldMatrix().multiply(_this._scene.getTransformMatrix());
  122091. };
  122092. this._multiRenderTarget.customRenderFunction = function (opaqueSubMeshes, alphaTestSubMeshes, transparentSubMeshes, depthOnlySubMeshes) {
  122093. var index;
  122094. if (depthOnlySubMeshes.length) {
  122095. engine.setColorWrite(false);
  122096. for (index = 0; index < depthOnlySubMeshes.length; index++) {
  122097. renderSubMesh(depthOnlySubMeshes.data[index]);
  122098. }
  122099. engine.setColorWrite(true);
  122100. }
  122101. for (index = 0; index < opaqueSubMeshes.length; index++) {
  122102. renderSubMesh(opaqueSubMeshes.data[index]);
  122103. }
  122104. for (index = 0; index < alphaTestSubMeshes.length; index++) {
  122105. renderSubMesh(alphaTestSubMeshes.data[index]);
  122106. }
  122107. };
  122108. };
  122109. /**
  122110. * Constant used to retrieve the position texture index in the G-Buffer textures array
  122111. * using getIndex(GeometryBufferRenderer.POSITION_TEXTURE_INDEX)
  122112. */
  122113. GeometryBufferRenderer.POSITION_TEXTURE_TYPE = 1;
  122114. /**
  122115. * Constant used to retrieve the velocity texture index in the G-Buffer textures array
  122116. * using getIndex(GeometryBufferRenderer.VELOCITY_TEXTURE_INDEX)
  122117. */
  122118. GeometryBufferRenderer.VELOCITY_TEXTURE_TYPE = 2;
  122119. /** @hidden */
  122120. GeometryBufferRenderer._SceneComponentInitialization = function (_) {
  122121. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_8__["_DevTools"].WarnImport("GeometryBufferRendererSceneComponent");
  122122. };
  122123. return GeometryBufferRenderer;
  122124. }());
  122125. /***/ }),
  122126. /***/ "./Rendering/geometryBufferRendererSceneComponent.ts":
  122127. /*!***********************************************************!*\
  122128. !*** ./Rendering/geometryBufferRendererSceneComponent.ts ***!
  122129. \***********************************************************/
  122130. /*! exports provided: GeometryBufferRendererSceneComponent */
  122131. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122132. "use strict";
  122133. __webpack_require__.r(__webpack_exports__);
  122134. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return GeometryBufferRendererSceneComponent; });
  122135. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122136. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  122137. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  122138. Object.defineProperty(_scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype, "geometryBufferRenderer", {
  122139. get: function () {
  122140. this._geometryBufferRenderer;
  122141. },
  122142. set: function (value) {
  122143. if (value && value.isSupported) {
  122144. this._geometryBufferRenderer = value;
  122145. }
  122146. },
  122147. enumerable: true,
  122148. configurable: true
  122149. });
  122150. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.enableGeometryBufferRenderer = function (ratio) {
  122151. if (ratio === void 0) { ratio = 1; }
  122152. if (this._geometryBufferRenderer) {
  122153. return this._geometryBufferRenderer;
  122154. }
  122155. this._geometryBufferRenderer = new _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"](this, ratio);
  122156. if (!this._geometryBufferRenderer.isSupported) {
  122157. this._geometryBufferRenderer = null;
  122158. }
  122159. return this._geometryBufferRenderer;
  122160. };
  122161. _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].prototype.disableGeometryBufferRenderer = function () {
  122162. if (!this._geometryBufferRenderer) {
  122163. return;
  122164. }
  122165. this._geometryBufferRenderer.dispose();
  122166. this._geometryBufferRenderer = null;
  122167. };
  122168. /**
  122169. * Defines the Geometry Buffer scene component responsible to manage a G-Buffer useful
  122170. * in several rendering techniques.
  122171. */
  122172. var GeometryBufferRendererSceneComponent = /** @class */ (function () {
  122173. /**
  122174. * Creates a new instance of the component for the given scene
  122175. * @param scene Defines the scene to register the component in
  122176. */
  122177. function GeometryBufferRendererSceneComponent(scene) {
  122178. /**
  122179. * The component name helpful to identify the component in the list of scene components.
  122180. */
  122181. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER;
  122182. this.scene = scene;
  122183. }
  122184. /**
  122185. * Registers the component in a given scene
  122186. */
  122187. GeometryBufferRendererSceneComponent.prototype.register = function () {
  122188. this.scene._gatherRenderTargetsStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER, this, this._gatherRenderTargets);
  122189. };
  122190. /**
  122191. * Rebuilds the elements related to this component in case of
  122192. * context lost for instance.
  122193. */
  122194. GeometryBufferRendererSceneComponent.prototype.rebuild = function () {
  122195. // Nothing to do for this component
  122196. };
  122197. /**
  122198. * Disposes the component and the associated ressources
  122199. */
  122200. GeometryBufferRendererSceneComponent.prototype.dispose = function () {
  122201. // Nothing to do for this component
  122202. };
  122203. GeometryBufferRendererSceneComponent.prototype._gatherRenderTargets = function (renderTargets) {
  122204. if (this.scene._geometryBufferRenderer) {
  122205. renderTargets.push(this.scene._geometryBufferRenderer.getGBuffer());
  122206. }
  122207. };
  122208. return GeometryBufferRendererSceneComponent;
  122209. }());
  122210. _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_2__["GeometryBufferRenderer"]._SceneComponentInitialization = function (scene) {
  122211. // Register the G Buffer component to the scene.
  122212. var component = scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_1__["SceneComponentConstants"].NAME_GEOMETRYBUFFERRENDERER);
  122213. if (!component) {
  122214. component = new GeometryBufferRendererSceneComponent(scene);
  122215. scene._addComponent(component);
  122216. }
  122217. };
  122218. /***/ }),
  122219. /***/ "./Rendering/index.ts":
  122220. /*!****************************!*\
  122221. !*** ./Rendering/index.ts ***!
  122222. \****************************/
  122223. /*! exports provided: BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer */
  122224. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122225. "use strict";
  122226. __webpack_require__.r(__webpack_exports__);
  122227. /* harmony import */ var _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./boundingBoxRenderer */ "./Rendering/boundingBoxRenderer.ts");
  122228. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _boundingBoxRenderer__WEBPACK_IMPORTED_MODULE_0__["BoundingBoxRenderer"]; });
  122229. /* harmony import */ var _depthRenderer__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthRenderer */ "./Rendering/depthRenderer.ts");
  122230. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _depthRenderer__WEBPACK_IMPORTED_MODULE_1__["DepthRenderer"]; });
  122231. /* harmony import */ var _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./depthRendererSceneComponent */ "./Rendering/depthRendererSceneComponent.ts");
  122232. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _depthRendererSceneComponent__WEBPACK_IMPORTED_MODULE_2__["DepthRendererSceneComponent"]; });
  122233. /* harmony import */ var _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./edgesRenderer */ "./Rendering/edgesRenderer.ts");
  122234. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["EdgesRenderer"]; });
  122235. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _edgesRenderer__WEBPACK_IMPORTED_MODULE_3__["LineEdgesRenderer"]; });
  122236. /* harmony import */ var _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./geometryBufferRenderer */ "./Rendering/geometryBufferRenderer.ts");
  122237. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _geometryBufferRenderer__WEBPACK_IMPORTED_MODULE_4__["GeometryBufferRenderer"]; });
  122238. /* harmony import */ var _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./geometryBufferRendererSceneComponent */ "./Rendering/geometryBufferRendererSceneComponent.ts");
  122239. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _geometryBufferRendererSceneComponent__WEBPACK_IMPORTED_MODULE_5__["GeometryBufferRendererSceneComponent"]; });
  122240. /* harmony import */ var _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./outlineRenderer */ "./Rendering/outlineRenderer.ts");
  122241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _outlineRenderer__WEBPACK_IMPORTED_MODULE_6__["OutlineRenderer"]; });
  122242. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  122243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _renderingGroup__WEBPACK_IMPORTED_MODULE_7__["RenderingGroup"]; });
  122244. /* harmony import */ var _renderingManager__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./renderingManager */ "./Rendering/renderingManager.ts");
  122245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingGroupInfo"]; });
  122246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _renderingManager__WEBPACK_IMPORTED_MODULE_8__["RenderingManager"]; });
  122247. /* harmony import */ var _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./utilityLayerRenderer */ "./Rendering/utilityLayerRenderer.ts");
  122248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _utilityLayerRenderer__WEBPACK_IMPORTED_MODULE_9__["UtilityLayerRenderer"]; });
  122249. /***/ }),
  122250. /***/ "./Rendering/outlineRenderer.ts":
  122251. /*!**************************************!*\
  122252. !*** ./Rendering/outlineRenderer.ts ***!
  122253. \**************************************/
  122254. /*! exports provided: OutlineRenderer */
  122255. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122256. "use strict";
  122257. __webpack_require__.r(__webpack_exports__);
  122258. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return OutlineRenderer; });
  122259. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  122260. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  122261. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  122262. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122263. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  122264. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  122265. /* harmony import */ var _Shaders_outline_fragment__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Shaders/outline.fragment */ "./Shaders/outline.fragment.ts");
  122266. /* harmony import */ var _Shaders_outline_vertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Shaders/outline.vertex */ "./Shaders/outline.vertex.ts");
  122267. /**
  122268. * Gets the outline renderer associated with the scene
  122269. * @returns a OutlineRenderer
  122270. */
  122271. _scene__WEBPACK_IMPORTED_MODULE_2__["Scene"].prototype.getOutlineRenderer = function () {
  122272. if (!this._outlineRenderer) {
  122273. this._outlineRenderer = new OutlineRenderer(this);
  122274. }
  122275. return this._outlineRenderer;
  122276. };
  122277. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOutline", {
  122278. get: function () {
  122279. return this._renderOutline;
  122280. },
  122281. set: function (value) {
  122282. if (value) {
  122283. // Lazy Load the component.
  122284. this.getScene().getOutlineRenderer();
  122285. }
  122286. this._renderOutline = value;
  122287. },
  122288. enumerable: true,
  122289. configurable: true
  122290. });
  122291. Object.defineProperty(_Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_1__["AbstractMesh"].prototype, "renderOverlay", {
  122292. get: function () {
  122293. return this._renderOverlay;
  122294. },
  122295. set: function (value) {
  122296. if (value) {
  122297. // Lazy Load the component.
  122298. this.getScene().getOutlineRenderer();
  122299. }
  122300. this._renderOverlay = value;
  122301. },
  122302. enumerable: true,
  122303. configurable: true
  122304. });
  122305. /**
  122306. * This class is responsible to draw bothe outline/overlay of meshes.
  122307. * It should not be used directly but through the available method on mesh.
  122308. */
  122309. var OutlineRenderer = /** @class */ (function () {
  122310. /**
  122311. * Instantiates a new outline renderer. (There could be only one per scene).
  122312. * @param scene Defines the scene it belongs to
  122313. */
  122314. function OutlineRenderer(scene) {
  122315. /**
  122316. * The name of the component. Each component must have a unique name.
  122317. */
  122318. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_OUTLINERENDERER;
  122319. /**
  122320. * Defines a zOffset to prevent zFighting between the overlay and the mesh.
  122321. */
  122322. this.zOffset = 1;
  122323. this.scene = scene;
  122324. this._engine = scene.getEngine();
  122325. this.scene._addComponent(this);
  122326. }
  122327. /**
  122328. * Register the component to one instance of a scene.
  122329. */
  122330. OutlineRenderer.prototype.register = function () {
  122331. this.scene._beforeRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_BEFORERENDERINGMESH_OUTLINE, this, this._beforeRenderingMesh);
  122332. this.scene._afterRenderingMeshStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_AFTERRENDERINGMESH_OUTLINE, this, this._afterRenderingMesh);
  122333. };
  122334. /**
  122335. * Rebuilds the elements related to this component in case of
  122336. * context lost for instance.
  122337. */
  122338. OutlineRenderer.prototype.rebuild = function () {
  122339. // Nothing to do here.
  122340. };
  122341. /**
  122342. * Disposes the component and the associated ressources.
  122343. */
  122344. OutlineRenderer.prototype.dispose = function () {
  122345. // Nothing to do here.
  122346. };
  122347. /**
  122348. * Renders the outline in the canvas.
  122349. * @param subMesh Defines the sumesh to render
  122350. * @param batch Defines the batch of meshes in case of instances
  122351. * @param useOverlay Defines if the rendering is for the overlay or the outline
  122352. */
  122353. OutlineRenderer.prototype.render = function (subMesh, batch, useOverlay) {
  122354. var _this = this;
  122355. if (useOverlay === void 0) { useOverlay = false; }
  122356. var scene = this.scene;
  122357. var engine = scene.getEngine();
  122358. var hardwareInstancedRendering = (engine.getCaps().instancedArrays) && (batch.visibleInstances[subMesh._id] !== null) && (batch.visibleInstances[subMesh._id] !== undefined);
  122359. if (!this.isReady(subMesh, hardwareInstancedRendering)) {
  122360. return;
  122361. }
  122362. var mesh = subMesh.getRenderingMesh();
  122363. var material = subMesh.getMaterial();
  122364. if (!material || !scene.activeCamera) {
  122365. return;
  122366. }
  122367. engine.enableEffect(this._effect);
  122368. // Logarithmic depth
  122369. if (material.useLogarithmicDepth) {
  122370. this._effect.setFloat("logarithmicDepthConstant", 2.0 / (Math.log(scene.activeCamera.maxZ + 1.0) / Math.LN2));
  122371. }
  122372. this._effect.setFloat("offset", useOverlay ? 0 : mesh.outlineWidth);
  122373. this._effect.setColor4("color", useOverlay ? mesh.overlayColor : mesh.outlineColor, useOverlay ? mesh.overlayAlpha : material.alpha);
  122374. this._effect.setMatrix("viewProjection", scene.getTransformMatrix());
  122375. // Bones
  122376. if (mesh.useBones && mesh.computeBonesUsingShaders && mesh.skeleton) {
  122377. this._effect.setMatrices("mBones", mesh.skeleton.getTransformMatrices(mesh));
  122378. }
  122379. mesh._bind(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode);
  122380. // Alpha test
  122381. if (material && material.needAlphaTesting()) {
  122382. var alphaTexture = material.getAlphaTestTexture();
  122383. if (alphaTexture) {
  122384. this._effect.setTexture("diffuseSampler", alphaTexture);
  122385. this._effect.setMatrix("diffuseMatrix", alphaTexture.getTextureMatrix());
  122386. }
  122387. }
  122388. engine.setZOffset(-this.zOffset);
  122389. mesh._processRendering(subMesh, this._effect, _Materials_material__WEBPACK_IMPORTED_MODULE_5__["Material"].TriangleFillMode, batch, hardwareInstancedRendering, function (isInstance, world) { _this._effect.setMatrix("world", world); });
  122390. engine.setZOffset(0);
  122391. };
  122392. /**
  122393. * Returns whether or not the outline renderer is ready for a given submesh.
  122394. * All the dependencies e.g. submeshes, texture, effect... mus be ready
  122395. * @param subMesh Defines the submesh to check readyness for
  122396. * @param useInstances Defines wheter wee are trying to render instances or not
  122397. * @returns true if ready otherwise false
  122398. */
  122399. OutlineRenderer.prototype.isReady = function (subMesh, useInstances) {
  122400. var defines = [];
  122401. var attribs = [_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].PositionKind, _Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].NormalKind];
  122402. var mesh = subMesh.getMesh();
  122403. var material = subMesh.getMaterial();
  122404. if (material) {
  122405. // Alpha test
  122406. if (material.needAlphaTesting()) {
  122407. defines.push("#define ALPHATEST");
  122408. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind)) {
  122409. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UVKind);
  122410. defines.push("#define UV1");
  122411. }
  122412. if (mesh.isVerticesDataPresent(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind)) {
  122413. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].UV2Kind);
  122414. defines.push("#define UV2");
  122415. }
  122416. }
  122417. //Logarithmic depth
  122418. if (material.useLogarithmicDepth) {
  122419. defines.push("#define LOGARITHMICDEPTH");
  122420. }
  122421. }
  122422. // Bones
  122423. if (mesh.useBones && mesh.computeBonesUsingShaders) {
  122424. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesKind);
  122425. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsKind);
  122426. if (mesh.numBoneInfluencers > 4) {
  122427. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesIndicesExtraKind);
  122428. attribs.push(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_0__["VertexBuffer"].MatricesWeightsExtraKind);
  122429. }
  122430. defines.push("#define NUM_BONE_INFLUENCERS " + mesh.numBoneInfluencers);
  122431. defines.push("#define BonesPerMesh " + (mesh.skeleton ? mesh.skeleton.bones.length + 1 : 0));
  122432. }
  122433. else {
  122434. defines.push("#define NUM_BONE_INFLUENCERS 0");
  122435. }
  122436. // Instances
  122437. if (useInstances) {
  122438. defines.push("#define INSTANCES");
  122439. attribs.push("world0");
  122440. attribs.push("world1");
  122441. attribs.push("world2");
  122442. attribs.push("world3");
  122443. }
  122444. // Get correct effect
  122445. var join = defines.join("\n");
  122446. if (this._cachedDefines !== join) {
  122447. this._cachedDefines = join;
  122448. this._effect = this.scene.getEngine().createEffect("outline", attribs, ["world", "mBones", "viewProjection", "diffuseMatrix", "offset", "color", "logarithmicDepthConstant"], ["diffuseSampler"], join);
  122449. }
  122450. return this._effect.isReady();
  122451. };
  122452. OutlineRenderer.prototype._beforeRenderingMesh = function (mesh, subMesh, batch) {
  122453. // Outline - step 1
  122454. this._savedDepthWrite = this._engine.getDepthWrite();
  122455. if (mesh.renderOutline) {
  122456. this._engine.setDepthWrite(false);
  122457. this.render(subMesh, batch);
  122458. this._engine.setDepthWrite(this._savedDepthWrite);
  122459. }
  122460. };
  122461. OutlineRenderer.prototype._afterRenderingMesh = function (mesh, subMesh, batch) {
  122462. // Outline - step 2
  122463. if (mesh.renderOutline && this._savedDepthWrite) {
  122464. this._engine.setDepthWrite(true);
  122465. this._engine.setColorWrite(false);
  122466. this.render(subMesh, batch);
  122467. this._engine.setColorWrite(true);
  122468. }
  122469. // Overlay
  122470. if (mesh.renderOverlay) {
  122471. var currentMode = this._engine.getAlphaMode();
  122472. this._engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_3__["Constants"].ALPHA_COMBINE);
  122473. this.render(subMesh, batch, true);
  122474. this._engine.setAlphaMode(currentMode);
  122475. }
  122476. };
  122477. return OutlineRenderer;
  122478. }());
  122479. /***/ }),
  122480. /***/ "./Rendering/renderingGroup.ts":
  122481. /*!*************************************!*\
  122482. !*** ./Rendering/renderingGroup.ts ***!
  122483. \*************************************/
  122484. /*! exports provided: RenderingGroup */
  122485. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122486. "use strict";
  122487. __webpack_require__.r(__webpack_exports__);
  122488. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return RenderingGroup; });
  122489. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/smartArray */ "./Misc/smartArray.ts");
  122490. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  122491. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  122492. /**
  122493. * This represents the object necessary to create a rendering group.
  122494. * This is exclusively used and created by the rendering manager.
  122495. * To modify the behavior, you use the available helpers in your scene or meshes.
  122496. * @hidden
  122497. */
  122498. var RenderingGroup = /** @class */ (function () {
  122499. /**
  122500. * Creates a new rendering group.
  122501. * @param index The rendering group index
  122502. * @param opaqueSortCompareFn The opaque sort comparison function. If null no order is applied
  122503. * @param alphaTestSortCompareFn The alpha test sort comparison function. If null no order is applied
  122504. * @param transparentSortCompareFn The transparent sort comparison function. If null back to front + alpha index sort is applied
  122505. */
  122506. function RenderingGroup(index, scene, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  122507. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  122508. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  122509. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  122510. this.index = index;
  122511. this._opaqueSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122512. this._transparentSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122513. this._alphaTestSubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122514. this._depthOnlySubMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122515. this._particleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122516. this._spriteManagers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](256);
  122517. this._edgesRenderers = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_0__["SmartArray"](16);
  122518. this._scene = scene;
  122519. this.opaqueSortCompareFn = opaqueSortCompareFn;
  122520. this.alphaTestSortCompareFn = alphaTestSortCompareFn;
  122521. this.transparentSortCompareFn = transparentSortCompareFn;
  122522. }
  122523. Object.defineProperty(RenderingGroup.prototype, "opaqueSortCompareFn", {
  122524. /**
  122525. * Set the opaque sort comparison function.
  122526. * If null the sub meshes will be render in the order they were created
  122527. */
  122528. set: function (value) {
  122529. this._opaqueSortCompareFn = value;
  122530. if (value) {
  122531. this._renderOpaque = this.renderOpaqueSorted;
  122532. }
  122533. else {
  122534. this._renderOpaque = RenderingGroup.renderUnsorted;
  122535. }
  122536. },
  122537. enumerable: true,
  122538. configurable: true
  122539. });
  122540. Object.defineProperty(RenderingGroup.prototype, "alphaTestSortCompareFn", {
  122541. /**
  122542. * Set the alpha test sort comparison function.
  122543. * If null the sub meshes will be render in the order they were created
  122544. */
  122545. set: function (value) {
  122546. this._alphaTestSortCompareFn = value;
  122547. if (value) {
  122548. this._renderAlphaTest = this.renderAlphaTestSorted;
  122549. }
  122550. else {
  122551. this._renderAlphaTest = RenderingGroup.renderUnsorted;
  122552. }
  122553. },
  122554. enumerable: true,
  122555. configurable: true
  122556. });
  122557. Object.defineProperty(RenderingGroup.prototype, "transparentSortCompareFn", {
  122558. /**
  122559. * Set the transparent sort comparison function.
  122560. * If null the sub meshes will be render in the order they were created
  122561. */
  122562. set: function (value) {
  122563. if (value) {
  122564. this._transparentSortCompareFn = value;
  122565. }
  122566. else {
  122567. this._transparentSortCompareFn = RenderingGroup.defaultTransparentSortCompare;
  122568. }
  122569. this._renderTransparent = this.renderTransparentSorted;
  122570. },
  122571. enumerable: true,
  122572. configurable: true
  122573. });
  122574. /**
  122575. * Render all the sub meshes contained in the group.
  122576. * @param customRenderFunction Used to override the default render behaviour of the group.
  122577. * @returns true if rendered some submeshes.
  122578. */
  122579. RenderingGroup.prototype.render = function (customRenderFunction, renderSprites, renderParticles, activeMeshes) {
  122580. if (customRenderFunction) {
  122581. customRenderFunction(this._opaqueSubMeshes, this._alphaTestSubMeshes, this._transparentSubMeshes, this._depthOnlySubMeshes);
  122582. return;
  122583. }
  122584. var engine = this._scene.getEngine();
  122585. // Depth only
  122586. if (this._depthOnlySubMeshes.length !== 0) {
  122587. engine.setColorWrite(false);
  122588. this._renderAlphaTest(this._depthOnlySubMeshes);
  122589. engine.setColorWrite(true);
  122590. }
  122591. // Opaque
  122592. if (this._opaqueSubMeshes.length !== 0) {
  122593. this._renderOpaque(this._opaqueSubMeshes);
  122594. }
  122595. // Alpha test
  122596. if (this._alphaTestSubMeshes.length !== 0) {
  122597. this._renderAlphaTest(this._alphaTestSubMeshes);
  122598. }
  122599. var stencilState = engine.getStencilBuffer();
  122600. engine.setStencilBuffer(false);
  122601. // Sprites
  122602. if (renderSprites) {
  122603. this._renderSprites();
  122604. }
  122605. // Particles
  122606. if (renderParticles) {
  122607. this._renderParticles(activeMeshes);
  122608. }
  122609. if (this.onBeforeTransparentRendering) {
  122610. this.onBeforeTransparentRendering();
  122611. }
  122612. // Transparent
  122613. if (this._transparentSubMeshes.length !== 0) {
  122614. this._renderTransparent(this._transparentSubMeshes);
  122615. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  122616. }
  122617. // Set back stencil to false in case it changes before the edge renderer.
  122618. engine.setStencilBuffer(false);
  122619. // Edges
  122620. if (this._edgesRenderers.length) {
  122621. for (var edgesRendererIndex = 0; edgesRendererIndex < this._edgesRenderers.length; edgesRendererIndex++) {
  122622. this._edgesRenderers.data[edgesRendererIndex].render();
  122623. }
  122624. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  122625. }
  122626. // Restore Stencil state.
  122627. engine.setStencilBuffer(stencilState);
  122628. };
  122629. /**
  122630. * Renders the opaque submeshes in the order from the opaqueSortCompareFn.
  122631. * @param subMeshes The submeshes to render
  122632. */
  122633. RenderingGroup.prototype.renderOpaqueSorted = function (subMeshes) {
  122634. return RenderingGroup.renderSorted(subMeshes, this._opaqueSortCompareFn, this._scene.activeCamera, false);
  122635. };
  122636. /**
  122637. * Renders the opaque submeshes in the order from the alphatestSortCompareFn.
  122638. * @param subMeshes The submeshes to render
  122639. */
  122640. RenderingGroup.prototype.renderAlphaTestSorted = function (subMeshes) {
  122641. return RenderingGroup.renderSorted(subMeshes, this._alphaTestSortCompareFn, this._scene.activeCamera, false);
  122642. };
  122643. /**
  122644. * Renders the opaque submeshes in the order from the transparentSortCompareFn.
  122645. * @param subMeshes The submeshes to render
  122646. */
  122647. RenderingGroup.prototype.renderTransparentSorted = function (subMeshes) {
  122648. return RenderingGroup.renderSorted(subMeshes, this._transparentSortCompareFn, this._scene.activeCamera, true);
  122649. };
  122650. /**
  122651. * Renders the submeshes in a specified order.
  122652. * @param subMeshes The submeshes to sort before render
  122653. * @param sortCompareFn The comparison function use to sort
  122654. * @param cameraPosition The camera position use to preprocess the submeshes to help sorting
  122655. * @param transparent Specifies to activate blending if true
  122656. */
  122657. RenderingGroup.renderSorted = function (subMeshes, sortCompareFn, camera, transparent) {
  122658. var subIndex = 0;
  122659. var subMesh;
  122660. var cameraPosition = camera ? camera.globalPosition : _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Vector3"].Zero();
  122661. for (; subIndex < subMeshes.length; subIndex++) {
  122662. subMesh = subMeshes.data[subIndex];
  122663. subMesh._alphaIndex = subMesh.getMesh().alphaIndex;
  122664. subMesh._distanceToCamera = subMesh.getBoundingInfo().boundingSphere.centerWorld.subtract(cameraPosition).length();
  122665. }
  122666. var sortedArray = subMeshes.data.slice(0, subMeshes.length);
  122667. if (sortCompareFn) {
  122668. sortedArray.sort(sortCompareFn);
  122669. }
  122670. for (subIndex = 0; subIndex < sortedArray.length; subIndex++) {
  122671. subMesh = sortedArray[subIndex];
  122672. if (transparent) {
  122673. var material = subMesh.getMaterial();
  122674. if (material && material.needDepthPrePass) {
  122675. var engine = material.getScene().getEngine();
  122676. engine.setColorWrite(false);
  122677. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_2__["Constants"].ALPHA_DISABLE);
  122678. subMesh.render(false);
  122679. engine.setColorWrite(true);
  122680. }
  122681. }
  122682. subMesh.render(transparent);
  122683. }
  122684. };
  122685. /**
  122686. * Renders the submeshes in the order they were dispatched (no sort applied).
  122687. * @param subMeshes The submeshes to render
  122688. */
  122689. RenderingGroup.renderUnsorted = function (subMeshes) {
  122690. for (var subIndex = 0; subIndex < subMeshes.length; subIndex++) {
  122691. var submesh = subMeshes.data[subIndex];
  122692. submesh.render(false);
  122693. }
  122694. };
  122695. /**
  122696. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122697. * are rendered back to front if in the same alpha index.
  122698. *
  122699. * @param a The first submesh
  122700. * @param b The second submesh
  122701. * @returns The result of the comparison
  122702. */
  122703. RenderingGroup.defaultTransparentSortCompare = function (a, b) {
  122704. // Alpha index first
  122705. if (a._alphaIndex > b._alphaIndex) {
  122706. return 1;
  122707. }
  122708. if (a._alphaIndex < b._alphaIndex) {
  122709. return -1;
  122710. }
  122711. // Then distance to camera
  122712. return RenderingGroup.backToFrontSortCompare(a, b);
  122713. };
  122714. /**
  122715. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122716. * are rendered back to front.
  122717. *
  122718. * @param a The first submesh
  122719. * @param b The second submesh
  122720. * @returns The result of the comparison
  122721. */
  122722. RenderingGroup.backToFrontSortCompare = function (a, b) {
  122723. // Then distance to camera
  122724. if (a._distanceToCamera < b._distanceToCamera) {
  122725. return 1;
  122726. }
  122727. if (a._distanceToCamera > b._distanceToCamera) {
  122728. return -1;
  122729. }
  122730. return 0;
  122731. };
  122732. /**
  122733. * Build in function which can be applied to ensure meshes of a special queue (opaque, alpha test, transparent)
  122734. * are rendered front to back (prevent overdraw).
  122735. *
  122736. * @param a The first submesh
  122737. * @param b The second submesh
  122738. * @returns The result of the comparison
  122739. */
  122740. RenderingGroup.frontToBackSortCompare = function (a, b) {
  122741. // Then distance to camera
  122742. if (a._distanceToCamera < b._distanceToCamera) {
  122743. return -1;
  122744. }
  122745. if (a._distanceToCamera > b._distanceToCamera) {
  122746. return 1;
  122747. }
  122748. return 0;
  122749. };
  122750. /**
  122751. * Resets the different lists of submeshes to prepare a new frame.
  122752. */
  122753. RenderingGroup.prototype.prepare = function () {
  122754. this._opaqueSubMeshes.reset();
  122755. this._transparentSubMeshes.reset();
  122756. this._alphaTestSubMeshes.reset();
  122757. this._depthOnlySubMeshes.reset();
  122758. this._particleSystems.reset();
  122759. this._spriteManagers.reset();
  122760. this._edgesRenderers.reset();
  122761. };
  122762. RenderingGroup.prototype.dispose = function () {
  122763. this._opaqueSubMeshes.dispose();
  122764. this._transparentSubMeshes.dispose();
  122765. this._alphaTestSubMeshes.dispose();
  122766. this._depthOnlySubMeshes.dispose();
  122767. this._particleSystems.dispose();
  122768. this._spriteManagers.dispose();
  122769. this._edgesRenderers.dispose();
  122770. };
  122771. /**
  122772. * Inserts the submesh in its correct queue depending on its material.
  122773. * @param subMesh The submesh to dispatch
  122774. * @param [mesh] Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  122775. * @param [material] Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  122776. */
  122777. RenderingGroup.prototype.dispatch = function (subMesh, mesh, material) {
  122778. // Get mesh and materials if not provided
  122779. if (mesh === undefined) {
  122780. mesh = subMesh.getMesh();
  122781. }
  122782. if (material === undefined) {
  122783. material = subMesh.getMaterial();
  122784. }
  122785. if (material === null || material === undefined) {
  122786. return;
  122787. }
  122788. if (material.needAlphaBlendingForMesh(mesh)) { // Transparent
  122789. this._transparentSubMeshes.push(subMesh);
  122790. }
  122791. else if (material.needAlphaTesting()) { // Alpha test
  122792. if (material.needDepthPrePass) {
  122793. this._depthOnlySubMeshes.push(subMesh);
  122794. }
  122795. this._alphaTestSubMeshes.push(subMesh);
  122796. }
  122797. else {
  122798. if (material.needDepthPrePass) {
  122799. this._depthOnlySubMeshes.push(subMesh);
  122800. }
  122801. this._opaqueSubMeshes.push(subMesh); // Opaque
  122802. }
  122803. if (mesh._edgesRenderer && mesh._edgesRenderer.isEnabled) {
  122804. this._edgesRenderers.push(mesh._edgesRenderer);
  122805. }
  122806. };
  122807. RenderingGroup.prototype.dispatchSprites = function (spriteManager) {
  122808. this._spriteManagers.push(spriteManager);
  122809. };
  122810. RenderingGroup.prototype.dispatchParticles = function (particleSystem) {
  122811. this._particleSystems.push(particleSystem);
  122812. };
  122813. RenderingGroup.prototype._renderParticles = function (activeMeshes) {
  122814. if (this._particleSystems.length === 0) {
  122815. return;
  122816. }
  122817. // Particles
  122818. var activeCamera = this._scene.activeCamera;
  122819. this._scene.onBeforeParticlesRenderingObservable.notifyObservers(this._scene);
  122820. for (var particleIndex = 0; particleIndex < this._particleSystems.length; particleIndex++) {
  122821. var particleSystem = this._particleSystems.data[particleIndex];
  122822. if ((activeCamera && activeCamera.layerMask & particleSystem.layerMask) === 0) {
  122823. continue;
  122824. }
  122825. var emitter = particleSystem.emitter;
  122826. if (!emitter.position || !activeMeshes || activeMeshes.indexOf(emitter) !== -1) {
  122827. this._scene._activeParticles.addCount(particleSystem.render(), false);
  122828. }
  122829. }
  122830. this._scene.onAfterParticlesRenderingObservable.notifyObservers(this._scene);
  122831. };
  122832. RenderingGroup.prototype._renderSprites = function () {
  122833. if (!this._scene.spritesEnabled || this._spriteManagers.length === 0) {
  122834. return;
  122835. }
  122836. // Sprites
  122837. var activeCamera = this._scene.activeCamera;
  122838. this._scene.onBeforeSpritesRenderingObservable.notifyObservers(this._scene);
  122839. for (var id = 0; id < this._spriteManagers.length; id++) {
  122840. var spriteManager = this._spriteManagers.data[id];
  122841. if (((activeCamera && activeCamera.layerMask & spriteManager.layerMask) !== 0)) {
  122842. spriteManager.render();
  122843. }
  122844. }
  122845. this._scene.onAfterSpritesRenderingObservable.notifyObservers(this._scene);
  122846. };
  122847. return RenderingGroup;
  122848. }());
  122849. /***/ }),
  122850. /***/ "./Rendering/renderingManager.ts":
  122851. /*!***************************************!*\
  122852. !*** ./Rendering/renderingManager.ts ***!
  122853. \***************************************/
  122854. /*! exports provided: RenderingGroupInfo, RenderingManager */
  122855. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  122856. "use strict";
  122857. __webpack_require__.r(__webpack_exports__);
  122858. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return RenderingGroupInfo; });
  122859. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return RenderingManager; });
  122860. /* harmony import */ var _renderingGroup__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./renderingGroup */ "./Rendering/renderingGroup.ts");
  122861. /**
  122862. * This class is used by the onRenderingGroupObservable
  122863. */
  122864. var RenderingGroupInfo = /** @class */ (function () {
  122865. function RenderingGroupInfo() {
  122866. }
  122867. return RenderingGroupInfo;
  122868. }());
  122869. /**
  122870. * This is the manager responsible of all the rendering for meshes sprites and particles.
  122871. * It is enable to manage the different groups as well as the different necessary sort functions.
  122872. * This should not be used directly aside of the few static configurations
  122873. */
  122874. var RenderingManager = /** @class */ (function () {
  122875. /**
  122876. * Instantiates a new rendering group for a particular scene
  122877. * @param scene Defines the scene the groups belongs to
  122878. */
  122879. function RenderingManager(scene) {
  122880. /**
  122881. * @hidden
  122882. */
  122883. this._useSceneAutoClearSetup = false;
  122884. this._renderingGroups = new Array();
  122885. this._autoClearDepthStencil = {};
  122886. this._customOpaqueSortCompareFn = {};
  122887. this._customAlphaTestSortCompareFn = {};
  122888. this._customTransparentSortCompareFn = {};
  122889. this._renderingGroupInfo = new RenderingGroupInfo();
  122890. this._scene = scene;
  122891. for (var i = RenderingManager.MIN_RENDERINGGROUPS; i < RenderingManager.MAX_RENDERINGGROUPS; i++) {
  122892. this._autoClearDepthStencil[i] = { autoClear: true, depth: true, stencil: true };
  122893. }
  122894. }
  122895. RenderingManager.prototype._clearDepthStencilBuffer = function (depth, stencil) {
  122896. if (depth === void 0) { depth = true; }
  122897. if (stencil === void 0) { stencil = true; }
  122898. if (this._depthStencilBufferAlreadyCleaned) {
  122899. return;
  122900. }
  122901. this._scene.getEngine().clear(null, false, depth, stencil);
  122902. this._depthStencilBufferAlreadyCleaned = true;
  122903. };
  122904. /**
  122905. * Renders the entire managed groups. This is used by the scene or the different rennder targets.
  122906. * @hidden
  122907. */
  122908. RenderingManager.prototype.render = function (customRenderFunction, activeMeshes, renderParticles, renderSprites) {
  122909. // Update the observable context (not null as it only goes away on dispose)
  122910. var info = this._renderingGroupInfo;
  122911. info.scene = this._scene;
  122912. info.camera = this._scene.activeCamera;
  122913. // Dispatch sprites
  122914. if (this._scene.spriteManagers && renderSprites) {
  122915. for (var index = 0; index < this._scene.spriteManagers.length; index++) {
  122916. var manager = this._scene.spriteManagers[index];
  122917. this.dispatchSprites(manager);
  122918. }
  122919. }
  122920. // Render
  122921. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122922. this._depthStencilBufferAlreadyCleaned = index === RenderingManager.MIN_RENDERINGGROUPS;
  122923. var renderingGroup = this._renderingGroups[index];
  122924. if (!renderingGroup) {
  122925. continue;
  122926. }
  122927. var renderingGroupMask = Math.pow(2, index);
  122928. info.renderingGroupId = index;
  122929. // Before Observable
  122930. this._scene.onBeforeRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122931. // Clear depth/stencil if needed
  122932. if (RenderingManager.AUTOCLEAR) {
  122933. var autoClear = this._useSceneAutoClearSetup ?
  122934. this._scene.getAutoClearDepthStencilSetup(index) :
  122935. this._autoClearDepthStencil[index];
  122936. if (autoClear && autoClear.autoClear) {
  122937. this._clearDepthStencilBuffer(autoClear.depth, autoClear.stencil);
  122938. }
  122939. }
  122940. // Render
  122941. for (var _i = 0, _a = this._scene._beforeRenderingGroupDrawStage; _i < _a.length; _i++) {
  122942. var step = _a[_i];
  122943. step.action(index);
  122944. }
  122945. renderingGroup.render(customRenderFunction, renderSprites, renderParticles, activeMeshes);
  122946. for (var _b = 0, _c = this._scene._afterRenderingGroupDrawStage; _b < _c.length; _b++) {
  122947. var step = _c[_b];
  122948. step.action(index);
  122949. }
  122950. // After Observable
  122951. this._scene.onAfterRenderingGroupObservable.notifyObservers(info, renderingGroupMask);
  122952. }
  122953. };
  122954. /**
  122955. * Resets the different information of the group to prepare a new frame
  122956. * @hidden
  122957. */
  122958. RenderingManager.prototype.reset = function () {
  122959. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122960. var renderingGroup = this._renderingGroups[index];
  122961. if (renderingGroup) {
  122962. renderingGroup.prepare();
  122963. }
  122964. }
  122965. };
  122966. /**
  122967. * Dispose and release the group and its associated resources.
  122968. * @hidden
  122969. */
  122970. RenderingManager.prototype.dispose = function () {
  122971. this.freeRenderingGroups();
  122972. this._renderingGroups.length = 0;
  122973. this._renderingGroupInfo = null;
  122974. };
  122975. /**
  122976. * Clear the info related to rendering groups preventing retention points during dispose.
  122977. */
  122978. RenderingManager.prototype.freeRenderingGroups = function () {
  122979. for (var index = RenderingManager.MIN_RENDERINGGROUPS; index < RenderingManager.MAX_RENDERINGGROUPS; index++) {
  122980. var renderingGroup = this._renderingGroups[index];
  122981. if (renderingGroup) {
  122982. renderingGroup.dispose();
  122983. }
  122984. }
  122985. };
  122986. RenderingManager.prototype._prepareRenderingGroup = function (renderingGroupId) {
  122987. if (this._renderingGroups[renderingGroupId] === undefined) {
  122988. this._renderingGroups[renderingGroupId] = new _renderingGroup__WEBPACK_IMPORTED_MODULE_0__["RenderingGroup"](renderingGroupId, this._scene, this._customOpaqueSortCompareFn[renderingGroupId], this._customAlphaTestSortCompareFn[renderingGroupId], this._customTransparentSortCompareFn[renderingGroupId]);
  122989. }
  122990. };
  122991. /**
  122992. * Add a sprite manager to the rendering manager in order to render it this frame.
  122993. * @param spriteManager Define the sprite manager to render
  122994. */
  122995. RenderingManager.prototype.dispatchSprites = function (spriteManager) {
  122996. var renderingGroupId = spriteManager.renderingGroupId || 0;
  122997. this._prepareRenderingGroup(renderingGroupId);
  122998. this._renderingGroups[renderingGroupId].dispatchSprites(spriteManager);
  122999. };
  123000. /**
  123001. * Add a particle system to the rendering manager in order to render it this frame.
  123002. * @param particleSystem Define the particle system to render
  123003. */
  123004. RenderingManager.prototype.dispatchParticles = function (particleSystem) {
  123005. var renderingGroupId = particleSystem.renderingGroupId || 0;
  123006. this._prepareRenderingGroup(renderingGroupId);
  123007. this._renderingGroups[renderingGroupId].dispatchParticles(particleSystem);
  123008. };
  123009. /**
  123010. * Add a submesh to the manager in order to render it this frame
  123011. * @param subMesh The submesh to dispatch
  123012. * @param mesh Optional reference to the submeshes's mesh. Provide if you have an exiting reference to improve performance.
  123013. * @param material Optional reference to the submeshes's material. Provide if you have an exiting reference to improve performance.
  123014. */
  123015. RenderingManager.prototype.dispatch = function (subMesh, mesh, material) {
  123016. if (mesh === undefined) {
  123017. mesh = subMesh.getMesh();
  123018. }
  123019. var renderingGroupId = mesh.renderingGroupId || 0;
  123020. this._prepareRenderingGroup(renderingGroupId);
  123021. this._renderingGroups[renderingGroupId].dispatch(subMesh, mesh, material);
  123022. };
  123023. /**
  123024. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  123025. * This allowed control for front to back rendering or reversly depending of the special needs.
  123026. *
  123027. * @param renderingGroupId The rendering group id corresponding to its index
  123028. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  123029. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  123030. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  123031. */
  123032. RenderingManager.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  123033. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  123034. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  123035. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  123036. this._customOpaqueSortCompareFn[renderingGroupId] = opaqueSortCompareFn;
  123037. this._customAlphaTestSortCompareFn[renderingGroupId] = alphaTestSortCompareFn;
  123038. this._customTransparentSortCompareFn[renderingGroupId] = transparentSortCompareFn;
  123039. if (this._renderingGroups[renderingGroupId]) {
  123040. var group = this._renderingGroups[renderingGroupId];
  123041. group.opaqueSortCompareFn = this._customOpaqueSortCompareFn[renderingGroupId];
  123042. group.alphaTestSortCompareFn = this._customAlphaTestSortCompareFn[renderingGroupId];
  123043. group.transparentSortCompareFn = this._customTransparentSortCompareFn[renderingGroupId];
  123044. }
  123045. };
  123046. /**
  123047. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  123048. *
  123049. * @param renderingGroupId The rendering group id corresponding to its index
  123050. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  123051. * @param depth Automatically clears depth between groups if true and autoClear is true.
  123052. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  123053. */
  123054. RenderingManager.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  123055. if (depth === void 0) { depth = true; }
  123056. if (stencil === void 0) { stencil = true; }
  123057. this._autoClearDepthStencil[renderingGroupId] = {
  123058. autoClear: autoClearDepthStencil,
  123059. depth: depth,
  123060. stencil: stencil
  123061. };
  123062. };
  123063. /**
  123064. * Gets the current auto clear configuration for one rendering group of the rendering
  123065. * manager.
  123066. * @param index the rendering group index to get the information for
  123067. * @returns The auto clear setup for the requested rendering group
  123068. */
  123069. RenderingManager.prototype.getAutoClearDepthStencilSetup = function (index) {
  123070. return this._autoClearDepthStencil[index];
  123071. };
  123072. /**
  123073. * The max id used for rendering groups (not included)
  123074. */
  123075. RenderingManager.MAX_RENDERINGGROUPS = 4;
  123076. /**
  123077. * The min id used for rendering groups (included)
  123078. */
  123079. RenderingManager.MIN_RENDERINGGROUPS = 0;
  123080. /**
  123081. * Used to globally prevent autoclearing scenes.
  123082. */
  123083. RenderingManager.AUTOCLEAR = true;
  123084. return RenderingManager;
  123085. }());
  123086. /***/ }),
  123087. /***/ "./Rendering/utilityLayerRenderer.ts":
  123088. /*!*******************************************!*\
  123089. !*** ./Rendering/utilityLayerRenderer.ts ***!
  123090. \*******************************************/
  123091. /*! exports provided: UtilityLayerRenderer */
  123092. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123093. "use strict";
  123094. __webpack_require__.r(__webpack_exports__);
  123095. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return UtilityLayerRenderer; });
  123096. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  123097. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  123098. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Events/pointerEvents */ "./Events/pointerEvents.ts");
  123099. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Engines/engineStore */ "./Engines/engineStore.ts");
  123100. /**
  123101. * Renders a layer on top of an existing scene
  123102. */
  123103. var UtilityLayerRenderer = /** @class */ (function () {
  123104. /**
  123105. * Instantiates a UtilityLayerRenderer
  123106. * @param originalScene the original scene that will be rendered on top of
  123107. * @param handleEvents boolean indicating if the utility layer should handle events
  123108. */
  123109. function UtilityLayerRenderer(
  123110. /** the original scene that will be rendered on top of */
  123111. originalScene, handleEvents) {
  123112. if (handleEvents === void 0) { handleEvents = true; }
  123113. var _this = this;
  123114. this.originalScene = originalScene;
  123115. this._pointerCaptures = {};
  123116. this._lastPointerEvents = {};
  123117. /**
  123118. * If the picking should be done on the utility layer prior to the actual scene (Default: true)
  123119. */
  123120. this.pickUtilitySceneFirst = true;
  123121. /**
  123122. * If the utility layer should automatically be rendered on top of existing scene
  123123. */
  123124. this.shouldRender = true;
  123125. /**
  123126. * If set to true, only pointer down onPointerObservable events will be blocked when picking is occluded by original scene
  123127. */
  123128. this.onlyCheckPointerDownEvents = true;
  123129. /**
  123130. * If set to false, only pointerUp, pointerDown and pointerMove will be sent to the utilityLayerScene (false by default)
  123131. */
  123132. this.processAllEvents = false;
  123133. /**
  123134. * Observable raised when the pointer move from the utility layer scene to the main scene
  123135. */
  123136. this.onPointerOutObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  123137. // Create scene which will be rendered in the foreground and remove it from being referenced by engine to avoid interfering with existing app
  123138. this.utilityLayerScene = new _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"](originalScene.getEngine());
  123139. this.utilityLayerScene.useRightHandedSystem = originalScene.useRightHandedSystem;
  123140. this.utilityLayerScene._allowPostProcessClearColor = false;
  123141. originalScene.getEngine().scenes.pop();
  123142. // Detach controls on utility scene, events will be fired by logic below to handle picking priority
  123143. this.utilityLayerScene.detachControl();
  123144. if (handleEvents) {
  123145. this._originalPointerObserver = originalScene.onPrePointerObservable.add(function (prePointerInfo, eventState) {
  123146. if (!_this.utilityLayerScene.activeCamera) {
  123147. return;
  123148. }
  123149. if (!_this.processAllEvents) {
  123150. if (prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERMOVE
  123151. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP
  123152. && prePointerInfo.type !== _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  123153. return;
  123154. }
  123155. }
  123156. _this.utilityLayerScene.pointerX = originalScene.pointerX;
  123157. _this.utilityLayerScene.pointerY = originalScene.pointerY;
  123158. var pointerEvent = (prePointerInfo.event);
  123159. if (originalScene.isPointerCaptured(pointerEvent.pointerId)) {
  123160. _this._pointerCaptures[pointerEvent.pointerId] = false;
  123161. return;
  123162. }
  123163. var utilityScenePick = prePointerInfo.ray ? _this.utilityLayerScene.pickWithRay(prePointerInfo.ray) : _this.utilityLayerScene.pick(originalScene.pointerX, originalScene.pointerY);
  123164. if (!prePointerInfo.ray && utilityScenePick) {
  123165. prePointerInfo.ray = utilityScenePick.ray;
  123166. }
  123167. // always fire the prepointer oversvable
  123168. _this.utilityLayerScene.onPrePointerObservable.notifyObservers(prePointerInfo);
  123169. // allow every non pointer down event to flow to the utility layer
  123170. if (_this.onlyCheckPointerDownEvents && prePointerInfo.type != _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  123171. if (!prePointerInfo.skipOnPointerObservable) {
  123172. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  123173. }
  123174. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent.pointerId]) {
  123175. _this._pointerCaptures[pointerEvent.pointerId] = false;
  123176. }
  123177. return;
  123178. }
  123179. if (_this.utilityLayerScene.autoClearDepthAndStencil || _this.pickUtilitySceneFirst) {
  123180. // If this layer is an overlay, check if this layer was hit and if so, skip pointer events for the main scene
  123181. if (utilityScenePick && utilityScenePick.hit) {
  123182. if (!prePointerInfo.skipOnPointerObservable) {
  123183. _this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, utilityScenePick));
  123184. }
  123185. prePointerInfo.skipOnPointerObservable = true;
  123186. }
  123187. }
  123188. else {
  123189. var originalScenePick = prePointerInfo.ray ? originalScene.pickWithRay(prePointerInfo.ray) : originalScene.pick(originalScene.pointerX, originalScene.pointerY);
  123190. var pointerEvent_1 = (prePointerInfo.event);
  123191. // If the layer can be occluded by the original scene, only fire pointer events to the first layer that hit they ray
  123192. if (originalScenePick && utilityScenePick) {
  123193. // No pick in utility scene
  123194. if (utilityScenePick.distance === 0 && originalScenePick.pickedMesh) {
  123195. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  123196. // We touched an utility mesh present in the main scene
  123197. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  123198. prePointerInfo.skipOnPointerObservable = true;
  123199. }
  123200. else if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERDOWN) {
  123201. _this._pointerCaptures[pointerEvent_1.pointerId] = true;
  123202. }
  123203. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  123204. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  123205. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  123206. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  123207. }
  123208. }
  123209. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance < originalScenePick.distance || originalScenePick.distance === 0)) {
  123210. // We pick something in utility scene or the pick in utility is closer than the one in main scene
  123211. _this._notifyObservers(prePointerInfo, utilityScenePick, pointerEvent_1);
  123212. // If a previous utility layer set this, do not unset this
  123213. if (!prePointerInfo.skipOnPointerObservable) {
  123214. prePointerInfo.skipOnPointerObservable = utilityScenePick.distance > 0;
  123215. }
  123216. }
  123217. else if (!_this._pointerCaptures[pointerEvent_1.pointerId] && (utilityScenePick.distance > originalScenePick.distance)) {
  123218. // We have a pick in both scenes but main is closer than utility
  123219. // We touched an utility mesh present in the main scene
  123220. if (_this.mainSceneTrackerPredicate && _this.mainSceneTrackerPredicate(originalScenePick.pickedMesh)) {
  123221. _this._notifyObservers(prePointerInfo, originalScenePick, pointerEvent_1);
  123222. prePointerInfo.skipOnPointerObservable = true;
  123223. }
  123224. else if (_this._lastPointerEvents[pointerEvent_1.pointerId]) {
  123225. // We need to send a last pointerup to the utilityLayerScene to make sure animations can complete
  123226. _this.onPointerOutObservable.notifyObservers(pointerEvent_1.pointerId);
  123227. delete _this._lastPointerEvents[pointerEvent_1.pointerId];
  123228. }
  123229. }
  123230. if (prePointerInfo.type === _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerEventTypes"].POINTERUP && _this._pointerCaptures[pointerEvent_1.pointerId]) {
  123231. _this._pointerCaptures[pointerEvent_1.pointerId] = false;
  123232. }
  123233. }
  123234. }
  123235. });
  123236. }
  123237. // Render directly on top of existing scene without clearing
  123238. this.utilityLayerScene.autoClear = false;
  123239. this._afterRenderObserver = this.originalScene.onAfterRenderObservable.add(function () {
  123240. if (_this.shouldRender) {
  123241. _this.render();
  123242. }
  123243. });
  123244. this._sceneDisposeObserver = this.originalScene.onDisposeObservable.add(function () {
  123245. _this.dispose();
  123246. });
  123247. this._updateCamera();
  123248. }
  123249. Object.defineProperty(UtilityLayerRenderer, "DefaultUtilityLayer", {
  123250. /**
  123251. * 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)
  123252. */
  123253. get: function () {
  123254. if (UtilityLayerRenderer._DefaultUtilityLayer == null) {
  123255. UtilityLayerRenderer._DefaultUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  123256. UtilityLayerRenderer._DefaultUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  123257. UtilityLayerRenderer._DefaultUtilityLayer = null;
  123258. });
  123259. }
  123260. return UtilityLayerRenderer._DefaultUtilityLayer;
  123261. },
  123262. enumerable: true,
  123263. configurable: true
  123264. });
  123265. Object.defineProperty(UtilityLayerRenderer, "DefaultKeepDepthUtilityLayer", {
  123266. /**
  123267. * 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)
  123268. */
  123269. get: function () {
  123270. if (UtilityLayerRenderer._DefaultKeepDepthUtilityLayer == null) {
  123271. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = new UtilityLayerRenderer(_Engines_engineStore__WEBPACK_IMPORTED_MODULE_3__["EngineStore"].LastCreatedScene);
  123272. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.utilityLayerScene.autoClearDepthAndStencil = false;
  123273. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer.originalScene.onDisposeObservable.addOnce(function () {
  123274. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  123275. });
  123276. }
  123277. return UtilityLayerRenderer._DefaultKeepDepthUtilityLayer;
  123278. },
  123279. enumerable: true,
  123280. configurable: true
  123281. });
  123282. UtilityLayerRenderer.prototype._notifyObservers = function (prePointerInfo, pickInfo, pointerEvent) {
  123283. if (!prePointerInfo.skipOnPointerObservable) {
  123284. this.utilityLayerScene.onPointerObservable.notifyObservers(new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_2__["PointerInfo"](prePointerInfo.type, prePointerInfo.event, pickInfo));
  123285. this._lastPointerEvents[pointerEvent.pointerId] = true;
  123286. }
  123287. };
  123288. /**
  123289. * Renders the utility layers scene on top of the original scene
  123290. */
  123291. UtilityLayerRenderer.prototype.render = function () {
  123292. this._updateCamera();
  123293. if (this.utilityLayerScene.activeCamera) {
  123294. // Set the camera's scene to utility layers scene
  123295. var oldScene = this.utilityLayerScene.activeCamera.getScene();
  123296. var camera = this.utilityLayerScene.activeCamera;
  123297. camera._scene = this.utilityLayerScene;
  123298. if (camera.leftCamera) {
  123299. camera.leftCamera._scene = this.utilityLayerScene;
  123300. }
  123301. if (camera.rightCamera) {
  123302. camera.rightCamera._scene = this.utilityLayerScene;
  123303. }
  123304. this.utilityLayerScene.render(false);
  123305. // Reset camera's scene back to original
  123306. camera._scene = oldScene;
  123307. if (camera.leftCamera) {
  123308. camera.leftCamera._scene = oldScene;
  123309. }
  123310. if (camera.rightCamera) {
  123311. camera.rightCamera._scene = oldScene;
  123312. }
  123313. }
  123314. };
  123315. /**
  123316. * Disposes of the renderer
  123317. */
  123318. UtilityLayerRenderer.prototype.dispose = function () {
  123319. this.onPointerOutObservable.clear();
  123320. if (this._afterRenderObserver) {
  123321. this.originalScene.onAfterRenderObservable.remove(this._afterRenderObserver);
  123322. }
  123323. if (this._sceneDisposeObserver) {
  123324. this.originalScene.onDisposeObservable.remove(this._sceneDisposeObserver);
  123325. }
  123326. if (this._originalPointerObserver) {
  123327. this.originalScene.onPrePointerObservable.remove(this._originalPointerObserver);
  123328. }
  123329. this.utilityLayerScene.dispose();
  123330. };
  123331. UtilityLayerRenderer.prototype._updateCamera = function () {
  123332. if (this.originalScene.activeCameras.length > 1) {
  123333. this.utilityLayerScene.activeCamera = this.originalScene.activeCameras[this.originalScene.activeCameras.length - 1];
  123334. }
  123335. else {
  123336. this.utilityLayerScene.activeCamera = this.originalScene.activeCamera;
  123337. }
  123338. };
  123339. UtilityLayerRenderer._DefaultUtilityLayer = null;
  123340. UtilityLayerRenderer._DefaultKeepDepthUtilityLayer = null;
  123341. return UtilityLayerRenderer;
  123342. }());
  123343. /***/ }),
  123344. /***/ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts":
  123345. /*!*****************************************************************!*\
  123346. !*** ./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts ***!
  123347. \*****************************************************************/
  123348. /*! exports provided: backgroundFragmentDeclaration */
  123349. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123350. "use strict";
  123351. __webpack_require__.r(__webpack_exports__);
  123352. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundFragmentDeclaration", function() { return backgroundFragmentDeclaration; });
  123353. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123354. var name = 'backgroundFragmentDeclaration';
  123355. 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";
  123356. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123357. /** @hidden */
  123358. var backgroundFragmentDeclaration = { name: name, shader: shader };
  123359. /***/ }),
  123360. /***/ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts":
  123361. /*!************************************************************!*\
  123362. !*** ./Shaders/ShadersInclude/backgroundUboDeclaration.ts ***!
  123363. \************************************************************/
  123364. /*! exports provided: backgroundUboDeclaration */
  123365. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123366. "use strict";
  123367. __webpack_require__.r(__webpack_exports__);
  123368. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundUboDeclaration", function() { return backgroundUboDeclaration; });
  123369. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123370. var name = 'backgroundUboDeclaration';
  123371. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec4 vPrimaryColor;\nuniform vec4 vPrimaryColorShadow;\nuniform vec2 vDiffuseInfos;\nuniform vec2 vReflectionInfos;\nuniform mat4 diffuseMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform float fFovMultiplier;\nuniform float pointSize;\nuniform float shadowLevel;\nuniform float alpha;\n#if defined(REFLECTIONFRESNEL) || defined(OPACITYFRESNEL)\nuniform vec3 vBackgroundCenter;\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 vReflectionControl;\n#endif\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  123372. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123373. /** @hidden */
  123374. var backgroundUboDeclaration = { name: name, shader: shader };
  123375. /***/ }),
  123376. /***/ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts":
  123377. /*!***************************************************************!*\
  123378. !*** ./Shaders/ShadersInclude/backgroundVertexDeclaration.ts ***!
  123379. \***************************************************************/
  123380. /*! exports provided: backgroundVertexDeclaration */
  123381. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123382. "use strict";
  123383. __webpack_require__.r(__webpack_exports__);
  123384. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexDeclaration", function() { return backgroundVertexDeclaration; });
  123385. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123386. var name = 'backgroundVertexDeclaration';
  123387. 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";
  123388. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123389. /** @hidden */
  123390. var backgroundVertexDeclaration = { name: name, shader: shader };
  123391. /***/ }),
  123392. /***/ "./Shaders/ShadersInclude/bonesDeclaration.ts":
  123393. /*!****************************************************!*\
  123394. !*** ./Shaders/ShadersInclude/bonesDeclaration.ts ***!
  123395. \****************************************************/
  123396. /*! exports provided: bonesDeclaration */
  123397. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123398. "use strict";
  123399. __webpack_require__.r(__webpack_exports__);
  123400. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesDeclaration", function() { return bonesDeclaration; });
  123401. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123402. var name = 'bonesDeclaration';
  123403. 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";
  123404. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123405. /** @hidden */
  123406. var bonesDeclaration = { name: name, shader: shader };
  123407. /***/ }),
  123408. /***/ "./Shaders/ShadersInclude/bonesVertex.ts":
  123409. /*!***********************************************!*\
  123410. !*** ./Shaders/ShadersInclude/bonesVertex.ts ***!
  123411. \***********************************************/
  123412. /*! exports provided: bonesVertex */
  123413. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123414. "use strict";
  123415. __webpack_require__.r(__webpack_exports__);
  123416. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bonesVertex", function() { return bonesVertex; });
  123417. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123418. var name = 'bonesVertex';
  123419. 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";
  123420. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123421. /** @hidden */
  123422. var bonesVertex = { name: name, shader: shader };
  123423. /***/ }),
  123424. /***/ "./Shaders/ShadersInclude/bumpFragment.ts":
  123425. /*!************************************************!*\
  123426. !*** ./Shaders/ShadersInclude/bumpFragment.ts ***!
  123427. \************************************************/
  123428. /*! exports provided: bumpFragment */
  123429. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123430. "use strict";
  123431. __webpack_require__.r(__webpack_exports__);
  123432. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragment", function() { return bumpFragment; });
  123433. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123434. var name = 'bumpFragment';
  123435. 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";
  123436. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123437. /** @hidden */
  123438. var bumpFragment = { name: name, shader: shader };
  123439. /***/ }),
  123440. /***/ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts":
  123441. /*!*********************************************************!*\
  123442. !*** ./Shaders/ShadersInclude/bumpFragmentFunctions.ts ***!
  123443. \*********************************************************/
  123444. /*! exports provided: bumpFragmentFunctions */
  123445. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123446. "use strict";
  123447. __webpack_require__.r(__webpack_exports__);
  123448. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpFragmentFunctions", function() { return bumpFragmentFunctions; });
  123449. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123450. var name = 'bumpFragmentFunctions';
  123451. 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";
  123452. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123453. /** @hidden */
  123454. var bumpFragmentFunctions = { name: name, shader: shader };
  123455. /***/ }),
  123456. /***/ "./Shaders/ShadersInclude/bumpVertex.ts":
  123457. /*!**********************************************!*\
  123458. !*** ./Shaders/ShadersInclude/bumpVertex.ts ***!
  123459. \**********************************************/
  123460. /*! exports provided: bumpVertex */
  123461. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123462. "use strict";
  123463. __webpack_require__.r(__webpack_exports__);
  123464. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertex", function() { return bumpVertex; });
  123465. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123466. var name = 'bumpVertex';
  123467. 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";
  123468. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123469. /** @hidden */
  123470. var bumpVertex = { name: name, shader: shader };
  123471. /***/ }),
  123472. /***/ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts":
  123473. /*!*********************************************************!*\
  123474. !*** ./Shaders/ShadersInclude/bumpVertexDeclaration.ts ***!
  123475. \*********************************************************/
  123476. /*! exports provided: bumpVertexDeclaration */
  123477. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123478. "use strict";
  123479. __webpack_require__.r(__webpack_exports__);
  123480. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bumpVertexDeclaration", function() { return bumpVertexDeclaration; });
  123481. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123482. var name = 'bumpVertexDeclaration';
  123483. var shader = "#if defined(BUMP) || defined(PARALLAX) || defined(CLEARCOAT_BUMP)\n#if defined(TANGENT) && defined(NORMAL)\nvarying mat3 vTBN;\n#endif\n#endif\n";
  123484. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123485. /** @hidden */
  123486. var bumpVertexDeclaration = { name: name, shader: shader };
  123487. /***/ }),
  123488. /***/ "./Shaders/ShadersInclude/clipPlaneFragment.ts":
  123489. /*!*****************************************************!*\
  123490. !*** ./Shaders/ShadersInclude/clipPlaneFragment.ts ***!
  123491. \*****************************************************/
  123492. /*! exports provided: clipPlaneFragment */
  123493. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123494. "use strict";
  123495. __webpack_require__.r(__webpack_exports__);
  123496. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragment", function() { return clipPlaneFragment; });
  123497. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123498. var name = 'clipPlaneFragment';
  123499. 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";
  123500. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123501. /** @hidden */
  123502. var clipPlaneFragment = { name: name, shader: shader };
  123503. /***/ }),
  123504. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts":
  123505. /*!****************************************************************!*\
  123506. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts ***!
  123507. \****************************************************************/
  123508. /*! exports provided: clipPlaneFragmentDeclaration */
  123509. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123510. "use strict";
  123511. __webpack_require__.r(__webpack_exports__);
  123512. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration", function() { return clipPlaneFragmentDeclaration; });
  123513. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123514. var name = 'clipPlaneFragmentDeclaration';
  123515. 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";
  123516. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123517. /** @hidden */
  123518. var clipPlaneFragmentDeclaration = { name: name, shader: shader };
  123519. /***/ }),
  123520. /***/ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts":
  123521. /*!*****************************************************************!*\
  123522. !*** ./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts ***!
  123523. \*****************************************************************/
  123524. /*! exports provided: clipPlaneFragmentDeclaration2 */
  123525. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123526. "use strict";
  123527. __webpack_require__.r(__webpack_exports__);
  123528. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneFragmentDeclaration2", function() { return clipPlaneFragmentDeclaration2; });
  123529. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123530. var name = 'clipPlaneFragmentDeclaration2';
  123531. 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";
  123532. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123533. /** @hidden */
  123534. var clipPlaneFragmentDeclaration2 = { name: name, shader: shader };
  123535. /***/ }),
  123536. /***/ "./Shaders/ShadersInclude/clipPlaneVertex.ts":
  123537. /*!***************************************************!*\
  123538. !*** ./Shaders/ShadersInclude/clipPlaneVertex.ts ***!
  123539. \***************************************************/
  123540. /*! exports provided: clipPlaneVertex */
  123541. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123542. "use strict";
  123543. __webpack_require__.r(__webpack_exports__);
  123544. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertex", function() { return clipPlaneVertex; });
  123545. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123546. var name = 'clipPlaneVertex';
  123547. 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";
  123548. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123549. /** @hidden */
  123550. var clipPlaneVertex = { name: name, shader: shader };
  123551. /***/ }),
  123552. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts":
  123553. /*!**************************************************************!*\
  123554. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts ***!
  123555. \**************************************************************/
  123556. /*! exports provided: clipPlaneVertexDeclaration */
  123557. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123558. "use strict";
  123559. __webpack_require__.r(__webpack_exports__);
  123560. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration", function() { return clipPlaneVertexDeclaration; });
  123561. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123562. var name = 'clipPlaneVertexDeclaration';
  123563. 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";
  123564. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123565. /** @hidden */
  123566. var clipPlaneVertexDeclaration = { name: name, shader: shader };
  123567. /***/ }),
  123568. /***/ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts":
  123569. /*!***************************************************************!*\
  123570. !*** ./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts ***!
  123571. \***************************************************************/
  123572. /*! exports provided: clipPlaneVertexDeclaration2 */
  123573. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123574. "use strict";
  123575. __webpack_require__.r(__webpack_exports__);
  123576. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clipPlaneVertexDeclaration2", function() { return clipPlaneVertexDeclaration2; });
  123577. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123578. var name = 'clipPlaneVertexDeclaration2';
  123579. 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";
  123580. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123581. /** @hidden */
  123582. var clipPlaneVertexDeclaration2 = { name: name, shader: shader };
  123583. /***/ }),
  123584. /***/ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts":
  123585. /*!**************************************************************!*\
  123586. !*** ./Shaders/ShadersInclude/defaultFragmentDeclaration.ts ***!
  123587. \**************************************************************/
  123588. /*! exports provided: defaultFragmentDeclaration */
  123589. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123590. "use strict";
  123591. __webpack_require__.r(__webpack_exports__);
  123592. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultFragmentDeclaration", function() { return defaultFragmentDeclaration; });
  123593. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123594. var name = 'defaultFragmentDeclaration';
  123595. var shader = "uniform vec4 vDiffuseColor;\n#ifdef SPECULARTERM\nuniform vec4 vSpecularColor;\n#endif\nuniform vec3 vEmissiveColor;\n\n#ifdef DIFFUSE\nuniform vec2 vDiffuseInfos;\n#endif\n#ifdef AMBIENT\nuniform vec2 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\n#ifndef REFRACTIONMAP_3D\nuniform mat4 refractionMatrix;\n#endif\n#ifdef REFRACTIONFRESNEL\nuniform vec4 refractionLeftColor;\nuniform vec4 refractionRightColor;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\nuniform vec2 vSpecularInfos;\n#endif\n#ifdef DIFFUSEFRESNEL\nuniform vec4 diffuseLeftColor;\nuniform vec4 diffuseRightColor;\n#endif\n#ifdef OPACITYFRESNEL\nuniform vec4 opacityParts;\n#endif\n#ifdef EMISSIVEFRESNEL\nuniform vec4 emissiveLeftColor;\nuniform vec4 emissiveRightColor;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\n#ifdef REFLECTIONMAP_SKYBOX\n#else\n#if defined(REFLECTIONMAP_PLANAR) || defined(REFLECTIONMAP_CUBIC) || defined(REFLECTIONMAP_PROJECTION)\nuniform mat4 reflectionMatrix;\n#endif\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n#ifdef REFLECTIONFRESNEL\nuniform vec4 reflectionLeftColor;\nuniform vec4 reflectionRightColor;\n#endif\n#endif";
  123596. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123597. /** @hidden */
  123598. var defaultFragmentDeclaration = { name: name, shader: shader };
  123599. /***/ }),
  123600. /***/ "./Shaders/ShadersInclude/defaultUboDeclaration.ts":
  123601. /*!*********************************************************!*\
  123602. !*** ./Shaders/ShadersInclude/defaultUboDeclaration.ts ***!
  123603. \*********************************************************/
  123604. /*! exports provided: defaultUboDeclaration */
  123605. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123606. "use strict";
  123607. __webpack_require__.r(__webpack_exports__);
  123608. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultUboDeclaration", function() { return defaultUboDeclaration; });
  123609. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123610. var name = 'defaultUboDeclaration';
  123611. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nvec4 diffuseLeftColor;\nvec4 diffuseRightColor;\nvec4 opacityParts;\nvec4 reflectionLeftColor;\nvec4 reflectionRightColor;\nvec4 refractionLeftColor;\nvec4 refractionRightColor;\nvec4 emissiveLeftColor;\nvec4 emissiveRightColor;\nvec2 vDiffuseInfos;\nvec2 vAmbientInfos;\nvec2 vOpacityInfos;\nvec2 vReflectionInfos;\nvec3 vReflectionPosition;\nvec3 vReflectionSize;\nvec2 vEmissiveInfos;\nvec2 vLightmapInfos;\nvec2 vSpecularInfos;\nvec3 vBumpInfos;\nmat4 diffuseMatrix;\nmat4 ambientMatrix;\nmat4 opacityMatrix;\nmat4 reflectionMatrix;\nmat4 emissiveMatrix;\nmat4 lightmapMatrix;\nmat4 specularMatrix;\nmat4 bumpMatrix;\nvec2 vTangentSpaceParams;\nmat4 refractionMatrix;\nvec4 vRefractionInfos;\nvec4 vSpecularColor;\nvec3 vEmissiveColor;\nvec4 vDiffuseColor;\nfloat pointSize;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};\n";
  123612. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123613. /** @hidden */
  123614. var defaultUboDeclaration = { name: name, shader: shader };
  123615. /***/ }),
  123616. /***/ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts":
  123617. /*!************************************************************!*\
  123618. !*** ./Shaders/ShadersInclude/defaultVertexDeclaration.ts ***!
  123619. \************************************************************/
  123620. /*! exports provided: defaultVertexDeclaration */
  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__, "defaultVertexDeclaration", function() { return defaultVertexDeclaration; });
  123625. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123626. var name = 'defaultVertexDeclaration';
  123627. 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";
  123628. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123629. /** @hidden */
  123630. var defaultVertexDeclaration = { name: name, shader: shader };
  123631. /***/ }),
  123632. /***/ "./Shaders/ShadersInclude/depthPrePass.ts":
  123633. /*!************************************************!*\
  123634. !*** ./Shaders/ShadersInclude/depthPrePass.ts ***!
  123635. \************************************************/
  123636. /*! exports provided: depthPrePass */
  123637. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123638. "use strict";
  123639. __webpack_require__.r(__webpack_exports__);
  123640. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPrePass", function() { return depthPrePass; });
  123641. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123642. var name = 'depthPrePass';
  123643. var shader = "#ifdef DEPTHPREPASS\ngl_FragColor=vec4(0.,0.,0.,1.0);\nreturn;\n#endif";
  123644. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123645. /** @hidden */
  123646. var depthPrePass = { name: name, shader: shader };
  123647. /***/ }),
  123648. /***/ "./Shaders/ShadersInclude/fogFragment.ts":
  123649. /*!***********************************************!*\
  123650. !*** ./Shaders/ShadersInclude/fogFragment.ts ***!
  123651. \***********************************************/
  123652. /*! exports provided: fogFragment */
  123653. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123654. "use strict";
  123655. __webpack_require__.r(__webpack_exports__);
  123656. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragment", function() { return fogFragment; });
  123657. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123658. var name = 'fogFragment';
  123659. var shader = "#ifdef FOG\nfloat fog=CalcFogFactor();\ncolor.rgb=fog*color.rgb+(1.0-fog)*vFogColor;\n#endif";
  123660. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123661. /** @hidden */
  123662. var fogFragment = { name: name, shader: shader };
  123663. /***/ }),
  123664. /***/ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts":
  123665. /*!**********************************************************!*\
  123666. !*** ./Shaders/ShadersInclude/fogFragmentDeclaration.ts ***!
  123667. \**********************************************************/
  123668. /*! exports provided: fogFragmentDeclaration */
  123669. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123670. "use strict";
  123671. __webpack_require__.r(__webpack_exports__);
  123672. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogFragmentDeclaration", function() { return fogFragmentDeclaration; });
  123673. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123674. var name = 'fogFragmentDeclaration';
  123675. 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";
  123676. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123677. /** @hidden */
  123678. var fogFragmentDeclaration = { name: name, shader: shader };
  123679. /***/ }),
  123680. /***/ "./Shaders/ShadersInclude/fogVertex.ts":
  123681. /*!*********************************************!*\
  123682. !*** ./Shaders/ShadersInclude/fogVertex.ts ***!
  123683. \*********************************************/
  123684. /*! exports provided: fogVertex */
  123685. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123686. "use strict";
  123687. __webpack_require__.r(__webpack_exports__);
  123688. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertex", function() { return fogVertex; });
  123689. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123690. var name = 'fogVertex';
  123691. var shader = "#ifdef FOG\nvFogDistance=(view*worldPos).xyz;\n#endif";
  123692. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123693. /** @hidden */
  123694. var fogVertex = { name: name, shader: shader };
  123695. /***/ }),
  123696. /***/ "./Shaders/ShadersInclude/fogVertexDeclaration.ts":
  123697. /*!********************************************************!*\
  123698. !*** ./Shaders/ShadersInclude/fogVertexDeclaration.ts ***!
  123699. \********************************************************/
  123700. /*! exports provided: fogVertexDeclaration */
  123701. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123702. "use strict";
  123703. __webpack_require__.r(__webpack_exports__);
  123704. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fogVertexDeclaration", function() { return fogVertexDeclaration; });
  123705. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123706. var name = 'fogVertexDeclaration';
  123707. var shader = "#ifdef FOG\nvarying vec3 vFogDistance;\n#endif";
  123708. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123709. /** @hidden */
  123710. var fogVertexDeclaration = { name: name, shader: shader };
  123711. /***/ }),
  123712. /***/ "./Shaders/ShadersInclude/fresnelFunction.ts":
  123713. /*!***************************************************!*\
  123714. !*** ./Shaders/ShadersInclude/fresnelFunction.ts ***!
  123715. \***************************************************/
  123716. /*! exports provided: fresnelFunction */
  123717. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123718. "use strict";
  123719. __webpack_require__.r(__webpack_exports__);
  123720. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fresnelFunction", function() { return fresnelFunction; });
  123721. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123722. var name = 'fresnelFunction';
  123723. 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";
  123724. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123725. /** @hidden */
  123726. var fresnelFunction = { name: name, shader: shader };
  123727. /***/ }),
  123728. /***/ "./Shaders/ShadersInclude/harmonicsFunctions.ts":
  123729. /*!******************************************************!*\
  123730. !*** ./Shaders/ShadersInclude/harmonicsFunctions.ts ***!
  123731. \******************************************************/
  123732. /*! exports provided: harmonicsFunctions */
  123733. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123734. "use strict";
  123735. __webpack_require__.r(__webpack_exports__);
  123736. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "harmonicsFunctions", function() { return harmonicsFunctions; });
  123737. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123738. var name = 'harmonicsFunctions';
  123739. 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";
  123740. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123741. /** @hidden */
  123742. var harmonicsFunctions = { name: name, shader: shader };
  123743. /***/ }),
  123744. /***/ "./Shaders/ShadersInclude/helperFunctions.ts":
  123745. /*!***************************************************!*\
  123746. !*** ./Shaders/ShadersInclude/helperFunctions.ts ***!
  123747. \***************************************************/
  123748. /*! exports provided: helperFunctions */
  123749. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123750. "use strict";
  123751. __webpack_require__.r(__webpack_exports__);
  123752. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "helperFunctions", function() { return helperFunctions; });
  123753. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123754. var name = 'helperFunctions';
  123755. var shader = "const float PI=3.1415926535897932384626433832795;\nconst float LinearEncodePowerApprox=2.2;\nconst float GammaEncodePowerApprox=1.0/LinearEncodePowerApprox;\nconst vec3 LuminanceEncodeApprox=vec3(0.2126,0.7152,0.0722);\nmat3 transposeMat3(mat3 inMatrix) {\nvec3 i0=inMatrix[0];\nvec3 i1=inMatrix[1];\nvec3 i2=inMatrix[2];\nmat3 outMatrix=mat3(\nvec3(i0.x,i1.x,i2.x),\nvec3(i0.y,i1.y,i2.y),\nvec3(i0.z,i1.z,i2.z)\n);\nreturn outMatrix;\n}\n\nmat3 inverseMat3(mat3 inMatrix) {\nfloat a00=inMatrix[0][0],a01=inMatrix[0][1],a02=inMatrix[0][2];\nfloat a10=inMatrix[1][0],a11=inMatrix[1][1],a12=inMatrix[1][2];\nfloat a20=inMatrix[2][0],a21=inMatrix[2][1],a22=inMatrix[2][2];\nfloat b01=a22*a11-a12*a21;\nfloat b11=-a22*a10+a12*a20;\nfloat b21=a21*a10-a11*a20;\nfloat det=a00*b01+a01*b11+a02*b21;\nreturn mat3(b01,(-a22*a01+a02*a21),(a12*a01-a02*a11),\nb11,(a22*a00-a02*a20),(-a12*a00+a02*a10),\nb21,(-a21*a00+a01*a20),(a11*a00-a01*a10))/det;\n}\nfloat computeFallOff(float value,vec2 clipSpace,float frustumEdgeFalloff)\n{\nfloat mask=smoothstep(1.0-frustumEdgeFalloff,1.0,clamp(dot(clipSpace,clipSpace),0.,1.));\nreturn mix(value,1.0,mask);\n}\nvec3 applyEaseInOut(vec3 x){\nreturn x*x*(3.0-2.0*x);\n}\nvec3 toLinearSpace(vec3 color)\n{\nreturn pow(color,vec3(LinearEncodePowerApprox));\n}\nvec3 toGammaSpace(vec3 color)\n{\nreturn pow(color,vec3(GammaEncodePowerApprox));\n}\nfloat square(float value)\n{\nreturn value*value;\n}\nfloat getLuminance(vec3 color)\n{\nreturn clamp(dot(color,LuminanceEncodeApprox),0.,1.);\n}\n\nfloat getRand(vec2 seed) {\nreturn fract(sin(dot(seed.xy ,vec2(12.9898,78.233)))*43758.5453);\n}\nfloat dither(vec2 seed,float varianceAmount) {\nfloat rand=getRand(seed);\nfloat dither=mix(-varianceAmount/255.0,varianceAmount/255.0,rand);\nreturn dither;\n}\n\nconst float rgbdMaxRange=255.0;\nvec4 toRGBD(vec3 color) {\nfloat maxRGB=max(0.0000001,max(color.r,max(color.g,color.b)));\nfloat D=max(rgbdMaxRange/maxRGB,1.);\nD=clamp(floor(D)/255.0,0.,1.);\n\nvec3 rgb=color.rgb*D;\n\nrgb=toGammaSpace(rgb);\nreturn vec4(rgb,D);\n}\nvec3 fromRGBD(vec4 rgbd) {\n\nrgbd.rgb=toLinearSpace(rgbd.rgb);\n\nreturn rgbd.rgb/rgbd.a;\n}";
  123756. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123757. /** @hidden */
  123758. var helperFunctions = { name: name, shader: shader };
  123759. /***/ }),
  123760. /***/ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts":
  123761. /*!**************************************************************!*\
  123762. !*** ./Shaders/ShadersInclude/imageProcessingDeclaration.ts ***!
  123763. \**************************************************************/
  123764. /*! exports provided: imageProcessingDeclaration */
  123765. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123766. "use strict";
  123767. __webpack_require__.r(__webpack_exports__);
  123768. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingDeclaration", function() { return imageProcessingDeclaration; });
  123769. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123770. var name = 'imageProcessingDeclaration';
  123771. 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";
  123772. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123773. /** @hidden */
  123774. var imageProcessingDeclaration = { name: name, shader: shader };
  123775. /***/ }),
  123776. /***/ "./Shaders/ShadersInclude/imageProcessingFunctions.ts":
  123777. /*!************************************************************!*\
  123778. !*** ./Shaders/ShadersInclude/imageProcessingFunctions.ts ***!
  123779. \************************************************************/
  123780. /*! exports provided: imageProcessingFunctions */
  123781. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123782. "use strict";
  123783. __webpack_require__.r(__webpack_exports__);
  123784. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingFunctions", function() { return imageProcessingFunctions; });
  123785. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123786. var name = 'imageProcessingFunctions';
  123787. var shader = "#if defined(COLORGRADING) && !defined(COLORGRADING3D)\n\nvec3 sampleTexture3D(sampler2D colorTransform,vec3 color,vec2 sampler3dSetting)\n{\nfloat sliceSize=2.0*sampler3dSetting.x;\n#ifdef SAMPLER3DGREENDEPTH\nfloat sliceContinuous=(color.g-sampler3dSetting.x)*sampler3dSetting.y;\n#else\nfloat sliceContinuous=(color.b-sampler3dSetting.x)*sampler3dSetting.y;\n#endif\nfloat sliceInteger=floor(sliceContinuous);\n\n\nfloat sliceFraction=sliceContinuous-sliceInteger;\n#ifdef SAMPLER3DGREENDEPTH\nvec2 sliceUV=color.rb;\n#else\nvec2 sliceUV=color.rg;\n#endif\nsliceUV.x*=sliceSize;\nsliceUV.x+=sliceInteger*sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice0Color=texture2D(colorTransform,sliceUV);\nsliceUV.x+=sliceSize;\nsliceUV=clamp(sliceUV,0.,1.);\nvec4 slice1Color=texture2D(colorTransform,sliceUV);\nvec3 result=mix(slice0Color.rgb,slice1Color.rgb,sliceFraction);\n#ifdef SAMPLER3DBGRMAP\ncolor.rgb=result.rgb;\n#else\ncolor.rgb=result.bgr;\n#endif\nreturn color;\n}\n#endif\n#ifdef TONEMAPPING_ACES\n\n\n\n\n\nconst mat3 ACESInputMat=mat3(\nvec3(0.59719,0.07600,0.02840),\nvec3(0.35458,0.90834,0.13383),\nvec3(0.04823,0.01566,0.83777)\n);\n\nconst mat3 ACESOutputMat=mat3(\nvec3( 1.60475,-0.10208,-0.00327),\nvec3(-0.53108,1.10813,-0.07276),\nvec3(-0.07367,-0.00605,1.07602)\n);\nvec3 RRTAndODTFit(vec3 v)\n{\nvec3 a=v*(v+0.0245786)-0.000090537;\nvec3 b=v*(0.983729*v+0.4329510)+0.238081;\nreturn a/b;\n}\nvec3 ACESFitted(vec3 color)\n{\ncolor=ACESInputMat*color;\n\ncolor=RRTAndODTFit(color);\ncolor=ACESOutputMat*color;\n\ncolor=clamp(color,0.0,1.0);\nreturn color;\n}\n#endif\nvec4 applyImageProcessing(vec4 result) {\n#ifdef EXPOSURE\nresult.rgb*=exposureLinear;\n#endif\n#ifdef VIGNETTE\n\nvec2 viewportXY=gl_FragCoord.xy*vInverseScreenSize;\nviewportXY=viewportXY*2.0-1.0;\nvec3 vignetteXY1=vec3(viewportXY*vignetteSettings1.xy+vignetteSettings1.zw,1.0);\nfloat vignetteTerm=dot(vignetteXY1,vignetteXY1);\nfloat vignette=pow(vignetteTerm,vignetteSettings2.w);\n\nvec3 vignetteColor=vignetteSettings2.rgb;\n#ifdef VIGNETTEBLENDMODEMULTIPLY\nvec3 vignetteColorMultiplier=mix(vignetteColor,vec3(1,1,1),vignette);\nresult.rgb*=vignetteColorMultiplier;\n#endif\n#ifdef VIGNETTEBLENDMODEOPAQUE\nresult.rgb=mix(vignetteColor,result.rgb,vignette);\n#endif\n#endif\n#ifdef TONEMAPPING\n#ifdef TONEMAPPING_ACES\nresult.rgb=ACESFitted(result.rgb);\n#else\nconst float tonemappingCalibration=1.590579;\nresult.rgb=1.0-exp2(-tonemappingCalibration*result.rgb);\n#endif\n#endif\n\nresult.rgb=toGammaSpace(result.rgb);\nresult.rgb=clamp(result.rgb,0.0,1.0);\n#ifdef CONTRAST\n\nvec3 resultHighContrast=applyEaseInOut(result.rgb);\nif (contrast<1.0) {\n\nresult.rgb=mix(vec3(0.5,0.5,0.5),result.rgb,contrast);\n} else {\n\nresult.rgb=mix(result.rgb,resultHighContrast,contrast-1.0);\n}\n#endif\n\n#ifdef COLORGRADING\nvec3 colorTransformInput=result.rgb*colorTransformSettings.xxx+colorTransformSettings.yyy;\n#ifdef COLORGRADING3D\nvec3 colorTransformOutput=texture(txColorTransform,colorTransformInput).rgb;\n#else\nvec3 colorTransformOutput=sampleTexture3D(txColorTransform,colorTransformInput,colorTransformSettings.yz).rgb;\n#endif\nresult.rgb=mix(result.rgb,colorTransformOutput,colorTransformSettings.www);\n#endif\n#ifdef COLORCURVES\n\nfloat luma=getLuminance(result.rgb);\nvec2 curveMix=clamp(vec2(luma*3.0-1.5,luma*-3.0+1.5),vec2(0.0),vec2(1.0));\nvec4 colorCurve=vCameraColorCurveNeutral+curveMix.x*vCameraColorCurvePositive-curveMix.y*vCameraColorCurveNegative;\nresult.rgb*=colorCurve.rgb;\nresult.rgb=mix(vec3(luma),result.rgb,colorCurve.a);\n#endif\nreturn result;\n}";
  123788. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123789. /** @hidden */
  123790. var imageProcessingFunctions = { name: name, shader: shader };
  123791. /***/ }),
  123792. /***/ "./Shaders/ShadersInclude/instancesDeclaration.ts":
  123793. /*!********************************************************!*\
  123794. !*** ./Shaders/ShadersInclude/instancesDeclaration.ts ***!
  123795. \********************************************************/
  123796. /*! exports provided: instancesDeclaration */
  123797. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123798. "use strict";
  123799. __webpack_require__.r(__webpack_exports__);
  123800. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesDeclaration", function() { return instancesDeclaration; });
  123801. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123802. var name = 'instancesDeclaration';
  123803. var shader = "#ifdef INSTANCES\nattribute vec4 world0;\nattribute vec4 world1;\nattribute vec4 world2;\nattribute vec4 world3;\n#else\nuniform mat4 world;\n#endif";
  123804. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123805. /** @hidden */
  123806. var instancesDeclaration = { name: name, shader: shader };
  123807. /***/ }),
  123808. /***/ "./Shaders/ShadersInclude/instancesVertex.ts":
  123809. /*!***************************************************!*\
  123810. !*** ./Shaders/ShadersInclude/instancesVertex.ts ***!
  123811. \***************************************************/
  123812. /*! exports provided: instancesVertex */
  123813. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123814. "use strict";
  123815. __webpack_require__.r(__webpack_exports__);
  123816. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "instancesVertex", function() { return instancesVertex; });
  123817. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123818. var name = 'instancesVertex';
  123819. var shader = "#ifdef INSTANCES\nmat4 finalWorld=mat4(world0,world1,world2,world3);\n#else\nmat4 finalWorld=world;\n#endif";
  123820. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123821. /** @hidden */
  123822. var instancesVertex = { name: name, shader: shader };
  123823. /***/ }),
  123824. /***/ "./Shaders/ShadersInclude/kernelBlurFragment.ts":
  123825. /*!******************************************************!*\
  123826. !*** ./Shaders/ShadersInclude/kernelBlurFragment.ts ***!
  123827. \******************************************************/
  123828. /*! exports provided: kernelBlurFragment */
  123829. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123830. "use strict";
  123831. __webpack_require__.r(__webpack_exports__);
  123832. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment", function() { return kernelBlurFragment; });
  123833. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123834. var name = 'kernelBlurFragment';
  123835. 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";
  123836. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123837. /** @hidden */
  123838. var kernelBlurFragment = { name: name, shader: shader };
  123839. /***/ }),
  123840. /***/ "./Shaders/ShadersInclude/kernelBlurFragment2.ts":
  123841. /*!*******************************************************!*\
  123842. !*** ./Shaders/ShadersInclude/kernelBlurFragment2.ts ***!
  123843. \*******************************************************/
  123844. /*! exports provided: kernelBlurFragment2 */
  123845. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123846. "use strict";
  123847. __webpack_require__.r(__webpack_exports__);
  123848. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurFragment2", function() { return kernelBlurFragment2; });
  123849. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123850. var name = 'kernelBlurFragment2';
  123851. 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";
  123852. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123853. /** @hidden */
  123854. var kernelBlurFragment2 = { name: name, shader: shader };
  123855. /***/ }),
  123856. /***/ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts":
  123857. /*!****************************************************************!*\
  123858. !*** ./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts ***!
  123859. \****************************************************************/
  123860. /*! exports provided: kernelBlurVaryingDeclaration */
  123861. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123862. "use strict";
  123863. __webpack_require__.r(__webpack_exports__);
  123864. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVaryingDeclaration", function() { return kernelBlurVaryingDeclaration; });
  123865. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123866. var name = 'kernelBlurVaryingDeclaration';
  123867. var shader = "varying vec2 sampleCoord{X};";
  123868. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123869. /** @hidden */
  123870. var kernelBlurVaryingDeclaration = { name: name, shader: shader };
  123871. /***/ }),
  123872. /***/ "./Shaders/ShadersInclude/kernelBlurVertex.ts":
  123873. /*!****************************************************!*\
  123874. !*** ./Shaders/ShadersInclude/kernelBlurVertex.ts ***!
  123875. \****************************************************/
  123876. /*! exports provided: kernelBlurVertex */
  123877. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123878. "use strict";
  123879. __webpack_require__.r(__webpack_exports__);
  123880. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertex", function() { return kernelBlurVertex; });
  123881. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123882. var name = 'kernelBlurVertex';
  123883. var shader = "sampleCoord{X}=sampleCenter+delta*KERNEL_OFFSET{X};";
  123884. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123885. /** @hidden */
  123886. var kernelBlurVertex = { name: name, shader: shader };
  123887. /***/ }),
  123888. /***/ "./Shaders/ShadersInclude/lightFragment.ts":
  123889. /*!*************************************************!*\
  123890. !*** ./Shaders/ShadersInclude/lightFragment.ts ***!
  123891. \*************************************************/
  123892. /*! exports provided: lightFragment */
  123893. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123894. "use strict";
  123895. __webpack_require__.r(__webpack_exports__);
  123896. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragment", function() { return lightFragment; });
  123897. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123898. var name = 'lightFragment';
  123899. var shader = "#ifdef LIGHT{X}\n#if defined(SHADOWONLY) || (defined(LIGHTMAP) && defined(LIGHTMAPEXCLUDED{X}) && defined(LIGHTMAPNOSPECULAR{X}))\n\n#else\n#ifdef PBR\n\n#ifdef SPOTLIGHT{X}\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(POINTLIGHT{X})\npreInfo=computePointAndSpotPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(HEMILIGHT{X})\npreInfo=computeHemisphericPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#elif defined(DIRLIGHT{X})\npreInfo=computeDirectionalPreLightingInfo(light{X}.vLightData,viewDirectionW,normalW);\n#endif\npreInfo.NdotV=NdotV;\n\n#ifdef SPOTLIGHT{X}\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff_GLTF(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\npreInfo.attenuation*=computeDirectionalLightFalloff_Physical(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\npreInfo.attenuation*=computeDirectionalLightFalloff_Standard(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\npreInfo.attenuation*=computeDirectionalLightFalloff(light{X}.vLightDirection.xyz,preInfo.L,light{X}.vLightDirection.w,light{X}.vLightData.w,light{X}.vLightFalloff.z,light{X}.vLightFalloff.w);\n#endif\n#elif defined(POINTLIGHT{X})\n#ifdef LIGHT_FALLOFF_GLTF{X}\npreInfo.attenuation=computeDistanceLightFalloff_GLTF(preInfo.lightDistanceSquared,light{X}.vLightFalloff.y);\n#elif defined(LIGHT_FALLOFF_PHYSICAL{X})\npreInfo.attenuation=computeDistanceLightFalloff_Physical(preInfo.lightDistanceSquared);\n#elif defined(LIGHT_FALLOFF_STANDARD{X})\npreInfo.attenuation=computeDistanceLightFalloff_Standard(preInfo.lightOffset,light{X}.vLightFalloff.x);\n#else\npreInfo.attenuation=computeDistanceLightFalloff(preInfo.lightOffset,preInfo.lightDistanceSquared,light{X}.vLightFalloff.x,light{X}.vLightFalloff.y);\n#endif\n#else\npreInfo.attenuation=1.0;\n#endif\n\n\n#ifdef HEMILIGHT{X}\npreInfo.roughness=roughness;\n#else\npreInfo.roughness=adjustRoughnessFromLightProperties(roughness,light{X}.vLightDiffuse.a,preInfo.lightDistance);\n#endif\n\n#ifdef HEMILIGHT{X}\ninfo.diffuse=computeHemisphericDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb,light{X}.vLightGround);\n#else\ninfo.diffuse=computeDiffuseLighting(preInfo,light{X}.vLightDiffuse.rgb);\n#endif\n\n#ifdef SPECULARTERM\n#ifdef ANISOTROPIC\ninfo.specular=computeAnisotropicSpecularLighting(preInfo,viewDirectionW,normalW,normalize(TBN[0]),normalize(TBN[1]),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 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\ninfo.diffuse*=info.clearCoat.w;\n#ifdef SPECULARTERM\ninfo.specular*=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#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#endif\n#endif\n#endif";
  123900. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123901. /** @hidden */
  123902. var lightFragment = { name: name, shader: shader };
  123903. /***/ }),
  123904. /***/ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts":
  123905. /*!************************************************************!*\
  123906. !*** ./Shaders/ShadersInclude/lightFragmentDeclaration.ts ***!
  123907. \************************************************************/
  123908. /*! exports provided: lightFragmentDeclaration */
  123909. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123910. "use strict";
  123911. __webpack_require__.r(__webpack_exports__);
  123912. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightFragmentDeclaration", function() { return lightFragmentDeclaration; });
  123913. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123914. var name = 'lightFragmentDeclaration';
  123915. 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";
  123916. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123917. /** @hidden */
  123918. var lightFragmentDeclaration = { name: name, shader: shader };
  123919. /***/ }),
  123920. /***/ "./Shaders/ShadersInclude/lightUboDeclaration.ts":
  123921. /*!*******************************************************!*\
  123922. !*** ./Shaders/ShadersInclude/lightUboDeclaration.ts ***!
  123923. \*******************************************************/
  123924. /*! exports provided: lightUboDeclaration */
  123925. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123926. "use strict";
  123927. __webpack_require__.r(__webpack_exports__);
  123928. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightUboDeclaration", function() { return lightUboDeclaration; });
  123929. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123930. var name = 'lightUboDeclaration';
  123931. 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";
  123932. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123933. /** @hidden */
  123934. var lightUboDeclaration = { name: name, shader: shader };
  123935. /***/ }),
  123936. /***/ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts":
  123937. /*!***********************************************************!*\
  123938. !*** ./Shaders/ShadersInclude/lightsFragmentFunctions.ts ***!
  123939. \***********************************************************/
  123940. /*! exports provided: lightsFragmentFunctions */
  123941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123942. "use strict";
  123943. __webpack_require__.r(__webpack_exports__);
  123944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lightsFragmentFunctions", function() { return lightsFragmentFunctions; });
  123945. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123946. var name = 'lightsFragmentFunctions';
  123947. 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}";
  123948. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123949. /** @hidden */
  123950. var lightsFragmentFunctions = { name: name, shader: shader };
  123951. /***/ }),
  123952. /***/ "./Shaders/ShadersInclude/logDepthDeclaration.ts":
  123953. /*!*******************************************************!*\
  123954. !*** ./Shaders/ShadersInclude/logDepthDeclaration.ts ***!
  123955. \*******************************************************/
  123956. /*! exports provided: logDepthDeclaration */
  123957. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123958. "use strict";
  123959. __webpack_require__.r(__webpack_exports__);
  123960. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthDeclaration", function() { return logDepthDeclaration; });
  123961. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123962. var name = 'logDepthDeclaration';
  123963. var shader = "#ifdef LOGARITHMICDEPTH\nuniform float logarithmicDepthConstant;\nvarying float vFragmentDepth;\n#endif";
  123964. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123965. /** @hidden */
  123966. var logDepthDeclaration = { name: name, shader: shader };
  123967. /***/ }),
  123968. /***/ "./Shaders/ShadersInclude/logDepthFragment.ts":
  123969. /*!****************************************************!*\
  123970. !*** ./Shaders/ShadersInclude/logDepthFragment.ts ***!
  123971. \****************************************************/
  123972. /*! exports provided: logDepthFragment */
  123973. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123974. "use strict";
  123975. __webpack_require__.r(__webpack_exports__);
  123976. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthFragment", function() { return logDepthFragment; });
  123977. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123978. var name = 'logDepthFragment';
  123979. var shader = "#ifdef LOGARITHMICDEPTH\ngl_FragDepthEXT=log2(vFragmentDepth)*logarithmicDepthConstant*0.5;\n#endif";
  123980. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123981. /** @hidden */
  123982. var logDepthFragment = { name: name, shader: shader };
  123983. /***/ }),
  123984. /***/ "./Shaders/ShadersInclude/logDepthVertex.ts":
  123985. /*!**************************************************!*\
  123986. !*** ./Shaders/ShadersInclude/logDepthVertex.ts ***!
  123987. \**************************************************/
  123988. /*! exports provided: logDepthVertex */
  123989. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  123990. "use strict";
  123991. __webpack_require__.r(__webpack_exports__);
  123992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logDepthVertex", function() { return logDepthVertex; });
  123993. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  123994. var name = 'logDepthVertex';
  123995. var shader = "#ifdef LOGARITHMICDEPTH\nvFragmentDepth=1.0+gl_Position.w;\ngl_Position.z=log2(max(0.000001,vFragmentDepth))*logarithmicDepthConstant;\n#endif";
  123996. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  123997. /** @hidden */
  123998. var logDepthVertex = { name: name, shader: shader };
  123999. /***/ }),
  124000. /***/ "./Shaders/ShadersInclude/morphTargetsVertex.ts":
  124001. /*!******************************************************!*\
  124002. !*** ./Shaders/ShadersInclude/morphTargetsVertex.ts ***!
  124003. \******************************************************/
  124004. /*! exports provided: morphTargetsVertex */
  124005. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124006. "use strict";
  124007. __webpack_require__.r(__webpack_exports__);
  124008. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertex", function() { return morphTargetsVertex; });
  124009. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124010. var name = 'morphTargetsVertex';
  124011. 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";
  124012. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124013. /** @hidden */
  124014. var morphTargetsVertex = { name: name, shader: shader };
  124015. /***/ }),
  124016. /***/ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts":
  124017. /*!*****************************************************************!*\
  124018. !*** ./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts ***!
  124019. \*****************************************************************/
  124020. /*! exports provided: morphTargetsVertexDeclaration */
  124021. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124022. "use strict";
  124023. __webpack_require__.r(__webpack_exports__);
  124024. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexDeclaration", function() { return morphTargetsVertexDeclaration; });
  124025. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124026. var name = 'morphTargetsVertexDeclaration';
  124027. 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";
  124028. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124029. /** @hidden */
  124030. var morphTargetsVertexDeclaration = { name: name, shader: shader };
  124031. /***/ }),
  124032. /***/ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts":
  124033. /*!***********************************************************************!*\
  124034. !*** ./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts ***!
  124035. \***********************************************************************/
  124036. /*! exports provided: morphTargetsVertexGlobalDeclaration */
  124037. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124038. "use strict";
  124039. __webpack_require__.r(__webpack_exports__);
  124040. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "morphTargetsVertexGlobalDeclaration", function() { return morphTargetsVertexGlobalDeclaration; });
  124041. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124042. var name = 'morphTargetsVertexGlobalDeclaration';
  124043. var shader = "#ifdef MORPHTARGETS\nuniform float morphTargetInfluences[NUM_MORPH_INFLUENCERS];\n#endif";
  124044. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124045. /** @hidden */
  124046. var morphTargetsVertexGlobalDeclaration = { name: name, shader: shader };
  124047. /***/ }),
  124048. /***/ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts":
  124049. /*!**********************************************************!*\
  124050. !*** ./Shaders/ShadersInclude/mrtFragmentDeclaration.ts ***!
  124051. \**********************************************************/
  124052. /*! exports provided: mrtFragmentDeclaration */
  124053. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124054. "use strict";
  124055. __webpack_require__.r(__webpack_exports__);
  124056. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "mrtFragmentDeclaration", function() { return mrtFragmentDeclaration; });
  124057. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124058. var name = 'mrtFragmentDeclaration';
  124059. var shader = "#if __VERSION__>=200\nlayout(location=0) out vec4 glFragData[{X}];\n#endif\n";
  124060. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124061. /** @hidden */
  124062. var mrtFragmentDeclaration = { name: name, shader: shader };
  124063. /***/ }),
  124064. /***/ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts":
  124065. /*!***************************************************************!*\
  124066. !*** ./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts ***!
  124067. \***************************************************************/
  124068. /*! exports provided: pbrFalloffLightingFunctions */
  124069. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124070. "use strict";
  124071. __webpack_require__.r(__webpack_exports__);
  124072. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFalloffLightingFunctions", function() { return pbrFalloffLightingFunctions; });
  124073. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124074. var name = 'pbrFalloffLightingFunctions';
  124075. 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/((lightDistanceSquared+0.001));\n}\nfloat computeDistanceLightFalloff_GLTF(float lightDistanceSquared,float inverseSquaredRange)\n{\nconst float minDistanceSquared=0.01*0.01;\nfloat lightDistanceFalloff=1.0/(max(lightDistanceSquared,minDistanceSquared));\nfloat factor=lightDistanceSquared*inverseSquaredRange;\nfloat attenuation=clamp(1.0-factor*factor,0.,1.);\nattenuation*=attenuation;\n\nlightDistanceFalloff*=attenuation;\nreturn lightDistanceFalloff;\n}\nfloat computeDistanceLightFalloff(vec3 lightOffset,float lightDistanceSquared,float range,float inverseSquaredRange)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDistanceLightFalloff_Physical(lightDistanceSquared);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDistanceLightFalloff_GLTF(lightDistanceSquared,inverseSquaredRange);\n#else\nreturn computeDistanceLightFalloff_Standard(lightOffset,range);\n#endif\n}\nfloat computeDirectionalLightFalloff_Standard(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent)\n{\nfloat falloff=0.0;\nfloat cosAngle=max(0.000000000000001,dot(-lightDirection,directionToLightCenterW));\nif (cosAngle>=cosHalfAngle)\n{\nfalloff=max(0.,pow(cosAngle,exponent));\n}\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_Physical(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle)\n{\nconst float kMinusLog2ConeAngleIntensityRatio=6.64385618977;\n\n\n\n\n\nfloat concentrationKappa=kMinusLog2ConeAngleIntensityRatio/(1.0-cosHalfAngle);\n\n\nvec4 lightDirectionSpreadSG=vec4(-lightDirection*concentrationKappa,-concentrationKappa);\nfloat falloff=exp2(dot(vec4(directionToLightCenterW,1.0),lightDirectionSpreadSG));\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff_GLTF(vec3 lightDirection,vec3 directionToLightCenterW,float lightAngleScale,float lightAngleOffset)\n{\n\n\n\nfloat cd=dot(-lightDirection,directionToLightCenterW);\nfloat falloff=clamp(cd*lightAngleScale+lightAngleOffset,0.,1.);\n\nfalloff*=falloff;\nreturn falloff;\n}\nfloat computeDirectionalLightFalloff(vec3 lightDirection,vec3 directionToLightCenterW,float cosHalfAngle,float exponent,float lightAngleScale,float lightAngleOffset)\n{\n#ifdef USEPHYSICALLIGHTFALLOFF\nreturn computeDirectionalLightFalloff_Physical(lightDirection,directionToLightCenterW,cosHalfAngle);\n#elif defined(USEGLTFLIGHTFALLOFF)\nreturn computeDirectionalLightFalloff_GLTF(lightDirection,directionToLightCenterW,lightAngleScale,lightAngleOffset);\n#else\nreturn computeDirectionalLightFalloff_Standard(lightDirection,directionToLightCenterW,cosHalfAngle,exponent);\n#endif\n}";
  124076. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124077. /** @hidden */
  124078. var pbrFalloffLightingFunctions = { name: name, shader: shader };
  124079. /***/ }),
  124080. /***/ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts":
  124081. /*!**********************************************************!*\
  124082. !*** ./Shaders/ShadersInclude/pbrFragmentDeclaration.ts ***!
  124083. \**********************************************************/
  124084. /*! exports provided: pbrFragmentDeclaration */
  124085. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124086. "use strict";
  124087. __webpack_require__.r(__webpack_exports__);
  124088. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFragmentDeclaration", function() { return pbrFragmentDeclaration; });
  124089. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124090. var name = 'pbrFragmentDeclaration';
  124091. var shader = "uniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\n\nuniform vec4 vLightingIntensity;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\n\n#ifdef ALBEDO\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform vec2 vTangentSpaceParams;\n#endif\n#ifdef OPACITY\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\n#endif\n\n#if defined(REFLECTIONMAP_SPHERICAL) || defined(REFLECTIONMAP_PROJECTION) || defined(REFRACTION)\nuniform mat4 view;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#if defined(USE_LOCAL_REFLECTIONMAP_CUBIC) && defined(REFLECTIONMAP_CUBIC)\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\n#endif\n#endif\n\n#ifdef CLEARCOAT\nuniform vec2 vClearCoatParams;\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#endif\n\n#ifdef ANISOTROPIC\nuniform float anisotropy;\n#endif";
  124092. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124093. /** @hidden */
  124094. var pbrFragmentDeclaration = { name: name, shader: shader };
  124095. /***/ }),
  124096. /***/ "./Shaders/ShadersInclude/pbrFunctions.ts":
  124097. /*!************************************************!*\
  124098. !*** ./Shaders/ShadersInclude/pbrFunctions.ts ***!
  124099. \************************************************/
  124100. /*! exports provided: pbrFunctions */
  124101. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124102. "use strict";
  124103. __webpack_require__.r(__webpack_exports__);
  124104. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrFunctions", function() { return pbrFunctions; });
  124105. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124106. var name = 'pbrFunctions';
  124107. var shader = "\n#define RECIPROCAL_PI2 0.15915494\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\n\n#define MINIMUMVARIANCE 0.0005\n\n#define CLEARCOATREFLECTANCE0 0.04\n#define CLEARCOATREFLECTANCE90 1.0\nfloat convertRoughnessToAverageSlope(float roughness)\n{\n\nreturn square(roughness)+MINIMUMVARIANCE;\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(clamp(slopeSquare ,0.,1.),0.333);\n\nfloat geometricAlphaGFactor=sqrt(slopeSquare);\n\ngeometricAlphaGFactor*=0.75;\nreturn vec2(geometricRoughnessFactor,geometricAlphaGFactor);\n#else\nreturn vec2(0.);\n#endif\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nvec3 getR0RemappedForPolyurethaneClearCoat(vec3 f0) {\nvec3 s=sqrt(f0);\nreturn (-1.0+5.0*s)/(5.0+s);\n}\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nfloat smithVisibilityG1_TrowbridgeReitzGGXFast(float dot,float alphaG)\n{\nfloat alphaSquared=alphaG*alphaG;\nreturn 1.0/(dot+sqrt(alphaSquared+(1.0-alphaSquared)*dot*dot));\n}\n\n\n\n\n\n\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}\nfloat kelemenVisibility(float VdotH) {\n\n\n\nreturn 0.25/(VdotH*VdotH);\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\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\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*(1.0/PI);\n}\n\n\nfloat smithVisibility_GGXCorrelated_Anisotropic(float NdotV,float NdotL,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}\nvec3 fresnelSchlickGGX(float VdotH,vec3 reflectance0,vec3 reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(1.0-VdotH,5.0);\n}\nfloat fresnelSchlickGGX(float VdotH,float reflectance0,float reflectance90)\n{\nreturn reflectance0+(reflectance90-reflectance0)*pow(1.0-VdotH,5.0);\n}\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n\n\n\nfloat computeDiffuseTerm(float NdotL,float NdotV,float VdotH,float roughness)\n{\n\n\nfloat diffuseFresnelNV=pow(clamp(1.0-NdotL,0.000001,1.),5.0);\nfloat diffuseFresnelNL=pow(clamp(1.0-NdotV,0.000001,1.),5.0);\nfloat diffuseFresnel90=0.5+2.0*VdotH*VdotH*roughness;\nfloat fresnel =\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNL) *\n(1.0+(diffuseFresnel90-1.0)*diffuseFresnelNV);\nreturn fresnel/PI;\n}\n\nvec3 computeSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float roughness,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor) {\nroughness=max(roughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=smithVisibility_TrowbridgeReitzGGXFast(NdotL,NdotV,alphaG);\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nvec3 computeAnisotropicSpecularTerm(float NdotH,float NdotL,float NdotV,float VdotH,float TdotH,float BdotH,float TdotV,float BdotV,float TdotL,float BdotL,float roughness,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor) {\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 alphaTB=getAnisotropicRoughness(alphaG,anisotropy);\nalphaTB=max(alphaTB,geometricRoughnessFactor*geometricRoughnessFactor);\nfloat distribution=normalDistributionFunction_BurleyGGX_Anisotropic(NdotH,TdotH,BdotH,alphaTB);\nfloat visibility=smithVisibility_GGXCorrelated_Anisotropic(NdotV,NdotL,TdotV,BdotV,TdotL,BdotL,alphaTB);\nfloat specTerm=max(0.,visibility*distribution);\nvec3 fresnel=fresnelSchlickGGX(VdotH,reflectance0,reflectance90);\nreturn fresnel*specTerm;\n}\nvec2 computeClearCoatTerm(float NdotH,float VdotH,float clearCoatRoughness,float geometricRoughnessFactor,float clearCoatIntensity) {\nclearCoatRoughness=max(clearCoatRoughness,geometricRoughnessFactor);\nfloat alphaG=convertRoughnessToAverageSlope(clearCoatRoughness);\nfloat distribution=normalDistributionFunction_TrowbridgeReitzGGX(NdotH,alphaG);\nfloat visibility=kelemenVisibility(VdotH);\nfloat clearCoatTerm=max(0.,visibility*distribution);\nfloat fresnel=fresnelSchlickGGX(VdotH,CLEARCOATREFLECTANCE0,CLEARCOATREFLECTANCE90);\nfresnel*=clearCoatIntensity;\nreturn vec2(fresnel*clearCoatTerm,1.0-fresnel);\n}\nfloat adjustRoughnessFromLightProperties(float roughness,float lightRadius,float lightDistance)\n{\n#if defined(USEPHYSICALLIGHTFALLOFF) || defined(USEGLTFLIGHTFALLOFF)\n\nfloat lightRoughness=lightRadius/lightDistance;\n\nfloat totalRoughness=clamp(lightRoughness+roughness,0.,1.);\nreturn totalRoughness;\n#else\nreturn roughness;\n#endif\n}\nfloat computeDefaultMicroSurface(float microSurface,vec3 reflectivityColor)\n{\nconst float kReflectivityNoAlphaWorkflow_SmoothnessMax=0.95;\nfloat reflectivityLuminance=getLuminance(reflectivityColor);\nfloat reflectivityLuma=sqrt(reflectivityLuminance);\nmicroSurface=reflectivityLuma*kReflectivityNoAlphaWorkflow_SmoothnessMax;\nreturn microSurface;\n}\n\n\nfloat fresnelGrazingReflectance(float reflectance0) {\nfloat reflectance90=clamp(reflectance0*25.0,0.0,1.0);\nreturn reflectance90;\n}\n\n\n#define UNPACK_LOD(x) (1.0-x)*255.0\nfloat getLodFromAlphaG(float cubeMapDimensionPixels,float alphaG,float NdotV) {\nfloat microsurfaceAverageSlope=alphaG;\n\n\n\n\n\n\nmicrosurfaceAverageSlope*=sqrt(abs(NdotV));\nfloat microsurfaceAverageSlopeTexels=microsurfaceAverageSlope*cubeMapDimensionPixels;\nfloat lod=log2(microsurfaceAverageSlopeTexels);\nreturn lod;\n}\nfloat environmentRadianceOcclusion(float ambientOcclusion,float NdotVUnclamped) {\n\n\nfloat temp=NdotVUnclamped+ambientOcclusion;\nreturn clamp(square(temp)-1.0+ambientOcclusion,0.0,1.0);\n}\nfloat environmentHorizonOcclusion(vec3 view,vec3 normal) {\n\nvec3 reflection=reflect(view,normal);\nfloat temp=clamp( 1.0+1.1*dot(reflection,normal),0.0,1.0);\nreturn square(temp);\n}";
  124108. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124109. /** @hidden */
  124110. var pbrFunctions = { name: name, shader: shader };
  124111. /***/ }),
  124112. /***/ "./Shaders/ShadersInclude/pbrLightingFunctions.ts":
  124113. /*!********************************************************!*\
  124114. !*** ./Shaders/ShadersInclude/pbrLightingFunctions.ts ***!
  124115. \********************************************************/
  124116. /*! exports provided: pbrLightingFunctions */
  124117. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124118. "use strict";
  124119. __webpack_require__.r(__webpack_exports__);
  124120. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrLightingFunctions", function() { return pbrLightingFunctions; });
  124121. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124122. var name = 'pbrLightingFunctions';
  124123. var shader = "\nstruct lightingInfo\n{\nvec3 diffuse;\n#ifdef SPECULARTERM\nvec3 specular;\n#endif\n#ifdef CLEARCOAT\n\n\nvec4 clearCoat;\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=computeDiffuseTerm(info.NdotL,info.NdotV,info.VdotH,info.roughness);\nreturn diffuseTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeSpecularLighting(preLightingInfo info,vec3 N,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=clamp(dot(N,info.H),0.000000000001,1.0);\nvec3 specTerm=computeSpecularTerm(NdotH,info.NdotL,info.NdotV,info.VdotH,info.roughness,reflectance0,reflectance90,geometricRoughnessFactor);\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec3 computeAnisotropicSpecularLighting(preLightingInfo info,vec3 V,vec3 N,vec3 T,vec3 B,float anisotropy,vec3 reflectance0,vec3 reflectance90,float geometricRoughnessFactor,vec3 lightColor) {\nfloat NdotH=clamp(dot(N,info.H),0.000000000001,1.0);\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);\nvec3 specTerm=computeAnisotropicSpecularTerm(NdotH,info.NdotL,info.NdotV,info.VdotH,TdotH,BdotH,TdotV,BdotV,TdotL,BdotL,info.roughness,anisotropy,reflectance0,reflectance90,geometricRoughnessFactor);\nreturn specTerm*info.attenuation*info.NdotL*lightColor;\n}\nvec4 computeClearCoatLighting(preLightingInfo info,vec3 Ncc,float geometricRoughnessFactor,float clearCoatIntensity,vec3 lightColor) {\nfloat NccdotL=clamp(dot(Ncc,info.L),0.00000000001,1.0);\nfloat NccdotH=clamp(dot(Ncc,info.H),0.000000000001,1.0);\nvec2 clearCoatTerm=computeClearCoatTerm(NccdotH,info.VdotH,info.roughness,geometricRoughnessFactor,clearCoatIntensity);\nvec4 result=vec4(0.);\nresult.rgb=clearCoatTerm.x*info.attenuation*NccdotL*lightColor;\nresult.a=clearCoatTerm.y;\nreturn result;\n}\nvec3 computeProjectionTextureDiffuseLighting(sampler2D projectionLightSampler,mat4 textureProjectionMatrix){\nvec4 strq=textureProjectionMatrix*vec4(vPositionW,1.0);\nstrq/=strq.w;\nvec3 textureColor=texture2D(projectionLightSampler,strq.xy).rgb;\nreturn toLinearSpace(textureColor);\n}\n";
  124124. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124125. /** @hidden */
  124126. var pbrLightingFunctions = { name: name, shader: shader };
  124127. /***/ }),
  124128. /***/ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts":
  124129. /*!***********************************************************!*\
  124130. !*** ./Shaders/ShadersInclude/pbrPreLightingFunctions.ts ***!
  124131. \***********************************************************/
  124132. /*! exports provided: pbrPreLightingFunctions */
  124133. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124134. "use strict";
  124135. __webpack_require__.r(__webpack_exports__);
  124136. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPreLightingFunctions", function() { return pbrPreLightingFunctions; });
  124137. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124138. var name = 'pbrPreLightingFunctions';
  124139. var shader = "\nstruct preLightingInfo\n{\n\nvec3 lightOffset;\nfloat lightDistanceSquared;\nfloat lightDistance;\n\nfloat attenuation;\n\nvec3 L;\nvec3 H;\nfloat NdotV;\nfloat NdotL;\nfloat VdotH;\nfloat roughness;\n};\npreLightingInfo computePointAndSpotPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightOffset=lightData.xyz-vPositionW;\nresult.lightDistanceSquared=dot(result.lightOffset,result.lightOffset);\n\nresult.lightDistance=sqrt(result.lightDistanceSquared);\n\nresult.L=normalize(result.lightOffset);\nresult.H=normalize(V+result.L);\nresult.NdotL=clamp(dot(N,result.L),0.000000000001,1.0);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\nreturn result;\n}\npreLightingInfo computeDirectionalPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.lightDistance=length(-lightData.xyz);\n\nresult.L=normalize(-lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.NdotL=clamp(dot(N,result.L),0.00000000001,1.0);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\nreturn result;\n}\npreLightingInfo computeHemisphericPreLightingInfo(vec4 lightData,vec3 V,vec3 N) {\npreLightingInfo result;\n\nresult.NdotL=dot(N,lightData.xyz)*0.5+0.5;\nresult.NdotL=clamp(result.NdotL,0.000000000001,1.0);\n#ifdef SPECULARTERM\nresult.L=normalize(lightData.xyz);\nresult.H=normalize(V+result.L);\nresult.VdotH=clamp(dot(V,result.H),0.0,1.0);\n#endif\nreturn result;\n}";
  124140. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124141. /** @hidden */
  124142. var pbrPreLightingFunctions = { name: name, shader: shader };
  124143. /***/ }),
  124144. /***/ "./Shaders/ShadersInclude/pbrUboDeclaration.ts":
  124145. /*!*****************************************************!*\
  124146. !*** ./Shaders/ShadersInclude/pbrUboDeclaration.ts ***!
  124147. \*****************************************************/
  124148. /*! exports provided: pbrUboDeclaration */
  124149. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124150. "use strict";
  124151. __webpack_require__.r(__webpack_exports__);
  124152. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrUboDeclaration", function() { return pbrUboDeclaration; });
  124153. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124154. var name = 'pbrUboDeclaration';
  124155. var shader = "layout(std140,column_major) uniform;\nuniform Material\n{\nuniform vec2 vAlbedoInfos;\nuniform vec4 vAmbientInfos;\nuniform vec2 vOpacityInfos;\nuniform vec2 vEmissiveInfos;\nuniform vec2 vLightmapInfos;\nuniform vec3 vReflectivityInfos;\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform vec4 vRefractionInfos;\nuniform vec2 vReflectionInfos;\nuniform vec3 vReflectionPosition;\nuniform vec3 vReflectionSize;\nuniform vec3 vBumpInfos;\nuniform mat4 albedoMatrix;\nuniform mat4 ambientMatrix;\nuniform mat4 opacityMatrix;\nuniform mat4 emissiveMatrix;\nuniform mat4 lightmapMatrix;\nuniform mat4 reflectivityMatrix;\nuniform mat4 microSurfaceSamplerMatrix;\nuniform mat4 bumpMatrix;\nuniform vec2 vTangentSpaceParams;\nuniform mat4 refractionMatrix;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionColor;\nuniform vec4 vAlbedoColor;\nuniform vec4 vLightingIntensity;\nuniform vec3 vRefractionMicrosurfaceInfos;\nuniform vec3 vReflectionMicrosurfaceInfos;\nuniform vec4 vReflectivityColor;\nuniform vec3 vEmissiveColor;\nuniform float pointSize;\nuniform vec2 vClearCoatParams;\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\nuniform vec2 vClearCoatBumpInfos;\nuniform vec2 vClearCoatTangentSpaceParams;\nuniform mat4 clearCoatBumpMatrix;\nuniform float anisotropy;\n};\nuniform Scene {\nmat4 viewProjection;\nmat4 view;\n};";
  124156. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124157. /** @hidden */
  124158. var pbrUboDeclaration = { name: name, shader: shader };
  124159. /***/ }),
  124160. /***/ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts":
  124161. /*!********************************************************!*\
  124162. !*** ./Shaders/ShadersInclude/pbrVertexDeclaration.ts ***!
  124163. \********************************************************/
  124164. /*! exports provided: pbrVertexDeclaration */
  124165. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124166. "use strict";
  124167. __webpack_require__.r(__webpack_exports__);
  124168. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexDeclaration", function() { return pbrVertexDeclaration; });
  124169. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124170. var name = 'pbrVertexDeclaration';
  124171. var shader = "uniform mat4 view;\nuniform mat4 viewProjection;\n#ifdef ALBEDO\nuniform mat4 albedoMatrix;\nuniform vec2 vAlbedoInfos;\n#endif\n#ifdef AMBIENT\nuniform mat4 ambientMatrix;\nuniform vec4 vAmbientInfos;\n#endif\n#ifdef OPACITY\nuniform mat4 opacityMatrix;\nuniform vec2 vOpacityInfos;\n#endif\n#ifdef EMISSIVE\nuniform vec2 vEmissiveInfos;\nuniform mat4 emissiveMatrix;\n#endif\n#ifdef LIGHTMAP\nuniform vec2 vLightmapInfos;\nuniform mat4 lightmapMatrix;\n#endif\n#ifdef REFLECTIVITY\nuniform vec3 vReflectivityInfos;\nuniform mat4 reflectivityMatrix;\n#endif\n#ifdef MICROSURFACEMAP\nuniform vec2 vMicroSurfaceSamplerInfos;\nuniform mat4 microSurfaceSamplerMatrix;\n#endif\n#ifdef BUMP\nuniform vec3 vBumpInfos;\nuniform mat4 bumpMatrix;\n#endif\n#ifdef POINTSIZE\nuniform float pointSize;\n#endif\n\n#ifdef REFRACTION\nuniform vec4 vRefractionInfos;\nuniform mat4 refractionMatrix;\nuniform vec3 vRefractionMicrosurfaceInfos;\n#endif\n\n#ifdef REFLECTION\nuniform vec2 vReflectionInfos;\nuniform mat4 reflectionMatrix;\nuniform vec3 vReflectionMicrosurfaceInfos;\n#endif\n\n#ifdef CLEARCOAT\n#ifdef CLEARCOAT_TEXTURE\nuniform vec2 vClearCoatInfos;\nuniform mat4 clearCoatMatrix;\n#endif\n#ifdef CLEARCOAT_BUMP\nuniform vec2 vClearCoatBumpInfos;\nuniform mat4 clearCoatBumpMatrix;\n#endif\n#endif\n";
  124172. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124173. /** @hidden */
  124174. var pbrVertexDeclaration = { name: name, shader: shader };
  124175. /***/ }),
  124176. /***/ "./Shaders/ShadersInclude/pointCloudVertex.ts":
  124177. /*!****************************************************!*\
  124178. !*** ./Shaders/ShadersInclude/pointCloudVertex.ts ***!
  124179. \****************************************************/
  124180. /*! exports provided: pointCloudVertex */
  124181. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124182. "use strict";
  124183. __webpack_require__.r(__webpack_exports__);
  124184. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pointCloudVertex", function() { return pointCloudVertex; });
  124185. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124186. var name = 'pointCloudVertex';
  124187. var shader = "#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif";
  124188. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124189. /** @hidden */
  124190. var pointCloudVertex = { name: name, shader: shader };
  124191. /***/ }),
  124192. /***/ "./Shaders/ShadersInclude/reflectionFunction.ts":
  124193. /*!******************************************************!*\
  124194. !*** ./Shaders/ShadersInclude/reflectionFunction.ts ***!
  124195. \******************************************************/
  124196. /*! exports provided: reflectionFunction */
  124197. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124198. "use strict";
  124199. __webpack_require__.r(__webpack_exports__);
  124200. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "reflectionFunction", function() { return reflectionFunction; });
  124201. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124202. var name = 'reflectionFunction';
  124203. 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}";
  124204. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124205. /** @hidden */
  124206. var reflectionFunction = { name: name, shader: shader };
  124207. /***/ }),
  124208. /***/ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts":
  124209. /*!************************************************************!*\
  124210. !*** ./Shaders/ShadersInclude/shadowsFragmentFunctions.ts ***!
  124211. \************************************************************/
  124212. /*! exports provided: shadowsFragmentFunctions */
  124213. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124214. "use strict";
  124215. __webpack_require__.r(__webpack_exports__);
  124216. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsFragmentFunctions", function() { return shadowsFragmentFunctions; });
  124217. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124218. var name = 'shadowsFragmentFunctions';
  124219. var shader = "#ifdef SHADOWS\n#ifndef SHADOWFLOAT\nfloat unpack(vec4 color)\n{\nconst vec4 bit_shift=vec4(1.0/(255.0*255.0*255.0),1.0/(255.0*255.0),1.0/255.0,1.0);\nreturn dot(color,bit_shift);\n}\n#endif\nfloat computeShadowCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadow=textureCube(shadowSampler,directionToLight).x;\n#endif\nif (depth>shadow)\n{\nreturn darkness;\n}\nreturn 1.0;\n}\nfloat computeShadowWithPoissonSamplingCube(vec3 lightPosition,samplerCube shadowSampler,float mapSize,float darkness,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\ndepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\nfloat visibility=1.;\nvec3 poissonDisk[4];\npoissonDisk[0]=vec3(-1.0,1.0,-1.0);\npoissonDisk[1]=vec3(1.0,-1.0,-1.0);\npoissonDisk[2]=vec3(-1.0,-1.0,-1.0);\npoissonDisk[3]=vec3(1.0,-1.0,1.0);\n\n#ifndef SHADOWFLOAT\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize))<depth) visibility-=0.25;\nif (unpack(textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize))<depth) visibility-=0.25;\n#else\nif (textureCube(shadowSampler,directionToLight+poissonDisk[0]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[1]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[2]*mapSize).x<depth) visibility-=0.25;\nif (textureCube(shadowSampler,directionToLight+poissonDisk[3]*mapSize).x<depth) visibility-=0.25;\n#endif\nreturn min(1.0,visibility+darkness);\n}\nfloat computeShadowWithESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn esm;\n}\nfloat computeShadowWithCloseESMCube(vec3 lightPosition,samplerCube shadowSampler,float darkness,float depthScale,vec2 depthValues)\n{\nvec3 directionToLight=vPositionW-lightPosition;\nfloat depth=length(directionToLight);\ndepth=(depth+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depth,0.,1.0);\ndirectionToLight=normalize(directionToLight);\ndirectionToLight.y=-directionToLight.y;\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(textureCube(shadowSampler,directionToLight));\n#else\nfloat shadowMapSample=textureCube(shadowSampler,directionToLight).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn esm;\n}\nfloat computeShadow(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadow=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadow=texture2D(shadowSampler,uv).x;\n#endif\nif (shadowPixelDepth>shadow)\n{\nreturn computeFallOff(darkness,clipSpace.xy,frustumEdgeFalloff);\n}\nreturn 1.;\n}\nfloat computeShadowWithPoissonSampling(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float mapSize,float darkness,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\nfloat visibility=1.;\nvec2 poissonDisk[4];\npoissonDisk[0]=vec2(-0.94201624,-0.39906216);\npoissonDisk[1]=vec2(0.94558609,-0.76890725);\npoissonDisk[2]=vec2(-0.094184101,-0.92938870);\npoissonDisk[3]=vec2(0.34495938,0.29387760);\n\n#ifndef SHADOWFLOAT\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[0]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[1]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[2]*mapSize))<shadowPixelDepth) visibility-=0.25;\nif (unpack(texture2D(shadowSampler,uv+poissonDisk[3]*mapSize))<shadowPixelDepth) visibility-=0.25;\n#else\nif (texture2D(shadowSampler,uv+poissonDisk[0]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[1]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[2]*mapSize).x<shadowPixelDepth) visibility-=0.25;\nif (texture2D(shadowSampler,uv+poissonDisk[3]*mapSize).x<shadowPixelDepth) visibility-=0.25;\n#endif\nreturn computeFallOff(min(1.0,visibility+darkness),clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=1.0-clamp(exp(min(87.,depthScale*shadowPixelDepth))*shadowMapSample,0.,1.-darkness);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithCloseESM(vec4 vPositionFromLight,float depthMetric,sampler2D shadowSampler,float darkness,float depthScale,float frustumEdgeFalloff)\n{\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec2 uv=0.5*clipSpace.xy+vec2(0.5);\nif (uv.x<0. || uv.x>1.0 || uv.y<0. || uv.y>1.0)\n{\nreturn 1.0;\n}\nfloat shadowPixelDepth=clamp(depthMetric,0.,1.0);\n#ifndef SHADOWFLOAT\nfloat shadowMapSample=unpack(texture2D(shadowSampler,uv));\n#else\nfloat shadowMapSample=texture2D(shadowSampler,uv).x;\n#endif\nfloat esm=clamp(exp(min(87.,-depthScale*(shadowPixelDepth-shadowMapSample))),darkness,1.);\nreturn computeFallOff(esm,clipSpace.xy,frustumEdgeFalloff);\n}\n#ifdef WEBGL2\n\nfloat computeShadowWithPCF1(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat shadow=texture2D(shadowSampler,uvDepth);\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF3(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\n\n\nvec2 uvw0=3.-2.*st;\nvec2 uvw1=1.+2.*st;\nvec2 u=vec2((2.-st.x)/uvw0.x-1.,st.x/uvw1.x+1.)*shadowMapSizeAndInverse.y;\nvec2 v=vec2((2.-st.y)/uvw0.y-1.,st.y/uvw1.y+1.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow=shadow/16.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\n\n\n\nfloat computeShadowWithPCF5(vec4 vPositionFromLight,float depthMetric,sampler2DShadow shadowSampler,vec2 shadowMapSizeAndInverse,float darkness,float frustumEdgeFalloff)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nvec2 uv=uvDepth.xy*shadowMapSizeAndInverse.x;\nuv+=0.5;\nvec2 st=fract(uv);\nvec2 base_uv=floor(uv)-0.5;\nbase_uv*=shadowMapSizeAndInverse.y;\n\n\nvec2 uvw0=4.-3.*st;\nvec2 uvw1=vec2(7.);\nvec2 uvw2=1.+3.*st;\nvec3 u=vec3((3.-2.*st.x)/uvw0.x-2.,(3.+st.x)/uvw1.x,st.x/uvw2.x+2.)*shadowMapSizeAndInverse.y;\nvec3 v=vec3((3.-2.*st.y)/uvw0.y-2.,(3.+st.y)/uvw1.y,st.y/uvw2.y+2.)*shadowMapSizeAndInverse.y;\nfloat shadow=0.;\nshadow+=uvw0.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[0]),uvDepth.z));\nshadow+=uvw1.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[0]),uvDepth.z));\nshadow+=uvw2.x*uvw0.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[0]),uvDepth.z));\nshadow+=uvw0.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[1]),uvDepth.z));\nshadow+=uvw1.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[1]),uvDepth.z));\nshadow+=uvw2.x*uvw1.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[1]),uvDepth.z));\nshadow+=uvw0.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[0],v[2]),uvDepth.z));\nshadow+=uvw1.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[1],v[2]),uvDepth.z));\nshadow+=uvw2.x*uvw2.y*texture2D(shadowSampler,vec3(base_uv.xy+vec2(u[2],v[2]),uvDepth.z));\nshadow=shadow/144.;\nshadow=mix(darkness,1.,shadow);\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nconst vec3 PoissonSamplers32[64]=vec3[64](\nvec3(0.06407013,0.05409927,0.),\nvec3(0.7366577,0.5789394,0.),\nvec3(-0.6270542,-0.5320278,0.),\nvec3(-0.4096107,0.8411095,0.),\nvec3(0.6849564,-0.4990818,0.),\nvec3(-0.874181,-0.04579735,0.),\nvec3(0.9989998,0.0009880066,0.),\nvec3(-0.004920578,-0.9151649,0.),\nvec3(0.1805763,0.9747483,0.),\nvec3(-0.2138451,0.2635818,0.),\nvec3(0.109845,0.3884785,0.),\nvec3(0.06876755,-0.3581074,0.),\nvec3(0.374073,-0.7661266,0.),\nvec3(0.3079132,-0.1216763,0.),\nvec3(-0.3794335,-0.8271583,0.),\nvec3(-0.203878,-0.07715034,0.),\nvec3(0.5912697,0.1469799,0.),\nvec3(-0.88069,0.3031784,0.),\nvec3(0.5040108,0.8283722,0.),\nvec3(-0.5844124,0.5494877,0.),\nvec3(0.6017799,-0.1726654,0.),\nvec3(-0.5554981,0.1559997,0.),\nvec3(-0.3016369,-0.3900928,0.),\nvec3(-0.5550632,-0.1723762,0.),\nvec3(0.925029,0.2995041,0.),\nvec3(-0.2473137,0.5538505,0.),\nvec3(0.9183037,-0.2862392,0.),\nvec3(0.2469421,0.6718712,0.),\nvec3(0.3916397,-0.4328209,0.),\nvec3(-0.03576927,-0.6220032,0.),\nvec3(-0.04661255,0.7995201,0.),\nvec3(0.4402924,0.3640312,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.),\nvec3(0.,0.,0.)\n);\nconst vec3 PoissonSamplers64[64]=vec3[64](\nvec3(-0.613392,0.617481,0.),\nvec3(0.170019,-0.040254,0.),\nvec3(-0.299417,0.791925,0.),\nvec3(0.645680,0.493210,0.),\nvec3(-0.651784,0.717887,0.),\nvec3(0.421003,0.027070,0.),\nvec3(-0.817194,-0.271096,0.),\nvec3(-0.705374,-0.668203,0.),\nvec3(0.977050,-0.108615,0.),\nvec3(0.063326,0.142369,0.),\nvec3(0.203528,0.214331,0.),\nvec3(-0.667531,0.326090,0.),\nvec3(-0.098422,-0.295755,0.),\nvec3(-0.885922,0.215369,0.),\nvec3(0.566637,0.605213,0.),\nvec3(0.039766,-0.396100,0.),\nvec3(0.751946,0.453352,0.),\nvec3(0.078707,-0.715323,0.),\nvec3(-0.075838,-0.529344,0.),\nvec3(0.724479,-0.580798,0.),\nvec3(0.222999,-0.215125,0.),\nvec3(-0.467574,-0.405438,0.),\nvec3(-0.248268,-0.814753,0.),\nvec3(0.354411,-0.887570,0.),\nvec3(0.175817,0.382366,0.),\nvec3(0.487472,-0.063082,0.),\nvec3(-0.084078,0.898312,0.),\nvec3(0.488876,-0.783441,0.),\nvec3(0.470016,0.217933,0.),\nvec3(-0.696890,-0.549791,0.),\nvec3(-0.149693,0.605762,0.),\nvec3(0.034211,0.979980,0.),\nvec3(0.503098,-0.308878,0.),\nvec3(-0.016205,-0.872921,0.),\nvec3(0.385784,-0.393902,0.),\nvec3(-0.146886,-0.859249,0.),\nvec3(0.643361,0.164098,0.),\nvec3(0.634388,-0.049471,0.),\nvec3(-0.688894,0.007843,0.),\nvec3(0.464034,-0.188818,0.),\nvec3(-0.440840,0.137486,0.),\nvec3(0.364483,0.511704,0.),\nvec3(0.034028,0.325968,0.),\nvec3(0.099094,-0.308023,0.),\nvec3(0.693960,-0.366253,0.),\nvec3(0.678884,-0.204688,0.),\nvec3(0.001801,0.780328,0.),\nvec3(0.145177,-0.898984,0.),\nvec3(0.062655,-0.611866,0.),\nvec3(0.315226,-0.604297,0.),\nvec3(-0.780145,0.486251,0.),\nvec3(-0.371868,0.882138,0.),\nvec3(0.200476,0.494430,0.),\nvec3(-0.494552,-0.711051,0.),\nvec3(0.612476,0.705252,0.),\nvec3(-0.578845,-0.768792,0.),\nvec3(-0.772454,-0.090976,0.),\nvec3(0.504440,0.372295,0.),\nvec3(0.155736,0.065157,0.),\nvec3(0.391522,0.849605,0.),\nvec3(-0.620106,-0.328104,0.),\nvec3(0.789239,-0.419965,0.),\nvec3(-0.545396,0.538133,0.),\nvec3(-0.178564,-0.596057,0.)\n);\n\n\n\n\n\nfloat computeShadowWithPCSS(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff,int searchTapCount,int pcfTapCount,vec3[64] poissonSamplers)\n{\nif (depthMetric>1.0 || depthMetric<0.0) {\nreturn 1.0;\n}\nvec3 clipSpace=vPositionFromLight.xyz/vPositionFromLight.w;\nvec3 uvDepth=vec3(0.5*clipSpace.xyz+vec3(0.5));\nfloat blockerDepth=0.0;\nfloat sumBlockerDepth=0.0;\nfloat numBlocker=0.0;\nfor (int i=0; i<searchTapCount; i ++) {\nblockerDepth=texture(depthSampler,uvDepth.xy+(lightSizeUV*shadowMapSizeInverse*PoissonSamplers32[i].xy)).r;\nif (blockerDepth<depthMetric) {\nsumBlockerDepth+=blockerDepth;\nnumBlocker++;\n}\n}\nif (numBlocker<1.0) {\nreturn 1.0;\n}\nfloat avgBlockerDepth=sumBlockerDepth/numBlocker;\n\nfloat AAOffset=shadowMapSizeInverse*10.;\n\n\nfloat penumbraRatio=((depthMetric-avgBlockerDepth)+AAOffset);\nfloat filterRadius=penumbraRatio*lightSizeUV*shadowMapSizeInverse;\nfloat random=getRand(vPositionFromLight.xy);\nfloat rotationAngle=random*3.1415926;\nvec2 rotationVector=vec2(cos(rotationAngle),sin(rotationAngle));\nfloat shadow=0.;\nfor (int i=0; i<pcfTapCount; i++) {\nvec3 offset=poissonSamplers[i];\n\noffset=vec3(offset.x*rotationVector.x-offset.y*rotationVector.y,offset.y*rotationVector.x+offset.x*rotationVector.y,0.);\nshadow+=texture2D(shadowSampler,uvDepth+offset*filterRadius);\n}\nshadow/=float(pcfTapCount);\n\nshadow=mix(shadow,1.,depthMetric-avgBlockerDepth);\n\nshadow=mix(darkness,1.,shadow);\n\nreturn computeFallOff(shadow,clipSpace.xy,frustumEdgeFalloff);\n}\nfloat computeShadowWithPCSS16(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,16,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS32(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,16,32,PoissonSamplers32);\n}\nfloat computeShadowWithPCSS64(vec4 vPositionFromLight,float depthMetric,sampler2D depthSampler,sampler2DShadow shadowSampler,float shadowMapSizeInverse,float lightSizeUV,float darkness,float frustumEdgeFalloff)\n{\nreturn computeShadowWithPCSS(vPositionFromLight,depthMetric,depthSampler,shadowSampler,shadowMapSizeInverse,lightSizeUV,darkness,frustumEdgeFalloff,32,64,PoissonSamplers64);\n}\n#endif\n#endif\n";
  124220. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124221. /** @hidden */
  124222. var shadowsFragmentFunctions = { name: name, shader: shader };
  124223. /***/ }),
  124224. /***/ "./Shaders/ShadersInclude/shadowsVertex.ts":
  124225. /*!*************************************************!*\
  124226. !*** ./Shaders/ShadersInclude/shadowsVertex.ts ***!
  124227. \*************************************************/
  124228. /*! exports provided: shadowsVertex */
  124229. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124230. "use strict";
  124231. __webpack_require__.r(__webpack_exports__);
  124232. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowsVertex", function() { return shadowsVertex; });
  124233. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../../Materials/effect */ "./Materials/effect.ts");
  124234. var name = 'shadowsVertex';
  124235. 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";
  124236. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].IncludesShadersStore[name] = shader;
  124237. /** @hidden */
  124238. var shadowsVertex = { name: name, shader: shader };
  124239. /***/ }),
  124240. /***/ "./Shaders/anaglyph.fragment.ts":
  124241. /*!**************************************!*\
  124242. !*** ./Shaders/anaglyph.fragment.ts ***!
  124243. \**************************************/
  124244. /*! exports provided: anaglyphPixelShader */
  124245. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124246. "use strict";
  124247. __webpack_require__.r(__webpack_exports__);
  124248. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "anaglyphPixelShader", function() { return anaglyphPixelShader; });
  124249. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124250. var name = 'anaglyphPixelShader';
  124251. 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}";
  124252. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124253. /** @hidden */
  124254. var anaglyphPixelShader = { name: name, shader: shader };
  124255. /***/ }),
  124256. /***/ "./Shaders/background.fragment.ts":
  124257. /*!****************************************!*\
  124258. !*** ./Shaders/background.fragment.ts ***!
  124259. \****************************************/
  124260. /*! exports provided: backgroundPixelShader */
  124261. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124262. "use strict";
  124263. __webpack_require__.r(__webpack_exports__);
  124264. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundPixelShader", function() { return backgroundPixelShader; });
  124265. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124266. /* harmony import */ var _ShadersInclude_backgroundFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundFragmentDeclaration */ "./Shaders/ShadersInclude/backgroundFragmentDeclaration.ts");
  124267. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  124268. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124269. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124270. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124271. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124272. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124273. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  124274. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124275. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124276. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124277. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124278. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124279. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124280. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124281. var name = 'backgroundPixelShader';
  124282. var shader = "#ifdef TEXTURELODSUPPORT\n#extension GL_EXT_shader_texture_lod : enable\n#endif\nprecision highp float;\n#include<__decl__backgroundFragment>\n#define RECIPROCAL_PI2 0.15915494\n\nuniform vec3 vEyePosition;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef TEXTURELODSUPPORT\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n\n#ifndef SHADOWONLY\n#define SHADOWONLY;\n#endif\n#include<imageProcessingDeclaration>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<helperFunctions>\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n#include<imageProcessingFunctions>\n#include<clipPlaneFragmentDeclaration>\n\n#include<fogFragmentDeclaration>\n#ifdef REFLECTIONFRESNEL\n#define FRESNEL_MAXIMUM_ON_ROUGH 0.25\nvec3 fresnelSchlickEnvironmentGGX(float VdotN,vec3 reflectance0,vec3 reflectance90,float smoothness)\n{\n\nfloat weight=mix(FRESNEL_MAXIMUM_ON_ROUGH,1.0,smoothness);\nreturn reflectance0+weight*(reflectance90-reflectance0)*pow(clamp(1.0-VdotN,0.,1.),5.0);\n}\n#endif\nvoid main(void) {\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=vec3(0.0,1.0,0.0);\n#endif\n\nfloat shadow=1.;\nfloat globalShadow=0.;\nfloat shadowLightCount=0.;\n#include<lightFragment>[0..maxSimultaneousLights]\n#ifdef SHADOWINUSE\nglobalShadow/=shadowLightCount;\n#else\nglobalShadow=1.0;\n#endif\n\nvec4 reflectionColor=vec4(1.,1.,1.,1.);\n#ifdef REFLECTION\nvec3 reflectionVector=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\n\n#ifdef REFLECTIONMAP_3D\nvec3 reflectionCoords=reflectionVector;\n#else\nvec2 reflectionCoords=reflectionVector.xy;\n#ifdef REFLECTIONMAP_PROJECTION\nreflectionCoords/=reflectionVector.z;\n#endif\nreflectionCoords.y=1.0-reflectionCoords.y;\n#endif\n#ifdef REFLECTIONBLUR\nfloat reflectionLOD=vReflectionInfos.y;\n#ifdef TEXTURELODSUPPORT\n\nreflectionLOD=reflectionLOD*log2(vReflectionMicrosurfaceInfos.x)*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nreflectionColor=sampleReflectionLod(reflectionSampler,reflectionCoords,reflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD,0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 reflectionSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nreflectionColor=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nreflectionSpecularMid,\nlodReflectionNormalizedDoubled\n);\n} else {\nreflectionColor=mix(\nreflectionSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#else\nvec4 reflectionSample=sampleReflection(reflectionSampler,reflectionCoords);\nreflectionColor=reflectionSample;\n#endif\n#ifdef RGBDREFLECTION\nreflectionColor.rgb=fromRGBD(reflectionColor);\n#endif\n#ifdef GAMMAREFLECTION\nreflectionColor.rgb=toLinearSpace(reflectionColor.rgb);\n#endif\n#ifdef REFLECTIONBGR\nreflectionColor.rgb=reflectionColor.bgr;\n#endif\n\nreflectionColor.rgb*=vReflectionInfos.x;\n#endif\n\nvec3 diffuseColor=vec3(1.,1.,1.);\nfloat finalAlpha=alpha;\n#ifdef DIFFUSE\nvec4 diffuseMap=texture2D(diffuseSampler,vDiffuseUV);\n#ifdef GAMMADIFFUSE\ndiffuseMap.rgb=toLinearSpace(diffuseMap.rgb);\n#endif\n\ndiffuseMap.rgb*=vDiffuseInfos.y;\n#ifdef DIFFUSEHASALPHA\nfinalAlpha*=diffuseMap.a;\n#endif\ndiffuseColor=diffuseMap.rgb;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 colorBase=diffuseColor;\n#else\nvec3 colorBase=reflectionColor.rgb*diffuseColor;\n#endif\ncolorBase=max(colorBase,0.0);\n\n#ifdef USERGBCOLOR\nvec3 finalColor=colorBase;\n#else\n#ifdef USEHIGHLIGHTANDSHADOWCOLORS\nvec3 mainColor=mix(vPrimaryColorShadow.rgb,vPrimaryColor.rgb,colorBase);\n#else\nvec3 mainColor=vPrimaryColor.rgb;\n#endif\nvec3 finalColor=colorBase*mainColor;\n#endif\n\n#ifdef REFLECTIONFRESNEL\nvec3 reflectionAmount=vReflectionControl.xxx;\nvec3 reflectionReflectance0=vReflectionControl.yyy;\nvec3 reflectionReflectance90=vReflectionControl.zzz;\nfloat VdotN=dot(normalize(vEyePosition),normalW);\nvec3 planarReflectionFresnel=fresnelSchlickEnvironmentGGX(clamp(VdotN,0.0,1.0),reflectionReflectance0,reflectionReflectance90,1.0);\nreflectionAmount*=planarReflectionFresnel;\n#ifdef REFLECTIONFALLOFF\nfloat reflectionDistanceFalloff=1.0-clamp(length(vPositionW.xyz-vBackgroundCenter)*vReflectionControl.w,0.0,1.0);\nreflectionDistanceFalloff*=reflectionDistanceFalloff;\nreflectionAmount*=reflectionDistanceFalloff;\n#endif\nfinalColor=mix(finalColor,reflectionColor.rgb,clamp(reflectionAmount,0.,1.));\n#endif\n#ifdef OPACITYFRESNEL\nfloat viewAngleToFloor=dot(normalW,normalize(vEyePosition-vBackgroundCenter));\n\nconst float startAngle=0.1;\nfloat fadeFactor=clamp(viewAngleToFloor/startAngle,0.0,1.0);\nfinalAlpha*=fadeFactor*fadeFactor;\n#endif\n\n#ifdef SHADOWINUSE\nfinalColor=mix(finalColor*shadowLevel,finalColor,globalShadow);\n#endif\n\nvec4 color=vec4(finalColor,finalAlpha);\n#include<fogFragment>\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\ncolor.rgb=clamp(color.rgb,0.,30.0);\n#else\n\ncolor=applyImageProcessing(color);\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#ifdef NOISE\ncolor.rgb+=dither(vPositionW.xy,0.5);\ncolor=max(color,0.0);\n#endif\ngl_FragColor=color;\n}\n";
  124283. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124284. /** @hidden */
  124285. var backgroundPixelShader = { name: name, shader: shader };
  124286. /***/ }),
  124287. /***/ "./Shaders/background.vertex.ts":
  124288. /*!**************************************!*\
  124289. !*** ./Shaders/background.vertex.ts ***!
  124290. \**************************************/
  124291. /*! exports provided: backgroundVertexShader */
  124292. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124293. "use strict";
  124294. __webpack_require__.r(__webpack_exports__);
  124295. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "backgroundVertexShader", function() { return backgroundVertexShader; });
  124296. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124297. /* harmony import */ var _ShadersInclude_backgroundVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/backgroundVertexDeclaration */ "./Shaders/ShadersInclude/backgroundVertexDeclaration.ts");
  124298. /* harmony import */ var _ShadersInclude_backgroundUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/backgroundUboDeclaration */ "./Shaders/ShadersInclude/backgroundUboDeclaration.ts");
  124299. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124300. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124301. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124302. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124303. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124304. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124305. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124306. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124307. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124308. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124309. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124310. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124311. var name = 'backgroundVertexShader';
  124312. var shader = "precision highp float;\n#include<__decl__backgroundVertex>\n#include<helperFunctions>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\nvoid main(void) {\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\nvec4 worldPos=finalWorld*vec4(position,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normal);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(position,0.0)));\n#ifdef EQUIRECTANGULAR_RELFECTION_FOV\nmat3 screenToWorld=inverseMat3(mat3(finalWorld*viewProjection));\nvec3 segment=mix(vDirectionW,screenToWorld*vec3(0.0,0.0,1.0),abs(fFovMultiplier-1.0));\nif (fFovMultiplier<=1.0) {\nvDirectionW=normalize(segment);\n} else {\nvDirectionW=normalize(vDirectionW+(vDirectionW-segment));\n}\n#endif\n#endif\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n\n#include<clipPlaneVertex>\n\n#include<fogVertex>\n\n#include<shadowsVertex>[0..maxSimultaneousLights]\n\n#ifdef VERTEXCOLOR\nvColor=color;\n#endif\n\n#ifdef POINTSIZE\ngl_PointSize=pointSize;\n#endif\n}\n";
  124313. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124314. /** @hidden */
  124315. var backgroundVertexShader = { name: name, shader: shader };
  124316. /***/ }),
  124317. /***/ "./Shaders/blackAndWhite.fragment.ts":
  124318. /*!*******************************************!*\
  124319. !*** ./Shaders/blackAndWhite.fragment.ts ***!
  124320. \*******************************************/
  124321. /*! exports provided: blackAndWhitePixelShader */
  124322. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124323. "use strict";
  124324. __webpack_require__.r(__webpack_exports__);
  124325. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "blackAndWhitePixelShader", function() { return blackAndWhitePixelShader; });
  124326. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124327. var name = 'blackAndWhitePixelShader';
  124328. 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}";
  124329. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124330. /** @hidden */
  124331. var blackAndWhitePixelShader = { name: name, shader: shader };
  124332. /***/ }),
  124333. /***/ "./Shaders/bloomMerge.fragment.ts":
  124334. /*!****************************************!*\
  124335. !*** ./Shaders/bloomMerge.fragment.ts ***!
  124336. \****************************************/
  124337. /*! exports provided: bloomMergePixelShader */
  124338. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124339. "use strict";
  124340. __webpack_require__.r(__webpack_exports__);
  124341. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "bloomMergePixelShader", function() { return bloomMergePixelShader; });
  124342. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124343. var name = 'bloomMergePixelShader';
  124344. 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";
  124345. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124346. /** @hidden */
  124347. var bloomMergePixelShader = { name: name, shader: shader };
  124348. /***/ }),
  124349. /***/ "./Shaders/chromaticAberration.fragment.ts":
  124350. /*!*************************************************!*\
  124351. !*** ./Shaders/chromaticAberration.fragment.ts ***!
  124352. \*************************************************/
  124353. /*! exports provided: chromaticAberrationPixelShader */
  124354. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124355. "use strict";
  124356. __webpack_require__.r(__webpack_exports__);
  124357. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "chromaticAberrationPixelShader", function() { return chromaticAberrationPixelShader; });
  124358. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124359. var name = 'chromaticAberrationPixelShader';
  124360. 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}";
  124361. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124362. /** @hidden */
  124363. var chromaticAberrationPixelShader = { name: name, shader: shader };
  124364. /***/ }),
  124365. /***/ "./Shaders/circleOfConfusion.fragment.ts":
  124366. /*!***********************************************!*\
  124367. !*** ./Shaders/circleOfConfusion.fragment.ts ***!
  124368. \***********************************************/
  124369. /*! exports provided: circleOfConfusionPixelShader */
  124370. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124371. "use strict";
  124372. __webpack_require__.r(__webpack_exports__);
  124373. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "circleOfConfusionPixelShader", function() { return circleOfConfusionPixelShader; });
  124374. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124375. var name = 'circleOfConfusionPixelShader';
  124376. 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";
  124377. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124378. /** @hidden */
  124379. var circleOfConfusionPixelShader = { name: name, shader: shader };
  124380. /***/ }),
  124381. /***/ "./Shaders/color.fragment.ts":
  124382. /*!***********************************!*\
  124383. !*** ./Shaders/color.fragment.ts ***!
  124384. \***********************************/
  124385. /*! exports provided: colorPixelShader */
  124386. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124387. "use strict";
  124388. __webpack_require__.r(__webpack_exports__);
  124389. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorPixelShader", function() { return colorPixelShader; });
  124390. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124391. var name = 'colorPixelShader';
  124392. var shader = "#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#else\nuniform vec4 color;\n#endif\nvoid main(void) {\n#ifdef VERTEXCOLOR\ngl_FragColor=vColor;\n#else\ngl_FragColor=color;\n#endif\n}";
  124393. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124394. /** @hidden */
  124395. var colorPixelShader = { name: name, shader: shader };
  124396. /***/ }),
  124397. /***/ "./Shaders/color.vertex.ts":
  124398. /*!*********************************!*\
  124399. !*** ./Shaders/color.vertex.ts ***!
  124400. \*********************************/
  124401. /*! exports provided: colorVertexShader */
  124402. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124403. "use strict";
  124404. __webpack_require__.r(__webpack_exports__);
  124405. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorVertexShader", function() { return colorVertexShader; });
  124406. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124407. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124408. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124409. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124410. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124411. var name = 'colorVertexShader';
  124412. var shader = "\nattribute vec3 position;\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\nuniform mat4 viewProjection;\n\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\nvoid main(void) {\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(position,1.0);\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n}";
  124413. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124414. /** @hidden */
  124415. var colorVertexShader = { name: name, shader: shader };
  124416. /***/ }),
  124417. /***/ "./Shaders/colorCorrection.fragment.ts":
  124418. /*!*********************************************!*\
  124419. !*** ./Shaders/colorCorrection.fragment.ts ***!
  124420. \*********************************************/
  124421. /*! exports provided: colorCorrectionPixelShader */
  124422. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124423. "use strict";
  124424. __webpack_require__.r(__webpack_exports__);
  124425. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "colorCorrectionPixelShader", function() { return colorCorrectionPixelShader; });
  124426. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124427. var name = 'colorCorrectionPixelShader';
  124428. 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}";
  124429. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124430. /** @hidden */
  124431. var colorCorrectionPixelShader = { name: name, shader: shader };
  124432. /***/ }),
  124433. /***/ "./Shaders/convolution.fragment.ts":
  124434. /*!*****************************************!*\
  124435. !*** ./Shaders/convolution.fragment.ts ***!
  124436. \*****************************************/
  124437. /*! exports provided: convolutionPixelShader */
  124438. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124439. "use strict";
  124440. __webpack_require__.r(__webpack_exports__);
  124441. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convolutionPixelShader", function() { return convolutionPixelShader; });
  124442. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124443. var name = 'convolutionPixelShader';
  124444. 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}";
  124445. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124446. /** @hidden */
  124447. var convolutionPixelShader = { name: name, shader: shader };
  124448. /***/ }),
  124449. /***/ "./Shaders/default.fragment.ts":
  124450. /*!*************************************!*\
  124451. !*** ./Shaders/default.fragment.ts ***!
  124452. \*************************************/
  124453. /*! exports provided: defaultPixelShader */
  124454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124455. "use strict";
  124456. __webpack_require__.r(__webpack_exports__);
  124457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultPixelShader", function() { return defaultPixelShader; });
  124458. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124459. /* harmony import */ var _ShadersInclude_defaultFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultFragmentDeclaration */ "./Shaders/ShadersInclude/defaultFragmentDeclaration.ts");
  124460. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  124461. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124462. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124463. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124464. /* harmony import */ var _ShadersInclude_lightsFragmentFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/lightsFragmentFunctions */ "./Shaders/ShadersInclude/lightsFragmentFunctions.ts");
  124465. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  124466. /* harmony import */ var _ShadersInclude_fresnelFunction__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fresnelFunction */ "./Shaders/ShadersInclude/fresnelFunction.ts");
  124467. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  124468. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124469. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124470. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  124471. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  124472. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124473. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  124474. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124475. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  124476. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  124477. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  124478. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  124479. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  124480. var name = 'defaultPixelShader';
  124481. var shader = "#include<__decl__defaultFragment>\n#if defined(BUMP) || !defined(NORMAL)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#define CUSTOM_FRAGMENT_BEGIN\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\n\n#define RECIPROCAL_PI2 0.15915494\nuniform vec3 vEyePosition;\nuniform vec3 vAmbientColor;\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n\n#include<helperFunctions>\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<lightsFragmentFunctions>\n#include<shadowsFragmentFunctions>\n\n#ifdef DIFFUSE\n#if DIFFUSEDIRECTUV == 1\n#define vDiffuseUV vMainUV1\n#elif DIFFUSEDIRECTUV == 2\n#define vDiffuseUV vMainUV2\n#else\nvarying vec2 vDiffuseUV;\n#endif\nuniform sampler2D diffuseSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\nuniform samplerCube refractionCubeSampler;\n#else\nuniform sampler2D refraction2DSampler;\n#endif\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM)\n#if SPECULARDIRECTUV == 1\n#define vSpecularUV vMainUV1\n#elif SPECULARDIRECTUV == 2\n#define vSpecularUV vMainUV2\n#else\nvarying vec2 vSpecularUV;\n#endif\nuniform sampler2D specularSampler;\n#endif\n#ifdef ALPHATEST\nuniform float alphaCutOff;\n#endif\n\n#include<fresnelFunction>\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\nuniform samplerCube reflectionCubeSampler;\n#else\nuniform sampler2D reflection2DSampler;\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#include<imageProcessingDeclaration>\n#include<imageProcessingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n#include<fogFragmentDeclaration>\n#define CUSTOM_FRAGMENT_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_FRAGMENT_MAIN_BEGIN\n#include<clipPlaneFragment>\nvec3 viewDirectionW=normalize(vEyePosition-vPositionW);\n\nvec4 baseColor=vec4(1.,1.,1.,1.);\nvec3 diffuseColor=vDiffuseColor.rgb;\n\nfloat alpha=vDiffuseColor.a;\n\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(-cross(dFdx(vPositionW),dFdy(vPositionW)));\n#endif\n#include<bumpFragment>\n#ifdef TWOSIDEDLIGHTING\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n#ifdef DIFFUSE\nbaseColor=texture2D(diffuseSampler,vDiffuseUV+uvOffset);\n#ifdef ALPHATEST\nif (baseColor.a<alphaCutOff)\ndiscard;\n#endif\n#ifdef ALPHAFROMDIFFUSE\nalpha*=baseColor.a;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_ALPHA\nbaseColor.rgb*=vDiffuseInfos.y;\n#endif\n#include<depthPrePass>\n#ifdef VERTEXCOLOR\nbaseColor.rgb*=vColor.rgb;\n#endif\n#define CUSTOM_FRAGMENT_UPDATE_DIFFUSE\n\nvec3 baseAmbientColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nbaseAmbientColor=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_LIGHTS\n\n#ifdef SPECULARTERM\nfloat glossiness=vSpecularColor.a;\nvec3 specularColor=vSpecularColor.rgb;\n#ifdef SPECULAR\nvec4 specularMapColor=texture2D(specularSampler,vSpecularUV+uvOffset);\nspecularColor=specularMapColor.rgb;\n#ifdef GLOSSINESS\nglossiness=glossiness*specularMapColor.a;\n#endif\n#endif\n#else\nfloat glossiness=0.;\n#endif\n\nvec3 diffuseBase=vec3(0.,0.,0.);\nlightingInfo info;\n#ifdef SPECULARTERM\nvec3 specularBase=vec3(0.,0.,0.);\n#endif\nfloat shadow=1.;\n#ifdef LIGHTMAP\nvec3 lightmapColor=texture2D(lightmapSampler,vLightmapUV+uvOffset).rgb*vLightmapInfos.y;\n#endif\n#include<lightFragment>[0..maxSimultaneousLights]\n\nvec3 refractionColor=vec3(0.,0.,0.);\n#ifdef REFRACTION\nvec3 refractionVector=normalize(refract(-viewDirectionW,normalW,vRefractionInfos.y));\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nif (dot(refractionVector,viewDirectionW)<1.0) {\nrefractionColor=textureCube(refractionCubeSampler,refractionVector).rgb;\n}\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\nrefractionColor=texture2D(refraction2DSampler,refractionCoords).rgb;\n#endif\n#ifdef IS_REFRACTION_LINEAR\nrefractionColor=toGammaSpace(refractionColor);\n#endif\nrefractionColor*=vRefractionInfos.x;\n#endif\n\nvec3 reflectionColor=vec3(0.,0.,0.);\n#ifdef REFLECTION\nvec3 vReflectionUVW=computeReflectionCoords(vec4(vPositionW,1.0),normalW);\n#ifdef REFLECTIONMAP_3D\n#ifdef ROUGHNESS\nfloat bias=vReflectionInfos.y;\n#ifdef SPECULARTERM\n#ifdef SPECULAR\n#ifdef GLOSSINESS\nbias*=(1.0-specularMapColor.a);\n#endif\n#endif\n#endif\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW,bias).rgb;\n#else\nreflectionColor=textureCube(reflectionCubeSampler,vReflectionUVW).rgb;\n#endif\n#else\nvec2 coords=vReflectionUVW.xy;\n#ifdef REFLECTIONMAP_PROJECTION\ncoords/=vReflectionUVW.z;\n#endif\ncoords.y=1.0-coords.y;\nreflectionColor=texture2D(reflection2DSampler,coords).rgb;\n#endif\n#ifdef IS_REFLECTION_LINEAR\nreflectionColor=toGammaSpace(reflectionColor);\n#endif\nreflectionColor*=vReflectionInfos.x;\n#ifdef REFLECTIONFRESNEL\nfloat reflectionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,reflectionRightColor.a,reflectionLeftColor.a);\n#ifdef REFLECTIONFRESNELFROMSPECULAR\n#ifdef SPECULARTERM\nreflectionColor*=specularColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#else\nreflectionColor*=reflectionLeftColor.rgb*(1.0-reflectionFresnelTerm)+reflectionFresnelTerm*reflectionRightColor.rgb;\n#endif\n#endif\n#endif\n#ifdef REFRACTIONFRESNEL\nfloat refractionFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,refractionRightColor.a,refractionLeftColor.a);\nrefractionColor*=refractionLeftColor.rgb*(1.0-refractionFresnelTerm)+refractionFresnelTerm*refractionRightColor.rgb;\n#endif\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nopacityMap.rgb=opacityMap.rgb*vec3(0.3,0.59,0.11);\nalpha*=(opacityMap.x+opacityMap.y+opacityMap.z)* vOpacityInfos.y;\n#else\nalpha*=opacityMap.a*vOpacityInfos.y;\n#endif\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#ifdef OPACITYFRESNEL\nfloat opacityFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,opacityParts.z,opacityParts.w);\nalpha+=opacityParts.x*(1.0-opacityFresnelTerm)+opacityFresnelTerm*opacityParts.y;\n#endif\n\nvec3 emissiveColor=vEmissiveColor;\n#ifdef EMISSIVE\nemissiveColor+=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb*vEmissiveInfos.y;\n#endif\n#ifdef EMISSIVEFRESNEL\nfloat emissiveFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,emissiveRightColor.a,emissiveLeftColor.a);\nemissiveColor*=emissiveLeftColor.rgb*(1.0-emissiveFresnelTerm)+emissiveFresnelTerm*emissiveRightColor.rgb;\n#endif\n\n#ifdef DIFFUSEFRESNEL\nfloat diffuseFresnelTerm=computeFresnelTerm(viewDirectionW,normalW,diffuseRightColor.a,diffuseLeftColor.a);\ndiffuseBase*=diffuseLeftColor.rgb*(1.0-diffuseFresnelTerm)+diffuseFresnelTerm*diffuseRightColor.rgb;\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\n#ifdef LINKEMISSIVEWITHDIFFUSE\nvec3 finalDiffuse=clamp((diffuseBase+emissiveColor)*diffuseColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#else\nvec3 finalDiffuse=clamp(diffuseBase*diffuseColor+emissiveColor+vAmbientColor,0.0,1.0)*baseColor.rgb;\n#endif\n#endif\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase*specularColor;\n#ifdef SPECULAROVERALPHA\nalpha=clamp(alpha+dot(finalSpecular,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n#else\nvec3 finalSpecular=vec3(0.0);\n#endif\n#ifdef REFLECTIONOVERALPHA\nalpha=clamp(alpha+dot(reflectionColor,vec3(0.3,0.59,0.11)),0.,1.);\n#endif\n\n#ifdef EMISSIVEASILLUMINATION\nvec4 color=vec4(clamp(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+emissiveColor+refractionColor,0.0,1.0),alpha);\n#else\nvec4 color=vec4(finalDiffuse*baseAmbientColor+finalSpecular+reflectionColor+refractionColor,alpha);\n#endif\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\ncolor.rgb*=lightmapColor;\n#else\ncolor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FOG\ncolor.rgb=max(color.rgb,0.);\n#include<logDepthFragment>\n#include<fogFragment>\n\n\n#ifdef IMAGEPROCESSINGPOSTPROCESS\ncolor.rgb=toLinearSpace(color.rgb);\n#else\n#ifdef IMAGEPROCESSING\ncolor.rgb=toLinearSpace(color.rgb);\ncolor=applyImageProcessing(color);\n#endif\n#endif\n#ifdef PREMULTIPLYALPHA\n\ncolor.rgb*=color.a;\n#endif\n#define CUSTOM_FRAGMENT_BEFORE_FRAGCOLOR\ngl_FragColor=color;\n}\n";
  124482. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124483. /** @hidden */
  124484. var defaultPixelShader = { name: name, shader: shader };
  124485. /***/ }),
  124486. /***/ "./Shaders/default.vertex.ts":
  124487. /*!***********************************!*\
  124488. !*** ./Shaders/default.vertex.ts ***!
  124489. \***********************************/
  124490. /*! exports provided: defaultVertexShader */
  124491. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124492. "use strict";
  124493. __webpack_require__.r(__webpack_exports__);
  124494. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "defaultVertexShader", function() { return defaultVertexShader; });
  124495. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124496. /* harmony import */ var _ShadersInclude_defaultVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/defaultVertexDeclaration */ "./Shaders/ShadersInclude/defaultVertexDeclaration.ts");
  124497. /* harmony import */ var _ShadersInclude_defaultUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/defaultUboDeclaration */ "./Shaders/ShadersInclude/defaultUboDeclaration.ts");
  124498. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124499. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124500. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124501. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  124502. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  124503. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  124504. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  124505. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  124506. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124507. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124508. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  124509. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124510. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124511. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124512. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  124513. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124514. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  124515. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  124516. /* harmony import */ var _ShadersInclude_pointCloudVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/pointCloudVertex */ "./Shaders/ShadersInclude/pointCloudVertex.ts");
  124517. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  124518. var name = 'defaultVertexShader';
  124519. var shader = "#include<__decl__defaultVertex>\n\n#define CUSTOM_VERTEX_BEGIN\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nvarying vec2 vDiffuseUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nvarying vec2 vSpecularUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\n#define CUSTOM_VERTEX_DEFINITIONS\nvoid main(void) {\n#define CUSTOM_VERTEX_MAIN_BEGIN\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(position,1.0)).xyz;\n#else\nvPositionUVW=position;\n#endif\n#endif\n#define CUSTOM_VERTEX_UPDATE_POSITION\n#define CUSTOM_VERTEX_UPDATE_NORMAL\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(DIFFUSE) && DIFFUSEDIRECTUV == 0\nif (vDiffuseInfos.x == 0.)\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvDiffuseUV=vec2(diffuseMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(SPECULAR) && defined(SPECULARTERM) && SPECULARDIRECTUV == 0\nif (vSpecularInfos.x == 0.)\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvSpecularUV=vec2(specularMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#include<bumpVertex>\n#include<clipPlaneVertex>\n#include<fogVertex>\n#include<shadowsVertex>[0..maxSimultaneousLights]\n#ifdef VERTEXCOLOR\n\nvColor=color;\n#endif\n#include<pointCloudVertex>\n#include<logDepthVertex>\n#define CUSTOM_VERTEX_MAIN_END\n}\n";
  124520. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124521. /** @hidden */
  124522. var defaultVertexShader = { name: name, shader: shader };
  124523. /***/ }),
  124524. /***/ "./Shaders/depth.fragment.ts":
  124525. /*!***********************************!*\
  124526. !*** ./Shaders/depth.fragment.ts ***!
  124527. \***********************************/
  124528. /*! exports provided: depthPixelShader */
  124529. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124530. "use strict";
  124531. __webpack_require__.r(__webpack_exports__);
  124532. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthPixelShader", function() { return depthPixelShader; });
  124533. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124534. var name = 'depthPixelShader';
  124535. 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}";
  124536. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124537. /** @hidden */
  124538. var depthPixelShader = { name: name, shader: shader };
  124539. /***/ }),
  124540. /***/ "./Shaders/depth.vertex.ts":
  124541. /*!*********************************!*\
  124542. !*** ./Shaders/depth.vertex.ts ***!
  124543. \*********************************/
  124544. /*! exports provided: depthVertexShader */
  124545. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124546. "use strict";
  124547. __webpack_require__.r(__webpack_exports__);
  124548. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthVertexShader", function() { return depthVertexShader; });
  124549. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124550. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124551. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124552. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124553. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124554. var name = 'depthVertexShader';
  124555. 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}";
  124556. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124557. /** @hidden */
  124558. var depthVertexShader = { name: name, shader: shader };
  124559. /***/ }),
  124560. /***/ "./Shaders/depthBoxBlur.fragment.ts":
  124561. /*!******************************************!*\
  124562. !*** ./Shaders/depthBoxBlur.fragment.ts ***!
  124563. \******************************************/
  124564. /*! exports provided: depthBoxBlurPixelShader */
  124565. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124566. "use strict";
  124567. __webpack_require__.r(__webpack_exports__);
  124568. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthBoxBlurPixelShader", function() { return depthBoxBlurPixelShader; });
  124569. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124570. var name = 'depthBoxBlurPixelShader';
  124571. 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}";
  124572. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124573. /** @hidden */
  124574. var depthBoxBlurPixelShader = { name: name, shader: shader };
  124575. /***/ }),
  124576. /***/ "./Shaders/depthOfField.fragment.ts":
  124577. /*!******************************************!*\
  124578. !*** ./Shaders/depthOfField.fragment.ts ***!
  124579. \******************************************/
  124580. /*! exports provided: depthOfFieldPixelShader */
  124581. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124582. "use strict";
  124583. __webpack_require__.r(__webpack_exports__);
  124584. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldPixelShader", function() { return depthOfFieldPixelShader; });
  124585. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124586. var name = 'depthOfFieldPixelShader';
  124587. 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";
  124588. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124589. /** @hidden */
  124590. var depthOfFieldPixelShader = { name: name, shader: shader };
  124591. /***/ }),
  124592. /***/ "./Shaders/depthOfFieldMerge.fragment.ts":
  124593. /*!***********************************************!*\
  124594. !*** ./Shaders/depthOfFieldMerge.fragment.ts ***!
  124595. \***********************************************/
  124596. /*! exports provided: depthOfFieldMergePixelShader */
  124597. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124598. "use strict";
  124599. __webpack_require__.r(__webpack_exports__);
  124600. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "depthOfFieldMergePixelShader", function() { return depthOfFieldMergePixelShader; });
  124601. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124602. var name = 'depthOfFieldMergePixelShader';
  124603. 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";
  124604. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124605. /** @hidden */
  124606. var depthOfFieldMergePixelShader = { name: name, shader: shader };
  124607. /***/ }),
  124608. /***/ "./Shaders/displayPass.fragment.ts":
  124609. /*!*****************************************!*\
  124610. !*** ./Shaders/displayPass.fragment.ts ***!
  124611. \*****************************************/
  124612. /*! exports provided: displayPassPixelShader */
  124613. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124614. "use strict";
  124615. __webpack_require__.r(__webpack_exports__);
  124616. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayPassPixelShader", function() { return displayPassPixelShader; });
  124617. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124618. var name = 'displayPassPixelShader';
  124619. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nuniform sampler2D passSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(passSampler,vUV);\n}";
  124620. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124621. /** @hidden */
  124622. var displayPassPixelShader = { name: name, shader: shader };
  124623. /***/ }),
  124624. /***/ "./Shaders/extractHighlights.fragment.ts":
  124625. /*!***********************************************!*\
  124626. !*** ./Shaders/extractHighlights.fragment.ts ***!
  124627. \***********************************************/
  124628. /*! exports provided: extractHighlightsPixelShader */
  124629. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124630. "use strict";
  124631. __webpack_require__.r(__webpack_exports__);
  124632. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "extractHighlightsPixelShader", function() { return extractHighlightsPixelShader; });
  124633. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124634. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124635. var name = 'extractHighlightsPixelShader';
  124636. 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}";
  124637. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124638. /** @hidden */
  124639. var extractHighlightsPixelShader = { name: name, shader: shader };
  124640. /***/ }),
  124641. /***/ "./Shaders/filter.fragment.ts":
  124642. /*!************************************!*\
  124643. !*** ./Shaders/filter.fragment.ts ***!
  124644. \************************************/
  124645. /*! exports provided: filterPixelShader */
  124646. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124647. "use strict";
  124648. __webpack_require__.r(__webpack_exports__);
  124649. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "filterPixelShader", function() { return filterPixelShader; });
  124650. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124651. var name = 'filterPixelShader';
  124652. 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}";
  124653. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124654. /** @hidden */
  124655. var filterPixelShader = { name: name, shader: shader };
  124656. /***/ }),
  124657. /***/ "./Shaders/fxaa.fragment.ts":
  124658. /*!**********************************!*\
  124659. !*** ./Shaders/fxaa.fragment.ts ***!
  124660. \**********************************/
  124661. /*! exports provided: fxaaPixelShader */
  124662. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124663. "use strict";
  124664. __webpack_require__.r(__webpack_exports__);
  124665. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaPixelShader", function() { return fxaaPixelShader; });
  124666. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124667. var name = 'fxaaPixelShader';
  124668. 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}";
  124669. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124670. /** @hidden */
  124671. var fxaaPixelShader = { name: name, shader: shader };
  124672. /***/ }),
  124673. /***/ "./Shaders/fxaa.vertex.ts":
  124674. /*!********************************!*\
  124675. !*** ./Shaders/fxaa.vertex.ts ***!
  124676. \********************************/
  124677. /*! exports provided: fxaaVertexShader */
  124678. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124679. "use strict";
  124680. __webpack_require__.r(__webpack_exports__);
  124681. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "fxaaVertexShader", function() { return fxaaVertexShader; });
  124682. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124683. var name = 'fxaaVertexShader';
  124684. 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}";
  124685. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124686. /** @hidden */
  124687. var fxaaVertexShader = { name: name, shader: shader };
  124688. /***/ }),
  124689. /***/ "./Shaders/geometry.fragment.ts":
  124690. /*!**************************************!*\
  124691. !*** ./Shaders/geometry.fragment.ts ***!
  124692. \**************************************/
  124693. /*! exports provided: geometryPixelShader */
  124694. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124695. "use strict";
  124696. __webpack_require__.r(__webpack_exports__);
  124697. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryPixelShader", function() { return geometryPixelShader; });
  124698. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124699. /* harmony import */ var _ShadersInclude_mrtFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/mrtFragmentDeclaration */ "./Shaders/ShadersInclude/mrtFragmentDeclaration.ts");
  124700. var name = 'geometryPixelShader';
  124701. 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}";
  124702. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124703. /** @hidden */
  124704. var geometryPixelShader = { name: name, shader: shader };
  124705. /***/ }),
  124706. /***/ "./Shaders/geometry.vertex.ts":
  124707. /*!************************************!*\
  124708. !*** ./Shaders/geometry.vertex.ts ***!
  124709. \************************************/
  124710. /*! exports provided: geometryVertexShader */
  124711. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124712. "use strict";
  124713. __webpack_require__.r(__webpack_exports__);
  124714. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "geometryVertexShader", function() { return geometryVertexShader; });
  124715. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124716. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124717. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124718. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124719. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124720. var name = 'geometryVertexShader';
  124721. 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}";
  124722. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124723. /** @hidden */
  124724. var geometryVertexShader = { name: name, shader: shader };
  124725. /***/ }),
  124726. /***/ "./Shaders/glowBlurPostProcess.fragment.ts":
  124727. /*!*************************************************!*\
  124728. !*** ./Shaders/glowBlurPostProcess.fragment.ts ***!
  124729. \*************************************************/
  124730. /*! exports provided: glowBlurPostProcessPixelShader */
  124731. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124732. "use strict";
  124733. __webpack_require__.r(__webpack_exports__);
  124734. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowBlurPostProcessPixelShader", function() { return glowBlurPostProcessPixelShader; });
  124735. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124736. var name = 'glowBlurPostProcessPixelShader';
  124737. 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}";
  124738. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124739. /** @hidden */
  124740. var glowBlurPostProcessPixelShader = { name: name, shader: shader };
  124741. /***/ }),
  124742. /***/ "./Shaders/glowMapGeneration.fragment.ts":
  124743. /*!***********************************************!*\
  124744. !*** ./Shaders/glowMapGeneration.fragment.ts ***!
  124745. \***********************************************/
  124746. /*! exports provided: glowMapGenerationPixelShader */
  124747. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124748. "use strict";
  124749. __webpack_require__.r(__webpack_exports__);
  124750. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationPixelShader", function() { return glowMapGenerationPixelShader; });
  124751. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124752. var name = 'glowMapGenerationPixelShader';
  124753. 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}";
  124754. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124755. /** @hidden */
  124756. var glowMapGenerationPixelShader = { name: name, shader: shader };
  124757. /***/ }),
  124758. /***/ "./Shaders/glowMapGeneration.vertex.ts":
  124759. /*!*********************************************!*\
  124760. !*** ./Shaders/glowMapGeneration.vertex.ts ***!
  124761. \*********************************************/
  124762. /*! exports provided: glowMapGenerationVertexShader */
  124763. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124764. "use strict";
  124765. __webpack_require__.r(__webpack_exports__);
  124766. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapGenerationVertexShader", function() { return glowMapGenerationVertexShader; });
  124767. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124768. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  124769. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  124770. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  124771. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  124772. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  124773. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  124774. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  124775. var name = 'glowMapGenerationVertexShader';
  124776. 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}";
  124777. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124778. /** @hidden */
  124779. var glowMapGenerationVertexShader = { name: name, shader: shader };
  124780. /***/ }),
  124781. /***/ "./Shaders/glowMapMerge.fragment.ts":
  124782. /*!******************************************!*\
  124783. !*** ./Shaders/glowMapMerge.fragment.ts ***!
  124784. \******************************************/
  124785. /*! exports provided: glowMapMergePixelShader */
  124786. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124787. "use strict";
  124788. __webpack_require__.r(__webpack_exports__);
  124789. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergePixelShader", function() { return glowMapMergePixelShader; });
  124790. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124791. var name = 'glowMapMergePixelShader';
  124792. 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}";
  124793. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124794. /** @hidden */
  124795. var glowMapMergePixelShader = { name: name, shader: shader };
  124796. /***/ }),
  124797. /***/ "./Shaders/glowMapMerge.vertex.ts":
  124798. /*!****************************************!*\
  124799. !*** ./Shaders/glowMapMerge.vertex.ts ***!
  124800. \****************************************/
  124801. /*! exports provided: glowMapMergeVertexShader */
  124802. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124803. "use strict";
  124804. __webpack_require__.r(__webpack_exports__);
  124805. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "glowMapMergeVertexShader", function() { return glowMapMergeVertexShader; });
  124806. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124807. var name = 'glowMapMergeVertexShader';
  124808. 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}";
  124809. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124810. /** @hidden */
  124811. var glowMapMergeVertexShader = { name: name, shader: shader };
  124812. /***/ }),
  124813. /***/ "./Shaders/gpuRenderParticles.fragment.ts":
  124814. /*!************************************************!*\
  124815. !*** ./Shaders/gpuRenderParticles.fragment.ts ***!
  124816. \************************************************/
  124817. /*! exports provided: gpuRenderParticlesPixelShader */
  124818. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124819. "use strict";
  124820. __webpack_require__.r(__webpack_exports__);
  124821. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesPixelShader", function() { return gpuRenderParticlesPixelShader; });
  124822. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124823. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration2.ts");
  124824. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124825. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124826. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124827. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  124828. var name = 'gpuRenderParticlesPixelShader';
  124829. 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";
  124830. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124831. /** @hidden */
  124832. var gpuRenderParticlesPixelShader = { name: name, shader: shader };
  124833. /***/ }),
  124834. /***/ "./Shaders/gpuRenderParticles.vertex.ts":
  124835. /*!**********************************************!*\
  124836. !*** ./Shaders/gpuRenderParticles.vertex.ts ***!
  124837. \**********************************************/
  124838. /*! exports provided: gpuRenderParticlesVertexShader */
  124839. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124840. "use strict";
  124841. __webpack_require__.r(__webpack_exports__);
  124842. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuRenderParticlesVertexShader", function() { return gpuRenderParticlesVertexShader; });
  124843. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124844. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration2__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration2 */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration2.ts");
  124845. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  124846. var name = 'gpuRenderParticlesVertexShader';
  124847. var shader = "#version 300 es\nuniform mat4 view;\nuniform mat4 projection;\nuniform vec2 translationPivot;\n\nin vec3 position;\nin float age;\nin float life;\nin vec3 size;\n#ifndef BILLBOARD\nin vec3 initialDirection;\n#endif\n#ifdef BILLBOARDSTRETCHED\nin vec3 direction;\n#endif\nin float angle;\n#ifdef ANIMATESHEET\nin float cellIndex;\n#endif\nin vec2 offset;\nin vec2 uv;\nout vec2 vUV;\nout vec4 vColor;\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nuniform mat4 invView;\n#endif\n#include<clipPlaneVertexDeclaration2>\n#ifdef COLORGRADIENTS\nuniform sampler2D colorGradientSampler;\n#else\nuniform vec4 colorDead;\nin vec4 color;\n#endif\n#ifdef ANIMATESHEET\nuniform vec3 sheetInfos;\n#endif\n#ifdef BILLBOARD\nuniform vec3 eyePosition;\n#endif\nvec3 rotate(vec3 yaxis,vec3 rotatedCorner) {\nvec3 xaxis=normalize(cross(vec3(0.,1.0,0.),yaxis));\nvec3 zaxis=normalize(cross(yaxis,xaxis));\nvec3 row0=vec3(xaxis.x,xaxis.y,xaxis.z);\nvec3 row1=vec3(yaxis.x,yaxis.y,yaxis.z);\nvec3 row2=vec3(zaxis.x,zaxis.y,zaxis.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#ifdef BILLBOARDSTRETCHED\nvec3 rotateAlign(vec3 toCamera,vec3 rotatedCorner) {\nvec3 normalizedToCamera=normalize(toCamera);\nvec3 normalizedCrossDirToCamera=normalize(cross(normalize(direction),normalizedToCamera));\nvec3 crossProduct=normalize(cross(normalizedToCamera,normalizedCrossDirToCamera));\nvec3 row0=vec3(normalizedCrossDirToCamera.x,normalizedCrossDirToCamera.y,normalizedCrossDirToCamera.z);\nvec3 row1=vec3(crossProduct.x,crossProduct.y,crossProduct.z);\nvec3 row2=vec3(normalizedToCamera.x,normalizedToCamera.y,normalizedToCamera.z);\nmat3 rotMatrix=mat3(row0,row1,row2);\nvec3 alignedCorner=rotMatrix*rotatedCorner;\nreturn position+alignedCorner;\n}\n#endif\nvoid main() {\n#ifdef ANIMATESHEET\nfloat rowOffset=floor(cellIndex/sheetInfos.z);\nfloat columnOffset=cellIndex-rowOffset*sheetInfos.z;\nvec2 uvScale=sheetInfos.xy;\nvec2 uvOffset=vec2(uv.x ,1.0-uv.y);\nvUV=(uvOffset+vec2(columnOffset,rowOffset))*uvScale;\n#else\nvUV=uv;\n#endif\nfloat ratio=age/life;\n#ifdef COLORGRADIENTS\nvColor=texture(colorGradientSampler,vec2(ratio,0));\n#else\nvColor=color*vec4(1.0-ratio)+colorDead*vec4(ratio);\n#endif\nvec2 cornerPos=(offset-translationPivot)*size.yz*size.x+translationPivot;\n#ifdef BILLBOARD\nvec4 rotatedCorner;\nrotatedCorner.w=0.;\n#ifdef BILLBOARDY\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.y=0.;\nvec3 yaxis=position-eyePosition;\nyaxis.y=0.;\nvec3 worldPos=rotate(normalize(yaxis),rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#elif defined(BILLBOARDSTRETCHED)\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\nvec3 toCamera=position-eyePosition;\nvec3 worldPos=rotateAlign(toCamera,rotatedCorner.xyz);\nvec4 viewPosition=(view*vec4(worldPos,1.0));\n#else\n\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nrotatedCorner.z=0.;\n\nvec4 viewPosition=view*vec4(position,1.0)+rotatedCorner;\n#endif\n#else\n\nvec3 rotatedCorner;\nrotatedCorner.x=cornerPos.x*cos(angle)-cornerPos.y*sin(angle);\nrotatedCorner.y=0.;\nrotatedCorner.z=cornerPos.x*sin(angle)+cornerPos.y*cos(angle);\nvec3 yaxis=normalize(initialDirection);\nvec3 worldPos=rotate(yaxis,rotatedCorner);\n\nvec4 viewPosition=view*vec4(worldPos,1.0);\n#endif\ngl_Position=projection*viewPosition;\n\n#if defined(CLIPPLANE) || defined(CLIPPLANE2) || defined(CLIPPLANE3) || defined(CLIPPLANE4)\nvec4 worldPos=invView*viewPosition;\n#endif\n#include<clipPlaneVertex>\n}";
  124848. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124849. /** @hidden */
  124850. var gpuRenderParticlesVertexShader = { name: name, shader: shader };
  124851. /***/ }),
  124852. /***/ "./Shaders/gpuUpdateParticles.fragment.ts":
  124853. /*!************************************************!*\
  124854. !*** ./Shaders/gpuUpdateParticles.fragment.ts ***!
  124855. \************************************************/
  124856. /*! exports provided: gpuUpdateParticlesPixelShader */
  124857. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124858. "use strict";
  124859. __webpack_require__.r(__webpack_exports__);
  124860. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesPixelShader", function() { return gpuUpdateParticlesPixelShader; });
  124861. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124862. var name = 'gpuUpdateParticlesPixelShader';
  124863. var shader = "#version 300 es\nvoid main() {\ndiscard;\n}\n";
  124864. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124865. /** @hidden */
  124866. var gpuUpdateParticlesPixelShader = { name: name, shader: shader };
  124867. /***/ }),
  124868. /***/ "./Shaders/gpuUpdateParticles.vertex.ts":
  124869. /*!**********************************************!*\
  124870. !*** ./Shaders/gpuUpdateParticles.vertex.ts ***!
  124871. \**********************************************/
  124872. /*! exports provided: gpuUpdateParticlesVertexShader */
  124873. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124874. "use strict";
  124875. __webpack_require__.r(__webpack_exports__);
  124876. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "gpuUpdateParticlesVertexShader", function() { return gpuUpdateParticlesVertexShader; });
  124877. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124878. var name = 'gpuUpdateParticlesVertexShader';
  124879. 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}";
  124880. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124881. /** @hidden */
  124882. var gpuUpdateParticlesVertexShader = { name: name, shader: shader };
  124883. /***/ }),
  124884. /***/ "./Shaders/grain.fragment.ts":
  124885. /*!***********************************!*\
  124886. !*** ./Shaders/grain.fragment.ts ***!
  124887. \***********************************/
  124888. /*! exports provided: grainPixelShader */
  124889. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124890. "use strict";
  124891. __webpack_require__.r(__webpack_exports__);
  124892. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "grainPixelShader", function() { return grainPixelShader; });
  124893. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124894. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124895. var name = 'grainPixelShader';
  124896. 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}";
  124897. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124898. /** @hidden */
  124899. var grainPixelShader = { name: name, shader: shader };
  124900. /***/ }),
  124901. /***/ "./Shaders/highlights.fragment.ts":
  124902. /*!****************************************!*\
  124903. !*** ./Shaders/highlights.fragment.ts ***!
  124904. \****************************************/
  124905. /*! exports provided: highlightsPixelShader */
  124906. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124907. "use strict";
  124908. __webpack_require__.r(__webpack_exports__);
  124909. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "highlightsPixelShader", function() { return highlightsPixelShader; });
  124910. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124911. var name = 'highlightsPixelShader';
  124912. 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}";
  124913. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124914. /** @hidden */
  124915. var highlightsPixelShader = { name: name, shader: shader };
  124916. /***/ }),
  124917. /***/ "./Shaders/imageProcessing.fragment.ts":
  124918. /*!*********************************************!*\
  124919. !*** ./Shaders/imageProcessing.fragment.ts ***!
  124920. \*********************************************/
  124921. /*! exports provided: imageProcessingPixelShader */
  124922. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124923. "use strict";
  124924. __webpack_require__.r(__webpack_exports__);
  124925. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "imageProcessingPixelShader", function() { return imageProcessingPixelShader; });
  124926. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124927. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  124928. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  124929. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  124930. var name = 'imageProcessingPixelShader';
  124931. 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}";
  124932. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124933. /** @hidden */
  124934. var imageProcessingPixelShader = { name: name, shader: shader };
  124935. /***/ }),
  124936. /***/ "./Shaders/kernelBlur.fragment.ts":
  124937. /*!****************************************!*\
  124938. !*** ./Shaders/kernelBlur.fragment.ts ***!
  124939. \****************************************/
  124940. /*! exports provided: kernelBlurPixelShader */
  124941. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124942. "use strict";
  124943. __webpack_require__.r(__webpack_exports__);
  124944. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurPixelShader", function() { return kernelBlurPixelShader; });
  124945. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124946. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124947. /* harmony import */ var _ShadersInclude_kernelBlurFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment */ "./Shaders/ShadersInclude/kernelBlurFragment.ts");
  124948. /* harmony import */ var _ShadersInclude_kernelBlurFragment2__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurFragment2 */ "./Shaders/ShadersInclude/kernelBlurFragment2.ts");
  124949. var name = 'kernelBlurPixelShader';
  124950. 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}";
  124951. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124952. /** @hidden */
  124953. var kernelBlurPixelShader = { name: name, shader: shader };
  124954. /***/ }),
  124955. /***/ "./Shaders/kernelBlur.vertex.ts":
  124956. /*!**************************************!*\
  124957. !*** ./Shaders/kernelBlur.vertex.ts ***!
  124958. \**************************************/
  124959. /*! exports provided: kernelBlurVertexShader */
  124960. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124961. "use strict";
  124962. __webpack_require__.r(__webpack_exports__);
  124963. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "kernelBlurVertexShader", function() { return kernelBlurVertexShader; });
  124964. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124965. /* harmony import */ var _ShadersInclude_kernelBlurVaryingDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVaryingDeclaration */ "./Shaders/ShadersInclude/kernelBlurVaryingDeclaration.ts");
  124966. /* harmony import */ var _ShadersInclude_kernelBlurVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/kernelBlurVertex */ "./Shaders/ShadersInclude/kernelBlurVertex.ts");
  124967. var name = 'kernelBlurVertexShader';
  124968. 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}";
  124969. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124970. /** @hidden */
  124971. var kernelBlurVertexShader = { name: name, shader: shader };
  124972. /***/ }),
  124973. /***/ "./Shaders/layer.fragment.ts":
  124974. /*!***********************************!*\
  124975. !*** ./Shaders/layer.fragment.ts ***!
  124976. \***********************************/
  124977. /*! exports provided: layerPixelShader */
  124978. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124979. "use strict";
  124980. __webpack_require__.r(__webpack_exports__);
  124981. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerPixelShader", function() { return layerPixelShader; });
  124982. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124983. var name = 'layerPixelShader';
  124984. 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}";
  124985. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  124986. /** @hidden */
  124987. var layerPixelShader = { name: name, shader: shader };
  124988. /***/ }),
  124989. /***/ "./Shaders/layer.vertex.ts":
  124990. /*!*********************************!*\
  124991. !*** ./Shaders/layer.vertex.ts ***!
  124992. \*********************************/
  124993. /*! exports provided: layerVertexShader */
  124994. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  124995. "use strict";
  124996. __webpack_require__.r(__webpack_exports__);
  124997. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "layerVertexShader", function() { return layerVertexShader; });
  124998. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  124999. var name = 'layerVertexShader';
  125000. 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}";
  125001. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125002. /** @hidden */
  125003. var layerVertexShader = { name: name, shader: shader };
  125004. /***/ }),
  125005. /***/ "./Shaders/lensFlare.fragment.ts":
  125006. /*!***************************************!*\
  125007. !*** ./Shaders/lensFlare.fragment.ts ***!
  125008. \***************************************/
  125009. /*! exports provided: lensFlarePixelShader */
  125010. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125011. "use strict";
  125012. __webpack_require__.r(__webpack_exports__);
  125013. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlarePixelShader", function() { return lensFlarePixelShader; });
  125014. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125015. var name = 'lensFlarePixelShader';
  125016. 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}";
  125017. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125018. /** @hidden */
  125019. var lensFlarePixelShader = { name: name, shader: shader };
  125020. /***/ }),
  125021. /***/ "./Shaders/lensFlare.vertex.ts":
  125022. /*!*************************************!*\
  125023. !*** ./Shaders/lensFlare.vertex.ts ***!
  125024. \*************************************/
  125025. /*! exports provided: lensFlareVertexShader */
  125026. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125027. "use strict";
  125028. __webpack_require__.r(__webpack_exports__);
  125029. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensFlareVertexShader", function() { return lensFlareVertexShader; });
  125030. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125031. var name = 'lensFlareVertexShader';
  125032. 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}";
  125033. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125034. /** @hidden */
  125035. var lensFlareVertexShader = { name: name, shader: shader };
  125036. /***/ }),
  125037. /***/ "./Shaders/lensHighlights.fragment.ts":
  125038. /*!********************************************!*\
  125039. !*** ./Shaders/lensHighlights.fragment.ts ***!
  125040. \********************************************/
  125041. /*! exports provided: lensHighlightsPixelShader */
  125042. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125043. "use strict";
  125044. __webpack_require__.r(__webpack_exports__);
  125045. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lensHighlightsPixelShader", function() { return lensHighlightsPixelShader; });
  125046. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125047. var name = 'lensHighlightsPixelShader';
  125048. 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}";
  125049. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125050. /** @hidden */
  125051. var lensHighlightsPixelShader = { name: name, shader: shader };
  125052. /***/ }),
  125053. /***/ "./Shaders/line.fragment.ts":
  125054. /*!**********************************!*\
  125055. !*** ./Shaders/line.fragment.ts ***!
  125056. \**********************************/
  125057. /*! exports provided: linePixelShader */
  125058. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125059. "use strict";
  125060. __webpack_require__.r(__webpack_exports__);
  125061. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "linePixelShader", function() { return linePixelShader; });
  125062. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125063. var name = 'linePixelShader';
  125064. var shader = "uniform vec4 color;\nvoid main(void) {\ngl_FragColor=color;\n}";
  125065. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125066. /** @hidden */
  125067. var linePixelShader = { name: name, shader: shader };
  125068. /***/ }),
  125069. /***/ "./Shaders/line.vertex.ts":
  125070. /*!********************************!*\
  125071. !*** ./Shaders/line.vertex.ts ***!
  125072. \********************************/
  125073. /*! exports provided: lineVertexShader */
  125074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125075. "use strict";
  125076. __webpack_require__.r(__webpack_exports__);
  125077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "lineVertexShader", function() { return lineVertexShader; });
  125078. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125079. var name = 'lineVertexShader';
  125080. 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}";
  125081. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125082. /** @hidden */
  125083. var lineVertexShader = { name: name, shader: shader };
  125084. /***/ }),
  125085. /***/ "./Shaders/motionBlur.fragment.ts":
  125086. /*!****************************************!*\
  125087. !*** ./Shaders/motionBlur.fragment.ts ***!
  125088. \****************************************/
  125089. /*! exports provided: motionBlurPixelShader */
  125090. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125091. "use strict";
  125092. __webpack_require__.r(__webpack_exports__);
  125093. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "motionBlurPixelShader", function() { return motionBlurPixelShader; });
  125094. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125095. var name = 'motionBlurPixelShader';
  125096. 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";
  125097. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125098. /** @hidden */
  125099. var motionBlurPixelShader = { name: name, shader: shader };
  125100. /***/ }),
  125101. /***/ "./Shaders/noise.fragment.ts":
  125102. /*!***********************************!*\
  125103. !*** ./Shaders/noise.fragment.ts ***!
  125104. \***********************************/
  125105. /*! exports provided: noisePixelShader */
  125106. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125107. "use strict";
  125108. __webpack_require__.r(__webpack_exports__);
  125109. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "noisePixelShader", function() { return noisePixelShader; });
  125110. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125111. var name = 'noisePixelShader';
  125112. 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";
  125113. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125114. /** @hidden */
  125115. var noisePixelShader = { name: name, shader: shader };
  125116. /***/ }),
  125117. /***/ "./Shaders/outline.fragment.ts":
  125118. /*!*************************************!*\
  125119. !*** ./Shaders/outline.fragment.ts ***!
  125120. \*************************************/
  125121. /*! exports provided: outlinePixelShader */
  125122. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125123. "use strict";
  125124. __webpack_require__.r(__webpack_exports__);
  125125. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlinePixelShader", function() { return outlinePixelShader; });
  125126. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125127. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125128. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  125129. var name = 'outlinePixelShader';
  125130. 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}";
  125131. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125132. /** @hidden */
  125133. var outlinePixelShader = { name: name, shader: shader };
  125134. /***/ }),
  125135. /***/ "./Shaders/outline.vertex.ts":
  125136. /*!***********************************!*\
  125137. !*** ./Shaders/outline.vertex.ts ***!
  125138. \***********************************/
  125139. /*! exports provided: outlineVertexShader */
  125140. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125141. "use strict";
  125142. __webpack_require__.r(__webpack_exports__);
  125143. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "outlineVertexShader", function() { return outlineVertexShader; });
  125144. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125145. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125146. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125147. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125148. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125149. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125150. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  125151. var name = 'outlineVertexShader';
  125152. 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";
  125153. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125154. /** @hidden */
  125155. var outlineVertexShader = { name: name, shader: shader };
  125156. /***/ }),
  125157. /***/ "./Shaders/particles.fragment.ts":
  125158. /*!***************************************!*\
  125159. !*** ./Shaders/particles.fragment.ts ***!
  125160. \***************************************/
  125161. /*! exports provided: particlesPixelShader */
  125162. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125163. "use strict";
  125164. __webpack_require__.r(__webpack_exports__);
  125165. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesPixelShader", function() { return particlesPixelShader; });
  125166. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125167. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125168. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125169. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125170. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125171. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125172. var name = 'particlesPixelShader';
  125173. 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}";
  125174. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125175. /** @hidden */
  125176. var particlesPixelShader = { name: name, shader: shader };
  125177. /***/ }),
  125178. /***/ "./Shaders/particles.vertex.ts":
  125179. /*!*************************************!*\
  125180. !*** ./Shaders/particles.vertex.ts ***!
  125181. \*************************************/
  125182. /*! exports provided: particlesVertexShader */
  125183. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125184. "use strict";
  125185. __webpack_require__.r(__webpack_exports__);
  125186. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "particlesVertexShader", function() { return particlesVertexShader; });
  125187. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125188. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125189. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125190. var name = 'particlesVertexShader';
  125191. 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}";
  125192. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125193. /** @hidden */
  125194. var particlesVertexShader = { name: name, shader: shader };
  125195. /***/ }),
  125196. /***/ "./Shaders/pass.fragment.ts":
  125197. /*!**********************************!*\
  125198. !*** ./Shaders/pass.fragment.ts ***!
  125199. \**********************************/
  125200. /*! exports provided: passPixelShader */
  125201. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125202. "use strict";
  125203. __webpack_require__.r(__webpack_exports__);
  125204. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passPixelShader", function() { return passPixelShader; });
  125205. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125206. var name = 'passPixelShader';
  125207. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(textureSampler,vUV);\n}";
  125208. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125209. /** @hidden */
  125210. var passPixelShader = { name: name, shader: shader };
  125211. /***/ }),
  125212. /***/ "./Shaders/passCube.fragment.ts":
  125213. /*!**************************************!*\
  125214. !*** ./Shaders/passCube.fragment.ts ***!
  125215. \**************************************/
  125216. /*! exports provided: passCubePixelShader */
  125217. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125218. "use strict";
  125219. __webpack_require__.r(__webpack_exports__);
  125220. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "passCubePixelShader", function() { return passCubePixelShader; });
  125221. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125222. var name = 'passCubePixelShader';
  125223. 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}";
  125224. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125225. /** @hidden */
  125226. var passCubePixelShader = { name: name, shader: shader };
  125227. /***/ }),
  125228. /***/ "./Shaders/pbr.fragment.ts":
  125229. /*!*********************************!*\
  125230. !*** ./Shaders/pbr.fragment.ts ***!
  125231. \*********************************/
  125232. /*! exports provided: pbrPixelShader */
  125233. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125234. "use strict";
  125235. __webpack_require__.r(__webpack_exports__);
  125236. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrPixelShader", function() { return pbrPixelShader; });
  125237. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125238. /* harmony import */ var _ShadersInclude_pbrFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrFragmentDeclaration */ "./Shaders/ShadersInclude/pbrFragmentDeclaration.ts");
  125239. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  125240. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125241. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125242. /* harmony import */ var _ShadersInclude_reflectionFunction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/reflectionFunction */ "./Shaders/ShadersInclude/reflectionFunction.ts");
  125243. /* harmony import */ var _ShadersInclude_imageProcessingDeclaration__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingDeclaration */ "./Shaders/ShadersInclude/imageProcessingDeclaration.ts");
  125244. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125245. /* harmony import */ var _ShadersInclude_imageProcessingFunctions__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/imageProcessingFunctions */ "./Shaders/ShadersInclude/imageProcessingFunctions.ts");
  125246. /* harmony import */ var _ShadersInclude_shadowsFragmentFunctions__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/shadowsFragmentFunctions */ "./Shaders/ShadersInclude/shadowsFragmentFunctions.ts");
  125247. /* harmony import */ var _ShadersInclude_pbrFunctions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/pbrFunctions */ "./Shaders/ShadersInclude/pbrFunctions.ts");
  125248. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  125249. /* harmony import */ var _ShadersInclude_pbrPreLightingFunctions__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/pbrPreLightingFunctions */ "./Shaders/ShadersInclude/pbrPreLightingFunctions.ts");
  125250. /* harmony import */ var _ShadersInclude_pbrFalloffLightingFunctions__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/pbrFalloffLightingFunctions */ "./Shaders/ShadersInclude/pbrFalloffLightingFunctions.ts");
  125251. /* harmony import */ var _ShadersInclude_pbrLightingFunctions__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/pbrLightingFunctions */ "./Shaders/ShadersInclude/pbrLightingFunctions.ts");
  125252. /* harmony import */ var _ShadersInclude_bumpFragmentFunctions__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/bumpFragmentFunctions */ "./Shaders/ShadersInclude/bumpFragmentFunctions.ts");
  125253. /* harmony import */ var _ShadersInclude_clipPlaneFragmentDeclaration__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragmentDeclaration */ "./Shaders/ShadersInclude/clipPlaneFragmentDeclaration.ts");
  125254. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125255. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125256. /* harmony import */ var _ShadersInclude_clipPlaneFragment__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneFragment */ "./Shaders/ShadersInclude/clipPlaneFragment.ts");
  125257. /* harmony import */ var _ShadersInclude_bumpFragment__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/bumpFragment */ "./Shaders/ShadersInclude/bumpFragment.ts");
  125258. /* harmony import */ var _ShadersInclude_depthPrePass__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/depthPrePass */ "./Shaders/ShadersInclude/depthPrePass.ts");
  125259. /* harmony import */ var _ShadersInclude_lightFragment__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/lightFragment */ "./Shaders/ShadersInclude/lightFragment.ts");
  125260. /* harmony import */ var _ShadersInclude_logDepthFragment__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./ShadersInclude/logDepthFragment */ "./Shaders/ShadersInclude/logDepthFragment.ts");
  125261. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125262. var name = 'pbrPixelShader';
  125263. var shader = "#if defined(BUMP) || !defined(NORMAL) || defined(FORCENORMALFORWARD) || defined(SPECULARAA) || defined(CLEARCOAT_BUMP) || defined(ANISOTROPIC)\n#extension GL_OES_standard_derivatives : enable\n#endif\n#ifdef LODBASEDMICROSFURACE\n#extension GL_EXT_shader_texture_lod : enable\n#endif\n#ifdef LOGARITHMICDEPTH\n#extension GL_EXT_frag_depth : enable\n#endif\nprecision highp float;\n#include<__decl__pbrFragment>\nuniform vec4 vEyePosition;\nuniform vec3 vAmbientColor;\nuniform vec4 vCameraInfos;\n\nvarying vec3 vPositionW;\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n\n#ifdef ALBEDO\n#if ALBEDODIRECTUV == 1\n#define vAlbedoUV vMainUV1\n#elif ALBEDODIRECTUV == 2\n#define vAlbedoUV vMainUV2\n#else\nvarying vec2 vAlbedoUV;\n#endif\nuniform sampler2D albedoSampler;\n#endif\n#ifdef AMBIENT\n#if AMBIENTDIRECTUV == 1\n#define vAmbientUV vMainUV1\n#elif AMBIENTDIRECTUV == 2\n#define vAmbientUV vMainUV2\n#else\nvarying vec2 vAmbientUV;\n#endif\nuniform sampler2D ambientSampler;\n#endif\n#ifdef OPACITY\n#if OPACITYDIRECTUV == 1\n#define vOpacityUV vMainUV1\n#elif OPACITYDIRECTUV == 2\n#define vOpacityUV vMainUV2\n#else\nvarying vec2 vOpacityUV;\n#endif\nuniform sampler2D opacitySampler;\n#endif\n#ifdef EMISSIVE\n#if EMISSIVEDIRECTUV == 1\n#define vEmissiveUV vMainUV1\n#elif EMISSIVEDIRECTUV == 2\n#define vEmissiveUV vMainUV2\n#else\nvarying vec2 vEmissiveUV;\n#endif\nuniform sampler2D emissiveSampler;\n#endif\n#ifdef LIGHTMAP\n#if LIGHTMAPDIRECTUV == 1\n#define vLightmapUV vMainUV1\n#elif LIGHTMAPDIRECTUV == 2\n#define vLightmapUV vMainUV2\n#else\nvarying vec2 vLightmapUV;\n#endif\nuniform sampler2D lightmapSampler;\n#endif\n#ifdef REFLECTIVITY\n#if REFLECTIVITYDIRECTUV == 1\n#define vReflectivityUV vMainUV1\n#elif REFLECTIVITYDIRECTUV == 2\n#define vReflectivityUV vMainUV2\n#else\nvarying vec2 vReflectivityUV;\n#endif\nuniform sampler2D reflectivitySampler;\n#endif\n#ifdef MICROSURFACEMAP\n#if MICROSURFACEMAPDIRECTUV == 1\n#define vMicroSurfaceSamplerUV vMainUV1\n#elif MICROSURFACEMAPDIRECTUV == 2\n#define vMicroSurfaceSamplerUV vMainUV2\n#else\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\nuniform sampler2D microSurfaceSampler;\n#endif\n#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#endif\n\n#ifdef REFRACTION\n#ifdef REFRACTIONMAP_3D\n#define sampleRefraction(s,c) textureCube(s,c)\nuniform samplerCube refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#else\n#define sampleRefraction(s,c) texture2D(s,c)\nuniform sampler2D refractionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleRefractionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube refractionSamplerLow;\nuniform samplerCube refractionSamplerHigh;\n#endif\n#endif\n#endif\n\n#ifdef REFLECTION\n#ifdef REFLECTIONMAP_3D\n#define sampleReflection(s,c) textureCube(s,c)\nuniform samplerCube reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) textureCubeLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#else\n#define sampleReflection(s,c) texture2D(s,c)\nuniform sampler2D reflectionSampler;\n#ifdef LODBASEDMICROSFURACE\n#define sampleReflectionLod(s,c,l) texture2DLodEXT(s,c,l)\n#else\nuniform samplerCube reflectionSamplerLow;\nuniform samplerCube reflectionSamplerHigh;\n#endif\n#endif\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#else\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#endif\n#include<reflectionFunction>\n#endif\n#ifdef ENVIRONMENTBRDF\nuniform sampler2D environmentBrdfSampler;\n#endif\n\n#ifndef FROMLINEARSPACE\n#define FROMLINEARSPACE;\n#endif\n#include<imageProcessingDeclaration>\n#include<helperFunctions>\n#include<imageProcessingFunctions>\n\n#include<shadowsFragmentFunctions>\n#include<pbrFunctions>\n#include<harmonicsFunctions>\n#include<pbrPreLightingFunctions>\n#include<pbrFalloffLightingFunctions>\n#include<pbrLightingFunctions>\n#include<bumpFragmentFunctions>\n#include<clipPlaneFragmentDeclaration>\n#include<logDepthDeclaration>\n\n#include<fogFragmentDeclaration>\nvoid main(void) {\n#include<clipPlaneFragment>\n\n\nvec3 viewDirectionW=normalize(vEyePosition.xyz-vPositionW);\n#ifdef NORMAL\nvec3 normalW=normalize(vNormalW);\n#else\nvec3 normalW=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#endif\n#ifdef CLEARCOAT\n\nvec3 clearCoatNormalW=normalW;\n#endif\n#include<bumpFragment>\n#if defined(FORCENORMALFORWARD) && defined(NORMAL)\nvec3 faceNormal=normalize(cross(dFdx(vPositionW),dFdy(vPositionW)))*vEyePosition.w;\n#if defined(TWOSIDEDLIGHTING)\nfaceNormal=gl_FrontFacing ? faceNormal : -faceNormal;\n#endif\nnormalW*=sign(dot(normalW,faceNormal));\n#endif\n#if defined(TWOSIDEDLIGHTING) && defined(NORMAL)\nnormalW=gl_FrontFacing ? normalW : -normalW;\n#endif\n\n\nvec3 surfaceAlbedo=vAlbedoColor.rgb;\n\nfloat alpha=vAlbedoColor.a;\n#ifdef ALBEDO\nvec4 albedoTexture=texture2D(albedoSampler,vAlbedoUV+uvOffset);\n#if defined(ALPHAFROMALBEDO) || defined(ALPHATEST)\nalpha*=albedoTexture.a;\n#endif\nsurfaceAlbedo*=toLinearSpace(albedoTexture.rgb);\nsurfaceAlbedo*=vAlbedoInfos.y;\n#endif\n#ifdef VERTEXCOLOR\nsurfaceAlbedo*=vColor.rgb;\n#endif\n\n#ifdef OPACITY\nvec4 opacityMap=texture2D(opacitySampler,vOpacityUV+uvOffset);\n#ifdef OPACITYRGB\nalpha=getLuminance(opacityMap.rgb);\n#else\nalpha*=opacityMap.a;\n#endif\nalpha*=vOpacityInfos.y;\n#endif\n#ifdef VERTEXALPHA\nalpha*=vColor.a;\n#endif\n#if !defined(LINKREFRACTIONTOTRANSPARENCY) && !defined(ALPHAFRESNEL)\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#include<depthPrePass>\n\nvec3 ambientOcclusionColor=vec3(1.,1.,1.);\n#ifdef AMBIENT\nvec3 ambientOcclusionColorMap=texture2D(ambientSampler,vAmbientUV+uvOffset).rgb*vAmbientInfos.y;\n#ifdef AMBIENTINGRAYSCALE\nambientOcclusionColorMap=vec3(ambientOcclusionColorMap.r,ambientOcclusionColorMap.r,ambientOcclusionColorMap.r);\n#endif\nambientOcclusionColor=mix(ambientOcclusionColor,ambientOcclusionColorMap,vAmbientInfos.z);\n#endif\n#ifdef UNLIT\nvec3 diffuseBase=vec3(1.,1.,1.);\n#else\n\nfloat microSurface=vReflectivityColor.a;\nvec3 surfaceReflectivityColor=vReflectivityColor.rgb;\n#ifdef METALLICWORKFLOW\nvec2 metallicRoughness=surfaceReflectivityColor.rg;\n#ifdef REFLECTIVITY\nvec4 surfaceMetallicColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\n#ifdef AOSTOREINMETALMAPRED\nvec3 aoStoreInMetalMap=vec3(surfaceMetallicColorMap.r,surfaceMetallicColorMap.r,surfaceMetallicColorMap.r);\nambientOcclusionColor=mix(ambientOcclusionColor,aoStoreInMetalMap,vReflectivityInfos.z);\n#endif\n#ifdef METALLNESSSTOREINMETALMAPBLUE\nmetallicRoughness.r*=surfaceMetallicColorMap.b;\n#else\nmetallicRoughness.r*=surfaceMetallicColorMap.r;\n#endif\n#ifdef ROUGHNESSSTOREINMETALMAPALPHA\nmetallicRoughness.g*=surfaceMetallicColorMap.a;\n#else\n#ifdef ROUGHNESSSTOREINMETALMAPGREEN\nmetallicRoughness.g*=surfaceMetallicColorMap.g;\n#endif\n#endif\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmetallicRoughness.g*=microSurfaceTexel.r;\n#endif\n\nmicroSurface=1.0-metallicRoughness.g;\n\nvec3 baseColor=surfaceAlbedo;\n#ifdef REFLECTANCE\n\n\n\n\n\nsurfaceAlbedo=baseColor.rgb*(1.0-metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(0.16*reflectance*reflectance,baseColor,metallicRoughness.r);\n#else\n\n\n\nconst vec3 DefaultSpecularReflectanceDielectric=vec3(0.04,0.04,0.04);\n\nsurfaceAlbedo=mix(baseColor.rgb*(1.0-DefaultSpecularReflectanceDielectric.r),vec3(0.,0.,0.),metallicRoughness.r);\n\nsurfaceReflectivityColor=mix(DefaultSpecularReflectanceDielectric,baseColor,metallicRoughness.r);\n#endif\n#else\n#ifdef REFLECTIVITY\nvec4 surfaceReflectivityColorMap=texture2D(reflectivitySampler,vReflectivityUV+uvOffset);\nsurfaceReflectivityColor*=toLinearSpace(surfaceReflectivityColorMap.rgb);\nsurfaceReflectivityColor*=vReflectivityInfos.y;\n#ifdef MICROSURFACEFROMREFLECTIVITYMAP\nmicroSurface*=surfaceReflectivityColorMap.a;\nmicroSurface*=vReflectivityInfos.z;\n#else\n#ifdef MICROSURFACEAUTOMATIC\nmicroSurface*=computeDefaultMicroSurface(microSurface,surfaceReflectivityColor);\n#endif\n#ifdef MICROSURFACEMAP\nvec4 microSurfaceTexel=texture2D(microSurfaceSampler,vMicroSurfaceSamplerUV+uvOffset)*vMicroSurfaceSamplerInfos.y;\nmicroSurface*=microSurfaceTexel.r;\n#endif\n#endif\n#endif\n#endif\n\nmicroSurface=clamp(microSurface,0.,1.);\n\nfloat roughness=1.-microSurface;\n\n#ifdef ALPHAFRESNEL\n#if defined(ALPHATEST) || defined(ALPHABLEND)\n\n\n\nfloat opacityPerceptual=alpha;\n#ifdef LINEARALPHAFRESNEL\nfloat opacity0=opacityPerceptual;\n#else\nfloat opacity0=opacityPerceptual*opacityPerceptual;\n#endif\nfloat opacity90=fresnelGrazingReflectance(opacity0);\nvec3 normalForward=faceforward(normalW,-viewDirectionW,normalW);\n\nalpha=fresnelSchlickEnvironmentGGX(clamp(dot(viewDirectionW,normalForward),0.0,1.0),vec3(opacity0),vec3(opacity90),sqrt(microSurface)).x;\n#ifdef ALPHATEST\nif (alpha<ALPHATESTVALUE)\ndiscard;\n#ifndef ALPHABLEND\n\nalpha=1.0;\n#endif\n#endif\n#endif\n#endif\n\nfloat NdotVUnclamped=dot(normalW,viewDirectionW);\nfloat NdotV=clamp(NdotVUnclamped,0.,1.)+0.00001;\nfloat alphaG=convertRoughnessToAverageSlope(roughness);\nvec2 AARoughnessFactors=getAARoughnessFactors(normalW.xyz);\n#ifdef SPECULARAA\n\nalphaG+=AARoughnessFactors.y;\n#endif\n#ifdef ANISOTROPIC\nvec3 anisotropicFrameDirection=anisotropy>=0.0 ? TBN[1] : TBN[0];\nvec3 anisotropicFrameTangent=cross(normalize(anisotropicFrameDirection),viewDirectionW);\nvec3 anisotropicFrameNormal=cross(anisotropicFrameTangent,anisotropicFrameDirection);\nvec3 anisotropicNormal=normalize(mix(normalW,anisotropicFrameNormal,abs(anisotropy)));\n#endif\n\n#ifdef REFRACTION\nvec4 environmentRefraction=vec4(0.,0.,0.,0.);\n#ifdef ANISOTROPIC\nvec3 refractionVector=refract(-viewDirectionW,anisotropicNormal,vRefractionInfos.y);\n#else\nvec3 refractionVector=refract(-viewDirectionW,normalW,vRefractionInfos.y);\n#endif\n#ifdef REFRACTIONMAP_OPPOSITEZ\nrefractionVector.z*=-1.0;\n#endif\n\n#ifdef REFRACTIONMAP_3D\nrefractionVector.y=refractionVector.y*vRefractionInfos.w;\nvec3 refractionCoords=refractionVector;\nrefractionCoords=vec3(refractionMatrix*vec4(refractionCoords,0));\n#else\nvec3 vRefractionUVW=vec3(refractionMatrix*(view*vec4(vPositionW+refractionVector*vRefractionInfos.z,1.0)));\nvec2 refractionCoords=vRefractionUVW.xy/vRefractionUVW.z;\nrefractionCoords.y=1.0-refractionCoords.y;\n#endif\n#ifdef LODINREFRACTIONALPHA\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,NdotVUnclamped);\n#else\nfloat refractionLOD=getLodFromAlphaG(vRefractionMicrosurfaceInfos.x,alphaG,1.0);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nrefractionLOD=refractionLOD*vRefractionMicrosurfaceInfos.y+vRefractionMicrosurfaceInfos.z;\n#ifdef LODINREFRACTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticRefractionLOD=UNPACK_LOD(sampleRefraction(refractionSampler,refractionCoords).a);\nfloat requestedRefractionLOD=max(automaticRefractionLOD,refractionLOD);\n#else\nfloat requestedRefractionLOD=refractionLOD;\n#endif\nenvironmentRefraction=sampleRefractionLod(refractionSampler,refractionCoords,requestedRefractionLOD);\n#else\nfloat lodRefractionNormalized=clamp(refractionLOD/log2(vRefractionMicrosurfaceInfos.x),0.,1.);\nfloat lodRefractionNormalizedDoubled=lodRefractionNormalized*2.0;\nvec4 environmentRefractionMid=sampleRefraction(refractionSampler,refractionCoords);\nif(lodRefractionNormalizedDoubled<1.0){\nenvironmentRefraction=mix(\nsampleRefraction(refractionSamplerHigh,refractionCoords),\nenvironmentRefractionMid,\nlodRefractionNormalizedDoubled\n);\n}else{\nenvironmentRefraction=mix(\nenvironmentRefractionMid,\nsampleRefraction(refractionSamplerLow,refractionCoords),\nlodRefractionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFRACTION\nenvironmentRefraction.rgb=fromRGBD(environmentRefraction);\n#endif\n#ifdef GAMMAREFRACTION\nenvironmentRefraction.rgb=toLinearSpace(environmentRefraction.rgb);\n#endif\n\nenvironmentRefraction.rgb*=vRefractionInfos.x;\n#endif\n\n#ifdef REFLECTION\nvec4 environmentRadiance=vec4(0.,0.,0.,0.);\nvec3 environmentIrradiance=vec3(0.,0.,0.);\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,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nreflectionLOD=reflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\n#ifdef LODINREFLECTIONALPHA\n\n\n\n\n\n\n\n\n\nfloat automaticReflectionLOD=UNPACK_LOD(sampleReflection(reflectionSampler,reflectionCoords).a);\nfloat requestedReflectionLOD=max(automaticReflectionLOD,reflectionLOD);\n#else\nfloat requestedReflectionLOD=reflectionLOD;\n#endif\nenvironmentRadiance=sampleReflectionLod(reflectionSampler,reflectionCoords,requestedReflectionLOD);\n#else\nfloat lodReflectionNormalized=clamp(reflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\nfloat lodReflectionNormalizedDoubled=lodReflectionNormalized*2.0;\nvec4 environmentSpecularMid=sampleReflection(reflectionSampler,reflectionCoords);\nif(lodReflectionNormalizedDoubled<1.0){\nenvironmentRadiance=mix(\nsampleReflection(reflectionSamplerHigh,reflectionCoords),\nenvironmentSpecularMid,\nlodReflectionNormalizedDoubled\n);\n}else{\nenvironmentRadiance=mix(\nenvironmentSpecularMid,\nsampleReflection(reflectionSamplerLow,reflectionCoords),\nlodReflectionNormalizedDoubled-1.0\n);\n}\n#endif\n#ifdef RGBDREFLECTION\nenvironmentRadiance.rgb=fromRGBD(environmentRadiance);\n#endif\n#ifdef GAMMAREFLECTION\nenvironmentRadiance.rgb=toLinearSpace(environmentRadiance.rgb);\n#endif\n\n#ifdef USESPHERICALFROMREFLECTIONMAP\n#if defined(NORMAL) && defined(USESPHERICALINVERTEX)\nenvironmentIrradiance=vEnvironmentIrradiance;\n#else\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 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\n\n\n\nvec3 specularEnvironmentR0Updated=getR0RemappedForPolyurethaneClearCoat(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);\nfloat clearCoatNdotV=clamp(clearCoatNdotVUnclamped,0.,1.)+0.00001;\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,1.);\n#endif\n#ifdef LODBASEDMICROSFURACE\n\nclearCoatReflectionLOD=clearCoatReflectionLOD*vReflectionMicrosurfaceInfos.y+vReflectionMicrosurfaceInfos.z;\nfloat requestedClearCoatReflectionLOD=clearCoatReflectionLOD;\nenvironmentClearCoatRadiance=sampleReflectionLod(reflectionSampler,clearCoatReflectionCoords,requestedClearCoatReflectionLOD);\n#else\nfloat lodClearCoatReflectionNormalized=clamp(clearCoatReflectionLOD/log2(vReflectionMicrosurfaceInfos.x),0.,1.);\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\nenvironmentClearCoatRadiance.rgb*=vReflectionInfos.x;\nenvironmentClearCoatRadiance.rgb*=vReflectionColor.rgb;\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 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)\n\nvec2 brdfSamplerUV=vec2(NdotV,roughness);\n\nvec4 environmentBrdf=texture2D(environmentBrdfSampler,brdfSamplerUV);\nvec3 specularEnvironmentReflectance=specularEnvironmentR0*environmentBrdf.x+environmentBrdf.y;\n#ifdef RADIANCEOCCLUSION\n#ifdef AMBIENTINGRAYSCALE\nfloat ambientMonochrome=ambientOcclusionColor.r;\n#else\nfloat ambientMonochrome=getLuminance(ambientOcclusionColor);\n#endif\nfloat seo=environmentRadianceOcclusion(ambientMonochrome,NdotVUnclamped);\nspecularEnvironmentReflectance*=seo;\n#endif\n#ifdef HORIZONOCCLUSION\n#ifdef BUMP\n#ifdef REFLECTIONMAP_3D\nfloat eho=environmentHorizonOcclusion(-viewDirectionW,normalW);\nspecularEnvironmentReflectance*=eho;\n#endif\n#endif\n#endif\n#else\n\nvec3 specularEnvironmentReflectance=fresnelSchlickEnvironmentGGX(NdotV,specularEnvironmentR0,specularEnvironmentR90,sqrt(microSurface));\n#endif\n\n#ifdef CLEARCOAT\n#if defined(ENVIRONMENTBRDF) && !defined(REFLECTIONMAP_SKYBOX)\n\nvec2 brdfClearCoatSamplerUV=vec2(clearCoatNdotV,clearCoatRoughness);\n\nvec4 environmentClearCoatBrdf=texture2D(environmentBrdfSampler,brdfClearCoatSamplerUV);\nvec3 clearCoatEnvironmentReflectance=vec3(CLEARCOATREFLECTANCE0*environmentClearCoatBrdf.x+environmentClearCoatBrdf.y);\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=fresnelSchlickEnvironmentGGX(clearCoatNdotV,vec3(1.),vec3(1.),sqrt(1.-clearCoatRoughness));\n#endif\nclearCoatEnvironmentReflectance*=clearCoatIntensity;\n\nfloat fresnelIBLClearCoat=fresnelSchlickGGX(clearCoatNdotV,CLEARCOATREFLECTANCE0,CLEARCOATREFLECTANCE90);\nfresnelIBLClearCoat*=clearCoatIntensity;\nfloat conservationFactor=(1.-fresnelIBLClearCoat);\n#ifdef REFLECTION\nenvironmentIrradiance*=conservationFactor;\n#endif\nspecularEnvironmentReflectance*=(conservationFactor*conservationFactor);\n#endif\n\n#ifdef REFRACTION\nvec3 refractance=vec3(0.0,0.0,0.0);\nvec3 transmission=vec3(1.0,1.0,1.0);\n#ifdef LINKREFRACTIONTOTRANSPARENCY\n\ntransmission*=(1.0-alpha);\n\n\nvec3 mixedAlbedo=surfaceAlbedo;\nfloat maxChannel=max(max(mixedAlbedo.r,mixedAlbedo.g),mixedAlbedo.b);\nvec3 tint=clamp(maxChannel*mixedAlbedo,0.0,1.0);\n\nsurfaceAlbedo*=alpha;\n\nenvironmentIrradiance*=alpha;\n\nenvironmentRefraction.rgb*=tint;\n\nalpha=1.0;\n#endif\n\nvec3 bounceSpecularEnvironmentReflectance=(2.0*specularEnvironmentReflectance)/(1.0+specularEnvironmentReflectance);\nspecularEnvironmentReflectance=mix(bounceSpecularEnvironmentReflectance,specularEnvironmentReflectance,alpha);\n\ntransmission*=1.0-specularEnvironmentReflectance;\n\nrefractance=transmission;\n#endif\n\n\n\n\nsurfaceAlbedo.rgb=(1.-reflectance)*surfaceAlbedo.rgb;\n\n#ifdef REFLECTION\nvec3 finalIrradiance=environmentIrradiance;\nfinalIrradiance*=surfaceAlbedo.rgb;\n#endif\n\n#ifdef SPECULARTERM\nvec3 finalSpecular=specularBase;\nfinalSpecular=max(finalSpecular,0.0);\n\nvec3 finalSpecularScaled=finalSpecular*vLightingIntensity.x*vLightingIntensity.w;\n#endif\n\n#ifdef REFLECTION\nvec3 finalRadiance=environmentRadiance.rgb;\nfinalRadiance*=specularEnvironmentReflectance;\n\nvec3 finalRadianceScaled=finalRadiance*vLightingIntensity.z;\n#endif\n\n#ifdef REFRACTION\nvec3 finalRefraction=environmentRefraction.rgb;\nfinalRefraction*=refractance;\n#endif\n\n#ifdef CLEARCOAT\nvec3 finalClearCoat=clearCoatBase;\nfinalClearCoat=max(finalClearCoat,0.0);\n\nvec3 finalClearCoatScaled=finalClearCoat*vLightingIntensity.x*vLightingIntensity.w;\n\n#ifdef REFLECTION\nvec3 finalClearCoatRadiance=environmentClearCoatRadiance.rgb;\nfinalClearCoatRadiance*=clearCoatEnvironmentReflectance;\n\nvec3 finalClearCoatRadianceScaled=finalClearCoatRadiance*vLightingIntensity.z;\n#endif\n#ifdef REFRACTION\nfinalRefraction*=(conservationFactor*conservationFactor);\n#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=clamp(alpha+luminanceOverAlpha*luminanceOverAlpha,0.,1.);\n#endif\n#endif\n#endif\n\n\nvec3 finalDiffuse=diffuseBase;\nfinalDiffuse*=surfaceAlbedo.rgb;\nfinalDiffuse=max(finalDiffuse,0.0);\n\nvec3 finalEmissive=vEmissiveColor;\n#ifdef EMISSIVE\nvec3 emissiveColorTex=texture2D(emissiveSampler,vEmissiveUV+uvOffset).rgb;\nfinalEmissive*=toLinearSpace(emissiveColorTex.rgb);\nfinalEmissive*=vEmissiveInfos.y;\n#endif\n\n#ifdef AMBIENT\nvec3 ambientOcclusionForDirectDiffuse=mix(vec3(1.),ambientOcclusionColor,vAmbientInfos.w);\n#else\nvec3 ambientOcclusionForDirectDiffuse=ambientOcclusionColor;\n#endif\n\n\n\nvec4 finalColor=vec4(\nvAmbientColor*ambientOcclusionColor +\nfinalDiffuse*ambientOcclusionForDirectDiffuse*vLightingIntensity.x +\n#ifndef UNLIT\n#ifdef REFLECTION\nfinalIrradiance*ambientOcclusionColor*vLightingIntensity.z +\n#endif\n#ifdef SPECULARTERM\n\n\nfinalSpecularScaled +\n#endif\n#ifdef CLEARCOAT\n\n\nfinalClearCoatScaled +\n#endif\n#ifdef REFLECTION\n\n\nfinalRadianceScaled +\n#ifdef CLEARCOAT\n\n\nfinalClearCoatRadianceScaled +\n#endif\n#endif\n#ifdef REFRACTION\nfinalRefraction*vLightingIntensity.z +\n#endif\n#endif\nfinalEmissive*vLightingIntensity.y,\nalpha);\n\n#ifdef LIGHTMAP\n#ifndef LIGHTMAPEXCLUDED\n#ifdef USELIGHTMAPASSHADOWMAP\nfinalColor.rgb*=lightmapColor;\n#else\nfinalColor.rgb+=lightmapColor;\n#endif\n#endif\n#endif\n\nfinalColor=max(finalColor,0.0);\n#include<logDepthFragment>\n#include<fogFragment>(color,finalColor)\n#ifdef IMAGEPROCESSINGPOSTPROCESS\n\n\nfinalColor.rgb=clamp(finalColor.rgb,0.,30.0);\n#else\n\nfinalColor=applyImageProcessing(finalColor);\n#endif\n#ifdef PREMULTIPLYALPHA\n\nfinalColor.rgb*=finalColor.a;\n#endif\ngl_FragColor=finalColor;\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n}\n";
  125264. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125265. /** @hidden */
  125266. var pbrPixelShader = { name: name, shader: shader };
  125267. /***/ }),
  125268. /***/ "./Shaders/pbr.vertex.ts":
  125269. /*!*******************************!*\
  125270. !*** ./Shaders/pbr.vertex.ts ***!
  125271. \*******************************/
  125272. /*! exports provided: pbrVertexShader */
  125273. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125274. "use strict";
  125275. __webpack_require__.r(__webpack_exports__);
  125276. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "pbrVertexShader", function() { return pbrVertexShader; });
  125277. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125278. /* harmony import */ var _ShadersInclude_pbrVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/pbrVertexDeclaration */ "./Shaders/ShadersInclude/pbrVertexDeclaration.ts");
  125279. /* harmony import */ var _ShadersInclude_pbrUboDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/pbrUboDeclaration */ "./Shaders/ShadersInclude/pbrUboDeclaration.ts");
  125280. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125281. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125282. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125283. /* harmony import */ var _ShadersInclude_harmonicsFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/harmonicsFunctions */ "./Shaders/ShadersInclude/harmonicsFunctions.ts");
  125284. /* harmony import */ var _ShadersInclude_bumpVertexDeclaration__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/bumpVertexDeclaration */ "./Shaders/ShadersInclude/bumpVertexDeclaration.ts");
  125285. /* harmony import */ var _ShadersInclude_clipPlaneVertexDeclaration__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertexDeclaration */ "./Shaders/ShadersInclude/clipPlaneVertexDeclaration.ts");
  125286. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125287. /* harmony import */ var _ShadersInclude_lightFragmentDeclaration__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./ShadersInclude/lightFragmentDeclaration */ "./Shaders/ShadersInclude/lightFragmentDeclaration.ts");
  125288. /* harmony import */ var _ShadersInclude_lightUboDeclaration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ShadersInclude/lightUboDeclaration */ "./Shaders/ShadersInclude/lightUboDeclaration.ts");
  125289. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  125290. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  125291. /* harmony import */ var _ShadersInclude_logDepthDeclaration__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./ShadersInclude/logDepthDeclaration */ "./Shaders/ShadersInclude/logDepthDeclaration.ts");
  125292. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  125293. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125294. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125295. /* harmony import */ var _ShadersInclude_bumpVertex__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./ShadersInclude/bumpVertex */ "./Shaders/ShadersInclude/bumpVertex.ts");
  125296. /* harmony import */ var _ShadersInclude_clipPlaneVertex__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./ShadersInclude/clipPlaneVertex */ "./Shaders/ShadersInclude/clipPlaneVertex.ts");
  125297. /* harmony import */ var _ShadersInclude_fogVertex__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./ShadersInclude/fogVertex */ "./Shaders/ShadersInclude/fogVertex.ts");
  125298. /* harmony import */ var _ShadersInclude_shadowsVertex__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./ShadersInclude/shadowsVertex */ "./Shaders/ShadersInclude/shadowsVertex.ts");
  125299. /* harmony import */ var _ShadersInclude_logDepthVertex__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ShadersInclude/logDepthVertex */ "./Shaders/ShadersInclude/logDepthVertex.ts");
  125300. var name = 'pbrVertexShader';
  125301. var shader = "precision highp float;\n#include<__decl__pbrVertex>\n\nattribute vec3 position;\n#ifdef NORMAL\nattribute vec3 normal;\n#endif\n#ifdef TANGENT\nattribute vec4 tangent;\n#endif\n#ifdef UV1\nattribute vec2 uv;\n#endif\n#ifdef UV2\nattribute vec2 uv2;\n#endif\n#ifdef MAINUV1\nvarying vec2 vMainUV1;\n#endif\n#ifdef MAINUV2\nvarying vec2 vMainUV2;\n#endif\n#ifdef VERTEXCOLOR\nattribute vec4 color;\n#endif\n#include<helperFunctions>\n#include<bonesDeclaration>\n\n#include<instancesDeclaration>\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nvarying vec2 vAlbedoUV;\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nvarying vec2 vAmbientUV;\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nvarying vec2 vOpacityUV;\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nvarying vec2 vEmissiveUV;\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nvarying vec2 vLightmapUV;\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nvarying vec2 vReflectivityUV;\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nvarying vec2 vMicroSurfaceSamplerUV;\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nvarying vec2 vBumpUV;\n#endif\n#ifdef CLEARCOAT\n#if defined(CLEARCOAT_TEXTURE) && CLEARCOAT_TEXTUREDIRECTUV == 0\nvarying vec2 vClearCoatUV;\n#endif\n#if defined(CLEARCOAT_BUMP) && CLEARCOAT_BUMPDIRECTUV == 0\nvarying vec2 vClearCoatBumpUV;\n#endif\n#endif\n\nvarying vec3 vPositionW;\n#ifdef NORMAL\nvarying vec3 vNormalW;\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvarying vec3 vEnvironmentIrradiance;\n#include<harmonicsFunctions>\n#endif\n#endif\n#ifdef VERTEXCOLOR\nvarying vec4 vColor;\n#endif\n#include<bumpVertexDeclaration>\n#include<clipPlaneVertexDeclaration>\n#include<fogVertexDeclaration>\n#include<__decl__lightFragment>[0..maxSimultaneousLights]\n#include<morphTargetsVertexGlobalDeclaration>\n#include<morphTargetsVertexDeclaration>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\nvarying vec3 vPositionUVW;\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvarying vec3 vDirectionW;\n#endif\n#include<logDepthDeclaration>\nvoid main(void) {\nvec3 positionUpdated=position;\n#ifdef NORMAL\nvec3 normalUpdated=normal;\n#endif\n#ifdef TANGENT\nvec4 tangentUpdated=tangent;\n#endif\n#include<morphTargetsVertex>[0..maxSimultaneousMorphTargets]\n#ifdef REFLECTIONMAP_SKYBOX\n#ifdef REFLECTIONMAP_SKYBOX_TRANSFORMED\nvPositionUVW=(reflectionMatrix*vec4(positionUpdated,1.0)).xyz;\n#else\nvPositionUVW=positionUpdated;\n#endif\n#endif\n#include<instancesVertex>\n#include<bonesVertex>\ngl_Position=viewProjection*finalWorld*vec4(positionUpdated,1.0);\nvec4 worldPos=finalWorld*vec4(positionUpdated,1.0);\nvPositionW=vec3(worldPos);\n#ifdef NORMAL\nmat3 normalWorld=mat3(finalWorld);\n#ifdef NONUNIFORMSCALING\nnormalWorld=transposeMat3(inverseMat3(normalWorld));\n#endif\nvNormalW=normalize(normalWorld*normalUpdated);\n#if defined(USESPHERICALFROMREFLECTIONMAP) && defined(USESPHERICALINVERTEX)\nvec3 reflectionVector=vec3(reflectionMatrix*vec4(vNormalW,0)).xyz;\n#ifdef REFLECTIONMAP_OPPOSITEZ\nreflectionVector.z*=-1.0;\n#endif\nvEnvironmentIrradiance=environmentIrradianceJones(reflectionVector);\n#endif\n#endif\n#if defined(REFLECTIONMAP_EQUIRECTANGULAR_FIXED) || defined(REFLECTIONMAP_MIRROREDEQUIRECTANGULAR_FIXED)\nvDirectionW=normalize(vec3(finalWorld*vec4(positionUpdated,0.0)));\n#endif\n\n#ifndef UV1\nvec2 uv=vec2(0.,0.);\n#endif\n#ifndef UV2\nvec2 uv2=vec2(0.,0.);\n#endif\n#ifdef MAINUV1\nvMainUV1=uv;\n#endif\n#ifdef MAINUV2\nvMainUV2=uv2;\n#endif\n#if defined(ALBEDO) && ALBEDODIRECTUV == 0\nif (vAlbedoInfos.x == 0.)\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAlbedoUV=vec2(albedoMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(AMBIENT) && AMBIENTDIRECTUV == 0\nif (vAmbientInfos.x == 0.)\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvAmbientUV=vec2(ambientMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(OPACITY) && OPACITYDIRECTUV == 0\nif (vOpacityInfos.x == 0.)\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvOpacityUV=vec2(opacityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(EMISSIVE) && EMISSIVEDIRECTUV == 0\nif (vEmissiveInfos.x == 0.)\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvEmissiveUV=vec2(emissiveMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(LIGHTMAP) && LIGHTMAPDIRECTUV == 0\nif (vLightmapInfos.x == 0.)\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvLightmapUV=vec2(lightmapMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(REFLECTIVITY) && REFLECTIVITYDIRECTUV == 0\nif (vReflectivityInfos.x == 0.)\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvReflectivityUV=vec2(reflectivityMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(MICROSURFACEMAP) && MICROSURFACEMAPDIRECTUV == 0\nif (vMicroSurfaceSamplerInfos.x == 0.)\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvMicroSurfaceSamplerUV=vec2(microSurfaceSamplerMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#if defined(BUMP) && BUMPDIRECTUV == 0\nif (vBumpInfos.x == 0.)\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv,1.0,0.0));\n}\nelse\n{\nvBumpUV=vec2(bumpMatrix*vec4(uv2,1.0,0.0));\n}\n#endif\n#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#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}";
  125302. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125303. /** @hidden */
  125304. var pbrVertexShader = { name: name, shader: shader };
  125305. /***/ }),
  125306. /***/ "./Shaders/postprocess.vertex.ts":
  125307. /*!***************************************!*\
  125308. !*** ./Shaders/postprocess.vertex.ts ***!
  125309. \***************************************/
  125310. /*! exports provided: postprocessVertexShader */
  125311. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125312. "use strict";
  125313. __webpack_require__.r(__webpack_exports__);
  125314. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postprocessVertexShader", function() { return postprocessVertexShader; });
  125315. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125316. var name = 'postprocessVertexShader';
  125317. 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}";
  125318. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125319. /** @hidden */
  125320. var postprocessVertexShader = { name: name, shader: shader };
  125321. /***/ }),
  125322. /***/ "./Shaders/procedural.vertex.ts":
  125323. /*!**************************************!*\
  125324. !*** ./Shaders/procedural.vertex.ts ***!
  125325. \**************************************/
  125326. /*! exports provided: proceduralVertexShader */
  125327. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125328. "use strict";
  125329. __webpack_require__.r(__webpack_exports__);
  125330. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "proceduralVertexShader", function() { return proceduralVertexShader; });
  125331. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125332. var name = 'proceduralVertexShader';
  125333. 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}";
  125334. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125335. /** @hidden */
  125336. var proceduralVertexShader = { name: name, shader: shader };
  125337. /***/ }),
  125338. /***/ "./Shaders/refraction.fragment.ts":
  125339. /*!****************************************!*\
  125340. !*** ./Shaders/refraction.fragment.ts ***!
  125341. \****************************************/
  125342. /*! exports provided: refractionPixelShader */
  125343. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125344. "use strict";
  125345. __webpack_require__.r(__webpack_exports__);
  125346. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "refractionPixelShader", function() { return refractionPixelShader; });
  125347. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125348. var name = 'refractionPixelShader';
  125349. 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}";
  125350. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125351. /** @hidden */
  125352. var refractionPixelShader = { name: name, shader: shader };
  125353. /***/ }),
  125354. /***/ "./Shaders/rgbdDecode.fragment.ts":
  125355. /*!****************************************!*\
  125356. !*** ./Shaders/rgbdDecode.fragment.ts ***!
  125357. \****************************************/
  125358. /*! exports provided: rgbdDecodePixelShader */
  125359. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125360. "use strict";
  125361. __webpack_require__.r(__webpack_exports__);
  125362. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdDecodePixelShader", function() { return rgbdDecodePixelShader; });
  125363. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125364. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125365. var name = 'rgbdDecodePixelShader';
  125366. 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}";
  125367. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125368. /** @hidden */
  125369. var rgbdDecodePixelShader = { name: name, shader: shader };
  125370. /***/ }),
  125371. /***/ "./Shaders/rgbdEncode.fragment.ts":
  125372. /*!****************************************!*\
  125373. !*** ./Shaders/rgbdEncode.fragment.ts ***!
  125374. \****************************************/
  125375. /*! exports provided: rgbdEncodePixelShader */
  125376. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125377. "use strict";
  125378. __webpack_require__.r(__webpack_exports__);
  125379. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "rgbdEncodePixelShader", function() { return rgbdEncodePixelShader; });
  125380. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125381. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125382. var name = 'rgbdEncodePixelShader';
  125383. var shader = "\nvarying vec2 vUV;\nuniform sampler2D textureSampler;\n#include<helperFunctions>\nvoid main(void)\n{\ngl_FragColor=toRGBD(texture2D(textureSampler,vUV).rgb);\n}";
  125384. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125385. /** @hidden */
  125386. var rgbdEncodePixelShader = { name: name, shader: shader };
  125387. /***/ }),
  125388. /***/ "./Shaders/shadowMap.fragment.ts":
  125389. /*!***************************************!*\
  125390. !*** ./Shaders/shadowMap.fragment.ts ***!
  125391. \***************************************/
  125392. /*! exports provided: shadowMapPixelShader */
  125393. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125394. "use strict";
  125395. __webpack_require__.r(__webpack_exports__);
  125396. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapPixelShader", function() { return shadowMapPixelShader; });
  125397. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125398. var name = 'shadowMapPixelShader';
  125399. 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}";
  125400. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125401. /** @hidden */
  125402. var shadowMapPixelShader = { name: name, shader: shader };
  125403. /***/ }),
  125404. /***/ "./Shaders/shadowMap.vertex.ts":
  125405. /*!*************************************!*\
  125406. !*** ./Shaders/shadowMap.vertex.ts ***!
  125407. \*************************************/
  125408. /*! exports provided: shadowMapVertexShader */
  125409. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125410. "use strict";
  125411. __webpack_require__.r(__webpack_exports__);
  125412. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shadowMapVertexShader", function() { return shadowMapVertexShader; });
  125413. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125414. /* harmony import */ var _ShadersInclude_bonesDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/bonesDeclaration */ "./Shaders/ShadersInclude/bonesDeclaration.ts");
  125415. /* harmony import */ var _ShadersInclude_morphTargetsVertexGlobalDeclaration__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexGlobalDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexGlobalDeclaration.ts");
  125416. /* harmony import */ var _ShadersInclude_morphTargetsVertexDeclaration__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertexDeclaration */ "./Shaders/ShadersInclude/morphTargetsVertexDeclaration.ts");
  125417. /* harmony import */ var _ShadersInclude_instancesDeclaration__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./ShadersInclude/instancesDeclaration */ "./Shaders/ShadersInclude/instancesDeclaration.ts");
  125418. /* harmony import */ var _ShadersInclude_helperFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./ShadersInclude/helperFunctions */ "./Shaders/ShadersInclude/helperFunctions.ts");
  125419. /* harmony import */ var _ShadersInclude_morphTargetsVertex__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ShadersInclude/morphTargetsVertex */ "./Shaders/ShadersInclude/morphTargetsVertex.ts");
  125420. /* harmony import */ var _ShadersInclude_instancesVertex__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./ShadersInclude/instancesVertex */ "./Shaders/ShadersInclude/instancesVertex.ts");
  125421. /* harmony import */ var _ShadersInclude_bonesVertex__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ShadersInclude/bonesVertex */ "./Shaders/ShadersInclude/bonesVertex.ts");
  125422. var name = 'shadowMapVertexShader';
  125423. 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}";
  125424. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125425. /** @hidden */
  125426. var shadowMapVertexShader = { name: name, shader: shader };
  125427. /***/ }),
  125428. /***/ "./Shaders/sharpen.fragment.ts":
  125429. /*!*************************************!*\
  125430. !*** ./Shaders/sharpen.fragment.ts ***!
  125431. \*************************************/
  125432. /*! exports provided: sharpenPixelShader */
  125433. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125434. "use strict";
  125435. __webpack_require__.r(__webpack_exports__);
  125436. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sharpenPixelShader", function() { return sharpenPixelShader; });
  125437. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125438. var name = 'sharpenPixelShader';
  125439. 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}";
  125440. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125441. /** @hidden */
  125442. var sharpenPixelShader = { name: name, shader: shader };
  125443. /***/ }),
  125444. /***/ "./Shaders/sprites.fragment.ts":
  125445. /*!*************************************!*\
  125446. !*** ./Shaders/sprites.fragment.ts ***!
  125447. \*************************************/
  125448. /*! exports provided: spritesPixelShader */
  125449. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125450. "use strict";
  125451. __webpack_require__.r(__webpack_exports__);
  125452. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesPixelShader", function() { return spritesPixelShader; });
  125453. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125454. /* harmony import */ var _ShadersInclude_fogFragmentDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogFragmentDeclaration */ "./Shaders/ShadersInclude/fogFragmentDeclaration.ts");
  125455. /* harmony import */ var _ShadersInclude_fogFragment__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./ShadersInclude/fogFragment */ "./Shaders/ShadersInclude/fogFragment.ts");
  125456. var name = 'spritesPixelShader';
  125457. 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}";
  125458. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125459. /** @hidden */
  125460. var spritesPixelShader = { name: name, shader: shader };
  125461. /***/ }),
  125462. /***/ "./Shaders/sprites.vertex.ts":
  125463. /*!***********************************!*\
  125464. !*** ./Shaders/sprites.vertex.ts ***!
  125465. \***********************************/
  125466. /*! exports provided: spritesVertexShader */
  125467. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125468. "use strict";
  125469. __webpack_require__.r(__webpack_exports__);
  125470. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "spritesVertexShader", function() { return spritesVertexShader; });
  125471. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125472. /* harmony import */ var _ShadersInclude_fogVertexDeclaration__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./ShadersInclude/fogVertexDeclaration */ "./Shaders/ShadersInclude/fogVertexDeclaration.ts");
  125473. var name = 'spritesVertexShader';
  125474. 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}";
  125475. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125476. /** @hidden */
  125477. var spritesVertexShader = { name: name, shader: shader };
  125478. /***/ }),
  125479. /***/ "./Shaders/ssao.fragment.ts":
  125480. /*!**********************************!*\
  125481. !*** ./Shaders/ssao.fragment.ts ***!
  125482. \**********************************/
  125483. /*! exports provided: ssaoPixelShader */
  125484. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125485. "use strict";
  125486. __webpack_require__.r(__webpack_exports__);
  125487. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoPixelShader", function() { return ssaoPixelShader; });
  125488. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125489. var name = 'ssaoPixelShader';
  125490. 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";
  125491. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125492. /** @hidden */
  125493. var ssaoPixelShader = { name: name, shader: shader };
  125494. /***/ }),
  125495. /***/ "./Shaders/ssao2.fragment.ts":
  125496. /*!***********************************!*\
  125497. !*** ./Shaders/ssao2.fragment.ts ***!
  125498. \***********************************/
  125499. /*! exports provided: ssao2PixelShader */
  125500. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125501. "use strict";
  125502. __webpack_require__.r(__webpack_exports__);
  125503. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssao2PixelShader", function() { return ssao2PixelShader; });
  125504. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125505. var name = 'ssao2PixelShader';
  125506. 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";
  125507. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125508. /** @hidden */
  125509. var ssao2PixelShader = { name: name, shader: shader };
  125510. /***/ }),
  125511. /***/ "./Shaders/ssaoCombine.fragment.ts":
  125512. /*!*****************************************!*\
  125513. !*** ./Shaders/ssaoCombine.fragment.ts ***!
  125514. \*****************************************/
  125515. /*! exports provided: ssaoCombinePixelShader */
  125516. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125517. "use strict";
  125518. __webpack_require__.r(__webpack_exports__);
  125519. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ssaoCombinePixelShader", function() { return ssaoCombinePixelShader; });
  125520. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125521. var name = 'ssaoCombinePixelShader';
  125522. 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";
  125523. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125524. /** @hidden */
  125525. var ssaoCombinePixelShader = { name: name, shader: shader };
  125526. /***/ }),
  125527. /***/ "./Shaders/standard.fragment.ts":
  125528. /*!**************************************!*\
  125529. !*** ./Shaders/standard.fragment.ts ***!
  125530. \**************************************/
  125531. /*! exports provided: standardPixelShader */
  125532. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125533. "use strict";
  125534. __webpack_require__.r(__webpack_exports__);
  125535. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "standardPixelShader", function() { return standardPixelShader; });
  125536. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125537. var name = 'standardPixelShader';
  125538. var shader = "uniform sampler2D textureSampler;\nvarying vec2 vUV;\n#if defined(PASS_POST_PROCESS)\nvoid main(void)\n{\nvec4 color=texture2D(textureSampler,vUV);\ngl_FragColor=color;\n}\n#endif\n#if defined(DOWN_SAMPLE_X4)\nuniform vec2 dsOffsets[16];\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+dsOffsets[0]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[1]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[2]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[3]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[4]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[5]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[6]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[7]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[8]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[9]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[10]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[11]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[12]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[13]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[14]);\naverage+=texture2D(textureSampler,vUV+dsOffsets[15]);\naverage/=16.0;\ngl_FragColor=average;\n}\n#endif\n#if defined(BRIGHT_PASS)\nuniform vec2 dsOffsets[4];\nuniform float brightThreshold;\nvoid main(void)\n{\nvec4 average=vec4(0.0,0.0,0.0,0.0);\naverage=texture2D(textureSampler,vUV+vec2(dsOffsets[0].x,dsOffsets[0].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[1].x,dsOffsets[1].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[2].x,dsOffsets[2].y));\naverage+=texture2D(textureSampler,vUV+vec2(dsOffsets[3].x,dsOffsets[3].y));\naverage*=0.25;\nfloat luminance=length(average.rgb);\nif (luminance<brightThreshold) {\naverage=vec4(0.0,0.0,0.0,1.0);\n}\ngl_FragColor=average;\n}\n#endif\n#if defined(TEXTURE_ADDER)\nuniform sampler2D otherSampler;\nuniform sampler2D lensSampler;\nuniform float exposure;\nvoid main(void)\n{\nvec3 colour=texture2D(textureSampler,vUV).rgb;\ncolour*=exposure;\nvec3 X=max(vec3(0.0,0.0,0.0),colour-0.004);\nvec3 retColor=(X*(6.2*X+0.5))/(X*(6.2*X+1.7)+0.06);\ncolour=retColor*retColor;\ncolour+=colour*texture2D(lensSampler,vUV).rgb;\nvec4 finalColor=vec4(colour.rgb,1.0)+texture2D(otherSampler,vUV);\ngl_FragColor=finalColor;\n}\n#endif\n#if defined(VLS)\n#define PI 3.1415926535897932384626433832795\nuniform mat4 shadowViewProjection;\nuniform mat4 lightWorld;\nuniform vec3 cameraPosition;\nuniform vec3 sunDirection;\nuniform vec3 sunColor;\nuniform vec2 depthValues;\nuniform float scatteringCoefficient;\nuniform float scatteringPower;\nuniform sampler2D shadowMapSampler;\nuniform sampler2D positionSampler;\nfloat computeScattering(float lightDotView)\n{\nfloat result=1.0-scatteringCoefficient*scatteringCoefficient;\nresult/=(4.0*PI*pow(1.0+scatteringCoefficient*scatteringCoefficient-(2.0*scatteringCoefficient)*lightDotView,1.5));\nreturn result;\n}\nvoid main(void)\n{\n\nvec3 worldPos=texture2D(positionSampler,vUV).rgb;\nvec3 startPosition=cameraPosition;\nvec3 rayVector=worldPos-startPosition;\nfloat rayLength=length(rayVector);\nvec3 rayDirection=rayVector/rayLength;\nfloat stepLength=rayLength/NB_STEPS;\nvec3 stepL=rayDirection*stepLength;\nvec3 currentPosition=startPosition;\nvec3 accumFog=vec3(0.0);\nfor (int i=0; i<int(NB_STEPS); i++)\n{\nvec4 worldInShadowCameraSpace=shadowViewProjection*vec4(currentPosition,1.0);\nfloat depthMetric=(worldInShadowCameraSpace.z+depthValues.x)/(depthValues.y);\nfloat shadowPixelDepth=clamp(depthMetric,0.0,1.0);\nworldInShadowCameraSpace.xyz/=worldInShadowCameraSpace.w;\nworldInShadowCameraSpace.xyz=0.5*worldInShadowCameraSpace.xyz+vec3(0.5);\nfloat shadowMapValue=texture2D(shadowMapSampler,worldInShadowCameraSpace.xy).r;\nif (shadowMapValue>shadowPixelDepth)\naccumFog+=sunColor*computeScattering(dot(rayDirection,sunDirection));\ncurrentPosition+=stepL;\n}\naccumFog/=NB_STEPS;\nvec3 color=accumFog*scatteringPower;\ngl_FragColor=vec4(color*exp(color) ,1.0);\n}\n#endif\n#if defined(VLSMERGE)\nuniform sampler2D originalSampler;\nvoid main(void)\n{\ngl_FragColor=texture2D(originalSampler,vUV)+texture2D(textureSampler,vUV);\n}\n#endif\n#if defined(LUMINANCE)\nuniform vec2 lumOffsets[4];\nvoid main()\n{\nfloat average=0.0;\nvec4 color=vec4(0.0);\nfloat maximum=-1e20;\nvec3 weight=vec3(0.299,0.587,0.114);\nfor (int i=0; i<4; i++)\n{\ncolor=texture2D(textureSampler,vUV+ lumOffsets[i]);\n\nfloat GreyValue=dot(color.rgb,vec3(0.33,0.33,0.33));\n\n#ifdef WEIGHTED_AVERAGE\nfloat GreyValue=dot(color.rgb,weight);\n#endif\n#ifdef BRIGHTNESS\nfloat GreyValue=max(color.r,max(color.g,color.b));\n#endif\n#ifdef HSL_COMPONENT\nfloat GreyValue=0.5*(max(color.r,max(color.g,color.b))+min(color.r,min(color.g,color.b)));\n#endif\n#ifdef MAGNITUDE\nfloat GreyValue=length(color.rgb);\n#endif\nmaximum=max(maximum,GreyValue);\naverage+=(0.25*log(1e-5+GreyValue));\n}\naverage=exp(average);\ngl_FragColor=vec4(average,maximum,0.0,1.0);\n}\n#endif\n#if defined(LUMINANCE_DOWN_SAMPLE)\nuniform vec2 dsOffsets[9];\nuniform float halfDestPixelSize;\n#ifdef FINAL_DOWN_SAMPLER\nvec4 pack(float value) {\nconst vec4 bit_shift=vec4(255.0*255.0*255.0,255.0*255.0,255.0,1.0);\nconst vec4 bit_mask=vec4(0.0,1.0/255.0,1.0/255.0,1.0/255.0);\nvec4 res=fract(value*bit_shift);\nres-=res.xxyz*bit_mask;\nreturn res;\n}\n#endif\nvoid main()\n{\nvec4 color=vec4(0.0);\nfloat average=0.0;\nfor (int i=0; i<9; i++)\n{\ncolor=texture2D(textureSampler,vUV+vec2(halfDestPixelSize,halfDestPixelSize)+dsOffsets[i]);\naverage+=color.r;\n}\naverage/=9.0;\n#ifdef FINAL_DOWN_SAMPLER\ngl_FragColor=pack(average);\n#else\ngl_FragColor=vec4(average,average,0.0,1.0);\n#endif\n}\n#endif\n#if defined(HDR)\nuniform sampler2D textureAdderSampler;\nuniform float averageLuminance;\nvoid main()\n{\nvec4 color=texture2D(textureAdderSampler,vUV);\nvec4 adjustedColor=color/averageLuminance;\ncolor=adjustedColor;\ncolor.a=1.0;\ngl_FragColor=color;\n}\n#endif\n#if defined(LENS_FLARE)\n#define GHOSTS 3\nuniform sampler2D lensColorSampler;\nuniform float strength;\nuniform float ghostDispersal;\nuniform float haloWidth;\nuniform vec2 resolution;\nuniform float distortionStrength;\nfloat hash(vec2 p)\n{\nfloat h=dot(p,vec2(127.1,311.7));\nreturn -1.0+2.0*fract(sin(h)*43758.5453123);\n}\nfloat noise(in vec2 p)\n{\nvec2 i=floor(p);\nvec2 f=fract(p);\nvec2 u=f*f*(3.0-2.0*f);\nreturn mix(mix(hash(i+vec2(0.0,0.0)),\nhash(i+vec2(1.0,0.0)),u.x),\nmix(hash(i+vec2(0.0,1.0)),\nhash(i+vec2(1.0,1.0)),u.x),u.y);\n}\nfloat fbm(vec2 p)\n{\nfloat f=0.0;\nf+=0.5000*noise(p); p*=2.02;\nf+=0.2500*noise(p); p*=2.03;\nf+=0.1250*noise(p); p*=2.01;\nf+=0.0625*noise(p); p*=2.04;\nf/=0.9375;\nreturn f;\n}\nvec3 pattern(vec2 uv)\n{\nvec2 p=-1.0+2.0*uv;\nfloat p2=dot(p,p);\nfloat f=fbm(vec2(15.0*p2))/2.0;\nfloat r=0.2+0.6*sin(12.5*length(uv-vec2(0.5)));\nfloat g=0.2+0.6*sin(20.5*length(uv-vec2(0.5)));\nfloat b=0.2+0.6*sin(17.2*length(uv-vec2(0.5)));\nreturn (1.0-f)*vec3(r,g,b);\n}\nfloat luminance(vec3 color)\n{\nreturn dot(color.rgb,vec3(0.2126,0.7152,0.0722));\n}\nvec4 textureDistorted(sampler2D tex,vec2 texcoord,vec2 direction,vec3 distortion)\n{\nreturn vec4(\ntexture2D(tex,texcoord+direction*distortion.r).r,\ntexture2D(tex,texcoord+direction*distortion.g).g,\ntexture2D(tex,texcoord+direction*distortion.b).b,\n1.0\n);\n}\nvoid main(void)\n{\nvec2 uv=-vUV+vec2(1.0);\nvec2 ghostDir=(vec2(0.5)-uv)*ghostDispersal;\nvec2 texelSize=1.0/resolution;\nvec3 distortion=vec3(-texelSize.x*distortionStrength,0.0,texelSize.x*distortionStrength);\nvec4 result=vec4(0.0);\nfloat ghostIndice=1.0;\nfor (int i=0; i<GHOSTS; ++i)\n{\nvec2 offset=fract(uv+ghostDir*ghostIndice);\nfloat weight=length(vec2(0.5)-offset)/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,offset,normalize(ghostDir),distortion)*weight*strength;\nghostIndice+=1.0;\n}\nvec2 haloVec=normalize(ghostDir)*haloWidth;\nfloat weight=length(vec2(0.5)-fract(uv+haloVec))/length(vec2(0.5));\nweight=pow(1.0-weight,10.0);\nresult+=textureDistorted(textureSampler,fract(uv+haloVec),normalize(ghostDir),distortion)*weight*strength;\nresult*=texture2D(lensColorSampler,vec2(length(vec2(0.5)-uv)/length(vec2(0.5))));\ngl_FragColor=result;\n}\n#endif\n#if defined(LENS_FLARE_COMPOSE)\nuniform sampler2D otherSampler;\nuniform sampler2D lensDirtSampler;\nuniform sampler2D lensStarSampler;\nuniform mat4 lensStarMatrix;\nvoid main(void)\n{\nvec2 lensFlareCoords=(lensStarMatrix*vec4(vUV,1.0,1.0)).xy;\nvec4 lensMod=texture2D(lensDirtSampler,vUV);\nlensMod+=texture2D(lensStarSampler,vUV);\nvec4 result=texture2D(textureSampler,vUV)*lensMod;\ngl_FragColor=texture2D(otherSampler,vUV)+result;\n}\n#endif\n#if defined(DEPTH_OF_FIELD)\nuniform sampler2D otherSampler;\nuniform sampler2D depthSampler;\nuniform float distance;\nvoid main(void)\n{\nvec4 sharp=texture2D(otherSampler,vUV);\nvec4 blur=texture2D(textureSampler,vUV);\nfloat dist=clamp(texture2D(depthSampler,vUV).r*distance,0.0,1.0);\nfloat factor=0.0;\nif (dist<0.05)\nfactor=1.0;\nelse if (dist<0.1)\nfactor=20.0*(0.1-dist);\nelse if (dist<0.5)\nfactor=0.0;\nelse\nfactor=2.0*(dist-0.5);\nfactor=clamp(factor,0.0,0.90);\ngl_FragColor=mix(sharp,blur,factor);\n}\n#endif\n#if defined(MOTION_BLUR)\nuniform mat4 inverseViewProjection;\nuniform mat4 prevViewProjection;\nuniform vec2 screenSize;\nuniform float motionScale;\nuniform float motionStrength;\nuniform sampler2D depthSampler;\nvoid main(void)\n{\nvec2 texelSize=1.0/screenSize;\nfloat depth=texture2D(depthSampler,vUV).r;\nvec4 cpos=vec4(vUV*2.0-1.0,depth,1.0);\ncpos=cpos*inverseViewProjection;\nvec4 ppos=cpos*prevViewProjection;\nppos.xyz/=ppos.w;\nppos.xy=ppos.xy*0.5+0.5;\nvec2 velocity=(ppos.xy-vUV)*motionScale*motionStrength;\nfloat speed=length(velocity/texelSize);\nint nSamples=int(clamp(speed,1.0,MAX_MOTION_SAMPLES));\nvec4 result=texture2D(textureSampler,vUV);\nfor (int i=1; i<int(MAX_MOTION_SAMPLES); ++i) {\nif (i>=nSamples)\nbreak;\nvec2 offset1=vUV+velocity*(float(i)/float(nSamples-1)-0.5);\nresult+=texture2D(textureSampler,offset1);\n}\ngl_FragColor=result/float(nSamples);\n}\n#endif\n";
  125539. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125540. /** @hidden */
  125541. var standardPixelShader = { name: name, shader: shader };
  125542. /***/ }),
  125543. /***/ "./Shaders/stereoscopicInterlace.fragment.ts":
  125544. /*!***************************************************!*\
  125545. !*** ./Shaders/stereoscopicInterlace.fragment.ts ***!
  125546. \***************************************************/
  125547. /*! exports provided: stereoscopicInterlacePixelShader */
  125548. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125549. "use strict";
  125550. __webpack_require__.r(__webpack_exports__);
  125551. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stereoscopicInterlacePixelShader", function() { return stereoscopicInterlacePixelShader; });
  125552. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125553. var name = 'stereoscopicInterlacePixelShader';
  125554. 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}";
  125555. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125556. /** @hidden */
  125557. var stereoscopicInterlacePixelShader = { name: name, shader: shader };
  125558. /***/ }),
  125559. /***/ "./Shaders/tonemap.fragment.ts":
  125560. /*!*************************************!*\
  125561. !*** ./Shaders/tonemap.fragment.ts ***!
  125562. \*************************************/
  125563. /*! exports provided: tonemapPixelShader */
  125564. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125565. "use strict";
  125566. __webpack_require__.r(__webpack_exports__);
  125567. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "tonemapPixelShader", function() { return tonemapPixelShader; });
  125568. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125569. var name = 'tonemapPixelShader';
  125570. 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}";
  125571. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125572. /** @hidden */
  125573. var tonemapPixelShader = { name: name, shader: shader };
  125574. /***/ }),
  125575. /***/ "./Shaders/volumetricLightScattering.fragment.ts":
  125576. /*!*******************************************************!*\
  125577. !*** ./Shaders/volumetricLightScattering.fragment.ts ***!
  125578. \*******************************************************/
  125579. /*! exports provided: volumetricLightScatteringPixelShader */
  125580. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125581. "use strict";
  125582. __webpack_require__.r(__webpack_exports__);
  125583. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPixelShader", function() { return volumetricLightScatteringPixelShader; });
  125584. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125585. var name = 'volumetricLightScatteringPixelShader';
  125586. 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";
  125587. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125588. /** @hidden */
  125589. var volumetricLightScatteringPixelShader = { name: name, shader: shader };
  125590. /***/ }),
  125591. /***/ "./Shaders/volumetricLightScatteringPass.fragment.ts":
  125592. /*!***********************************************************!*\
  125593. !*** ./Shaders/volumetricLightScatteringPass.fragment.ts ***!
  125594. \***********************************************************/
  125595. /*! exports provided: volumetricLightScatteringPassPixelShader */
  125596. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125597. "use strict";
  125598. __webpack_require__.r(__webpack_exports__);
  125599. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "volumetricLightScatteringPassPixelShader", function() { return volumetricLightScatteringPassPixelShader; });
  125600. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125601. var name = 'volumetricLightScatteringPassPixelShader';
  125602. 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";
  125603. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125604. /** @hidden */
  125605. var volumetricLightScatteringPassPixelShader = { name: name, shader: shader };
  125606. /***/ }),
  125607. /***/ "./Shaders/vrDistortionCorrection.fragment.ts":
  125608. /*!****************************************************!*\
  125609. !*** ./Shaders/vrDistortionCorrection.fragment.ts ***!
  125610. \****************************************************/
  125611. /*! exports provided: vrDistortionCorrectionPixelShader */
  125612. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125613. "use strict";
  125614. __webpack_require__.r(__webpack_exports__);
  125615. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "vrDistortionCorrectionPixelShader", function() { return vrDistortionCorrectionPixelShader; });
  125616. /* harmony import */ var _Materials_effect__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Materials/effect */ "./Materials/effect.ts");
  125617. var name = 'vrDistortionCorrectionPixelShader';
  125618. 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}";
  125619. _Materials_effect__WEBPACK_IMPORTED_MODULE_0__["Effect"].ShadersStore[name] = shader;
  125620. /** @hidden */
  125621. var vrDistortionCorrectionPixelShader = { name: name, shader: shader };
  125622. /***/ }),
  125623. /***/ "./Sprites/index.ts":
  125624. /*!**************************!*\
  125625. !*** ./Sprites/index.ts ***!
  125626. \**************************/
  125627. /*! exports provided: Sprite, SpriteManager, SpriteSceneComponent */
  125628. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125629. "use strict";
  125630. __webpack_require__.r(__webpack_exports__);
  125631. /* harmony import */ var _sprite__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./sprite */ "./Sprites/sprite.ts");
  125632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _sprite__WEBPACK_IMPORTED_MODULE_0__["Sprite"]; });
  125633. /* harmony import */ var _spriteManager__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./spriteManager */ "./Sprites/spriteManager.ts");
  125634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _spriteManager__WEBPACK_IMPORTED_MODULE_1__["SpriteManager"]; });
  125635. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  125636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_2__["SpriteSceneComponent"]; });
  125637. /***/ }),
  125638. /***/ "./Sprites/sprite.ts":
  125639. /*!***************************!*\
  125640. !*** ./Sprites/sprite.ts ***!
  125641. \***************************/
  125642. /*! exports provided: Sprite */
  125643. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125644. "use strict";
  125645. __webpack_require__.r(__webpack_exports__);
  125646. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return Sprite; });
  125647. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125648. /**
  125649. * Class used to represent a sprite
  125650. * @see http://doc.babylonjs.com/babylon101/sprites
  125651. */
  125652. var Sprite = /** @class */ (function () {
  125653. /**
  125654. * Creates a new Sprite
  125655. * @param name defines the name
  125656. * @param manager defines the manager
  125657. */
  125658. function Sprite(
  125659. /** defines the name */
  125660. name, manager) {
  125661. this.name = name;
  125662. /** Gets or sets the main color */
  125663. this.color = new _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Color4"](1.0, 1.0, 1.0, 1.0);
  125664. /** Gets or sets the width */
  125665. this.width = 1.0;
  125666. /** Gets or sets the height */
  125667. this.height = 1.0;
  125668. /** Gets or sets rotation angle */
  125669. this.angle = 0;
  125670. /** Gets or sets the cell index in the sprite sheet */
  125671. this.cellIndex = 0;
  125672. /** Gets or sets a boolean indicating if UV coordinates should be inverted in U axis */
  125673. this.invertU = 0;
  125674. /** Gets or sets a boolean indicating if UV coordinates should be inverted in B axis */
  125675. this.invertV = 0;
  125676. /** Gets the list of attached animations */
  125677. this.animations = new Array();
  125678. /** Gets or sets a boolean indicating if the sprite can be picked */
  125679. this.isPickable = false;
  125680. this._animationStarted = false;
  125681. this._loopAnimation = false;
  125682. this._fromIndex = 0;
  125683. this._toIndex = 0;
  125684. this._delay = 0;
  125685. this._direction = 1;
  125686. this._time = 0;
  125687. /**
  125688. * Gets or sets a boolean indicating if the sprite is visible (renderable). Default is true
  125689. */
  125690. this.isVisible = true;
  125691. this._manager = manager;
  125692. this._manager.sprites.push(this);
  125693. this.position = _Maths_math__WEBPACK_IMPORTED_MODULE_0__["Vector3"].Zero();
  125694. }
  125695. Object.defineProperty(Sprite.prototype, "size", {
  125696. /**
  125697. * Gets or sets the sprite size
  125698. */
  125699. get: function () {
  125700. return this.width;
  125701. },
  125702. set: function (value) {
  125703. this.width = value;
  125704. this.height = value;
  125705. },
  125706. enumerable: true,
  125707. configurable: true
  125708. });
  125709. /**
  125710. * Starts an animation
  125711. * @param from defines the initial key
  125712. * @param to defines the end key
  125713. * @param loop defines if the animation must loop
  125714. * @param delay defines the start delay (in ms)
  125715. * @param onAnimationEnd defines a callback to call when animation ends
  125716. */
  125717. Sprite.prototype.playAnimation = function (from, to, loop, delay, onAnimationEnd) {
  125718. this._fromIndex = from;
  125719. this._toIndex = to;
  125720. this._loopAnimation = loop;
  125721. this._delay = delay;
  125722. this._animationStarted = true;
  125723. this._direction = from < to ? 1 : -1;
  125724. this.cellIndex = from;
  125725. this._time = 0;
  125726. this._onAnimationEnd = onAnimationEnd;
  125727. };
  125728. /** Stops current animation (if any) */
  125729. Sprite.prototype.stopAnimation = function () {
  125730. this._animationStarted = false;
  125731. };
  125732. /** @hidden */
  125733. Sprite.prototype._animate = function (deltaTime) {
  125734. if (!this._animationStarted) {
  125735. return;
  125736. }
  125737. this._time += deltaTime;
  125738. if (this._time > this._delay) {
  125739. this._time = this._time % this._delay;
  125740. this.cellIndex += this._direction;
  125741. if (this.cellIndex > this._toIndex) {
  125742. if (this._loopAnimation) {
  125743. this.cellIndex = this._fromIndex;
  125744. }
  125745. else {
  125746. this.cellIndex = this._toIndex;
  125747. this._animationStarted = false;
  125748. if (this._onAnimationEnd) {
  125749. this._onAnimationEnd();
  125750. }
  125751. if (this.disposeWhenFinishedAnimating) {
  125752. this.dispose();
  125753. }
  125754. }
  125755. }
  125756. }
  125757. };
  125758. /** Release associated resources */
  125759. Sprite.prototype.dispose = function () {
  125760. for (var i = 0; i < this._manager.sprites.length; i++) {
  125761. if (this._manager.sprites[i] == this) {
  125762. this._manager.sprites.splice(i, 1);
  125763. }
  125764. }
  125765. };
  125766. return Sprite;
  125767. }());
  125768. /***/ }),
  125769. /***/ "./Sprites/spriteManager.ts":
  125770. /*!**********************************!*\
  125771. !*** ./Sprites/spriteManager.ts ***!
  125772. \**********************************/
  125773. /*! exports provided: SpriteManager */
  125774. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  125775. "use strict";
  125776. __webpack_require__.r(__webpack_exports__);
  125777. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return SpriteManager; });
  125778. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  125779. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  125780. /* harmony import */ var _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Meshes/buffer */ "./Meshes/buffer.ts");
  125781. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Maths/math */ "./Maths/math.ts");
  125782. /* harmony import */ var _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./spriteSceneComponent */ "./Sprites/spriteSceneComponent.ts");
  125783. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  125784. /* harmony import */ var _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Materials/Textures/texture */ "./Materials/Textures/texture.ts");
  125785. /* harmony import */ var _Materials_material__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../Materials/material */ "./Materials/material.ts");
  125786. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  125787. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  125788. /* harmony import */ var _Shaders_sprites_fragment__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Shaders/sprites.fragment */ "./Shaders/sprites.fragment.ts");
  125789. /* harmony import */ var _Shaders_sprites_vertex__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Shaders/sprites.vertex */ "./Shaders/sprites.vertex.ts");
  125790. /**
  125791. * Class used to manage multiple sprites on the same spritesheet
  125792. * @see http://doc.babylonjs.com/babylon101/sprites
  125793. */
  125794. var SpriteManager = /** @class */ (function () {
  125795. /**
  125796. * Creates a new sprite manager
  125797. * @param name defines the manager's name
  125798. * @param imgUrl defines the sprite sheet url
  125799. * @param capacity defines the maximum allowed number of sprites
  125800. * @param cellSize defines the size of a sprite cell
  125801. * @param scene defines the hosting scene
  125802. * @param epsilon defines the epsilon value to align texture (0.01 by default)
  125803. * @param samplingMode defines the smapling mode to use with spritesheet
  125804. */
  125805. function SpriteManager(
  125806. /** defines the manager's name */
  125807. name, imgUrl, capacity, cellSize, scene, epsilon, samplingMode) {
  125808. if (epsilon === void 0) { epsilon = 0.01; }
  125809. if (samplingMode === void 0) { samplingMode = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].TRILINEAR_SAMPLINGMODE; }
  125810. this.name = name;
  125811. /** Gets the list of sprites */
  125812. this.sprites = new Array();
  125813. /** Gets or sets the rendering group id (0 by default) */
  125814. this.renderingGroupId = 0;
  125815. /** Gets or sets camera layer mask */
  125816. this.layerMask = 0x0FFFFFFF;
  125817. /** Gets or sets a boolean indicating if the manager must consider scene fog when rendering */
  125818. this.fogEnabled = true;
  125819. /** Gets or sets a boolean indicating if the sprites are pickable */
  125820. this.isPickable = false;
  125821. /**
  125822. * An event triggered when the manager is disposed.
  125823. */
  125824. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_1__["Observable"]();
  125825. this._vertexBuffers = {};
  125826. if (!scene._getComponent(_sceneComponent__WEBPACK_IMPORTED_MODULE_8__["SceneComponentConstants"].NAME_SPRITE)) {
  125827. scene._addComponent(new _spriteSceneComponent__WEBPACK_IMPORTED_MODULE_4__["SpriteSceneComponent"](scene));
  125828. }
  125829. this._capacity = capacity;
  125830. this._spriteTexture = new _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"](imgUrl, scene, true, false, samplingMode);
  125831. this._spriteTexture.wrapU = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125832. this._spriteTexture.wrapV = _Materials_Textures_texture__WEBPACK_IMPORTED_MODULE_6__["Texture"].CLAMP_ADDRESSMODE;
  125833. if (cellSize.width && cellSize.height) {
  125834. this.cellWidth = cellSize.width;
  125835. this.cellHeight = cellSize.height;
  125836. }
  125837. else if (cellSize !== undefined) {
  125838. this.cellWidth = cellSize;
  125839. this.cellHeight = cellSize;
  125840. }
  125841. else {
  125842. return;
  125843. }
  125844. this._epsilon = epsilon;
  125845. this._scene = scene;
  125846. this._scene.spriteManagers.push(this);
  125847. var indices = [];
  125848. var index = 0;
  125849. for (var count = 0; count < capacity; count++) {
  125850. indices.push(index);
  125851. indices.push(index + 1);
  125852. indices.push(index + 2);
  125853. indices.push(index);
  125854. indices.push(index + 2);
  125855. indices.push(index + 3);
  125856. index += 4;
  125857. }
  125858. this._indexBuffer = scene.getEngine().createIndexBuffer(indices);
  125859. // VBO
  125860. // 16 floats per sprite (x, y, z, angle, sizeX, sizeY, offsetX, offsetY, invertU, invertV, cellIndexX, cellIndexY, color r, color g, color b, color a)
  125861. this._vertexData = new Float32Array(capacity * 16 * 4);
  125862. this._buffer = new _Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["Buffer"](scene.getEngine(), this._vertexData, true, 16);
  125863. var positions = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind, 0, 4);
  125864. var options = this._buffer.createVertexBuffer("options", 4, 4);
  125865. var cellInfo = this._buffer.createVertexBuffer("cellInfo", 8, 4);
  125866. var colors = this._buffer.createVertexBuffer(_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind, 12, 4);
  125867. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].PositionKind] = positions;
  125868. this._vertexBuffers["options"] = options;
  125869. this._vertexBuffers["cellInfo"] = cellInfo;
  125870. this._vertexBuffers[_Meshes_buffer__WEBPACK_IMPORTED_MODULE_2__["VertexBuffer"].ColorKind] = colors;
  125871. // Effects
  125872. 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"], "");
  125873. 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");
  125874. }
  125875. Object.defineProperty(SpriteManager.prototype, "onDispose", {
  125876. /**
  125877. * Callback called when the manager is disposed
  125878. */
  125879. set: function (callback) {
  125880. if (this._onDisposeObserver) {
  125881. this.onDisposeObservable.remove(this._onDisposeObserver);
  125882. }
  125883. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  125884. },
  125885. enumerable: true,
  125886. configurable: true
  125887. });
  125888. Object.defineProperty(SpriteManager.prototype, "texture", {
  125889. /**
  125890. * Gets or sets the spritesheet texture
  125891. */
  125892. get: function () {
  125893. return this._spriteTexture;
  125894. },
  125895. set: function (value) {
  125896. this._spriteTexture = value;
  125897. },
  125898. enumerable: true,
  125899. configurable: true
  125900. });
  125901. SpriteManager.prototype._appendSpriteVertex = function (index, sprite, offsetX, offsetY, rowSize) {
  125902. var arrayOffset = index * 16;
  125903. if (offsetX === 0) {
  125904. offsetX = this._epsilon;
  125905. }
  125906. else if (offsetX === 1) {
  125907. offsetX = 1 - this._epsilon;
  125908. }
  125909. if (offsetY === 0) {
  125910. offsetY = this._epsilon;
  125911. }
  125912. else if (offsetY === 1) {
  125913. offsetY = 1 - this._epsilon;
  125914. }
  125915. this._vertexData[arrayOffset] = sprite.position.x;
  125916. this._vertexData[arrayOffset + 1] = sprite.position.y;
  125917. this._vertexData[arrayOffset + 2] = sprite.position.z;
  125918. this._vertexData[arrayOffset + 3] = sprite.angle;
  125919. this._vertexData[arrayOffset + 4] = sprite.width;
  125920. this._vertexData[arrayOffset + 5] = sprite.height;
  125921. this._vertexData[arrayOffset + 6] = offsetX;
  125922. this._vertexData[arrayOffset + 7] = offsetY;
  125923. this._vertexData[arrayOffset + 8] = sprite.invertU ? 1 : 0;
  125924. this._vertexData[arrayOffset + 9] = sprite.invertV ? 1 : 0;
  125925. var offset = (sprite.cellIndex / rowSize) >> 0;
  125926. this._vertexData[arrayOffset + 10] = sprite.cellIndex - offset * rowSize;
  125927. this._vertexData[arrayOffset + 11] = offset;
  125928. // Color
  125929. this._vertexData[arrayOffset + 12] = sprite.color.r;
  125930. this._vertexData[arrayOffset + 13] = sprite.color.g;
  125931. this._vertexData[arrayOffset + 14] = sprite.color.b;
  125932. this._vertexData[arrayOffset + 15] = sprite.color.a;
  125933. };
  125934. /**
  125935. * Intersects the sprites with a ray
  125936. * @param ray defines the ray to intersect with
  125937. * @param camera defines the current active camera
  125938. * @param predicate defines a predicate used to select candidate sprites
  125939. * @param fastCheck defines if a fast check only must be done (the first potential sprite is will be used and not the closer)
  125940. * @returns null if no hit or a PickingInfo
  125941. */
  125942. SpriteManager.prototype.intersects = function (ray, camera, predicate, fastCheck) {
  125943. var count = Math.min(this._capacity, this.sprites.length);
  125944. var min = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125945. var max = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125946. var distance = Number.MAX_VALUE;
  125947. var currentSprite = null;
  125948. var cameraSpacePosition = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Zero();
  125949. var cameraView = camera.getViewMatrix();
  125950. for (var index = 0; index < count; index++) {
  125951. var sprite = this.sprites[index];
  125952. if (!sprite) {
  125953. continue;
  125954. }
  125955. if (predicate) {
  125956. if (!predicate(sprite)) {
  125957. continue;
  125958. }
  125959. }
  125960. else if (!sprite.isPickable) {
  125961. continue;
  125962. }
  125963. _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].TransformCoordinatesToRef(sprite.position, cameraView, cameraSpacePosition);
  125964. min.copyFromFloats(cameraSpacePosition.x - sprite.width / 2, cameraSpacePosition.y - sprite.height / 2, cameraSpacePosition.z);
  125965. max.copyFromFloats(cameraSpacePosition.x + sprite.width / 2, cameraSpacePosition.y + sprite.height / 2, cameraSpacePosition.z);
  125966. if (ray.intersectsBoxMinMax(min, max)) {
  125967. var currentDistance = _Maths_math__WEBPACK_IMPORTED_MODULE_3__["Vector3"].Distance(cameraSpacePosition, ray.origin);
  125968. if (distance > currentDistance) {
  125969. distance = currentDistance;
  125970. currentSprite = sprite;
  125971. if (fastCheck) {
  125972. break;
  125973. }
  125974. }
  125975. }
  125976. }
  125977. if (currentSprite) {
  125978. var result = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_5__["PickingInfo"]();
  125979. result.hit = true;
  125980. result.pickedSprite = currentSprite;
  125981. result.distance = distance;
  125982. return result;
  125983. }
  125984. return null;
  125985. };
  125986. /**
  125987. * Render all child sprites
  125988. */
  125989. SpriteManager.prototype.render = function () {
  125990. // Check
  125991. if (!this._effectBase.isReady() || !this._effectFog.isReady() || !this._spriteTexture
  125992. || !this._spriteTexture.isReady() || !this.sprites.length) {
  125993. return;
  125994. }
  125995. var engine = this._scene.getEngine();
  125996. var baseSize = this._spriteTexture.getBaseSize();
  125997. // Sprites
  125998. var deltaTime = engine.getDeltaTime();
  125999. var max = Math.min(this._capacity, this.sprites.length);
  126000. var rowSize = baseSize.width / this.cellWidth;
  126001. var offset = 0;
  126002. for (var index = 0; index < max; index++) {
  126003. var sprite = this.sprites[index];
  126004. if (!sprite || !sprite.isVisible) {
  126005. continue;
  126006. }
  126007. sprite._animate(deltaTime);
  126008. this._appendSpriteVertex(offset++, sprite, 0, 0, rowSize);
  126009. this._appendSpriteVertex(offset++, sprite, 1, 0, rowSize);
  126010. this._appendSpriteVertex(offset++, sprite, 1, 1, rowSize);
  126011. this._appendSpriteVertex(offset++, sprite, 0, 1, rowSize);
  126012. }
  126013. this._buffer.update(this._vertexData);
  126014. // Render
  126015. var effect = this._effectBase;
  126016. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  126017. effect = this._effectFog;
  126018. }
  126019. engine.enableEffect(effect);
  126020. var viewMatrix = this._scene.getViewMatrix();
  126021. effect.setTexture("diffuseSampler", this._spriteTexture);
  126022. effect.setMatrix("view", viewMatrix);
  126023. effect.setMatrix("projection", this._scene.getProjectionMatrix());
  126024. effect.setFloat2("textureInfos", this.cellWidth / baseSize.width, this.cellHeight / baseSize.height);
  126025. // Fog
  126026. if (this._scene.fogEnabled && this._scene.fogMode !== _scene__WEBPACK_IMPORTED_MODULE_0__["Scene"].FOGMODE_NONE && this.fogEnabled) {
  126027. effect.setFloat4("vFogInfos", this._scene.fogMode, this._scene.fogStart, this._scene.fogEnd, this._scene.fogDensity);
  126028. effect.setColor3("vFogColor", this._scene.fogColor);
  126029. }
  126030. // VBOs
  126031. engine.bindBuffers(this._vertexBuffers, this._indexBuffer, effect);
  126032. // Draw order
  126033. engine.setDepthFunctionToLessOrEqual();
  126034. effect.setBool("alphaTest", true);
  126035. engine.setColorWrite(false);
  126036. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  126037. engine.setColorWrite(true);
  126038. effect.setBool("alphaTest", false);
  126039. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_COMBINE);
  126040. engine.drawElementsType(_Materials_material__WEBPACK_IMPORTED_MODULE_7__["Material"].TriangleFillMode, 0, (offset / 4) * 6);
  126041. engine.setAlphaMode(_Engines_constants__WEBPACK_IMPORTED_MODULE_9__["Constants"].ALPHA_DISABLE);
  126042. };
  126043. /**
  126044. * Release associated resources
  126045. */
  126046. SpriteManager.prototype.dispose = function () {
  126047. if (this._buffer) {
  126048. this._buffer.dispose();
  126049. this._buffer = null;
  126050. }
  126051. if (this._indexBuffer) {
  126052. this._scene.getEngine()._releaseBuffer(this._indexBuffer);
  126053. this._indexBuffer = null;
  126054. }
  126055. if (this._spriteTexture) {
  126056. this._spriteTexture.dispose();
  126057. this._spriteTexture = null;
  126058. }
  126059. // Remove from scene
  126060. var index = this._scene.spriteManagers.indexOf(this);
  126061. this._scene.spriteManagers.splice(index, 1);
  126062. // Callback
  126063. this.onDisposeObservable.notifyObservers(this);
  126064. this.onDisposeObservable.clear();
  126065. };
  126066. return SpriteManager;
  126067. }());
  126068. /***/ }),
  126069. /***/ "./Sprites/spriteSceneComponent.ts":
  126070. /*!*****************************************!*\
  126071. !*** ./Sprites/spriteSceneComponent.ts ***!
  126072. \*****************************************/
  126073. /*! exports provided: SpriteSceneComponent */
  126074. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126075. "use strict";
  126076. __webpack_require__.r(__webpack_exports__);
  126077. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return SpriteSceneComponent; });
  126078. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Misc/observable */ "./Misc/observable.ts");
  126079. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../scene */ "./scene.ts");
  126080. /* harmony import */ var _Culling_ray__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Culling/ray */ "./Culling/ray.ts");
  126081. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  126082. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../sceneComponent */ "./sceneComponent.ts");
  126083. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Actions/actionEvent */ "./Actions/actionEvent.ts");
  126084. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126085. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype._internalPickSprites = function (ray, predicate, fastCheck, camera) {
  126086. if (!_Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]) {
  126087. return null;
  126088. }
  126089. var pickingInfo = null;
  126090. if (!camera) {
  126091. if (!this.activeCamera) {
  126092. return null;
  126093. }
  126094. camera = this.activeCamera;
  126095. }
  126096. if (this.spriteManagers.length > 0) {
  126097. for (var spriteIndex = 0; spriteIndex < this.spriteManagers.length; spriteIndex++) {
  126098. var spriteManager = this.spriteManagers[spriteIndex];
  126099. if (!spriteManager.isPickable) {
  126100. continue;
  126101. }
  126102. var result = spriteManager.intersects(ray, camera, predicate, fastCheck);
  126103. if (!result || !result.hit) {
  126104. continue;
  126105. }
  126106. if (!fastCheck && pickingInfo != null && result.distance >= pickingInfo.distance) {
  126107. continue;
  126108. }
  126109. pickingInfo = result;
  126110. if (fastCheck) {
  126111. break;
  126112. }
  126113. }
  126114. }
  126115. return pickingInfo || new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_3__["PickingInfo"]();
  126116. };
  126117. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSprite = function (x, y, predicate, fastCheck, camera) {
  126118. this.createPickingRayInCameraSpaceToRef(x, y, this._tempSpritePickingRay, camera);
  126119. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  126120. };
  126121. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.pickSpriteWithRay = function (ray, predicate, fastCheck, camera) {
  126122. if (!this._tempSpritePickingRay) {
  126123. return null;
  126124. }
  126125. if (!camera) {
  126126. if (!this.activeCamera) {
  126127. return null;
  126128. }
  126129. camera = this.activeCamera;
  126130. }
  126131. _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].TransformToRef(ray, camera.getViewMatrix(), this._tempSpritePickingRay);
  126132. return this._internalPickSprites(this._tempSpritePickingRay, predicate, fastCheck, camera);
  126133. };
  126134. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.setPointerOverSprite = function (sprite) {
  126135. if (this._pointerOverSprite === sprite) {
  126136. return;
  126137. }
  126138. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  126139. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  126140. }
  126141. this._pointerOverSprite = sprite;
  126142. if (this._pointerOverSprite && this._pointerOverSprite.actionManager) {
  126143. this._pointerOverSprite.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_6__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_5__["ActionEvent"].CreateNewFromSprite(this._pointerOverSprite, this));
  126144. }
  126145. };
  126146. _scene__WEBPACK_IMPORTED_MODULE_1__["Scene"].prototype.getPointerOverSprite = function () {
  126147. return this._pointerOverSprite;
  126148. };
  126149. /**
  126150. * Defines the sprite scene component responsible to manage sprites
  126151. * in a given scene.
  126152. */
  126153. var SpriteSceneComponent = /** @class */ (function () {
  126154. /**
  126155. * Creates a new instance of the component for the given scene
  126156. * @param scene Defines the scene to register the component in
  126157. */
  126158. function SpriteSceneComponent(scene) {
  126159. /**
  126160. * The component name helpfull to identify the component in the list of scene components.
  126161. */
  126162. this.name = _sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].NAME_SPRITE;
  126163. this.scene = scene;
  126164. this.scene.spriteManagers = new Array();
  126165. this.scene._tempSpritePickingRay = _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"] ? _Culling_ray__WEBPACK_IMPORTED_MODULE_2__["Ray"].Zero() : null;
  126166. this.scene.onBeforeSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  126167. this.scene.onAfterSpritesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_0__["Observable"]();
  126168. this._spritePredicate = function (sprite) {
  126169. if (!sprite.actionManager) {
  126170. return false;
  126171. }
  126172. return sprite.isPickable && sprite.actionManager.hasPointerTriggers;
  126173. };
  126174. }
  126175. /**
  126176. * Registers the component in a given scene
  126177. */
  126178. SpriteSceneComponent.prototype.register = function () {
  126179. this.scene._pointerMoveStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERMOVE_SPRITE, this, this._pointerMove);
  126180. this.scene._pointerDownStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERDOWN_SPRITE, this, this._pointerDown);
  126181. this.scene._pointerUpStage.registerStep(_sceneComponent__WEBPACK_IMPORTED_MODULE_4__["SceneComponentConstants"].STEP_POINTERUP_SPRITE, this, this._pointerUp);
  126182. };
  126183. /**
  126184. * Rebuilds the elements related to this component in case of
  126185. * context lost for instance.
  126186. */
  126187. SpriteSceneComponent.prototype.rebuild = function () {
  126188. /** Nothing to do for sprites */
  126189. };
  126190. /**
  126191. * Disposes the component and the associated ressources.
  126192. */
  126193. SpriteSceneComponent.prototype.dispose = function () {
  126194. this.scene.onBeforeSpritesRenderingObservable.clear();
  126195. this.scene.onAfterSpritesRenderingObservable.clear();
  126196. var spriteManagers = this.scene.spriteManagers;
  126197. while (spriteManagers.length) {
  126198. spriteManagers[0].dispose();
  126199. }
  126200. };
  126201. SpriteSceneComponent.prototype._pickSpriteButKeepRay = function (originalPointerInfo, x, y, fastCheck, camera) {
  126202. var result = this.scene.pickSprite(x, y, this._spritePredicate, fastCheck, camera);
  126203. if (result) {
  126204. result.ray = originalPointerInfo ? originalPointerInfo.ray : null;
  126205. }
  126206. return result;
  126207. };
  126208. SpriteSceneComponent.prototype._pointerMove = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, isMeshPicked, canvas) {
  126209. var scene = this.scene;
  126210. if (isMeshPicked) {
  126211. scene.setPointerOverSprite(null);
  126212. }
  126213. else {
  126214. pickResult = this._pickSpriteButKeepRay(pickResult, unTranslatedPointerX, unTranslatedPointerY, false, scene.cameraToUseForPointers || undefined);
  126215. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  126216. scene.setPointerOverSprite(pickResult.pickedSprite);
  126217. if (scene._pointerOverSprite && scene._pointerOverSprite.actionManager && scene._pointerOverSprite.actionManager.hoverCursor) {
  126218. canvas.style.cursor = scene._pointerOverSprite.actionManager.hoverCursor;
  126219. }
  126220. else {
  126221. canvas.style.cursor = scene.hoverCursor;
  126222. }
  126223. }
  126224. else {
  126225. scene.setPointerOverSprite(null);
  126226. }
  126227. }
  126228. return pickResult;
  126229. };
  126230. SpriteSceneComponent.prototype._pointerDown = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  126231. var scene = this.scene;
  126232. scene._pickedDownSprite = null;
  126233. if (scene.spriteManagers.length > 0) {
  126234. pickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  126235. if (pickResult && pickResult.hit && pickResult.pickedSprite) {
  126236. if (pickResult.pickedSprite.actionManager) {
  126237. scene._pickedDownSprite = pickResult.pickedSprite;
  126238. switch (evt.button) {
  126239. case 0:
  126240. 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));
  126241. break;
  126242. case 1:
  126243. 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));
  126244. break;
  126245. case 2:
  126246. 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));
  126247. break;
  126248. }
  126249. if (pickResult.pickedSprite.actionManager) {
  126250. 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));
  126251. }
  126252. }
  126253. }
  126254. }
  126255. return pickResult;
  126256. };
  126257. SpriteSceneComponent.prototype._pointerUp = function (unTranslatedPointerX, unTranslatedPointerY, pickResult, evt) {
  126258. var scene = this.scene;
  126259. if (scene.spriteManagers.length > 0) {
  126260. var spritePickResult = scene.pickSprite(unTranslatedPointerX, unTranslatedPointerY, this._spritePredicate, false, scene.cameraToUseForPointers || undefined);
  126261. if (spritePickResult) {
  126262. if (spritePickResult.hit && spritePickResult.pickedSprite) {
  126263. if (spritePickResult.pickedSprite.actionManager) {
  126264. 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));
  126265. if (spritePickResult.pickedSprite.actionManager) {
  126266. if (!this.scene._isPointerSwiping()) {
  126267. 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));
  126268. }
  126269. }
  126270. }
  126271. }
  126272. if (scene._pickedDownSprite && scene._pickedDownSprite.actionManager && scene._pickedDownSprite !== spritePickResult.pickedSprite) {
  126273. 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));
  126274. }
  126275. }
  126276. }
  126277. return pickResult;
  126278. };
  126279. return SpriteSceneComponent;
  126280. }());
  126281. /***/ }),
  126282. /***/ "./States/alphaCullingState.ts":
  126283. /*!*************************************!*\
  126284. !*** ./States/alphaCullingState.ts ***!
  126285. \*************************************/
  126286. /*! exports provided: _AlphaState */
  126287. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126288. "use strict";
  126289. __webpack_require__.r(__webpack_exports__);
  126290. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _AlphaState; });
  126291. /**
  126292. * @hidden
  126293. **/
  126294. var _AlphaState = /** @class */ (function () {
  126295. /**
  126296. * Initializes the state.
  126297. */
  126298. function _AlphaState() {
  126299. this._isAlphaBlendDirty = false;
  126300. this._isBlendFunctionParametersDirty = false;
  126301. this._isBlendEquationParametersDirty = false;
  126302. this._isBlendConstantsDirty = false;
  126303. this._alphaBlend = false;
  126304. this._blendFunctionParameters = new Array(4);
  126305. this._blendEquationParameters = new Array(2);
  126306. this._blendConstants = new Array(4);
  126307. this.reset();
  126308. }
  126309. Object.defineProperty(_AlphaState.prototype, "isDirty", {
  126310. get: function () {
  126311. return this._isAlphaBlendDirty || this._isBlendFunctionParametersDirty;
  126312. },
  126313. enumerable: true,
  126314. configurable: true
  126315. });
  126316. Object.defineProperty(_AlphaState.prototype, "alphaBlend", {
  126317. get: function () {
  126318. return this._alphaBlend;
  126319. },
  126320. set: function (value) {
  126321. if (this._alphaBlend === value) {
  126322. return;
  126323. }
  126324. this._alphaBlend = value;
  126325. this._isAlphaBlendDirty = true;
  126326. },
  126327. enumerable: true,
  126328. configurable: true
  126329. });
  126330. _AlphaState.prototype.setAlphaBlendConstants = function (r, g, b, a) {
  126331. if (this._blendConstants[0] === r &&
  126332. this._blendConstants[1] === g &&
  126333. this._blendConstants[2] === b &&
  126334. this._blendConstants[3] === a) {
  126335. return;
  126336. }
  126337. this._blendConstants[0] = r;
  126338. this._blendConstants[1] = g;
  126339. this._blendConstants[2] = b;
  126340. this._blendConstants[3] = a;
  126341. this._isBlendConstantsDirty = true;
  126342. };
  126343. _AlphaState.prototype.setAlphaBlendFunctionParameters = function (value0, value1, value2, value3) {
  126344. if (this._blendFunctionParameters[0] === value0 &&
  126345. this._blendFunctionParameters[1] === value1 &&
  126346. this._blendFunctionParameters[2] === value2 &&
  126347. this._blendFunctionParameters[3] === value3) {
  126348. return;
  126349. }
  126350. this._blendFunctionParameters[0] = value0;
  126351. this._blendFunctionParameters[1] = value1;
  126352. this._blendFunctionParameters[2] = value2;
  126353. this._blendFunctionParameters[3] = value3;
  126354. this._isBlendFunctionParametersDirty = true;
  126355. };
  126356. _AlphaState.prototype.setAlphaEquationParameters = function (rgb, alpha) {
  126357. if (this._blendEquationParameters[0] === rgb &&
  126358. this._blendEquationParameters[1] === alpha) {
  126359. return;
  126360. }
  126361. this._blendEquationParameters[0] = rgb;
  126362. this._blendEquationParameters[1] = alpha;
  126363. this._isBlendEquationParametersDirty = true;
  126364. };
  126365. _AlphaState.prototype.reset = function () {
  126366. this._alphaBlend = false;
  126367. this._blendFunctionParameters[0] = null;
  126368. this._blendFunctionParameters[1] = null;
  126369. this._blendFunctionParameters[2] = null;
  126370. this._blendFunctionParameters[3] = null;
  126371. this._blendEquationParameters[0] = null;
  126372. this._blendEquationParameters[1] = null;
  126373. this._blendConstants[0] = null;
  126374. this._blendConstants[1] = null;
  126375. this._blendConstants[2] = null;
  126376. this._blendConstants[3] = null;
  126377. this._isAlphaBlendDirty = true;
  126378. this._isBlendFunctionParametersDirty = false;
  126379. this._isBlendEquationParametersDirty = false;
  126380. this._isBlendConstantsDirty = false;
  126381. };
  126382. _AlphaState.prototype.apply = function (gl) {
  126383. if (!this.isDirty) {
  126384. return;
  126385. }
  126386. // Alpha blend
  126387. if (this._isAlphaBlendDirty) {
  126388. if (this._alphaBlend) {
  126389. gl.enable(gl.BLEND);
  126390. }
  126391. else {
  126392. gl.disable(gl.BLEND);
  126393. }
  126394. this._isAlphaBlendDirty = false;
  126395. }
  126396. // Alpha function
  126397. if (this._isBlendFunctionParametersDirty) {
  126398. gl.blendFuncSeparate(this._blendFunctionParameters[0], this._blendFunctionParameters[1], this._blendFunctionParameters[2], this._blendFunctionParameters[3]);
  126399. this._isBlendFunctionParametersDirty = false;
  126400. }
  126401. // Alpha equation
  126402. if (this._isBlendEquationParametersDirty) {
  126403. gl.blendEquationSeparate(this._blendEquationParameters[0], this._blendEquationParameters[1]);
  126404. this._isBlendEquationParametersDirty = false;
  126405. }
  126406. // Constants
  126407. if (this._isBlendConstantsDirty) {
  126408. gl.blendColor(this._blendConstants[0], this._blendConstants[1], this._blendConstants[2], this._blendConstants[3]);
  126409. this._isBlendConstantsDirty = false;
  126410. }
  126411. };
  126412. return _AlphaState;
  126413. }());
  126414. /***/ }),
  126415. /***/ "./States/depthCullingState.ts":
  126416. /*!*************************************!*\
  126417. !*** ./States/depthCullingState.ts ***!
  126418. \*************************************/
  126419. /*! exports provided: _DepthCullingState */
  126420. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126421. "use strict";
  126422. __webpack_require__.r(__webpack_exports__);
  126423. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _DepthCullingState; });
  126424. /**
  126425. * @hidden
  126426. **/
  126427. var _DepthCullingState = /** @class */ (function () {
  126428. /**
  126429. * Initializes the state.
  126430. */
  126431. function _DepthCullingState() {
  126432. this._isDepthTestDirty = false;
  126433. this._isDepthMaskDirty = false;
  126434. this._isDepthFuncDirty = false;
  126435. this._isCullFaceDirty = false;
  126436. this._isCullDirty = false;
  126437. this._isZOffsetDirty = false;
  126438. this._isFrontFaceDirty = false;
  126439. this.reset();
  126440. }
  126441. Object.defineProperty(_DepthCullingState.prototype, "isDirty", {
  126442. get: function () {
  126443. return this._isDepthFuncDirty || this._isDepthTestDirty || this._isDepthMaskDirty || this._isCullFaceDirty || this._isCullDirty || this._isZOffsetDirty || this._isFrontFaceDirty;
  126444. },
  126445. enumerable: true,
  126446. configurable: true
  126447. });
  126448. Object.defineProperty(_DepthCullingState.prototype, "zOffset", {
  126449. get: function () {
  126450. return this._zOffset;
  126451. },
  126452. set: function (value) {
  126453. if (this._zOffset === value) {
  126454. return;
  126455. }
  126456. this._zOffset = value;
  126457. this._isZOffsetDirty = true;
  126458. },
  126459. enumerable: true,
  126460. configurable: true
  126461. });
  126462. Object.defineProperty(_DepthCullingState.prototype, "cullFace", {
  126463. get: function () {
  126464. return this._cullFace;
  126465. },
  126466. set: function (value) {
  126467. if (this._cullFace === value) {
  126468. return;
  126469. }
  126470. this._cullFace = value;
  126471. this._isCullFaceDirty = true;
  126472. },
  126473. enumerable: true,
  126474. configurable: true
  126475. });
  126476. Object.defineProperty(_DepthCullingState.prototype, "cull", {
  126477. get: function () {
  126478. return this._cull;
  126479. },
  126480. set: function (value) {
  126481. if (this._cull === value) {
  126482. return;
  126483. }
  126484. this._cull = value;
  126485. this._isCullDirty = true;
  126486. },
  126487. enumerable: true,
  126488. configurable: true
  126489. });
  126490. Object.defineProperty(_DepthCullingState.prototype, "depthFunc", {
  126491. get: function () {
  126492. return this._depthFunc;
  126493. },
  126494. set: function (value) {
  126495. if (this._depthFunc === value) {
  126496. return;
  126497. }
  126498. this._depthFunc = value;
  126499. this._isDepthFuncDirty = true;
  126500. },
  126501. enumerable: true,
  126502. configurable: true
  126503. });
  126504. Object.defineProperty(_DepthCullingState.prototype, "depthMask", {
  126505. get: function () {
  126506. return this._depthMask;
  126507. },
  126508. set: function (value) {
  126509. if (this._depthMask === value) {
  126510. return;
  126511. }
  126512. this._depthMask = value;
  126513. this._isDepthMaskDirty = true;
  126514. },
  126515. enumerable: true,
  126516. configurable: true
  126517. });
  126518. Object.defineProperty(_DepthCullingState.prototype, "depthTest", {
  126519. get: function () {
  126520. return this._depthTest;
  126521. },
  126522. set: function (value) {
  126523. if (this._depthTest === value) {
  126524. return;
  126525. }
  126526. this._depthTest = value;
  126527. this._isDepthTestDirty = true;
  126528. },
  126529. enumerable: true,
  126530. configurable: true
  126531. });
  126532. Object.defineProperty(_DepthCullingState.prototype, "frontFace", {
  126533. get: function () {
  126534. return this._frontFace;
  126535. },
  126536. set: function (value) {
  126537. if (this._frontFace === value) {
  126538. return;
  126539. }
  126540. this._frontFace = value;
  126541. this._isFrontFaceDirty = true;
  126542. },
  126543. enumerable: true,
  126544. configurable: true
  126545. });
  126546. _DepthCullingState.prototype.reset = function () {
  126547. this._depthMask = true;
  126548. this._depthTest = true;
  126549. this._depthFunc = null;
  126550. this._cullFace = null;
  126551. this._cull = null;
  126552. this._zOffset = 0;
  126553. this._frontFace = null;
  126554. this._isDepthTestDirty = true;
  126555. this._isDepthMaskDirty = true;
  126556. this._isDepthFuncDirty = false;
  126557. this._isCullFaceDirty = false;
  126558. this._isCullDirty = false;
  126559. this._isZOffsetDirty = false;
  126560. this._isFrontFaceDirty = false;
  126561. };
  126562. _DepthCullingState.prototype.apply = function (gl) {
  126563. if (!this.isDirty) {
  126564. return;
  126565. }
  126566. // Cull
  126567. if (this._isCullDirty) {
  126568. if (this.cull) {
  126569. gl.enable(gl.CULL_FACE);
  126570. }
  126571. else {
  126572. gl.disable(gl.CULL_FACE);
  126573. }
  126574. this._isCullDirty = false;
  126575. }
  126576. // Cull face
  126577. if (this._isCullFaceDirty) {
  126578. gl.cullFace(this.cullFace);
  126579. this._isCullFaceDirty = false;
  126580. }
  126581. // Depth mask
  126582. if (this._isDepthMaskDirty) {
  126583. gl.depthMask(this.depthMask);
  126584. this._isDepthMaskDirty = false;
  126585. }
  126586. // Depth test
  126587. if (this._isDepthTestDirty) {
  126588. if (this.depthTest) {
  126589. gl.enable(gl.DEPTH_TEST);
  126590. }
  126591. else {
  126592. gl.disable(gl.DEPTH_TEST);
  126593. }
  126594. this._isDepthTestDirty = false;
  126595. }
  126596. // Depth func
  126597. if (this._isDepthFuncDirty) {
  126598. gl.depthFunc(this.depthFunc);
  126599. this._isDepthFuncDirty = false;
  126600. }
  126601. // zOffset
  126602. if (this._isZOffsetDirty) {
  126603. if (this.zOffset) {
  126604. gl.enable(gl.POLYGON_OFFSET_FILL);
  126605. gl.polygonOffset(this.zOffset, 0);
  126606. }
  126607. else {
  126608. gl.disable(gl.POLYGON_OFFSET_FILL);
  126609. }
  126610. this._isZOffsetDirty = false;
  126611. }
  126612. // Front face
  126613. if (this._isFrontFaceDirty) {
  126614. gl.frontFace(this.frontFace);
  126615. this._isFrontFaceDirty = false;
  126616. }
  126617. };
  126618. return _DepthCullingState;
  126619. }());
  126620. /***/ }),
  126621. /***/ "./States/index.ts":
  126622. /*!*************************!*\
  126623. !*** ./States/index.ts ***!
  126624. \*************************/
  126625. /*! exports provided: _AlphaState, _DepthCullingState, _StencilState */
  126626. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126627. "use strict";
  126628. __webpack_require__.r(__webpack_exports__);
  126629. /* harmony import */ var _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./alphaCullingState */ "./States/alphaCullingState.ts");
  126630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _alphaCullingState__WEBPACK_IMPORTED_MODULE_0__["_AlphaState"]; });
  126631. /* harmony import */ var _depthCullingState__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./depthCullingState */ "./States/depthCullingState.ts");
  126632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _depthCullingState__WEBPACK_IMPORTED_MODULE_1__["_DepthCullingState"]; });
  126633. /* harmony import */ var _stencilState__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./stencilState */ "./States/stencilState.ts");
  126634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _stencilState__WEBPACK_IMPORTED_MODULE_2__["_StencilState"]; });
  126635. /***/ }),
  126636. /***/ "./States/stencilState.ts":
  126637. /*!********************************!*\
  126638. !*** ./States/stencilState.ts ***!
  126639. \********************************/
  126640. /*! exports provided: _StencilState */
  126641. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126642. "use strict";
  126643. __webpack_require__.r(__webpack_exports__);
  126644. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _StencilState; });
  126645. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Engines/constants */ "./Engines/constants.ts");
  126646. /**
  126647. * @hidden
  126648. **/
  126649. var _StencilState = /** @class */ (function () {
  126650. function _StencilState() {
  126651. this._isStencilTestDirty = false;
  126652. this._isStencilMaskDirty = false;
  126653. this._isStencilFuncDirty = false;
  126654. this._isStencilOpDirty = false;
  126655. this.reset();
  126656. }
  126657. Object.defineProperty(_StencilState.prototype, "isDirty", {
  126658. get: function () {
  126659. return this._isStencilTestDirty || this._isStencilMaskDirty || this._isStencilFuncDirty || this._isStencilOpDirty;
  126660. },
  126661. enumerable: true,
  126662. configurable: true
  126663. });
  126664. Object.defineProperty(_StencilState.prototype, "stencilFunc", {
  126665. get: function () {
  126666. return this._stencilFunc;
  126667. },
  126668. set: function (value) {
  126669. if (this._stencilFunc === value) {
  126670. return;
  126671. }
  126672. this._stencilFunc = value;
  126673. this._isStencilFuncDirty = true;
  126674. },
  126675. enumerable: true,
  126676. configurable: true
  126677. });
  126678. Object.defineProperty(_StencilState.prototype, "stencilFuncRef", {
  126679. get: function () {
  126680. return this._stencilFuncRef;
  126681. },
  126682. set: function (value) {
  126683. if (this._stencilFuncRef === value) {
  126684. return;
  126685. }
  126686. this._stencilFuncRef = value;
  126687. this._isStencilFuncDirty = true;
  126688. },
  126689. enumerable: true,
  126690. configurable: true
  126691. });
  126692. Object.defineProperty(_StencilState.prototype, "stencilFuncMask", {
  126693. get: function () {
  126694. return this._stencilFuncMask;
  126695. },
  126696. set: function (value) {
  126697. if (this._stencilFuncMask === value) {
  126698. return;
  126699. }
  126700. this._stencilFuncMask = value;
  126701. this._isStencilFuncDirty = true;
  126702. },
  126703. enumerable: true,
  126704. configurable: true
  126705. });
  126706. Object.defineProperty(_StencilState.prototype, "stencilOpStencilFail", {
  126707. get: function () {
  126708. return this._stencilOpStencilFail;
  126709. },
  126710. set: function (value) {
  126711. if (this._stencilOpStencilFail === value) {
  126712. return;
  126713. }
  126714. this._stencilOpStencilFail = value;
  126715. this._isStencilOpDirty = true;
  126716. },
  126717. enumerable: true,
  126718. configurable: true
  126719. });
  126720. Object.defineProperty(_StencilState.prototype, "stencilOpDepthFail", {
  126721. get: function () {
  126722. return this._stencilOpDepthFail;
  126723. },
  126724. set: function (value) {
  126725. if (this._stencilOpDepthFail === value) {
  126726. return;
  126727. }
  126728. this._stencilOpDepthFail = value;
  126729. this._isStencilOpDirty = true;
  126730. },
  126731. enumerable: true,
  126732. configurable: true
  126733. });
  126734. Object.defineProperty(_StencilState.prototype, "stencilOpStencilDepthPass", {
  126735. get: function () {
  126736. return this._stencilOpStencilDepthPass;
  126737. },
  126738. set: function (value) {
  126739. if (this._stencilOpStencilDepthPass === value) {
  126740. return;
  126741. }
  126742. this._stencilOpStencilDepthPass = value;
  126743. this._isStencilOpDirty = true;
  126744. },
  126745. enumerable: true,
  126746. configurable: true
  126747. });
  126748. Object.defineProperty(_StencilState.prototype, "stencilMask", {
  126749. get: function () {
  126750. return this._stencilMask;
  126751. },
  126752. set: function (value) {
  126753. if (this._stencilMask === value) {
  126754. return;
  126755. }
  126756. this._stencilMask = value;
  126757. this._isStencilMaskDirty = true;
  126758. },
  126759. enumerable: true,
  126760. configurable: true
  126761. });
  126762. Object.defineProperty(_StencilState.prototype, "stencilTest", {
  126763. get: function () {
  126764. return this._stencilTest;
  126765. },
  126766. set: function (value) {
  126767. if (this._stencilTest === value) {
  126768. return;
  126769. }
  126770. this._stencilTest = value;
  126771. this._isStencilTestDirty = true;
  126772. },
  126773. enumerable: true,
  126774. configurable: true
  126775. });
  126776. _StencilState.prototype.reset = function () {
  126777. this._stencilTest = false;
  126778. this._stencilMask = 0xFF;
  126779. this._stencilFunc = _StencilState.ALWAYS;
  126780. this._stencilFuncRef = 1;
  126781. this._stencilFuncMask = 0xFF;
  126782. this._stencilOpStencilFail = _StencilState.KEEP;
  126783. this._stencilOpDepthFail = _StencilState.KEEP;
  126784. this._stencilOpStencilDepthPass = _StencilState.REPLACE;
  126785. this._isStencilTestDirty = true;
  126786. this._isStencilMaskDirty = true;
  126787. this._isStencilFuncDirty = true;
  126788. this._isStencilOpDirty = true;
  126789. };
  126790. _StencilState.prototype.apply = function (gl) {
  126791. if (!this.isDirty) {
  126792. return;
  126793. }
  126794. // Stencil test
  126795. if (this._isStencilTestDirty) {
  126796. if (this.stencilTest) {
  126797. gl.enable(gl.STENCIL_TEST);
  126798. }
  126799. else {
  126800. gl.disable(gl.STENCIL_TEST);
  126801. }
  126802. this._isStencilTestDirty = false;
  126803. }
  126804. // Stencil mask
  126805. if (this._isStencilMaskDirty) {
  126806. gl.stencilMask(this.stencilMask);
  126807. this._isStencilMaskDirty = false;
  126808. }
  126809. // Stencil func
  126810. if (this._isStencilFuncDirty) {
  126811. gl.stencilFunc(this.stencilFunc, this.stencilFuncRef, this.stencilFuncMask);
  126812. this._isStencilFuncDirty = false;
  126813. }
  126814. // Stencil op
  126815. if (this._isStencilOpDirty) {
  126816. gl.stencilOp(this.stencilOpStencilFail, this.stencilOpDepthFail, this.stencilOpStencilDepthPass);
  126817. this._isStencilOpDirty = false;
  126818. }
  126819. };
  126820. /** 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 */
  126821. _StencilState.ALWAYS = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].ALWAYS;
  126822. /** Passed to stencilOperation to specify that stencil value must be kept */
  126823. _StencilState.KEEP = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].KEEP;
  126824. /** Passed to stencilOperation to specify that stencil value must be replaced */
  126825. _StencilState.REPLACE = _Engines_constants__WEBPACK_IMPORTED_MODULE_0__["Constants"].REPLACE;
  126826. return _StencilState;
  126827. }());
  126828. /***/ }),
  126829. /***/ "./abstractScene.ts":
  126830. /*!**************************!*\
  126831. !*** ./abstractScene.ts ***!
  126832. \**************************/
  126833. /*! exports provided: AbstractScene */
  126834. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126835. "use strict";
  126836. __webpack_require__.r(__webpack_exports__);
  126837. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return AbstractScene; });
  126838. /**
  126839. * Base class of the scene acting as a container for the different elements composing a scene.
  126840. * This class is dynamically extended by the different components of the scene increasing
  126841. * flexibility and reducing coupling
  126842. */
  126843. var AbstractScene = /** @class */ (function () {
  126844. function AbstractScene() {
  126845. /**
  126846. * Gets the list of root nodes (ie. nodes with no parent)
  126847. */
  126848. this.rootNodes = new Array();
  126849. /** All of the cameras added to this scene
  126850. * @see http://doc.babylonjs.com/babylon101/cameras
  126851. */
  126852. this.cameras = new Array();
  126853. /**
  126854. * All of the lights added to this scene
  126855. * @see http://doc.babylonjs.com/babylon101/lights
  126856. */
  126857. this.lights = new Array();
  126858. /**
  126859. * All of the (abstract) meshes added to this scene
  126860. */
  126861. this.meshes = new Array();
  126862. /**
  126863. * The list of skeletons added to the scene
  126864. * @see http://doc.babylonjs.com/how_to/how_to_use_bones_and_skeletons
  126865. */
  126866. this.skeletons = new Array();
  126867. /**
  126868. * All of the particle systems added to this scene
  126869. * @see http://doc.babylonjs.com/babylon101/particles
  126870. */
  126871. this.particleSystems = new Array();
  126872. /**
  126873. * Gets a list of Animations associated with the scene
  126874. */
  126875. this.animations = [];
  126876. /**
  126877. * All of the animation groups added to this scene
  126878. * @see http://doc.babylonjs.com/how_to/group
  126879. */
  126880. this.animationGroups = new Array();
  126881. /**
  126882. * All of the multi-materials added to this scene
  126883. * @see http://doc.babylonjs.com/how_to/multi_materials
  126884. */
  126885. this.multiMaterials = new Array();
  126886. /**
  126887. * All of the materials added to this scene
  126888. * In the context of a Scene, it is not supposed to be modified manually.
  126889. * Any addition or removal should be done using the addMaterial and removeMAterial Scene methods.
  126890. * Note also that the order of the Material wihin the array is not significant and might change.
  126891. * @see http://doc.babylonjs.com/babylon101/materials
  126892. */
  126893. this.materials = new Array();
  126894. /**
  126895. * The list of morph target managers added to the scene
  126896. * @see http://doc.babylonjs.com/how_to/how_to_dynamically_morph_a_mesh
  126897. */
  126898. this.morphTargetManagers = new Array();
  126899. /**
  126900. * The list of geometries used in the scene.
  126901. */
  126902. this.geometries = new Array();
  126903. /**
  126904. * All of the tranform nodes added to this scene
  126905. * In the context of a Scene, it is not supposed to be modified manually.
  126906. * Any addition or removal should be done using the addTransformNode and removeTransformNode Scene methods.
  126907. * Note also that the order of the TransformNode wihin the array is not significant and might change.
  126908. * @see http://doc.babylonjs.com/how_to/transformnode
  126909. */
  126910. this.transformNodes = new Array();
  126911. /**
  126912. * ActionManagers available on the scene.
  126913. */
  126914. this.actionManagers = new Array();
  126915. /**
  126916. * Textures to keep.
  126917. */
  126918. this.textures = new Array();
  126919. }
  126920. /**
  126921. * Adds a parser in the list of available ones
  126922. * @param name Defines the name of the parser
  126923. * @param parser Defines the parser to add
  126924. */
  126925. AbstractScene.AddParser = function (name, parser) {
  126926. this._BabylonFileParsers[name] = parser;
  126927. };
  126928. /**
  126929. * Gets a general parser from the list of avaialble ones
  126930. * @param name Defines the name of the parser
  126931. * @returns the requested parser or null
  126932. */
  126933. AbstractScene.GetParser = function (name) {
  126934. if (this._BabylonFileParsers[name]) {
  126935. return this._BabylonFileParsers[name];
  126936. }
  126937. return null;
  126938. };
  126939. /**
  126940. * Adds n individual parser in the list of available ones
  126941. * @param name Defines the name of the parser
  126942. * @param parser Defines the parser to add
  126943. */
  126944. AbstractScene.AddIndividualParser = function (name, parser) {
  126945. this._IndividualBabylonFileParsers[name] = parser;
  126946. };
  126947. /**
  126948. * Gets an individual parser from the list of avaialble ones
  126949. * @param name Defines the name of the parser
  126950. * @returns the requested parser or null
  126951. */
  126952. AbstractScene.GetIndividualParser = function (name) {
  126953. if (this._IndividualBabylonFileParsers[name]) {
  126954. return this._IndividualBabylonFileParsers[name];
  126955. }
  126956. return null;
  126957. };
  126958. /**
  126959. * Parser json data and populate both a scene and its associated container object
  126960. * @param jsonData Defines the data to parse
  126961. * @param scene Defines the scene to parse the data for
  126962. * @param container Defines the container attached to the parsing sequence
  126963. * @param rootUrl Defines the root url of the data
  126964. */
  126965. AbstractScene.Parse = function (jsonData, scene, container, rootUrl) {
  126966. for (var parserName in this._BabylonFileParsers) {
  126967. if (this._BabylonFileParsers.hasOwnProperty(parserName)) {
  126968. this._BabylonFileParsers[parserName](jsonData, scene, container, rootUrl);
  126969. }
  126970. }
  126971. };
  126972. /**
  126973. * Stores the list of available parsers in the application.
  126974. */
  126975. AbstractScene._BabylonFileParsers = {};
  126976. /**
  126977. * Stores the list of available individual parsers in the application.
  126978. */
  126979. AbstractScene._IndividualBabylonFileParsers = {};
  126980. return AbstractScene;
  126981. }());
  126982. /***/ }),
  126983. /***/ "./assetContainer.ts":
  126984. /*!***************************!*\
  126985. !*** ./assetContainer.ts ***!
  126986. \***************************/
  126987. /*! exports provided: KeepAssets, AssetContainer */
  126988. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  126989. "use strict";
  126990. __webpack_require__.r(__webpack_exports__);
  126991. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return KeepAssets; });
  126992. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return AssetContainer; });
  126993. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  126994. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  126995. /* harmony import */ var _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Meshes/mesh */ "./Meshes/mesh.ts");
  126996. /**
  126997. * Set of assets to keep when moving a scene into an asset container.
  126998. */
  126999. var KeepAssets = /** @class */ (function (_super) {
  127000. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](KeepAssets, _super);
  127001. function KeepAssets() {
  127002. return _super !== null && _super.apply(this, arguments) || this;
  127003. }
  127004. return KeepAssets;
  127005. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  127006. /**
  127007. * Container with a set of assets that can be added or removed from a scene.
  127008. */
  127009. var AssetContainer = /** @class */ (function (_super) {
  127010. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](AssetContainer, _super);
  127011. /**
  127012. * Instantiates an AssetContainer.
  127013. * @param scene The scene the AssetContainer belongs to.
  127014. */
  127015. function AssetContainer(scene) {
  127016. var _this = _super.call(this) || this;
  127017. _this.scene = scene;
  127018. _this["sounds"] = [];
  127019. _this["effectLayers"] = [];
  127020. _this["layers"] = [];
  127021. _this["lensFlareSystems"] = [];
  127022. _this["proceduralTextures"] = [];
  127023. _this["reflectionProbes"] = [];
  127024. return _this;
  127025. }
  127026. /**
  127027. * Adds all the assets from the container to the scene.
  127028. */
  127029. AssetContainer.prototype.addAllToScene = function () {
  127030. var _this = this;
  127031. this.cameras.forEach(function (o) {
  127032. _this.scene.addCamera(o);
  127033. });
  127034. this.lights.forEach(function (o) {
  127035. _this.scene.addLight(o);
  127036. });
  127037. this.meshes.forEach(function (o) {
  127038. _this.scene.addMesh(o);
  127039. });
  127040. this.skeletons.forEach(function (o) {
  127041. _this.scene.addSkeleton(o);
  127042. });
  127043. this.animations.forEach(function (o) {
  127044. _this.scene.addAnimation(o);
  127045. });
  127046. this.animationGroups.forEach(function (o) {
  127047. _this.scene.addAnimationGroup(o);
  127048. });
  127049. this.multiMaterials.forEach(function (o) {
  127050. _this.scene.addMultiMaterial(o);
  127051. });
  127052. this.materials.forEach(function (o) {
  127053. _this.scene.addMaterial(o);
  127054. });
  127055. this.morphTargetManagers.forEach(function (o) {
  127056. _this.scene.addMorphTargetManager(o);
  127057. });
  127058. this.geometries.forEach(function (o) {
  127059. _this.scene.addGeometry(o);
  127060. });
  127061. this.transformNodes.forEach(function (o) {
  127062. _this.scene.addTransformNode(o);
  127063. });
  127064. this.actionManagers.forEach(function (o) {
  127065. _this.scene.addActionManager(o);
  127066. });
  127067. this.textures.forEach(function (o) {
  127068. _this.scene.addTexture(o);
  127069. });
  127070. this.reflectionProbes.forEach(function (o) {
  127071. _this.scene.addReflectionProbe(o);
  127072. });
  127073. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  127074. var component = _a[_i];
  127075. component.addFromContainer(this);
  127076. }
  127077. };
  127078. /**
  127079. * Removes all the assets in the container from the scene
  127080. */
  127081. AssetContainer.prototype.removeAllFromScene = function () {
  127082. var _this = this;
  127083. this.cameras.forEach(function (o) {
  127084. _this.scene.removeCamera(o);
  127085. });
  127086. this.lights.forEach(function (o) {
  127087. _this.scene.removeLight(o);
  127088. });
  127089. this.meshes.forEach(function (o) {
  127090. _this.scene.removeMesh(o);
  127091. });
  127092. this.skeletons.forEach(function (o) {
  127093. _this.scene.removeSkeleton(o);
  127094. });
  127095. this.animations.forEach(function (o) {
  127096. _this.scene.removeAnimation(o);
  127097. });
  127098. this.animationGroups.forEach(function (o) {
  127099. _this.scene.removeAnimationGroup(o);
  127100. });
  127101. this.multiMaterials.forEach(function (o) {
  127102. _this.scene.removeMultiMaterial(o);
  127103. });
  127104. this.materials.forEach(function (o) {
  127105. _this.scene.removeMaterial(o);
  127106. });
  127107. this.morphTargetManagers.forEach(function (o) {
  127108. _this.scene.removeMorphTargetManager(o);
  127109. });
  127110. this.geometries.forEach(function (o) {
  127111. _this.scene.removeGeometry(o);
  127112. });
  127113. this.transformNodes.forEach(function (o) {
  127114. _this.scene.removeTransformNode(o);
  127115. });
  127116. this.actionManagers.forEach(function (o) {
  127117. _this.scene.removeActionManager(o);
  127118. });
  127119. this.textures.forEach(function (o) {
  127120. _this.scene.removeTexture(o);
  127121. });
  127122. this.reflectionProbes.forEach(function (o) {
  127123. _this.scene.removeReflectionProbe(o);
  127124. });
  127125. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  127126. var component = _a[_i];
  127127. component.removeFromContainer(this);
  127128. }
  127129. };
  127130. /**
  127131. * Disposes all the assets in the container
  127132. */
  127133. AssetContainer.prototype.dispose = function () {
  127134. this.cameras.forEach(function (o) {
  127135. o.dispose();
  127136. });
  127137. this.lights.forEach(function (o) {
  127138. o.dispose();
  127139. });
  127140. this.meshes.forEach(function (o) {
  127141. o.dispose();
  127142. });
  127143. this.skeletons.forEach(function (o) {
  127144. o.dispose();
  127145. });
  127146. this.animationGroups.forEach(function (o) {
  127147. o.dispose();
  127148. });
  127149. this.multiMaterials.forEach(function (o) {
  127150. o.dispose();
  127151. });
  127152. this.materials.forEach(function (o) {
  127153. o.dispose();
  127154. });
  127155. this.geometries.forEach(function (o) {
  127156. o.dispose();
  127157. });
  127158. this.transformNodes.forEach(function (o) {
  127159. o.dispose();
  127160. });
  127161. this.actionManagers.forEach(function (o) {
  127162. o.dispose();
  127163. });
  127164. this.textures.forEach(function (o) {
  127165. o.dispose();
  127166. });
  127167. this.reflectionProbes.forEach(function (o) {
  127168. o.dispose();
  127169. });
  127170. for (var _i = 0, _a = this.scene._serializableComponents; _i < _a.length; _i++) {
  127171. var component = _a[_i];
  127172. component.dispose();
  127173. }
  127174. };
  127175. AssetContainer.prototype._moveAssets = function (sourceAssets, targetAssets, keepAssets) {
  127176. if (!sourceAssets) {
  127177. return;
  127178. }
  127179. for (var _i = 0, sourceAssets_1 = sourceAssets; _i < sourceAssets_1.length; _i++) {
  127180. var asset = sourceAssets_1[_i];
  127181. var move = true;
  127182. if (keepAssets) {
  127183. for (var _a = 0, keepAssets_1 = keepAssets; _a < keepAssets_1.length; _a++) {
  127184. var keepAsset = keepAssets_1[_a];
  127185. if (asset === keepAsset) {
  127186. move = false;
  127187. break;
  127188. }
  127189. }
  127190. }
  127191. if (move) {
  127192. targetAssets.push(asset);
  127193. }
  127194. }
  127195. };
  127196. /**
  127197. * Removes all the assets contained in the scene and adds them to the container.
  127198. * @param keepAssets Set of assets to keep in the scene. (default: empty)
  127199. */
  127200. AssetContainer.prototype.moveAllFromScene = function (keepAssets) {
  127201. if (keepAssets === undefined) {
  127202. keepAssets = new KeepAssets();
  127203. }
  127204. for (var key in this) {
  127205. if (this.hasOwnProperty(key)) {
  127206. this[key] = this[key] || [];
  127207. this._moveAssets(this.scene[key], this[key], keepAssets[key]);
  127208. }
  127209. }
  127210. this.removeAllFromScene();
  127211. };
  127212. /**
  127213. * 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.
  127214. * @returns the root mesh
  127215. */
  127216. AssetContainer.prototype.createRootMesh = function () {
  127217. var rootMesh = new _Meshes_mesh__WEBPACK_IMPORTED_MODULE_2__["Mesh"]("assetContainerRootMesh", this.scene);
  127218. this.meshes.forEach(function (m) {
  127219. if (!m.parent) {
  127220. rootMesh.addChild(m);
  127221. }
  127222. });
  127223. this.meshes.unshift(rootMesh);
  127224. return rootMesh;
  127225. };
  127226. return AssetContainer;
  127227. }(_abstractScene__WEBPACK_IMPORTED_MODULE_1__["AbstractScene"]));
  127228. /***/ }),
  127229. /***/ "./index.ts":
  127230. /*!******************!*\
  127231. !*** ./index.ts ***!
  127232. \******************/
  127233. /*! exports provided: AbstractScene, KeepAssets, AssetContainer, Node, Scene, SceneComponentConstants, Stage, Action, ActionEvent, ActionManager, Condition, ValueCondition, PredicateCondition, StateCondition, SwitchBooleanAction, SetStateAction, SetValueAction, IncrementValueAction, PlayAnimationAction, StopAnimationAction, DoNothingAction, CombineAction, ExecuteCodeAction, SetParentAction, PlaySoundAction, StopSoundAction, InterpolateValueAction, Animatable, Animation, TargetedAnimation, AnimationGroup, AnimationPropertiesOverride, EasingFunction, CircleEase, BackEase, BounceEase, CubicEase, ElasticEase, ExponentialEase, PowerEase, QuadraticEase, QuarticEase, QuinticEase, SineEase, BezierCurveEase, RuntimeAnimation, AnimationEvent, AnimationKeyInterpolation, AnimationRange, Analyser, AudioEngine, AudioSceneComponent, Sound, SoundTrack, WeightedSound, Bone, BoneIKController, BoneLookController, Skeleton, CameraInputTypes, CameraInputsManager, Camera, TargetCamera, FreeCamera, FreeCameraInputsManager, TouchCamera, ArcRotateCamera, ArcRotateCameraInputsManager, DeviceOrientationCamera, FlyCamera, FlyCameraInputsManager, FollowCamera, ArcFollowCamera, GamepadCamera, UniversalCamera, VirtualJoysticksCamera, Collider, DefaultCollisionCoordinator, PickingInfo, IntersectionInfo, BoundingBox, BoundingInfo, BoundingSphere, Ray, AxesViewer, BoneAxesViewer, DebugLayer, PhysicsViewer, RayHelper, SkeletonViewer, Constants, InstancingAttributeInfo, DepthTextureCreationOptions, EngineCapabilities, Engine, EngineStore, NullEngineOptions, NullEngine, KeyboardEventTypes, KeyboardInfo, KeyboardInfoPre, PointerEventTypes, PointerInfoBase, PointerInfoPre, PointerInfo, ClipboardEventTypes, ClipboardInfo, DaydreamController, GearVRController, GenericController, OculusTouchController, PoseEnabledControllerType, PoseEnabledControllerHelper, PoseEnabledController, ViveController, WebVRController, WindowsMotionController, StickValues, Gamepad, GenericPad, GamepadManager, GamepadSystemSceneComponent, Xbox360Button, Xbox360Dpad, Xbox360Pad, AxisDragGizmo, AxisScaleGizmo, BoundingBoxGizmo, Gizmo, GizmoManager, PlaneRotationGizmo, PositionGizmo, RotationGizmo, ScaleGizmo, LightGizmo, EnvironmentHelper, PhotoDome, _forceSceneHelpersToBundle, VideoDome, EngineInstrumentation, SceneInstrumentation, _TimeToken, EffectLayer, EffectLayerSceneComponent, GlowLayer, HighlightLayer, Layer, LayerSceneComponent, LensFlare, LensFlareSystem, LensFlareSystemSceneComponent, Light, ShadowLight, DirectionalLight, HemisphericLight, PointLight, SpotLight, DefaultLoadingScreen, SceneLoaderProgressEvent, SceneLoader, SceneLoaderFlags, ColorCurves, EffectFallbacks, EffectCreationOptions, Effect, FresnelParameters, ImageProcessingConfigurationDefines, ImageProcessingConfiguration, Material, MaterialDefines, MaterialHelper, MultiMaterial, PushMaterial, ShaderMaterial, StandardMaterialDefines, StandardMaterial, BaseTexture, CubeTexture, HDRCubeTexture, InternalTexture, DummyInternalTextureTracker, MirrorTexture, MultiRenderTarget, RawTexture, RenderTargetTexture, Texture, UniformBuffer, MaterialFlags, Scalar, ToGammaSpace, ToLinearSpace, Epsilon, Color3, Color4, Vector2, Vector3, Vector4, Size, Quaternion, Matrix, Plane, Viewport, Frustum, Space, Axis, BezierCurve, Orientation, Angle, Arc2, Path2, Path3D, Curve3, PositionNormalVertex, PositionNormalTextureVertex, Tmp, SphericalPolynomial, SphericalHarmonics, AbstractMesh, Buffer, VertexBuffer, CSG, Geometry, GroundMesh, 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, PhysicsRadialExplosionEvent, PhysicsGravitationalFieldEvent, PhysicsUpdraftEvent, PhysicsVortexEvent, PhysicsRadialImpulseFalloff, PhysicsUpdraftMode, PhysicsImpostor, PhysicsJoint, DistanceJoint, MotorEnabledJoint, HingeJoint, Hinge2Joint, AnaglyphPostProcess, BlackAndWhitePostProcess, BloomEffect, BloomMergePostProcess, BlurPostProcess, ChromaticAberrationPostProcess, CircleOfConfusionPostProcess, ColorCorrectionPostProcess, ConvolutionPostProcess, DepthOfFieldBlurPostProcess, DepthOfFieldEffectBlurLevel, DepthOfFieldEffect, DepthOfFieldMergePostProcessOptions, DepthOfFieldMergePostProcess, DisplayPassPostProcess, ExtractHighlightsPostProcess, FilterPostProcess, FxaaPostProcess, GrainPostProcess, HighlightsPostProcess, ImageProcessingPostProcess, MotionBlurPostProcess, PassPostProcess, PassCubePostProcess, PostProcess, PostProcessManager, RefractionPostProcess, SharpenPostProcess, StereoscopicInterlacePostProcess, TonemappingOperator, TonemapPostProcess, VolumetricLightScatteringPostProcess, VRDistortionCorrectionPostProcess, ReflectionProbe, BoundingBoxRenderer, DepthRenderer, DepthRendererSceneComponent, EdgesRenderer, LineEdgesRenderer, GeometryBufferRenderer, GeometryBufferRendererSceneComponent, OutlineRenderer, RenderingGroup, RenderingGroupInfo, RenderingManager, UtilityLayerRenderer, Sprite, SpriteManager, SpriteSceneComponent, _AlphaState, _DepthCullingState, _StencilState, AndOrNotEvaluator, AssetTaskState, AbstractAssetTask, AssetsProgressEvent, MeshAssetTask, TextFileAssetTask, BinaryFileAssetTask, ImageAssetTask, TextureAssetTask, CubeTextureAssetTask, HDRCubeTextureAssetTask, AssetsManager, DDSTools, expandToProperty, serialize, serializeAsTexture, serializeAsColor3, serializeAsFresnelParameters, serializeAsVector2, serializeAsVector3, serializeAsMeshReference, serializeAsColorCurves, serializeAsColor4, serializeAsImageProcessingConfiguration, serializeAsQuaternion, serializeAsCameraReference, SerializationHelper, Deferred, EnvironmentTextureTools, FilesInput, KhronosTextureContainer, EventState, Observer, MultiObserver, Observable, PerformanceMonitor, RollingAverage, PromisePolyfill, SceneOptimization, TextureOptimization, HardwareScalingOptimization, ShadowsOptimization, PostProcessesOptimization, LensFlaresOptimization, CustomOptimization, ParticlesOptimization, RenderTargetsOptimization, MergeMeshesOptimization, SceneOptimizerOptions, SceneOptimizer, SceneSerializer, SmartArray, SmartArrayNoDuplicate, StringDictionary, Tags, TextureTools, TGATools, ColorGradient, Color3Gradient, FactorGradient, LoadFileError, RetryStrategy, Tools, PerfCounter, className, AsyncLoop, VideoRecorder, JoystickAxis, VirtualJoystick, WorkerPool, Logger, _TypeStore, FilesInputStore, DeepCopier, PivotTools, PrecisionDate, ScreenshotTools, AutoRotationBehavior, BouncingBehavior, FramingBehavior, AttachToBoxBehavior, FadeInOutBehavior, MultiPointerScaleBehavior, PointerDragBehavior, SixDofDragBehavior, ArcRotateCameraGamepadInput, ArcRotateCameraKeyboardMoveInput, ArcRotateCameraMouseWheelInput, ArcRotateCameraPointersInput, ArcRotateCameraVRDeviceOrientationInput, FlyCameraKeyboardInput, FlyCameraMouseInput, FreeCameraDeviceOrientationInput, FreeCameraGamepadInput, FreeCameraKeyboardMoveInput, FreeCameraMouseInput, FreeCameraTouchInput, FreeCameraVirtualJoystickInput, AnaglyphArcRotateCamera, AnaglyphFreeCamera, AnaglyphGamepadCamera, AnaglyphUniversalCamera, StereoscopicArcRotateCamera, StereoscopicFreeCamera, StereoscopicGamepadCamera, StereoscopicUniversalCamera, VRCameraMetrics, VRDeviceOrientationArcRotateCamera, VRDeviceOrientationFreeCamera, VRDeviceOrientationGamepadCamera, VRExperienceHelper, WebVRFreeCamera, WebXRCamera, WebXREnterExitUIButton, WebXREnterExitUIOptions, WebXREnterExitUI, WebXRState, WebXRExperienceHelper, WebXRController, WebXRInput, WebXRManagedOutputCanvas, WebXRSessionManager, Octree, OctreeBlock, OctreeSceneComponent, _OcclusionDataStorage, _forceTransformFeedbackToBundle, ShadowGenerator, ShadowGeneratorSceneComponent, _BabylonLoaderRegistered, BackgroundMaterial, PBRBaseMaterial, PBRBaseSimpleMaterial, PBRMaterial, PBRMetallicRoughnessMaterial, PBRSpecularGlossinessMaterial, ColorGradingTexture, DynamicTexture, ProceduralTexture, RawCubeTexture, RawTexture3D, RefractionTexture, VideoTexture, DracoCompression, DiscBuilder, RibbonBuilder, TorusBuilder, TorusKnotBuilder, PolygonBuilder, ShapeBuilder, LatheBuilder, GroundBuilder, TubeBuilder, PolyhedronBuilder, IcoSphereBuilder, DecalBuilder, BoxParticleEmitter, ConeParticleEmitter, CylinderParticleEmitter, CylinderDirectedParticleEmitter, HemisphericParticleEmitter, PointParticleEmitter, SphereParticleEmitter, SphereDirectedParticleEmitter, CannonJSPlugin, AmmoJSPlugin, OimoJSPlugin, PostProcessRenderEffect, PostProcessRenderPipeline, PostProcessRenderPipelineManager, PostProcessRenderPipelineManagerSceneComponent, CubeMapToSphericalPolynomialTools, HDRTools, PanoramaToCubeMapTools, _DDSTextureLoader, _ENVTextureLoader, _KTXTextureLoader, _TGATextureLoader, CustomProceduralTexture, NoiseProceduralTexture, ProceduralTextureSceneComponent, DefaultRenderingPipeline, LensRenderingPipeline, SSAO2RenderingPipeline, SSAORenderingPipeline, StandardRenderingPipeline */
  127234. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127235. "use strict";
  127236. __webpack_require__.r(__webpack_exports__);
  127237. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  127238. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractScene", function() { return _abstractScene__WEBPACK_IMPORTED_MODULE_0__["AbstractScene"]; });
  127239. /* harmony import */ var _Actions_index__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Actions/index */ "./Actions/index.ts");
  127240. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Action", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Action"]; });
  127241. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionEvent", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionEvent"]; });
  127242. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ActionManager", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ActionManager"]; });
  127243. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Condition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["Condition"]; });
  127244. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ValueCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ValueCondition"]; });
  127245. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PredicateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PredicateCondition"]; });
  127246. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StateCondition", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StateCondition"]; });
  127247. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SwitchBooleanAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SwitchBooleanAction"]; });
  127248. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetStateAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetStateAction"]; });
  127249. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetValueAction"]; });
  127250. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IncrementValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["IncrementValueAction"]; });
  127251. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlayAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlayAnimationAction"]; });
  127252. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopAnimationAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopAnimationAction"]; });
  127253. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DoNothingAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["DoNothingAction"]; });
  127254. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CombineAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["CombineAction"]; });
  127255. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExecuteCodeAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["ExecuteCodeAction"]; });
  127256. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SetParentAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["SetParentAction"]; });
  127257. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaySoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["PlaySoundAction"]; });
  127258. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StopSoundAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["StopSoundAction"]; });
  127259. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InterpolateValueAction", function() { return _Actions_index__WEBPACK_IMPORTED_MODULE_1__["InterpolateValueAction"]; });
  127260. /* harmony import */ var _Animations_index__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Animations/index */ "./Animations/index.ts");
  127261. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animatable", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animatable"]; });
  127262. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Animation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["Animation"]; });
  127263. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetedAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["TargetedAnimation"]; });
  127264. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationGroup", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationGroup"]; });
  127265. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationPropertiesOverride", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationPropertiesOverride"]; });
  127266. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EasingFunction", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["EasingFunction"]; });
  127267. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CircleEase"]; });
  127268. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BackEase"]; });
  127269. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BounceEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BounceEase"]; });
  127270. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubicEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["CubicEase"]; });
  127271. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ElasticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ElasticEase"]; });
  127272. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExponentialEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["ExponentialEase"]; });
  127273. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PowerEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["PowerEase"]; });
  127274. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuadraticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuadraticEase"]; });
  127275. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuarticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuarticEase"]; });
  127276. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "QuinticEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["QuinticEase"]; });
  127277. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SineEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["SineEase"]; });
  127278. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurveEase", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["BezierCurveEase"]; });
  127279. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RuntimeAnimation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["RuntimeAnimation"]; });
  127280. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationEvent", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationEvent"]; });
  127281. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationKeyInterpolation", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationKeyInterpolation"]; });
  127282. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnimationRange", function() { return _Animations_index__WEBPACK_IMPORTED_MODULE_2__["AnimationRange"]; });
  127283. /* harmony import */ var _assetContainer__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./assetContainer */ "./assetContainer.ts");
  127284. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeepAssets", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["KeepAssets"]; });
  127285. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetContainer", function() { return _assetContainer__WEBPACK_IMPORTED_MODULE_3__["AssetContainer"]; });
  127286. /* harmony import */ var _Audio_index__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Audio/index */ "./Audio/index.ts");
  127287. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Analyser", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Analyser"]; });
  127288. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioEngine", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioEngine"]; });
  127289. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AudioSceneComponent", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["AudioSceneComponent"]; });
  127290. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["Sound"]; });
  127291. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SoundTrack", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["SoundTrack"]; });
  127292. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WeightedSound", function() { return _Audio_index__WEBPACK_IMPORTED_MODULE_4__["WeightedSound"]; });
  127293. /* harmony import */ var _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Behaviors/index */ "./Behaviors/index.ts");
  127294. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AutoRotationBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AutoRotationBehavior"]; });
  127295. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BouncingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["BouncingBehavior"]; });
  127296. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FramingBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FramingBehavior"]; });
  127297. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AttachToBoxBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["AttachToBoxBehavior"]; });
  127298. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FadeInOutBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["FadeInOutBehavior"]; });
  127299. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiPointerScaleBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["MultiPointerScaleBehavior"]; });
  127300. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["PointerDragBehavior"]; });
  127301. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SixDofDragBehavior", function() { return _Behaviors_index__WEBPACK_IMPORTED_MODULE_5__["SixDofDragBehavior"]; });
  127302. /* harmony import */ var _Bones_index__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Bones/index */ "./Bones/index.ts");
  127303. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Bone", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Bone"]; });
  127304. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneIKController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneIKController"]; });
  127305. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneLookController", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["BoneLookController"]; });
  127306. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Skeleton", function() { return _Bones_index__WEBPACK_IMPORTED_MODULE_6__["Skeleton"]; });
  127307. /* harmony import */ var _Cameras_index__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Cameras/index */ "./Cameras/index.ts");
  127308. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputTypes", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputTypes"]; });
  127309. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["CameraInputsManager"]; });
  127310. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Camera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["Camera"]; });
  127311. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TargetCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TargetCamera"]; });
  127312. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCamera"]; });
  127313. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraInputsManager"]; });
  127314. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TouchCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["TouchCamera"]; });
  127315. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCamera"]; });
  127316. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraInputsManager"]; });
  127317. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeviceOrientationCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["DeviceOrientationCamera"]; });
  127318. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCamera"]; });
  127319. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraInputsManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraInputsManager"]; });
  127320. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FollowCamera"]; });
  127321. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcFollowCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcFollowCamera"]; });
  127322. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["GamepadCamera"]; });
  127323. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["UniversalCamera"]; });
  127324. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoysticksCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VirtualJoysticksCamera"]; });
  127325. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraGamepadInput"]; });
  127326. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraKeyboardMoveInput"]; });
  127327. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraMouseWheelInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraMouseWheelInput"]; });
  127328. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraPointersInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraPointersInput"]; });
  127329. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ArcRotateCameraVRDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["ArcRotateCameraVRDeviceOrientationInput"]; });
  127330. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraKeyboardInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraKeyboardInput"]; });
  127331. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FlyCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FlyCameraMouseInput"]; });
  127332. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraDeviceOrientationInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraDeviceOrientationInput"]; });
  127333. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraGamepadInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraGamepadInput"]; });
  127334. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraKeyboardMoveInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraKeyboardMoveInput"]; });
  127335. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraMouseInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraMouseInput"]; });
  127336. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraTouchInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraTouchInput"]; });
  127337. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FreeCameraVirtualJoystickInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["FreeCameraVirtualJoystickInput"]; });
  127338. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphArcRotateCamera"]; });
  127339. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphFreeCamera"]; });
  127340. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphGamepadCamera"]; });
  127341. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["AnaglyphUniversalCamera"]; });
  127342. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicArcRotateCamera"]; });
  127343. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicFreeCamera"]; });
  127344. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicGamepadCamera"]; });
  127345. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicUniversalCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["StereoscopicUniversalCamera"]; });
  127346. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRCameraMetrics", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRCameraMetrics"]; });
  127347. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationArcRotateCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationArcRotateCamera"]; });
  127348. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationFreeCamera"]; });
  127349. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDeviceOrientationGamepadCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRDeviceOrientationGamepadCamera"]; });
  127350. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["VRExperienceHelper"]; });
  127351. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRFreeCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebVRFreeCamera"]; });
  127352. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRCamera", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRCamera"]; });
  127353. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIButton", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIButton"]; });
  127354. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUIOptions", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUIOptions"]; });
  127355. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXREnterExitUI", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXREnterExitUI"]; });
  127356. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRState", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRState"]; });
  127357. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRExperienceHelper", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRExperienceHelper"]; });
  127358. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRController", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRController"]; });
  127359. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRInput", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRInput"]; });
  127360. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRManagedOutputCanvas", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRManagedOutputCanvas"]; });
  127361. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebXRSessionManager", function() { return _Cameras_index__WEBPACK_IMPORTED_MODULE_7__["WebXRSessionManager"]; });
  127362. /* harmony import */ var _Collisions_index__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Collisions/index */ "./Collisions/index.ts");
  127363. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Collider", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["Collider"]; });
  127364. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultCollisionCoordinator", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["DefaultCollisionCoordinator"]; });
  127365. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PickingInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["PickingInfo"]; });
  127366. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IntersectionInfo", function() { return _Collisions_index__WEBPACK_IMPORTED_MODULE_8__["IntersectionInfo"]; });
  127367. /* harmony import */ var _Culling_index__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Culling/index */ "./Culling/index.ts");
  127368. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBox", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingBox"]; });
  127369. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingInfo", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingInfo"]; });
  127370. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingSphere", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["BoundingSphere"]; });
  127371. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Ray", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Ray"]; });
  127372. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Octree", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["Octree"]; });
  127373. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeBlock", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeBlock"]; });
  127374. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OctreeSceneComponent", function() { return _Culling_index__WEBPACK_IMPORTED_MODULE_9__["OctreeSceneComponent"]; });
  127375. /* harmony import */ var _Debug_index__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Debug/index */ "./Debug/index.ts");
  127376. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["AxesViewer"]; });
  127377. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoneAxesViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["BoneAxesViewer"]; });
  127378. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DebugLayer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["DebugLayer"]; });
  127379. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["PhysicsViewer"]; });
  127380. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RayHelper", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["RayHelper"]; });
  127381. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SkeletonViewer", function() { return _Debug_index__WEBPACK_IMPORTED_MODULE_10__["SkeletonViewer"]; });
  127382. /* harmony import */ var _Engines_index__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Engines/index */ "./Engines/index.ts");
  127383. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Constants", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Constants"]; });
  127384. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancingAttributeInfo", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["InstancingAttributeInfo"]; });
  127385. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthTextureCreationOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["DepthTextureCreationOptions"]; });
  127386. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineCapabilities", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineCapabilities"]; });
  127387. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Engine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["Engine"]; });
  127388. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineStore", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["EngineStore"]; });
  127389. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngineOptions", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngineOptions"]; });
  127390. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NullEngine", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["NullEngine"]; });
  127391. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_OcclusionDataStorage", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_OcclusionDataStorage"]; });
  127392. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceTransformFeedbackToBundle", function() { return _Engines_index__WEBPACK_IMPORTED_MODULE_11__["_forceTransformFeedbackToBundle"]; });
  127393. /* harmony import */ var _Events_index__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Events/index */ "./Events/index.ts");
  127394. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardEventTypes"]; });
  127395. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfo"]; });
  127396. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KeyboardInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["KeyboardInfoPre"]; });
  127397. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerEventTypes"]; });
  127398. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoBase", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoBase"]; });
  127399. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfoPre", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfoPre"]; });
  127400. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointerInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["PointerInfo"]; });
  127401. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardEventTypes", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardEventTypes"]; });
  127402. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ClipboardInfo", function() { return _Events_index__WEBPACK_IMPORTED_MODULE_12__["ClipboardInfo"]; });
  127403. /* harmony import */ var _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Gamepads/index */ "./Gamepads/index.ts");
  127404. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DaydreamController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["DaydreamController"]; });
  127405. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GearVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GearVRController"]; });
  127406. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericController"]; });
  127407. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OculusTouchController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["OculusTouchController"]; });
  127408. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerType", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerType"]; });
  127409. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledControllerHelper", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledControllerHelper"]; });
  127410. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PoseEnabledController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["PoseEnabledController"]; });
  127411. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ViveController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["ViveController"]; });
  127412. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WebVRController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WebVRController"]; });
  127413. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WindowsMotionController", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["WindowsMotionController"]; });
  127414. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StickValues", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["StickValues"]; });
  127415. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gamepad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Gamepad"]; });
  127416. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GenericPad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GenericPad"]; });
  127417. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadManager", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadManager"]; });
  127418. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GamepadSystemSceneComponent", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["GamepadSystemSceneComponent"]; });
  127419. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Button", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Button"]; });
  127420. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Dpad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Dpad"]; });
  127421. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Xbox360Pad", function() { return _Gamepads_index__WEBPACK_IMPORTED_MODULE_13__["Xbox360Pad"]; });
  127422. /* harmony import */ var _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Gizmos/index */ "./Gizmos/index.ts");
  127423. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisDragGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisDragGizmo"]; });
  127424. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AxisScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["AxisScaleGizmo"]; });
  127425. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["BoundingBoxGizmo"]; });
  127426. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Gizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["Gizmo"]; });
  127427. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GizmoManager", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["GizmoManager"]; });
  127428. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneRotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PlaneRotationGizmo"]; });
  127429. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["PositionGizmo"]; });
  127430. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RotationGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["RotationGizmo"]; });
  127431. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScaleGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["ScaleGizmo"]; });
  127432. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LightGizmo", function() { return _Gizmos_index__WEBPACK_IMPORTED_MODULE_14__["LightGizmo"]; });
  127433. /* harmony import */ var _Helpers_index__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Helpers/index */ "./Helpers/index.ts");
  127434. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentHelper", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["EnvironmentHelper"]; });
  127435. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhotoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["PhotoDome"]; });
  127436. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_forceSceneHelpersToBundle", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["_forceSceneHelpersToBundle"]; });
  127437. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoDome", function() { return _Helpers_index__WEBPACK_IMPORTED_MODULE_15__["VideoDome"]; });
  127438. /* harmony import */ var _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Instrumentation/index */ "./Instrumentation/index.ts");
  127439. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EngineInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["EngineInstrumentation"]; });
  127440. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneInstrumentation", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["SceneInstrumentation"]; });
  127441. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TimeToken", function() { return _Instrumentation_index__WEBPACK_IMPORTED_MODULE_16__["_TimeToken"]; });
  127442. /* harmony import */ var _Layers_index__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Layers/index */ "./Layers/index.ts");
  127443. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayer"]; });
  127444. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectLayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["EffectLayerSceneComponent"]; });
  127445. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GlowLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["GlowLayer"]; });
  127446. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightLayer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["HighlightLayer"]; });
  127447. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Layer", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["Layer"]; });
  127448. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LayerSceneComponent", function() { return _Layers_index__WEBPACK_IMPORTED_MODULE_17__["LayerSceneComponent"]; });
  127449. /* harmony import */ var _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./LensFlares/index */ "./LensFlares/index.ts");
  127450. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlare", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlare"]; });
  127451. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystem", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystem"]; });
  127452. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlareSystemSceneComponent", function() { return _LensFlares_index__WEBPACK_IMPORTED_MODULE_18__["LensFlareSystemSceneComponent"]; });
  127453. /* harmony import */ var _Lights_index__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Lights/index */ "./Lights/index.ts");
  127454. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Light", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["Light"]; });
  127455. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowLight"]; });
  127456. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DirectionalLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["DirectionalLight"]; });
  127457. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["HemisphericLight"]; });
  127458. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["PointLight"]; });
  127459. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpotLight", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["SpotLight"]; });
  127460. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGenerator", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGenerator"]; });
  127461. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowGeneratorSceneComponent", function() { return _Lights_index__WEBPACK_IMPORTED_MODULE_19__["ShadowGeneratorSceneComponent"]; });
  127462. /* harmony import */ var _Loading_index__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Loading/index */ "./Loading/index.ts");
  127463. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultLoadingScreen", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["DefaultLoadingScreen"]; });
  127464. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderProgressEvent", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderProgressEvent"]; });
  127465. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoader", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoader"]; });
  127466. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneLoaderFlags", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["SceneLoaderFlags"]; });
  127467. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_BabylonLoaderRegistered", function() { return _Loading_index__WEBPACK_IMPORTED_MODULE_20__["_BabylonLoaderRegistered"]; });
  127468. /* harmony import */ var _Materials_index__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Materials/index */ "./Materials/index.ts");
  127469. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCurves", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorCurves"]; });
  127470. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectFallbacks", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectFallbacks"]; });
  127471. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EffectCreationOptions", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["EffectCreationOptions"]; });
  127472. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Effect", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Effect"]; });
  127473. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FresnelParameters", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["FresnelParameters"]; });
  127474. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfigurationDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfigurationDefines"]; });
  127475. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingConfiguration", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ImageProcessingConfiguration"]; });
  127476. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Material", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Material"]; });
  127477. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialDefines"]; });
  127478. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialHelper", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialHelper"]; });
  127479. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiMaterial"]; });
  127480. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PushMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PushMaterial"]; });
  127481. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShaderMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ShaderMaterial"]; });
  127482. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterialDefines", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterialDefines"]; });
  127483. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["StandardMaterial"]; });
  127484. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BaseTexture"]; });
  127485. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CubeTexture"]; });
  127486. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["HDRCubeTexture"]; });
  127487. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InternalTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["InternalTexture"]; });
  127488. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DummyInternalTextureTracker", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DummyInternalTextureTracker"]; });
  127489. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MirrorTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MirrorTexture"]; });
  127490. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiRenderTarget", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MultiRenderTarget"]; });
  127491. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture"]; });
  127492. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RenderTargetTexture"]; });
  127493. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Texture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["Texture"]; });
  127494. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UniformBuffer", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["UniformBuffer"]; });
  127495. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MaterialFlags", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["MaterialFlags"]; });
  127496. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BackgroundMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["BackgroundMaterial"]; });
  127497. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseMaterial"]; });
  127498. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRBaseSimpleMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRBaseSimpleMaterial"]; });
  127499. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMaterial"]; });
  127500. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRMetallicRoughnessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRMetallicRoughnessMaterial"]; });
  127501. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PBRSpecularGlossinessMaterial", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["PBRSpecularGlossinessMaterial"]; });
  127502. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradingTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ColorGradingTexture"]; });
  127503. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DynamicTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["DynamicTexture"]; });
  127504. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTexture"]; });
  127505. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawCubeTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawCubeTexture"]; });
  127506. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RawTexture3D", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RawTexture3D"]; });
  127507. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["RefractionTexture"]; });
  127508. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["VideoTexture"]; });
  127509. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DDSTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_DDSTextureLoader"]; });
  127510. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_ENVTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_ENVTextureLoader"]; });
  127511. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_KTXTextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_KTXTextureLoader"]; });
  127512. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TGATextureLoader", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["_TGATextureLoader"]; });
  127513. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["CustomProceduralTexture"]; });
  127514. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "NoiseProceduralTexture", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["NoiseProceduralTexture"]; });
  127515. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ProceduralTextureSceneComponent", function() { return _Materials_index__WEBPACK_IMPORTED_MODULE_21__["ProceduralTextureSceneComponent"]; });
  127516. /* harmony import */ var _Maths_index__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Maths/index */ "./Maths/index.ts");
  127517. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scalar", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Scalar"]; });
  127518. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToGammaSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToGammaSpace"]; });
  127519. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ToLinearSpace", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["ToLinearSpace"]; });
  127520. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Epsilon", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Epsilon"]; });
  127521. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color3"]; });
  127522. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Color4"]; });
  127523. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector2"]; });
  127524. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector3"]; });
  127525. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Vector4", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Vector4"]; });
  127526. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Size", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Size"]; });
  127527. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Quaternion", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Quaternion"]; });
  127528. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Matrix", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Matrix"]; });
  127529. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Plane", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Plane"]; });
  127530. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Viewport", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Viewport"]; });
  127531. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Frustum", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Frustum"]; });
  127532. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Space", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Space"]; });
  127533. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Axis", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Axis"]; });
  127534. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BezierCurve", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["BezierCurve"]; });
  127535. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Orientation", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Orientation"]; });
  127536. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Angle", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Angle"]; });
  127537. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Arc2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Arc2"]; });
  127538. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path2", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path2"]; });
  127539. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Path3D", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Path3D"]; });
  127540. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Curve3", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Curve3"]; });
  127541. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalVertex"]; });
  127542. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PositionNormalTextureVertex", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["PositionNormalTextureVertex"]; });
  127543. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tmp", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["Tmp"]; });
  127544. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalPolynomial", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalPolynomial"]; });
  127545. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphericalHarmonics", function() { return _Maths_index__WEBPACK_IMPORTED_MODULE_22__["SphericalHarmonics"]; });
  127546. /* harmony import */ var _Meshes_index__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Meshes/index */ "./Meshes/index.ts");
  127547. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["AbstractMesh"]; });
  127548. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Buffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Buffer"]; });
  127549. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexBuffer", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexBuffer"]; });
  127550. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CSG", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CSG"]; });
  127551. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Geometry", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Geometry"]; });
  127552. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundMesh"]; });
  127553. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TrailMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TrailMesh"]; });
  127554. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedMesh"]; });
  127555. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesMesh"]; });
  127556. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "InstancedLinesMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["InstancedLinesMesh"]; });
  127557. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshLODLevel", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshLODLevel"]; });
  127558. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_CreationDataStorage", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_CreationDataStorage"]; });
  127559. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_InstancesBatch", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["_InstancesBatch"]; });
  127560. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Mesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Mesh"]; });
  127561. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VertexData", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["VertexData"]; });
  127562. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["MeshBuilder"]; });
  127563. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationSettings", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationSettings"]; });
  127564. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationQueue", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationQueue"]; });
  127565. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplificationType", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplificationType"]; });
  127566. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SimplicationQueueSceneComponent", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SimplicationQueueSceneComponent"]; });
  127567. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Polygon", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["Polygon"]; });
  127568. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonMeshBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonMeshBuilder"]; });
  127569. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseSubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BaseSubMesh"]; });
  127570. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubMesh", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SubMesh"]; });
  127571. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TransformNode", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TransformNode"]; });
  127572. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["BoxBuilder"]; });
  127573. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["SphereBuilder"]; });
  127574. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["CylinderBuilder"]; });
  127575. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LinesBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LinesBuilder"]; });
  127576. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PlaneBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PlaneBuilder"]; });
  127577. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DracoCompression", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DracoCompression"]; });
  127578. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DiscBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DiscBuilder"]; });
  127579. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RibbonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["RibbonBuilder"]; });
  127580. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusBuilder"]; });
  127581. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TorusKnotBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TorusKnotBuilder"]; });
  127582. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolygonBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolygonBuilder"]; });
  127583. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShapeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["ShapeBuilder"]; });
  127584. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LatheBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["LatheBuilder"]; });
  127585. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GroundBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["GroundBuilder"]; });
  127586. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TubeBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["TubeBuilder"]; });
  127587. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PolyhedronBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["PolyhedronBuilder"]; });
  127588. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "IcoSphereBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["IcoSphereBuilder"]; });
  127589. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DecalBuilder", function() { return _Meshes_index__WEBPACK_IMPORTED_MODULE_23__["DecalBuilder"]; });
  127590. /* harmony import */ var _Morph_index__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Morph/index */ "./Morph/index.ts");
  127591. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTarget", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTarget"]; });
  127592. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MorphTargetManager", function() { return _Morph_index__WEBPACK_IMPORTED_MODULE_24__["MorphTargetManager"]; });
  127593. /* harmony import */ var _node__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./node */ "./node.ts");
  127594. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return _node__WEBPACK_IMPORTED_MODULE_25__["Node"]; });
  127595. /* harmony import */ var _Offline_index__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Offline/index */ "./Offline/index.ts");
  127596. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Database", function() { return _Offline_index__WEBPACK_IMPORTED_MODULE_26__["Database"]; });
  127597. /* harmony import */ var _Particles_index__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Particles/index */ "./Particles/index.ts");
  127598. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BaseParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BaseParticleSystem"]; });
  127599. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GPUParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["GPUParticleSystem"]; });
  127600. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Particle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["Particle"]; });
  127601. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleHelper", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleHelper"]; });
  127602. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystem"]; });
  127603. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_IDoNeedToBeInTheBuild", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["_IDoNeedToBeInTheBuild"]; });
  127604. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticleSystemSet", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ParticleSystemSet"]; });
  127605. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticle"]; });
  127606. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ModelShape", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ModelShape"]; });
  127607. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthSortedParticle", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["DepthSortedParticle"]; });
  127608. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SolidParticleSystem", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SolidParticleSystem"]; });
  127609. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitterType", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitterType"]; });
  127610. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SubEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SubEmitter"]; });
  127611. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoxParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["BoxParticleEmitter"]; });
  127612. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConeParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["ConeParticleEmitter"]; });
  127613. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderParticleEmitter"]; });
  127614. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CylinderDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["CylinderDirectedParticleEmitter"]; });
  127615. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HemisphericParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["HemisphericParticleEmitter"]; });
  127616. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PointParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["PointParticleEmitter"]; });
  127617. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereParticleEmitter"]; });
  127618. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SphereDirectedParticleEmitter", function() { return _Particles_index__WEBPACK_IMPORTED_MODULE_27__["SphereDirectedParticleEmitter"]; });
  127619. /* harmony import */ var _Physics_index__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./Physics/index */ "./Physics/index.ts");
  127620. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngine", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngine"]; });
  127621. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsEngineSceneComponent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsEngineSceneComponent"]; });
  127622. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsHelper", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsHelper"]; });
  127623. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialExplosionEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialExplosionEvent"]; });
  127624. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsGravitationalFieldEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsGravitationalFieldEvent"]; });
  127625. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftEvent"]; });
  127626. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsVortexEvent", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsVortexEvent"]; });
  127627. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsRadialImpulseFalloff", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsRadialImpulseFalloff"]; });
  127628. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsUpdraftMode", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsUpdraftMode"]; });
  127629. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsImpostor", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsImpostor"]; });
  127630. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PhysicsJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["PhysicsJoint"]; });
  127631. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DistanceJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["DistanceJoint"]; });
  127632. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotorEnabledJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["MotorEnabledJoint"]; });
  127633. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HingeJoint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["HingeJoint"]; });
  127634. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Hinge2Joint", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["Hinge2Joint"]; });
  127635. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CannonJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["CannonJSPlugin"]; });
  127636. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AmmoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["AmmoJSPlugin"]; });
  127637. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OimoJSPlugin", function() { return _Physics_index__WEBPACK_IMPORTED_MODULE_28__["OimoJSPlugin"]; });
  127638. /* harmony import */ var _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./PostProcesses/index */ "./PostProcesses/index.ts");
  127639. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AnaglyphPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["AnaglyphPostProcess"]; });
  127640. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlackAndWhitePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlackAndWhitePostProcess"]; });
  127641. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomEffect"]; });
  127642. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BloomMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BloomMergePostProcess"]; });
  127643. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["BlurPostProcess"]; });
  127644. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ChromaticAberrationPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ChromaticAberrationPostProcess"]; });
  127645. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CircleOfConfusionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["CircleOfConfusionPostProcess"]; });
  127646. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ColorCorrectionPostProcess"]; });
  127647. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ConvolutionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ConvolutionPostProcess"]; });
  127648. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldBlurPostProcess"]; });
  127649. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffectBlurLevel", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffectBlurLevel"]; });
  127650. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldEffect"]; });
  127651. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcessOptions", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcessOptions"]; });
  127652. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthOfFieldMergePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DepthOfFieldMergePostProcess"]; });
  127653. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DisplayPassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DisplayPassPostProcess"]; });
  127654. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ExtractHighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ExtractHighlightsPostProcess"]; });
  127655. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilterPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FilterPostProcess"]; });
  127656. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FxaaPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["FxaaPostProcess"]; });
  127657. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GrainPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["GrainPostProcess"]; });
  127658. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HighlightsPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["HighlightsPostProcess"]; });
  127659. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageProcessingPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["ImageProcessingPostProcess"]; });
  127660. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MotionBlurPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["MotionBlurPostProcess"]; });
  127661. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassPostProcess"]; });
  127662. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PassCubePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PassCubePostProcess"]; });
  127663. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcess"]; });
  127664. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessManager"]; });
  127665. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RefractionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["RefractionPostProcess"]; });
  127666. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SharpenPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SharpenPostProcess"]; });
  127667. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StereoscopicInterlacePostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StereoscopicInterlacePostProcess"]; });
  127668. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemappingOperator", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemappingOperator"]; });
  127669. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TonemapPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["TonemapPostProcess"]; });
  127670. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VolumetricLightScatteringPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VolumetricLightScatteringPostProcess"]; });
  127671. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VRDistortionCorrectionPostProcess", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["VRDistortionCorrectionPostProcess"]; });
  127672. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderEffect", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderEffect"]; });
  127673. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipeline"]; });
  127674. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManager", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManager"]; });
  127675. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessRenderPipelineManagerSceneComponent", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["PostProcessRenderPipelineManagerSceneComponent"]; });
  127676. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DefaultRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["DefaultRenderingPipeline"]; });
  127677. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["LensRenderingPipeline"]; });
  127678. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAO2RenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAO2RenderingPipeline"]; });
  127679. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SSAORenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["SSAORenderingPipeline"]; });
  127680. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StandardRenderingPipeline", function() { return _PostProcesses_index__WEBPACK_IMPORTED_MODULE_29__["StandardRenderingPipeline"]; });
  127681. /* harmony import */ var _Probes_index__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Probes/index */ "./Probes/index.ts");
  127682. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ReflectionProbe", function() { return _Probes_index__WEBPACK_IMPORTED_MODULE_30__["ReflectionProbe"]; });
  127683. /* harmony import */ var _Rendering_index__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Rendering/index */ "./Rendering/index.ts");
  127684. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BoundingBoxRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["BoundingBoxRenderer"]; });
  127685. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRenderer"]; });
  127686. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DepthRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["DepthRendererSceneComponent"]; });
  127687. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["EdgesRenderer"]; });
  127688. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LineEdgesRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["LineEdgesRenderer"]; });
  127689. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRenderer"]; });
  127690. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "GeometryBufferRendererSceneComponent", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["GeometryBufferRendererSceneComponent"]; });
  127691. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "OutlineRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["OutlineRenderer"]; });
  127692. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroup", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroup"]; });
  127693. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingGroupInfo", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingGroupInfo"]; });
  127694. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderingManager", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["RenderingManager"]; });
  127695. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "UtilityLayerRenderer", function() { return _Rendering_index__WEBPACK_IMPORTED_MODULE_31__["UtilityLayerRenderer"]; });
  127696. /* harmony import */ var _scene__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./scene */ "./scene.ts");
  127697. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return _scene__WEBPACK_IMPORTED_MODULE_32__["Scene"]; });
  127698. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  127699. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["SceneComponentConstants"]; });
  127700. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return _sceneComponent__WEBPACK_IMPORTED_MODULE_33__["Stage"]; });
  127701. /* harmony import */ var _Sprites_index__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./Sprites/index */ "./Sprites/index.ts");
  127702. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Sprite", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["Sprite"]; });
  127703. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteManager", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteManager"]; });
  127704. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SpriteSceneComponent", function() { return _Sprites_index__WEBPACK_IMPORTED_MODULE_34__["SpriteSceneComponent"]; });
  127705. /* harmony import */ var _States_index__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./States/index */ "./States/index.ts");
  127706. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_AlphaState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_AlphaState"]; });
  127707. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_DepthCullingState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_DepthCullingState"]; });
  127708. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_StencilState", function() { return _States_index__WEBPACK_IMPORTED_MODULE_35__["_StencilState"]; });
  127709. /* harmony import */ var _Misc_index__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Misc/index */ "./Misc/index.ts");
  127710. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AndOrNotEvaluator", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AndOrNotEvaluator"]; });
  127711. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetTaskState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetTaskState"]; });
  127712. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AbstractAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AbstractAssetTask"]; });
  127713. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsProgressEvent", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsProgressEvent"]; });
  127714. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MeshAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MeshAssetTask"]; });
  127715. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextFileAssetTask"]; });
  127716. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "BinaryFileAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["BinaryFileAssetTask"]; });
  127717. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ImageAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ImageAssetTask"]; });
  127718. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureAssetTask"]; });
  127719. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeTextureAssetTask"]; });
  127720. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRCubeTextureAssetTask", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRCubeTextureAssetTask"]; });
  127721. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AssetsManager", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AssetsManager"]; });
  127722. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DDSTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DDSTools"]; });
  127723. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "expandToProperty", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["expandToProperty"]; });
  127724. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serialize", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serialize"]; });
  127725. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsTexture", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsTexture"]; });
  127726. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor3"]; });
  127727. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsFresnelParameters", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsFresnelParameters"]; });
  127728. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector2", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector2"]; });
  127729. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsVector3", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsVector3"]; });
  127730. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsMeshReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsMeshReference"]; });
  127731. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColorCurves", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColorCurves"]; });
  127732. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsColor4", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsColor4"]; });
  127733. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsImageProcessingConfiguration", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsImageProcessingConfiguration"]; });
  127734. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsQuaternion", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsQuaternion"]; });
  127735. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "serializeAsCameraReference", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["serializeAsCameraReference"]; });
  127736. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SerializationHelper", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SerializationHelper"]; });
  127737. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Deferred", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Deferred"]; });
  127738. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EnvironmentTextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EnvironmentTextureTools"]; });
  127739. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInput", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInput"]; });
  127740. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "KhronosTextureContainer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["KhronosTextureContainer"]; });
  127741. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "EventState", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["EventState"]; });
  127742. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observer"]; });
  127743. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MultiObserver", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MultiObserver"]; });
  127744. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Observable", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Observable"]; });
  127745. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerformanceMonitor", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerformanceMonitor"]; });
  127746. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RollingAverage", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RollingAverage"]; });
  127747. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PromisePolyfill", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PromisePolyfill"]; });
  127748. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimization"]; });
  127749. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureOptimization"]; });
  127750. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HardwareScalingOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HardwareScalingOptimization"]; });
  127751. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ShadowsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ShadowsOptimization"]; });
  127752. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PostProcessesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PostProcessesOptimization"]; });
  127753. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LensFlaresOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LensFlaresOptimization"]; });
  127754. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CustomOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CustomOptimization"]; });
  127755. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ParticlesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ParticlesOptimization"]; });
  127756. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RenderTargetsOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RenderTargetsOptimization"]; });
  127757. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "MergeMeshesOptimization", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["MergeMeshesOptimization"]; });
  127758. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizerOptions", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizerOptions"]; });
  127759. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneOptimizer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneOptimizer"]; });
  127760. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SceneSerializer", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SceneSerializer"]; });
  127761. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArray", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArray"]; });
  127762. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "SmartArrayNoDuplicate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["SmartArrayNoDuplicate"]; });
  127763. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "StringDictionary", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["StringDictionary"]; });
  127764. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tags", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tags"]; });
  127765. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TextureTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TextureTools"]; });
  127766. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "TGATools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["TGATools"]; });
  127767. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ColorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ColorGradient"]; });
  127768. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Color3Gradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Color3Gradient"]; });
  127769. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FactorGradient", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FactorGradient"]; });
  127770. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "LoadFileError", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["LoadFileError"]; });
  127771. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "RetryStrategy", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["RetryStrategy"]; });
  127772. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Tools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Tools"]; });
  127773. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PerfCounter", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PerfCounter"]; });
  127774. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "className", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["className"]; });
  127775. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "AsyncLoop", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["AsyncLoop"]; });
  127776. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VideoRecorder", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VideoRecorder"]; });
  127777. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "JoystickAxis", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["JoystickAxis"]; });
  127778. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "VirtualJoystick", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["VirtualJoystick"]; });
  127779. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "WorkerPool", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["WorkerPool"]; });
  127780. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "Logger", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["Logger"]; });
  127781. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "_TypeStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["_TypeStore"]; });
  127782. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "FilesInputStore", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["FilesInputStore"]; });
  127783. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "DeepCopier", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["DeepCopier"]; });
  127784. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PivotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PivotTools"]; });
  127785. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PrecisionDate", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PrecisionDate"]; });
  127786. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "ScreenshotTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["ScreenshotTools"]; });
  127787. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "CubeMapToSphericalPolynomialTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["CubeMapToSphericalPolynomialTools"]; });
  127788. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "HDRTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["HDRTools"]; });
  127789. /* harmony reexport (safe) */ __webpack_require__.d(__webpack_exports__, "PanoramaToCubeMapTools", function() { return _Misc_index__WEBPACK_IMPORTED_MODULE_36__["PanoramaToCubeMapTools"]; });
  127790. /***/ }),
  127791. /***/ "./node.ts":
  127792. /*!*****************!*\
  127793. !*** ./node.ts ***!
  127794. \*****************/
  127795. /*! exports provided: Node */
  127796. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  127797. "use strict";
  127798. __webpack_require__.r(__webpack_exports__);
  127799. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Node", function() { return Node; });
  127800. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  127801. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  127802. /* harmony import */ var _Misc_decorators__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/decorators */ "./Misc/decorators.ts");
  127803. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  127804. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  127805. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  127806. /**
  127807. * Node is the basic class for all scene objects (Mesh, Light, Camera.)
  127808. */
  127809. var Node = /** @class */ (function () {
  127810. /**
  127811. * Creates a new Node
  127812. * @param name the name and id to be given to this node
  127813. * @param scene the scene this node will be added to
  127814. * @param addToRootNodes the node will be added to scene.rootNodes
  127815. */
  127816. function Node(name, scene, addToRootNodes) {
  127817. if (scene === void 0) { scene = null; }
  127818. if (addToRootNodes === void 0) { addToRootNodes = true; }
  127819. /**
  127820. * Gets or sets a string used to store user defined state for the node
  127821. */
  127822. this.state = "";
  127823. /**
  127824. * Gets or sets an object used to store user defined information for the node
  127825. */
  127826. this.metadata = null;
  127827. /**
  127828. * For internal use only. Please do not use.
  127829. */
  127830. this.reservedDataStore = null;
  127831. /**
  127832. * Gets or sets a boolean used to define if the node must be serialized
  127833. */
  127834. this.doNotSerialize = false;
  127835. /** @hidden */
  127836. this._isDisposed = false;
  127837. /**
  127838. * Gets a list of Animations associated with the node
  127839. */
  127840. this.animations = new Array();
  127841. this._ranges = {};
  127842. this._isEnabled = true;
  127843. this._isParentEnabled = true;
  127844. this._isReady = true;
  127845. /** @hidden */
  127846. this._currentRenderId = -1;
  127847. this._parentRenderId = -1;
  127848. this._childRenderId = -1;
  127849. /** @hidden */
  127850. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  127851. /** @hidden */
  127852. this._worldMatrixDeterminant = 0;
  127853. /** @hidden */
  127854. this._sceneRootNodesIndex = -1;
  127855. this._animationPropertiesOverride = null;
  127856. /** @hidden */
  127857. this._isNode = true;
  127858. /**
  127859. * An event triggered when the mesh is disposed
  127860. */
  127861. this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  127862. // Behaviors
  127863. this._behaviors = new Array();
  127864. this.name = name;
  127865. this.id = name;
  127866. this._scene = (scene || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_4__["EngineStore"].LastCreatedScene);
  127867. this.uniqueId = this._scene.getUniqueId();
  127868. this._initCache();
  127869. if (addToRootNodes) {
  127870. this.addToSceneRootNodes();
  127871. }
  127872. }
  127873. /**
  127874. * Add a new node constructor
  127875. * @param type defines the type name of the node to construct
  127876. * @param constructorFunc defines the constructor function
  127877. */
  127878. Node.AddNodeConstructor = function (type, constructorFunc) {
  127879. this._NodeConstructors[type] = constructorFunc;
  127880. };
  127881. /**
  127882. * Returns a node constructor based on type name
  127883. * @param type defines the type name
  127884. * @param name defines the new node name
  127885. * @param scene defines the hosting scene
  127886. * @param options defines optional options to transmit to constructors
  127887. * @returns the new constructor or null
  127888. */
  127889. Node.Construct = function (type, name, scene, options) {
  127890. var constructorFunc = this._NodeConstructors[type];
  127891. if (!constructorFunc) {
  127892. return null;
  127893. }
  127894. return constructorFunc(name, scene, options);
  127895. };
  127896. /**
  127897. * Gets a boolean indicating if the node has been disposed
  127898. * @returns true if the node was disposed
  127899. */
  127900. Node.prototype.isDisposed = function () {
  127901. return this._isDisposed;
  127902. };
  127903. Object.defineProperty(Node.prototype, "parent", {
  127904. get: function () {
  127905. return this._parentNode;
  127906. },
  127907. /**
  127908. * Gets or sets the parent of the node
  127909. */
  127910. set: function (parent) {
  127911. if (this._parentNode === parent) {
  127912. return;
  127913. }
  127914. var previousParentNode = this._parentNode;
  127915. // Remove self from list of children of parent
  127916. if (this._parentNode && this._parentNode._children !== undefined && this._parentNode._children !== null) {
  127917. var index = this._parentNode._children.indexOf(this);
  127918. if (index !== -1) {
  127919. this._parentNode._children.splice(index, 1);
  127920. }
  127921. if (!parent && !this._isDisposed) {
  127922. this.addToSceneRootNodes();
  127923. }
  127924. }
  127925. // Store new parent
  127926. this._parentNode = parent;
  127927. // Add as child to new parent
  127928. if (this._parentNode) {
  127929. if (this._parentNode._children === undefined || this._parentNode._children === null) {
  127930. this._parentNode._children = new Array();
  127931. }
  127932. this._parentNode._children.push(this);
  127933. if (!previousParentNode) {
  127934. this.removeFromSceneRootNodes();
  127935. }
  127936. }
  127937. // Enabled state
  127938. this._syncParentEnabledState();
  127939. },
  127940. enumerable: true,
  127941. configurable: true
  127942. });
  127943. Node.prototype.addToSceneRootNodes = function () {
  127944. if (this._sceneRootNodesIndex === -1) {
  127945. this._sceneRootNodesIndex = this._scene.rootNodes.length;
  127946. this._scene.rootNodes.push(this);
  127947. }
  127948. };
  127949. Node.prototype.removeFromSceneRootNodes = function () {
  127950. if (this._sceneRootNodesIndex !== -1) {
  127951. var rootNodes = this._scene.rootNodes;
  127952. var lastIdx = rootNodes.length - 1;
  127953. rootNodes[this._sceneRootNodesIndex] = rootNodes[lastIdx];
  127954. rootNodes[this._sceneRootNodesIndex]._sceneRootNodesIndex = this._sceneRootNodesIndex;
  127955. this._scene.rootNodes.pop();
  127956. this._sceneRootNodesIndex = -1;
  127957. }
  127958. };
  127959. Object.defineProperty(Node.prototype, "animationPropertiesOverride", {
  127960. /**
  127961. * Gets or sets the animation properties override
  127962. */
  127963. get: function () {
  127964. if (!this._animationPropertiesOverride) {
  127965. return this._scene.animationPropertiesOverride;
  127966. }
  127967. return this._animationPropertiesOverride;
  127968. },
  127969. set: function (value) {
  127970. this._animationPropertiesOverride = value;
  127971. },
  127972. enumerable: true,
  127973. configurable: true
  127974. });
  127975. /**
  127976. * Gets a string idenfifying the name of the class
  127977. * @returns "Node" string
  127978. */
  127979. Node.prototype.getClassName = function () {
  127980. return "Node";
  127981. };
  127982. Object.defineProperty(Node.prototype, "onDispose", {
  127983. /**
  127984. * Sets a callback that will be raised when the node will be disposed
  127985. */
  127986. set: function (callback) {
  127987. if (this._onDisposeObserver) {
  127988. this.onDisposeObservable.remove(this._onDisposeObserver);
  127989. }
  127990. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  127991. },
  127992. enumerable: true,
  127993. configurable: true
  127994. });
  127995. /**
  127996. * Gets the scene of the node
  127997. * @returns a scene
  127998. */
  127999. Node.prototype.getScene = function () {
  128000. return this._scene;
  128001. };
  128002. /**
  128003. * Gets the engine of the node
  128004. * @returns a Engine
  128005. */
  128006. Node.prototype.getEngine = function () {
  128007. return this._scene.getEngine();
  128008. };
  128009. /**
  128010. * Attach a behavior to the node
  128011. * @see http://doc.babylonjs.com/features/behaviour
  128012. * @param behavior defines the behavior to attach
  128013. * @param attachImmediately defines that the behavior must be attached even if the scene is still loading
  128014. * @returns the current Node
  128015. */
  128016. Node.prototype.addBehavior = function (behavior, attachImmediately) {
  128017. var _this = this;
  128018. if (attachImmediately === void 0) { attachImmediately = false; }
  128019. var index = this._behaviors.indexOf(behavior);
  128020. if (index !== -1) {
  128021. return this;
  128022. }
  128023. behavior.init();
  128024. if (this._scene.isLoading && !attachImmediately) {
  128025. // We defer the attach when the scene will be loaded
  128026. this._scene.onDataLoadedObservable.addOnce(function () {
  128027. behavior.attach(_this);
  128028. });
  128029. }
  128030. else {
  128031. behavior.attach(this);
  128032. }
  128033. this._behaviors.push(behavior);
  128034. return this;
  128035. };
  128036. /**
  128037. * Remove an attached behavior
  128038. * @see http://doc.babylonjs.com/features/behaviour
  128039. * @param behavior defines the behavior to attach
  128040. * @returns the current Node
  128041. */
  128042. Node.prototype.removeBehavior = function (behavior) {
  128043. var index = this._behaviors.indexOf(behavior);
  128044. if (index === -1) {
  128045. return this;
  128046. }
  128047. this._behaviors[index].detach();
  128048. this._behaviors.splice(index, 1);
  128049. return this;
  128050. };
  128051. Object.defineProperty(Node.prototype, "behaviors", {
  128052. /**
  128053. * Gets the list of attached behaviors
  128054. * @see http://doc.babylonjs.com/features/behaviour
  128055. */
  128056. get: function () {
  128057. return this._behaviors;
  128058. },
  128059. enumerable: true,
  128060. configurable: true
  128061. });
  128062. /**
  128063. * Gets an attached behavior by name
  128064. * @param name defines the name of the behavior to look for
  128065. * @see http://doc.babylonjs.com/features/behaviour
  128066. * @returns null if behavior was not found else the requested behavior
  128067. */
  128068. Node.prototype.getBehaviorByName = function (name) {
  128069. for (var _i = 0, _a = this._behaviors; _i < _a.length; _i++) {
  128070. var behavior = _a[_i];
  128071. if (behavior.name === name) {
  128072. return behavior;
  128073. }
  128074. }
  128075. return null;
  128076. };
  128077. /**
  128078. * Returns the latest update of the World matrix
  128079. * @returns a Matrix
  128080. */
  128081. Node.prototype.getWorldMatrix = function () {
  128082. if (this._currentRenderId !== this._scene.getRenderId()) {
  128083. this.computeWorldMatrix();
  128084. }
  128085. return this._worldMatrix;
  128086. };
  128087. /** @hidden */
  128088. Node.prototype._getWorldMatrixDeterminant = function () {
  128089. return this._worldMatrixDeterminant;
  128090. };
  128091. Object.defineProperty(Node.prototype, "worldMatrixFromCache", {
  128092. /**
  128093. * Returns directly the latest state of the mesh World matrix.
  128094. * A Matrix is returned.
  128095. */
  128096. get: function () {
  128097. return this._worldMatrix;
  128098. },
  128099. enumerable: true,
  128100. configurable: true
  128101. });
  128102. // override it in derived class if you add new variables to the cache
  128103. // and call the parent class method
  128104. /** @hidden */
  128105. Node.prototype._initCache = function () {
  128106. this._cache = {};
  128107. this._cache.parent = undefined;
  128108. };
  128109. /** @hidden */
  128110. Node.prototype.updateCache = function (force) {
  128111. if (!force && this.isSynchronized()) {
  128112. return;
  128113. }
  128114. this._cache.parent = this.parent;
  128115. this._updateCache();
  128116. };
  128117. /** @hidden */
  128118. Node.prototype._getActionManagerForTrigger = function (trigger, initialCall) {
  128119. if (initialCall === void 0) { initialCall = true; }
  128120. if (!this.parent) {
  128121. return null;
  128122. }
  128123. return this.parent._getActionManagerForTrigger(trigger, false);
  128124. };
  128125. // override it in derived class if you add new variables to the cache
  128126. // and call the parent class method if !ignoreParentClass
  128127. /** @hidden */
  128128. Node.prototype._updateCache = function (ignoreParentClass) {
  128129. };
  128130. // override it in derived class if you add new variables to the cache
  128131. /** @hidden */
  128132. Node.prototype._isSynchronized = function () {
  128133. return true;
  128134. };
  128135. /** @hidden */
  128136. Node.prototype._markSyncedWithParent = function () {
  128137. if (this._parentNode) {
  128138. this._parentRenderId = this._parentNode._childRenderId;
  128139. }
  128140. };
  128141. /** @hidden */
  128142. Node.prototype.isSynchronizedWithParent = function () {
  128143. if (!this._parentNode) {
  128144. return true;
  128145. }
  128146. if (this._parentRenderId !== this._parentNode._childRenderId) {
  128147. return false;
  128148. }
  128149. return this._parentNode.isSynchronized();
  128150. };
  128151. /** @hidden */
  128152. Node.prototype.isSynchronized = function () {
  128153. if (this._cache.parent != this._parentNode) {
  128154. this._cache.parent = this._parentNode;
  128155. return false;
  128156. }
  128157. if (this._parentNode && !this.isSynchronizedWithParent()) {
  128158. return false;
  128159. }
  128160. return this._isSynchronized();
  128161. };
  128162. /**
  128163. * Is this node ready to be used/rendered
  128164. * @param completeCheck defines if a complete check (including materials and lights) has to be done (false by default)
  128165. * @return true if the node is ready
  128166. */
  128167. Node.prototype.isReady = function (completeCheck) {
  128168. if (completeCheck === void 0) { completeCheck = false; }
  128169. return this._isReady;
  128170. };
  128171. /**
  128172. * Is this node enabled?
  128173. * 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
  128174. * @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
  128175. * @return whether this node (and its parent) is enabled
  128176. */
  128177. Node.prototype.isEnabled = function (checkAncestors) {
  128178. if (checkAncestors === void 0) { checkAncestors = true; }
  128179. if (checkAncestors === false) {
  128180. return this._isEnabled;
  128181. }
  128182. if (!this._isEnabled) {
  128183. return false;
  128184. }
  128185. return this._isParentEnabled;
  128186. };
  128187. /** @hidden */
  128188. Node.prototype._syncParentEnabledState = function () {
  128189. this._isParentEnabled = this._parentNode ? this._parentNode.isEnabled() : true;
  128190. if (this._children) {
  128191. this._children.forEach(function (c) {
  128192. c._syncParentEnabledState(); // Force children to update accordingly
  128193. });
  128194. }
  128195. };
  128196. /**
  128197. * Set the enabled state of this node
  128198. * @param value defines the new enabled state
  128199. */
  128200. Node.prototype.setEnabled = function (value) {
  128201. this._isEnabled = value;
  128202. this._syncParentEnabledState();
  128203. };
  128204. /**
  128205. * Is this node a descendant of the given node?
  128206. * The function will iterate up the hierarchy until the ancestor was found or no more parents defined
  128207. * @param ancestor defines the parent node to inspect
  128208. * @returns a boolean indicating if this node is a descendant of the given node
  128209. */
  128210. Node.prototype.isDescendantOf = function (ancestor) {
  128211. if (this.parent) {
  128212. if (this.parent === ancestor) {
  128213. return true;
  128214. }
  128215. return this.parent.isDescendantOf(ancestor);
  128216. }
  128217. return false;
  128218. };
  128219. /** @hidden */
  128220. Node.prototype._getDescendants = function (results, directDescendantsOnly, predicate) {
  128221. if (directDescendantsOnly === void 0) { directDescendantsOnly = false; }
  128222. if (!this._children) {
  128223. return;
  128224. }
  128225. for (var index = 0; index < this._children.length; index++) {
  128226. var item = this._children[index];
  128227. if (!predicate || predicate(item)) {
  128228. results.push(item);
  128229. }
  128230. if (!directDescendantsOnly) {
  128231. item._getDescendants(results, false, predicate);
  128232. }
  128233. }
  128234. };
  128235. /**
  128236. * Will return all nodes that have this node as ascendant
  128237. * @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
  128238. * @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
  128239. * @return all children nodes of all types
  128240. */
  128241. Node.prototype.getDescendants = function (directDescendantsOnly, predicate) {
  128242. var results = new Array();
  128243. this._getDescendants(results, directDescendantsOnly, predicate);
  128244. return results;
  128245. };
  128246. /**
  128247. * Get all child-meshes of this node
  128248. * @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)
  128249. * @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
  128250. * @returns an array of AbstractMesh
  128251. */
  128252. Node.prototype.getChildMeshes = function (directDescendantsOnly, predicate) {
  128253. var results = [];
  128254. this._getDescendants(results, directDescendantsOnly, function (node) {
  128255. return ((!predicate || predicate(node)) && (node.cullingStrategy !== undefined));
  128256. });
  128257. return results;
  128258. };
  128259. /**
  128260. * Get all direct children of this node
  128261. * @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
  128262. * @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)
  128263. * @returns an array of Node
  128264. */
  128265. Node.prototype.getChildren = function (predicate, directDescendantsOnly) {
  128266. if (directDescendantsOnly === void 0) { directDescendantsOnly = true; }
  128267. return this.getDescendants(directDescendantsOnly, predicate);
  128268. };
  128269. /** @hidden */
  128270. Node.prototype._setReady = function (state) {
  128271. if (state === this._isReady) {
  128272. return;
  128273. }
  128274. if (!state) {
  128275. this._isReady = false;
  128276. return;
  128277. }
  128278. if (this.onReady) {
  128279. this.onReady(this);
  128280. }
  128281. this._isReady = true;
  128282. };
  128283. /**
  128284. * Get an animation by name
  128285. * @param name defines the name of the animation to look for
  128286. * @returns null if not found else the requested animation
  128287. */
  128288. Node.prototype.getAnimationByName = function (name) {
  128289. for (var i = 0; i < this.animations.length; i++) {
  128290. var animation = this.animations[i];
  128291. if (animation.name === name) {
  128292. return animation;
  128293. }
  128294. }
  128295. return null;
  128296. };
  128297. /**
  128298. * Creates an animation range for this node
  128299. * @param name defines the name of the range
  128300. * @param from defines the starting key
  128301. * @param to defines the end key
  128302. */
  128303. Node.prototype.createAnimationRange = function (name, from, to) {
  128304. // check name not already in use
  128305. if (!this._ranges[name]) {
  128306. this._ranges[name] = Node._AnimationRangeFactory(name, from, to);
  128307. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  128308. if (this.animations[i]) {
  128309. this.animations[i].createRange(name, from, to);
  128310. }
  128311. }
  128312. }
  128313. };
  128314. /**
  128315. * Delete a specific animation range
  128316. * @param name defines the name of the range to delete
  128317. * @param deleteFrames defines if animation frames from the range must be deleted as well
  128318. */
  128319. Node.prototype.deleteAnimationRange = function (name, deleteFrames) {
  128320. if (deleteFrames === void 0) { deleteFrames = true; }
  128321. for (var i = 0, nAnimations = this.animations.length; i < nAnimations; i++) {
  128322. if (this.animations[i]) {
  128323. this.animations[i].deleteRange(name, deleteFrames);
  128324. }
  128325. }
  128326. this._ranges[name] = null; // said much faster than 'delete this._range[name]'
  128327. };
  128328. /**
  128329. * Get an animation range by name
  128330. * @param name defines the name of the animation range to look for
  128331. * @returns null if not found else the requested animation range
  128332. */
  128333. Node.prototype.getAnimationRange = function (name) {
  128334. return this._ranges[name];
  128335. };
  128336. /**
  128337. * Will start the animation sequence
  128338. * @param name defines the range frames for animation sequence
  128339. * @param loop defines if the animation should loop (false by default)
  128340. * @param speedRatio defines the speed factor in which to run the animation (1 by default)
  128341. * @param onAnimationEnd defines a function to be executed when the animation ended (undefined by default)
  128342. * @returns the object created for this animation. If range does not exist, it will return null
  128343. */
  128344. Node.prototype.beginAnimation = function (name, loop, speedRatio, onAnimationEnd) {
  128345. var range = this.getAnimationRange(name);
  128346. if (!range) {
  128347. return null;
  128348. }
  128349. return this._scene.beginAnimation(this, range.from, range.to, loop, speedRatio, onAnimationEnd);
  128350. };
  128351. /**
  128352. * Serialize animation ranges into a JSON compatible object
  128353. * @returns serialization object
  128354. */
  128355. Node.prototype.serializeAnimationRanges = function () {
  128356. var serializationRanges = [];
  128357. for (var name in this._ranges) {
  128358. var localRange = this._ranges[name];
  128359. if (!localRange) {
  128360. continue;
  128361. }
  128362. var range = {};
  128363. range.name = name;
  128364. range.from = localRange.from;
  128365. range.to = localRange.to;
  128366. serializationRanges.push(range);
  128367. }
  128368. return serializationRanges;
  128369. };
  128370. /**
  128371. * Computes the world matrix of the node
  128372. * @param force defines if the cache version should be invalidated forcing the world matrix to be created from scratch
  128373. * @returns the world matrix
  128374. */
  128375. Node.prototype.computeWorldMatrix = function (force) {
  128376. if (!this._worldMatrix) {
  128377. this._worldMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_1__["Matrix"].Identity();
  128378. }
  128379. return this._worldMatrix;
  128380. };
  128381. /**
  128382. * Releases resources associated with this node.
  128383. * @param doNotRecurse Set to true to not recurse into each children (recurse into each children by default)
  128384. * @param disposeMaterialAndTextures Set to true to also dispose referenced materials and textures (false by default)
  128385. */
  128386. Node.prototype.dispose = function (doNotRecurse, disposeMaterialAndTextures) {
  128387. if (disposeMaterialAndTextures === void 0) { disposeMaterialAndTextures = false; }
  128388. this._isDisposed = true;
  128389. if (!doNotRecurse) {
  128390. var nodes = this.getDescendants(true);
  128391. for (var _i = 0, nodes_1 = nodes; _i < nodes_1.length; _i++) {
  128392. var node = nodes_1[_i];
  128393. node.dispose(doNotRecurse, disposeMaterialAndTextures);
  128394. }
  128395. }
  128396. if (!this.parent) {
  128397. this.removeFromSceneRootNodes();
  128398. }
  128399. else {
  128400. this.parent = null;
  128401. }
  128402. // Callback
  128403. this.onDisposeObservable.notifyObservers(this);
  128404. this.onDisposeObservable.clear();
  128405. // Behaviors
  128406. for (var _a = 0, _b = this._behaviors; _a < _b.length; _a++) {
  128407. var behavior = _b[_a];
  128408. behavior.detach();
  128409. }
  128410. this._behaviors = [];
  128411. };
  128412. /**
  128413. * Parse animation range data from a serialization object and store them into a given node
  128414. * @param node defines where to store the animation ranges
  128415. * @param parsedNode defines the serialization object to read data from
  128416. * @param scene defines the hosting scene
  128417. */
  128418. Node.ParseAnimationRanges = function (node, parsedNode, scene) {
  128419. if (parsedNode.ranges) {
  128420. for (var index = 0; index < parsedNode.ranges.length; index++) {
  128421. var data = parsedNode.ranges[index];
  128422. node.createAnimationRange(data.name, data.from, data.to);
  128423. }
  128424. }
  128425. };
  128426. /** @hidden */
  128427. Node._AnimationRangeFactory = function (name, from, to) {
  128428. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_5__["_DevTools"].WarnImport("AnimationRange");
  128429. };
  128430. Node._NodeConstructors = {};
  128431. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128432. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  128433. ], Node.prototype, "name", void 0);
  128434. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128435. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  128436. ], Node.prototype, "id", void 0);
  128437. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128438. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  128439. ], Node.prototype, "uniqueId", void 0);
  128440. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128441. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  128442. ], Node.prototype, "state", void 0);
  128443. tslib__WEBPACK_IMPORTED_MODULE_0__["__decorate"]([
  128444. Object(_Misc_decorators__WEBPACK_IMPORTED_MODULE_2__["serialize"])()
  128445. ], Node.prototype, "metadata", void 0);
  128446. return Node;
  128447. }());
  128448. /***/ }),
  128449. /***/ "./scene.ts":
  128450. /*!******************!*\
  128451. !*** ./scene.ts ***!
  128452. \******************/
  128453. /*! exports provided: Scene */
  128454. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  128455. "use strict";
  128456. __webpack_require__.r(__webpack_exports__);
  128457. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Scene", function() { return Scene; });
  128458. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  128459. /* harmony import */ var _Misc_tools__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Misc/tools */ "./Misc/tools.ts");
  128460. /* harmony import */ var _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Misc/precisionDate */ "./Misc/precisionDate.ts");
  128461. /* harmony import */ var _Misc_observable__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Misc/observable */ "./Misc/observable.ts");
  128462. /* harmony import */ var _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Misc/smartArray */ "./Misc/smartArray.ts");
  128463. /* harmony import */ var _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Misc/stringDictionary */ "./Misc/stringDictionary.ts");
  128464. /* harmony import */ var _Misc_tags__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Misc/tags */ "./Misc/tags.ts");
  128465. /* harmony import */ var _Maths_math__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Maths/math */ "./Maths/math.ts");
  128466. /* harmony import */ var _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Meshes/abstractMesh */ "./Meshes/abstractMesh.ts");
  128467. /* harmony import */ var _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Cameras/camera */ "./Cameras/camera.ts");
  128468. /* harmony import */ var _abstractScene__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./abstractScene */ "./abstractScene.ts");
  128469. /* harmony import */ var _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Materials/imageProcessingConfiguration */ "./Materials/imageProcessingConfiguration.ts");
  128470. /* harmony import */ var _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Materials/uniformBuffer */ "./Materials/uniformBuffer.ts");
  128471. /* harmony import */ var _Lights_light__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Lights/light */ "./Lights/light.ts");
  128472. /* harmony import */ var _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Collisions/pickingInfo */ "./Collisions/pickingInfo.ts");
  128473. /* harmony import */ var _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Events/pointerEvents */ "./Events/pointerEvents.ts");
  128474. /* harmony import */ var _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Events/keyboardEvents */ "./Events/keyboardEvents.ts");
  128475. /* harmony import */ var _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Actions/actionEvent */ "./Actions/actionEvent.ts");
  128476. /* harmony import */ var _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./PostProcesses/postProcessManager */ "./PostProcesses/postProcessManager.ts");
  128477. /* harmony import */ var _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./Rendering/renderingManager */ "./Rendering/renderingManager.ts");
  128478. /* harmony import */ var _sceneComponent__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./sceneComponent */ "./sceneComponent.ts");
  128479. /* harmony import */ var _Engines_constants__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Engines/constants */ "./Engines/constants.ts");
  128480. /* harmony import */ var _Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Misc/domManagement */ "./Misc/domManagement.ts");
  128481. /* harmony import */ var _Misc_logger__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Misc/logger */ "./Misc/logger.ts");
  128482. /* harmony import */ var _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./Engines/engineStore */ "./Engines/engineStore.ts");
  128483. /* harmony import */ var _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./Actions/abstractActionManager */ "./Actions/abstractActionManager.ts");
  128484. /* harmony import */ var _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Misc/devTools */ "./Misc/devTools.ts");
  128485. /** @hidden */
  128486. var ClickInfo = /** @class */ (function () {
  128487. function ClickInfo() {
  128488. this._singleClick = false;
  128489. this._doubleClick = false;
  128490. this._hasSwiped = false;
  128491. this._ignore = false;
  128492. }
  128493. Object.defineProperty(ClickInfo.prototype, "singleClick", {
  128494. get: function () {
  128495. return this._singleClick;
  128496. },
  128497. set: function (b) {
  128498. this._singleClick = b;
  128499. },
  128500. enumerable: true,
  128501. configurable: true
  128502. });
  128503. Object.defineProperty(ClickInfo.prototype, "doubleClick", {
  128504. get: function () {
  128505. return this._doubleClick;
  128506. },
  128507. set: function (b) {
  128508. this._doubleClick = b;
  128509. },
  128510. enumerable: true,
  128511. configurable: true
  128512. });
  128513. Object.defineProperty(ClickInfo.prototype, "hasSwiped", {
  128514. get: function () {
  128515. return this._hasSwiped;
  128516. },
  128517. set: function (b) {
  128518. this._hasSwiped = b;
  128519. },
  128520. enumerable: true,
  128521. configurable: true
  128522. });
  128523. Object.defineProperty(ClickInfo.prototype, "ignore", {
  128524. get: function () {
  128525. return this._ignore;
  128526. },
  128527. set: function (b) {
  128528. this._ignore = b;
  128529. },
  128530. enumerable: true,
  128531. configurable: true
  128532. });
  128533. return ClickInfo;
  128534. }());
  128535. /**
  128536. * Represents a scene to be rendered by the engine.
  128537. * @see http://doc.babylonjs.com/features/scene
  128538. */
  128539. var Scene = /** @class */ (function (_super) {
  128540. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Scene, _super);
  128541. /**
  128542. * Creates a new Scene
  128543. * @param engine defines the engine to use to render this scene
  128544. * @param options defines the scene options
  128545. */
  128546. function Scene(engine, options) {
  128547. var _this = _super.call(this) || this;
  128548. // Members
  128549. /** @hidden */
  128550. _this._isScene = true;
  128551. /**
  128552. * Gets or sets a boolean that indicates if the scene must clear the render buffer before rendering a frame
  128553. */
  128554. _this.autoClear = true;
  128555. /**
  128556. * Gets or sets a boolean that indicates if the scene must clear the depth and stencil buffers before rendering a frame
  128557. */
  128558. _this.autoClearDepthAndStencil = true;
  128559. /**
  128560. * Defines the color used to clear the render buffer (Default is (0.2, 0.2, 0.3, 1.0))
  128561. */
  128562. _this.clearColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color4"](0.2, 0.2, 0.3, 1.0);
  128563. /**
  128564. * Defines the color used to simulate the ambient color (Default is (0, 0, 0))
  128565. */
  128566. _this.ambientColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0, 0, 0);
  128567. _this._forceWireframe = false;
  128568. _this._forcePointsCloud = false;
  128569. /**
  128570. * Gets or sets a boolean indicating if animations are enabled
  128571. */
  128572. _this.animationsEnabled = true;
  128573. _this._animationPropertiesOverride = null;
  128574. /**
  128575. * Gets or sets a boolean indicating if a constant deltatime has to be used
  128576. * This is mostly useful for testing purposes when you do not want the animations to scale with the framerate
  128577. */
  128578. _this.useConstantAnimationDeltaTime = false;
  128579. /**
  128580. * Gets or sets a boolean indicating if the scene must keep the meshUnderPointer property updated
  128581. * Please note that it requires to run a ray cast through the scene on every frame
  128582. */
  128583. _this.constantlyUpdateMeshUnderPointer = false;
  128584. /**
  128585. * Defines the HTML cursor to use when hovering over interactive elements
  128586. */
  128587. _this.hoverCursor = "pointer";
  128588. /**
  128589. * Defines the HTML default cursor to use (empty by default)
  128590. */
  128591. _this.defaultCursor = "";
  128592. /**
  128593. * This is used to call preventDefault() on pointer down
  128594. * in order to block unwanted artifacts like system double clicks
  128595. */
  128596. _this.preventDefaultOnPointerDown = true;
  128597. /**
  128598. * This is used to call preventDefault() on pointer up
  128599. * in order to block unwanted artifacts like system double clicks
  128600. */
  128601. _this.preventDefaultOnPointerUp = true;
  128602. // Metadata
  128603. /**
  128604. * Gets or sets user defined metadata
  128605. */
  128606. _this.metadata = null;
  128607. /**
  128608. * For internal use only. Please do not use.
  128609. */
  128610. _this.reservedDataStore = null;
  128611. /**
  128612. * Use this array to add regular expressions used to disable offline support for specific urls
  128613. */
  128614. _this.disableOfflineSupportExceptionRules = new Array();
  128615. /**
  128616. * An event triggered when the scene is disposed.
  128617. */
  128618. _this.onDisposeObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128619. _this._onDisposeObserver = null;
  128620. /**
  128621. * An event triggered before rendering the scene (right after animations and physics)
  128622. */
  128623. _this.onBeforeRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128624. _this._onBeforeRenderObserver = null;
  128625. /**
  128626. * An event triggered after rendering the scene
  128627. */
  128628. _this.onAfterRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128629. _this._onAfterRenderObserver = null;
  128630. /**
  128631. * An event triggered before animating the scene
  128632. */
  128633. _this.onBeforeAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128634. /**
  128635. * An event triggered after animations processing
  128636. */
  128637. _this.onAfterAnimationsObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128638. /**
  128639. * An event triggered before draw calls are ready to be sent
  128640. */
  128641. _this.onBeforeDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128642. /**
  128643. * An event triggered after draw calls have been sent
  128644. */
  128645. _this.onAfterDrawPhaseObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128646. /**
  128647. * An event triggered when the scene is ready
  128648. */
  128649. _this.onReadyObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128650. /**
  128651. * An event triggered before rendering a camera
  128652. */
  128653. _this.onBeforeCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128654. _this._onBeforeCameraRenderObserver = null;
  128655. /**
  128656. * An event triggered after rendering a camera
  128657. */
  128658. _this.onAfterCameraRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128659. _this._onAfterCameraRenderObserver = null;
  128660. /**
  128661. * An event triggered when active meshes evaluation is about to start
  128662. */
  128663. _this.onBeforeActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128664. /**
  128665. * An event triggered when active meshes evaluation is done
  128666. */
  128667. _this.onAfterActiveMeshesEvaluationObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128668. /**
  128669. * An event triggered when particles rendering is about to start
  128670. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  128671. */
  128672. _this.onBeforeParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128673. /**
  128674. * An event triggered when particles rendering is done
  128675. * Note: This event can be trigger more than once per frame (because particles can be rendered by render target textures as well)
  128676. */
  128677. _this.onAfterParticlesRenderingObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128678. /**
  128679. * An event triggered when SceneLoader.Append or SceneLoader.Load or SceneLoader.ImportMesh were successfully executed
  128680. */
  128681. _this.onDataLoadedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128682. /**
  128683. * An event triggered when a camera is created
  128684. */
  128685. _this.onNewCameraAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128686. /**
  128687. * An event triggered when a camera is removed
  128688. */
  128689. _this.onCameraRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128690. /**
  128691. * An event triggered when a light is created
  128692. */
  128693. _this.onNewLightAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128694. /**
  128695. * An event triggered when a light is removed
  128696. */
  128697. _this.onLightRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128698. /**
  128699. * An event triggered when a geometry is created
  128700. */
  128701. _this.onNewGeometryAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128702. /**
  128703. * An event triggered when a geometry is removed
  128704. */
  128705. _this.onGeometryRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128706. /**
  128707. * An event triggered when a transform node is created
  128708. */
  128709. _this.onNewTransformNodeAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128710. /**
  128711. * An event triggered when a transform node is removed
  128712. */
  128713. _this.onTransformNodeRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128714. /**
  128715. * An event triggered when a mesh is created
  128716. */
  128717. _this.onNewMeshAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128718. /**
  128719. * An event triggered when a mesh is removed
  128720. */
  128721. _this.onMeshRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128722. /**
  128723. * An event triggered when a material is created
  128724. */
  128725. _this.onNewMaterialAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128726. /**
  128727. * An event triggered when a material is removed
  128728. */
  128729. _this.onMaterialRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128730. /**
  128731. * An event triggered when a texture is created
  128732. */
  128733. _this.onNewTextureAddedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128734. /**
  128735. * An event triggered when a texture is removed
  128736. */
  128737. _this.onTextureRemovedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128738. /**
  128739. * An event triggered when render targets are about to be rendered
  128740. * Can happen multiple times per frame.
  128741. */
  128742. _this.onBeforeRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128743. /**
  128744. * An event triggered when render targets were rendered.
  128745. * Can happen multiple times per frame.
  128746. */
  128747. _this.onAfterRenderTargetsRenderObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128748. /**
  128749. * An event triggered before calculating deterministic simulation step
  128750. */
  128751. _this.onBeforeStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128752. /**
  128753. * An event triggered after calculating deterministic simulation step
  128754. */
  128755. _this.onAfterStepObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128756. /**
  128757. * An event triggered when the activeCamera property is updated
  128758. */
  128759. _this.onActiveCameraChanged = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128760. /**
  128761. * This Observable will be triggered before rendering each renderingGroup of each rendered camera.
  128762. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128763. * 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)
  128764. */
  128765. _this.onBeforeRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128766. /**
  128767. * This Observable will be triggered after rendering each renderingGroup of each rendered camera.
  128768. * The RenderinGroupInfo class contains all the information about the context in which the observable is called
  128769. * 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)
  128770. */
  128771. _this.onAfterRenderingGroupObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128772. /**
  128773. * This Observable will when a mesh has been imported into the scene.
  128774. */
  128775. _this.onMeshImportedObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128776. // Animations
  128777. /** @hidden */
  128778. _this._registeredForLateAnimationBindings = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128779. /**
  128780. * 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).
  128781. * You have the possibility to skip the process and the call to onPointerObservable by setting PointerInfoPre.skipOnPointerObservable to true
  128782. */
  128783. _this.onPrePointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128784. /**
  128785. * Observable event triggered each time an input event is received from the rendering canvas
  128786. */
  128787. _this.onPointerObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128788. _this._meshPickProceed = false;
  128789. _this._currentPickResult = null;
  128790. _this._previousPickResult = null;
  128791. _this._totalPointersPressed = 0;
  128792. _this._doubleClickOccured = false;
  128793. /** Define this parameter if you are using multiple cameras and you want to specify which one should be used for pointer position */
  128794. _this.cameraToUseForPointers = null;
  128795. _this._pointerX = 0;
  128796. _this._pointerY = 0;
  128797. _this._startingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128798. _this._previousStartingPointerPosition = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](0, 0);
  128799. _this._startingPointerTime = 0;
  128800. _this._previousStartingPointerTime = 0;
  128801. _this._pointerCaptures = {};
  128802. // Deterministic lockstep
  128803. _this._timeAccumulator = 0;
  128804. _this._currentStepId = 0;
  128805. _this._currentInternalStep = 0;
  128806. // Keyboard
  128807. /**
  128808. * This observable event is triggered when any keyboard event si raised and registered during Scene.attachControl()
  128809. * You have the possibility to skip the process and the call to onKeyboardObservable by setting KeyboardInfoPre.skipOnPointerObservable to true
  128810. */
  128811. _this.onPreKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128812. /**
  128813. * Observable event triggered each time an keyboard event is received from the hosting window
  128814. */
  128815. _this.onKeyboardObservable = new _Misc_observable__WEBPACK_IMPORTED_MODULE_3__["Observable"]();
  128816. // Coordinates system
  128817. _this._useRightHandedSystem = false;
  128818. // Fog
  128819. _this._fogEnabled = true;
  128820. _this._fogMode = Scene.FOGMODE_NONE;
  128821. /**
  128822. * Gets or sets the fog color to use
  128823. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128824. * (Default is Color3(0.2, 0.2, 0.3))
  128825. */
  128826. _this.fogColor = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Color3"](0.2, 0.2, 0.3);
  128827. /**
  128828. * Gets or sets the fog density to use
  128829. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128830. * (Default is 0.1)
  128831. */
  128832. _this.fogDensity = 0.1;
  128833. /**
  128834. * Gets or sets the fog start distance to use
  128835. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128836. * (Default is 0)
  128837. */
  128838. _this.fogStart = 0;
  128839. /**
  128840. * Gets or sets the fog end distance to use
  128841. * @see http://doc.babylonjs.com/babylon101/environment#fog
  128842. * (Default is 1000)
  128843. */
  128844. _this.fogEnd = 1000.0;
  128845. // Lights
  128846. _this._shadowsEnabled = true;
  128847. _this._lightsEnabled = true;
  128848. /** All of the active cameras added to this scene. */
  128849. _this.activeCameras = new Array();
  128850. // Textures
  128851. _this._texturesEnabled = true;
  128852. // Particles
  128853. /**
  128854. * Gets or sets a boolean indicating if particles are enabled on this scene
  128855. */
  128856. _this.particlesEnabled = true;
  128857. // Sprites
  128858. /**
  128859. * Gets or sets a boolean indicating if sprites are enabled on this scene
  128860. */
  128861. _this.spritesEnabled = true;
  128862. // Skeletons
  128863. _this._skeletonsEnabled = true;
  128864. // Lens flares
  128865. /**
  128866. * Gets or sets a boolean indicating if lens flares are enabled on this scene
  128867. */
  128868. _this.lensFlaresEnabled = true;
  128869. // Collisions
  128870. /**
  128871. * Gets or sets a boolean indicating if collisions are enabled on this scene
  128872. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128873. */
  128874. _this.collisionsEnabled = true;
  128875. /**
  128876. * Defines the gravity applied to this scene (used only for collisions)
  128877. * @see http://doc.babylonjs.com/babylon101/cameras,_mesh_collisions_and_gravity
  128878. */
  128879. _this.gravity = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](0, -9.807, 0);
  128880. // Postprocesses
  128881. /**
  128882. * Gets or sets a boolean indicating if postprocesses are enabled on this scene
  128883. */
  128884. _this.postProcessesEnabled = true;
  128885. /**
  128886. * The list of postprocesses added to the scene
  128887. */
  128888. _this.postProcesses = new Array();
  128889. // Customs render targets
  128890. /**
  128891. * Gets or sets a boolean indicating if render targets are enabled on this scene
  128892. */
  128893. _this.renderTargetsEnabled = true;
  128894. /**
  128895. * Gets or sets a boolean indicating if next render targets must be dumped as image for debugging purposes
  128896. * We recommend not using it and instead rely on Spector.js: http://spector.babylonjs.com
  128897. */
  128898. _this.dumpNextRenderTargets = false;
  128899. /**
  128900. * The list of user defined render targets added to the scene
  128901. */
  128902. _this.customRenderTargets = new Array();
  128903. /**
  128904. * Gets the list of meshes imported to the scene through SceneLoader
  128905. */
  128906. _this.importedMeshesFiles = new Array();
  128907. // Probes
  128908. /**
  128909. * Gets or sets a boolean indicating if probes are enabled on this scene
  128910. */
  128911. _this.probesEnabled = true;
  128912. _this._meshesForIntersections = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128913. // Procedural textures
  128914. /**
  128915. * Gets or sets a boolean indicating if procedural textures are enabled on this scene
  128916. */
  128917. _this.proceduralTexturesEnabled = true;
  128918. // Performance counters
  128919. _this._totalVertices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128920. /** @hidden */
  128921. _this._activeIndices = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128922. /** @hidden */
  128923. _this._activeParticles = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128924. /** @hidden */
  128925. _this._activeBones = new _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["PerfCounter"]();
  128926. /** @hidden */
  128927. _this._animationTime = 0;
  128928. /**
  128929. * Gets or sets a general scale for animation speed
  128930. * @see https://www.babylonjs-playground.com/#IBU2W7#3
  128931. */
  128932. _this.animationTimeScale = 1;
  128933. _this._renderId = 0;
  128934. _this._frameId = 0;
  128935. _this._executeWhenReadyTimeoutId = -1;
  128936. _this._intermediateRendering = false;
  128937. _this._viewUpdateFlag = -1;
  128938. _this._projectionUpdateFlag = -1;
  128939. _this._alternateViewUpdateFlag = -1;
  128940. _this._alternateProjectionUpdateFlag = -1;
  128941. /** @hidden */
  128942. _this._toBeDisposed = new Array(256);
  128943. _this._activeRequests = new Array();
  128944. /** @hidden */
  128945. _this._pendingData = new Array();
  128946. _this._isDisposed = false;
  128947. /**
  128948. * Gets or sets a boolean indicating that all submeshes of active meshes must be rendered
  128949. * Use this boolean to avoid computing frustum clipping on submeshes (This could help when you are CPU bound)
  128950. */
  128951. _this.dispatchAllSubMeshesOfActiveMeshes = false;
  128952. _this._activeMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128953. _this._processedMaterials = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128954. _this._renderTargets = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](256);
  128955. /** @hidden */
  128956. _this._activeParticleSystems = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArray"](256);
  128957. _this._activeSkeletons = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128958. _this._softwareSkinnedMeshes = new _Misc_smartArray__WEBPACK_IMPORTED_MODULE_4__["SmartArrayNoDuplicate"](32);
  128959. /** @hidden */
  128960. _this._activeAnimatables = new Array();
  128961. _this._transformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  128962. _this._useAlternateCameraConfiguration = false;
  128963. _this._alternateRendering = false;
  128964. _this._wheelEventName = "";
  128965. /**
  128966. * Gets or sets a boolean indicating if lights must be sorted by priority (off by default)
  128967. * This is useful if there are more lights that the maximum simulteanous authorized
  128968. */
  128969. _this.requireLightSorting = false;
  128970. /**
  128971. * @hidden
  128972. * Backing store of defined scene components.
  128973. */
  128974. _this._components = [];
  128975. /**
  128976. * @hidden
  128977. * Backing store of defined scene components.
  128978. */
  128979. _this._serializableComponents = [];
  128980. /**
  128981. * List of components to register on the next registration step.
  128982. */
  128983. _this._transientComponents = [];
  128984. /**
  128985. * @hidden
  128986. * Defines the actions happening before camera updates.
  128987. */
  128988. _this._beforeCameraUpdateStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128989. /**
  128990. * @hidden
  128991. * Defines the actions happening before clear the canvas.
  128992. */
  128993. _this._beforeClearStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128994. /**
  128995. * @hidden
  128996. * Defines the actions when collecting render targets for the frame.
  128997. */
  128998. _this._gatherRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  128999. /**
  129000. * @hidden
  129001. * Defines the actions happening for one camera in the frame.
  129002. */
  129003. _this._gatherActiveCameraRenderTargetsStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129004. /**
  129005. * @hidden
  129006. * Defines the actions happening during the per mesh ready checks.
  129007. */
  129008. _this._isReadyForMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129009. /**
  129010. * @hidden
  129011. * Defines the actions happening before evaluate active mesh checks.
  129012. */
  129013. _this._beforeEvaluateActiveMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129014. /**
  129015. * @hidden
  129016. * Defines the actions happening during the evaluate sub mesh checks.
  129017. */
  129018. _this._evaluateSubMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129019. /**
  129020. * @hidden
  129021. * Defines the actions happening during the active mesh stage.
  129022. */
  129023. _this._activeMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129024. /**
  129025. * @hidden
  129026. * Defines the actions happening during the per camera render target step.
  129027. */
  129028. _this._cameraDrawRenderTargetStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129029. /**
  129030. * @hidden
  129031. * Defines the actions happening just before the active camera is drawing.
  129032. */
  129033. _this._beforeCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129034. /**
  129035. * @hidden
  129036. * Defines the actions happening just before a render target is drawing.
  129037. */
  129038. _this._beforeRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129039. /**
  129040. * @hidden
  129041. * Defines the actions happening just before a rendering group is drawing.
  129042. */
  129043. _this._beforeRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129044. /**
  129045. * @hidden
  129046. * Defines the actions happening just before a mesh is drawing.
  129047. */
  129048. _this._beforeRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129049. /**
  129050. * @hidden
  129051. * Defines the actions happening just after a mesh has been drawn.
  129052. */
  129053. _this._afterRenderingMeshStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129054. /**
  129055. * @hidden
  129056. * Defines the actions happening just after a rendering group has been drawn.
  129057. */
  129058. _this._afterRenderingGroupDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129059. /**
  129060. * @hidden
  129061. * Defines the actions happening just after the active camera has been drawn.
  129062. */
  129063. _this._afterCameraDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129064. /**
  129065. * @hidden
  129066. * Defines the actions happening just after a render target has been drawn.
  129067. */
  129068. _this._afterRenderTargetDrawStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129069. /**
  129070. * @hidden
  129071. * Defines the actions happening just after rendering all cameras and computing intersections.
  129072. */
  129073. _this._afterRenderStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129074. /**
  129075. * @hidden
  129076. * Defines the actions happening when a pointer move event happens.
  129077. */
  129078. _this._pointerMoveStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129079. /**
  129080. * @hidden
  129081. * Defines the actions happening when a pointer down event happens.
  129082. */
  129083. _this._pointerDownStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129084. /**
  129085. * @hidden
  129086. * Defines the actions happening when a pointer up event happens.
  129087. */
  129088. _this._pointerUpStage = _sceneComponent__WEBPACK_IMPORTED_MODULE_20__["Stage"].Create();
  129089. /**
  129090. * an optional map from Geometry Id to Geometry index in the 'geometries' array
  129091. */
  129092. _this.geometriesByUniqueId = null;
  129093. _this._defaultMeshCandidates = {
  129094. data: [],
  129095. length: 0
  129096. };
  129097. _this._defaultSubMeshCandidates = {
  129098. data: [],
  129099. length: 0
  129100. };
  129101. _this._preventFreeActiveMeshesAndRenderingGroups = false;
  129102. _this._activeMeshesFrozen = false;
  129103. /** @hidden */
  129104. _this._allowPostProcessClearColor = true;
  129105. /**
  129106. * User updatable function that will return a deterministic frame time when engine is in deterministic lock step mode
  129107. */
  129108. _this.getDeterministicFrameTime = function () {
  129109. return 1000.0 / 60.0; // frame time in ms
  129110. };
  129111. _this._blockMaterialDirtyMechanism = false;
  129112. _this._engine = engine || _Engines_engineStore__WEBPACK_IMPORTED_MODULE_24__["EngineStore"].LastCreatedEngine;
  129113. _this._engine.scenes.push(_this);
  129114. _this._uid = null;
  129115. _this._renderingManager = new _Rendering_renderingManager__WEBPACK_IMPORTED_MODULE_19__["RenderingManager"](_this);
  129116. if (_PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"]) {
  129117. _this.postProcessManager = new _PostProcesses_postProcessManager__WEBPACK_IMPORTED_MODULE_18__["PostProcessManager"](_this);
  129118. }
  129119. if (_Misc_domManagement__WEBPACK_IMPORTED_MODULE_22__["DomManagement"].IsWindowObjectExist()) {
  129120. _this.attachControl();
  129121. }
  129122. // Uniform Buffer
  129123. _this._createUbo();
  129124. // Default Image processing definition
  129125. if (_Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]) {
  129126. _this._imageProcessingConfiguration = new _Materials_imageProcessingConfiguration__WEBPACK_IMPORTED_MODULE_11__["ImageProcessingConfiguration"]();
  129127. }
  129128. _this.setDefaultCandidateProviders();
  129129. if (options && options.useGeometryUniqueIdsMap === true) {
  129130. _this.geometriesByUniqueId = {};
  129131. }
  129132. _this.useMaterialMeshMap = options && options.useGeometryUniqueIdsMap || false;
  129133. _this.useClonedMeshhMap = options && options.useClonedMeshhMap || false;
  129134. _this._engine.onNewSceneAddedObservable.notifyObservers(_this);
  129135. return _this;
  129136. }
  129137. /**
  129138. * Factory used to create the default material.
  129139. * @param name The name of the material to create
  129140. * @param scene The scene to create the material for
  129141. * @returns The default material
  129142. */
  129143. Scene.DefaultMaterialFactory = function (scene) {
  129144. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("StandardMaterial");
  129145. };
  129146. /**
  129147. * Factory used to create the a collision coordinator.
  129148. * @returns The collision coordinator
  129149. */
  129150. Scene.CollisionCoordinatorFactory = function () {
  129151. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("DefaultCollisionCoordinator");
  129152. };
  129153. Object.defineProperty(Scene.prototype, "environmentTexture", {
  129154. /**
  129155. * Texture used in all pbr material as the reflection texture.
  129156. * As in the majority of the scene they are the same (exception for multi room and so on),
  129157. * this is easier to reference from here than from all the materials.
  129158. */
  129159. get: function () {
  129160. return this._environmentTexture;
  129161. },
  129162. /**
  129163. * Texture used in all pbr material as the reflection texture.
  129164. * As in the majority of the scene they are the same (exception for multi room and so on),
  129165. * this is easier to set here than in all the materials.
  129166. */
  129167. set: function (value) {
  129168. if (this._environmentTexture === value) {
  129169. return;
  129170. }
  129171. this._environmentTexture = value;
  129172. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  129173. },
  129174. enumerable: true,
  129175. configurable: true
  129176. });
  129177. Object.defineProperty(Scene.prototype, "imageProcessingConfiguration", {
  129178. /**
  129179. * Default image processing configuration used either in the rendering
  129180. * Forward main pass or through the imageProcessingPostProcess if present.
  129181. * As in the majority of the scene they are the same (exception for multi camera),
  129182. * this is easier to reference from here than from all the materials and post process.
  129183. *
  129184. * No setter as we it is a shared configuration, you can set the values instead.
  129185. */
  129186. get: function () {
  129187. return this._imageProcessingConfiguration;
  129188. },
  129189. enumerable: true,
  129190. configurable: true
  129191. });
  129192. Object.defineProperty(Scene.prototype, "forceWireframe", {
  129193. get: function () {
  129194. return this._forceWireframe;
  129195. },
  129196. /**
  129197. * Gets or sets a boolean indicating if all rendering must be done in wireframe
  129198. */
  129199. set: function (value) {
  129200. if (this._forceWireframe === value) {
  129201. return;
  129202. }
  129203. this._forceWireframe = value;
  129204. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  129205. },
  129206. enumerable: true,
  129207. configurable: true
  129208. });
  129209. Object.defineProperty(Scene.prototype, "forcePointsCloud", {
  129210. get: function () {
  129211. return this._forcePointsCloud;
  129212. },
  129213. /**
  129214. * Gets or sets a boolean indicating if all rendering must be done in point cloud
  129215. */
  129216. set: function (value) {
  129217. if (this._forcePointsCloud === value) {
  129218. return;
  129219. }
  129220. this._forcePointsCloud = value;
  129221. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  129222. },
  129223. enumerable: true,
  129224. configurable: true
  129225. });
  129226. Object.defineProperty(Scene.prototype, "animationPropertiesOverride", {
  129227. /**
  129228. * Gets or sets the animation properties override
  129229. */
  129230. get: function () {
  129231. return this._animationPropertiesOverride;
  129232. },
  129233. set: function (value) {
  129234. this._animationPropertiesOverride = value;
  129235. },
  129236. enumerable: true,
  129237. configurable: true
  129238. });
  129239. Object.defineProperty(Scene.prototype, "onDispose", {
  129240. /** Sets a function to be executed when this scene is disposed. */
  129241. set: function (callback) {
  129242. if (this._onDisposeObserver) {
  129243. this.onDisposeObservable.remove(this._onDisposeObserver);
  129244. }
  129245. this._onDisposeObserver = this.onDisposeObservable.add(callback);
  129246. },
  129247. enumerable: true,
  129248. configurable: true
  129249. });
  129250. Object.defineProperty(Scene.prototype, "beforeRender", {
  129251. /** Sets a function to be executed before rendering this scene */
  129252. set: function (callback) {
  129253. if (this._onBeforeRenderObserver) {
  129254. this.onBeforeRenderObservable.remove(this._onBeforeRenderObserver);
  129255. }
  129256. if (callback) {
  129257. this._onBeforeRenderObserver = this.onBeforeRenderObservable.add(callback);
  129258. }
  129259. },
  129260. enumerable: true,
  129261. configurable: true
  129262. });
  129263. Object.defineProperty(Scene.prototype, "afterRender", {
  129264. /** Sets a function to be executed after rendering this scene */
  129265. set: function (callback) {
  129266. if (this._onAfterRenderObserver) {
  129267. this.onAfterRenderObservable.remove(this._onAfterRenderObserver);
  129268. }
  129269. if (callback) {
  129270. this._onAfterRenderObserver = this.onAfterRenderObservable.add(callback);
  129271. }
  129272. },
  129273. enumerable: true,
  129274. configurable: true
  129275. });
  129276. Object.defineProperty(Scene.prototype, "beforeCameraRender", {
  129277. /** Sets a function to be executed before rendering a camera*/
  129278. set: function (callback) {
  129279. if (this._onBeforeCameraRenderObserver) {
  129280. this.onBeforeCameraRenderObservable.remove(this._onBeforeCameraRenderObserver);
  129281. }
  129282. this._onBeforeCameraRenderObserver = this.onBeforeCameraRenderObservable.add(callback);
  129283. },
  129284. enumerable: true,
  129285. configurable: true
  129286. });
  129287. Object.defineProperty(Scene.prototype, "afterCameraRender", {
  129288. /** Sets a function to be executed after rendering a camera*/
  129289. set: function (callback) {
  129290. if (this._onAfterCameraRenderObserver) {
  129291. this.onAfterCameraRenderObservable.remove(this._onAfterCameraRenderObserver);
  129292. }
  129293. this._onAfterCameraRenderObserver = this.onAfterCameraRenderObservable.add(callback);
  129294. },
  129295. enumerable: true,
  129296. configurable: true
  129297. });
  129298. Object.defineProperty(Scene.prototype, "unTranslatedPointer", {
  129299. /**
  129300. * Gets the pointer coordinates without any translation (ie. straight out of the pointer event)
  129301. */
  129302. get: function () {
  129303. return new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector2"](this._unTranslatedPointerX, this._unTranslatedPointerY);
  129304. },
  129305. enumerable: true,
  129306. configurable: true
  129307. });
  129308. Object.defineProperty(Scene.prototype, "useRightHandedSystem", {
  129309. get: function () {
  129310. return this._useRightHandedSystem;
  129311. },
  129312. /**
  129313. * Gets or sets a boolean indicating if the scene must use right-handed coordinates system
  129314. */
  129315. set: function (value) {
  129316. if (this._useRightHandedSystem === value) {
  129317. return;
  129318. }
  129319. this._useRightHandedSystem = value;
  129320. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  129321. },
  129322. enumerable: true,
  129323. configurable: true
  129324. });
  129325. /**
  129326. * Sets the step Id used by deterministic lock step
  129327. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129328. * @param newStepId defines the step Id
  129329. */
  129330. Scene.prototype.setStepId = function (newStepId) {
  129331. this._currentStepId = newStepId;
  129332. };
  129333. /**
  129334. * Gets the step Id used by deterministic lock step
  129335. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129336. * @returns the step Id
  129337. */
  129338. Scene.prototype.getStepId = function () {
  129339. return this._currentStepId;
  129340. };
  129341. /**
  129342. * Gets the internal step used by deterministic lock step
  129343. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  129344. * @returns the internal step
  129345. */
  129346. Scene.prototype.getInternalStep = function () {
  129347. return this._currentInternalStep;
  129348. };
  129349. Object.defineProperty(Scene.prototype, "fogEnabled", {
  129350. get: function () {
  129351. return this._fogEnabled;
  129352. },
  129353. /**
  129354. * Gets or sets a boolean indicating if fog is enabled on this scene
  129355. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129356. * (Default is true)
  129357. */
  129358. set: function (value) {
  129359. if (this._fogEnabled === value) {
  129360. return;
  129361. }
  129362. this._fogEnabled = value;
  129363. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  129364. },
  129365. enumerable: true,
  129366. configurable: true
  129367. });
  129368. Object.defineProperty(Scene.prototype, "fogMode", {
  129369. get: function () {
  129370. return this._fogMode;
  129371. },
  129372. /**
  129373. * Gets or sets the fog mode to use
  129374. * @see http://doc.babylonjs.com/babylon101/environment#fog
  129375. * | mode | value |
  129376. * | --- | --- |
  129377. * | FOGMODE_NONE | 0 |
  129378. * | FOGMODE_EXP | 1 |
  129379. * | FOGMODE_EXP2 | 2 |
  129380. * | FOGMODE_LINEAR | 3 |
  129381. */
  129382. set: function (value) {
  129383. if (this._fogMode === value) {
  129384. return;
  129385. }
  129386. this._fogMode = value;
  129387. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_MiscDirtyFlag);
  129388. },
  129389. enumerable: true,
  129390. configurable: true
  129391. });
  129392. Object.defineProperty(Scene.prototype, "shadowsEnabled", {
  129393. get: function () {
  129394. return this._shadowsEnabled;
  129395. },
  129396. /**
  129397. * Gets or sets a boolean indicating if shadows are enabled on this scene
  129398. */
  129399. set: function (value) {
  129400. if (this._shadowsEnabled === value) {
  129401. return;
  129402. }
  129403. this._shadowsEnabled = value;
  129404. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  129405. },
  129406. enumerable: true,
  129407. configurable: true
  129408. });
  129409. Object.defineProperty(Scene.prototype, "lightsEnabled", {
  129410. get: function () {
  129411. return this._lightsEnabled;
  129412. },
  129413. /**
  129414. * Gets or sets a boolean indicating if lights are enabled on this scene
  129415. */
  129416. set: function (value) {
  129417. if (this._lightsEnabled === value) {
  129418. return;
  129419. }
  129420. this._lightsEnabled = value;
  129421. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_LightDirtyFlag);
  129422. },
  129423. enumerable: true,
  129424. configurable: true
  129425. });
  129426. Object.defineProperty(Scene.prototype, "activeCamera", {
  129427. /** Gets or sets the current active camera */
  129428. get: function () {
  129429. return this._activeCamera;
  129430. },
  129431. set: function (value) {
  129432. if (value === this._activeCamera) {
  129433. return;
  129434. }
  129435. this._activeCamera = value;
  129436. this.onActiveCameraChanged.notifyObservers(this);
  129437. },
  129438. enumerable: true,
  129439. configurable: true
  129440. });
  129441. Object.defineProperty(Scene.prototype, "defaultMaterial", {
  129442. /** The default material used on meshes when no material is affected */
  129443. get: function () {
  129444. if (!this._defaultMaterial) {
  129445. this._defaultMaterial = Scene.DefaultMaterialFactory(this);
  129446. }
  129447. return this._defaultMaterial;
  129448. },
  129449. /** The default material used on meshes when no material is affected */
  129450. set: function (value) {
  129451. this._defaultMaterial = value;
  129452. },
  129453. enumerable: true,
  129454. configurable: true
  129455. });
  129456. Object.defineProperty(Scene.prototype, "texturesEnabled", {
  129457. get: function () {
  129458. return this._texturesEnabled;
  129459. },
  129460. /**
  129461. * Gets or sets a boolean indicating if textures are enabled on this scene
  129462. */
  129463. set: function (value) {
  129464. if (this._texturesEnabled === value) {
  129465. return;
  129466. }
  129467. this._texturesEnabled = value;
  129468. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  129469. },
  129470. enumerable: true,
  129471. configurable: true
  129472. });
  129473. Object.defineProperty(Scene.prototype, "skeletonsEnabled", {
  129474. get: function () {
  129475. return this._skeletonsEnabled;
  129476. },
  129477. /**
  129478. * Gets or sets a boolean indicating if skeletons are enabled on this scene
  129479. */
  129480. set: function (value) {
  129481. if (this._skeletonsEnabled === value) {
  129482. return;
  129483. }
  129484. this._skeletonsEnabled = value;
  129485. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AttributesDirtyFlag);
  129486. },
  129487. enumerable: true,
  129488. configurable: true
  129489. });
  129490. Object.defineProperty(Scene.prototype, "collisionCoordinator", {
  129491. /** @hidden */
  129492. get: function () {
  129493. if (!this._collisionCoordinator) {
  129494. this._collisionCoordinator = Scene.CollisionCoordinatorFactory();
  129495. this._collisionCoordinator.init(this);
  129496. }
  129497. return this._collisionCoordinator;
  129498. },
  129499. enumerable: true,
  129500. configurable: true
  129501. });
  129502. Object.defineProperty(Scene.prototype, "_isAlternateRenderingEnabled", {
  129503. /** @hidden */
  129504. get: function () {
  129505. return this._alternateRendering;
  129506. },
  129507. enumerable: true,
  129508. configurable: true
  129509. });
  129510. Object.defineProperty(Scene.prototype, "frustumPlanes", {
  129511. /**
  129512. * Gets the list of frustum planes (built from the active camera)
  129513. */
  129514. get: function () {
  129515. return this._frustumPlanes;
  129516. },
  129517. enumerable: true,
  129518. configurable: true
  129519. });
  129520. /**
  129521. * Registers the transient components if needed.
  129522. */
  129523. Scene.prototype._registerTransientComponents = function () {
  129524. // Register components that have been associated lately to the scene.
  129525. if (this._transientComponents.length > 0) {
  129526. for (var _i = 0, _a = this._transientComponents; _i < _a.length; _i++) {
  129527. var component = _a[_i];
  129528. component.register();
  129529. }
  129530. this._transientComponents = [];
  129531. }
  129532. };
  129533. /**
  129534. * @hidden
  129535. * Add a component to the scene.
  129536. * Note that the ccomponent could be registered on th next frame if this is called after
  129537. * the register component stage.
  129538. * @param component Defines the component to add to the scene
  129539. */
  129540. Scene.prototype._addComponent = function (component) {
  129541. this._components.push(component);
  129542. this._transientComponents.push(component);
  129543. var serializableComponent = component;
  129544. if (serializableComponent.addFromContainer) {
  129545. this._serializableComponents.push(serializableComponent);
  129546. }
  129547. };
  129548. /**
  129549. * @hidden
  129550. * Gets a component from the scene.
  129551. * @param name defines the name of the component to retrieve
  129552. * @returns the component or null if not present
  129553. */
  129554. Scene.prototype._getComponent = function (name) {
  129555. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  129556. var component = _a[_i];
  129557. if (component.name === name) {
  129558. return component;
  129559. }
  129560. }
  129561. return null;
  129562. };
  129563. /**
  129564. * @hidden
  129565. */
  129566. Scene.prototype._getDefaultMeshCandidates = function () {
  129567. this._defaultMeshCandidates.data = this.meshes;
  129568. this._defaultMeshCandidates.length = this.meshes.length;
  129569. return this._defaultMeshCandidates;
  129570. };
  129571. /**
  129572. * @hidden
  129573. */
  129574. Scene.prototype._getDefaultSubMeshCandidates = function (mesh) {
  129575. this._defaultSubMeshCandidates.data = mesh.subMeshes;
  129576. this._defaultSubMeshCandidates.length = mesh.subMeshes.length;
  129577. return this._defaultSubMeshCandidates;
  129578. };
  129579. /**
  129580. * Sets the default candidate providers for the scene.
  129581. * This sets the getActiveMeshCandidates, getActiveSubMeshCandidates, getIntersectingSubMeshCandidates
  129582. * and getCollidingSubMeshCandidates to their default function
  129583. */
  129584. Scene.prototype.setDefaultCandidateProviders = function () {
  129585. this.getActiveMeshCandidates = this._getDefaultMeshCandidates.bind(this);
  129586. this.getActiveSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  129587. this.getIntersectingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  129588. this.getCollidingSubMeshCandidates = this._getDefaultSubMeshCandidates.bind(this);
  129589. };
  129590. Object.defineProperty(Scene.prototype, "meshUnderPointer", {
  129591. /**
  129592. * Gets the mesh that is currently under the pointer
  129593. */
  129594. get: function () {
  129595. return this._pointerOverMesh;
  129596. },
  129597. enumerable: true,
  129598. configurable: true
  129599. });
  129600. Object.defineProperty(Scene.prototype, "pointerX", {
  129601. /**
  129602. * Gets or sets the current on-screen X position of the pointer
  129603. */
  129604. get: function () {
  129605. return this._pointerX;
  129606. },
  129607. set: function (value) {
  129608. this._pointerX = value;
  129609. },
  129610. enumerable: true,
  129611. configurable: true
  129612. });
  129613. Object.defineProperty(Scene.prototype, "pointerY", {
  129614. /**
  129615. * Gets or sets the current on-screen Y position of the pointer
  129616. */
  129617. get: function () {
  129618. return this._pointerY;
  129619. },
  129620. set: function (value) {
  129621. this._pointerY = value;
  129622. },
  129623. enumerable: true,
  129624. configurable: true
  129625. });
  129626. /**
  129627. * Gets the cached material (ie. the latest rendered one)
  129628. * @returns the cached material
  129629. */
  129630. Scene.prototype.getCachedMaterial = function () {
  129631. return this._cachedMaterial;
  129632. };
  129633. /**
  129634. * Gets the cached effect (ie. the latest rendered one)
  129635. * @returns the cached effect
  129636. */
  129637. Scene.prototype.getCachedEffect = function () {
  129638. return this._cachedEffect;
  129639. };
  129640. /**
  129641. * Gets the cached visibility state (ie. the latest rendered one)
  129642. * @returns the cached visibility state
  129643. */
  129644. Scene.prototype.getCachedVisibility = function () {
  129645. return this._cachedVisibility;
  129646. };
  129647. /**
  129648. * Gets a boolean indicating if the current material / effect / visibility must be bind again
  129649. * @param material defines the current material
  129650. * @param effect defines the current effect
  129651. * @param visibility defines the current visibility state
  129652. * @returns true if one parameter is not cached
  129653. */
  129654. Scene.prototype.isCachedMaterialInvalid = function (material, effect, visibility) {
  129655. if (visibility === void 0) { visibility = 1; }
  129656. return this._cachedEffect !== effect || this._cachedMaterial !== material || this._cachedVisibility !== visibility;
  129657. };
  129658. /**
  129659. * Gets the engine associated with the scene
  129660. * @returns an Engine
  129661. */
  129662. Scene.prototype.getEngine = function () {
  129663. return this._engine;
  129664. };
  129665. /**
  129666. * Gets the total number of vertices rendered per frame
  129667. * @returns the total number of vertices rendered per frame
  129668. */
  129669. Scene.prototype.getTotalVertices = function () {
  129670. return this._totalVertices.current;
  129671. };
  129672. Object.defineProperty(Scene.prototype, "totalVerticesPerfCounter", {
  129673. /**
  129674. * Gets the performance counter for total vertices
  129675. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129676. */
  129677. get: function () {
  129678. return this._totalVertices;
  129679. },
  129680. enumerable: true,
  129681. configurable: true
  129682. });
  129683. /**
  129684. * Gets the total number of active indices rendered per frame (You can deduce the number of rendered triangles by dividing this number by 3)
  129685. * @returns the total number of active indices rendered per frame
  129686. */
  129687. Scene.prototype.getActiveIndices = function () {
  129688. return this._activeIndices.current;
  129689. };
  129690. Object.defineProperty(Scene.prototype, "totalActiveIndicesPerfCounter", {
  129691. /**
  129692. * Gets the performance counter for active indices
  129693. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129694. */
  129695. get: function () {
  129696. return this._activeIndices;
  129697. },
  129698. enumerable: true,
  129699. configurable: true
  129700. });
  129701. /**
  129702. * Gets the total number of active particles rendered per frame
  129703. * @returns the total number of active particles rendered per frame
  129704. */
  129705. Scene.prototype.getActiveParticles = function () {
  129706. return this._activeParticles.current;
  129707. };
  129708. Object.defineProperty(Scene.prototype, "activeParticlesPerfCounter", {
  129709. /**
  129710. * Gets the performance counter for active particles
  129711. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129712. */
  129713. get: function () {
  129714. return this._activeParticles;
  129715. },
  129716. enumerable: true,
  129717. configurable: true
  129718. });
  129719. /**
  129720. * Gets the total number of active bones rendered per frame
  129721. * @returns the total number of active bones rendered per frame
  129722. */
  129723. Scene.prototype.getActiveBones = function () {
  129724. return this._activeBones.current;
  129725. };
  129726. Object.defineProperty(Scene.prototype, "activeBonesPerfCounter", {
  129727. /**
  129728. * Gets the performance counter for active bones
  129729. * @see http://doc.babylonjs.com/how_to/optimizing_your_scene#instrumentation
  129730. */
  129731. get: function () {
  129732. return this._activeBones;
  129733. },
  129734. enumerable: true,
  129735. configurable: true
  129736. });
  129737. /**
  129738. * Gets the array of active meshes
  129739. * @returns an array of AbstractMesh
  129740. */
  129741. Scene.prototype.getActiveMeshes = function () {
  129742. return this._activeMeshes;
  129743. };
  129744. /**
  129745. * Gets the animation ratio (which is 1.0 is the scene renders at 60fps and 2 if the scene renders at 30fps, etc.)
  129746. * @returns a number
  129747. */
  129748. Scene.prototype.getAnimationRatio = function () {
  129749. return this._animationRatio !== undefined ? this._animationRatio : 1;
  129750. };
  129751. /**
  129752. * Gets an unique Id for the current render phase
  129753. * @returns a number
  129754. */
  129755. Scene.prototype.getRenderId = function () {
  129756. return this._renderId;
  129757. };
  129758. /**
  129759. * Gets an unique Id for the current frame
  129760. * @returns a number
  129761. */
  129762. Scene.prototype.getFrameId = function () {
  129763. return this._frameId;
  129764. };
  129765. /** Call this function if you want to manually increment the render Id*/
  129766. Scene.prototype.incrementRenderId = function () {
  129767. this._renderId++;
  129768. };
  129769. Scene.prototype._updatePointerPosition = function (evt) {
  129770. var canvasRect = this._engine.getRenderingCanvasClientRect();
  129771. if (!canvasRect) {
  129772. return;
  129773. }
  129774. this._pointerX = evt.clientX - canvasRect.left;
  129775. this._pointerY = evt.clientY - canvasRect.top;
  129776. this._unTranslatedPointerX = this._pointerX;
  129777. this._unTranslatedPointerY = this._pointerY;
  129778. };
  129779. Scene.prototype._createUbo = function () {
  129780. this._sceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129781. this._sceneUbo.addUniform("viewProjection", 16);
  129782. this._sceneUbo.addUniform("view", 16);
  129783. };
  129784. Scene.prototype._createAlternateUbo = function () {
  129785. this._alternateSceneUbo = new _Materials_uniformBuffer__WEBPACK_IMPORTED_MODULE_12__["UniformBuffer"](this._engine, undefined, true);
  129786. this._alternateSceneUbo.addUniform("viewProjection", 16);
  129787. this._alternateSceneUbo.addUniform("view", 16);
  129788. };
  129789. // Pointers handling
  129790. Scene.prototype._setRayOnPointerInfo = function (pointerInfo) {
  129791. if (pointerInfo.pickInfo && !pointerInfo.pickInfo._pickingUnavailable) {
  129792. if (!pointerInfo.pickInfo.ray) {
  129793. pointerInfo.pickInfo.ray = this.createPickingRay(pointerInfo.event.offsetX, pointerInfo.event.offsetY, _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Identity(), this.activeCamera);
  129794. }
  129795. }
  129796. };
  129797. /**
  129798. * Use this method to simulate a pointer move on a mesh
  129799. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129800. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129801. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129802. * @returns the current scene
  129803. */
  129804. Scene.prototype.simulatePointerMove = function (pickResult, pointerEventInit) {
  129805. var evt = new PointerEvent("pointermove", pointerEventInit);
  129806. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  129807. return this;
  129808. }
  129809. return this._processPointerMove(pickResult, evt);
  129810. };
  129811. Scene.prototype._processPointerMove = function (pickResult, evt) {
  129812. var canvas = this._engine.getRenderingCanvas();
  129813. if (!canvas) {
  129814. return this;
  129815. }
  129816. // Restore pointer
  129817. canvas.style.cursor = this.defaultCursor;
  129818. var isMeshPicked = (pickResult && pickResult.hit && pickResult.pickedMesh) ? true : false;
  129819. if (isMeshPicked) {
  129820. this.setPointerOverMesh(pickResult.pickedMesh);
  129821. if (this._pointerOverMesh && this._pointerOverMesh.actionManager && this._pointerOverMesh.actionManager.hasPointerTriggers) {
  129822. if (this._pointerOverMesh.actionManager.hoverCursor) {
  129823. canvas.style.cursor = this._pointerOverMesh.actionManager.hoverCursor;
  129824. }
  129825. else {
  129826. canvas.style.cursor = this.hoverCursor;
  129827. }
  129828. }
  129829. }
  129830. else {
  129831. this.setPointerOverMesh(null);
  129832. }
  129833. for (var _i = 0, _a = this._pointerMoveStage; _i < _a.length; _i++) {
  129834. var step = _a[_i];
  129835. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, isMeshPicked, canvas);
  129836. }
  129837. if (pickResult) {
  129838. var type = evt.type === this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE;
  129839. if (this.onPointerMove) {
  129840. this.onPointerMove(evt, pickResult, type);
  129841. }
  129842. if (this.onPointerObservable.hasObservers()) {
  129843. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129844. this._setRayOnPointerInfo(pi);
  129845. this.onPointerObservable.notifyObservers(pi, type);
  129846. }
  129847. }
  129848. return this;
  129849. };
  129850. Scene.prototype._checkPrePointerObservable = function (pickResult, evt, type) {
  129851. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfoPre"](type, evt, this._unTranslatedPointerX, this._unTranslatedPointerY);
  129852. if (pickResult) {
  129853. pi.ray = pickResult.ray;
  129854. }
  129855. this.onPrePointerObservable.notifyObservers(pi, type);
  129856. if (pi.skipOnPointerObservable) {
  129857. return true;
  129858. }
  129859. else {
  129860. return false;
  129861. }
  129862. };
  129863. /**
  129864. * Use this method to simulate a pointer down on a mesh
  129865. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129866. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129867. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129868. * @returns the current scene
  129869. */
  129870. Scene.prototype.simulatePointerDown = function (pickResult, pointerEventInit) {
  129871. var evt = new PointerEvent("pointerdown", pointerEventInit);
  129872. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  129873. return this;
  129874. }
  129875. return this._processPointerDown(pickResult, evt);
  129876. };
  129877. Scene.prototype._processPointerDown = function (pickResult, evt) {
  129878. var _this = this;
  129879. if (pickResult && pickResult.hit && pickResult.pickedMesh) {
  129880. this._pickedDownMesh = pickResult.pickedMesh;
  129881. var actionManager = pickResult.pickedMesh.actionManager;
  129882. if (actionManager) {
  129883. if (actionManager.hasPickTriggers) {
  129884. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129885. switch (evt.button) {
  129886. case 0:
  129887. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLeftPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129888. break;
  129889. case 1:
  129890. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnCenterPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129891. break;
  129892. case 2:
  129893. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnRightPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129894. break;
  129895. }
  129896. }
  129897. if (actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger)) {
  129898. window.setTimeout(function () {
  129899. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, function (mesh) { return (mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.actionManager && mesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger) && mesh == _this._pickedDownMesh); }, false, _this.cameraToUseForPointers);
  129900. if (pickResult && pickResult.hit && pickResult.pickedMesh && actionManager) {
  129901. if (_this._totalPointersPressed !== 0 &&
  129902. ((Date.now() - _this._startingPointerTime) > Scene.LongPressDelay) &&
  129903. !_this._isPointerSwiping()) {
  129904. _this._startingPointerTime = 0;
  129905. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnLongPressTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129906. }
  129907. }
  129908. }, Scene.LongPressDelay);
  129909. }
  129910. }
  129911. }
  129912. else {
  129913. for (var _i = 0, _a = this._pointerDownStage; _i < _a.length; _i++) {
  129914. var step = _a[_i];
  129915. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129916. }
  129917. }
  129918. if (pickResult) {
  129919. var type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN;
  129920. if (this.onPointerDown) {
  129921. this.onPointerDown(evt, pickResult, type);
  129922. }
  129923. if (this.onPointerObservable.hasObservers()) {
  129924. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  129925. this._setRayOnPointerInfo(pi);
  129926. this.onPointerObservable.notifyObservers(pi, type);
  129927. }
  129928. }
  129929. return this;
  129930. };
  129931. /**
  129932. * Use this method to simulate a pointer up on a mesh
  129933. * The pickResult parameter can be obtained from a scene.pick or scene.pickWithRay
  129934. * @param pickResult pickingInfo of the object wished to simulate pointer event on
  129935. * @param pointerEventInit pointer event state to be used when simulating the pointer event (eg. pointer id for multitouch)
  129936. * @param doubleTap indicates that the pointer up event should be considered as part of a double click (false by default)
  129937. * @returns the current scene
  129938. */
  129939. Scene.prototype.simulatePointerUp = function (pickResult, pointerEventInit, doubleTap) {
  129940. var evt = new PointerEvent("pointerup", pointerEventInit);
  129941. var clickInfo = new ClickInfo();
  129942. if (doubleTap) {
  129943. clickInfo.doubleClick = true;
  129944. }
  129945. else {
  129946. clickInfo.singleClick = true;
  129947. }
  129948. if (this._checkPrePointerObservable(pickResult, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  129949. return this;
  129950. }
  129951. return this._processPointerUp(pickResult, evt, clickInfo);
  129952. };
  129953. Scene.prototype._processPointerUp = function (pickResult, evt, clickInfo) {
  129954. if (pickResult && pickResult && pickResult.pickedMesh) {
  129955. this._pickedUpMesh = pickResult.pickedMesh;
  129956. if (this._pickedDownMesh === this._pickedUpMesh) {
  129957. if (this.onPointerPick) {
  129958. this.onPointerPick(evt, pickResult);
  129959. }
  129960. if (clickInfo.singleClick && !clickInfo.ignore && this.onPointerObservable.hasObservers()) {
  129961. var type_1 = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK;
  129962. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type_1, evt, pickResult);
  129963. this._setRayOnPointerInfo(pi);
  129964. this.onPointerObservable.notifyObservers(pi, type_1);
  129965. }
  129966. }
  129967. var actionManager = pickResult.pickedMesh._getActionManagerForTrigger();
  129968. if (actionManager && !clickInfo.ignore) {
  129969. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129970. if (!clickInfo.hasSwiped && clickInfo.singleClick) {
  129971. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129972. }
  129973. var doubleClickActionManager = pickResult.pickedMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  129974. if (clickInfo.doubleClick && doubleClickActionManager) {
  129975. doubleClickActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(pickResult.pickedMesh, evt));
  129976. }
  129977. }
  129978. }
  129979. else {
  129980. if (!clickInfo.ignore) {
  129981. for (var _i = 0, _a = this._pointerUpStage; _i < _a.length; _i++) {
  129982. var step = _a[_i];
  129983. pickResult = step.action(this._unTranslatedPointerX, this._unTranslatedPointerY, pickResult, evt);
  129984. }
  129985. }
  129986. }
  129987. if (this._pickedDownMesh && this._pickedDownMesh !== this._pickedUpMesh) {
  129988. var pickedDownActionManager = this._pickedDownMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger);
  129989. if (pickedDownActionManager) {
  129990. pickedDownActionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPickOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pickedDownMesh, evt));
  129991. }
  129992. }
  129993. var type = 0;
  129994. if (this.onPointerObservable.hasObservers()) {
  129995. if (!clickInfo.ignore && !clickInfo.hasSwiped) {
  129996. if (clickInfo.singleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  129997. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP;
  129998. }
  129999. else if (clickInfo.doubleClick && this.onPointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  130000. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP;
  130001. }
  130002. if (type) {
  130003. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130004. this._setRayOnPointerInfo(pi);
  130005. this.onPointerObservable.notifyObservers(pi, type);
  130006. }
  130007. }
  130008. if (!clickInfo.ignore) {
  130009. type = _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP;
  130010. var pi = new _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerInfo"](type, evt, pickResult);
  130011. this._setRayOnPointerInfo(pi);
  130012. this.onPointerObservable.notifyObservers(pi, type);
  130013. }
  130014. }
  130015. if (this.onPointerUp && !clickInfo.ignore) {
  130016. this.onPointerUp(evt, pickResult, type);
  130017. }
  130018. return this;
  130019. };
  130020. /**
  130021. * Gets a boolean indicating if the current pointer event is captured (meaning that the scene has already handled the pointer down)
  130022. * @param pointerId defines the pointer id to use in a multi-touch scenario (0 by default)
  130023. * @returns true if the pointer was captured
  130024. */
  130025. Scene.prototype.isPointerCaptured = function (pointerId) {
  130026. if (pointerId === void 0) { pointerId = 0; }
  130027. return this._pointerCaptures[pointerId];
  130028. };
  130029. /** @hidden */
  130030. Scene.prototype._isPointerSwiping = function () {
  130031. return Math.abs(this._startingPointerPosition.x - this._pointerX) > Scene.DragMovementThreshold ||
  130032. Math.abs(this._startingPointerPosition.y - this._pointerY) > Scene.DragMovementThreshold;
  130033. };
  130034. /**
  130035. * Attach events to the canvas (To handle actionManagers triggers and raise onPointerMove, onPointerDown and onPointerUp
  130036. * @param attachUp defines if you want to attach events to pointerup
  130037. * @param attachDown defines if you want to attach events to pointerdown
  130038. * @param attachMove defines if you want to attach events to pointermove
  130039. */
  130040. Scene.prototype.attachControl = function (attachUp, attachDown, attachMove) {
  130041. var _this = this;
  130042. if (attachUp === void 0) { attachUp = true; }
  130043. if (attachDown === void 0) { attachDown = true; }
  130044. if (attachMove === void 0) { attachMove = true; }
  130045. this._initActionManager = function (act, clickInfo) {
  130046. if (!_this._meshPickProceed) {
  130047. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  130048. _this._currentPickResult = pickResult;
  130049. if (pickResult) {
  130050. act = (pickResult.hit && pickResult.pickedMesh) ? pickResult.pickedMesh.actionManager : null;
  130051. }
  130052. _this._meshPickProceed = true;
  130053. }
  130054. return act;
  130055. };
  130056. this._delayedSimpleClick = function (btn, clickInfo, cb) {
  130057. // double click delay is over and that no double click has been raised since, or the 2 consecutive keys pressed are different
  130058. if ((Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay && !_this._doubleClickOccured) ||
  130059. btn !== _this._previousButtonPressed) {
  130060. _this._doubleClickOccured = false;
  130061. clickInfo.singleClick = true;
  130062. clickInfo.ignore = false;
  130063. cb(clickInfo, _this._currentPickResult);
  130064. }
  130065. };
  130066. this._initClickEvent = function (obs1, obs2, evt, cb) {
  130067. var clickInfo = new ClickInfo();
  130068. _this._currentPickResult = null;
  130069. var act = null;
  130070. var checkPicking = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERPICK)
  130071. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)
  130072. || obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) || obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  130073. if (!checkPicking && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"]) {
  130074. act = _this._initActionManager(act, clickInfo);
  130075. if (act) {
  130076. checkPicking = act.hasPickTriggers;
  130077. }
  130078. }
  130079. var needToIgnoreNext = false;
  130080. if (checkPicking) {
  130081. var btn = evt.button;
  130082. clickInfo.hasSwiped = _this._isPointerSwiping();
  130083. if (!clickInfo.hasSwiped) {
  130084. var checkSingleClickImmediately = !Scene.ExclusiveDoubleClickMode;
  130085. if (!checkSingleClickImmediately) {
  130086. checkSingleClickImmediately = !obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) &&
  130087. !obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  130088. if (checkSingleClickImmediately && !_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  130089. act = _this._initActionManager(act, clickInfo);
  130090. if (act) {
  130091. checkSingleClickImmediately = !act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  130092. }
  130093. }
  130094. }
  130095. if (checkSingleClickImmediately) {
  130096. // single click detected if double click delay is over or two different successive keys pressed without exclusive double click or no double click required
  130097. if (Date.now() - _this._previousStartingPointerTime > Scene.DoubleClickDelay ||
  130098. btn !== _this._previousButtonPressed) {
  130099. clickInfo.singleClick = true;
  130100. cb(clickInfo, _this._currentPickResult);
  130101. needToIgnoreNext = true;
  130102. }
  130103. }
  130104. // at least one double click is required to be check and exclusive double click is enabled
  130105. else {
  130106. // wait that no double click has been raised during the double click delay
  130107. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  130108. _this._delayedSimpleClickTimeout = window.setTimeout(_this._delayedSimpleClick.bind(_this, btn, clickInfo, cb), Scene.DoubleClickDelay);
  130109. }
  130110. var checkDoubleClick = obs1.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP) ||
  130111. obs2.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP);
  130112. if (!checkDoubleClick && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger)) {
  130113. act = _this._initActionManager(act, clickInfo);
  130114. if (act) {
  130115. checkDoubleClick = act.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnDoublePickTrigger);
  130116. }
  130117. }
  130118. if (checkDoubleClick) {
  130119. // two successive keys pressed are equal, double click delay is not over and double click has not just occurred
  130120. if (btn === _this._previousButtonPressed &&
  130121. Date.now() - _this._previousStartingPointerTime < Scene.DoubleClickDelay &&
  130122. !_this._doubleClickOccured) {
  130123. // pointer has not moved for 2 clicks, it's a double click
  130124. if (!clickInfo.hasSwiped &&
  130125. !_this._isPointerSwiping()) {
  130126. _this._previousStartingPointerTime = 0;
  130127. _this._doubleClickOccured = true;
  130128. clickInfo.doubleClick = true;
  130129. clickInfo.ignore = false;
  130130. if (Scene.ExclusiveDoubleClickMode && _this._previousDelayedSimpleClickTimeout) {
  130131. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  130132. }
  130133. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  130134. cb(clickInfo, _this._currentPickResult);
  130135. }
  130136. // if the two successive clicks are too far, it's just two simple clicks
  130137. else {
  130138. _this._doubleClickOccured = false;
  130139. _this._previousStartingPointerTime = _this._startingPointerTime;
  130140. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  130141. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  130142. _this._previousButtonPressed = btn;
  130143. if (Scene.ExclusiveDoubleClickMode) {
  130144. if (_this._previousDelayedSimpleClickTimeout) {
  130145. clearTimeout(_this._previousDelayedSimpleClickTimeout);
  130146. }
  130147. _this._previousDelayedSimpleClickTimeout = _this._delayedSimpleClickTimeout;
  130148. cb(clickInfo, _this._previousPickResult);
  130149. }
  130150. else {
  130151. cb(clickInfo, _this._currentPickResult);
  130152. }
  130153. }
  130154. needToIgnoreNext = true;
  130155. }
  130156. // just the first click of the double has been raised
  130157. else {
  130158. _this._doubleClickOccured = false;
  130159. _this._previousStartingPointerTime = _this._startingPointerTime;
  130160. _this._previousStartingPointerPosition.x = _this._startingPointerPosition.x;
  130161. _this._previousStartingPointerPosition.y = _this._startingPointerPosition.y;
  130162. _this._previousButtonPressed = btn;
  130163. }
  130164. }
  130165. }
  130166. }
  130167. if (!needToIgnoreNext) {
  130168. cb(clickInfo, _this._currentPickResult);
  130169. }
  130170. };
  130171. this._onPointerMove = function (evt) {
  130172. _this._updatePointerPosition(evt);
  130173. // PreObservable support
  130174. if (_this._checkPrePointerObservable(null, evt, evt.type === _this._wheelEventName ? _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERWHEEL : _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERMOVE)) {
  130175. return;
  130176. }
  130177. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  130178. return;
  130179. }
  130180. if (!_this.pointerMovePredicate) {
  130181. _this.pointerMovePredicate = function (mesh) { return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled() && (mesh.enablePointerMoveEvents || _this.constantlyUpdateMeshUnderPointer || (mesh.actionManager !== null && mesh.actionManager !== undefined)); };
  130182. }
  130183. // Meshes
  130184. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerMovePredicate, false, _this.cameraToUseForPointers);
  130185. _this._processPointerMove(pickResult, evt);
  130186. };
  130187. this._onPointerDown = function (evt) {
  130188. _this._totalPointersPressed++;
  130189. _this._pickedDownMesh = null;
  130190. _this._meshPickProceed = false;
  130191. _this._updatePointerPosition(evt);
  130192. if (_this.preventDefaultOnPointerDown && canvas) {
  130193. evt.preventDefault();
  130194. canvas.focus();
  130195. }
  130196. _this._startingPointerPosition.x = _this._pointerX;
  130197. _this._startingPointerPosition.y = _this._pointerY;
  130198. _this._startingPointerTime = Date.now();
  130199. // PreObservable support
  130200. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOWN)) {
  130201. return;
  130202. }
  130203. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  130204. return;
  130205. }
  130206. _this._pointerCaptures[evt.pointerId] = true;
  130207. if (!_this.pointerDownPredicate) {
  130208. _this.pointerDownPredicate = function (mesh) {
  130209. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  130210. };
  130211. }
  130212. // Meshes
  130213. _this._pickedDownMesh = null;
  130214. var pickResult = _this.pick(_this._unTranslatedPointerX, _this._unTranslatedPointerY, _this.pointerDownPredicate, false, _this.cameraToUseForPointers);
  130215. _this._processPointerDown(pickResult, evt);
  130216. };
  130217. this._onPointerUp = function (evt) {
  130218. if (_this._totalPointersPressed === 0) { // We are attaching the pointer up to windows because of a bug in FF
  130219. return; // So we need to test it the pointer down was pressed before.
  130220. }
  130221. _this._totalPointersPressed--;
  130222. _this._pickedUpMesh = null;
  130223. _this._meshPickProceed = false;
  130224. _this._updatePointerPosition(evt);
  130225. if (_this.preventDefaultOnPointerUp && canvas) {
  130226. evt.preventDefault();
  130227. canvas.focus();
  130228. }
  130229. _this._initClickEvent(_this.onPrePointerObservable, _this.onPointerObservable, evt, function (clickInfo, pickResult) {
  130230. // PreObservable support
  130231. if (_this.onPrePointerObservable.hasObservers()) {
  130232. if (!clickInfo.ignore) {
  130233. if (!clickInfo.hasSwiped) {
  130234. if (clickInfo.singleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  130235. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERTAP)) {
  130236. return;
  130237. }
  130238. }
  130239. if (clickInfo.doubleClick && _this.onPrePointerObservable.hasSpecificMask(_Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  130240. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERDOUBLETAP)) {
  130241. return;
  130242. }
  130243. }
  130244. }
  130245. if (_this._checkPrePointerObservable(null, evt, _Events_pointerEvents__WEBPACK_IMPORTED_MODULE_15__["PointerEventTypes"].POINTERUP)) {
  130246. return;
  130247. }
  130248. }
  130249. }
  130250. _this._pointerCaptures[evt.pointerId] = false;
  130251. if (!_this.cameraToUseForPointers && !_this.activeCamera) {
  130252. return;
  130253. }
  130254. if (!_this.pointerUpPredicate) {
  130255. _this.pointerUpPredicate = function (mesh) {
  130256. return mesh.isPickable && mesh.isVisible && mesh.isReady() && mesh.isEnabled();
  130257. };
  130258. }
  130259. // Meshes
  130260. if (!_this._meshPickProceed && (_Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"] && _Actions_abstractActionManager__WEBPACK_IMPORTED_MODULE_25__["AbstractActionManager"].HasTriggers || _this.onPointerObservable.hasObservers())) {
  130261. _this._initActionManager(null, clickInfo);
  130262. }
  130263. if (!pickResult) {
  130264. pickResult = _this._currentPickResult;
  130265. }
  130266. _this._processPointerUp(pickResult, evt, clickInfo);
  130267. _this._previousPickResult = _this._currentPickResult;
  130268. });
  130269. };
  130270. this._onKeyDown = function (evt) {
  130271. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYDOWN;
  130272. if (_this.onPreKeyboardObservable.hasObservers()) {
  130273. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  130274. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  130275. if (pi.skipOnPointerObservable) {
  130276. return;
  130277. }
  130278. }
  130279. if (_this.onKeyboardObservable.hasObservers()) {
  130280. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  130281. _this.onKeyboardObservable.notifyObservers(pi, type);
  130282. }
  130283. if (_this.actionManager) {
  130284. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyDownTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  130285. }
  130286. };
  130287. this._onKeyUp = function (evt) {
  130288. var type = _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardEventTypes"].KEYUP;
  130289. if (_this.onPreKeyboardObservable.hasObservers()) {
  130290. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfoPre"](type, evt);
  130291. _this.onPreKeyboardObservable.notifyObservers(pi, type);
  130292. if (pi.skipOnPointerObservable) {
  130293. return;
  130294. }
  130295. }
  130296. if (_this.onKeyboardObservable.hasObservers()) {
  130297. var pi = new _Events_keyboardEvents__WEBPACK_IMPORTED_MODULE_16__["KeyboardInfo"](type, evt);
  130298. _this.onKeyboardObservable.notifyObservers(pi, type);
  130299. }
  130300. if (_this.actionManager) {
  130301. _this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnKeyUpTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNewFromScene(_this, evt));
  130302. }
  130303. };
  130304. var engine = this.getEngine();
  130305. this._onCanvasFocusObserver = engine.onCanvasFocusObservable.add(function () {
  130306. if (!canvas) {
  130307. return;
  130308. }
  130309. canvas.addEventListener("keydown", _this._onKeyDown, false);
  130310. canvas.addEventListener("keyup", _this._onKeyUp, false);
  130311. });
  130312. this._onCanvasBlurObserver = engine.onCanvasBlurObservable.add(function () {
  130313. if (!canvas) {
  130314. return;
  130315. }
  130316. canvas.removeEventListener("keydown", _this._onKeyDown);
  130317. canvas.removeEventListener("keyup", _this._onKeyUp);
  130318. });
  130319. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  130320. var canvas = this._engine.getRenderingCanvas();
  130321. if (!canvas) {
  130322. return;
  130323. }
  130324. if (attachMove) {
  130325. canvas.addEventListener(eventPrefix + "move", this._onPointerMove, false);
  130326. // Wheel
  130327. this._wheelEventName = "onwheel" in document.createElement("div") ? "wheel" : // Modern browsers support "wheel"
  130328. document.onmousewheel !== undefined ? "mousewheel" : // Webkit and IE support at least "mousewheel"
  130329. "DOMMouseScroll"; // let's assume that remaining browsers are older Firefox
  130330. canvas.addEventListener(this._wheelEventName, this._onPointerMove, false);
  130331. }
  130332. if (attachDown) {
  130333. canvas.addEventListener(eventPrefix + "down", this._onPointerDown, false);
  130334. }
  130335. if (attachUp) {
  130336. window.addEventListener(eventPrefix + "up", this._onPointerUp, false);
  130337. }
  130338. canvas.tabIndex = 1;
  130339. };
  130340. /** Detaches all event handlers*/
  130341. Scene.prototype.detachControl = function () {
  130342. var engine = this.getEngine();
  130343. var eventPrefix = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].GetPointerPrefix();
  130344. var canvas = engine.getRenderingCanvas();
  130345. if (!canvas) {
  130346. return;
  130347. }
  130348. canvas.removeEventListener(eventPrefix + "move", this._onPointerMove);
  130349. canvas.removeEventListener(eventPrefix + "down", this._onPointerDown);
  130350. window.removeEventListener(eventPrefix + "up", this._onPointerUp);
  130351. if (this._onCanvasBlurObserver) {
  130352. engine.onCanvasBlurObservable.remove(this._onCanvasBlurObserver);
  130353. }
  130354. if (this._onCanvasFocusObserver) {
  130355. engine.onCanvasFocusObservable.remove(this._onCanvasFocusObserver);
  130356. }
  130357. // Wheel
  130358. canvas.removeEventListener(this._wheelEventName, this._onPointerMove);
  130359. // Keyboard
  130360. canvas.removeEventListener("keydown", this._onKeyDown);
  130361. canvas.removeEventListener("keyup", this._onKeyUp);
  130362. // Observables
  130363. this.onKeyboardObservable.clear();
  130364. this.onPreKeyboardObservable.clear();
  130365. this.onPointerObservable.clear();
  130366. this.onPrePointerObservable.clear();
  130367. };
  130368. /**
  130369. * This function will check if the scene can be rendered (textures are loaded, shaders are compiled)
  130370. * Delay loaded resources are not taking in account
  130371. * @return true if all required resources are ready
  130372. */
  130373. Scene.prototype.isReady = function () {
  130374. if (this._isDisposed) {
  130375. return false;
  130376. }
  130377. var index;
  130378. var engine = this.getEngine();
  130379. // Effects
  130380. if (!engine.areAllEffectsReady()) {
  130381. return false;
  130382. }
  130383. // Pending data
  130384. if (this._pendingData.length > 0) {
  130385. return false;
  130386. }
  130387. // Meshes
  130388. for (index = 0; index < this.meshes.length; index++) {
  130389. var mesh = this.meshes[index];
  130390. if (!mesh.isEnabled()) {
  130391. continue;
  130392. }
  130393. if (!mesh.subMeshes || mesh.subMeshes.length === 0) {
  130394. continue;
  130395. }
  130396. if (!mesh.isReady(true)) {
  130397. return false;
  130398. }
  130399. var hardwareInstancedRendering = mesh.getClassName() === "InstancedMesh" || mesh.getClassName() === "InstancedLinesMesh" || engine.getCaps().instancedArrays && mesh.instances.length > 0;
  130400. // Is Ready For Mesh
  130401. for (var _i = 0, _a = this._isReadyForMeshStage; _i < _a.length; _i++) {
  130402. var step = _a[_i];
  130403. if (!step.action(mesh, hardwareInstancedRendering)) {
  130404. return false;
  130405. }
  130406. }
  130407. }
  130408. // Geometries
  130409. for (index = 0; index < this.geometries.length; index++) {
  130410. var geometry = this.geometries[index];
  130411. if (geometry.delayLoadState === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].DELAYLOADSTATE_LOADING) {
  130412. return false;
  130413. }
  130414. }
  130415. // Post-processes
  130416. if (this.activeCameras && this.activeCameras.length > 0) {
  130417. for (var _b = 0, _c = this.activeCameras; _b < _c.length; _b++) {
  130418. var camera = _c[_b];
  130419. if (!camera.isReady(true)) {
  130420. return false;
  130421. }
  130422. }
  130423. }
  130424. else if (this.activeCamera) {
  130425. if (!this.activeCamera.isReady(true)) {
  130426. return false;
  130427. }
  130428. }
  130429. // Particles
  130430. for (var _d = 0, _e = this.particleSystems; _d < _e.length; _d++) {
  130431. var particleSystem = _e[_d];
  130432. if (!particleSystem.isReady()) {
  130433. return false;
  130434. }
  130435. }
  130436. return true;
  130437. };
  130438. /** Resets all cached information relative to material (including effect and visibility) */
  130439. Scene.prototype.resetCachedMaterial = function () {
  130440. this._cachedMaterial = null;
  130441. this._cachedEffect = null;
  130442. this._cachedVisibility = null;
  130443. };
  130444. /**
  130445. * Registers a function to be called before every frame render
  130446. * @param func defines the function to register
  130447. */
  130448. Scene.prototype.registerBeforeRender = function (func) {
  130449. this.onBeforeRenderObservable.add(func);
  130450. };
  130451. /**
  130452. * Unregisters a function called before every frame render
  130453. * @param func defines the function to unregister
  130454. */
  130455. Scene.prototype.unregisterBeforeRender = function (func) {
  130456. this.onBeforeRenderObservable.removeCallback(func);
  130457. };
  130458. /**
  130459. * Registers a function to be called after every frame render
  130460. * @param func defines the function to register
  130461. */
  130462. Scene.prototype.registerAfterRender = function (func) {
  130463. this.onAfterRenderObservable.add(func);
  130464. };
  130465. /**
  130466. * Unregisters a function called after every frame render
  130467. * @param func defines the function to unregister
  130468. */
  130469. Scene.prototype.unregisterAfterRender = function (func) {
  130470. this.onAfterRenderObservable.removeCallback(func);
  130471. };
  130472. Scene.prototype._executeOnceBeforeRender = function (func) {
  130473. var _this = this;
  130474. var execFunc = function () {
  130475. func();
  130476. setTimeout(function () {
  130477. _this.unregisterBeforeRender(execFunc);
  130478. });
  130479. };
  130480. this.registerBeforeRender(execFunc);
  130481. };
  130482. /**
  130483. * The provided function will run before render once and will be disposed afterwards.
  130484. * A timeout delay can be provided so that the function will be executed in N ms.
  130485. * The timeout is using the browser's native setTimeout so time percision cannot be guaranteed.
  130486. * @param func The function to be executed.
  130487. * @param timeout optional delay in ms
  130488. */
  130489. Scene.prototype.executeOnceBeforeRender = function (func, timeout) {
  130490. var _this = this;
  130491. if (timeout !== undefined) {
  130492. setTimeout(function () {
  130493. _this._executeOnceBeforeRender(func);
  130494. }, timeout);
  130495. }
  130496. else {
  130497. this._executeOnceBeforeRender(func);
  130498. }
  130499. };
  130500. /** @hidden */
  130501. Scene.prototype._addPendingData = function (data) {
  130502. this._pendingData.push(data);
  130503. };
  130504. /** @hidden */
  130505. Scene.prototype._removePendingData = function (data) {
  130506. var wasLoading = this.isLoading;
  130507. var index = this._pendingData.indexOf(data);
  130508. if (index !== -1) {
  130509. this._pendingData.splice(index, 1);
  130510. }
  130511. if (wasLoading && !this.isLoading) {
  130512. this.onDataLoadedObservable.notifyObservers(this);
  130513. }
  130514. };
  130515. /**
  130516. * Returns the number of items waiting to be loaded
  130517. * @returns the number of items waiting to be loaded
  130518. */
  130519. Scene.prototype.getWaitingItemsCount = function () {
  130520. return this._pendingData.length;
  130521. };
  130522. Object.defineProperty(Scene.prototype, "isLoading", {
  130523. /**
  130524. * Returns a boolean indicating if the scene is still loading data
  130525. */
  130526. get: function () {
  130527. return this._pendingData.length > 0;
  130528. },
  130529. enumerable: true,
  130530. configurable: true
  130531. });
  130532. /**
  130533. * Registers a function to be executed when the scene is ready
  130534. * @param {Function} func - the function to be executed
  130535. */
  130536. Scene.prototype.executeWhenReady = function (func) {
  130537. var _this = this;
  130538. this.onReadyObservable.add(func);
  130539. if (this._executeWhenReadyTimeoutId !== -1) {
  130540. return;
  130541. }
  130542. this._executeWhenReadyTimeoutId = setTimeout(function () {
  130543. _this._checkIsReady();
  130544. }, 150);
  130545. };
  130546. /**
  130547. * Returns a promise that resolves when the scene is ready
  130548. * @returns A promise that resolves when the scene is ready
  130549. */
  130550. Scene.prototype.whenReadyAsync = function () {
  130551. var _this = this;
  130552. return new Promise(function (resolve) {
  130553. _this.executeWhenReady(function () {
  130554. resolve();
  130555. });
  130556. });
  130557. };
  130558. /** @hidden */
  130559. Scene.prototype._checkIsReady = function () {
  130560. var _this = this;
  130561. this._registerTransientComponents();
  130562. if (this.isReady()) {
  130563. this.onReadyObservable.notifyObservers(this);
  130564. this.onReadyObservable.clear();
  130565. this._executeWhenReadyTimeoutId = -1;
  130566. return;
  130567. }
  130568. this._executeWhenReadyTimeoutId = setTimeout(function () {
  130569. _this._checkIsReady();
  130570. }, 150);
  130571. };
  130572. Object.defineProperty(Scene.prototype, "animatables", {
  130573. /**
  130574. * Gets all animatable attached to the scene
  130575. */
  130576. get: function () {
  130577. return this._activeAnimatables;
  130578. },
  130579. enumerable: true,
  130580. configurable: true
  130581. });
  130582. /**
  130583. * Resets the last animation time frame.
  130584. * Useful to override when animations start running when loading a scene for the first time.
  130585. */
  130586. Scene.prototype.resetLastAnimationTimeFrame = function () {
  130587. this._animationTimeLast = _Misc_precisionDate__WEBPACK_IMPORTED_MODULE_2__["PrecisionDate"].Now;
  130588. };
  130589. // Matrix
  130590. /** @hidden */
  130591. Scene.prototype._switchToAlternateCameraConfiguration = function (active) {
  130592. this._useAlternateCameraConfiguration = active;
  130593. };
  130594. /**
  130595. * Gets the current view matrix
  130596. * @returns a Matrix
  130597. */
  130598. Scene.prototype.getViewMatrix = function () {
  130599. return this._useAlternateCameraConfiguration ? this._alternateViewMatrix : this._viewMatrix;
  130600. };
  130601. /**
  130602. * Gets the current projection matrix
  130603. * @returns a Matrix
  130604. */
  130605. Scene.prototype.getProjectionMatrix = function () {
  130606. return this._useAlternateCameraConfiguration ? this._alternateProjectionMatrix : this._projectionMatrix;
  130607. };
  130608. /**
  130609. * Gets the current transform matrix
  130610. * @returns a Matrix made of View * Projection
  130611. */
  130612. Scene.prototype.getTransformMatrix = function () {
  130613. return this._useAlternateCameraConfiguration ? this._alternateTransformMatrix : this._transformMatrix;
  130614. };
  130615. /**
  130616. * Sets the current transform matrix
  130617. * @param view defines the View matrix to use
  130618. * @param projection defines the Projection matrix to use
  130619. */
  130620. Scene.prototype.setTransformMatrix = function (view, projection) {
  130621. if (this._viewUpdateFlag === view.updateFlag && this._projectionUpdateFlag === projection.updateFlag) {
  130622. return;
  130623. }
  130624. this._viewUpdateFlag = view.updateFlag;
  130625. this._projectionUpdateFlag = projection.updateFlag;
  130626. this._viewMatrix = view;
  130627. this._projectionMatrix = projection;
  130628. this._viewMatrix.multiplyToRef(this._projectionMatrix, this._transformMatrix);
  130629. // Update frustum
  130630. if (!this._frustumPlanes) {
  130631. this._frustumPlanes = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanes(this._transformMatrix);
  130632. }
  130633. else {
  130634. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetPlanesToRef(this._transformMatrix, this._frustumPlanes);
  130635. }
  130636. if (this.activeCamera && this.activeCamera._alternateCamera) {
  130637. var otherCamera = this.activeCamera._alternateCamera;
  130638. otherCamera.getViewMatrix().multiplyToRef(otherCamera.getProjectionMatrix(), _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0]);
  130639. _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Frustum"].GetRightPlaneToRef(_Maths_math__WEBPACK_IMPORTED_MODULE_7__["Tmp"].Matrix[0], this._frustumPlanes[3]); // Replace right plane by second camera right plane
  130640. }
  130641. if (this._sceneUbo.useUbo) {
  130642. this._sceneUbo.updateMatrix("viewProjection", this._transformMatrix);
  130643. this._sceneUbo.updateMatrix("view", this._viewMatrix);
  130644. this._sceneUbo.update();
  130645. }
  130646. };
  130647. /** @hidden */
  130648. Scene.prototype._setAlternateTransformMatrix = function (view, projection) {
  130649. if (this._alternateViewUpdateFlag === view.updateFlag && this._alternateProjectionUpdateFlag === projection.updateFlag) {
  130650. return;
  130651. }
  130652. this._alternateViewUpdateFlag = view.updateFlag;
  130653. this._alternateProjectionUpdateFlag = projection.updateFlag;
  130654. this._alternateViewMatrix = view;
  130655. this._alternateProjectionMatrix = projection;
  130656. if (!this._alternateTransformMatrix) {
  130657. this._alternateTransformMatrix = _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Matrix"].Zero();
  130658. }
  130659. this._alternateViewMatrix.multiplyToRef(this._alternateProjectionMatrix, this._alternateTransformMatrix);
  130660. if (!this._alternateSceneUbo) {
  130661. this._createAlternateUbo();
  130662. }
  130663. if (this._alternateSceneUbo.useUbo) {
  130664. this._alternateSceneUbo.updateMatrix("viewProjection", this._alternateTransformMatrix);
  130665. this._alternateSceneUbo.updateMatrix("view", this._alternateViewMatrix);
  130666. this._alternateSceneUbo.update();
  130667. }
  130668. };
  130669. /**
  130670. * Gets the uniform buffer used to store scene data
  130671. * @returns a UniformBuffer
  130672. */
  130673. Scene.prototype.getSceneUniformBuffer = function () {
  130674. return this._useAlternateCameraConfiguration ? this._alternateSceneUbo : this._sceneUbo;
  130675. };
  130676. /**
  130677. * Gets an unique (relatively to the current scene) Id
  130678. * @returns an unique number for the scene
  130679. */
  130680. Scene.prototype.getUniqueId = function () {
  130681. var result = Scene._uniqueIdCounter;
  130682. Scene._uniqueIdCounter++;
  130683. return result;
  130684. };
  130685. /**
  130686. * Add a mesh to the list of scene's meshes
  130687. * @param newMesh defines the mesh to add
  130688. * @param recursive if all child meshes should also be added to the scene
  130689. */
  130690. Scene.prototype.addMesh = function (newMesh, recursive) {
  130691. var _this = this;
  130692. if (recursive === void 0) { recursive = false; }
  130693. this.meshes.push(newMesh);
  130694. newMesh._resyncLightSources();
  130695. this.onNewMeshAddedObservable.notifyObservers(newMesh);
  130696. if (recursive) {
  130697. newMesh.getChildMeshes().forEach(function (m) {
  130698. _this.addMesh(m);
  130699. });
  130700. }
  130701. };
  130702. /**
  130703. * Remove a mesh for the list of scene's meshes
  130704. * @param toRemove defines the mesh to remove
  130705. * @param recursive if all child meshes should also be removed from the scene
  130706. * @returns the index where the mesh was in the mesh list
  130707. */
  130708. Scene.prototype.removeMesh = function (toRemove, recursive) {
  130709. var _this = this;
  130710. if (recursive === void 0) { recursive = false; }
  130711. var index = this.meshes.indexOf(toRemove);
  130712. if (index !== -1) {
  130713. // Remove from the scene if mesh found
  130714. this.meshes[index] = this.meshes[this.meshes.length - 1];
  130715. this.meshes.pop();
  130716. }
  130717. this.onMeshRemovedObservable.notifyObservers(toRemove);
  130718. if (recursive) {
  130719. toRemove.getChildMeshes().forEach(function (m) {
  130720. _this.removeMesh(m);
  130721. });
  130722. }
  130723. return index;
  130724. };
  130725. /**
  130726. * Add a transform node to the list of scene's transform nodes
  130727. * @param newTransformNode defines the transform node to add
  130728. */
  130729. Scene.prototype.addTransformNode = function (newTransformNode) {
  130730. newTransformNode._indexInSceneTransformNodesArray = this.transformNodes.length;
  130731. this.transformNodes.push(newTransformNode);
  130732. this.onNewTransformNodeAddedObservable.notifyObservers(newTransformNode);
  130733. };
  130734. /**
  130735. * Remove a transform node for the list of scene's transform nodes
  130736. * @param toRemove defines the transform node to remove
  130737. * @returns the index where the transform node was in the transform node list
  130738. */
  130739. Scene.prototype.removeTransformNode = function (toRemove) {
  130740. var index = toRemove._indexInSceneTransformNodesArray;
  130741. if (index !== -1) {
  130742. if (index !== this.transformNodes.length - 1) {
  130743. var lastNode = this.transformNodes[this.transformNodes.length - 1];
  130744. this.transformNodes[index] = lastNode;
  130745. lastNode._indexInSceneTransformNodesArray = index;
  130746. }
  130747. toRemove._indexInSceneTransformNodesArray = -1;
  130748. this.transformNodes.pop();
  130749. }
  130750. this.onTransformNodeRemovedObservable.notifyObservers(toRemove);
  130751. return index;
  130752. };
  130753. /**
  130754. * Remove a skeleton for the list of scene's skeletons
  130755. * @param toRemove defines the skeleton to remove
  130756. * @returns the index where the skeleton was in the skeleton list
  130757. */
  130758. Scene.prototype.removeSkeleton = function (toRemove) {
  130759. var index = this.skeletons.indexOf(toRemove);
  130760. if (index !== -1) {
  130761. // Remove from the scene if found
  130762. this.skeletons.splice(index, 1);
  130763. }
  130764. return index;
  130765. };
  130766. /**
  130767. * Remove a morph target for the list of scene's morph targets
  130768. * @param toRemove defines the morph target to remove
  130769. * @returns the index where the morph target was in the morph target list
  130770. */
  130771. Scene.prototype.removeMorphTargetManager = function (toRemove) {
  130772. var index = this.morphTargetManagers.indexOf(toRemove);
  130773. if (index !== -1) {
  130774. // Remove from the scene if found
  130775. this.morphTargetManagers.splice(index, 1);
  130776. }
  130777. return index;
  130778. };
  130779. /**
  130780. * Remove a light for the list of scene's lights
  130781. * @param toRemove defines the light to remove
  130782. * @returns the index where the light was in the light list
  130783. */
  130784. Scene.prototype.removeLight = function (toRemove) {
  130785. var index = this.lights.indexOf(toRemove);
  130786. if (index !== -1) {
  130787. // Remove from meshes
  130788. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130789. var mesh = _a[_i];
  130790. mesh._removeLightSource(toRemove);
  130791. }
  130792. // Remove from the scene if mesh found
  130793. this.lights.splice(index, 1);
  130794. this.sortLightsByPriority();
  130795. }
  130796. this.onLightRemovedObservable.notifyObservers(toRemove);
  130797. return index;
  130798. };
  130799. /**
  130800. * Remove a camera for the list of scene's cameras
  130801. * @param toRemove defines the camera to remove
  130802. * @returns the index where the camera was in the camera list
  130803. */
  130804. Scene.prototype.removeCamera = function (toRemove) {
  130805. var index = this.cameras.indexOf(toRemove);
  130806. if (index !== -1) {
  130807. // Remove from the scene if mesh found
  130808. this.cameras.splice(index, 1);
  130809. }
  130810. // Remove from activeCameras
  130811. var index2 = this.activeCameras.indexOf(toRemove);
  130812. if (index2 !== -1) {
  130813. // Remove from the scene if mesh found
  130814. this.activeCameras.splice(index2, 1);
  130815. }
  130816. // Reset the activeCamera
  130817. if (this.activeCamera === toRemove) {
  130818. if (this.cameras.length > 0) {
  130819. this.activeCamera = this.cameras[0];
  130820. }
  130821. else {
  130822. this.activeCamera = null;
  130823. }
  130824. }
  130825. this.onCameraRemovedObservable.notifyObservers(toRemove);
  130826. return index;
  130827. };
  130828. /**
  130829. * Remove a particle system for the list of scene's particle systems
  130830. * @param toRemove defines the particle system to remove
  130831. * @returns the index where the particle system was in the particle system list
  130832. */
  130833. Scene.prototype.removeParticleSystem = function (toRemove) {
  130834. var index = this.particleSystems.indexOf(toRemove);
  130835. if (index !== -1) {
  130836. this.particleSystems.splice(index, 1);
  130837. }
  130838. return index;
  130839. };
  130840. /**
  130841. * Remove a animation for the list of scene's animations
  130842. * @param toRemove defines the animation to remove
  130843. * @returns the index where the animation was in the animation list
  130844. */
  130845. Scene.prototype.removeAnimation = function (toRemove) {
  130846. var index = this.animations.indexOf(toRemove);
  130847. if (index !== -1) {
  130848. this.animations.splice(index, 1);
  130849. }
  130850. return index;
  130851. };
  130852. /**
  130853. * Removes the given animation group from this scene.
  130854. * @param toRemove The animation group to remove
  130855. * @returns The index of the removed animation group
  130856. */
  130857. Scene.prototype.removeAnimationGroup = function (toRemove) {
  130858. var index = this.animationGroups.indexOf(toRemove);
  130859. if (index !== -1) {
  130860. this.animationGroups.splice(index, 1);
  130861. }
  130862. return index;
  130863. };
  130864. /**
  130865. * Removes the given multi-material from this scene.
  130866. * @param toRemove The multi-material to remove
  130867. * @returns The index of the removed multi-material
  130868. */
  130869. Scene.prototype.removeMultiMaterial = function (toRemove) {
  130870. var index = this.multiMaterials.indexOf(toRemove);
  130871. if (index !== -1) {
  130872. this.multiMaterials.splice(index, 1);
  130873. }
  130874. return index;
  130875. };
  130876. /**
  130877. * Removes the given material from this scene.
  130878. * @param toRemove The material to remove
  130879. * @returns The index of the removed material
  130880. */
  130881. Scene.prototype.removeMaterial = function (toRemove) {
  130882. var index = toRemove._indexInSceneMaterialArray;
  130883. if (index !== -1 && index < this.materials.length) {
  130884. if (index !== this.materials.length - 1) {
  130885. var lastMaterial = this.materials[this.materials.length - 1];
  130886. this.materials[index] = lastMaterial;
  130887. lastMaterial._indexInSceneMaterialArray = index;
  130888. }
  130889. toRemove._indexInSceneMaterialArray = -1;
  130890. this.materials.pop();
  130891. }
  130892. this.onMaterialRemovedObservable.notifyObservers(toRemove);
  130893. return index;
  130894. };
  130895. /**
  130896. * Removes the given action manager from this scene.
  130897. * @param toRemove The action manager to remove
  130898. * @returns The index of the removed action manager
  130899. */
  130900. Scene.prototype.removeActionManager = function (toRemove) {
  130901. var index = this.actionManagers.indexOf(toRemove);
  130902. if (index !== -1) {
  130903. this.actionManagers.splice(index, 1);
  130904. }
  130905. return index;
  130906. };
  130907. /**
  130908. * Removes the given texture from this scene.
  130909. * @param toRemove The texture to remove
  130910. * @returns The index of the removed texture
  130911. */
  130912. Scene.prototype.removeTexture = function (toRemove) {
  130913. var index = this.textures.indexOf(toRemove);
  130914. if (index !== -1) {
  130915. this.textures.splice(index, 1);
  130916. }
  130917. this.onTextureRemovedObservable.notifyObservers(toRemove);
  130918. return index;
  130919. };
  130920. /**
  130921. * Adds the given light to this scene
  130922. * @param newLight The light to add
  130923. */
  130924. Scene.prototype.addLight = function (newLight) {
  130925. this.lights.push(newLight);
  130926. this.sortLightsByPriority();
  130927. // Add light to all meshes (To support if the light is removed and then readded)
  130928. for (var _i = 0, _a = this.meshes; _i < _a.length; _i++) {
  130929. var mesh = _a[_i];
  130930. if (mesh._lightSources.indexOf(newLight) === -1) {
  130931. mesh._lightSources.push(newLight);
  130932. mesh._resyncLightSources();
  130933. }
  130934. }
  130935. this.onNewLightAddedObservable.notifyObservers(newLight);
  130936. };
  130937. /**
  130938. * Sorts the list list based on light priorities
  130939. */
  130940. Scene.prototype.sortLightsByPriority = function () {
  130941. if (this.requireLightSorting) {
  130942. this.lights.sort(_Lights_light__WEBPACK_IMPORTED_MODULE_13__["Light"].CompareLightsPriority);
  130943. }
  130944. };
  130945. /**
  130946. * Adds the given camera to this scene
  130947. * @param newCamera The camera to add
  130948. */
  130949. Scene.prototype.addCamera = function (newCamera) {
  130950. this.cameras.push(newCamera);
  130951. this.onNewCameraAddedObservable.notifyObservers(newCamera);
  130952. };
  130953. /**
  130954. * Adds the given skeleton to this scene
  130955. * @param newSkeleton The skeleton to add
  130956. */
  130957. Scene.prototype.addSkeleton = function (newSkeleton) {
  130958. this.skeletons.push(newSkeleton);
  130959. };
  130960. /**
  130961. * Adds the given particle system to this scene
  130962. * @param newParticleSystem The particle system to add
  130963. */
  130964. Scene.prototype.addParticleSystem = function (newParticleSystem) {
  130965. this.particleSystems.push(newParticleSystem);
  130966. };
  130967. /**
  130968. * Adds the given animation to this scene
  130969. * @param newAnimation The animation to add
  130970. */
  130971. Scene.prototype.addAnimation = function (newAnimation) {
  130972. this.animations.push(newAnimation);
  130973. };
  130974. /**
  130975. * Adds the given animation group to this scene.
  130976. * @param newAnimationGroup The animation group to add
  130977. */
  130978. Scene.prototype.addAnimationGroup = function (newAnimationGroup) {
  130979. this.animationGroups.push(newAnimationGroup);
  130980. };
  130981. /**
  130982. * Adds the given multi-material to this scene
  130983. * @param newMultiMaterial The multi-material to add
  130984. */
  130985. Scene.prototype.addMultiMaterial = function (newMultiMaterial) {
  130986. this.multiMaterials.push(newMultiMaterial);
  130987. };
  130988. /**
  130989. * Adds the given material to this scene
  130990. * @param newMaterial The material to add
  130991. */
  130992. Scene.prototype.addMaterial = function (newMaterial) {
  130993. newMaterial._indexInSceneMaterialArray = this.materials.length;
  130994. this.materials.push(newMaterial);
  130995. this.onNewMaterialAddedObservable.notifyObservers(newMaterial);
  130996. };
  130997. /**
  130998. * Adds the given morph target to this scene
  130999. * @param newMorphTargetManager The morph target to add
  131000. */
  131001. Scene.prototype.addMorphTargetManager = function (newMorphTargetManager) {
  131002. this.morphTargetManagers.push(newMorphTargetManager);
  131003. };
  131004. /**
  131005. * Adds the given geometry to this scene
  131006. * @param newGeometry The geometry to add
  131007. */
  131008. Scene.prototype.addGeometry = function (newGeometry) {
  131009. if (this.geometriesByUniqueId) {
  131010. this.geometriesByUniqueId[newGeometry.uniqueId] = this.geometries.length;
  131011. }
  131012. this.geometries.push(newGeometry);
  131013. };
  131014. /**
  131015. * Adds the given action manager to this scene
  131016. * @param newActionManager The action manager to add
  131017. */
  131018. Scene.prototype.addActionManager = function (newActionManager) {
  131019. this.actionManagers.push(newActionManager);
  131020. };
  131021. /**
  131022. * Adds the given texture to this scene.
  131023. * @param newTexture The texture to add
  131024. */
  131025. Scene.prototype.addTexture = function (newTexture) {
  131026. this.textures.push(newTexture);
  131027. this.onNewTextureAddedObservable.notifyObservers(newTexture);
  131028. };
  131029. /**
  131030. * Switch active camera
  131031. * @param newCamera defines the new active camera
  131032. * @param attachControl defines if attachControl must be called for the new active camera (default: true)
  131033. */
  131034. Scene.prototype.switchActiveCamera = function (newCamera, attachControl) {
  131035. if (attachControl === void 0) { attachControl = true; }
  131036. var canvas = this._engine.getRenderingCanvas();
  131037. if (!canvas) {
  131038. return;
  131039. }
  131040. if (this.activeCamera) {
  131041. this.activeCamera.detachControl(canvas);
  131042. }
  131043. this.activeCamera = newCamera;
  131044. if (attachControl) {
  131045. newCamera.attachControl(canvas);
  131046. }
  131047. };
  131048. /**
  131049. * sets the active camera of the scene using its ID
  131050. * @param id defines the camera's ID
  131051. * @return the new active camera or null if none found.
  131052. */
  131053. Scene.prototype.setActiveCameraByID = function (id) {
  131054. var camera = this.getCameraByID(id);
  131055. if (camera) {
  131056. this.activeCamera = camera;
  131057. return camera;
  131058. }
  131059. return null;
  131060. };
  131061. /**
  131062. * sets the active camera of the scene using its name
  131063. * @param name defines the camera's name
  131064. * @returns the new active camera or null if none found.
  131065. */
  131066. Scene.prototype.setActiveCameraByName = function (name) {
  131067. var camera = this.getCameraByName(name);
  131068. if (camera) {
  131069. this.activeCamera = camera;
  131070. return camera;
  131071. }
  131072. return null;
  131073. };
  131074. /**
  131075. * get an animation group using its name
  131076. * @param name defines the material's name
  131077. * @return the animation group or null if none found.
  131078. */
  131079. Scene.prototype.getAnimationGroupByName = function (name) {
  131080. for (var index = 0; index < this.animationGroups.length; index++) {
  131081. if (this.animationGroups[index].name === name) {
  131082. return this.animationGroups[index];
  131083. }
  131084. }
  131085. return null;
  131086. };
  131087. /**
  131088. * get a material using its id
  131089. * @param id defines the material's ID
  131090. * @return the material or null if none found.
  131091. */
  131092. Scene.prototype.getMaterialByID = function (id) {
  131093. for (var index = 0; index < this.materials.length; index++) {
  131094. if (this.materials[index].id === id) {
  131095. return this.materials[index];
  131096. }
  131097. }
  131098. return null;
  131099. };
  131100. /**
  131101. * Gets a material using its name
  131102. * @param name defines the material's name
  131103. * @return the material or null if none found.
  131104. */
  131105. Scene.prototype.getMaterialByName = function (name) {
  131106. for (var index = 0; index < this.materials.length; index++) {
  131107. if (this.materials[index].name === name) {
  131108. return this.materials[index];
  131109. }
  131110. }
  131111. return null;
  131112. };
  131113. /**
  131114. * Gets a camera using its id
  131115. * @param id defines the id to look for
  131116. * @returns the camera or null if not found
  131117. */
  131118. Scene.prototype.getCameraByID = function (id) {
  131119. for (var index = 0; index < this.cameras.length; index++) {
  131120. if (this.cameras[index].id === id) {
  131121. return this.cameras[index];
  131122. }
  131123. }
  131124. return null;
  131125. };
  131126. /**
  131127. * Gets a camera using its unique id
  131128. * @param uniqueId defines the unique id to look for
  131129. * @returns the camera or null if not found
  131130. */
  131131. Scene.prototype.getCameraByUniqueID = function (uniqueId) {
  131132. for (var index = 0; index < this.cameras.length; index++) {
  131133. if (this.cameras[index].uniqueId === uniqueId) {
  131134. return this.cameras[index];
  131135. }
  131136. }
  131137. return null;
  131138. };
  131139. /**
  131140. * Gets a camera using its name
  131141. * @param name defines the camera's name
  131142. * @return the camera or null if none found.
  131143. */
  131144. Scene.prototype.getCameraByName = function (name) {
  131145. for (var index = 0; index < this.cameras.length; index++) {
  131146. if (this.cameras[index].name === name) {
  131147. return this.cameras[index];
  131148. }
  131149. }
  131150. return null;
  131151. };
  131152. /**
  131153. * Gets a bone using its id
  131154. * @param id defines the bone's id
  131155. * @return the bone or null if not found
  131156. */
  131157. Scene.prototype.getBoneByID = function (id) {
  131158. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  131159. var skeleton = this.skeletons[skeletonIndex];
  131160. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  131161. if (skeleton.bones[boneIndex].id === id) {
  131162. return skeleton.bones[boneIndex];
  131163. }
  131164. }
  131165. }
  131166. return null;
  131167. };
  131168. /**
  131169. * Gets a bone using its id
  131170. * @param name defines the bone's name
  131171. * @return the bone or null if not found
  131172. */
  131173. Scene.prototype.getBoneByName = function (name) {
  131174. for (var skeletonIndex = 0; skeletonIndex < this.skeletons.length; skeletonIndex++) {
  131175. var skeleton = this.skeletons[skeletonIndex];
  131176. for (var boneIndex = 0; boneIndex < skeleton.bones.length; boneIndex++) {
  131177. if (skeleton.bones[boneIndex].name === name) {
  131178. return skeleton.bones[boneIndex];
  131179. }
  131180. }
  131181. }
  131182. return null;
  131183. };
  131184. /**
  131185. * Gets a light node using its name
  131186. * @param name defines the the light's name
  131187. * @return the light or null if none found.
  131188. */
  131189. Scene.prototype.getLightByName = function (name) {
  131190. for (var index = 0; index < this.lights.length; index++) {
  131191. if (this.lights[index].name === name) {
  131192. return this.lights[index];
  131193. }
  131194. }
  131195. return null;
  131196. };
  131197. /**
  131198. * Gets a light node using its id
  131199. * @param id defines the light's id
  131200. * @return the light or null if none found.
  131201. */
  131202. Scene.prototype.getLightByID = function (id) {
  131203. for (var index = 0; index < this.lights.length; index++) {
  131204. if (this.lights[index].id === id) {
  131205. return this.lights[index];
  131206. }
  131207. }
  131208. return null;
  131209. };
  131210. /**
  131211. * Gets a light node using its scene-generated unique ID
  131212. * @param uniqueId defines the light's unique id
  131213. * @return the light or null if none found.
  131214. */
  131215. Scene.prototype.getLightByUniqueID = function (uniqueId) {
  131216. for (var index = 0; index < this.lights.length; index++) {
  131217. if (this.lights[index].uniqueId === uniqueId) {
  131218. return this.lights[index];
  131219. }
  131220. }
  131221. return null;
  131222. };
  131223. /**
  131224. * Gets a particle system by id
  131225. * @param id defines the particle system id
  131226. * @return the corresponding system or null if none found
  131227. */
  131228. Scene.prototype.getParticleSystemByID = function (id) {
  131229. for (var index = 0; index < this.particleSystems.length; index++) {
  131230. if (this.particleSystems[index].id === id) {
  131231. return this.particleSystems[index];
  131232. }
  131233. }
  131234. return null;
  131235. };
  131236. /**
  131237. * Gets a geometry using its ID
  131238. * @param id defines the geometry's id
  131239. * @return the geometry or null if none found.
  131240. */
  131241. Scene.prototype.getGeometryByID = function (id) {
  131242. for (var index = 0; index < this.geometries.length; index++) {
  131243. if (this.geometries[index].id === id) {
  131244. return this.geometries[index];
  131245. }
  131246. }
  131247. return null;
  131248. };
  131249. Scene.prototype._getGeometryByUniqueID = function (uniqueId) {
  131250. if (this.geometriesByUniqueId) {
  131251. var index_1 = this.geometriesByUniqueId[uniqueId];
  131252. if (index_1 !== undefined) {
  131253. return this.geometries[index_1];
  131254. }
  131255. }
  131256. else {
  131257. for (var index = 0; index < this.geometries.length; index++) {
  131258. if (this.geometries[index].uniqueId === uniqueId) {
  131259. return this.geometries[index];
  131260. }
  131261. }
  131262. }
  131263. return null;
  131264. };
  131265. /**
  131266. * Add a new geometry to this scene
  131267. * @param geometry defines the geometry to be added to the scene.
  131268. * @param force defines if the geometry must be pushed even if a geometry with this id already exists
  131269. * @return a boolean defining if the geometry was added or not
  131270. */
  131271. Scene.prototype.pushGeometry = function (geometry, force) {
  131272. if (!force && this._getGeometryByUniqueID(geometry.uniqueId)) {
  131273. return false;
  131274. }
  131275. this.addGeometry(geometry);
  131276. this.onNewGeometryAddedObservable.notifyObservers(geometry);
  131277. return true;
  131278. };
  131279. /**
  131280. * Removes an existing geometry
  131281. * @param geometry defines the geometry to be removed from the scene
  131282. * @return a boolean defining if the geometry was removed or not
  131283. */
  131284. Scene.prototype.removeGeometry = function (geometry) {
  131285. var index;
  131286. if (this.geometriesByUniqueId) {
  131287. index = this.geometriesByUniqueId[geometry.uniqueId];
  131288. if (index === undefined) {
  131289. return false;
  131290. }
  131291. }
  131292. else {
  131293. index = this.geometries.indexOf(geometry);
  131294. if (index < 0) {
  131295. return false;
  131296. }
  131297. }
  131298. if (index !== this.geometries.length - 1) {
  131299. var lastGeometry = this.geometries[this.geometries.length - 1];
  131300. this.geometries[index] = lastGeometry;
  131301. if (this.geometriesByUniqueId) {
  131302. this.geometriesByUniqueId[lastGeometry.uniqueId] = index;
  131303. this.geometriesByUniqueId[geometry.uniqueId] = undefined;
  131304. }
  131305. }
  131306. this.geometries.pop();
  131307. this.onGeometryRemovedObservable.notifyObservers(geometry);
  131308. return true;
  131309. };
  131310. /**
  131311. * Gets the list of geometries attached to the scene
  131312. * @returns an array of Geometry
  131313. */
  131314. Scene.prototype.getGeometries = function () {
  131315. return this.geometries;
  131316. };
  131317. /**
  131318. * Gets the first added mesh found of a given ID
  131319. * @param id defines the id to search for
  131320. * @return the mesh found or null if not found at all
  131321. */
  131322. Scene.prototype.getMeshByID = function (id) {
  131323. for (var index = 0; index < this.meshes.length; index++) {
  131324. if (this.meshes[index].id === id) {
  131325. return this.meshes[index];
  131326. }
  131327. }
  131328. return null;
  131329. };
  131330. /**
  131331. * Gets a list of meshes using their id
  131332. * @param id defines the id to search for
  131333. * @returns a list of meshes
  131334. */
  131335. Scene.prototype.getMeshesByID = function (id) {
  131336. return this.meshes.filter(function (m) {
  131337. return m.id === id;
  131338. });
  131339. };
  131340. /**
  131341. * Gets the first added transform node found of a given ID
  131342. * @param id defines the id to search for
  131343. * @return the found transform node or null if not found at all.
  131344. */
  131345. Scene.prototype.getTransformNodeByID = function (id) {
  131346. for (var index = 0; index < this.transformNodes.length; index++) {
  131347. if (this.transformNodes[index].id === id) {
  131348. return this.transformNodes[index];
  131349. }
  131350. }
  131351. return null;
  131352. };
  131353. /**
  131354. * Gets a list of transform nodes using their id
  131355. * @param id defines the id to search for
  131356. * @returns a list of transform nodes
  131357. */
  131358. Scene.prototype.getTransformNodesByID = function (id) {
  131359. return this.transformNodes.filter(function (m) {
  131360. return m.id === id;
  131361. });
  131362. };
  131363. /**
  131364. * Gets a mesh with its auto-generated unique id
  131365. * @param uniqueId defines the unique id to search for
  131366. * @return the found mesh or null if not found at all.
  131367. */
  131368. Scene.prototype.getMeshByUniqueID = function (uniqueId) {
  131369. for (var index = 0; index < this.meshes.length; index++) {
  131370. if (this.meshes[index].uniqueId === uniqueId) {
  131371. return this.meshes[index];
  131372. }
  131373. }
  131374. return null;
  131375. };
  131376. /**
  131377. * Gets a the last added mesh using a given id
  131378. * @param id defines the id to search for
  131379. * @return the found mesh or null if not found at all.
  131380. */
  131381. Scene.prototype.getLastMeshByID = function (id) {
  131382. for (var index = this.meshes.length - 1; index >= 0; index--) {
  131383. if (this.meshes[index].id === id) {
  131384. return this.meshes[index];
  131385. }
  131386. }
  131387. return null;
  131388. };
  131389. /**
  131390. * Gets a the last added node (Mesh, Camera, Light) using a given id
  131391. * @param id defines the id to search for
  131392. * @return the found node or null if not found at all
  131393. */
  131394. Scene.prototype.getLastEntryByID = function (id) {
  131395. var index;
  131396. for (index = this.meshes.length - 1; index >= 0; index--) {
  131397. if (this.meshes[index].id === id) {
  131398. return this.meshes[index];
  131399. }
  131400. }
  131401. for (index = this.transformNodes.length - 1; index >= 0; index--) {
  131402. if (this.transformNodes[index].id === id) {
  131403. return this.transformNodes[index];
  131404. }
  131405. }
  131406. for (index = this.cameras.length - 1; index >= 0; index--) {
  131407. if (this.cameras[index].id === id) {
  131408. return this.cameras[index];
  131409. }
  131410. }
  131411. for (index = this.lights.length - 1; index >= 0; index--) {
  131412. if (this.lights[index].id === id) {
  131413. return this.lights[index];
  131414. }
  131415. }
  131416. return null;
  131417. };
  131418. /**
  131419. * Gets a node (Mesh, Camera, Light) using a given id
  131420. * @param id defines the id to search for
  131421. * @return the found node or null if not found at all
  131422. */
  131423. Scene.prototype.getNodeByID = function (id) {
  131424. var mesh = this.getMeshByID(id);
  131425. if (mesh) {
  131426. return mesh;
  131427. }
  131428. var transformNode = this.getTransformNodeByID(id);
  131429. if (transformNode) {
  131430. return transformNode;
  131431. }
  131432. var light = this.getLightByID(id);
  131433. if (light) {
  131434. return light;
  131435. }
  131436. var camera = this.getCameraByID(id);
  131437. if (camera) {
  131438. return camera;
  131439. }
  131440. var bone = this.getBoneByID(id);
  131441. if (bone) {
  131442. return bone;
  131443. }
  131444. return null;
  131445. };
  131446. /**
  131447. * Gets a node (Mesh, Camera, Light) using a given name
  131448. * @param name defines the name to search for
  131449. * @return the found node or null if not found at all.
  131450. */
  131451. Scene.prototype.getNodeByName = function (name) {
  131452. var mesh = this.getMeshByName(name);
  131453. if (mesh) {
  131454. return mesh;
  131455. }
  131456. var transformNode = this.getTransformNodeByName(name);
  131457. if (transformNode) {
  131458. return transformNode;
  131459. }
  131460. var light = this.getLightByName(name);
  131461. if (light) {
  131462. return light;
  131463. }
  131464. var camera = this.getCameraByName(name);
  131465. if (camera) {
  131466. return camera;
  131467. }
  131468. var bone = this.getBoneByName(name);
  131469. if (bone) {
  131470. return bone;
  131471. }
  131472. return null;
  131473. };
  131474. /**
  131475. * Gets a mesh using a given name
  131476. * @param name defines the name to search for
  131477. * @return the found mesh or null if not found at all.
  131478. */
  131479. Scene.prototype.getMeshByName = function (name) {
  131480. for (var index = 0; index < this.meshes.length; index++) {
  131481. if (this.meshes[index].name === name) {
  131482. return this.meshes[index];
  131483. }
  131484. }
  131485. return null;
  131486. };
  131487. /**
  131488. * Gets a transform node using a given name
  131489. * @param name defines the name to search for
  131490. * @return the found transform node or null if not found at all.
  131491. */
  131492. Scene.prototype.getTransformNodeByName = function (name) {
  131493. for (var index = 0; index < this.transformNodes.length; index++) {
  131494. if (this.transformNodes[index].name === name) {
  131495. return this.transformNodes[index];
  131496. }
  131497. }
  131498. return null;
  131499. };
  131500. /**
  131501. * Gets a skeleton using a given id (if many are found, this function will pick the last one)
  131502. * @param id defines the id to search for
  131503. * @return the found skeleton or null if not found at all.
  131504. */
  131505. Scene.prototype.getLastSkeletonByID = function (id) {
  131506. for (var index = this.skeletons.length - 1; index >= 0; index--) {
  131507. if (this.skeletons[index].id === id) {
  131508. return this.skeletons[index];
  131509. }
  131510. }
  131511. return null;
  131512. };
  131513. /**
  131514. * Gets a skeleton using a given id (if many are found, this function will pick the first one)
  131515. * @param id defines the id to search for
  131516. * @return the found skeleton or null if not found at all.
  131517. */
  131518. Scene.prototype.getSkeletonById = function (id) {
  131519. for (var index = 0; index < this.skeletons.length; index++) {
  131520. if (this.skeletons[index].id === id) {
  131521. return this.skeletons[index];
  131522. }
  131523. }
  131524. return null;
  131525. };
  131526. /**
  131527. * Gets a skeleton using a given name
  131528. * @param name defines the name to search for
  131529. * @return the found skeleton or null if not found at all.
  131530. */
  131531. Scene.prototype.getSkeletonByName = function (name) {
  131532. for (var index = 0; index < this.skeletons.length; index++) {
  131533. if (this.skeletons[index].name === name) {
  131534. return this.skeletons[index];
  131535. }
  131536. }
  131537. return null;
  131538. };
  131539. /**
  131540. * Gets a morph target manager using a given id (if many are found, this function will pick the last one)
  131541. * @param id defines the id to search for
  131542. * @return the found morph target manager or null if not found at all.
  131543. */
  131544. Scene.prototype.getMorphTargetManagerById = function (id) {
  131545. for (var index = 0; index < this.morphTargetManagers.length; index++) {
  131546. if (this.morphTargetManagers[index].uniqueId === id) {
  131547. return this.morphTargetManagers[index];
  131548. }
  131549. }
  131550. return null;
  131551. };
  131552. /**
  131553. * Gets a morph target using a given id (if many are found, this function will pick the first one)
  131554. * @param id defines the id to search for
  131555. * @return the found morph target or null if not found at all.
  131556. */
  131557. Scene.prototype.getMorphTargetById = function (id) {
  131558. for (var managerIndex = 0; managerIndex < this.morphTargetManagers.length; ++managerIndex) {
  131559. var morphTargetManager = this.morphTargetManagers[managerIndex];
  131560. for (var index = 0; index < morphTargetManager.numTargets; ++index) {
  131561. var target = morphTargetManager.getTarget(index);
  131562. if (target.id === id) {
  131563. return target;
  131564. }
  131565. }
  131566. }
  131567. return null;
  131568. };
  131569. /**
  131570. * Gets a boolean indicating if the given mesh is active
  131571. * @param mesh defines the mesh to look for
  131572. * @returns true if the mesh is in the active list
  131573. */
  131574. Scene.prototype.isActiveMesh = function (mesh) {
  131575. return (this._activeMeshes.indexOf(mesh) !== -1);
  131576. };
  131577. Object.defineProperty(Scene.prototype, "uid", {
  131578. /**
  131579. * Return a unique id as a string which can serve as an identifier for the scene
  131580. */
  131581. get: function () {
  131582. if (!this._uid) {
  131583. this._uid = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].RandomId();
  131584. }
  131585. return this._uid;
  131586. },
  131587. enumerable: true,
  131588. configurable: true
  131589. });
  131590. /**
  131591. * Add an externaly attached data from its key.
  131592. * This method call will fail and return false, if such key already exists.
  131593. * If you don't care and just want to get the data no matter what, use the more convenient getOrAddExternalDataWithFactory() method.
  131594. * @param key the unique key that identifies the data
  131595. * @param data the data object to associate to the key for this Engine instance
  131596. * @return true if no such key were already present and the data was added successfully, false otherwise
  131597. */
  131598. Scene.prototype.addExternalData = function (key, data) {
  131599. if (!this._externalData) {
  131600. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  131601. }
  131602. return this._externalData.add(key, data);
  131603. };
  131604. /**
  131605. * Get an externaly attached data from its key
  131606. * @param key the unique key that identifies the data
  131607. * @return the associated data, if present (can be null), or undefined if not present
  131608. */
  131609. Scene.prototype.getExternalData = function (key) {
  131610. if (!this._externalData) {
  131611. return null;
  131612. }
  131613. return this._externalData.get(key);
  131614. };
  131615. /**
  131616. * Get an externaly attached data from its key, create it using a factory if it's not already present
  131617. * @param key the unique key that identifies the data
  131618. * @param factory the factory that will be called to create the instance if and only if it doesn't exists
  131619. * @return the associated data, can be null if the factory returned null.
  131620. */
  131621. Scene.prototype.getOrAddExternalDataWithFactory = function (key, factory) {
  131622. if (!this._externalData) {
  131623. this._externalData = new _Misc_stringDictionary__WEBPACK_IMPORTED_MODULE_5__["StringDictionary"]();
  131624. }
  131625. return this._externalData.getOrAddWithFactory(key, factory);
  131626. };
  131627. /**
  131628. * Remove an externaly attached data from the Engine instance
  131629. * @param key the unique key that identifies the data
  131630. * @return true if the data was successfully removed, false if it doesn't exist
  131631. */
  131632. Scene.prototype.removeExternalData = function (key) {
  131633. return this._externalData.remove(key);
  131634. };
  131635. Scene.prototype._evaluateSubMesh = function (subMesh, mesh) {
  131636. if (this.dispatchAllSubMeshesOfActiveMeshes || mesh.alwaysSelectAsActiveMesh || mesh.subMeshes.length === 1 || subMesh.isInFrustum(this._frustumPlanes)) {
  131637. for (var _i = 0, _a = this._evaluateSubMeshStage; _i < _a.length; _i++) {
  131638. var step = _a[_i];
  131639. step.action(mesh, subMesh);
  131640. }
  131641. var material = subMesh.getMaterial();
  131642. if (material !== null && material !== undefined) {
  131643. // Render targets
  131644. if (material.hasRenderTargetTextures && material.getRenderTargetTextures !== undefined) {
  131645. if (this._processedMaterials.indexOf(material) === -1) {
  131646. this._processedMaterials.push(material);
  131647. this._renderTargets.concatWithNoDuplicate(material.getRenderTargetTextures());
  131648. }
  131649. }
  131650. // Dispatch
  131651. this._activeIndices.addCount(subMesh.indexCount, false);
  131652. this._renderingManager.dispatch(subMesh, mesh, material);
  131653. }
  131654. }
  131655. };
  131656. /**
  131657. * Clear the processed materials smart array preventing retention point in material dispose.
  131658. */
  131659. Scene.prototype.freeProcessedMaterials = function () {
  131660. this._processedMaterials.dispose();
  131661. };
  131662. Object.defineProperty(Scene.prototype, "blockfreeActiveMeshesAndRenderingGroups", {
  131663. /** Gets or sets a boolean blocking all the calls to freeActiveMeshes and freeRenderingGroups
  131664. * It can be used in order to prevent going through methods freeRenderingGroups and freeActiveMeshes several times to improve performance
  131665. * when disposing several meshes in a row or a hierarchy of meshes.
  131666. * When used, it is the responsability of the user to blockfreeActiveMeshesAndRenderingGroups back to false.
  131667. */
  131668. get: function () {
  131669. return this._preventFreeActiveMeshesAndRenderingGroups;
  131670. },
  131671. set: function (value) {
  131672. if (this._preventFreeActiveMeshesAndRenderingGroups === value) {
  131673. return;
  131674. }
  131675. if (value) {
  131676. this.freeActiveMeshes();
  131677. this.freeRenderingGroups();
  131678. }
  131679. this._preventFreeActiveMeshesAndRenderingGroups = value;
  131680. },
  131681. enumerable: true,
  131682. configurable: true
  131683. });
  131684. /**
  131685. * Clear the active meshes smart array preventing retention point in mesh dispose.
  131686. */
  131687. Scene.prototype.freeActiveMeshes = function () {
  131688. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  131689. return;
  131690. }
  131691. this._activeMeshes.dispose();
  131692. if (this.activeCamera && this.activeCamera._activeMeshes) {
  131693. this.activeCamera._activeMeshes.dispose();
  131694. }
  131695. if (this.activeCameras) {
  131696. for (var i = 0; i < this.activeCameras.length; i++) {
  131697. var activeCamera = this.activeCameras[i];
  131698. if (activeCamera && activeCamera._activeMeshes) {
  131699. activeCamera._activeMeshes.dispose();
  131700. }
  131701. }
  131702. }
  131703. };
  131704. /**
  131705. * Clear the info related to rendering groups preventing retention points during dispose.
  131706. */
  131707. Scene.prototype.freeRenderingGroups = function () {
  131708. if (this.blockfreeActiveMeshesAndRenderingGroups) {
  131709. return;
  131710. }
  131711. if (this._renderingManager) {
  131712. this._renderingManager.freeRenderingGroups();
  131713. }
  131714. if (this.textures) {
  131715. for (var i = 0; i < this.textures.length; i++) {
  131716. var texture = this.textures[i];
  131717. if (texture && texture.renderList) {
  131718. texture.freeRenderingGroups();
  131719. }
  131720. }
  131721. }
  131722. };
  131723. /** @hidden */
  131724. Scene.prototype._isInIntermediateRendering = function () {
  131725. return this._intermediateRendering;
  131726. };
  131727. /**
  131728. * Use this function to stop evaluating active meshes. The current list will be keep alive between frames
  131729. * @returns the current scene
  131730. */
  131731. Scene.prototype.freezeActiveMeshes = function () {
  131732. if (!this.activeCamera) {
  131733. return this;
  131734. }
  131735. if (!this._frustumPlanes) {
  131736. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131737. }
  131738. this._evaluateActiveMeshes();
  131739. this._activeMeshesFrozen = true;
  131740. return this;
  131741. };
  131742. /**
  131743. * Use this function to restart evaluating active meshes on every frame
  131744. * @returns the current scene
  131745. */
  131746. Scene.prototype.unfreezeActiveMeshes = function () {
  131747. this._activeMeshesFrozen = false;
  131748. return this;
  131749. };
  131750. Scene.prototype._evaluateActiveMeshes = function () {
  131751. if (this._activeMeshesFrozen && this._activeMeshes.length) {
  131752. return;
  131753. }
  131754. if (!this.activeCamera) {
  131755. return;
  131756. }
  131757. this.onBeforeActiveMeshesEvaluationObservable.notifyObservers(this);
  131758. this.activeCamera._activeMeshes.reset();
  131759. this._activeMeshes.reset();
  131760. this._renderingManager.reset();
  131761. this._processedMaterials.reset();
  131762. this._activeParticleSystems.reset();
  131763. this._activeSkeletons.reset();
  131764. this._softwareSkinnedMeshes.reset();
  131765. for (var _i = 0, _a = this._beforeEvaluateActiveMeshStage; _i < _a.length; _i++) {
  131766. var step = _a[_i];
  131767. step.action();
  131768. }
  131769. // Determine mesh candidates
  131770. var meshes = this.getActiveMeshCandidates();
  131771. // Check each mesh
  131772. var len = meshes.length;
  131773. for (var i = 0; i < len; i++) {
  131774. var mesh = meshes.data[i];
  131775. if (mesh.isBlocked) {
  131776. continue;
  131777. }
  131778. this._totalVertices.addCount(mesh.getTotalVertices(), false);
  131779. if (!mesh.isReady() || !mesh.isEnabled()) {
  131780. continue;
  131781. }
  131782. mesh.computeWorldMatrix();
  131783. // Intersections
  131784. if (mesh.actionManager && mesh.actionManager.hasSpecificTriggers2(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger, _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger)) {
  131785. this._meshesForIntersections.pushNoDuplicate(mesh);
  131786. }
  131787. // Switch to current LOD
  131788. var meshLOD = mesh.getLOD(this.activeCamera);
  131789. if (meshLOD === undefined || meshLOD === null) {
  131790. continue;
  131791. }
  131792. mesh._preActivate();
  131793. if (mesh.isVisible && mesh.visibility > 0 && ((mesh.layerMask & this.activeCamera.layerMask) !== 0) && (mesh.alwaysSelectAsActiveMesh || mesh.isInFrustum(this._frustumPlanes))) {
  131794. this._activeMeshes.push(mesh);
  131795. this.activeCamera._activeMeshes.push(mesh);
  131796. mesh._activate(this._renderId);
  131797. if (meshLOD !== mesh) {
  131798. meshLOD._activate(this._renderId);
  131799. }
  131800. this._activeMesh(mesh, meshLOD);
  131801. }
  131802. }
  131803. this.onAfterActiveMeshesEvaluationObservable.notifyObservers(this);
  131804. // Particle systems
  131805. if (this.particlesEnabled) {
  131806. this.onBeforeParticlesRenderingObservable.notifyObservers(this);
  131807. for (var particleIndex = 0; particleIndex < this.particleSystems.length; particleIndex++) {
  131808. var particleSystem = this.particleSystems[particleIndex];
  131809. if (!particleSystem.isStarted() || !particleSystem.emitter) {
  131810. continue;
  131811. }
  131812. var emitter = particleSystem.emitter;
  131813. if (!emitter.position || emitter.isEnabled()) {
  131814. this._activeParticleSystems.push(particleSystem);
  131815. particleSystem.animate();
  131816. this._renderingManager.dispatchParticles(particleSystem);
  131817. }
  131818. }
  131819. this.onAfterParticlesRenderingObservable.notifyObservers(this);
  131820. }
  131821. };
  131822. Scene.prototype._activeMesh = function (sourceMesh, mesh) {
  131823. if (this._skeletonsEnabled && mesh.skeleton !== null && mesh.skeleton !== undefined) {
  131824. if (this._activeSkeletons.pushNoDuplicate(mesh.skeleton)) {
  131825. mesh.skeleton.prepare();
  131826. }
  131827. if (!mesh.computeBonesUsingShaders) {
  131828. this._softwareSkinnedMeshes.pushNoDuplicate(mesh);
  131829. }
  131830. }
  131831. for (var _i = 0, _a = this._activeMeshStage; _i < _a.length; _i++) {
  131832. var step = _a[_i];
  131833. step.action(sourceMesh, mesh);
  131834. }
  131835. if (mesh !== undefined && mesh !== null
  131836. && mesh.subMeshes !== undefined && mesh.subMeshes !== null && mesh.subMeshes.length > 0) {
  131837. var subMeshes = this.getActiveSubMeshCandidates(mesh);
  131838. var len = subMeshes.length;
  131839. for (var i = 0; i < len; i++) {
  131840. var subMesh = subMeshes.data[i];
  131841. this._evaluateSubMesh(subMesh, mesh);
  131842. }
  131843. }
  131844. };
  131845. /**
  131846. * Update the transform matrix to update from the current active camera
  131847. * @param force defines a boolean used to force the update even if cache is up to date
  131848. */
  131849. Scene.prototype.updateTransformMatrix = function (force) {
  131850. if (!this.activeCamera) {
  131851. return;
  131852. }
  131853. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix(force));
  131854. };
  131855. /**
  131856. * Defines an alternate camera (used mostly in VR-like scenario where two cameras can render the same scene from a slightly different point of view)
  131857. * @param alternateCamera defines the camera to use
  131858. */
  131859. Scene.prototype.updateAlternateTransformMatrix = function (alternateCamera) {
  131860. this._setAlternateTransformMatrix(alternateCamera.getViewMatrix(), alternateCamera.getProjectionMatrix());
  131861. };
  131862. Scene.prototype._renderForCamera = function (camera, rigParent) {
  131863. if (camera && camera._skipRendering) {
  131864. return;
  131865. }
  131866. var engine = this._engine;
  131867. this.activeCamera = camera;
  131868. if (!this.activeCamera) {
  131869. throw new Error("Active camera not set");
  131870. }
  131871. // Viewport
  131872. engine.setViewport(this.activeCamera.viewport);
  131873. // Camera
  131874. this.resetCachedMaterial();
  131875. this._renderId++;
  131876. this.updateTransformMatrix();
  131877. if (camera._alternateCamera) {
  131878. this.updateAlternateTransformMatrix(camera._alternateCamera);
  131879. this._alternateRendering = true;
  131880. }
  131881. this.onBeforeCameraRenderObservable.notifyObservers(this.activeCamera);
  131882. // Meshes
  131883. this._evaluateActiveMeshes();
  131884. // Software skinning
  131885. for (var softwareSkinnedMeshIndex = 0; softwareSkinnedMeshIndex < this._softwareSkinnedMeshes.length; softwareSkinnedMeshIndex++) {
  131886. var mesh = this._softwareSkinnedMeshes.data[softwareSkinnedMeshIndex];
  131887. mesh.applySkeleton(mesh.skeleton);
  131888. }
  131889. // Render targets
  131890. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  131891. if (camera.customRenderTargets && camera.customRenderTargets.length > 0) {
  131892. this._renderTargets.concatWithNoDuplicate(camera.customRenderTargets);
  131893. }
  131894. if (rigParent && rigParent.customRenderTargets && rigParent.customRenderTargets.length > 0) {
  131895. this._renderTargets.concatWithNoDuplicate(rigParent.customRenderTargets);
  131896. }
  131897. // Collects render targets from external components.
  131898. for (var _i = 0, _a = this._gatherActiveCameraRenderTargetsStage; _i < _a.length; _i++) {
  131899. var step = _a[_i];
  131900. step.action(this._renderTargets);
  131901. }
  131902. if (this.renderTargetsEnabled) {
  131903. this._intermediateRendering = true;
  131904. if (this._renderTargets.length > 0) {
  131905. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131906. for (var renderIndex = 0; renderIndex < this._renderTargets.length; renderIndex++) {
  131907. var renderTarget = this._renderTargets.data[renderIndex];
  131908. if (renderTarget._shouldRender()) {
  131909. this._renderId++;
  131910. var hasSpecialRenderTargetCamera = renderTarget.activeCamera && renderTarget.activeCamera !== this.activeCamera;
  131911. renderTarget.render(hasSpecialRenderTargetCamera, this.dumpNextRenderTargets);
  131912. }
  131913. }
  131914. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Render targets", this._renderTargets.length > 0);
  131915. this._renderId++;
  131916. }
  131917. for (var _b = 0, _c = this._cameraDrawRenderTargetStage; _b < _c.length; _b++) {
  131918. var step = _c[_b];
  131919. step.action(this.activeCamera);
  131920. }
  131921. this._intermediateRendering = false;
  131922. if (this.activeCamera.outputRenderTarget) {
  131923. var internalTexture = this.activeCamera.outputRenderTarget.getInternalTexture();
  131924. if (internalTexture) {
  131925. engine.bindFramebuffer(internalTexture);
  131926. }
  131927. else {
  131928. _Misc_logger__WEBPACK_IMPORTED_MODULE_23__["Logger"].Error("Camera contains invalid customDefaultRenderTarget");
  131929. }
  131930. }
  131931. else {
  131932. engine.restoreDefaultFramebuffer(); // Restore back buffer if needed
  131933. }
  131934. }
  131935. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  131936. // Prepare Frame
  131937. if (this.postProcessManager) {
  131938. this.postProcessManager._prepareFrame();
  131939. }
  131940. // Before Camera Draw
  131941. for (var _d = 0, _e = this._beforeCameraDrawStage; _d < _e.length; _d++) {
  131942. var step = _e[_d];
  131943. step.action(this.activeCamera);
  131944. }
  131945. // Render
  131946. this.onBeforeDrawPhaseObservable.notifyObservers(this);
  131947. this._renderingManager.render(null, null, true, true);
  131948. this.onAfterDrawPhaseObservable.notifyObservers(this);
  131949. // After Camera Draw
  131950. for (var _f = 0, _g = this._afterCameraDrawStage; _f < _g.length; _f++) {
  131951. var step = _g[_f];
  131952. step.action(this.activeCamera);
  131953. }
  131954. // Finalize frame
  131955. if (this.postProcessManager) {
  131956. this.postProcessManager._finalizeFrame(camera.isIntermediate);
  131957. }
  131958. // Reset some special arrays
  131959. this._renderTargets.reset();
  131960. this._alternateRendering = false;
  131961. this.onAfterCameraRenderObservable.notifyObservers(this.activeCamera);
  131962. };
  131963. Scene.prototype._processSubCameras = function (camera) {
  131964. if (camera.cameraRigMode === _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  131965. this._renderForCamera(camera);
  131966. return;
  131967. }
  131968. // rig cameras
  131969. for (var index = 0; index < camera._rigCameras.length; index++) {
  131970. this._renderForCamera(camera._rigCameras[index], camera);
  131971. }
  131972. this.activeCamera = camera;
  131973. this.setTransformMatrix(this.activeCamera.getViewMatrix(), this.activeCamera.getProjectionMatrix());
  131974. };
  131975. Scene.prototype._checkIntersections = function () {
  131976. for (var index = 0; index < this._meshesForIntersections.length; index++) {
  131977. var sourceMesh = this._meshesForIntersections.data[index];
  131978. if (!sourceMesh.actionManager) {
  131979. continue;
  131980. }
  131981. for (var actionIndex = 0; actionIndex < sourceMesh.actionManager.actions.length; actionIndex++) {
  131982. var action = sourceMesh.actionManager.actions[actionIndex];
  131983. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131984. var parameters = action.getTriggerParameter();
  131985. var otherMesh = parameters instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameters : parameters.mesh;
  131986. var areIntersecting = otherMesh.intersectsMesh(sourceMesh, parameters.usePreciseIntersection);
  131987. var currentIntersectionInProgress = sourceMesh._intersectionsInProgress.indexOf(otherMesh);
  131988. if (areIntersecting && currentIntersectionInProgress === -1) {
  131989. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionEnterTrigger) {
  131990. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  131991. sourceMesh._intersectionsInProgress.push(otherMesh);
  131992. }
  131993. else if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  131994. sourceMesh._intersectionsInProgress.push(otherMesh);
  131995. }
  131996. }
  131997. else if (!areIntersecting && currentIntersectionInProgress > -1) {
  131998. //They intersected, and now they don't.
  131999. //is this trigger an exit trigger? execute an event.
  132000. if (action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132001. action._executeCurrent(_Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(sourceMesh, undefined, otherMesh));
  132002. }
  132003. //if this is an exit trigger, or no exit trigger exists, remove the id from the intersection in progress array.
  132004. if (!sourceMesh.actionManager.hasSpecificTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger, function (parameter) {
  132005. var parameterMesh = parameter instanceof _Meshes_abstractMesh__WEBPACK_IMPORTED_MODULE_8__["AbstractMesh"] ? parameter : parameter.mesh;
  132006. return otherMesh === parameterMesh;
  132007. }) || action.trigger === _Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnIntersectionExitTrigger) {
  132008. sourceMesh._intersectionsInProgress.splice(currentIntersectionInProgress, 1);
  132009. }
  132010. }
  132011. }
  132012. }
  132013. }
  132014. };
  132015. /** @hidden */
  132016. Scene.prototype._advancePhysicsEngineStep = function (step) {
  132017. // Do nothing. Code will be replaced if physics engine component is referenced
  132018. };
  132019. /** @hidden */
  132020. Scene.prototype._animate = function () {
  132021. // Nothing to do as long as Animatable have not been imported.
  132022. };
  132023. /**
  132024. * Render the scene
  132025. * @param updateCameras defines a boolean indicating if cameras must update according to their inputs (true by default)
  132026. */
  132027. Scene.prototype.render = function (updateCameras) {
  132028. if (updateCameras === void 0) { updateCameras = true; }
  132029. if (this.isDisposed) {
  132030. return;
  132031. }
  132032. this._frameId++;
  132033. // Register components that have been associated lately to the scene.
  132034. this._registerTransientComponents();
  132035. this._activeParticles.fetchNewFrame();
  132036. this._totalVertices.fetchNewFrame();
  132037. this._activeIndices.fetchNewFrame();
  132038. this._activeBones.fetchNewFrame();
  132039. this._meshesForIntersections.reset();
  132040. this.resetCachedMaterial();
  132041. this.onBeforeAnimationsObservable.notifyObservers(this);
  132042. // Actions
  132043. if (this.actionManager) {
  132044. this.actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnEveryFrameTrigger);
  132045. }
  132046. if (this._engine.isDeterministicLockStep()) {
  132047. var deltaTime = Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime)) + this._timeAccumulator;
  132048. var defaultFPS = (60.0 / 1000.0);
  132049. var defaultFrameTime = this.getDeterministicFrameTime();
  132050. var stepsTaken = 0;
  132051. var maxSubSteps = this._engine.getLockstepMaxSteps();
  132052. var internalSteps = Math.floor(deltaTime / (1000 * defaultFPS));
  132053. internalSteps = Math.min(internalSteps, maxSubSteps);
  132054. do {
  132055. this.onBeforeStepObservable.notifyObservers(this);
  132056. // Animations
  132057. this._animationRatio = defaultFrameTime * defaultFPS;
  132058. this._animate();
  132059. this.onAfterAnimationsObservable.notifyObservers(this);
  132060. // Physics
  132061. this._advancePhysicsEngineStep(defaultFrameTime);
  132062. this.onAfterStepObservable.notifyObservers(this);
  132063. this._currentStepId++;
  132064. stepsTaken++;
  132065. deltaTime -= defaultFrameTime;
  132066. } while (deltaTime > 0 && stepsTaken < internalSteps);
  132067. this._timeAccumulator = deltaTime < 0 ? 0 : deltaTime;
  132068. }
  132069. else {
  132070. // Animations
  132071. var deltaTime = this.useConstantAnimationDeltaTime ? 16 : Math.max(Scene.MinDeltaTime, Math.min(this._engine.getDeltaTime(), Scene.MaxDeltaTime));
  132072. this._animationRatio = deltaTime * (60.0 / 1000.0);
  132073. this._animate();
  132074. this.onAfterAnimationsObservable.notifyObservers(this);
  132075. // Physics
  132076. this._advancePhysicsEngineStep(deltaTime);
  132077. }
  132078. // Before camera update steps
  132079. for (var _i = 0, _a = this._beforeCameraUpdateStage; _i < _a.length; _i++) {
  132080. var step = _a[_i];
  132081. step.action();
  132082. }
  132083. // Update Cameras
  132084. if (updateCameras) {
  132085. if (this.activeCameras.length > 0) {
  132086. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  132087. var camera = this.activeCameras[cameraIndex];
  132088. camera.update();
  132089. if (camera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  132090. // rig cameras
  132091. for (var index = 0; index < camera._rigCameras.length; index++) {
  132092. camera._rigCameras[index].update();
  132093. }
  132094. }
  132095. }
  132096. }
  132097. else if (this.activeCamera) {
  132098. this.activeCamera.update();
  132099. if (this.activeCamera.cameraRigMode !== _Cameras_camera__WEBPACK_IMPORTED_MODULE_9__["Camera"].RIG_MODE_NONE) {
  132100. // rig cameras
  132101. for (var index = 0; index < this.activeCamera._rigCameras.length; index++) {
  132102. this.activeCamera._rigCameras[index].update();
  132103. }
  132104. }
  132105. }
  132106. }
  132107. // Before render
  132108. this.onBeforeRenderObservable.notifyObservers(this);
  132109. // Customs render targets
  132110. this.onBeforeRenderTargetsRenderObservable.notifyObservers(this);
  132111. var engine = this.getEngine();
  132112. var currentActiveCamera = this.activeCamera;
  132113. if (this.renderTargetsEnabled) {
  132114. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].StartPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  132115. this._intermediateRendering = true;
  132116. for (var customIndex = 0; customIndex < this.customRenderTargets.length; customIndex++) {
  132117. var renderTarget = this.customRenderTargets[customIndex];
  132118. if (renderTarget._shouldRender()) {
  132119. this._renderId++;
  132120. this.activeCamera = renderTarget.activeCamera || this.activeCamera;
  132121. if (!this.activeCamera) {
  132122. throw new Error("Active camera not set");
  132123. }
  132124. // Viewport
  132125. engine.setViewport(this.activeCamera.viewport);
  132126. // Camera
  132127. this.updateTransformMatrix();
  132128. renderTarget.render(currentActiveCamera !== this.activeCamera, this.dumpNextRenderTargets);
  132129. }
  132130. }
  132131. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].EndPerformanceCounter("Custom render targets", this.customRenderTargets.length > 0);
  132132. this._intermediateRendering = false;
  132133. this._renderId++;
  132134. }
  132135. // Restore back buffer
  132136. if (this.customRenderTargets.length > 0) {
  132137. engine.restoreDefaultFramebuffer();
  132138. }
  132139. this.onAfterRenderTargetsRenderObservable.notifyObservers(this);
  132140. this.activeCamera = currentActiveCamera;
  132141. for (var _b = 0, _c = this._beforeClearStage; _b < _c.length; _b++) {
  132142. var step = _c[_b];
  132143. step.action();
  132144. }
  132145. // Clear
  132146. if (this.autoClearDepthAndStencil || this.autoClear) {
  132147. this._engine.clear(this.clearColor, this.autoClear || this.forceWireframe || this.forcePointsCloud, this.autoClearDepthAndStencil, this.autoClearDepthAndStencil);
  132148. }
  132149. // Collects render targets from external components.
  132150. for (var _d = 0, _e = this._gatherRenderTargetsStage; _d < _e.length; _d++) {
  132151. var step = _e[_d];
  132152. step.action(this._renderTargets);
  132153. }
  132154. // Multi-cameras?
  132155. if (this.activeCameras.length > 0) {
  132156. for (var cameraIndex = 0; cameraIndex < this.activeCameras.length; cameraIndex++) {
  132157. if (cameraIndex > 0) {
  132158. this._engine.clear(null, false, true, true);
  132159. }
  132160. this._processSubCameras(this.activeCameras[cameraIndex]);
  132161. }
  132162. }
  132163. else {
  132164. if (!this.activeCamera) {
  132165. throw new Error("No camera defined");
  132166. }
  132167. this._processSubCameras(this.activeCamera);
  132168. }
  132169. // Intersection checks
  132170. this._checkIntersections();
  132171. // Executes the after render stage actions.
  132172. for (var _f = 0, _g = this._afterRenderStage; _f < _g.length; _f++) {
  132173. var step = _g[_f];
  132174. step.action();
  132175. }
  132176. // After render
  132177. if (this.afterRender) {
  132178. this.afterRender();
  132179. }
  132180. this.onAfterRenderObservable.notifyObservers(this);
  132181. // Cleaning
  132182. if (this._toBeDisposed.length) {
  132183. for (var index = 0; index < this._toBeDisposed.length; index++) {
  132184. var data = this._toBeDisposed[index];
  132185. if (data) {
  132186. data.dispose();
  132187. }
  132188. }
  132189. this._toBeDisposed = [];
  132190. }
  132191. if (this.dumpNextRenderTargets) {
  132192. this.dumpNextRenderTargets = false;
  132193. }
  132194. this._activeBones.addCount(0, true);
  132195. this._activeIndices.addCount(0, true);
  132196. this._activeParticles.addCount(0, true);
  132197. };
  132198. /**
  132199. * Freeze all materials
  132200. * A frozen material will not be updatable but should be faster to render
  132201. */
  132202. Scene.prototype.freezeMaterials = function () {
  132203. for (var i = 0; i < this.materials.length; i++) {
  132204. this.materials[i].freeze();
  132205. }
  132206. };
  132207. /**
  132208. * Unfreeze all materials
  132209. * A frozen material will not be updatable but should be faster to render
  132210. */
  132211. Scene.prototype.unfreezeMaterials = function () {
  132212. for (var i = 0; i < this.materials.length; i++) {
  132213. this.materials[i].unfreeze();
  132214. }
  132215. };
  132216. /**
  132217. * Releases all held ressources
  132218. */
  132219. Scene.prototype.dispose = function () {
  132220. this.beforeRender = null;
  132221. this.afterRender = null;
  132222. this.skeletons = [];
  132223. this.morphTargetManagers = [];
  132224. this._transientComponents = [];
  132225. this._isReadyForMeshStage.clear();
  132226. this._beforeEvaluateActiveMeshStage.clear();
  132227. this._evaluateSubMeshStage.clear();
  132228. this._activeMeshStage.clear();
  132229. this._cameraDrawRenderTargetStage.clear();
  132230. this._beforeCameraDrawStage.clear();
  132231. this._beforeRenderTargetDrawStage.clear();
  132232. this._beforeRenderingGroupDrawStage.clear();
  132233. this._beforeRenderingMeshStage.clear();
  132234. this._afterRenderingMeshStage.clear();
  132235. this._afterRenderingGroupDrawStage.clear();
  132236. this._afterCameraDrawStage.clear();
  132237. this._afterRenderTargetDrawStage.clear();
  132238. this._afterRenderStage.clear();
  132239. this._beforeCameraUpdateStage.clear();
  132240. this._beforeClearStage.clear();
  132241. this._gatherRenderTargetsStage.clear();
  132242. this._gatherActiveCameraRenderTargetsStage.clear();
  132243. this._pointerMoveStage.clear();
  132244. this._pointerDownStage.clear();
  132245. this._pointerUpStage.clear();
  132246. for (var _i = 0, _a = this._components; _i < _a.length; _i++) {
  132247. var component = _a[_i];
  132248. component.dispose();
  132249. }
  132250. this.importedMeshesFiles = new Array();
  132251. this.stopAllAnimations();
  132252. this.resetCachedMaterial();
  132253. // Smart arrays
  132254. if (this.activeCamera) {
  132255. this.activeCamera._activeMeshes.dispose();
  132256. this.activeCamera = null;
  132257. }
  132258. this._activeMeshes.dispose();
  132259. this._renderingManager.dispose();
  132260. this._processedMaterials.dispose();
  132261. this._activeParticleSystems.dispose();
  132262. this._activeSkeletons.dispose();
  132263. this._softwareSkinnedMeshes.dispose();
  132264. this._renderTargets.dispose();
  132265. this._registeredForLateAnimationBindings.dispose();
  132266. this._meshesForIntersections.dispose();
  132267. this._toBeDisposed = [];
  132268. // Abort active requests
  132269. for (var _b = 0, _c = this._activeRequests; _b < _c.length; _b++) {
  132270. var request = _c[_b];
  132271. request.abort();
  132272. }
  132273. // Events
  132274. this.onDisposeObservable.notifyObservers(this);
  132275. this.onDisposeObservable.clear();
  132276. this.onBeforeRenderObservable.clear();
  132277. this.onAfterRenderObservable.clear();
  132278. this.onBeforeRenderTargetsRenderObservable.clear();
  132279. this.onAfterRenderTargetsRenderObservable.clear();
  132280. this.onAfterStepObservable.clear();
  132281. this.onBeforeStepObservable.clear();
  132282. this.onBeforeActiveMeshesEvaluationObservable.clear();
  132283. this.onAfterActiveMeshesEvaluationObservable.clear();
  132284. this.onBeforeParticlesRenderingObservable.clear();
  132285. this.onAfterParticlesRenderingObservable.clear();
  132286. this.onBeforeDrawPhaseObservable.clear();
  132287. this.onAfterDrawPhaseObservable.clear();
  132288. this.onBeforeAnimationsObservable.clear();
  132289. this.onAfterAnimationsObservable.clear();
  132290. this.onDataLoadedObservable.clear();
  132291. this.onBeforeRenderingGroupObservable.clear();
  132292. this.onAfterRenderingGroupObservable.clear();
  132293. this.onMeshImportedObservable.clear();
  132294. this.onBeforeCameraRenderObservable.clear();
  132295. this.onAfterCameraRenderObservable.clear();
  132296. this.onReadyObservable.clear();
  132297. this.onNewCameraAddedObservable.clear();
  132298. this.onCameraRemovedObservable.clear();
  132299. this.onNewLightAddedObservable.clear();
  132300. this.onLightRemovedObservable.clear();
  132301. this.onNewGeometryAddedObservable.clear();
  132302. this.onGeometryRemovedObservable.clear();
  132303. this.onNewTransformNodeAddedObservable.clear();
  132304. this.onTransformNodeRemovedObservable.clear();
  132305. this.onNewMeshAddedObservable.clear();
  132306. this.onMeshRemovedObservable.clear();
  132307. this.onNewMaterialAddedObservable.clear();
  132308. this.onMaterialRemovedObservable.clear();
  132309. this.onNewTextureAddedObservable.clear();
  132310. this.onTextureRemovedObservable.clear();
  132311. this.onPrePointerObservable.clear();
  132312. this.onPointerObservable.clear();
  132313. this.onPreKeyboardObservable.clear();
  132314. this.onKeyboardObservable.clear();
  132315. this.onActiveCameraChanged.clear();
  132316. this.detachControl();
  132317. // Detach cameras
  132318. var canvas = this._engine.getRenderingCanvas();
  132319. if (canvas) {
  132320. var index;
  132321. for (index = 0; index < this.cameras.length; index++) {
  132322. this.cameras[index].detachControl(canvas);
  132323. }
  132324. }
  132325. // Release animation groups
  132326. while (this.animationGroups.length) {
  132327. this.animationGroups[0].dispose();
  132328. }
  132329. // Release lights
  132330. while (this.lights.length) {
  132331. this.lights[0].dispose();
  132332. }
  132333. // Release meshes
  132334. while (this.meshes.length) {
  132335. this.meshes[0].dispose(true);
  132336. }
  132337. while (this.transformNodes.length) {
  132338. this.removeTransformNode(this.transformNodes[0]);
  132339. }
  132340. // Release cameras
  132341. while (this.cameras.length) {
  132342. this.cameras[0].dispose();
  132343. }
  132344. // Release materials
  132345. if (this.defaultMaterial) {
  132346. this.defaultMaterial.dispose();
  132347. }
  132348. while (this.multiMaterials.length) {
  132349. this.multiMaterials[0].dispose();
  132350. }
  132351. while (this.materials.length) {
  132352. this.materials[0].dispose();
  132353. }
  132354. // Release particles
  132355. while (this.particleSystems.length) {
  132356. this.particleSystems[0].dispose();
  132357. }
  132358. // Release postProcesses
  132359. while (this.postProcesses.length) {
  132360. this.postProcesses[0].dispose();
  132361. }
  132362. // Release textures
  132363. while (this.textures.length) {
  132364. this.textures[0].dispose();
  132365. }
  132366. // Release UBO
  132367. this._sceneUbo.dispose();
  132368. if (this._alternateSceneUbo) {
  132369. this._alternateSceneUbo.dispose();
  132370. }
  132371. // Post-processes
  132372. this.postProcessManager.dispose();
  132373. // Remove from engine
  132374. index = this._engine.scenes.indexOf(this);
  132375. if (index > -1) {
  132376. this._engine.scenes.splice(index, 1);
  132377. }
  132378. this._engine.wipeCaches(true);
  132379. this._isDisposed = true;
  132380. };
  132381. Object.defineProperty(Scene.prototype, "isDisposed", {
  132382. /**
  132383. * Gets if the scene is already disposed
  132384. */
  132385. get: function () {
  132386. return this._isDisposed;
  132387. },
  132388. enumerable: true,
  132389. configurable: true
  132390. });
  132391. /**
  132392. * Call this function to reduce memory footprint of the scene.
  132393. * Vertex buffers will not store CPU data anymore (this will prevent picking, collisions or physics to work correctly)
  132394. */
  132395. Scene.prototype.clearCachedVertexData = function () {
  132396. for (var meshIndex = 0; meshIndex < this.meshes.length; meshIndex++) {
  132397. var mesh = this.meshes[meshIndex];
  132398. var geometry = mesh.geometry;
  132399. if (geometry) {
  132400. geometry._indices = [];
  132401. for (var vbName in geometry._vertexBuffers) {
  132402. if (!geometry._vertexBuffers.hasOwnProperty(vbName)) {
  132403. continue;
  132404. }
  132405. geometry._vertexBuffers[vbName]._buffer._data = null;
  132406. }
  132407. }
  132408. }
  132409. };
  132410. /**
  132411. * This function will remove the local cached buffer data from texture.
  132412. * It will save memory but will prevent the texture from being rebuilt
  132413. */
  132414. Scene.prototype.cleanCachedTextureBuffer = function () {
  132415. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  132416. var baseTexture = _a[_i];
  132417. var buffer = baseTexture._buffer;
  132418. if (buffer) {
  132419. baseTexture._buffer = null;
  132420. }
  132421. }
  132422. };
  132423. /**
  132424. * Get the world extend vectors with an optional filter
  132425. *
  132426. * @param filterPredicate the predicate - which meshes should be included when calculating the world size
  132427. * @returns {{ min: Vector3; max: Vector3 }} min and max vectors
  132428. */
  132429. Scene.prototype.getWorldExtends = function (filterPredicate) {
  132430. var min = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](Number.MAX_VALUE, Number.MAX_VALUE, Number.MAX_VALUE);
  132431. var max = new _Maths_math__WEBPACK_IMPORTED_MODULE_7__["Vector3"](-Number.MAX_VALUE, -Number.MAX_VALUE, -Number.MAX_VALUE);
  132432. filterPredicate = filterPredicate || (function () { return true; });
  132433. this.meshes.filter(filterPredicate).forEach(function (mesh) {
  132434. mesh.computeWorldMatrix(true);
  132435. if (!mesh.subMeshes || mesh.subMeshes.length === 0 || mesh.infiniteDistance) {
  132436. return;
  132437. }
  132438. var boundingInfo = mesh.getBoundingInfo();
  132439. var minBox = boundingInfo.boundingBox.minimumWorld;
  132440. var maxBox = boundingInfo.boundingBox.maximumWorld;
  132441. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(minBox, min, max);
  132442. _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].CheckExtends(maxBox, min, max);
  132443. });
  132444. return {
  132445. min: min,
  132446. max: max
  132447. };
  132448. };
  132449. // Picking
  132450. /**
  132451. * Creates a ray that can be used to pick in the scene
  132452. * @param x defines the x coordinate of the origin (on-screen)
  132453. * @param y defines the y coordinate of the origin (on-screen)
  132454. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132455. * @param camera defines the camera to use for the picking
  132456. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132457. * @returns a Ray
  132458. */
  132459. Scene.prototype.createPickingRay = function (x, y, world, camera, cameraViewSpace) {
  132460. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  132461. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132462. };
  132463. /**
  132464. * Creates a ray that can be used to pick in the scene
  132465. * @param x defines the x coordinate of the origin (on-screen)
  132466. * @param y defines the y coordinate of the origin (on-screen)
  132467. * @param world defines the world matrix to use if you want to pick in object space (instead of world space)
  132468. * @param result defines the ray where to store the picking ray
  132469. * @param camera defines the camera to use for the picking
  132470. * @param cameraViewSpace defines if picking will be done in view space (false by default)
  132471. * @returns the current scene
  132472. */
  132473. Scene.prototype.createPickingRayToRef = function (x, y, world, result, camera, cameraViewSpace) {
  132474. if (cameraViewSpace === void 0) { cameraViewSpace = false; }
  132475. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132476. };
  132477. /**
  132478. * Creates a ray that can be used to pick in the scene
  132479. * @param x defines the x coordinate of the origin (on-screen)
  132480. * @param y defines the y coordinate of the origin (on-screen)
  132481. * @param camera defines the camera to use for the picking
  132482. * @returns a Ray
  132483. */
  132484. Scene.prototype.createPickingRayInCameraSpace = function (x, y, camera) {
  132485. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132486. };
  132487. /**
  132488. * Creates a ray that can be used to pick in the scene
  132489. * @param x defines the x coordinate of the origin (on-screen)
  132490. * @param y defines the y coordinate of the origin (on-screen)
  132491. * @param result defines the ray where to store the picking ray
  132492. * @param camera defines the camera to use for the picking
  132493. * @returns the current scene
  132494. */
  132495. Scene.prototype.createPickingRayInCameraSpaceToRef = function (x, y, result, camera) {
  132496. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132497. };
  132498. /** Launch a ray to try to pick a mesh in the scene
  132499. * @param x position on screen
  132500. * @param y position on screen
  132501. * @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
  132502. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null.
  132503. * @param camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132504. * @returns a PickingInfo
  132505. */
  132506. Scene.prototype.pick = function (x, y, predicate, fastCheck, camera) {
  132507. // Dummy info if picking as not been imported
  132508. var pi = new _Collisions_pickingInfo__WEBPACK_IMPORTED_MODULE_14__["PickingInfo"]();
  132509. pi._pickingUnavailable = true;
  132510. return pi;
  132511. };
  132512. /** Use the given ray to pick a mesh in the scene
  132513. * @param ray The ray to use to pick meshes
  132514. * @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
  132515. * @param fastCheck Launch a fast check only using the bounding boxes. Can be set to null
  132516. * @returns a PickingInfo
  132517. */
  132518. Scene.prototype.pickWithRay = function (ray, predicate, fastCheck) {
  132519. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132520. };
  132521. /**
  132522. * Launch a ray to try to pick a mesh in the scene
  132523. * @param x X position on screen
  132524. * @param y Y position on screen
  132525. * @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
  132526. * @param camera camera to use for computing the picking ray. Can be set to null. In this case, the scene.activeCamera will be used
  132527. * @returns an array of PickingInfo
  132528. */
  132529. Scene.prototype.multiPick = function (x, y, predicate, camera) {
  132530. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132531. };
  132532. /**
  132533. * Launch a ray to try to pick a mesh in the scene
  132534. * @param ray Ray to use
  132535. * @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
  132536. * @returns an array of PickingInfo
  132537. */
  132538. Scene.prototype.multiPickWithRay = function (ray, predicate) {
  132539. throw _Misc_devTools__WEBPACK_IMPORTED_MODULE_26__["_DevTools"].WarnImport("Ray");
  132540. };
  132541. /**
  132542. * Force the value of meshUnderPointer
  132543. * @param mesh defines the mesh to use
  132544. */
  132545. Scene.prototype.setPointerOverMesh = function (mesh) {
  132546. if (this._pointerOverMesh === mesh) {
  132547. return;
  132548. }
  132549. var actionManager;
  132550. if (this._pointerOverMesh) {
  132551. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger);
  132552. if (actionManager) {
  132553. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOutTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  132554. }
  132555. }
  132556. this._pointerOverMesh = mesh;
  132557. if (this._pointerOverMesh) {
  132558. actionManager = this._pointerOverMesh._getActionManagerForTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger);
  132559. if (actionManager) {
  132560. actionManager.processTrigger(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].ACTION_OnPointerOverTrigger, _Actions_actionEvent__WEBPACK_IMPORTED_MODULE_17__["ActionEvent"].CreateNew(this._pointerOverMesh));
  132561. }
  132562. }
  132563. };
  132564. /**
  132565. * Gets the mesh under the pointer
  132566. * @returns a Mesh or null if no mesh is under the pointer
  132567. */
  132568. Scene.prototype.getPointerOverMesh = function () {
  132569. return this._pointerOverMesh;
  132570. };
  132571. // Misc.
  132572. /** @hidden */
  132573. Scene.prototype._rebuildGeometries = function () {
  132574. for (var _i = 0, _a = this.geometries; _i < _a.length; _i++) {
  132575. var geometry = _a[_i];
  132576. geometry._rebuild();
  132577. }
  132578. for (var _b = 0, _c = this.meshes; _b < _c.length; _b++) {
  132579. var mesh = _c[_b];
  132580. mesh._rebuild();
  132581. }
  132582. if (this.postProcessManager) {
  132583. this.postProcessManager._rebuild();
  132584. }
  132585. for (var _d = 0, _e = this._components; _d < _e.length; _d++) {
  132586. var component = _e[_d];
  132587. component.rebuild();
  132588. }
  132589. for (var _f = 0, _g = this.particleSystems; _f < _g.length; _f++) {
  132590. var system = _g[_f];
  132591. system.rebuild();
  132592. }
  132593. };
  132594. /** @hidden */
  132595. Scene.prototype._rebuildTextures = function () {
  132596. for (var _i = 0, _a = this.textures; _i < _a.length; _i++) {
  132597. var texture = _a[_i];
  132598. texture._rebuild();
  132599. }
  132600. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_TextureDirtyFlag);
  132601. };
  132602. // Tags
  132603. Scene.prototype._getByTags = function (list, tagsQuery, forEach) {
  132604. if (tagsQuery === undefined) {
  132605. // returns the complete list (could be done with Tags.MatchesQuery but no need to have a for-loop here)
  132606. return list;
  132607. }
  132608. var listByTags = [];
  132609. forEach = forEach || (function (item) { return; });
  132610. for (var i in list) {
  132611. var item = list[i];
  132612. if (_Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"] && _Misc_tags__WEBPACK_IMPORTED_MODULE_6__["Tags"].MatchesQuery(item, tagsQuery)) {
  132613. listByTags.push(item);
  132614. forEach(item);
  132615. }
  132616. }
  132617. return listByTags;
  132618. };
  132619. /**
  132620. * Get a list of meshes by tags
  132621. * @param tagsQuery defines the tags query to use
  132622. * @param forEach defines a predicate used to filter results
  132623. * @returns an array of Mesh
  132624. */
  132625. Scene.prototype.getMeshesByTags = function (tagsQuery, forEach) {
  132626. return this._getByTags(this.meshes, tagsQuery, forEach);
  132627. };
  132628. /**
  132629. * Get a list of cameras by tags
  132630. * @param tagsQuery defines the tags query to use
  132631. * @param forEach defines a predicate used to filter results
  132632. * @returns an array of Camera
  132633. */
  132634. Scene.prototype.getCamerasByTags = function (tagsQuery, forEach) {
  132635. return this._getByTags(this.cameras, tagsQuery, forEach);
  132636. };
  132637. /**
  132638. * Get a list of lights by tags
  132639. * @param tagsQuery defines the tags query to use
  132640. * @param forEach defines a predicate used to filter results
  132641. * @returns an array of Light
  132642. */
  132643. Scene.prototype.getLightsByTags = function (tagsQuery, forEach) {
  132644. return this._getByTags(this.lights, tagsQuery, forEach);
  132645. };
  132646. /**
  132647. * Get a list of materials by tags
  132648. * @param tagsQuery defines the tags query to use
  132649. * @param forEach defines a predicate used to filter results
  132650. * @returns an array of Material
  132651. */
  132652. Scene.prototype.getMaterialByTags = function (tagsQuery, forEach) {
  132653. return this._getByTags(this.materials, tagsQuery, forEach).concat(this._getByTags(this.multiMaterials, tagsQuery, forEach));
  132654. };
  132655. /**
  132656. * Overrides the default sort function applied in the renderging group to prepare the meshes.
  132657. * This allowed control for front to back rendering or reversly depending of the special needs.
  132658. *
  132659. * @param renderingGroupId The rendering group id corresponding to its index
  132660. * @param opaqueSortCompareFn The opaque queue comparison function use to sort.
  132661. * @param alphaTestSortCompareFn The alpha test queue comparison function use to sort.
  132662. * @param transparentSortCompareFn The transparent queue comparison function use to sort.
  132663. */
  132664. Scene.prototype.setRenderingOrder = function (renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn) {
  132665. if (opaqueSortCompareFn === void 0) { opaqueSortCompareFn = null; }
  132666. if (alphaTestSortCompareFn === void 0) { alphaTestSortCompareFn = null; }
  132667. if (transparentSortCompareFn === void 0) { transparentSortCompareFn = null; }
  132668. this._renderingManager.setRenderingOrder(renderingGroupId, opaqueSortCompareFn, alphaTestSortCompareFn, transparentSortCompareFn);
  132669. };
  132670. /**
  132671. * Specifies whether or not the stencil and depth buffer are cleared between two rendering groups.
  132672. *
  132673. * @param renderingGroupId The rendering group id corresponding to its index
  132674. * @param autoClearDepthStencil Automatically clears depth and stencil between groups if true.
  132675. * @param depth Automatically clears depth between groups if true and autoClear is true.
  132676. * @param stencil Automatically clears stencil between groups if true and autoClear is true.
  132677. */
  132678. Scene.prototype.setRenderingAutoClearDepthStencil = function (renderingGroupId, autoClearDepthStencil, depth, stencil) {
  132679. if (depth === void 0) { depth = true; }
  132680. if (stencil === void 0) { stencil = true; }
  132681. this._renderingManager.setRenderingAutoClearDepthStencil(renderingGroupId, autoClearDepthStencil, depth, stencil);
  132682. };
  132683. /**
  132684. * Gets the current auto clear configuration for one rendering group of the rendering
  132685. * manager.
  132686. * @param index the rendering group index to get the information for
  132687. * @returns The auto clear setup for the requested rendering group
  132688. */
  132689. Scene.prototype.getAutoClearDepthStencilSetup = function (index) {
  132690. return this._renderingManager.getAutoClearDepthStencilSetup(index);
  132691. };
  132692. Object.defineProperty(Scene.prototype, "blockMaterialDirtyMechanism", {
  132693. /** Gets or sets a boolean blocking all the calls to markAllMaterialsAsDirty (ie. the materials won't be updated if they are out of sync) */
  132694. get: function () {
  132695. return this._blockMaterialDirtyMechanism;
  132696. },
  132697. set: function (value) {
  132698. if (this._blockMaterialDirtyMechanism === value) {
  132699. return;
  132700. }
  132701. this._blockMaterialDirtyMechanism = value;
  132702. if (!value) { // Do a complete update
  132703. this.markAllMaterialsAsDirty(_Engines_constants__WEBPACK_IMPORTED_MODULE_21__["Constants"].MATERIAL_AllDirtyFlag);
  132704. }
  132705. },
  132706. enumerable: true,
  132707. configurable: true
  132708. });
  132709. /**
  132710. * Will flag all materials as dirty to trigger new shader compilation
  132711. * @param flag defines the flag used to specify which material part must be marked as dirty
  132712. * @param predicate If not null, it will be used to specifiy if a material has to be marked as dirty
  132713. */
  132714. Scene.prototype.markAllMaterialsAsDirty = function (flag, predicate) {
  132715. if (this._blockMaterialDirtyMechanism) {
  132716. return;
  132717. }
  132718. for (var _i = 0, _a = this.materials; _i < _a.length; _i++) {
  132719. var material = _a[_i];
  132720. if (predicate && !predicate(material)) {
  132721. continue;
  132722. }
  132723. material.markAsDirty(flag);
  132724. }
  132725. };
  132726. /** @hidden */
  132727. Scene.prototype._loadFile = function (url, onSuccess, onProgress, useOfflineSupport, useArrayBuffer, onError) {
  132728. var _this = this;
  132729. var request = _Misc_tools__WEBPACK_IMPORTED_MODULE_1__["Tools"].LoadFile(url, onSuccess, onProgress, useOfflineSupport ? this.offlineProvider : undefined, useArrayBuffer, onError);
  132730. this._activeRequests.push(request);
  132731. request.onCompleteObservable.add(function (request) {
  132732. _this._activeRequests.splice(_this._activeRequests.indexOf(request), 1);
  132733. });
  132734. return request;
  132735. };
  132736. /** @hidden */
  132737. Scene.prototype._loadFileAsync = function (url, useOfflineSupport, useArrayBuffer) {
  132738. var _this = this;
  132739. return new Promise(function (resolve, reject) {
  132740. _this._loadFile(url, function (data) {
  132741. resolve(data);
  132742. }, undefined, useOfflineSupport, useArrayBuffer, function (request, exception) {
  132743. reject(exception);
  132744. });
  132745. });
  132746. };
  132747. // Statics
  132748. Scene._uniqueIdCounter = 0;
  132749. /** The fog is deactivated */
  132750. Scene.FOGMODE_NONE = 0;
  132751. /** The fog density is following an exponential function */
  132752. Scene.FOGMODE_EXP = 1;
  132753. /** The fog density is following an exponential function faster than FOGMODE_EXP */
  132754. Scene.FOGMODE_EXP2 = 2;
  132755. /** The fog density is following a linear function. */
  132756. Scene.FOGMODE_LINEAR = 3;
  132757. /**
  132758. * Gets or sets the minimum deltatime when deterministic lock step is enabled
  132759. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132760. */
  132761. Scene.MinDeltaTime = 1.0;
  132762. /**
  132763. * Gets or sets the maximum deltatime when deterministic lock step is enabled
  132764. * @see http://doc.babylonjs.com/babylon101/animations#deterministic-lockstep
  132765. */
  132766. Scene.MaxDeltaTime = 1000.0;
  132767. /** The distance in pixel that you have to move to prevent some events */
  132768. Scene.DragMovementThreshold = 10; // in pixels
  132769. /** Time in milliseconds to wait to raise long press events if button is still pressed */
  132770. Scene.LongPressDelay = 500; // in milliseconds
  132771. /** Time in milliseconds with two consecutive clicks will be considered as a double click */
  132772. Scene.DoubleClickDelay = 300; // in milliseconds
  132773. /** If you need to check double click without raising a single click at first click, enable this flag */
  132774. Scene.ExclusiveDoubleClickMode = false;
  132775. return Scene;
  132776. }(_abstractScene__WEBPACK_IMPORTED_MODULE_10__["AbstractScene"]));
  132777. /***/ }),
  132778. /***/ "./sceneComponent.ts":
  132779. /*!***************************!*\
  132780. !*** ./sceneComponent.ts ***!
  132781. \***************************/
  132782. /*! exports provided: SceneComponentConstants, Stage */
  132783. /***/ (function(module, __webpack_exports__, __webpack_require__) {
  132784. "use strict";
  132785. __webpack_require__.r(__webpack_exports__);
  132786. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SceneComponentConstants", function() { return SceneComponentConstants; });
  132787. /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Stage", function() { return Stage; });
  132788. /* harmony import */ var tslib__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! tslib */ "../node_modules/tslib/tslib.es6.js");
  132789. /**
  132790. * Groups all the scene component constants in one place to ease maintenance.
  132791. * @hidden
  132792. */
  132793. var SceneComponentConstants = /** @class */ (function () {
  132794. function SceneComponentConstants() {
  132795. }
  132796. SceneComponentConstants.NAME_EFFECTLAYER = "EffectLayer";
  132797. SceneComponentConstants.NAME_LAYER = "Layer";
  132798. SceneComponentConstants.NAME_LENSFLARESYSTEM = "LensFlareSystem";
  132799. SceneComponentConstants.NAME_BOUNDINGBOXRENDERER = "BoundingBoxRenderer";
  132800. SceneComponentConstants.NAME_PARTICLESYSTEM = "ParticleSystem";
  132801. SceneComponentConstants.NAME_GAMEPAD = "Gamepad";
  132802. SceneComponentConstants.NAME_SIMPLIFICATIONQUEUE = "SimplificationQueue";
  132803. SceneComponentConstants.NAME_GEOMETRYBUFFERRENDERER = "GeometryBufferRenderer";
  132804. SceneComponentConstants.NAME_DEPTHRENDERER = "DepthRenderer";
  132805. SceneComponentConstants.NAME_POSTPROCESSRENDERPIPELINEMANAGER = "PostProcessRenderPipelineManager";
  132806. SceneComponentConstants.NAME_SPRITE = "Sprite";
  132807. SceneComponentConstants.NAME_OUTLINERENDERER = "Outline";
  132808. SceneComponentConstants.NAME_PROCEDURALTEXTURE = "ProceduralTexture";
  132809. SceneComponentConstants.NAME_SHADOWGENERATOR = "ShadowGenerator";
  132810. SceneComponentConstants.NAME_OCTREE = "Octree";
  132811. SceneComponentConstants.NAME_PHYSICSENGINE = "PhysicsEngine";
  132812. SceneComponentConstants.NAME_AUDIO = "Audio";
  132813. SceneComponentConstants.STEP_ISREADYFORMESH_EFFECTLAYER = 0;
  132814. SceneComponentConstants.STEP_BEFOREEVALUATEACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132815. SceneComponentConstants.STEP_EVALUATESUBMESH_BOUNDINGBOXRENDERER = 0;
  132816. SceneComponentConstants.STEP_ACTIVEMESH_BOUNDINGBOXRENDERER = 0;
  132817. SceneComponentConstants.STEP_CAMERADRAWRENDERTARGET_EFFECTLAYER = 1;
  132818. SceneComponentConstants.STEP_BEFORECAMERADRAW_EFFECTLAYER = 0;
  132819. SceneComponentConstants.STEP_BEFORECAMERADRAW_LAYER = 1;
  132820. SceneComponentConstants.STEP_BEFORERENDERTARGETDRAW_LAYER = 0;
  132821. SceneComponentConstants.STEP_BEFORERENDERINGMESH_OUTLINE = 0;
  132822. SceneComponentConstants.STEP_AFTERRENDERINGMESH_OUTLINE = 0;
  132823. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_EFFECTLAYER_DRAW = 0;
  132824. SceneComponentConstants.STEP_AFTERRENDERINGGROUPDRAW_BOUNDINGBOXRENDERER = 1;
  132825. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_SIMPLIFICATIONQUEUE = 0;
  132826. SceneComponentConstants.STEP_BEFORECAMERAUPDATE_GAMEPAD = 1;
  132827. SceneComponentConstants.STEP_BEFORECLEAR_PROCEDURALTEXTURE = 0;
  132828. SceneComponentConstants.STEP_AFTERRENDERTARGETDRAW_LAYER = 0;
  132829. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER = 0;
  132830. SceneComponentConstants.STEP_AFTERCAMERADRAW_LENSFLARESYSTEM = 1;
  132831. SceneComponentConstants.STEP_AFTERCAMERADRAW_EFFECTLAYER_DRAW = 2;
  132832. SceneComponentConstants.STEP_AFTERCAMERADRAW_LAYER = 3;
  132833. SceneComponentConstants.STEP_AFTERRENDER_AUDIO = 0;
  132834. SceneComponentConstants.STEP_GATHERRENDERTARGETS_SHADOWGENERATOR = 0;
  132835. SceneComponentConstants.STEP_GATHERRENDERTARGETS_GEOMETRYBUFFERRENDERER = 1;
  132836. SceneComponentConstants.STEP_GATHERRENDERTARGETS_DEPTHRENDERER = 2;
  132837. SceneComponentConstants.STEP_GATHERRENDERTARGETS_POSTPROCESSRENDERPIPELINEMANAGER = 3;
  132838. SceneComponentConstants.STEP_GATHERACTIVECAMERARENDERTARGETS_DEPTHRENDERER = 0;
  132839. SceneComponentConstants.STEP_POINTERMOVE_SPRITE = 0;
  132840. SceneComponentConstants.STEP_POINTERDOWN_SPRITE = 0;
  132841. SceneComponentConstants.STEP_POINTERUP_SPRITE = 0;
  132842. return SceneComponentConstants;
  132843. }());
  132844. /**
  132845. * Repressentation of a stage in the scene (Basically a list of ordered steps)
  132846. * @hidden
  132847. */
  132848. var Stage = /** @class */ (function (_super) {
  132849. tslib__WEBPACK_IMPORTED_MODULE_0__["__extends"](Stage, _super);
  132850. /**
  132851. * Hide ctor from the rest of the world.
  132852. * @param items The items to add.
  132853. */
  132854. function Stage(items) {
  132855. return _super.apply(this, items) || this;
  132856. }
  132857. /**
  132858. * Creates a new Stage.
  132859. * @returns A new instance of a Stage
  132860. */
  132861. Stage.Create = function () {
  132862. return Object.create(Stage.prototype);
  132863. };
  132864. /**
  132865. * Registers a step in an ordered way in the targeted stage.
  132866. * @param index Defines the position to register the step in
  132867. * @param component Defines the component attached to the step
  132868. * @param action Defines the action to launch during the step
  132869. */
  132870. Stage.prototype.registerStep = function (index, component, action) {
  132871. var i = 0;
  132872. var maxIndex = Number.MAX_VALUE;
  132873. for (; i < this.length; i++) {
  132874. var step = this[i];
  132875. maxIndex = step.index;
  132876. if (index < maxIndex) {
  132877. break;
  132878. }
  132879. }
  132880. this.splice(i, 0, { index: index, component: component, action: action.bind(component) });
  132881. };
  132882. /**
  132883. * Clears all the steps from the stage.
  132884. */
  132885. Stage.prototype.clear = function () {
  132886. this.length = 0;
  132887. };
  132888. return Stage;
  132889. }(Array));
  132890. /***/ })
  132891. /******/ });
  132892. });
  132893. //# sourceMappingURL=babylon.max.js.map